@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 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 '@cparra/apex-reflection';
17
+ import { reflect } from "@cparra/apex-reflection";
19
18
 
20
- const classBody = 'public with sharing class ExampleClass {}';
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` or an `EnumMirror`) or a `ParsingError` if the passed in
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 JS output must be tested.
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 individual Dart file
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 `js/apex-reflection-node/__tests__`. These are end-to-end tests that ensure that the transpiled JS
53
- code is working as intended.
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
- antlr4 -Dlanguage=Dart lib/src/antlr/grammars/apex/ApexLexer.g4 lib/src/antlr/grammars/apex/ApexParser.g4 -o lib/src/antlr/lib/apex/
75
+ dart run build_runner build
79
76
  ```
80
77
 
81
- To generate the Antlr4 Apexdoc output run:
78
+ ### Parsing
82
79
 
83
- ```shell
84
- antlr4 -Dlanguage=Dart lib/src/antlr/grammars/apexdoc/ApexdocLexer.g4 lib/src/antlr/grammars/apexdoc/ApexdocParser.g4 -o lib/src/antlr/lib/apexdoc/
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
- const builtins = { builtins: ['js-string'] };
8
- return new CompiledApp(await WebAssembly.compileStreaming(source, builtins), builtins);
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
- const builtins = { builtins: ['js-string'] };
14
- return new CompiledApp(await WebAssembly.compile(bytes, builtins), builtins);
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
- var moduleOrCompiledApp = await modulePromise;
21
- if (!(moduleOrCompiledApp instanceof CompiledApp)) {
22
- moduleOrCompiledApp = new CompiledApp(moduleOrCompiledApp);
23
- }
24
- const instantiatedApp = await moduleOrCompiledApp.instantiate(await importObjectPromise);
25
- return instantiatedApp.instantiatedModule;
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
- moduleInstance.exports.$invokeMain(args);
32
- };
35
+ moduleInstance.exports.$invokeMain(args);
36
+ }
37
+
33
38
  class CompiledApp {
34
- constructor(module, builtins) {
35
- this.module = module;
36
- this.builtins = builtins;
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
- // The second argument is an options object containing:
39
- // `loadDeferredModule` is a JS function that takes a module name matching a
40
- // wasm file produced by the dart2wasm compiler and returns the bytes to
41
- // load the module. These bytes can be in either a format supported by
42
- // `WebAssembly.compile` or `WebAssembly.compileStreaming`.
43
- // `loadDynamicModule` is a JS function that takes two string names matching,
44
- // in order, a wasm file produced by the dart2wasm compiler during dynamic
45
- // module compilation and a corresponding js file produced by the same
46
- // compilation. It should return a JS Array containing 2 elements. The first
47
- // should be the bytes for the wasm module in a format supported by
48
- // `WebAssembly.compile` or `WebAssembly.compileStreaming`. The second
49
- // should be the result of using the JS 'import' API on the js file path.
50
- // `loadDeferredId` is a JS function that takes a string corresponding to a load
51
- // ID generated by the compiler when 'load-ids' option is passed. Each load
52
- // ID maps to one or more WASM modules produced by the compiler. This
53
- // function should return an array of byte arrays corresponding to all the
54
- // modules specified by that load ID. The arrays should be in a format
55
- // supported by `WebAssembly.compile` or `WebAssembly.compileStreaming`.
56
- async instantiate(additionalImports, { loadDeferredModule, loadDynamicModule, loadDeferredId } = {}) {
57
- let dartInstance;
58
- // Prints to the console
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
- // A special symbol attached to functions that wrap Dart functions.
75
- const jsWrappedDartFunctionSymbol = Symbol("JSWrappedDartFunction");
76
- function finalizeWrapper(dartFunction, wrapped) {
77
- wrapped.dartFunction = dartFunction;
78
- wrapped[jsWrappedDartFunctionSymbol] = true;
79
- return wrapped;
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
- // Imports
82
- const dart2wasm = {
83
- _9: () => new Error().stack,
84
- _18: (exn) => exn.toString(),
85
- _19: (exn) => exn.stack,
86
- _20: (exn) => {
87
- let stackString = exn.toString();
88
- let frames = stackString.split('\n');
89
- let drop = 2;
90
- if (frames[0] === 'Error') {
91
- drop += 1;
92
- }
93
- return frames.slice(drop).join('\n');
94
- },
95
- _33: s => JSON.stringify(s),
96
- _34: s => printToConsole(s),
97
- _37: Function.prototype.call.bind(String.prototype.toLowerCase),
98
- _39: s => s.trim(),
99
- _40: s => s.trimLeft(),
100
- _41: s => s.trimRight(),
101
- _42: (string, times) => string.repeat(times),
102
- _43: Function.prototype.call.bind(String.prototype.indexOf),
103
- _44: (s, p, i) => s.lastIndexOf(p, i),
104
- _45: (string, token) => string.split(token),
105
- _46: Object.is,
106
- _53: (o, s, v) => o[s] = v,
107
- _82: x0 => new Array(x0),
108
- _84: x0 => x0.length,
109
- _86: (x0, x1) => x0[x1],
110
- _87: (x0, x1, x2) => { x0[x1] = x2; },
111
- _89: x0 => new Promise(x0),
112
- _91: (x0, x1, x2) => new DataView(x0, x1, x2),
113
- _93: x0 => new Int8Array(x0),
114
- _94: (x0, x1, x2) => new Uint8Array(x0, x1, x2),
115
- _95: x0 => new Uint8Array(x0),
116
- _97: x0 => new Uint8ClampedArray(x0),
117
- _99: x0 => new Int16Array(x0),
118
- _101: x0 => new Uint16Array(x0),
119
- _103: x0 => new Int32Array(x0),
120
- _105: x0 => new Uint32Array(x0),
121
- _107: x0 => new Float32Array(x0),
122
- _109: x0 => new Float64Array(x0),
123
- _129: (x0, x1, x2) => x0.call(x1, x2),
124
- _130: (module, f) => finalizeWrapper(f, function (x0, x1) { return module.exports._130(f, arguments.length, x0, x1); }),
125
- _133: () => Symbol("jsBoxedDartObjectProperty"),
126
- _134: x0 => x0.random(),
127
- _137: () => globalThis.Math,
128
- _150: (ms, c) => setTimeout(() => dartInstance.exports.$invokeCallback(c), ms),
129
- _154: (c) => queueMicrotask(() => dartInstance.exports.$invokeCallback(c)),
130
- _156: (s, m) => {
131
- try {
132
- return new RegExp(s, m);
133
- }
134
- catch (e) {
135
- return String(e);
136
- }
137
- },
138
- _157: (x0, x1) => x0.exec(x1),
139
- _158: (x0, x1) => x0.test(x1),
140
- _161: o => o === undefined,
141
- _163: o => typeof o === 'function' && o[jsWrappedDartFunctionSymbol] === true,
142
- _166: o => o instanceof RegExp,
143
- _167: (l, r) => l === r,
144
- _168: o => o,
145
- _169: o => o,
146
- _170: o => o,
147
- _171: b => !!b,
148
- _172: o => o.length,
149
- _174: (o, i) => o[i],
150
- _175: f => f.dartFunction,
151
- _176: () => ({}),
152
- _179: () => globalThis,
153
- _180: (constructor, args) => {
154
- const factoryFunction = constructor.bind.apply(constructor, [null, ...args]);
155
- return new factoryFunction();
156
- },
157
- _182: (o, p) => o[p],
158
- _186: o => String(o),
159
- _187: (p, s, f) => p.then(s, (e) => f(e, e === undefined)),
160
- _188: (module, f) => finalizeWrapper(f, function (x0) { return module.exports._188(f, arguments.length, x0); }),
161
- _189: (module, f) => finalizeWrapper(f, function (x0, x1) { return module.exports._189(f, arguments.length, x0, x1); }),
162
- _190: o => {
163
- if (o === undefined)
164
- return 1;
165
- var type = typeof o;
166
- if (type === 'boolean')
167
- return 2;
168
- if (type === 'number')
169
- return 3;
170
- if (type === 'string')
171
- return 4;
172
- if (o instanceof Array)
173
- return 5;
174
- if (ArrayBuffer.isView(o)) {
175
- if (o instanceof Int8Array)
176
- return 6;
177
- if (o instanceof Uint8Array)
178
- return 7;
179
- if (o instanceof Uint8ClampedArray)
180
- return 8;
181
- if (o instanceof Int16Array)
182
- return 9;
183
- if (o instanceof Uint16Array)
184
- return 10;
185
- if (o instanceof Int32Array)
186
- return 11;
187
- if (o instanceof Uint32Array)
188
- return 12;
189
- if (o instanceof Float32Array)
190
- return 13;
191
- if (o instanceof Float64Array)
192
- return 14;
193
- if (o instanceof DataView)
194
- return 15;
195
- }
196
- if (o instanceof ArrayBuffer)
197
- return 16;
198
- // Feature check for `SharedArrayBuffer` before doing a type-check.
199
- if (globalThis.SharedArrayBuffer !== undefined &&
200
- o instanceof SharedArrayBuffer) {
201
- return 17;
202
- }
203
- if (o instanceof Promise)
204
- return 18;
205
- return 19;
206
- },
207
- _191: o => [o],
208
- _192: (o0, o1) => [o0, o1],
209
- _193: (o0, o1, o2) => [o0, o1, o2],
210
- _194: (o0, o1, o2, o3) => [o0, o1, o2, o3],
211
- _199: (jsArray, jsArrayOffset, wasmArray, wasmArrayOffset, length) => {
212
- const getValue = dartInstance.exports.$wasmI32ArrayGet;
213
- for (let i = 0; i < length; i++) {
214
- jsArray[jsArrayOffset + i] = getValue(wasmArray, wasmArrayOffset + i);
215
- }
216
- },
217
- _205: x0 => new ArrayBuffer(x0),
218
- _208: x0 => x0.index,
219
- _210: x0 => x0.flags,
220
- _211: x0 => x0.multiline,
221
- _212: x0 => x0.ignoreCase,
222
- _213: x0 => x0.unicode,
223
- _214: x0 => x0.dotAll,
224
- _215: (x0, x1) => { x0.lastIndex = x1; },
225
- _217: (o, p) => o[p],
226
- _218: (o, p, v) => o[p] = v,
227
- _220: o => o instanceof Array,
228
- _227: (a, s) => a.join(s),
229
- _231: a => a.length,
230
- _233: (a, i) => a[i],
231
- _239: o => o instanceof Uint8Array,
232
- _240: (o, start, length) => new Uint8Array(o.buffer, o.byteOffset + start, length),
233
- _241: o => o instanceof Int8Array,
234
- _242: (o, start, length) => new Int8Array(o.buffer, o.byteOffset + start, length),
235
- _243: o => o instanceof Uint8ClampedArray,
236
- _244: (o, start, length) => new Uint8ClampedArray(o.buffer, o.byteOffset + start, length),
237
- _245: o => o instanceof Uint16Array,
238
- _246: (o, start, length) => new Uint16Array(o.buffer, o.byteOffset + start, length),
239
- _247: o => o instanceof Int16Array,
240
- _248: (o, start, length) => new Int16Array(o.buffer, o.byteOffset + start, length),
241
- _249: o => o instanceof Uint32Array,
242
- _250: (o, start, length) => new Uint32Array(o.buffer, o.byteOffset + start, length),
243
- _251: o => o instanceof Int32Array,
244
- _252: (o, start, length) => new Int32Array(o.buffer, o.byteOffset + start, length),
245
- _255: o => o instanceof Float32Array,
246
- _256: (o, start, length) => new Float32Array(o.buffer, o.byteOffset + start, length),
247
- _257: o => o instanceof Float64Array,
248
- _258: (o, start, length) => new Float64Array(o.buffer, o.byteOffset + start, length),
249
- _259: (t, s) => t.set(s),
250
- _261: (o) => new DataView(o.buffer, o.byteOffset, o.byteLength),
251
- _263: o => o.buffer,
252
- _264: o => o.byteOffset,
253
- _265: Function.prototype.call.bind(Object.getOwnPropertyDescriptor(DataView.prototype, 'byteLength').get),
254
- _266: (b, o) => new DataView(b, o),
255
- _267: (b, o, l) => new DataView(b, o, l),
256
- _268: Function.prototype.call.bind(DataView.prototype.getUint8),
257
- _269: Function.prototype.call.bind(DataView.prototype.setUint8),
258
- _270: Function.prototype.call.bind(DataView.prototype.getInt8),
259
- _271: Function.prototype.call.bind(DataView.prototype.setInt8),
260
- _272: Function.prototype.call.bind(DataView.prototype.getUint16),
261
- _273: Function.prototype.call.bind(DataView.prototype.setUint16),
262
- _274: Function.prototype.call.bind(DataView.prototype.getInt16),
263
- _275: Function.prototype.call.bind(DataView.prototype.setInt16),
264
- _276: Function.prototype.call.bind(DataView.prototype.getUint32),
265
- _277: Function.prototype.call.bind(DataView.prototype.setUint32),
266
- _278: Function.prototype.call.bind(DataView.prototype.getInt32),
267
- _279: Function.prototype.call.bind(DataView.prototype.setInt32),
268
- _284: Function.prototype.call.bind(DataView.prototype.getFloat32),
269
- _285: Function.prototype.call.bind(DataView.prototype.setFloat32),
270
- _286: Function.prototype.call.bind(DataView.prototype.getFloat64),
271
- _287: Function.prototype.call.bind(DataView.prototype.setFloat64),
272
- _288: Function.prototype.call.bind(Number.prototype.toString),
273
- _289: Function.prototype.call.bind(BigInt.prototype.toString),
274
- _290: Function.prototype.call.bind(Number.prototype.toString),
275
- _295: x0 => { globalThis.reflect = x0; },
276
- _296: x0 => { globalThis.reflectAsync = x0; },
277
- _297: x0 => { globalThis.reflectTrigger = x0; },
278
- _298: x0 => { globalThis.reflectTriggerAsync = x0; },
279
- _299: (module, f) => finalizeWrapper(f, function (x0) { return module.exports._299(f, arguments.length, x0); }),
280
- _300: (module, f) => finalizeWrapper(f, function (x0) { return module.exports._300(f, arguments.length, x0); }),
281
- _301: (module, f) => finalizeWrapper(f, function (x0) { return module.exports._301(f, arguments.length, x0); }),
282
- _302: (module, f) => finalizeWrapper(f, function (x0) { return module.exports._302(f, arguments.length, x0); }),
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
- constructor(compiledApp, instantiatedModule) {
352
- this.compiledApp = compiledApp;
353
- this.instantiatedModule = instantiatedModule;
354
- }
355
- // Call the main function with the given arguments.
356
- invokeMain(...args) {
357
- this.instantiatedModule.exports.$invokeMain(args);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cparra/apex-reflection",
3
- "version": "4.0.0-beta.3",
3
+ "version": "4.0.0-beta.5",
4
4
  "description": "Provides tools for reflecting Apex code, the language used in Salesforce development.",
5
5
  "main": "dist/index.mjs",
6
6
  "scripts": {