brass-runtime 1.13.4 → 1.13.6

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,657 @@
1
+ /* @ts-self-types="./brass_runtime_wasm_engine.d.ts" */
2
+
3
+ class BrassWasmChunkBuffer {
4
+ __destroy_into_raw() {
5
+ const ptr = this.__wbg_ptr;
6
+ this.__wbg_ptr = 0;
7
+ BrassWasmChunkBufferFinalization.unregister(this);
8
+ return ptr;
9
+ }
10
+ free() {
11
+ const ptr = this.__destroy_into_raw();
12
+ wasm.__wbg_brasswasmchunkbuffer_free(ptr, 0);
13
+ }
14
+ clear() {
15
+ wasm.brasswasmchunkbuffer_clear(this.__wbg_ptr);
16
+ }
17
+ /**
18
+ * @returns {boolean}
19
+ */
20
+ is_empty() {
21
+ const ret = wasm.brasswasmchunkbuffer_is_empty(this.__wbg_ptr);
22
+ return ret !== 0;
23
+ }
24
+ /**
25
+ * @returns {boolean}
26
+ */
27
+ is_full() {
28
+ const ret = wasm.brasswasmchunkbuffer_is_full(this.__wbg_ptr);
29
+ return ret !== 0;
30
+ }
31
+ /**
32
+ * @returns {number}
33
+ */
34
+ len() {
35
+ const ret = wasm.brasswasmchunkbuffer_len(this.__wbg_ptr);
36
+ return ret >>> 0;
37
+ }
38
+ /**
39
+ * @returns {number}
40
+ */
41
+ max_chunk_size() {
42
+ const ret = wasm.brasswasmchunkbuffer_max_chunk_size(this.__wbg_ptr);
43
+ return ret >>> 0;
44
+ }
45
+ /**
46
+ * @param {number} max_chunk_size
47
+ */
48
+ constructor(max_chunk_size) {
49
+ const ret = wasm.brasswasmchunkbuffer_new(max_chunk_size);
50
+ this.__wbg_ptr = ret;
51
+ BrassWasmChunkBufferFinalization.register(this, this.__wbg_ptr, this);
52
+ return this;
53
+ }
54
+ /**
55
+ * @param {any} value
56
+ * @returns {boolean}
57
+ */
58
+ push(value) {
59
+ const ret = wasm.brasswasmchunkbuffer_push(this.__wbg_ptr, value);
60
+ return ret !== 0;
61
+ }
62
+ /**
63
+ * @returns {string}
64
+ */
65
+ stats_json() {
66
+ let deferred1_0;
67
+ let deferred1_1;
68
+ try {
69
+ const ret = wasm.brasswasmchunkbuffer_stats_json(this.__wbg_ptr);
70
+ deferred1_0 = ret[0];
71
+ deferred1_1 = ret[1];
72
+ return getStringFromWasm0(ret[0], ret[1]);
73
+ } finally {
74
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
75
+ }
76
+ }
77
+ /**
78
+ * @returns {Array<any>}
79
+ */
80
+ take_chunk() {
81
+ const ret = wasm.brasswasmchunkbuffer_take_chunk(this.__wbg_ptr);
82
+ return ret;
83
+ }
84
+ }
85
+ if (Symbol.dispose) BrassWasmChunkBuffer.prototype[Symbol.dispose] = BrassWasmChunkBuffer.prototype.free;
86
+ exports.BrassWasmChunkBuffer = BrassWasmChunkBuffer;
87
+
88
+ class BrassWasmFiberRegistry {
89
+ __destroy_into_raw() {
90
+ const ptr = this.__wbg_ptr;
91
+ this.__wbg_ptr = 0;
92
+ BrassWasmFiberRegistryFinalization.unregister(this);
93
+ return ptr;
94
+ }
95
+ free() {
96
+ const ptr = this.__destroy_into_raw();
97
+ wasm.__wbg_brasswasmfiberregistry_free(ptr, 0);
98
+ }
99
+ /**
100
+ * @param {number} fiber_id
101
+ * @returns {number}
102
+ */
103
+ add_joiner(fiber_id) {
104
+ const ret = wasm.brasswasmfiberregistry_add_joiner(this.__wbg_ptr, fiber_id);
105
+ return ret >>> 0;
106
+ }
107
+ /**
108
+ * @returns {number}
109
+ */
110
+ drain_wakeup() {
111
+ const ret = wasm.brasswasmfiberregistry_drain_wakeup(this.__wbg_ptr);
112
+ return ret >>> 0;
113
+ }
114
+ /**
115
+ * @param {number} fiber_id
116
+ * @returns {boolean}
117
+ */
118
+ drop_fiber(fiber_id) {
119
+ const ret = wasm.brasswasmfiberregistry_drop_fiber(this.__wbg_ptr, fiber_id);
120
+ return ret !== 0;
121
+ }
122
+ /**
123
+ * @param {number} fiber_id
124
+ * @param {number} state
125
+ * @param {number} now_ms
126
+ * @returns {number}
127
+ */
128
+ mark_done(fiber_id, state, now_ms) {
129
+ const ret = wasm.brasswasmfiberregistry_mark_done(this.__wbg_ptr, fiber_id, state, now_ms);
130
+ return ret >>> 0;
131
+ }
132
+ /**
133
+ * @param {number} fiber_id
134
+ * @param {number} now_ms
135
+ * @returns {boolean}
136
+ */
137
+ mark_queued(fiber_id, now_ms) {
138
+ const ret = wasm.brasswasmfiberregistry_mark_queued(this.__wbg_ptr, fiber_id, now_ms);
139
+ return ret !== 0;
140
+ }
141
+ /**
142
+ * @param {number} fiber_id
143
+ * @param {number} now_ms
144
+ * @returns {boolean}
145
+ */
146
+ mark_running(fiber_id, now_ms) {
147
+ const ret = wasm.brasswasmfiberregistry_mark_running(this.__wbg_ptr, fiber_id, now_ms);
148
+ return ret !== 0;
149
+ }
150
+ /**
151
+ * @param {number} fiber_id
152
+ * @param {number} now_ms
153
+ * @returns {boolean}
154
+ */
155
+ mark_suspended(fiber_id, now_ms) {
156
+ const ret = wasm.brasswasmfiberregistry_mark_suspended(this.__wbg_ptr, fiber_id, now_ms);
157
+ return ret !== 0;
158
+ }
159
+ constructor() {
160
+ const ret = wasm.brasswasmfiberregistry_new();
161
+ this.__wbg_ptr = ret;
162
+ BrassWasmFiberRegistryFinalization.register(this, this.__wbg_ptr, this);
163
+ return this;
164
+ }
165
+ /**
166
+ * @param {number} fiber_id
167
+ * @param {number} parent_id
168
+ * @param {number} scope_id
169
+ * @param {number} now_ms
170
+ * @returns {boolean}
171
+ */
172
+ register_fiber(fiber_id, parent_id, scope_id, now_ms) {
173
+ const ret = wasm.brasswasmfiberregistry_register_fiber(this.__wbg_ptr, fiber_id, parent_id, scope_id, now_ms);
174
+ return ret !== 0;
175
+ }
176
+ /**
177
+ * @param {number} fiber_id
178
+ * @returns {number}
179
+ */
180
+ state_of(fiber_id) {
181
+ const ret = wasm.brasswasmfiberregistry_state_of(this.__wbg_ptr, fiber_id);
182
+ return ret >>> 0;
183
+ }
184
+ /**
185
+ * @returns {string}
186
+ */
187
+ stats_json() {
188
+ let deferred1_0;
189
+ let deferred1_1;
190
+ try {
191
+ const ret = wasm.brasswasmfiberregistry_stats_json(this.__wbg_ptr);
192
+ deferred1_0 = ret[0];
193
+ deferred1_1 = ret[1];
194
+ return getStringFromWasm0(ret[0], ret[1]);
195
+ } finally {
196
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
197
+ }
198
+ }
199
+ /**
200
+ * @param {number} fiber_id
201
+ * @returns {boolean}
202
+ */
203
+ wake(fiber_id) {
204
+ const ret = wasm.brasswasmfiberregistry_wake(this.__wbg_ptr, fiber_id);
205
+ return ret !== 0;
206
+ }
207
+ /**
208
+ * @returns {number}
209
+ */
210
+ wake_queue_len() {
211
+ const ret = wasm.brasswasmfiberregistry_wake_queue_len(this.__wbg_ptr);
212
+ return ret >>> 0;
213
+ }
214
+ }
215
+ if (Symbol.dispose) BrassWasmFiberRegistry.prototype[Symbol.dispose] = BrassWasmFiberRegistry.prototype.free;
216
+ exports.BrassWasmFiberRegistry = BrassWasmFiberRegistry;
217
+
218
+ class BrassWasmRingBuffer {
219
+ __destroy_into_raw() {
220
+ const ptr = this.__wbg_ptr;
221
+ this.__wbg_ptr = 0;
222
+ BrassWasmRingBufferFinalization.unregister(this);
223
+ return ptr;
224
+ }
225
+ free() {
226
+ const ptr = this.__destroy_into_raw();
227
+ wasm.__wbg_brasswasmringbuffer_free(ptr, 0);
228
+ }
229
+ /**
230
+ * @returns {number}
231
+ */
232
+ capacity() {
233
+ const ret = wasm.brasswasmringbuffer_capacity(this.__wbg_ptr);
234
+ return ret >>> 0;
235
+ }
236
+ clear() {
237
+ wasm.brasswasmringbuffer_clear(this.__wbg_ptr);
238
+ }
239
+ /**
240
+ * @returns {boolean}
241
+ */
242
+ is_empty() {
243
+ const ret = wasm.brasswasmringbuffer_is_empty(this.__wbg_ptr);
244
+ return ret !== 0;
245
+ }
246
+ /**
247
+ * @returns {number}
248
+ */
249
+ len() {
250
+ const ret = wasm.brasswasmringbuffer_len(this.__wbg_ptr);
251
+ return ret >>> 0;
252
+ }
253
+ /**
254
+ * @param {number} initial_capacity
255
+ * @param {number} max_capacity
256
+ */
257
+ constructor(initial_capacity, max_capacity) {
258
+ const ret = wasm.brasswasmringbuffer_new(initial_capacity, max_capacity);
259
+ this.__wbg_ptr = ret;
260
+ BrassWasmRingBufferFinalization.register(this, this.__wbg_ptr, this);
261
+ return this;
262
+ }
263
+ /**
264
+ * @param {any} value
265
+ * @returns {number}
266
+ */
267
+ push(value) {
268
+ const ret = wasm.brasswasmringbuffer_push(this.__wbg_ptr, value);
269
+ return ret >>> 0;
270
+ }
271
+ /**
272
+ * @returns {any}
273
+ */
274
+ shift() {
275
+ const ret = wasm.brasswasmringbuffer_shift(this.__wbg_ptr);
276
+ return ret;
277
+ }
278
+ }
279
+ if (Symbol.dispose) BrassWasmRingBuffer.prototype[Symbol.dispose] = BrassWasmRingBuffer.prototype.free;
280
+ exports.BrassWasmRingBuffer = BrassWasmRingBuffer;
281
+
282
+ class BrassWasmSchedulerStateMachine {
283
+ __destroy_into_raw() {
284
+ const ptr = this.__wbg_ptr;
285
+ this.__wbg_ptr = 0;
286
+ BrassWasmSchedulerStateMachineFinalization.unregister(this);
287
+ return ptr;
288
+ }
289
+ free() {
290
+ const ptr = this.__destroy_into_raw();
291
+ wasm.__wbg_brasswasmschedulerstatemachine_free(ptr, 0);
292
+ }
293
+ /**
294
+ * Enter flushing. Returns the number of tasks this flush may run.
295
+ * @returns {number}
296
+ */
297
+ begin_flush() {
298
+ const ret = wasm.brasswasmschedulerstatemachine_begin_flush(this.__wbg_ptr);
299
+ return ret >>> 0;
300
+ }
301
+ /**
302
+ * @returns {number}
303
+ */
304
+ capacity() {
305
+ const ret = wasm.brasswasmschedulerstatemachine_capacity(this.__wbg_ptr);
306
+ return ret >>> 0;
307
+ }
308
+ clear() {
309
+ wasm.brasswasmschedulerstatemachine_clear(this.__wbg_ptr);
310
+ }
311
+ /**
312
+ * Finish a flush. Returns the scheduling policy for the next flush:
313
+ * - 0 => schedule a micro flush
314
+ * - 1 => schedule a macro flush
315
+ * - 2 => no more work
316
+ * @param {number} ran
317
+ * @returns {number}
318
+ */
319
+ end_flush(ran) {
320
+ const ret = wasm.brasswasmschedulerstatemachine_end_flush(this.__wbg_ptr, ran);
321
+ return ret >>> 0;
322
+ }
323
+ /**
324
+ * Enqueue a task ref and return the scheduling policy:
325
+ * - 0 => schedule a micro flush
326
+ * - 1 => schedule a macro flush
327
+ * - 2 => no new flush needed
328
+ * - 3 => queue full / task dropped
329
+ * @param {number} task_ref
330
+ * @returns {number}
331
+ */
332
+ enqueue(task_ref) {
333
+ const ret = wasm.brasswasmschedulerstatemachine_enqueue(this.__wbg_ptr, task_ref);
334
+ return ret >>> 0;
335
+ }
336
+ /**
337
+ * @returns {boolean}
338
+ */
339
+ is_flushing() {
340
+ const ret = wasm.brasswasmschedulerstatemachine_is_flushing(this.__wbg_ptr);
341
+ return ret !== 0;
342
+ }
343
+ /**
344
+ * @returns {boolean}
345
+ */
346
+ is_scheduled() {
347
+ const ret = wasm.brasswasmschedulerstatemachine_is_scheduled(this.__wbg_ptr);
348
+ return ret !== 0;
349
+ }
350
+ /**
351
+ * @returns {number}
352
+ */
353
+ len() {
354
+ const ret = wasm.brasswasmschedulerstatemachine_len(this.__wbg_ptr);
355
+ return ret >>> 0;
356
+ }
357
+ /**
358
+ * @param {number} initial_capacity
359
+ * @param {number} max_capacity
360
+ * @param {number} flush_budget
361
+ * @param {number} micro_threshold
362
+ */
363
+ constructor(initial_capacity, max_capacity, flush_budget, micro_threshold) {
364
+ const ret = wasm.brasswasmschedulerstatemachine_new(initial_capacity, max_capacity, flush_budget, micro_threshold);
365
+ this.__wbg_ptr = ret;
366
+ BrassWasmSchedulerStateMachineFinalization.register(this, this.__wbg_ptr, this);
367
+ return this;
368
+ }
369
+ /**
370
+ * @returns {number}
371
+ */
372
+ shift() {
373
+ const ret = wasm.brasswasmschedulerstatemachine_shift(this.__wbg_ptr);
374
+ return ret >>> 0;
375
+ }
376
+ /**
377
+ * @returns {string}
378
+ */
379
+ stats_json() {
380
+ let deferred1_0;
381
+ let deferred1_1;
382
+ try {
383
+ const ret = wasm.brasswasmschedulerstatemachine_stats_json(this.__wbg_ptr);
384
+ deferred1_0 = ret[0];
385
+ deferred1_1 = ret[1];
386
+ return getStringFromWasm0(ret[0], ret[1]);
387
+ } finally {
388
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
389
+ }
390
+ }
391
+ }
392
+ if (Symbol.dispose) BrassWasmSchedulerStateMachine.prototype[Symbol.dispose] = BrassWasmSchedulerStateMachine.prototype.free;
393
+ exports.BrassWasmSchedulerStateMachine = BrassWasmSchedulerStateMachine;
394
+
395
+ class BrassWasmVm {
396
+ __destroy_into_raw() {
397
+ const ptr = this.__wbg_ptr;
398
+ this.__wbg_ptr = 0;
399
+ BrassWasmVmFinalization.unregister(this);
400
+ return ptr;
401
+ }
402
+ free() {
403
+ const ptr = this.__destroy_into_raw();
404
+ wasm.__wbg_brasswasmvm_free(ptr, 0);
405
+ }
406
+ /**
407
+ * @param {string} program_json
408
+ * @returns {number}
409
+ */
410
+ create_fiber(program_json) {
411
+ const ptr0 = passStringToWasm0(program_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
412
+ const len0 = WASM_VECTOR_LEN;
413
+ const ret = wasm.brasswasmvm_create_fiber(this.__wbg_ptr, ptr0, len0);
414
+ return ret >>> 0;
415
+ }
416
+ /**
417
+ * @param {number} fiber_id
418
+ */
419
+ drop_fiber(fiber_id) {
420
+ wasm.brasswasmvm_drop_fiber(this.__wbg_ptr, fiber_id);
421
+ }
422
+ /**
423
+ * @param {number} fiber_id
424
+ * @param {number} reason_ref
425
+ * @returns {string}
426
+ */
427
+ interrupt(fiber_id, reason_ref) {
428
+ let deferred1_0;
429
+ let deferred1_1;
430
+ try {
431
+ const ret = wasm.brasswasmvm_interrupt(this.__wbg_ptr, fiber_id, reason_ref);
432
+ deferred1_0 = ret[0];
433
+ deferred1_1 = ret[1];
434
+ return getStringFromWasm0(ret[0], ret[1]);
435
+ } finally {
436
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
437
+ }
438
+ }
439
+ constructor() {
440
+ const ret = wasm.brasswasmvm_new();
441
+ this.__wbg_ptr = ret;
442
+ BrassWasmVmFinalization.register(this, this.__wbg_ptr, this);
443
+ return this;
444
+ }
445
+ /**
446
+ * @param {number} fiber_id
447
+ * @returns {string}
448
+ */
449
+ poll(fiber_id) {
450
+ let deferred1_0;
451
+ let deferred1_1;
452
+ try {
453
+ const ret = wasm.brasswasmvm_poll(this.__wbg_ptr, fiber_id);
454
+ deferred1_0 = ret[0];
455
+ deferred1_1 = ret[1];
456
+ return getStringFromWasm0(ret[0], ret[1]);
457
+ } finally {
458
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
459
+ }
460
+ }
461
+ /**
462
+ * @param {number} fiber_id
463
+ * @param {number} root
464
+ * @param {string} nodes_json
465
+ * @returns {string}
466
+ */
467
+ provide_effect(fiber_id, root, nodes_json) {
468
+ let deferred2_0;
469
+ let deferred2_1;
470
+ try {
471
+ const ptr0 = passStringToWasm0(nodes_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
472
+ const len0 = WASM_VECTOR_LEN;
473
+ const ret = wasm.brasswasmvm_provide_effect(this.__wbg_ptr, fiber_id, root, ptr0, len0);
474
+ deferred2_0 = ret[0];
475
+ deferred2_1 = ret[1];
476
+ return getStringFromWasm0(ret[0], ret[1]);
477
+ } finally {
478
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
479
+ }
480
+ }
481
+ /**
482
+ * @param {number} fiber_id
483
+ * @param {number} error_ref
484
+ * @returns {string}
485
+ */
486
+ provide_error(fiber_id, error_ref) {
487
+ let deferred1_0;
488
+ let deferred1_1;
489
+ try {
490
+ const ret = wasm.brasswasmvm_provide_error(this.__wbg_ptr, fiber_id, error_ref);
491
+ deferred1_0 = ret[0];
492
+ deferred1_1 = ret[1];
493
+ return getStringFromWasm0(ret[0], ret[1]);
494
+ } finally {
495
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
496
+ }
497
+ }
498
+ /**
499
+ * @param {number} fiber_id
500
+ * @param {number} value_ref
501
+ * @returns {string}
502
+ */
503
+ provide_value(fiber_id, value_ref) {
504
+ let deferred1_0;
505
+ let deferred1_1;
506
+ try {
507
+ const ret = wasm.brasswasmvm_provide_value(this.__wbg_ptr, fiber_id, value_ref);
508
+ deferred1_0 = ret[0];
509
+ deferred1_1 = ret[1];
510
+ return getStringFromWasm0(ret[0], ret[1]);
511
+ } finally {
512
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
513
+ }
514
+ }
515
+ /**
516
+ * @returns {string}
517
+ */
518
+ stats_json() {
519
+ let deferred1_0;
520
+ let deferred1_1;
521
+ try {
522
+ const ret = wasm.brasswasmvm_stats_json(this.__wbg_ptr);
523
+ deferred1_0 = ret[0];
524
+ deferred1_1 = ret[1];
525
+ return getStringFromWasm0(ret[0], ret[1]);
526
+ } finally {
527
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
528
+ }
529
+ }
530
+ }
531
+ if (Symbol.dispose) BrassWasmVm.prototype[Symbol.dispose] = BrassWasmVm.prototype.free;
532
+ exports.BrassWasmVm = BrassWasmVm;
533
+ function __wbg_get_imports() {
534
+ const import0 = {
535
+ __proto__: null,
536
+ __wbg___wbindgen_throw_9c75d47bf9e7731e: function(arg0, arg1) {
537
+ throw new Error(getStringFromWasm0(arg0, arg1));
538
+ },
539
+ __wbg_length_0a6ce016dc1460b0: function(arg0) {
540
+ const ret = arg0.length;
541
+ return ret;
542
+ },
543
+ __wbg_new_with_length_95e51bab415f3ca8: function(arg0) {
544
+ const ret = new Array(arg0 >>> 0);
545
+ return ret;
546
+ },
547
+ __wbg_set_f614f6a0608d1d1d: function(arg0, arg1, arg2) {
548
+ arg0[arg1 >>> 0] = arg2;
549
+ },
550
+ __wbindgen_init_externref_table: function() {
551
+ const table = wasm.__wbindgen_externrefs;
552
+ const offset = table.grow(4);
553
+ table.set(0, undefined);
554
+ table.set(offset + 0, undefined);
555
+ table.set(offset + 1, null);
556
+ table.set(offset + 2, true);
557
+ table.set(offset + 3, false);
558
+ },
559
+ };
560
+ return {
561
+ __proto__: null,
562
+ "./brass_runtime_wasm_engine_bg.js": import0,
563
+ };
564
+ }
565
+
566
+ const BrassWasmChunkBufferFinalization = (typeof FinalizationRegistry === 'undefined')
567
+ ? { register: () => {}, unregister: () => {} }
568
+ : new FinalizationRegistry(ptr => wasm.__wbg_brasswasmchunkbuffer_free(ptr, 1));
569
+ const BrassWasmFiberRegistryFinalization = (typeof FinalizationRegistry === 'undefined')
570
+ ? { register: () => {}, unregister: () => {} }
571
+ : new FinalizationRegistry(ptr => wasm.__wbg_brasswasmfiberregistry_free(ptr, 1));
572
+ const BrassWasmRingBufferFinalization = (typeof FinalizationRegistry === 'undefined')
573
+ ? { register: () => {}, unregister: () => {} }
574
+ : new FinalizationRegistry(ptr => wasm.__wbg_brasswasmringbuffer_free(ptr, 1));
575
+ const BrassWasmSchedulerStateMachineFinalization = (typeof FinalizationRegistry === 'undefined')
576
+ ? { register: () => {}, unregister: () => {} }
577
+ : new FinalizationRegistry(ptr => wasm.__wbg_brasswasmschedulerstatemachine_free(ptr, 1));
578
+ const BrassWasmVmFinalization = (typeof FinalizationRegistry === 'undefined')
579
+ ? { register: () => {}, unregister: () => {} }
580
+ : new FinalizationRegistry(ptr => wasm.__wbg_brasswasmvm_free(ptr, 1));
581
+
582
+ function getStringFromWasm0(ptr, len) {
583
+ return decodeText(ptr >>> 0, len);
584
+ }
585
+
586
+ let cachedUint8ArrayMemory0 = null;
587
+ function getUint8ArrayMemory0() {
588
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
589
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
590
+ }
591
+ return cachedUint8ArrayMemory0;
592
+ }
593
+
594
+ function passStringToWasm0(arg, malloc, realloc) {
595
+ if (realloc === undefined) {
596
+ const buf = cachedTextEncoder.encode(arg);
597
+ const ptr = malloc(buf.length, 1) >>> 0;
598
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
599
+ WASM_VECTOR_LEN = buf.length;
600
+ return ptr;
601
+ }
602
+
603
+ let len = arg.length;
604
+ let ptr = malloc(len, 1) >>> 0;
605
+
606
+ const mem = getUint8ArrayMemory0();
607
+
608
+ let offset = 0;
609
+
610
+ for (; offset < len; offset++) {
611
+ const code = arg.charCodeAt(offset);
612
+ if (code > 0x7F) break;
613
+ mem[ptr + offset] = code;
614
+ }
615
+ if (offset !== len) {
616
+ if (offset !== 0) {
617
+ arg = arg.slice(offset);
618
+ }
619
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
620
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
621
+ const ret = cachedTextEncoder.encodeInto(arg, view);
622
+
623
+ offset += ret.written;
624
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
625
+ }
626
+
627
+ WASM_VECTOR_LEN = offset;
628
+ return ptr;
629
+ }
630
+
631
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
632
+ cachedTextDecoder.decode();
633
+ function decodeText(ptr, len) {
634
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
635
+ }
636
+
637
+ const cachedTextEncoder = new TextEncoder();
638
+
639
+ if (!('encodeInto' in cachedTextEncoder)) {
640
+ cachedTextEncoder.encodeInto = function (arg, view) {
641
+ const buf = cachedTextEncoder.encode(arg);
642
+ view.set(buf);
643
+ return {
644
+ read: arg.length,
645
+ written: buf.length
646
+ };
647
+ };
648
+ }
649
+
650
+ let WASM_VECTOR_LEN = 0;
651
+
652
+ const wasmPath = `${__dirname}/brass_runtime_wasm_engine_bg.wasm`;
653
+ const wasmBytes = require('fs').readFileSync(wasmPath);
654
+ const wasmModule = new WebAssembly.Module(wasmBytes);
655
+ let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
656
+ let wasm = wasmInstance.exports;
657
+ wasm.__wbindgen_start();