@cparra/apex-reflection 4.0.0-beta.3 → 4.0.0-beta.5
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 +26 -28
- package/dist/node.mjs +338 -332
- package/dist/node.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,13 +11,12 @@ npm i @cparra/apex-reflection
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
This library exposes a single function that handles parsing the body of an Apex top level type (class, interface, or
|
|
14
|
-
enum)
|
|
15
|
-
and returns the result.
|
|
14
|
+
enum) and returns the result.
|
|
16
15
|
|
|
17
16
|
```typescript
|
|
18
|
-
import {reflect} from
|
|
17
|
+
import { reflect } from "@cparra/apex-reflection";
|
|
19
18
|
|
|
20
|
-
const classBody =
|
|
19
|
+
const classBody = "public with sharing class ExampleClass {}";
|
|
21
20
|
const response = reflect(classBody);
|
|
22
21
|
```
|
|
23
22
|
|
|
@@ -34,23 +33,33 @@ const response = reflect(rawFile.toString());
|
|
|
34
33
|
```
|
|
35
34
|
|
|
36
35
|
The `reflect` function returns a `ReflectionResult` which contains either the results of the parsed `Type`
|
|
37
|
-
(which will either be a `ClassMirror`, an `InterfaceMirror
|
|
36
|
+
(which will either be a `ClassMirror`, an `InterfaceMirror`, or an `EnumMirror`) or a `ParsingError` if the passed in
|
|
38
37
|
body was not parsed successfully, with a message indicating where the error occurred.
|
|
39
38
|
|
|
40
39
|
## Contributing
|
|
41
40
|
|
|
42
41
|
Even though this library is exposed as a Node.js library, the project's source code is written in Dart. The source can
|
|
43
|
-
be found in the `lib/src` directory.
|
|
42
|
+
be found in the `lib/src` directory of the repository.
|
|
43
|
+
|
|
44
|
+
This package ships the Dart code compiled to a WebAssembly module (`dist/node.wasm`) together with its JS loader
|
|
45
|
+
(`dist/node.mjs`), loaded lazily by the thin TypeScript wrapper in `index.mts`. Node.js 22 or newer is required (the
|
|
46
|
+
module uses WasmGC). To rebuild the module after changing the Dart source, run from the repository root:
|
|
47
|
+
|
|
48
|
+
```shell
|
|
49
|
+
dart compile wasm lib/src/node/node.dart -o js/node.wasm
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`npm run build` compiles the TypeScript wrapper and copies the wasm module and its loader into `dist/`.
|
|
44
53
|
|
|
45
54
|
### Tests
|
|
46
55
|
|
|
47
|
-
Both the Dart source code and the
|
|
56
|
+
Both the Dart source code and the packaged WebAssembly module must be tested.
|
|
48
57
|
|
|
49
|
-
The Dart tests live in the `test` directory. The Dart source code must have unit tests testing each
|
|
50
|
-
as well as end-to-end tests that verify the overall parsing functionality.
|
|
58
|
+
The Dart tests live in the repository's `test` directory. The Dart source code must have unit tests testing each
|
|
59
|
+
individual Dart file as well as end-to-end tests that verify the overall parsing functionality.
|
|
51
60
|
|
|
52
|
-
The JS tests live in `
|
|
53
|
-
|
|
61
|
+
The JS tests live in `__tests__`. These are end-to-end tests that run against the built package (`dist/`), so they
|
|
62
|
+
also guard against publishing a stale WebAssembly artifact. Run them with `npm test`.
|
|
54
63
|
|
|
55
64
|
### JSON serialization
|
|
56
65
|
|
|
@@ -62,27 +71,16 @@ helps automatically create the round-trip code for serialization and de-serializ
|
|
|
62
71
|
|
|
63
72
|
When changing any of the model classes with serialization support, to re-build the serialization code run
|
|
64
73
|
|
|
65
|
-
```
|
|
66
|
-
pub run build_runner build
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### Parsing
|
|
70
|
-
|
|
71
|
-
The parsing algorithm relies on using ANTLR4 and its Dart target. Currently `dart2js` is not able to transpile the
|
|
72
|
-
source from the `antrl4` library hosted in pub.dev, so we rely on a local copy that fixes the transpilation issues,
|
|
73
|
-
which lives in `lib/antrl4-4.9.2`.
|
|
74
|
-
|
|
75
|
-
To generate the Antlr4 Apex output run:
|
|
76
|
-
|
|
77
74
|
```shell
|
|
78
|
-
|
|
75
|
+
dart run build_runner build
|
|
79
76
|
```
|
|
80
77
|
|
|
81
|
-
|
|
78
|
+
### Parsing
|
|
82
79
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
Parsing is implemented with handwritten [petitparser](https://pub.dev/packages/petitparser) grammars.
|
|
81
|
+
The Apex grammar parses only the declaration structure needed for reflection (bodies are skipped as
|
|
82
|
+
balanced blocks), and the Apexdoc grammar is composed into it, so doc comments are parsed in the same single pass. See
|
|
83
|
+
the repository README for details.
|
|
86
84
|
|
|
87
85
|
## Typescript
|
|
88
86
|
|
package/dist/node.mjs
CHANGED
|
@@ -4,356 +4,362 @@
|
|
|
4
4
|
// `source` needs to be a `Response` object (or promise thereof) e.g. created
|
|
5
5
|
// via the `fetch()` JS API.
|
|
6
6
|
export async function compileStreaming(source) {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const builtins = {builtins: ['js-string']};
|
|
8
|
+
return new CompiledApp(
|
|
9
|
+
await WebAssembly.compileStreaming(source, builtins), builtins);
|
|
9
10
|
}
|
|
11
|
+
|
|
10
12
|
// Compiles a dart2wasm-generated wasm modules from `bytes` which is then
|
|
11
13
|
// instantiatable via the `instantiate` method.
|
|
12
14
|
export async function compile(bytes) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
const builtins = {builtins: ['js-string']};
|
|
16
|
+
return new CompiledApp(await WebAssembly.compile(bytes, builtins), builtins);
|
|
15
17
|
}
|
|
18
|
+
|
|
16
19
|
// DEPRECATED: Please use `compile` or `compileStreaming` to get a compiled app,
|
|
17
20
|
// use `instantiate` method to get an instantiated app and then call
|
|
18
21
|
// `invokeMain` to invoke the main function.
|
|
19
22
|
export async function instantiate(modulePromise, importObjectPromise) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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;
|
|
26
29
|
}
|
|
30
|
+
|
|
27
31
|
// DEPRECATED: Please use `compile` or `compileStreaming` to get a compiled app,
|
|
28
32
|
// use `instantiate` method to get an instantiated app and then call
|
|
29
33
|
// `invokeMain` to invoke the main function.
|
|
30
34
|
export const invoke = (moduleInstance, ...args) => {
|
|
31
|
-
|
|
32
|
-
}
|
|
35
|
+
moduleInstance.exports.$invokeMain(args);
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
class CompiledApp {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
constructor(module, builtins) {
|
|
40
|
+
this.module = module;
|
|
41
|
+
this.builtins = builtins;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// The second argument is an options object containing:
|
|
45
|
+
// `loadDeferredModule` 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
|
+
// `loadDeferredId` is a JS function that takes a string corresponding to a load
|
|
57
|
+
// ID generated by the compiler when 'load-ids' option is passed. Each load
|
|
58
|
+
// ID maps to one or more WASM modules produced by the compiler. This
|
|
59
|
+
// function should return an array of byte arrays corresponding to all the
|
|
60
|
+
// modules specified by that load ID. The arrays should be in a format
|
|
61
|
+
// supported by `WebAssembly.compile` or `WebAssembly.compileStreaming`.
|
|
62
|
+
async instantiate(additionalImports,
|
|
63
|
+
{loadDeferredModule, loadDynamicModule, loadDeferredId} = {}) {
|
|
64
|
+
let dartInstance;
|
|
65
|
+
|
|
66
|
+
// Prints to the console
|
|
67
|
+
function printToConsole(value) {
|
|
68
|
+
if (typeof dartPrint == "function") {
|
|
69
|
+
dartPrint(value);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (typeof console == "object" && typeof console.log != "undefined") {
|
|
73
|
+
console.log(value);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (typeof print == "function") {
|
|
77
|
+
print(value);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
throw "Unable to print message: " + value;
|
|
37
82
|
}
|
|
38
|
-
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
function printToConsole(value) {
|
|
60
|
-
if (typeof dartPrint == "function") {
|
|
61
|
-
dartPrint(value);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
if (typeof console == "object" && typeof console.log != "undefined") {
|
|
65
|
-
console.log(value);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (typeof print == "function") {
|
|
69
|
-
print(value);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
throw "Unable to print message: " + value;
|
|
83
|
+
|
|
84
|
+
// A special symbol attached to functions that wrap Dart functions.
|
|
85
|
+
const jsWrappedDartFunctionSymbol = Symbol("JSWrappedDartFunction");
|
|
86
|
+
|
|
87
|
+
function finalizeWrapper(dartFunction, wrapped) {
|
|
88
|
+
wrapped.dartFunction = dartFunction;
|
|
89
|
+
wrapped[jsWrappedDartFunctionSymbol] = true;
|
|
90
|
+
return wrapped;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Imports
|
|
94
|
+
const dart2wasm = {
|
|
95
|
+
_9: () => new Error().stack,
|
|
96
|
+
_18: (exn) => exn.toString(),
|
|
97
|
+
_19: (exn) => exn.stack,
|
|
98
|
+
_20: (exn) => {
|
|
99
|
+
let stackString = exn.toString();
|
|
100
|
+
let frames = stackString.split('\n');
|
|
101
|
+
let drop = 2;
|
|
102
|
+
if (frames[0] === 'Error') {
|
|
103
|
+
drop += 1;
|
|
73
104
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
105
|
+
return frames.slice(drop).join('\n');
|
|
106
|
+
},
|
|
107
|
+
_33: s => JSON.stringify(s),
|
|
108
|
+
_34: s => printToConsole(s),
|
|
109
|
+
_37: Function.prototype.call.bind(String.prototype.toLowerCase),
|
|
110
|
+
_39: s => s.trim(),
|
|
111
|
+
_40: s => s.trimLeft(),
|
|
112
|
+
_41: s => s.trimRight(),
|
|
113
|
+
_42: (string, times) => string.repeat(times),
|
|
114
|
+
_43: Function.prototype.call.bind(String.prototype.indexOf),
|
|
115
|
+
_44: (s, p, i) => s.lastIndexOf(p, i),
|
|
116
|
+
_45: (string, token) => string.split(token),
|
|
117
|
+
_46: Object.is,
|
|
118
|
+
_53: (o,s,v) => o[s] = v,
|
|
119
|
+
_82: x0 => new Array(x0),
|
|
120
|
+
_84: x0 => x0.length,
|
|
121
|
+
_86: (x0,x1) => x0[x1],
|
|
122
|
+
_87: (x0,x1,x2) => { x0[x1] = x2 },
|
|
123
|
+
_89: x0 => new Promise(x0),
|
|
124
|
+
_91: (x0,x1,x2) => new DataView(x0,x1,x2),
|
|
125
|
+
_93: x0 => new Int8Array(x0),
|
|
126
|
+
_94: (x0,x1,x2) => new Uint8Array(x0,x1,x2),
|
|
127
|
+
_95: x0 => new Uint8Array(x0),
|
|
128
|
+
_97: x0 => new Uint8ClampedArray(x0),
|
|
129
|
+
_99: x0 => new Int16Array(x0),
|
|
130
|
+
_101: x0 => new Uint16Array(x0),
|
|
131
|
+
_103: x0 => new Int32Array(x0),
|
|
132
|
+
_105: x0 => new Uint32Array(x0),
|
|
133
|
+
_107: x0 => new Float32Array(x0),
|
|
134
|
+
_109: x0 => new Float64Array(x0),
|
|
135
|
+
_129: (x0,x1,x2) => x0.call(x1,x2),
|
|
136
|
+
_130: (module,f) => finalizeWrapper(f, function(x0,x1) { return module.exports._130(f,arguments.length,x0,x1) }),
|
|
137
|
+
_133: () => Symbol("jsBoxedDartObjectProperty"),
|
|
138
|
+
_134: x0 => x0.random(),
|
|
139
|
+
_137: () => globalThis.Math,
|
|
140
|
+
_150: (ms, c) =>
|
|
141
|
+
setTimeout(() => dartInstance.exports.$invokeCallback(c),ms),
|
|
142
|
+
_154: (c) =>
|
|
143
|
+
queueMicrotask(() => dartInstance.exports.$invokeCallback(c)),
|
|
144
|
+
_156: (s, m) => {
|
|
145
|
+
try {
|
|
146
|
+
return new RegExp(s, m);
|
|
147
|
+
} catch (e) {
|
|
148
|
+
return String(e);
|
|
80
149
|
}
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
const baseImports = {
|
|
285
|
-
dart2wasm: dart2wasm,
|
|
286
|
-
Math: Math,
|
|
287
|
-
Date: Date,
|
|
288
|
-
Object: Object,
|
|
289
|
-
Array: Array,
|
|
290
|
-
Reflect: Reflect,
|
|
291
|
-
WebAssembly: {
|
|
292
|
-
JSTag: WebAssembly.JSTag,
|
|
293
|
-
},
|
|
294
|
-
"": new Proxy({}, { get(_, prop) { return prop; } }),
|
|
295
|
-
};
|
|
296
|
-
const jsStringPolyfill = {
|
|
297
|
-
"charCodeAt": (s, i) => s.charCodeAt(i),
|
|
298
|
-
"compare": (s1, s2) => {
|
|
299
|
-
if (s1 < s2)
|
|
300
|
-
return -1;
|
|
301
|
-
if (s1 > s2)
|
|
302
|
-
return 1;
|
|
303
|
-
return 0;
|
|
304
|
-
},
|
|
305
|
-
"concat": (s1, s2) => s1 + s2,
|
|
306
|
-
"equals": (s1, s2) => s1 === s2,
|
|
307
|
-
"fromCharCode": (i) => String.fromCharCode(i),
|
|
308
|
-
"length": (s) => s.length,
|
|
309
|
-
"substring": (s, a, b) => s.substring(a, b),
|
|
310
|
-
"fromCharCodeArray": (a, start, end) => {
|
|
311
|
-
if (end <= start)
|
|
312
|
-
return '';
|
|
313
|
-
const read = dartInstance.exports.$wasmI16ArrayGet;
|
|
314
|
-
let result = '';
|
|
315
|
-
let index = start;
|
|
316
|
-
const chunkLength = Math.min(end - index, 500);
|
|
317
|
-
let array = new Array(chunkLength);
|
|
318
|
-
while (index < end) {
|
|
319
|
-
const newChunkLength = Math.min(end - index, 500);
|
|
320
|
-
for (let i = 0; i < newChunkLength; i++) {
|
|
321
|
-
array[i] = read(a, index++);
|
|
322
|
-
}
|
|
323
|
-
if (newChunkLength < chunkLength) {
|
|
324
|
-
array = array.slice(0, newChunkLength);
|
|
325
|
-
}
|
|
326
|
-
result += String.fromCharCode(...array);
|
|
327
|
-
}
|
|
328
|
-
return result;
|
|
329
|
-
},
|
|
330
|
-
"intoCharCodeArray": (s, a, start) => {
|
|
331
|
-
if (s === '')
|
|
332
|
-
return 0;
|
|
333
|
-
const write = dartInstance.exports.$wasmI16ArraySet;
|
|
334
|
-
for (var i = 0; i < s.length; ++i) {
|
|
335
|
-
write(a, start++, s.charCodeAt(i));
|
|
336
|
-
}
|
|
337
|
-
return s.length;
|
|
338
|
-
},
|
|
339
|
-
"test": (s) => typeof s == "string",
|
|
340
|
-
};
|
|
341
|
-
dartInstance = await WebAssembly.instantiate(this.module, {
|
|
342
|
-
...baseImports,
|
|
343
|
-
...additionalImports,
|
|
344
|
-
"wasm:js-string": jsStringPolyfill,
|
|
345
|
-
});
|
|
346
|
-
dartInstance.exports.$setThisModule(dartInstance);
|
|
347
|
-
return new InstantiatedApp(this, dartInstance);
|
|
348
|
-
}
|
|
150
|
+
},
|
|
151
|
+
_157: (x0,x1) => x0.exec(x1),
|
|
152
|
+
_158: (x0,x1) => x0.test(x1),
|
|
153
|
+
_161: o => o === undefined,
|
|
154
|
+
_163: o => typeof o === 'function' && o[jsWrappedDartFunctionSymbol] === true,
|
|
155
|
+
_166: o => o instanceof RegExp,
|
|
156
|
+
_167: (l, r) => l === r,
|
|
157
|
+
_168: o => o,
|
|
158
|
+
_169: o => o,
|
|
159
|
+
_170: o => o,
|
|
160
|
+
_171: b => !!b,
|
|
161
|
+
_172: o => o.length,
|
|
162
|
+
_174: (o, i) => o[i],
|
|
163
|
+
_175: f => f.dartFunction,
|
|
164
|
+
_176: () => ({}),
|
|
165
|
+
_179: () => globalThis,
|
|
166
|
+
_180: (constructor, args) => {
|
|
167
|
+
const factoryFunction = constructor.bind.apply(
|
|
168
|
+
constructor, [null, ...args]);
|
|
169
|
+
return new factoryFunction();
|
|
170
|
+
},
|
|
171
|
+
_182: (o, p) => o[p],
|
|
172
|
+
_186: o => String(o),
|
|
173
|
+
_187: (p, s, f) => p.then(s, (e) => f(e, e === undefined)),
|
|
174
|
+
_188: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._188(f,arguments.length,x0) }),
|
|
175
|
+
_189: (module,f) => finalizeWrapper(f, function(x0,x1) { return module.exports._189(f,arguments.length,x0,x1) }),
|
|
176
|
+
_190: o => {
|
|
177
|
+
if (o === undefined) return 1;
|
|
178
|
+
var type = typeof o;
|
|
179
|
+
if (type === 'boolean') return 2;
|
|
180
|
+
if (type === 'number') return 3;
|
|
181
|
+
if (type === 'string') return 4;
|
|
182
|
+
if (o instanceof Array) return 5;
|
|
183
|
+
if (ArrayBuffer.isView(o)) {
|
|
184
|
+
if (o instanceof Int8Array) return 6;
|
|
185
|
+
if (o instanceof Uint8Array) return 7;
|
|
186
|
+
if (o instanceof Uint8ClampedArray) return 8;
|
|
187
|
+
if (o instanceof Int16Array) return 9;
|
|
188
|
+
if (o instanceof Uint16Array) return 10;
|
|
189
|
+
if (o instanceof Int32Array) return 11;
|
|
190
|
+
if (o instanceof Uint32Array) return 12;
|
|
191
|
+
if (o instanceof Float32Array) return 13;
|
|
192
|
+
if (o instanceof Float64Array) return 14;
|
|
193
|
+
if (o instanceof DataView) return 15;
|
|
194
|
+
}
|
|
195
|
+
if (o instanceof ArrayBuffer) return 16;
|
|
196
|
+
// Feature check for `SharedArrayBuffer` before doing a type-check.
|
|
197
|
+
if (globalThis.SharedArrayBuffer !== undefined &&
|
|
198
|
+
o instanceof SharedArrayBuffer) {
|
|
199
|
+
return 17;
|
|
200
|
+
}
|
|
201
|
+
if (o instanceof Promise) return 18;
|
|
202
|
+
return 19;
|
|
203
|
+
},
|
|
204
|
+
_191: o => [o],
|
|
205
|
+
_192: (o0, o1) => [o0, o1],
|
|
206
|
+
_193: (o0, o1, o2) => [o0, o1, o2],
|
|
207
|
+
_194: (o0, o1, o2, o3) => [o0, o1, o2, o3],
|
|
208
|
+
_199: (jsArray, jsArrayOffset, wasmArray, wasmArrayOffset, length) => {
|
|
209
|
+
const getValue = dartInstance.exports.$wasmI32ArrayGet;
|
|
210
|
+
for (let i = 0; i < length; i++) {
|
|
211
|
+
jsArray[jsArrayOffset + i] = getValue(wasmArray, wasmArrayOffset + i);
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
_205: x0 => new ArrayBuffer(x0),
|
|
215
|
+
_208: x0 => x0.index,
|
|
216
|
+
_210: x0 => x0.flags,
|
|
217
|
+
_211: x0 => x0.multiline,
|
|
218
|
+
_212: x0 => x0.ignoreCase,
|
|
219
|
+
_213: x0 => x0.unicode,
|
|
220
|
+
_214: x0 => x0.dotAll,
|
|
221
|
+
_215: (x0,x1) => { x0.lastIndex = x1 },
|
|
222
|
+
_217: (o, p) => o[p],
|
|
223
|
+
_218: (o, p, v) => o[p] = v,
|
|
224
|
+
_220: o => o instanceof Array,
|
|
225
|
+
_231: a => a.length,
|
|
226
|
+
_233: (a, i) => a[i],
|
|
227
|
+
_239: o => o instanceof Uint8Array,
|
|
228
|
+
_240: (o, start, length) => new Uint8Array(o.buffer, o.byteOffset + start, length),
|
|
229
|
+
_241: o => o instanceof Int8Array,
|
|
230
|
+
_242: (o, start, length) => new Int8Array(o.buffer, o.byteOffset + start, length),
|
|
231
|
+
_243: o => o instanceof Uint8ClampedArray,
|
|
232
|
+
_244: (o, start, length) => new Uint8ClampedArray(o.buffer, o.byteOffset + start, length),
|
|
233
|
+
_245: o => o instanceof Uint16Array,
|
|
234
|
+
_246: (o, start, length) => new Uint16Array(o.buffer, o.byteOffset + start, length),
|
|
235
|
+
_247: o => o instanceof Int16Array,
|
|
236
|
+
_248: (o, start, length) => new Int16Array(o.buffer, o.byteOffset + start, length),
|
|
237
|
+
_249: o => o instanceof Uint32Array,
|
|
238
|
+
_250: (o, start, length) => new Uint32Array(o.buffer, o.byteOffset + start, length),
|
|
239
|
+
_251: o => o instanceof Int32Array,
|
|
240
|
+
_252: (o, start, length) => new Int32Array(o.buffer, o.byteOffset + start, length),
|
|
241
|
+
_255: o => o instanceof Float32Array,
|
|
242
|
+
_256: (o, start, length) => new Float32Array(o.buffer, o.byteOffset + start, length),
|
|
243
|
+
_257: o => o instanceof Float64Array,
|
|
244
|
+
_258: (o, start, length) => new Float64Array(o.buffer, o.byteOffset + start, length),
|
|
245
|
+
_259: (t, s) => t.set(s),
|
|
246
|
+
_261: (o) => new DataView(o.buffer, o.byteOffset, o.byteLength),
|
|
247
|
+
_263: o => o.buffer,
|
|
248
|
+
_264: o => o.byteOffset,
|
|
249
|
+
_265: Function.prototype.call.bind(Object.getOwnPropertyDescriptor(DataView.prototype, 'byteLength').get),
|
|
250
|
+
_266: (b, o) => new DataView(b, o),
|
|
251
|
+
_267: (b, o, l) => new DataView(b, o, l),
|
|
252
|
+
_268: Function.prototype.call.bind(DataView.prototype.getUint8),
|
|
253
|
+
_269: Function.prototype.call.bind(DataView.prototype.setUint8),
|
|
254
|
+
_270: Function.prototype.call.bind(DataView.prototype.getInt8),
|
|
255
|
+
_271: Function.prototype.call.bind(DataView.prototype.setInt8),
|
|
256
|
+
_272: Function.prototype.call.bind(DataView.prototype.getUint16),
|
|
257
|
+
_273: Function.prototype.call.bind(DataView.prototype.setUint16),
|
|
258
|
+
_274: Function.prototype.call.bind(DataView.prototype.getInt16),
|
|
259
|
+
_275: Function.prototype.call.bind(DataView.prototype.setInt16),
|
|
260
|
+
_276: Function.prototype.call.bind(DataView.prototype.getUint32),
|
|
261
|
+
_277: Function.prototype.call.bind(DataView.prototype.setUint32),
|
|
262
|
+
_278: Function.prototype.call.bind(DataView.prototype.getInt32),
|
|
263
|
+
_279: Function.prototype.call.bind(DataView.prototype.setInt32),
|
|
264
|
+
_284: Function.prototype.call.bind(DataView.prototype.getFloat32),
|
|
265
|
+
_285: Function.prototype.call.bind(DataView.prototype.setFloat32),
|
|
266
|
+
_286: Function.prototype.call.bind(DataView.prototype.getFloat64),
|
|
267
|
+
_287: Function.prototype.call.bind(DataView.prototype.setFloat64),
|
|
268
|
+
_288: Function.prototype.call.bind(Number.prototype.toString),
|
|
269
|
+
_289: Function.prototype.call.bind(BigInt.prototype.toString),
|
|
270
|
+
_290: Function.prototype.call.bind(Number.prototype.toString),
|
|
271
|
+
_295: x0 => { globalThis.reflect = x0 },
|
|
272
|
+
_296: x0 => { globalThis.reflectAsync = x0 },
|
|
273
|
+
_297: x0 => { globalThis.reflectTrigger = x0 },
|
|
274
|
+
_298: x0 => { globalThis.reflectTriggerAsync = x0 },
|
|
275
|
+
_299: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._299(f,arguments.length,x0) }),
|
|
276
|
+
_300: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._300(f,arguments.length,x0) }),
|
|
277
|
+
_301: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._301(f,arguments.length,x0) }),
|
|
278
|
+
_302: (module,f) => finalizeWrapper(f, function(x0) { return module.exports._302(f,arguments.length,x0) }),
|
|
279
|
+
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
const baseImports = {
|
|
283
|
+
dart2wasm: dart2wasm,
|
|
284
|
+
Math: Math,
|
|
285
|
+
Date: Date,
|
|
286
|
+
Object: Object,
|
|
287
|
+
Array: Array,
|
|
288
|
+
Reflect: Reflect,
|
|
289
|
+
WebAssembly: {
|
|
290
|
+
JSTag: WebAssembly.JSTag,
|
|
291
|
+
},
|
|
292
|
+
"": new Proxy({}, { get(_, prop) { return prop; } }),
|
|
293
|
+
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const jsStringPolyfill = {
|
|
297
|
+
"charCodeAt": (s, i) => s.charCodeAt(i),
|
|
298
|
+
"compare": (s1, s2) => {
|
|
299
|
+
if (s1 < s2) return -1;
|
|
300
|
+
if (s1 > s2) return 1;
|
|
301
|
+
return 0;
|
|
302
|
+
},
|
|
303
|
+
"concat": (s1, s2) => s1 + s2,
|
|
304
|
+
"equals": (s1, s2) => s1 === s2,
|
|
305
|
+
"fromCharCode": (i) => String.fromCharCode(i),
|
|
306
|
+
"length": (s) => s.length,
|
|
307
|
+
"substring": (s, a, b) => s.substring(a, b),
|
|
308
|
+
"fromCharCodeArray": (a, start, end) => {
|
|
309
|
+
if (end <= start) return '';
|
|
310
|
+
|
|
311
|
+
const read = dartInstance.exports.$wasmI16ArrayGet;
|
|
312
|
+
let result = '';
|
|
313
|
+
let index = start;
|
|
314
|
+
const chunkLength = Math.min(end - index, 500);
|
|
315
|
+
let array = new Array(chunkLength);
|
|
316
|
+
while (index < end) {
|
|
317
|
+
const newChunkLength = Math.min(end - index, 500);
|
|
318
|
+
for (let i = 0; i < newChunkLength; i++) {
|
|
319
|
+
array[i] = read(a, index++);
|
|
320
|
+
}
|
|
321
|
+
if (newChunkLength < chunkLength) {
|
|
322
|
+
array = array.slice(0, newChunkLength);
|
|
323
|
+
}
|
|
324
|
+
result += String.fromCharCode(...array);
|
|
325
|
+
}
|
|
326
|
+
return result;
|
|
327
|
+
},
|
|
328
|
+
"intoCharCodeArray": (s, a, start) => {
|
|
329
|
+
if (s === '') return 0;
|
|
330
|
+
|
|
331
|
+
const write = dartInstance.exports.$wasmI16ArraySet;
|
|
332
|
+
for (var i = 0; i < s.length; ++i) {
|
|
333
|
+
write(a, start++, s.charCodeAt(i));
|
|
334
|
+
}
|
|
335
|
+
return s.length;
|
|
336
|
+
},
|
|
337
|
+
"test": (s) => typeof s == "string",
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
dartInstance = await WebAssembly.instantiate(this.module, {
|
|
344
|
+
...baseImports,
|
|
345
|
+
...additionalImports,
|
|
346
|
+
|
|
347
|
+
"wasm:js-string": jsStringPolyfill,
|
|
348
|
+
});
|
|
349
|
+
dartInstance.exports.$setThisModule(dartInstance);
|
|
350
|
+
|
|
351
|
+
return new InstantiatedApp(this, dartInstance);
|
|
352
|
+
}
|
|
349
353
|
}
|
|
354
|
+
|
|
350
355
|
class InstantiatedApp {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
356
|
+
constructor(compiledApp, instantiatedModule) {
|
|
357
|
+
this.compiledApp = compiledApp;
|
|
358
|
+
this.instantiatedModule = instantiatedModule;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// Call the main function with the given arguments.
|
|
362
|
+
invokeMain(...args) {
|
|
363
|
+
this.instantiatedModule.exports.$invokeMain(args);
|
|
364
|
+
}
|
|
359
365
|
}
|
package/dist/node.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED