@wasm-fmt/dart_fmt 0.1.0 → 0.1.2

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.mjs CHANGED
@@ -1,4 +1,3 @@
1
- let buildArgsList;
2
1
 
3
2
  // `modulePromise` is a promise to the `WebAssembly.module` object to be
4
3
  // instantiated.
@@ -10,224 +9,57 @@
10
9
  export const instantiate = async (modulePromise, importObjectPromise) => {
11
10
  let dartInstance;
12
11
 
13
- function stringFromDartString(string) {
14
- const totalLength = dartInstance.exports.$stringLength(string);
15
- let result = '';
16
- let index = 0;
17
- while (index < totalLength) {
18
- let chunkLength = Math.min(totalLength - index, 0xFFFF);
19
- const array = new Array(chunkLength);
20
- for (let i = 0; i < chunkLength; i++) {
21
- array[i] = dartInstance.exports.$stringRead(string, index++);
22
- }
23
- result += String.fromCharCode(...array);
24
- }
25
- return result;
26
- }
12
+ // Prints to the console
13
+ function printToConsole(value) {
14
+ if (typeof dartPrint == "function") {
15
+ dartPrint(value);
16
+ return;
17
+ }
18
+ if (typeof console == "object" && typeof console.log != "undefined") {
19
+ console.log(value);
20
+ return;
21
+ }
22
+ if (typeof print == "function") {
23
+ print(value);
24
+ return;
25
+ }
27
26
 
28
- function stringToDartString(string) {
29
- const length = string.length;
30
- let range = 0;
31
- for (let i = 0; i < length; i++) {
32
- range |= string.codePointAt(i);
33
- }
34
- if (range < 256) {
35
- const dartString = dartInstance.exports.$stringAllocate1(length);
36
- for (let i = 0; i < length; i++) {
37
- dartInstance.exports.$stringWrite1(dartString, i, string.codePointAt(i));
38
- }
39
- return dartString;
40
- } else {
41
- const dartString = dartInstance.exports.$stringAllocate2(length);
42
- for (let i = 0; i < length; i++) {
43
- dartInstance.exports.$stringWrite2(dartString, i, string.charCodeAt(i));
44
- }
45
- return dartString;
46
- }
27
+ throw "Unable to print message: " + js;
47
28
  }
48
29
 
49
- // Converts a Dart List to a JS array. Any Dart objects will be converted, but
30
+ // Converts a Dart List to a JS array. Any Dart objects will be converted, but
50
31
  // this will be cheap for JSValues.
51
32
  function arrayFromDartList(constructor, list) {
52
- const length = dartInstance.exports.$listLength(list);
53
- const array = new constructor(length);
54
- for (let i = 0; i < length; i++) {
55
- array[i] = dartInstance.exports.$listRead(list, i);
56
- }
57
- return array;
58
- }
59
-
60
- buildArgsList = function(list) {
61
- const dartList = dartInstance.exports.$makeStringList();
62
- for (let i = 0; i < list.length; i++) {
63
- dartInstance.exports.$listAdd(dartList, stringToDartString(list[i]));
64
- }
65
- return dartList;
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;
66
41
  }
67
42
 
68
43
  // A special symbol attached to functions that wrap Dart functions.
69
44
  const jsWrappedDartFunctionSymbol = Symbol("JSWrappedDartFunction");
70
45
 
71
46
  function finalizeWrapper(dartFunction, wrapped) {
72
- wrapped.dartFunction = dartFunction;
73
- wrapped[jsWrappedDartFunctionSymbol] = true;
74
- return wrapped;
75
- }
76
-
77
- if (WebAssembly.String === undefined) {
78
- console.log("WebAssembly.String is undefined, adding polyfill");
79
- WebAssembly.String = {
80
- "charCodeAt": (s, i) => s.charCodeAt(i),
81
- "compare": (s1, s2) => {
82
- if (s1 < s2) return -1;
83
- if (s1 > s2) return 1;
84
- return 0;
85
- },
86
- "concat": (s1, s2) => s1 + s2,
87
- "equals": (s1, s2) => s1 === s2,
88
- "fromCharCode": (i) => String.fromCharCode(i),
89
- "length": (s) => s.length,
90
- "substring": (s, a, b) => s.substring(a, b),
91
- };
47
+ wrapped.dartFunction = dartFunction;
48
+ wrapped[jsWrappedDartFunctionSymbol] = true;
49
+ return wrapped;
92
50
  }
93
51
 
94
52
  // Imports
95
53
  const dart2wasm = {
96
54
 
97
- _69: s => stringToDartString(JSON.stringify(stringFromDartString(s))),
98
- _70: s => console.log(stringFromDartString(s)),
99
- _173: o => o === undefined,
100
- _174: o => typeof o === 'boolean',
101
- _175: o => typeof o === 'number',
102
- _177: o => typeof o === 'string',
103
- _180: o => o instanceof Int8Array,
104
- _181: o => o instanceof Uint8Array,
105
- _182: o => o instanceof Uint8ClampedArray,
106
- _183: o => o instanceof Int16Array,
107
- _184: o => o instanceof Uint16Array,
108
- _185: o => o instanceof Int32Array,
109
- _186: o => o instanceof Uint32Array,
110
- _187: o => o instanceof Float32Array,
111
- _188: o => o instanceof Float64Array,
112
- _189: o => o instanceof ArrayBuffer,
113
- _190: o => o instanceof DataView,
114
- _191: o => o instanceof Array,
115
- _192: o => typeof o === 'function' && o[jsWrappedDartFunctionSymbol] === true,
116
- _195: o => o instanceof RegExp,
117
- _196: (l, r) => l === r,
118
- _197: o => o,
119
- _198: o => o,
120
- _199: o => o,
121
- _200: b => !!b,
122
- _201: o => o.length,
123
- _204: (o, i) => o[i],
124
- _205: f => f.dartFunction,
125
- _206: l => arrayFromDartList(Int8Array, l),
126
- _207: l => arrayFromDartList(Uint8Array, l),
127
- _208: l => arrayFromDartList(Uint8ClampedArray, l),
128
- _209: l => arrayFromDartList(Int16Array, l),
129
- _210: l => arrayFromDartList(Uint16Array, l),
130
- _211: l => arrayFromDartList(Int32Array, l),
131
- _212: l => arrayFromDartList(Uint32Array, l),
132
- _213: l => arrayFromDartList(Float32Array, l),
133
- _214: l => arrayFromDartList(Float64Array, l),
134
- _215: (data, length) => {
135
- const view = new DataView(new ArrayBuffer(length));
136
- for (let i = 0; i < length; i++) {
137
- view.setUint8(i, dartInstance.exports.$byteDataGetUint8(data, i));
138
- }
139
- return view;
140
- },
141
- _216: l => arrayFromDartList(Array, l),
142
- _217: stringFromDartString,
143
- _218: stringToDartString,
144
- _225: (o, p) => o[p],
145
- _162: (s, m) => {
146
- try {
147
- return new RegExp(s, m);
148
- } catch (e) {
149
- return String(e);
150
- }
151
- },
152
- _163: (x0,x1) => x0.exec(x1),
153
- _164: (x0,x1) => x0.test(x1),
154
- _165: (x0,x1) => x0.exec(x1),
155
- _166: (x0,x1) => x0.exec(x1),
156
- _167: x0 => x0.pop(),
157
- _221: l => new Array(l),
158
- _229: o => String(o),
159
- _234: x0 => x0.index,
160
- _236: x0 => x0.length,
161
- _238: (x0,x1) => x0[x1],
162
- _240: (x0,x1) => x0.exec(x1),
163
- _242: x0 => x0.flags,
164
- _243: x0 => x0.multiline,
165
- _244: x0 => x0.ignoreCase,
166
- _245: x0 => x0.unicode,
167
- _246: x0 => x0.dotAll,
168
- _247: (x0,x1) => x0.lastIndex = x1,
169
- _122: Object.is,
170
- _124: WebAssembly.String.concat,
171
- _132: (o) => new DataView(o.buffer, o.byteOffset, o.byteLength),
172
- _82: (a, i) => a.push(i),
173
- _92: (a, b) => a == b ? 0 : (a > b ? 1 : -1),
174
- _93: a => a.length,
175
- _95: (a, i) => a[i],
176
- _96: (a, i, v) => a[i] = v,
177
- _98: a => a.join(''),
178
- _101: (s, t) => s.split(t),
179
- _102: s => s.toLowerCase(),
180
- _103: s => s.toUpperCase(),
181
- _104: s => s.trim(),
182
- _106: s => s.trimRight(),
183
- _108: (s, p, i) => s.indexOf(p, i),
184
- _109: (s, p, i) => s.lastIndexOf(p, i),
185
- _111: (o, start, length) => new Uint8Array(o.buffer, o.byteOffset + start, length),
186
- _112: (o, start, length) => new Int8Array(o.buffer, o.byteOffset + start, length),
187
- _113: (o, start, length) => new Uint8ClampedArray(o.buffer, o.byteOffset + start, length),
188
- _114: (o, start, length) => new Uint16Array(o.buffer, o.byteOffset + start, length),
189
- _115: (o, start, length) => new Int16Array(o.buffer, o.byteOffset + start, length),
190
- _116: (o, start, length) => new Uint32Array(o.buffer, o.byteOffset + start, length),
191
- _117: (o, start, length) => new Int32Array(o.buffer, o.byteOffset + start, length),
192
- _120: (o, start, length) => new Float32Array(o.buffer, o.byteOffset + start, length),
193
- _121: (o, start, length) => new Float64Array(o.buffer, o.byteOffset + start, length),
194
- _123: WebAssembly.String.charCodeAt,
195
- _125: WebAssembly.String.substring,
196
- _126: WebAssembly.String.length,
197
- _127: WebAssembly.String.equals,
198
- _128: WebAssembly.String.compare,
199
- _129: WebAssembly.String.fromCharCode,
200
- _136: Function.prototype.call.bind(Object.getOwnPropertyDescriptor(DataView.prototype, 'byteLength').get),
201
- _137: (b, o) => new DataView(b, o),
202
- _139: Function.prototype.call.bind(DataView.prototype.getUint8),
203
- _140: Function.prototype.call.bind(DataView.prototype.setUint8),
204
- _141: Function.prototype.call.bind(DataView.prototype.getInt8),
205
- _142: Function.prototype.call.bind(DataView.prototype.setInt8),
206
- _143: Function.prototype.call.bind(DataView.prototype.getUint16),
207
- _144: Function.prototype.call.bind(DataView.prototype.setUint16),
208
- _145: Function.prototype.call.bind(DataView.prototype.getInt16),
209
- _146: Function.prototype.call.bind(DataView.prototype.setInt16),
210
- _147: Function.prototype.call.bind(DataView.prototype.getUint32),
211
- _148: Function.prototype.call.bind(DataView.prototype.setUint32),
212
- _149: Function.prototype.call.bind(DataView.prototype.getInt32),
213
- _150: Function.prototype.call.bind(DataView.prototype.setInt32),
214
- _155: Function.prototype.call.bind(DataView.prototype.getFloat32),
215
- _156: Function.prototype.call.bind(DataView.prototype.setFloat32),
216
- _157: Function.prototype.call.bind(DataView.prototype.getFloat64),
217
- _158: Function.prototype.call.bind(DataView.prototype.setFloat64),
218
- _80: (c) =>
219
- queueMicrotask(() => dartInstance.exports.$invokeCallback(c)),
220
- _159: s => stringToDartString(stringFromDartString(s).toUpperCase()),
221
- _160: s => stringToDartString(stringFromDartString(s).toLowerCase()),
222
- _45: v => stringToDartString(v.toString()),
223
- _59: s => {
224
- const jsSource = stringFromDartString(s);
225
- if (!/^\s*[+-]?(?:Infinity|NaN|(?:\.\d+|\d+(?:\.\d*)?)(?:[eE][+-]?\d+)?)\s*$/.test(jsSource)) {
55
+ _49: v => v.toString(),
56
+ _64: s => {
57
+ if (!/^\s*[+-]?(?:Infinity|NaN|(?:\.\d+|\d+(?:\.\d*)?)(?:[eE][+-]?\d+)?)\s*$/.test(s)) {
226
58
  return NaN;
227
59
  }
228
- return parseFloat(jsSource);
60
+ return parseFloat(s);
229
61
  },
230
- _60: () => {
62
+ _65: () => {
231
63
  let stackString = new Error().stack.toString();
232
64
  let frames = stackString.split('\n');
233
65
  let drop = 2;
@@ -236,33 +68,273 @@ _60: () => {
236
68
  }
237
69
  return frames.slice(drop).join('\n');
238
70
  },
239
- _64: () => {
71
+ _69: () => {
240
72
  // On browsers return `globalThis.location.href`
241
73
  if (globalThis.location != null) {
242
- return stringToDartString(globalThis.location.href);
74
+ return globalThis.location.href;
243
75
  }
244
76
  return null;
245
77
  },
246
- _65: () => {
247
- return typeof process != undefined &&
78
+ _70: () => {
79
+ return typeof process != "undefined" &&
248
80
  Object.prototype.toString.call(process) == "[object process]" &&
249
81
  process.platform == "win32"
82
+ },
83
+ _85: s => JSON.stringify(s),
84
+ _86: s => printToConsole(s),
85
+ _87: a => a.join(''),
86
+ _90: (s, t) => s.split(t),
87
+ _91: s => s.toLowerCase(),
88
+ _92: s => s.toUpperCase(),
89
+ _93: s => s.trim(),
90
+ _95: s => s.trimRight(),
91
+ _97: (s, p, i) => s.indexOf(p, i),
92
+ _98: (s, p, i) => s.lastIndexOf(p, i),
93
+ _100: Object.is,
94
+ _101: s => s.toUpperCase(),
95
+ _102: s => s.toLowerCase(),
96
+ _103: (a, i) => a.push(i),
97
+ _113: (a, b) => a == b ? 0 : (a > b ? 1 : -1),
98
+ _114: a => a.length,
99
+ _116: (a, i) => a[i],
100
+ _117: (a, i, v) => a[i] = v,
101
+ _120: (o, start, length) => new Uint8Array(o.buffer, o.byteOffset + start, length),
102
+ _121: (o, start, length) => new Int8Array(o.buffer, o.byteOffset + start, length),
103
+ _122: (o, start, length) => new Uint8ClampedArray(o.buffer, o.byteOffset + start, length),
104
+ _123: (o, start, length) => new Uint16Array(o.buffer, o.byteOffset + start, length),
105
+ _124: (o, start, length) => new Int16Array(o.buffer, o.byteOffset + start, length),
106
+ _125: (o, start, length) => new Uint32Array(o.buffer, o.byteOffset + start, length),
107
+ _126: (o, start, length) => new Int32Array(o.buffer, o.byteOffset + start, length),
108
+ _129: (o, start, length) => new Float32Array(o.buffer, o.byteOffset + start, length),
109
+ _130: (o, start, length) => new Float64Array(o.buffer, o.byteOffset + start, length),
110
+ _133: (o) => new DataView(o.buffer, o.byteOffset, o.byteLength),
111
+ _137: Function.prototype.call.bind(Object.getOwnPropertyDescriptor(DataView.prototype, 'byteLength').get),
112
+ _138: (b, o) => new DataView(b, o),
113
+ _140: Function.prototype.call.bind(DataView.prototype.getUint8),
114
+ _141: Function.prototype.call.bind(DataView.prototype.setUint8),
115
+ _142: Function.prototype.call.bind(DataView.prototype.getInt8),
116
+ _143: Function.prototype.call.bind(DataView.prototype.setInt8),
117
+ _144: Function.prototype.call.bind(DataView.prototype.getUint16),
118
+ _145: Function.prototype.call.bind(DataView.prototype.setUint16),
119
+ _146: Function.prototype.call.bind(DataView.prototype.getInt16),
120
+ _147: Function.prototype.call.bind(DataView.prototype.setInt16),
121
+ _148: Function.prototype.call.bind(DataView.prototype.getUint32),
122
+ _149: Function.prototype.call.bind(DataView.prototype.setUint32),
123
+ _150: Function.prototype.call.bind(DataView.prototype.getInt32),
124
+ _151: Function.prototype.call.bind(DataView.prototype.setInt32),
125
+ _156: Function.prototype.call.bind(DataView.prototype.getFloat32),
126
+ _157: Function.prototype.call.bind(DataView.prototype.setFloat32),
127
+ _158: Function.prototype.call.bind(DataView.prototype.getFloat64),
128
+ _159: Function.prototype.call.bind(DataView.prototype.setFloat64),
129
+ _165: x0 => format = x0,
130
+ _166: f => finalizeWrapper(f, function(x0,x1,x2) { return dartInstance.exports._166(f,arguments.length,x0,x1,x2) }),
131
+ _184: (c) =>
132
+ queueMicrotask(() => dartInstance.exports.$invokeCallback(c)),
133
+ _187: (s, m) => {
134
+ try {
135
+ return new RegExp(s, m);
136
+ } catch (e) {
137
+ return String(e);
138
+ }
139
+ },
140
+ _188: (x0,x1) => x0.exec(x1),
141
+ _189: (x0,x1) => x0.test(x1),
142
+ _190: (x0,x1) => x0.exec(x1),
143
+ _191: (x0,x1) => x0.exec(x1),
144
+ _192: x0 => x0.pop(),
145
+ _198: o => o === undefined,
146
+ _199: o => typeof o === 'boolean',
147
+ _200: o => typeof o === 'number',
148
+ _202: o => typeof o === 'string',
149
+ _205: o => o instanceof Int8Array,
150
+ _206: o => o instanceof Uint8Array,
151
+ _207: o => o instanceof Uint8ClampedArray,
152
+ _208: o => o instanceof Int16Array,
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);
213
+ }
214
+ return result;
250
215
  }
251
- };
216
+ ,
217
+ _243: (s, length) => {
218
+ if (length == 0) return '';
219
+
220
+ const read = dartInstance.exports.$stringRead2;
221
+ let result = '';
222
+ let index = 0;
223
+ const chunkLength = Math.min(length - index, 500);
224
+ let array = new Array(chunkLength);
225
+ while (index < length) {
226
+ const newChunkLength = Math.min(length - index, 500);
227
+ for (let i = 0; i < newChunkLength; i++) {
228
+ array[i] = read(s, index++);
229
+ }
230
+ if (newChunkLength < chunkLength) {
231
+ array = array.slice(0, newChunkLength);
232
+ }
233
+ result += String.fromCharCode(...array);
234
+ }
235
+ return result;
236
+ }
237
+ ,
238
+ _244: (s) => {
239
+ let length = s.length;
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
+ }
277
+ }
278
+ const dartString = exports.$stringAllocate1(length);
279
+ const write = exports.$stringWrite1;
280
+ for (let i = 0; i < length; i++) {
281
+ write(dartString, i, s.codePointAt(i));
282
+ }
283
+ return dartString;
284
+ } else {
285
+ const dartString = exports.$stringAllocate2(length);
286
+ const write = exports.$stringWrite2;
287
+ for (let i = 0; i < length; i++) {
288
+ write(dartString, i, s.charCodeAt(i));
289
+ }
290
+ return dartString;
291
+ }
292
+ }
293
+ ,
294
+ _247: l => new Array(l),
295
+ _251: (o, p) => o[p],
296
+ _255: o => String(o),
297
+ _260: x0 => x0.index,
298
+ _262: x0 => x0.length,
299
+ _264: (x0,x1) => x0[x1],
300
+ _265: (x0,x1) => x0.exec(x1),
301
+ _267: x0 => x0.flags,
302
+ _268: x0 => x0.multiline,
303
+ _269: x0 => x0.ignoreCase,
304
+ _270: x0 => x0.unicode,
305
+ _271: x0 => x0.dotAll,
306
+ _272: (x0,x1) => x0.lastIndex = x1
307
+ };
252
308
 
253
309
  const baseImports = {
254
310
  dart2wasm: dart2wasm,
255
311
 
256
-
257
- Math: Math,
312
+
313
+ Math: Math,
258
314
  Date: Date,
259
315
  Object: Object,
260
316
  Array: Array,
261
317
  Reflect: Reflect,
262
318
  };
319
+
320
+ const jsStringPolyfill = {
321
+ "charCodeAt": (s, i) => s.charCodeAt(i),
322
+ "compare": (s1, s2) => {
323
+ if (s1 < s2) return -1;
324
+ if (s1 > s2) return 1;
325
+ return 0;
326
+ },
327
+ "concat": (s1, s2) => s1 + s2,
328
+ "equals": (s1, s2) => s1 === s2,
329
+ "fromCharCode": (i) => String.fromCharCode(i),
330
+ "length": (s) => s?.length||0,
331
+ "substring": (s, a, b) => s.substring(a, b),
332
+ };
333
+
263
334
  dartInstance = await WebAssembly.instantiate(await modulePromise, {
264
335
  ...baseImports,
265
336
  ...(await importObjectPromise),
337
+ "wasm:js-string": jsStringPolyfill,
266
338
  });
267
339
 
268
340
  return dartInstance;
@@ -272,8 +344,8 @@ _65: () => {
272
344
  // `moduleInstance` is the instantiated dart2wasm module
273
345
  // `args` are any arguments that should be passed into the main function.
274
346
  export const invoke = (moduleInstance, ...args) => {
275
- const dartMain = moduleInstance.exports.$getMain();
276
- const dartArgs = buildArgsList(args);
277
- moduleInstance.exports.$invokeMain(dartMain, dartArgs);
347
+ moduleInstance.exports.$invokeMain(args);
278
348
  }
279
349
 
350
+
351
+ export let format;
package/dart_fmt.wasm CHANGED
Binary file