@wasm-fmt/dart_fmt 0.1.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dart_fmt.d.ts +1 -0
- package/dart_fmt.js +8 -12
- package/dart_fmt.mjs +306 -292
- package/dart_fmt.support.js +1 -0
- package/dart_fmt.unopt.wasm +0 -0
- package/dart_fmt.unopt.wasm.map +6 -0
- package/dart_fmt.wasm +0 -0
- package/dart_fmt.wasm.map +1 -6
- package/jsr.jsonc +30 -0
- package/package.json +1 -1
- package/wasm-fmt-dart_fmt-0.3.0.tgz +0 -0
package/dart_fmt.mjs
CHANGED
|
@@ -1,12 +1,59 @@
|
|
|
1
|
+
// Compiles a dart2wasm-generated main module from `source` which can then
|
|
2
|
+
// instantiatable via the `instantiate` method.
|
|
3
|
+
//
|
|
4
|
+
// `source` needs to be a `Response` object (or promise thereof) e.g. created
|
|
5
|
+
// via the `fetch()` JS API.
|
|
6
|
+
export async function compileStreaming(source) {
|
|
7
|
+
const builtins = {builtins: ['js-string']};
|
|
8
|
+
return new CompiledApp(
|
|
9
|
+
await WebAssembly.compileStreaming(source, builtins), builtins);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Compiles a dart2wasm-generated wasm modules from `bytes` which is then
|
|
13
|
+
// instantiatable via the `instantiate` method.
|
|
14
|
+
export async function compile(bytes) {
|
|
15
|
+
const builtins = {builtins: ['js-string']};
|
|
16
|
+
return new CompiledApp(await WebAssembly.compile(bytes, builtins), builtins);
|
|
17
|
+
}
|
|
1
18
|
|
|
2
|
-
// `
|
|
3
|
-
//
|
|
4
|
-
// `
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
19
|
+
// DEPRECATED: Please use `compile` or `compileStreaming` to get a compiled app,
|
|
20
|
+
// use `instantiate` method to get an instantiated app and then call
|
|
21
|
+
// `invokeMain` to invoke the main function.
|
|
22
|
+
export async function instantiate(modulePromise, importObjectPromise) {
|
|
23
|
+
var moduleOrCompiledApp = await modulePromise;
|
|
24
|
+
if (!(moduleOrCompiledApp instanceof CompiledApp)) {
|
|
25
|
+
moduleOrCompiledApp = new CompiledApp(moduleOrCompiledApp);
|
|
26
|
+
}
|
|
27
|
+
const instantiatedApp = await moduleOrCompiledApp.instantiate(await importObjectPromise);
|
|
28
|
+
return instantiatedApp.instantiatedModule;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// DEPRECATED: Please use `compile` or `compileStreaming` to get a compiled app,
|
|
32
|
+
// use `instantiate` method to get an instantiated app and then call
|
|
33
|
+
// `invokeMain` to invoke the main function.
|
|
34
|
+
export const invoke = (moduleInstance, ...args) => {
|
|
35
|
+
moduleInstance.exports.$invokeMain(args);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
class CompiledApp {
|
|
39
|
+
constructor(module, builtins) {
|
|
40
|
+
this.module = module;
|
|
41
|
+
this.builtins = builtins;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// The second argument is an options object containing:
|
|
45
|
+
// `loadDeferredWasm` is a JS function that takes a module name matching a
|
|
46
|
+
// wasm file produced by the dart2wasm compiler and returns the bytes to
|
|
47
|
+
// load the module. These bytes can be in either a format supported by
|
|
48
|
+
// `WebAssembly.compile` or `WebAssembly.compileStreaming`.
|
|
49
|
+
// `loadDynamicModule` is a JS function that takes two string names matching,
|
|
50
|
+
// in order, a wasm file produced by the dart2wasm compiler during dynamic
|
|
51
|
+
// module compilation and a corresponding js file produced by the same
|
|
52
|
+
// compilation. It should return a JS Array containing 2 elements. The first
|
|
53
|
+
// should be the bytes for the wasm module in a format supported by
|
|
54
|
+
// `WebAssembly.compile` or `WebAssembly.compileStreaming`. The second
|
|
55
|
+
// should be the result of using the JS 'import' API on the js file path.
|
|
56
|
+
async instantiate(additionalImports, {loadDeferredWasm, loadDynamicModule} = {}) {
|
|
10
57
|
let dartInstance;
|
|
11
58
|
|
|
12
59
|
// Prints to the console
|
|
@@ -24,20 +71,7 @@ export const instantiate = async (modulePromise, importObjectPromise) => {
|
|
|
24
71
|
return;
|
|
25
72
|
}
|
|
26
73
|
|
|
27
|
-
throw "Unable to print message: " +
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Converts a Dart List to a JS array. Any Dart objects will be converted, but
|
|
31
|
-
// this will be cheap for JSValues.
|
|
32
|
-
function arrayFromDartList(constructor, list) {
|
|
33
|
-
const exports = dartInstance.exports;
|
|
34
|
-
const read = exports.$listRead;
|
|
35
|
-
const length = exports.$listLength(list);
|
|
36
|
-
const array = new constructor(length);
|
|
37
|
-
for (let i = 0; i < length; i++) {
|
|
38
|
-
array[i] = read(list, i);
|
|
39
|
-
}
|
|
40
|
-
return array;
|
|
74
|
+
throw "Unable to print message: " + value;
|
|
41
75
|
}
|
|
42
76
|
|
|
43
77
|
// A special symbol attached to functions that wrap Dart functions.
|
|
@@ -51,301 +85,281 @@ export const instantiate = async (modulePromise, importObjectPromise) => {
|
|
|
51
85
|
|
|
52
86
|
// Imports
|
|
53
87
|
const dart2wasm = {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
88
|
+
_36: x0 => new Array(x0),
|
|
89
|
+
_38: x0 => x0.length,
|
|
90
|
+
_40: (x0,x1) => x0[x1],
|
|
91
|
+
_41: (x0,x1,x2) => { x0[x1] = x2 },
|
|
92
|
+
_45: (x0,x1,x2) => new DataView(x0,x1,x2),
|
|
93
|
+
_47: x0 => new Int8Array(x0),
|
|
94
|
+
_48: (x0,x1,x2) => new Uint8Array(x0,x1,x2),
|
|
95
|
+
_49: x0 => new Uint8Array(x0),
|
|
96
|
+
_51: x0 => new Uint8ClampedArray(x0),
|
|
97
|
+
_53: x0 => new Int16Array(x0),
|
|
98
|
+
_55: x0 => new Uint16Array(x0),
|
|
99
|
+
_57: x0 => new Int32Array(x0),
|
|
100
|
+
_59: x0 => new Uint32Array(x0),
|
|
101
|
+
_61: x0 => new Float32Array(x0),
|
|
102
|
+
_63: x0 => new Float64Array(x0),
|
|
103
|
+
_73: (s) => +s,
|
|
104
|
+
_77: s => {
|
|
105
|
+
if (!/^\s*[+-]?(?:Infinity|NaN|(?:\.\d+|\d+(?:\.\d*)?)(?:[eE][+-]?\d+)?)\s*$/.test(s)) {
|
|
106
|
+
return NaN;
|
|
107
|
+
}
|
|
108
|
+
return parseFloat(s);
|
|
109
|
+
},
|
|
110
|
+
_78: () => {
|
|
111
|
+
let stackString = new Error().stack.toString();
|
|
112
|
+
let frames = stackString.split('\n');
|
|
113
|
+
let drop = 2;
|
|
114
|
+
if (frames[0] === 'Error') {
|
|
115
|
+
drop += 1;
|
|
116
|
+
}
|
|
117
|
+
return frames.slice(drop).join('\n');
|
|
118
|
+
},
|
|
119
|
+
_82: () => {
|
|
120
|
+
// On browsers return `globalThis.location.href`
|
|
121
|
+
if (globalThis.location != null) {
|
|
122
|
+
return globalThis.location.href;
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
},
|
|
126
|
+
_83: () => {
|
|
79
127
|
return typeof process != "undefined" &&
|
|
80
128
|
Object.prototype.toString.call(process) == "[object process]" &&
|
|
81
129
|
process.platform == "win32"
|
|
82
130
|
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
_209: o => o instanceof Uint16Array,
|
|
154
|
-
_210: o => o instanceof Int32Array,
|
|
155
|
-
_211: o => o instanceof Uint32Array,
|
|
156
|
-
_212: o => o instanceof Float32Array,
|
|
157
|
-
_213: o => o instanceof Float64Array,
|
|
158
|
-
_214: o => o instanceof ArrayBuffer,
|
|
159
|
-
_215: o => o instanceof DataView,
|
|
160
|
-
_216: o => o instanceof Array,
|
|
161
|
-
_217: o => typeof o === 'function' && o[jsWrappedDartFunctionSymbol] === true,
|
|
162
|
-
_220: o => o instanceof RegExp,
|
|
163
|
-
_221: (l, r) => l === r,
|
|
164
|
-
_222: o => o,
|
|
165
|
-
_223: o => o,
|
|
166
|
-
_224: o => o,
|
|
167
|
-
_225: b => !!b,
|
|
168
|
-
_226: o => o.length,
|
|
169
|
-
_229: (o, i) => o[i],
|
|
170
|
-
_230: f => f.dartFunction,
|
|
171
|
-
_231: l => arrayFromDartList(Int8Array, l),
|
|
172
|
-
_232: (data, length) => {
|
|
173
|
-
const jsBytes = new Uint8Array(length);
|
|
174
|
-
const getByte = dartInstance.exports.$uint8ListGet;
|
|
175
|
-
for (let i = 0; i < length; i++) {
|
|
176
|
-
jsBytes[i] = getByte(data, i);
|
|
177
|
-
}
|
|
178
|
-
return jsBytes;
|
|
179
|
-
},
|
|
180
|
-
_233: l => arrayFromDartList(Uint8ClampedArray, l),
|
|
181
|
-
_234: l => arrayFromDartList(Int16Array, l),
|
|
182
|
-
_235: l => arrayFromDartList(Uint16Array, l),
|
|
183
|
-
_236: l => arrayFromDartList(Int32Array, l),
|
|
184
|
-
_237: l => arrayFromDartList(Uint32Array, l),
|
|
185
|
-
_238: l => arrayFromDartList(Float32Array, l),
|
|
186
|
-
_239: l => arrayFromDartList(Float64Array, l),
|
|
187
|
-
_240: (data, length) => {
|
|
188
|
-
const read = dartInstance.exports.$byteDataGetUint8;
|
|
189
|
-
const view = new DataView(new ArrayBuffer(length));
|
|
190
|
-
for (let i = 0; i < length; i++) {
|
|
191
|
-
view.setUint8(i, read(data, i));
|
|
192
|
-
}
|
|
193
|
-
return view;
|
|
194
|
-
},
|
|
195
|
-
_241: l => arrayFromDartList(Array, l),
|
|
196
|
-
_242: (s, length) => {
|
|
197
|
-
if (length == 0) return '';
|
|
198
|
-
|
|
199
|
-
const read = dartInstance.exports.$stringRead1;
|
|
200
|
-
let result = '';
|
|
201
|
-
let index = 0;
|
|
202
|
-
const chunkLength = Math.min(length - index, 500);
|
|
203
|
-
let array = new Array(chunkLength);
|
|
204
|
-
while (index < length) {
|
|
205
|
-
const newChunkLength = Math.min(length - index, 500);
|
|
206
|
-
for (let i = 0; i < newChunkLength; i++) {
|
|
207
|
-
array[i] = read(s, index++);
|
|
208
|
-
}
|
|
209
|
-
if (newChunkLength < chunkLength) {
|
|
210
|
-
array = array.slice(0, newChunkLength);
|
|
211
|
-
}
|
|
212
|
-
result += String.fromCharCode(...array);
|
|
131
|
+
_99: s => JSON.stringify(s),
|
|
132
|
+
_100: s => printToConsole(s),
|
|
133
|
+
_101: (o, p, r) => o.replaceAll(p, () => r),
|
|
134
|
+
_103: Function.prototype.call.bind(String.prototype.toLowerCase),
|
|
135
|
+
_104: s => s.toUpperCase(),
|
|
136
|
+
_105: s => s.trim(),
|
|
137
|
+
_108: (string, times) => string.repeat(times),
|
|
138
|
+
_109: Function.prototype.call.bind(String.prototype.indexOf),
|
|
139
|
+
_110: (s, p, i) => s.lastIndexOf(p, i),
|
|
140
|
+
_111: (string, token) => string.split(token),
|
|
141
|
+
_112: Object.is,
|
|
142
|
+
_113: o => o instanceof Array,
|
|
143
|
+
_123: (a, b) => a == b ? 0 : (a > b ? 1 : -1),
|
|
144
|
+
_124: a => a.length,
|
|
145
|
+
_126: (a, i) => a[i],
|
|
146
|
+
_127: (a, i, v) => a[i] = v,
|
|
147
|
+
_132: o => o instanceof Uint8Array,
|
|
148
|
+
_133: (o, start, length) => new Uint8Array(o.buffer, o.byteOffset + start, length),
|
|
149
|
+
_134: o => o instanceof Int8Array,
|
|
150
|
+
_135: (o, start, length) => new Int8Array(o.buffer, o.byteOffset + start, length),
|
|
151
|
+
_136: o => o instanceof Uint8ClampedArray,
|
|
152
|
+
_137: (o, start, length) => new Uint8ClampedArray(o.buffer, o.byteOffset + start, length),
|
|
153
|
+
_138: o => o instanceof Uint16Array,
|
|
154
|
+
_139: (o, start, length) => new Uint16Array(o.buffer, o.byteOffset + start, length),
|
|
155
|
+
_140: o => o instanceof Int16Array,
|
|
156
|
+
_141: (o, start, length) => new Int16Array(o.buffer, o.byteOffset + start, length),
|
|
157
|
+
_142: o => o instanceof Uint32Array,
|
|
158
|
+
_143: (o, start, length) => new Uint32Array(o.buffer, o.byteOffset + start, length),
|
|
159
|
+
_144: o => o instanceof Int32Array,
|
|
160
|
+
_145: (o, start, length) => new Int32Array(o.buffer, o.byteOffset + start, length),
|
|
161
|
+
_148: o => o instanceof Float32Array,
|
|
162
|
+
_149: (o, start, length) => new Float32Array(o.buffer, o.byteOffset + start, length),
|
|
163
|
+
_150: o => o instanceof Float64Array,
|
|
164
|
+
_151: (o, start, length) => new Float64Array(o.buffer, o.byteOffset + start, length),
|
|
165
|
+
_152: (t, s) => t.set(s),
|
|
166
|
+
_154: (o) => new DataView(o.buffer, o.byteOffset, o.byteLength),
|
|
167
|
+
_156: o => o.buffer,
|
|
168
|
+
_157: o => o.byteOffset,
|
|
169
|
+
_158: Function.prototype.call.bind(Object.getOwnPropertyDescriptor(DataView.prototype, 'byteLength').get),
|
|
170
|
+
_159: (b, o) => new DataView(b, o),
|
|
171
|
+
_160: (b, o, l) => new DataView(b, o, l),
|
|
172
|
+
_161: Function.prototype.call.bind(DataView.prototype.getUint8),
|
|
173
|
+
_162: Function.prototype.call.bind(DataView.prototype.setUint8),
|
|
174
|
+
_163: Function.prototype.call.bind(DataView.prototype.getInt8),
|
|
175
|
+
_164: Function.prototype.call.bind(DataView.prototype.setInt8),
|
|
176
|
+
_165: Function.prototype.call.bind(DataView.prototype.getUint16),
|
|
177
|
+
_166: Function.prototype.call.bind(DataView.prototype.setUint16),
|
|
178
|
+
_167: Function.prototype.call.bind(DataView.prototype.getInt16),
|
|
179
|
+
_168: Function.prototype.call.bind(DataView.prototype.setInt16),
|
|
180
|
+
_169: Function.prototype.call.bind(DataView.prototype.getUint32),
|
|
181
|
+
_170: Function.prototype.call.bind(DataView.prototype.setUint32),
|
|
182
|
+
_171: Function.prototype.call.bind(DataView.prototype.getInt32),
|
|
183
|
+
_172: Function.prototype.call.bind(DataView.prototype.setInt32),
|
|
184
|
+
_177: Function.prototype.call.bind(DataView.prototype.getFloat32),
|
|
185
|
+
_178: Function.prototype.call.bind(DataView.prototype.setFloat32),
|
|
186
|
+
_179: Function.prototype.call.bind(DataView.prototype.getFloat64),
|
|
187
|
+
_180: Function.prototype.call.bind(DataView.prototype.setFloat64),
|
|
188
|
+
_181: () => new Object(),
|
|
189
|
+
_182: (x0,x1) => { x0.success = x1 },
|
|
190
|
+
_183: (x0,x1) => { x0.code = x1 },
|
|
191
|
+
_184: (x0,x1) => { x0.error = x1 },
|
|
192
|
+
_185: x0 => { format = x0 },
|
|
193
|
+
_186: f => finalizeWrapper(f, function(x0,x1,x2) { return dartInstance.exports._186(f,arguments.length,x0,x1,x2) }),
|
|
194
|
+
_203: (c) =>
|
|
195
|
+
queueMicrotask(() => dartInstance.exports.$invokeCallback(c)),
|
|
196
|
+
_205: (s, m) => {
|
|
197
|
+
try {
|
|
198
|
+
return new RegExp(s, m);
|
|
199
|
+
} catch (e) {
|
|
200
|
+
return String(e);
|
|
213
201
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
,
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
202
|
+
},
|
|
203
|
+
_206: (x0,x1) => x0.exec(x1),
|
|
204
|
+
_207: (x0,x1) => x0.test(x1),
|
|
205
|
+
_208: x0 => x0.pop(),
|
|
206
|
+
_210: o => o === undefined,
|
|
207
|
+
_212: o => typeof o === 'function' && o[jsWrappedDartFunctionSymbol] === true,
|
|
208
|
+
_215: o => o instanceof RegExp,
|
|
209
|
+
_216: (l, r) => l === r,
|
|
210
|
+
_217: o => o,
|
|
211
|
+
_218: o => o,
|
|
212
|
+
_219: o => o,
|
|
213
|
+
_220: b => !!b,
|
|
214
|
+
_221: o => o.length,
|
|
215
|
+
_223: (o, i) => o[i],
|
|
216
|
+
_224: f => f.dartFunction,
|
|
217
|
+
_231: (o, p) => o[p],
|
|
218
|
+
_235: o => String(o),
|
|
219
|
+
_236: (p, s, f) => p.then(s, (e) => f(e, e === undefined)),
|
|
220
|
+
_237: f => finalizeWrapper(f, function(x0) { return dartInstance.exports._237(f,arguments.length,x0) }),
|
|
221
|
+
_238: f => finalizeWrapper(f, function(x0,x1) { return dartInstance.exports._238(f,arguments.length,x0,x1) }),
|
|
222
|
+
_239: o => {
|
|
223
|
+
if (o === undefined) return 1;
|
|
224
|
+
var type = typeof o;
|
|
225
|
+
if (type === 'boolean') return 2;
|
|
226
|
+
if (type === 'number') return 3;
|
|
227
|
+
if (type === 'string') return 4;
|
|
228
|
+
if (o instanceof Array) return 5;
|
|
229
|
+
if (ArrayBuffer.isView(o)) {
|
|
230
|
+
if (o instanceof Int8Array) return 6;
|
|
231
|
+
if (o instanceof Uint8Array) return 7;
|
|
232
|
+
if (o instanceof Uint8ClampedArray) return 8;
|
|
233
|
+
if (o instanceof Int16Array) return 9;
|
|
234
|
+
if (o instanceof Uint16Array) return 10;
|
|
235
|
+
if (o instanceof Int32Array) return 11;
|
|
236
|
+
if (o instanceof Uint32Array) return 12;
|
|
237
|
+
if (o instanceof Float32Array) return 13;
|
|
238
|
+
if (o instanceof Float64Array) return 14;
|
|
239
|
+
if (o instanceof DataView) return 15;
|
|
229
240
|
}
|
|
230
|
-
if (
|
|
231
|
-
|
|
241
|
+
if (o instanceof ArrayBuffer) return 16;
|
|
242
|
+
// Feature check for `SharedArrayBuffer` before doing a type-check.
|
|
243
|
+
if (globalThis.SharedArrayBuffer !== undefined &&
|
|
244
|
+
o instanceof SharedArrayBuffer) {
|
|
245
|
+
return 17;
|
|
232
246
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
let range = 0;
|
|
241
|
-
for (let i = 0; i < length; i++) {
|
|
242
|
-
range |= s.codePointAt(i);
|
|
243
|
-
}
|
|
244
|
-
const exports = dartInstance.exports;
|
|
245
|
-
if (range < 256) {
|
|
246
|
-
if (length <= 10) {
|
|
247
|
-
if (length == 1) {
|
|
248
|
-
return exports.$stringAllocate1_1(s.codePointAt(0));
|
|
249
|
-
}
|
|
250
|
-
if (length == 2) {
|
|
251
|
-
return exports.$stringAllocate1_2(s.codePointAt(0), s.codePointAt(1));
|
|
252
|
-
}
|
|
253
|
-
if (length == 3) {
|
|
254
|
-
return exports.$stringAllocate1_3(s.codePointAt(0), s.codePointAt(1), s.codePointAt(2));
|
|
255
|
-
}
|
|
256
|
-
if (length == 4) {
|
|
257
|
-
return exports.$stringAllocate1_4(s.codePointAt(0), s.codePointAt(1), s.codePointAt(2), s.codePointAt(3));
|
|
258
|
-
}
|
|
259
|
-
if (length == 5) {
|
|
260
|
-
return exports.$stringAllocate1_5(s.codePointAt(0), s.codePointAt(1), s.codePointAt(2), s.codePointAt(3), s.codePointAt(4));
|
|
261
|
-
}
|
|
262
|
-
if (length == 6) {
|
|
263
|
-
return exports.$stringAllocate1_6(s.codePointAt(0), s.codePointAt(1), s.codePointAt(2), s.codePointAt(3), s.codePointAt(4), s.codePointAt(5));
|
|
264
|
-
}
|
|
265
|
-
if (length == 7) {
|
|
266
|
-
return exports.$stringAllocate1_7(s.codePointAt(0), s.codePointAt(1), s.codePointAt(2), s.codePointAt(3), s.codePointAt(4), s.codePointAt(5), s.codePointAt(6));
|
|
267
|
-
}
|
|
268
|
-
if (length == 8) {
|
|
269
|
-
return exports.$stringAllocate1_8(s.codePointAt(0), s.codePointAt(1), s.codePointAt(2), s.codePointAt(3), s.codePointAt(4), s.codePointAt(5), s.codePointAt(6), s.codePointAt(7));
|
|
270
|
-
}
|
|
271
|
-
if (length == 9) {
|
|
272
|
-
return exports.$stringAllocate1_9(s.codePointAt(0), s.codePointAt(1), s.codePointAt(2), s.codePointAt(3), s.codePointAt(4), s.codePointAt(5), s.codePointAt(6), s.codePointAt(7), s.codePointAt(8));
|
|
273
|
-
}
|
|
274
|
-
if (length == 10) {
|
|
275
|
-
return exports.$stringAllocate1_10(s.codePointAt(0), s.codePointAt(1), s.codePointAt(2), s.codePointAt(3), s.codePointAt(4), s.codePointAt(5), s.codePointAt(6), s.codePointAt(7), s.codePointAt(8), s.codePointAt(9));
|
|
276
|
-
}
|
|
247
|
+
if (o instanceof Promise) return 18;
|
|
248
|
+
return 19;
|
|
249
|
+
},
|
|
250
|
+
_244: (jsArray, jsArrayOffset, wasmArray, wasmArrayOffset, length) => {
|
|
251
|
+
const getValue = dartInstance.exports.$wasmI8ArrayGet;
|
|
252
|
+
for (let i = 0; i < length; i++) {
|
|
253
|
+
jsArray[jsArrayOffset + i] = getValue(wasmArray, wasmArrayOffset + i);
|
|
277
254
|
}
|
|
278
|
-
|
|
279
|
-
|
|
255
|
+
},
|
|
256
|
+
_246: (jsArray, jsArrayOffset, wasmArray, wasmArrayOffset, length) => {
|
|
257
|
+
const getValue = dartInstance.exports.$wasmI16ArrayGet;
|
|
280
258
|
for (let i = 0; i < length; i++) {
|
|
281
|
-
|
|
259
|
+
jsArray[jsArrayOffset + i] = getValue(wasmArray, wasmArrayOffset + i);
|
|
282
260
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
const
|
|
286
|
-
const write = exports.$stringWrite2;
|
|
261
|
+
},
|
|
262
|
+
_248: (jsArray, jsArrayOffset, wasmArray, wasmArrayOffset, length) => {
|
|
263
|
+
const getValue = dartInstance.exports.$wasmI32ArrayGet;
|
|
287
264
|
for (let i = 0; i < length; i++) {
|
|
288
|
-
|
|
265
|
+
jsArray[jsArrayOffset + i] = getValue(wasmArray, wasmArrayOffset + i);
|
|
289
266
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
_271: x0 => x0.dotAll,
|
|
306
|
-
_272: (x0,x1) => x0.lastIndex = x1
|
|
267
|
+
},
|
|
268
|
+
_254: x0 => new ArrayBuffer(x0),
|
|
269
|
+
_257: x0 => x0.index,
|
|
270
|
+
_259: x0 => x0.flags,
|
|
271
|
+
_260: x0 => x0.multiline,
|
|
272
|
+
_261: x0 => x0.ignoreCase,
|
|
273
|
+
_262: x0 => x0.unicode,
|
|
274
|
+
_263: x0 => x0.dotAll,
|
|
275
|
+
_264: (x0,x1) => { x0.lastIndex = x1 },
|
|
276
|
+
_269: x0 => x0.random(),
|
|
277
|
+
_272: () => globalThis.Math,
|
|
278
|
+
_273: Function.prototype.call.bind(Number.prototype.toString),
|
|
279
|
+
_274: Function.prototype.call.bind(BigInt.prototype.toString),
|
|
280
|
+
_275: Function.prototype.call.bind(Number.prototype.toString),
|
|
281
|
+
|
|
307
282
|
};
|
|
308
283
|
|
|
309
284
|
const baseImports = {
|
|
310
|
-
|
|
311
|
-
|
|
285
|
+
dart2wasm: dart2wasm,
|
|
286
|
+
Math: Math,
|
|
287
|
+
Date: Date,
|
|
288
|
+
Object: Object,
|
|
289
|
+
Array: Array,
|
|
290
|
+
Reflect: Reflect,
|
|
291
|
+
S: new Proxy({}, { get(_, prop) { return prop; } }),
|
|
312
292
|
|
|
313
|
-
Math: Math,
|
|
314
|
-
Date: Date,
|
|
315
|
-
Object: Object,
|
|
316
|
-
Array: Array,
|
|
317
|
-
Reflect: Reflect,
|
|
318
293
|
};
|
|
319
294
|
|
|
320
295
|
const jsStringPolyfill = {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
296
|
+
"charCodeAt": (s, i) => s.charCodeAt(i),
|
|
297
|
+
"compare": (s1, s2) => {
|
|
298
|
+
if (s1 < s2) return -1;
|
|
299
|
+
if (s1 > s2) return 1;
|
|
300
|
+
return 0;
|
|
301
|
+
},
|
|
302
|
+
"concat": (s1, s2) => s1 + s2,
|
|
303
|
+
"equals": (s1, s2) => s1 === s2,
|
|
304
|
+
"fromCharCode": (i) => String.fromCharCode(i),
|
|
305
|
+
"length": (s) => s?.length||0,
|
|
306
|
+
"substring": (s, a, b) => s.substring(a, b),
|
|
307
|
+
"fromCharCodeArray": (a, start, end) => {
|
|
308
|
+
if (end <= start) return '';
|
|
309
|
+
|
|
310
|
+
const read = dartInstance.exports.$wasmI16ArrayGet;
|
|
311
|
+
let result = '';
|
|
312
|
+
let index = start;
|
|
313
|
+
const chunkLength = Math.min(end - index, 500);
|
|
314
|
+
let array = new Array(chunkLength);
|
|
315
|
+
while (index < end) {
|
|
316
|
+
const newChunkLength = Math.min(end - index, 500);
|
|
317
|
+
for (let i = 0; i < newChunkLength; i++) {
|
|
318
|
+
array[i] = read(a, index++);
|
|
319
|
+
}
|
|
320
|
+
if (newChunkLength < chunkLength) {
|
|
321
|
+
array = array.slice(0, newChunkLength);
|
|
322
|
+
}
|
|
323
|
+
result += String.fromCharCode(...array);
|
|
324
|
+
}
|
|
325
|
+
return result;
|
|
326
|
+
},
|
|
327
|
+
"intoCharCodeArray": (s, a, start) => {
|
|
328
|
+
if (s === '') return 0;
|
|
329
|
+
|
|
330
|
+
const write = dartInstance.exports.$wasmI16ArraySet;
|
|
331
|
+
for (var i = 0; i < s.length; ++i) {
|
|
332
|
+
write(a, start++, s.charCodeAt(i));
|
|
333
|
+
}
|
|
334
|
+
return s.length;
|
|
335
|
+
},
|
|
336
|
+
"test": (s) => typeof s == "string",
|
|
332
337
|
};
|
|
333
338
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
dartInstance = await WebAssembly.instantiate(this.module, {
|
|
343
|
+
...baseImports,
|
|
344
|
+
...additionalImports,
|
|
345
|
+
|
|
346
|
+
"wasm:js-string": jsStringPolyfill,
|
|
338
347
|
});
|
|
339
348
|
|
|
340
|
-
return dartInstance;
|
|
349
|
+
return new InstantiatedApp(this, dartInstance);
|
|
350
|
+
}
|
|
341
351
|
}
|
|
342
352
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
353
|
+
class InstantiatedApp {
|
|
354
|
+
constructor(compiledApp, instantiatedModule) {
|
|
355
|
+
this.compiledApp = compiledApp;
|
|
356
|
+
this.instantiatedModule = instantiatedModule;
|
|
357
|
+
}
|
|
349
358
|
|
|
359
|
+
// Call the main function with the given arguments.
|
|
360
|
+
invokeMain(...args) {
|
|
361
|
+
this.instantiatedModule.exports.$invokeMain(args);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
350
364
|
|
|
351
365
|
export let format;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,95,1,120,0])))
|
|
Binary file
|