@wasm-fmt/dart_fmt 0.1.1 → 0.2.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/README.md CHANGED
@@ -29,8 +29,26 @@ console.log(formatted);
29
29
 
30
30
  For Vite users:
31
31
 
32
+ Add `"@wasm-fmt/dart_fmt"` to `optimizeDeps.exclude` in your vite config:
33
+
34
+ ```JSON
35
+ {
36
+ "optimizeDeps": {
37
+ "exclude": ["@wasm-fmt/dart_fmt"]
38
+ }
39
+ }
40
+ ```
41
+
42
+ <details>
43
+ <summary>
44
+ If you cannot change the vite config, you can use another import entry
45
+
46
+ </summary>
47
+
32
48
  ```JavaScript
33
49
  import init, { format } from "@wasm-fmt/dart_fmt/vite";
34
50
 
35
51
  // ...
36
52
  ```
53
+
54
+ </details>
package/dart_fmt.d.ts CHANGED
@@ -3,6 +3,7 @@ export function format(input: string, filename: string, config?: LayoutConfig):
3
3
  interface LayoutConfig {
4
4
  line_width?: number;
5
5
  line_ending?: "lf" | "crlf";
6
+ language_version?: string;
6
7
  }
7
8
 
8
9
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
package/dart_fmt.js CHANGED
@@ -1,22 +1,10 @@
1
- import { instantiate } from "./dart_fmt.mjs";
1
+ import { format as dart_fmt, instantiate, invoke } from "./dart_fmt.mjs";
2
2
 
3
3
  let wasm;
4
4
 
5
5
  function get_imports() {}
6
6
  function init_memory() {}
7
7
 
8
- // export function initSync(module) {
9
- // if (wasm !== undefined) return wasm;
10
-
11
- // const imports = get_imports();
12
-
13
- // init_memory(imports);
14
-
15
- // module = normalize(module);
16
-
17
- // return (wasm = instantiate(module));
18
- // }
19
-
20
8
  function normalize(module) {
21
9
  if (!(module instanceof WebAssembly.Module)) {
22
10
  return new WebAssembly.Module(module);
@@ -42,9 +30,13 @@ export default async function (input) {
42
30
 
43
31
  init_memory(imports);
44
32
 
45
- return (wasm = await load(await input)
33
+ wasm = await load(await input)
46
34
  .then(normalize)
47
- .then(instantiate));
35
+ .then(instantiate);
36
+
37
+ invoke(wasm);
38
+
39
+ return wasm;
48
40
  }
49
41
 
50
42
  async function load(module) {
@@ -70,43 +62,7 @@ async function load(module) {
70
62
  return module;
71
63
  }
72
64
 
73
- function stringFromDartString(string) {
74
- const totalLength = wasm.exports.$stringLength(string);
75
- let result = "";
76
- let index = 0;
77
- while (index < totalLength) {
78
- let chunkLength = Math.min(totalLength - index, 0xffff);
79
- const array = new Array(chunkLength);
80
- for (let i = 0; i < chunkLength; i++) {
81
- array[i] = wasm.exports.$stringRead(string, index++);
82
- }
83
- result += String.fromCharCode(...array);
84
- }
85
- return result;
86
- }
87
-
88
- function stringToDartString(string) {
89
- const length = string.length;
90
- let range = 0;
91
- for (let i = 0; i < length; i++) {
92
- range |= string.codePointAt(i);
93
- }
94
- if (range < 256) {
95
- const dartString = wasm.exports.$stringAllocate1(length);
96
- for (let i = 0; i < length; i++) {
97
- wasm.exports.$stringWrite1(dartString, i, string.codePointAt(i));
98
- }
99
- return dartString;
100
- } else {
101
- const dartString = wasm.exports.$stringAllocate2(length);
102
- for (let i = 0; i < length; i++) {
103
- wasm.exports.$stringWrite2(dartString, i, string.charCodeAt(i));
104
- }
105
- return dartString;
106
- }
107
- }
108
-
109
- export function format(source, filename, config = {}) {
65
+ export function format(source, filename = "stdin.dart", config = {}) {
110
66
  const options = { lineEnding: "\n" };
111
67
  if (config.line_width) {
112
68
  options.pageWidth = config.line_width;
@@ -114,14 +70,15 @@ export function format(source, filename, config = {}) {
114
70
  if (options.line_ending === "crlf") {
115
71
  options.lineEnding = "\r\n";
116
72
  }
73
+ if(options.language_version) {
74
+ options.languageVersion = options.language_version;
75
+ }
117
76
 
118
- const sourceString = stringToDartString(source);
119
- const filenameString = stringToDartString(filename);
120
- const configString = stringToDartString(JSON.stringify(options));
121
- const result = wasm.exports.format(
122
- sourceString,
123
- filenameString,
124
- configString,
125
- );
126
- return stringFromDartString(result);
77
+ const result = dart_fmt(source, filename, JSON.stringify(options));
78
+ const err = result[0] === "x";
79
+ const output = result.slice(1);
80
+ if (err) {
81
+ throw new Error(output);
82
+ }
83
+ return output;
127
84
  }
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,42 +9,6 @@ let buildArgsList;
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
- }
27
-
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
- }
47
- }
48
-
49
12
  // Prints to the console
50
13
  function printToConsole(value) {
51
14
  if (typeof dartPrint == "function") {
@@ -67,43 +30,36 @@ export const instantiate = async (modulePromise, importObjectPromise) => {
67
30
  // Converts a Dart List to a JS array. Any Dart objects will be converted, but
68
31
  // this will be cheap for JSValues.
69
32
  function arrayFromDartList(constructor, list) {
70
- const length = dartInstance.exports.$listLength(list);
71
- const array = new constructor(length);
72
- for (let i = 0; i < length; i++) {
73
- array[i] = dartInstance.exports.$listRead(list, i);
74
- }
75
- return array;
76
- }
77
-
78
- buildArgsList = function(list) {
79
- const dartList = dartInstance.exports.$makeStringList();
80
- for (let i = 0; i < list.length; i++) {
81
- dartInstance.exports.$listAdd(dartList, stringToDartString(list[i]));
82
- }
83
- 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;
84
41
  }
85
42
 
86
43
  // A special symbol attached to functions that wrap Dart functions.
87
44
  const jsWrappedDartFunctionSymbol = Symbol("JSWrappedDartFunction");
88
45
 
89
46
  function finalizeWrapper(dartFunction, wrapped) {
90
- wrapped.dartFunction = dartFunction;
91
- wrapped[jsWrappedDartFunctionSymbol] = true;
92
- return wrapped;
47
+ wrapped.dartFunction = dartFunction;
48
+ wrapped[jsWrappedDartFunctionSymbol] = true;
49
+ return wrapped;
93
50
  }
94
51
 
95
52
  // Imports
96
53
  const dart2wasm = {
97
54
 
98
- _48: v => stringToDartString(v.toString()),
99
- _62: s => {
100
- const jsSource = stringFromDartString(s);
101
- 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)) {
102
58
  return NaN;
103
59
  }
104
- return parseFloat(jsSource);
60
+ return parseFloat(s);
105
61
  },
106
- _63: () => {
62
+ _65: () => {
107
63
  let stackString = new Error().stack.toString();
108
64
  let frames = stackString.split('\n');
109
65
  let drop = 2;
@@ -112,136 +68,241 @@ _63: () => {
112
68
  }
113
69
  return frames.slice(drop).join('\n');
114
70
  },
115
- _67: () => {
71
+ _69: () => {
116
72
  // On browsers return `globalThis.location.href`
117
73
  if (globalThis.location != null) {
118
- return stringToDartString(globalThis.location.href);
74
+ return globalThis.location.href;
119
75
  }
120
76
  return null;
121
77
  },
122
- _68: () => {
123
- return typeof process != undefined &&
78
+ _70: () => {
79
+ return typeof process != "undefined" &&
124
80
  Object.prototype.toString.call(process) == "[object process]" &&
125
81
  process.platform == "win32"
126
82
  },
127
- _72: s => stringToDartString(JSON.stringify(stringFromDartString(s))),
128
- _73: s => printToConsole(stringFromDartString(s)),
129
- _91: (c) =>
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
+ _97: (s, p, i) => s.indexOf(p, i),
91
+ _98: (s, p, i) => s.lastIndexOf(p, i),
92
+ _100: Object.is,
93
+ _101: s => s.toUpperCase(),
94
+ _102: s => s.toLowerCase(),
95
+ _103: (a, i) => a.push(i),
96
+ _113: (a, b) => a == b ? 0 : (a > b ? 1 : -1),
97
+ _114: a => a.length,
98
+ _116: (a, i) => a[i],
99
+ _117: (a, i, v) => a[i] = v,
100
+ _120: (o, start, length) => new Uint8Array(o.buffer, o.byteOffset + start, length),
101
+ _121: (o, start, length) => new Int8Array(o.buffer, o.byteOffset + start, length),
102
+ _122: (o, start, length) => new Uint8ClampedArray(o.buffer, o.byteOffset + start, length),
103
+ _123: (o, start, length) => new Uint16Array(o.buffer, o.byteOffset + start, length),
104
+ _124: (o, start, length) => new Int16Array(o.buffer, o.byteOffset + start, length),
105
+ _125: (o, start, length) => new Uint32Array(o.buffer, o.byteOffset + start, length),
106
+ _126: (o, start, length) => new Int32Array(o.buffer, o.byteOffset + start, length),
107
+ _129: (o, start, length) => new Float32Array(o.buffer, o.byteOffset + start, length),
108
+ _130: (o, start, length) => new Float64Array(o.buffer, o.byteOffset + start, length),
109
+ _133: (o) => new DataView(o.buffer, o.byteOffset, o.byteLength),
110
+ _137: Function.prototype.call.bind(Object.getOwnPropertyDescriptor(DataView.prototype, 'byteLength').get),
111
+ _138: (b, o) => new DataView(b, o),
112
+ _140: Function.prototype.call.bind(DataView.prototype.getUint8),
113
+ _141: Function.prototype.call.bind(DataView.prototype.setUint8),
114
+ _142: Function.prototype.call.bind(DataView.prototype.getInt8),
115
+ _143: Function.prototype.call.bind(DataView.prototype.setInt8),
116
+ _144: Function.prototype.call.bind(DataView.prototype.getUint16),
117
+ _145: Function.prototype.call.bind(DataView.prototype.setUint16),
118
+ _146: Function.prototype.call.bind(DataView.prototype.getInt16),
119
+ _147: Function.prototype.call.bind(DataView.prototype.setInt16),
120
+ _148: Function.prototype.call.bind(DataView.prototype.getUint32),
121
+ _149: Function.prototype.call.bind(DataView.prototype.setUint32),
122
+ _150: Function.prototype.call.bind(DataView.prototype.getInt32),
123
+ _151: Function.prototype.call.bind(DataView.prototype.setInt32),
124
+ _156: Function.prototype.call.bind(DataView.prototype.getFloat32),
125
+ _157: Function.prototype.call.bind(DataView.prototype.setFloat32),
126
+ _158: Function.prototype.call.bind(DataView.prototype.getFloat64),
127
+ _159: Function.prototype.call.bind(DataView.prototype.setFloat64),
128
+ _165: x0 => format = x0,
129
+ _166: f => finalizeWrapper(f, function(x0,x1,x2) { return dartInstance.exports._166(f,arguments.length,x0,x1,x2) }),
130
+ _184: (c) =>
130
131
  queueMicrotask(() => dartInstance.exports.$invokeCallback(c)),
131
- _93: (a, i) => a.push(i),
132
- _103: (a, b) => a == b ? 0 : (a > b ? 1 : -1),
133
- _104: a => a.length,
134
- _106: (a, i) => a[i],
135
- _107: (a, i, v) => a[i] = v,
136
- _109: a => a.join(''),
137
- _112: (s, t) => s.split(t),
138
- _113: s => s.toLowerCase(),
139
- _114: s => s.toUpperCase(),
140
- _115: s => s.trim(),
141
- _117: s => s.trimRight(),
142
- _119: (s, p, i) => s.indexOf(p, i),
143
- _120: (s, p, i) => s.lastIndexOf(p, i),
144
- _122: (o, start, length) => new Uint8Array(o.buffer, o.byteOffset + start, length),
145
- _123: (o, start, length) => new Int8Array(o.buffer, o.byteOffset + start, length),
146
- _124: (o, start, length) => new Uint8ClampedArray(o.buffer, o.byteOffset + start, length),
147
- _125: (o, start, length) => new Uint16Array(o.buffer, o.byteOffset + start, length),
148
- _126: (o, start, length) => new Int16Array(o.buffer, o.byteOffset + start, length),
149
- _127: (o, start, length) => new Uint32Array(o.buffer, o.byteOffset + start, length),
150
- _128: (o, start, length) => new Int32Array(o.buffer, o.byteOffset + start, length),
151
- _131: (o, start, length) => new Float32Array(o.buffer, o.byteOffset + start, length),
152
- _132: (o, start, length) => new Float64Array(o.buffer, o.byteOffset + start, length),
153
- _133: Object.is,
154
- _136: (o) => new DataView(o.buffer, o.byteOffset, o.byteLength),
155
- _140: Function.prototype.call.bind(Object.getOwnPropertyDescriptor(DataView.prototype, 'byteLength').get),
156
- _141: (b, o) => new DataView(b, o),
157
- _143: Function.prototype.call.bind(DataView.prototype.getUint8),
158
- _144: Function.prototype.call.bind(DataView.prototype.setUint8),
159
- _145: Function.prototype.call.bind(DataView.prototype.getInt8),
160
- _146: Function.prototype.call.bind(DataView.prototype.setInt8),
161
- _147: Function.prototype.call.bind(DataView.prototype.getUint16),
162
- _148: Function.prototype.call.bind(DataView.prototype.setUint16),
163
- _149: Function.prototype.call.bind(DataView.prototype.getInt16),
164
- _150: Function.prototype.call.bind(DataView.prototype.setInt16),
165
- _151: Function.prototype.call.bind(DataView.prototype.getUint32),
166
- _152: Function.prototype.call.bind(DataView.prototype.setUint32),
167
- _153: Function.prototype.call.bind(DataView.prototype.getInt32),
168
- _154: Function.prototype.call.bind(DataView.prototype.setInt32),
169
- _159: Function.prototype.call.bind(DataView.prototype.getFloat32),
170
- _160: Function.prototype.call.bind(DataView.prototype.setFloat32),
171
- _161: Function.prototype.call.bind(DataView.prototype.getFloat64),
172
- _162: Function.prototype.call.bind(DataView.prototype.setFloat64),
173
- _168: s => stringToDartString(stringFromDartString(s).toUpperCase()),
174
- _169: s => stringToDartString(stringFromDartString(s).toLowerCase()),
175
- _171: (s, m) => {
132
+ _187: (s, m) => {
176
133
  try {
177
134
  return new RegExp(s, m);
178
135
  } catch (e) {
179
136
  return String(e);
180
137
  }
181
138
  },
182
- _172: (x0,x1) => x0.exec(x1),
183
- _173: (x0,x1) => x0.test(x1),
184
- _174: (x0,x1) => x0.exec(x1),
185
- _175: (x0,x1) => x0.exec(x1),
186
- _176: x0 => x0.pop(),
187
- _182: o => o === undefined,
188
- _183: o => typeof o === 'boolean',
189
- _184: o => typeof o === 'number',
190
- _186: o => typeof o === 'string',
191
- _189: o => o instanceof Int8Array,
192
- _190: o => o instanceof Uint8Array,
193
- _191: o => o instanceof Uint8ClampedArray,
194
- _192: o => o instanceof Int16Array,
195
- _193: o => o instanceof Uint16Array,
196
- _194: o => o instanceof Int32Array,
197
- _195: o => o instanceof Uint32Array,
198
- _196: o => o instanceof Float32Array,
199
- _197: o => o instanceof Float64Array,
200
- _198: o => o instanceof ArrayBuffer,
201
- _199: o => o instanceof DataView,
202
- _200: o => o instanceof Array,
203
- _201: o => typeof o === 'function' && o[jsWrappedDartFunctionSymbol] === true,
204
- _204: o => o instanceof RegExp,
205
- _205: (l, r) => l === r,
206
- _206: o => o,
207
- _207: o => o,
208
- _208: o => o,
209
- _209: b => !!b,
210
- _210: o => o.length,
211
- _213: (o, i) => o[i],
212
- _214: f => f.dartFunction,
213
- _215: l => arrayFromDartList(Int8Array, l),
214
- _216: l => arrayFromDartList(Uint8Array, l),
215
- _217: l => arrayFromDartList(Uint8ClampedArray, l),
216
- _218: l => arrayFromDartList(Int16Array, l),
217
- _219: l => arrayFromDartList(Uint16Array, l),
218
- _220: l => arrayFromDartList(Int32Array, l),
219
- _221: l => arrayFromDartList(Uint32Array, l),
220
- _222: l => arrayFromDartList(Float32Array, l),
221
- _223: l => arrayFromDartList(Float64Array, l),
222
- _224: (data, length) => {
139
+ _188: (x0,x1) => x0.exec(x1),
140
+ _189: (x0,x1) => x0.test(x1),
141
+ _190: (x0,x1) => x0.exec(x1),
142
+ _191: (x0,x1) => x0.exec(x1),
143
+ _192: x0 => x0.pop(),
144
+ _198: o => o === undefined,
145
+ _199: o => typeof o === 'boolean',
146
+ _200: o => typeof o === 'number',
147
+ _202: o => typeof o === 'string',
148
+ _205: o => o instanceof Int8Array,
149
+ _206: o => o instanceof Uint8Array,
150
+ _207: o => o instanceof Uint8ClampedArray,
151
+ _208: o => o instanceof Int16Array,
152
+ _209: o => o instanceof Uint16Array,
153
+ _210: o => o instanceof Int32Array,
154
+ _211: o => o instanceof Uint32Array,
155
+ _212: o => o instanceof Float32Array,
156
+ _213: o => o instanceof Float64Array,
157
+ _214: o => o instanceof ArrayBuffer,
158
+ _215: o => o instanceof DataView,
159
+ _216: o => o instanceof Array,
160
+ _217: o => typeof o === 'function' && o[jsWrappedDartFunctionSymbol] === true,
161
+ _220: o => o instanceof RegExp,
162
+ _221: (l, r) => l === r,
163
+ _222: o => o,
164
+ _223: o => o,
165
+ _224: o => o,
166
+ _225: b => !!b,
167
+ _226: o => o.length,
168
+ _229: (o, i) => o[i],
169
+ _230: f => f.dartFunction,
170
+ _231: l => arrayFromDartList(Int8Array, l),
171
+ _232: (data, length) => {
172
+ const jsBytes = new Uint8Array(length);
173
+ const getByte = dartInstance.exports.$uint8ListGet;
174
+ for (let i = 0; i < length; i++) {
175
+ jsBytes[i] = getByte(data, i);
176
+ }
177
+ return jsBytes;
178
+ },
179
+ _233: l => arrayFromDartList(Uint8ClampedArray, l),
180
+ _234: l => arrayFromDartList(Int16Array, l),
181
+ _235: l => arrayFromDartList(Uint16Array, l),
182
+ _236: l => arrayFromDartList(Int32Array, l),
183
+ _237: l => arrayFromDartList(Uint32Array, l),
184
+ _238: l => arrayFromDartList(Float32Array, l),
185
+ _239: l => arrayFromDartList(Float64Array, l),
186
+ _240: (data, length) => {
187
+ const read = dartInstance.exports.$byteDataGetUint8;
223
188
  const view = new DataView(new ArrayBuffer(length));
224
189
  for (let i = 0; i < length; i++) {
225
- view.setUint8(i, dartInstance.exports.$byteDataGetUint8(data, i));
190
+ view.setUint8(i, read(data, i));
226
191
  }
227
192
  return view;
228
193
  },
229
- _225: l => arrayFromDartList(Array, l),
230
- _226: stringFromDartString,
231
- _227: stringToDartString,
232
- _230: l => new Array(l),
233
- _234: (o, p) => o[p],
234
- _238: o => String(o),
235
- _243: x0 => x0.index,
236
- _245: x0 => x0.length,
237
- _247: (x0,x1) => x0[x1],
238
- _249: (x0,x1) => x0.exec(x1),
239
- _251: x0 => x0.flags,
240
- _252: x0 => x0.multiline,
241
- _253: x0 => x0.ignoreCase,
242
- _254: x0 => x0.unicode,
243
- _255: x0 => x0.dotAll,
244
- _256: (x0,x1) => x0.lastIndex = x1
194
+ _241: l => arrayFromDartList(Array, l),
195
+ _242: (s, length) => {
196
+ if (length == 0) return '';
197
+
198
+ const read = dartInstance.exports.$stringRead1;
199
+ let result = '';
200
+ let index = 0;
201
+ const chunkLength = Math.min(length - index, 500);
202
+ let array = new Array(chunkLength);
203
+ while (index < length) {
204
+ const newChunkLength = Math.min(length - index, 500);
205
+ for (let i = 0; i < newChunkLength; i++) {
206
+ array[i] = read(s, index++);
207
+ }
208
+ if (newChunkLength < chunkLength) {
209
+ array = array.slice(0, newChunkLength);
210
+ }
211
+ result += String.fromCharCode(...array);
212
+ }
213
+ return result;
214
+ }
215
+ ,
216
+ _243: (s, length) => {
217
+ if (length == 0) return '';
218
+
219
+ const read = dartInstance.exports.$stringRead2;
220
+ let result = '';
221
+ let index = 0;
222
+ const chunkLength = Math.min(length - index, 500);
223
+ let array = new Array(chunkLength);
224
+ while (index < length) {
225
+ const newChunkLength = Math.min(length - index, 500);
226
+ for (let i = 0; i < newChunkLength; i++) {
227
+ array[i] = read(s, index++);
228
+ }
229
+ if (newChunkLength < chunkLength) {
230
+ array = array.slice(0, newChunkLength);
231
+ }
232
+ result += String.fromCharCode(...array);
233
+ }
234
+ return result;
235
+ }
236
+ ,
237
+ _244: (s) => {
238
+ let length = s.length;
239
+ let range = 0;
240
+ for (let i = 0; i < length; i++) {
241
+ range |= s.codePointAt(i);
242
+ }
243
+ const exports = dartInstance.exports;
244
+ if (range < 256) {
245
+ if (length <= 10) {
246
+ if (length == 1) {
247
+ return exports.$stringAllocate1_1(s.codePointAt(0));
248
+ }
249
+ if (length == 2) {
250
+ return exports.$stringAllocate1_2(s.codePointAt(0), s.codePointAt(1));
251
+ }
252
+ if (length == 3) {
253
+ return exports.$stringAllocate1_3(s.codePointAt(0), s.codePointAt(1), s.codePointAt(2));
254
+ }
255
+ if (length == 4) {
256
+ return exports.$stringAllocate1_4(s.codePointAt(0), s.codePointAt(1), s.codePointAt(2), s.codePointAt(3));
257
+ }
258
+ if (length == 5) {
259
+ return exports.$stringAllocate1_5(s.codePointAt(0), s.codePointAt(1), s.codePointAt(2), s.codePointAt(3), s.codePointAt(4));
260
+ }
261
+ if (length == 6) {
262
+ return exports.$stringAllocate1_6(s.codePointAt(0), s.codePointAt(1), s.codePointAt(2), s.codePointAt(3), s.codePointAt(4), s.codePointAt(5));
263
+ }
264
+ if (length == 7) {
265
+ 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));
266
+ }
267
+ if (length == 8) {
268
+ 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));
269
+ }
270
+ if (length == 9) {
271
+ 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));
272
+ }
273
+ if (length == 10) {
274
+ 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));
275
+ }
276
+ }
277
+ const dartString = exports.$stringAllocate1(length);
278
+ const write = exports.$stringWrite1;
279
+ for (let i = 0; i < length; i++) {
280
+ write(dartString, i, s.codePointAt(i));
281
+ }
282
+ return dartString;
283
+ } else {
284
+ const dartString = exports.$stringAllocate2(length);
285
+ const write = exports.$stringWrite2;
286
+ for (let i = 0; i < length; i++) {
287
+ write(dartString, i, s.charCodeAt(i));
288
+ }
289
+ return dartString;
290
+ }
291
+ }
292
+ ,
293
+ _247: l => new Array(l),
294
+ _251: (o, p) => o[p],
295
+ _255: o => String(o),
296
+ _260: x0 => x0.index,
297
+ _262: x0 => x0.length,
298
+ _264: (x0,x1) => x0[x1],
299
+ _265: (x0,x1) => x0.exec(x1),
300
+ _267: x0 => x0.flags,
301
+ _268: x0 => x0.multiline,
302
+ _269: x0 => x0.ignoreCase,
303
+ _270: x0 => x0.unicode,
304
+ _271: x0 => x0.dotAll,
305
+ _272: (x0,x1) => x0.lastIndex = x1
245
306
  };
246
307
 
247
308
  const baseImports = {
@@ -265,7 +326,7 @@ _256: (x0,x1) => x0.lastIndex = x1
265
326
  "concat": (s1, s2) => s1 + s2,
266
327
  "equals": (s1, s2) => s1 === s2,
267
328
  "fromCharCode": (i) => String.fromCharCode(i),
268
- "length": (s) => s.length,
329
+ "length": (s) => s?.length||0,
269
330
  "substring": (s, a, b) => s.substring(a, b),
270
331
  };
271
332
 
@@ -282,8 +343,8 @@ _256: (x0,x1) => x0.lastIndex = x1
282
343
  // `moduleInstance` is the instantiated dart2wasm module
283
344
  // `args` are any arguments that should be passed into the main function.
284
345
  export const invoke = (moduleInstance, ...args) => {
285
- const dartMain = moduleInstance.exports.$getMain();
286
- const dartArgs = buildArgsList(args);
287
- moduleInstance.exports.$invokeMain(dartMain, dartArgs);
346
+ moduleInstance.exports.$invokeMain(args);
288
347
  }
289
348
 
349
+
350
+ export let format;
Binary file