|
3 | 3 | // BSD-style license that can be found in the LICENSE file.
|
4 | 4 |
|
5 | 5 | const jsRuntimeBlobPart1 = r'''
|
6 |
| -// Returns whether the `js-string` built-in is supported. |
7 |
| -function detectJsStringBuiltins() { |
8 |
| - let bytes = [ |
9 |
| - 0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, |
10 |
| - 0, 2, 23, 1, 14, 119, 97, 115, 109, 58, 106, 115, 45, |
11 |
| - 115, 116, 114, 105, 110, 103, 4, 99, 97, 115, 116, 0, 0 |
12 |
| - ]; |
13 |
| - return WebAssembly.validate( |
14 |
| - new Uint8Array(bytes), {builtins: ['js-string']}); |
15 |
| -} |
16 | 6 |
|
17 | 7 | // Compiles a dart2wasm-generated main module from `source` which can then
|
18 | 8 | // instantiatable via the `instantiate` method.
|
19 | 9 | //
|
20 | 10 | // `source` needs to be a `Response` object (or promise thereof) e.g. created
|
21 | 11 | // via the `fetch()` JS API.
|
22 | 12 | export async function compileStreaming(source) {
|
23 |
| - const builtins = detectJsStringBuiltins() |
24 |
| - ? {builtins: ['js-string']} : {}; |
| 13 | + const builtins = {builtins: ['js-string']}; |
25 | 14 | return new CompiledApp(
|
26 | 15 | await WebAssembly.compileStreaming(source, builtins), builtins);
|
27 | 16 | }
|
28 | 17 |
|
29 | 18 | // Compiles a dart2wasm-generated wasm modules from `bytes` which is then
|
30 | 19 | // instantiatable via the `instantiate` method.
|
31 | 20 | export async function compile(bytes) {
|
32 |
| - const builtins = detectJsStringBuiltins() |
33 |
| - ? {builtins: ['js-string']} : {}; |
| 21 | + const builtins = {builtins: ['js-string']}; |
34 | 22 | return new CompiledApp(await WebAssembly.compile(bytes, builtins), builtins);
|
35 | 23 | }
|
36 | 24 |
|
|
0 commit comments