parsanol 0.10.44 → 0.10.45

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.
@@ -0,0 +1,803 @@
1
+ /* @ts-self-types="./parsanol.d.ts" */
2
+
3
+ /**
4
+ * A verified PARG artifact exposed to JavaScript: checksum-verified
5
+ * load, native parse, bindings application, embedded-suite runs and
6
+ * the binding-requirements schema (PN 2/4).
7
+ */
8
+ export class PargArtifactJs {
9
+ __destroy_into_raw() {
10
+ const ptr = this.__wbg_ptr;
11
+ this.__wbg_ptr = 0;
12
+ PargArtifactJsFinalization.unregister(this);
13
+ return ptr;
14
+ }
15
+ free() {
16
+ const ptr = this.__destroy_into_raw();
17
+ wasm.__wbg_pargartifactjs_free(ptr, 0);
18
+ }
19
+ /**
20
+ * Apply an entry's DECLARED bindings artifact (parsanol-ruby#432)
21
+ * to a parsanol-shape tree. The bindings artifact is verified
22
+ * (kind, checksum, `ts` target, binding version) and pair-checked
23
+ * against this parse artifact by grammar source hash before the
24
+ * shared apply core runs.
25
+ * @param {string} bindings_json
26
+ * @param {string} entry
27
+ * @param {string} shape_json
28
+ * @returns {string}
29
+ */
30
+ applyBindingsArtifact(bindings_json, entry, shape_json) {
31
+ let ptr0, len0, ptr1, len1, ptr2, len2;
32
+ try {
33
+ ptr0 = passStringToWasm0(bindings_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
34
+ len0 = WASM_VECTOR_LEN;
35
+ ptr1 = passStringToWasm0(entry, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
36
+ len1 = WASM_VECTOR_LEN;
37
+ ptr2 = passStringToWasm0(shape_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
38
+ len2 = WASM_VECTOR_LEN;
39
+ } catch (e) {
40
+ if (ptr2) { wasm.__wbindgen_free(ptr2, len2 * 1, 1); }
41
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
42
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
43
+ throw e;
44
+ }
45
+ const ret = wasm.pargartifactjs_applyBindingsArtifact(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
46
+ if (ret[2]) {
47
+ throw takeFromExternrefTable0(ret[1]);
48
+ }
49
+ return takeFromExternrefTable0(ret[0]);
50
+ }
51
+ /**
52
+ * Apply an entry's bindings to a parsanol-shape tree (JSON text).
53
+ * @param {string} entry
54
+ * @param {string} shape_json
55
+ * @returns {string}
56
+ */
57
+ applyBindings(entry, shape_json) {
58
+ let ptr0, len0, ptr1, len1;
59
+ try {
60
+ ptr0 = passStringToWasm0(entry, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
61
+ len0 = WASM_VECTOR_LEN;
62
+ ptr1 = passStringToWasm0(shape_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
63
+ len1 = WASM_VECTOR_LEN;
64
+ } catch (e) {
65
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
66
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
67
+ throw e;
68
+ }
69
+ const ret = wasm.pargartifactjs_applyBindings(this.__wbg_ptr, ptr0, len0, ptr1, len1);
70
+ if (ret[2]) {
71
+ throw takeFromExternrefTable0(ret[1]);
72
+ }
73
+ return takeFromExternrefTable0(ret[0]);
74
+ }
75
+ /**
76
+ * Declared entry point names, sorted.
77
+ * @returns {string[]}
78
+ */
79
+ entryNames() {
80
+ const ret = wasm.pargartifactjs_entryNames(this.__wbg_ptr);
81
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
82
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
83
+ return v1;
84
+ }
85
+ /**
86
+ * Load and checksum-verify an artifact envelope.
87
+ * @param {string} artifact_json
88
+ */
89
+ constructor(artifact_json) {
90
+ const ptr0 = passStringToWasm0(artifact_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
91
+ const len0 = WASM_VECTOR_LEN;
92
+ const ret = wasm.pargartifactjs_new(ptr0, len0);
93
+ if (ret[2]) {
94
+ throw takeFromExternrefTable0(ret[1]);
95
+ }
96
+ this.__wbg_ptr = ret[0];
97
+ PargArtifactJsFinalization.register(this, this.__wbg_ptr, this);
98
+ return this;
99
+ }
100
+ /**
101
+ * Parse and bind in one step: the bound attribute hash as JSON.
102
+ *
103
+ * Returns `{}` when the entry declares no `bindings` block — the
104
+ * parse succeeded, there was simply nothing to bind.
105
+ * @param {string} entry
106
+ * @param {string} input
107
+ * @returns {string}
108
+ */
109
+ parseAndBind(entry, input) {
110
+ let ptr0, len0, ptr1, len1;
111
+ try {
112
+ ptr0 = passStringToWasm0(entry, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
113
+ len0 = WASM_VECTOR_LEN;
114
+ ptr1 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
115
+ len1 = WASM_VECTOR_LEN;
116
+ } catch (e) {
117
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
118
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
119
+ throw e;
120
+ }
121
+ const ret = wasm.pargartifactjs_parseAndBind(this.__wbg_ptr, ptr0, len0, ptr1, len1);
122
+ if (ret[2]) {
123
+ throw takeFromExternrefTable0(ret[1]);
124
+ }
125
+ return takeFromExternrefTable0(ret[0]);
126
+ }
127
+ /**
128
+ * Best-effort recovery (TODO.sota/1): success returns
129
+ * `{"ok": true, "shape": ...}`; failure returns
130
+ * `{"ok": false, "captures": ..., "error": ..., "consumed_upto"}`.
131
+ * @param {string} entry
132
+ * @param {string} input
133
+ * @returns {string}
134
+ */
135
+ parseShapeRecovering(entry, input) {
136
+ let ptr0, len0, ptr1, len1;
137
+ try {
138
+ ptr0 = passStringToWasm0(entry, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
139
+ len0 = WASM_VECTOR_LEN;
140
+ ptr1 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
141
+ len1 = WASM_VECTOR_LEN;
142
+ } catch (e) {
143
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
144
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
145
+ throw e;
146
+ }
147
+ const ret = wasm.pargartifactjs_parseShapeRecovering(this.__wbg_ptr, ptr0, len0, ptr1, len1);
148
+ if (ret[2]) {
149
+ throw takeFromExternrefTable0(ret[1]);
150
+ }
151
+ return takeFromExternrefTable0(ret[0]);
152
+ }
153
+ /**
154
+ * Explicit compatibility without changing parseShape defaults.
155
+ * The JSON envelope contains either shape or causal error diagnostics;
156
+ * it does not claim best-effort recovery captures.
157
+ * @param {string} entry
158
+ * @param {string} input
159
+ * @param {string} compatibility
160
+ * @returns {string}
161
+ */
162
+ parseShapeWithCompatibility(entry, input, compatibility) {
163
+ let ptr0, len0, ptr1, len1, ptr2, len2;
164
+ try {
165
+ ptr0 = passStringToWasm0(entry, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
166
+ len0 = WASM_VECTOR_LEN;
167
+ ptr1 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
168
+ len1 = WASM_VECTOR_LEN;
169
+ ptr2 = passStringToWasm0(compatibility, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
170
+ len2 = WASM_VECTOR_LEN;
171
+ } catch (e) {
172
+ if (ptr2) { wasm.__wbindgen_free(ptr2, len2 * 1, 1); }
173
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
174
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
175
+ throw e;
176
+ }
177
+ const ret = wasm.pargartifactjs_parseShapeWithCompatibility(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
178
+ if (ret[2]) {
179
+ throw takeFromExternrefTable0(ret[1]);
180
+ }
181
+ return takeFromExternrefTable0(ret[0]);
182
+ }
183
+ /**
184
+ * Parse an entry with the native engine; returns the parsanol-shape
185
+ * tree as JSON text.
186
+ * @param {string} entry
187
+ * @param {string} input
188
+ * @returns {string}
189
+ */
190
+ parseShape(entry, input) {
191
+ let ptr0, len0, ptr1, len1;
192
+ try {
193
+ ptr0 = passStringToWasm0(entry, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
194
+ len0 = WASM_VECTOR_LEN;
195
+ ptr1 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
196
+ len1 = WASM_VECTOR_LEN;
197
+ } catch (e) {
198
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
199
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
200
+ throw e;
201
+ }
202
+ const ret = wasm.pargartifactjs_parseShape(this.__wbg_ptr, ptr0, len0, ptr1, len1);
203
+ if (ret[2]) {
204
+ throw takeFromExternrefTable0(ret[1]);
205
+ }
206
+ return takeFromExternrefTable0(ret[0]);
207
+ }
208
+ /**
209
+ * Run the artifact's embedded tests; returns the failure list as
210
+ * JSON (empty array means green).
211
+ * @returns {string}
212
+ */
213
+ runTests() {
214
+ const ret = wasm.pargartifactjs_runTests(this.__wbg_ptr);
215
+ if (ret[2]) {
216
+ throw takeFromExternrefTable0(ret[1]);
217
+ }
218
+ return takeFromExternrefTable0(ret[0]);
219
+ }
220
+ /**
221
+ * The binding-requirements schema as TypeScript source.
222
+ * @returns {string}
223
+ */
224
+ schemaTypescript() {
225
+ const ret = wasm.pargartifactjs_schemaTypescript(this.__wbg_ptr);
226
+ if (ret[2]) {
227
+ throw takeFromExternrefTable0(ret[1]);
228
+ }
229
+ return takeFromExternrefTable0(ret[0]);
230
+ }
231
+ /**
232
+ * The binding-requirements schema as JSON text.
233
+ * @returns {string}
234
+ */
235
+ schema() {
236
+ const ret = wasm.pargartifactjs_schema(this.__wbg_ptr);
237
+ if (ret[2]) {
238
+ throw takeFromExternrefTable0(ret[1]);
239
+ }
240
+ return takeFromExternrefTable0(ret[0]);
241
+ }
242
+ /**
243
+ * The semantics hash (ruby#377): sha256 over the canonicalized
244
+ * envelope minus the producer set — byte-stable across re-bakes
245
+ * by a newer compiler when the grammar is unchanged. `undefined`
246
+ * on artifacts baked before the field existed.
247
+ * @returns {string | undefined}
248
+ */
249
+ semanticsHash() {
250
+ const ret = wasm.pargartifactjs_semanticsHash(this.__wbg_ptr);
251
+ return ret;
252
+ }
253
+ }
254
+ if (Symbol.dispose) PargArtifactJs.prototype[Symbol.dispose] = PargArtifactJs.prototype.free;
255
+
256
+ /**
257
+ * WASM parser instance
258
+ *
259
+ * Create with `new WasmParser(grammarJson)` and parse with `parse(input)`.
260
+ */
261
+ export class WasmParser {
262
+ static __wrap(ptr) {
263
+ const obj = Object.create(WasmParser.prototype);
264
+ obj.__wbg_ptr = ptr;
265
+ WasmParserFinalization.register(obj, obj.__wbg_ptr, obj);
266
+ return obj;
267
+ }
268
+ __destroy_into_raw() {
269
+ const ptr = this.__wbg_ptr;
270
+ this.__wbg_ptr = 0;
271
+ WasmParserFinalization.unregister(this);
272
+ return ptr;
273
+ }
274
+ free() {
275
+ const ptr = this.__destroy_into_raw();
276
+ wasm.__wbg_wasmparser_free(ptr, 0);
277
+ }
278
+ /**
279
+ * Create a new parser from a PARG artifact envelope and entry name.
280
+ *
281
+ * The artifact's canonical checksum is verified before any parsing;
282
+ * a mismatched or corrupt artifact is rejected (PN 2).
283
+ *
284
+ * # Arguments
285
+ * * `artifact_json` - JSON text of the PARG artifact envelope
286
+ * * `entry` - entry point name declared in the artifact
287
+ * @param {string} artifact_json
288
+ * @param {string} entry
289
+ * @returns {WasmParser}
290
+ */
291
+ static fromArtifact(artifact_json, entry) {
292
+ let ptr0, len0, ptr1, len1;
293
+ try {
294
+ ptr0 = passStringToWasm0(artifact_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
295
+ len0 = WASM_VECTOR_LEN;
296
+ ptr1 = passStringToWasm0(entry, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
297
+ len1 = WASM_VECTOR_LEN;
298
+ } catch (e) {
299
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
300
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
301
+ throw e;
302
+ }
303
+ const ret = wasm.wasmparser_fromArtifact(ptr0, len0, ptr1, len1);
304
+ if (ret[2]) {
305
+ throw takeFromExternrefTable0(ret[1]);
306
+ }
307
+ return WasmParser.__wrap(ret[0]);
308
+ }
309
+ /**
310
+ * Create a new parser from grammar JSON
311
+ *
312
+ * # Arguments
313
+ * * `grammar_json` - JSON string representing the grammar
314
+ *
315
+ * # Returns
316
+ * A new WasmParser instance
317
+ *
318
+ * # Throws
319
+ * If the grammar JSON is invalid
320
+ * @param {string} grammar_json
321
+ */
322
+ constructor(grammar_json) {
323
+ const ptr0 = passStringToWasm0(grammar_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
324
+ const len0 = WASM_VECTOR_LEN;
325
+ const ret = wasm.wasmparser_new(ptr0, len0);
326
+ if (ret[2]) {
327
+ throw takeFromExternrefTable0(ret[1]);
328
+ }
329
+ this.__wbg_ptr = ret[0];
330
+ WasmParserFinalization.register(this, this.__wbg_ptr, this);
331
+ return this;
332
+ }
333
+ /**
334
+ * Parse input and return JavaScript AST
335
+ *
336
+ * # Arguments
337
+ * * `input` - The input string to parse
338
+ *
339
+ * # Returns
340
+ * A JavaScript object representing the parsed AST
341
+ *
342
+ * # Throws
343
+ * If parsing fails
344
+ * @param {string} input
345
+ * @returns {any}
346
+ */
347
+ parse(input) {
348
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
349
+ const len0 = WASM_VECTOR_LEN;
350
+ const ret = wasm.wasmparser_parse(this.__wbg_ptr, ptr0, len0);
351
+ if (ret[2]) {
352
+ throw takeFromExternrefTable0(ret[1]);
353
+ }
354
+ return takeFromExternrefTable0(ret[0]);
355
+ }
356
+ /**
357
+ * Parse and return flat array (for Opal compatibility)
358
+ *
359
+ * # Arguments
360
+ * * `input` - The input string to parse
361
+ *
362
+ * # Returns
363
+ * A Uint32Array containing the flattened AST
364
+ *
365
+ * # Throws
366
+ * If parsing fails
367
+ * @param {string} input
368
+ * @returns {BigUint64Array}
369
+ */
370
+ parse_flat(input) {
371
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
372
+ const len0 = WASM_VECTOR_LEN;
373
+ const ret = wasm.wasmparser_parse_flat(this.__wbg_ptr, ptr0, len0);
374
+ if (ret[3]) {
375
+ throw takeFromExternrefTable0(ret[2]);
376
+ }
377
+ var v2 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
378
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
379
+ return v2;
380
+ }
381
+ /**
382
+ * Parse and return JSON string
383
+ *
384
+ * # Arguments
385
+ * * `input` - The input string to parse
386
+ *
387
+ * # Returns
388
+ * A JSON string representing the parsed AST
389
+ *
390
+ * # Throws
391
+ * If parsing fails
392
+ * @param {string} input
393
+ * @returns {string}
394
+ */
395
+ parse_json(input) {
396
+ let deferred3_0;
397
+ let deferred3_1;
398
+ try {
399
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
400
+ const len0 = WASM_VECTOR_LEN;
401
+ const ret = wasm.wasmparser_parse_json(this.__wbg_ptr, ptr0, len0);
402
+ var ptr2 = ret[0];
403
+ var len2 = ret[1];
404
+ if (ret[3]) {
405
+ ptr2 = 0; len2 = 0;
406
+ throw takeFromExternrefTable0(ret[2]);
407
+ }
408
+ deferred3_0 = ptr2;
409
+ deferred3_1 = len2;
410
+ return getStringFromWasm0(ptr2, len2);
411
+ } finally {
412
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
413
+ }
414
+ }
415
+ }
416
+ if (Symbol.dispose) WasmParser.prototype[Symbol.dispose] = WasmParser.prototype.free;
417
+
418
+ /**
419
+ * Compile PARG source to a checksummed artifact — the playground's
420
+ * compiler-in-the-browser (site#19). Single-file grammars: `use`
421
+ * imports have no filesystem here and reject with the merge error.
422
+ * @param {string} source
423
+ * @returns {string}
424
+ */
425
+ export function compileSource(source) {
426
+ let deferred3_0;
427
+ let deferred3_1;
428
+ try {
429
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
430
+ const len0 = WASM_VECTOR_LEN;
431
+ const ret = wasm.compileSource(ptr0, len0);
432
+ var ptr2 = ret[0];
433
+ var len2 = ret[1];
434
+ if (ret[3]) {
435
+ ptr2 = 0; len2 = 0;
436
+ throw takeFromExternrefTable0(ret[2]);
437
+ }
438
+ deferred3_0 = ptr2;
439
+ deferred3_1 = len2;
440
+ return getStringFromWasm0(ptr2, len2);
441
+ } finally {
442
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
443
+ }
444
+ }
445
+
446
+ /**
447
+ * Install the panic hook (better panic messages in the console).
448
+ *
449
+ * The glue's real bootstrap is the DEFAULT export —
450
+ * `__wbg_init(module_or_path?)` / `initSync` — which calls this on
451
+ * its way up; calling it directly is only needed outside the
452
+ * bootstrap. It is deliberately NOT named `init`: that name in the
453
+ * generated d.ts typed the bootstrap as `() => void` and hid the
454
+ * real signatures (rs#308).
455
+ */
456
+ export function setPanicHook() {
457
+ wasm.setPanicHook();
458
+ }
459
+ function __wbg_get_imports() {
460
+ const import0 = {
461
+ __proto__: null,
462
+ __wbg___wbindgen_string_get_7ce8eee7fd327545: function(arg0, arg1) {
463
+ const obj = arg1;
464
+ const ret = typeof(obj) === 'string' ? obj : undefined;
465
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
466
+ var len1 = WASM_VECTOR_LEN;
467
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
468
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
469
+ },
470
+ __wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
471
+ throw new Error(getStringFromWasm0(arg0, arg1));
472
+ },
473
+ __wbg_error_757e9472f8410341: function(arg0, arg1) {
474
+ let deferred0_0;
475
+ let deferred0_1;
476
+ try {
477
+ deferred0_0 = arg0;
478
+ deferred0_1 = arg1;
479
+ console.error(getStringFromWasm0(arg0, arg1));
480
+ } finally {
481
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
482
+ }
483
+ },
484
+ __wbg_getRandomValues_5d8c030b527203a6: function() { return handleError(function (arg0, arg1) {
485
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
486
+ }, arguments); },
487
+ __wbg_new_37eb45aaf5eeb820: function() {
488
+ const ret = new Array();
489
+ return ret;
490
+ },
491
+ __wbg_new_787b9fb330d55d78: function(arg0, arg1) {
492
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
493
+ return ret;
494
+ },
495
+ __wbg_new_bb74001155cb8ca8: function() {
496
+ const ret = new Error();
497
+ return ret;
498
+ },
499
+ __wbg_new_cd4348290afae586: function() {
500
+ const ret = new Object();
501
+ return ret;
502
+ },
503
+ __wbg_push_c9f4893fc209f768: function(arg0, arg1) {
504
+ const ret = arg0.push(arg1);
505
+ return ret;
506
+ },
507
+ __wbg_set_2793479888329cb6: function() { return handleError(function (arg0, arg1, arg2) {
508
+ const ret = Reflect.set(arg0, arg1, arg2);
509
+ return ret;
510
+ }, arguments); },
511
+ __wbg_set_name_822e3903f3184979: function(arg0, arg1, arg2) {
512
+ arg0.name = getStringFromWasm0(arg1, arg2);
513
+ },
514
+ __wbg_stack_575c4e0918581b9c: function(arg0, arg1) {
515
+ const ret = arg1.stack;
516
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
517
+ const len1 = WASM_VECTOR_LEN;
518
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
519
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
520
+ },
521
+ __wbg_stringify_0a0fbf2ef722380a: function() { return handleError(function (arg0) {
522
+ const ret = JSON.stringify(arg0);
523
+ return ret;
524
+ }, arguments); },
525
+ __wbindgen_generic_0000000000000001: function(arg0) {
526
+ // Cast intrinsic for `F64 -> Externref`.
527
+ const ret = arg0;
528
+ return ret;
529
+ },
530
+ __wbindgen_generic_0000000000000002: function(arg0, arg1) {
531
+ // Cast intrinsic for `Ref(String) -> Externref`.
532
+ const ret = getStringFromWasm0(arg0, arg1);
533
+ return ret;
534
+ },
535
+ __wbindgen_init_externref_table: function() {
536
+ const table = wasm.__wbindgen_externrefs;
537
+ table.set(0, undefined);
538
+ table.set(1024, undefined);
539
+ table.set(1025, null);
540
+ table.set(1026, true);
541
+ table.set(1027, false);
542
+ },
543
+ };
544
+ return {
545
+ __proto__: null,
546
+ "./parsanol_bg.js": import0,
547
+ };
548
+ }
549
+
550
+ const PargArtifactJsFinalization = (typeof FinalizationRegistry === 'undefined')
551
+ ? { register: () => {}, unregister: () => {} }
552
+ : new FinalizationRegistry(ptr => wasm.__wbg_pargartifactjs_free(ptr, 1));
553
+ const WasmParserFinalization = (typeof FinalizationRegistry === 'undefined')
554
+ ? { register: () => {}, unregister: () => {} }
555
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmparser_free(ptr, 1));
556
+
557
+ function addToExternrefTable0(obj) {
558
+ const idx = wasm.__externref_table_alloc();
559
+ wasm.__wbindgen_externrefs.set(idx, obj);
560
+ return idx;
561
+ }
562
+
563
+ function getArrayJsValueFromWasm0(ptr, len) {
564
+ ptr = ptr >>> 0;
565
+ const mem = getDataViewMemory0();
566
+ const result = [];
567
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
568
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
569
+ }
570
+ wasm.__externref_drop_slice(ptr, len);
571
+ return result;
572
+ }
573
+
574
+ function getArrayU64FromWasm0(ptr, len) {
575
+ ptr = ptr >>> 0;
576
+ return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
577
+ }
578
+
579
+ function getArrayU8FromWasm0(ptr, len) {
580
+ ptr = ptr >>> 0;
581
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
582
+ }
583
+
584
+ let cachedBigUint64ArrayMemory0 = null;
585
+ function getBigUint64ArrayMemory0() {
586
+ if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
587
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
588
+ }
589
+ return cachedBigUint64ArrayMemory0;
590
+ }
591
+
592
+ let cachedDataViewMemory0 = null;
593
+ function getDataViewMemory0() {
594
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
595
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
596
+ }
597
+ return cachedDataViewMemory0;
598
+ }
599
+
600
+ function getStringFromWasm0(ptr, len) {
601
+ ptr = ptr >>> 0;
602
+ return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
603
+ }
604
+
605
+ let cachedUint8ArrayMemory0 = null;
606
+ function getUint8ArrayMemory0() {
607
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
608
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
609
+ }
610
+ return cachedUint8ArrayMemory0;
611
+ }
612
+
613
+ function handleError(f, args) {
614
+ try {
615
+ return f.apply(this, args);
616
+ } catch (e) {
617
+ const idx = addToExternrefTable0(e);
618
+ wasm.__wbindgen_exn_store(idx);
619
+ }
620
+ }
621
+
622
+ function isLikeNone(x) {
623
+ return x === undefined || x === null;
624
+ }
625
+
626
+ function passStringToWasm0(arg, malloc, realloc) {
627
+ if (realloc === undefined) {
628
+ const buf = cachedTextEncoder.encode(arg);
629
+ const ptr = malloc(buf.length, 1) >>> 0;
630
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
631
+ WASM_VECTOR_LEN = buf.length;
632
+ return ptr;
633
+ }
634
+
635
+ let len = arg.length;
636
+ let ptr = malloc(len, 1) >>> 0;
637
+
638
+ const mem = getUint8ArrayMemory0();
639
+
640
+ let offset = 0;
641
+
642
+ for (; offset < len; offset++) {
643
+ const code = arg.charCodeAt(offset);
644
+ if (code > 0x7F) break;
645
+ mem[ptr + offset] = code;
646
+ }
647
+ if (offset !== len) {
648
+ if (offset !== 0) {
649
+ arg = arg.slice(offset);
650
+ }
651
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
652
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
653
+ const ret = cachedTextEncoder.encodeInto(arg, view);
654
+
655
+ offset += ret.written;
656
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
657
+ }
658
+
659
+ WASM_VECTOR_LEN = offset;
660
+ return ptr;
661
+ }
662
+
663
+ function takeFromExternrefTable0(idx) {
664
+ const value = wasm.__wbindgen_externrefs.get(idx);
665
+ wasm.__externref_table_dealloc(idx);
666
+ return value;
667
+ }
668
+
669
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
670
+ cachedTextDecoder.decode();
671
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
672
+ let numBytesDecoded = 0;
673
+ function decodeText(bytes) {
674
+ numBytesDecoded += bytes.length;
675
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
676
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
677
+ cachedTextDecoder.decode();
678
+ numBytesDecoded = bytes.length;
679
+ }
680
+ return cachedTextDecoder.decode(bytes);
681
+ }
682
+
683
+ const cachedTextEncoder = new TextEncoder();
684
+
685
+ if (!('encodeInto' in cachedTextEncoder)) {
686
+ cachedTextEncoder.encodeInto = function (arg, view) {
687
+ const buf = cachedTextEncoder.encode(arg);
688
+ view.set(buf);
689
+ return {
690
+ read: arg.length,
691
+ written: buf.length
692
+ };
693
+ };
694
+ }
695
+
696
+ let WASM_VECTOR_LEN = 0;
697
+
698
+ let wasmModule, wasmInstance, wasm;
699
+ function __wbg_finalize_init(instance, module) {
700
+ wasmInstance = instance;
701
+ wasm = instance.exports;
702
+ wasmModule = module;
703
+ cachedBigUint64ArrayMemory0 = null;
704
+ cachedDataViewMemory0 = null;
705
+ cachedUint8ArrayMemory0 = null;
706
+ wasm.__wbindgen_start();
707
+ return wasm;
708
+ }
709
+
710
+ async function __wbg_load(module, imports) {
711
+ if (typeof Response === 'function' && module instanceof Response) {
712
+ if (!module.ok) {
713
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
714
+ }
715
+
716
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
717
+ try {
718
+ return await WebAssembly.instantiateStreaming(module, imports);
719
+ } catch (e) {
720
+ const validResponse = expectedResponseType(module.type);
721
+
722
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
723
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
724
+
725
+ } else { throw e; }
726
+ }
727
+ }
728
+
729
+ const bytes = await module.arrayBuffer();
730
+ return await WebAssembly.instantiate(bytes, imports);
731
+ } else {
732
+ const instance = await WebAssembly.instantiate(module, imports);
733
+
734
+ if (instance instanceof WebAssembly.Instance) {
735
+ return { instance, module };
736
+ } else {
737
+ return instance;
738
+ }
739
+ }
740
+
741
+ function expectedResponseType(type) {
742
+ switch (type) {
743
+ case 'basic': case 'cors': case 'default': return true;
744
+ }
745
+ return false;
746
+ }
747
+ }
748
+
749
+ function initSync(module) {
750
+ if (wasm !== undefined) return wasm;
751
+
752
+
753
+ if (module !== undefined) {
754
+ if (Object.getPrototypeOf(module) === Object.prototype) {
755
+ ({module} = module)
756
+ } else {
757
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
758
+ }
759
+ }
760
+
761
+ const imports = __wbg_get_imports();
762
+ if (!(module instanceof WebAssembly.Module)) {
763
+ module = new WebAssembly.Module(module);
764
+ }
765
+ const instance = new WebAssembly.Instance(module, imports);
766
+ return __wbg_finalize_init(instance, module);
767
+ }
768
+
769
+ let __wbg_init_promise;
770
+ async function __wbg_init(module_or_path) {
771
+ if (wasm !== undefined) return wasm;
772
+ if (__wbg_init_promise === undefined) {
773
+ __wbg_init_promise = __wbg_init_once(module_or_path);
774
+ __wbg_init_promise.catch(() => { __wbg_init_promise = undefined; });
775
+ }
776
+ return __wbg_init_promise;
777
+ }
778
+
779
+ async function __wbg_init_once(module_or_path) {
780
+
781
+ if (module_or_path !== undefined) {
782
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
783
+ ({module_or_path} = module_or_path)
784
+ } else {
785
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
786
+ }
787
+ }
788
+
789
+ if (module_or_path === undefined) {
790
+ module_or_path = new URL('parsanol_bg.wasm', import.meta.url);
791
+ }
792
+ const imports = __wbg_get_imports();
793
+
794
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
795
+ module_or_path = fetch(module_or_path);
796
+ }
797
+
798
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
799
+
800
+ return __wbg_finalize_init(instance, module);
801
+ }
802
+
803
+ export { initSync, __wbg_init as default };