brass-runtime 1.13.3 → 1.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brass-runtime",
3
- "version": "1.13.3",
3
+ "version": "1.13.5",
4
4
  "description": "Effect runtime utilities for TypeScript",
5
5
  "license": "MIT",
6
6
  "author": "Augusto Vivaldelli",
@@ -52,20 +52,18 @@
52
52
  ],
53
53
  "scripts": {
54
54
  "dev": "tsx src/examples/index.ts",
55
- "clean": "rimraf dist",
55
+ "clean": "rimraf dist wasm/pkg",
56
56
  "test": "vitest run",
57
57
  "test:watch": "vitest",
58
58
  "test:coverage": "vitest run --coverage",
59
59
  "test:types": "tsc -p tsconfig.json --noEmit",
60
60
  "check": "npm run test:types && npm run test && npm run test:coverage",
61
61
  "check:full": "npm run clean && npm run build && npm run test",
62
- "build": "tsup",
62
+ "build": "npm run build:wasm && npm run build:ts",
63
63
  "build:legacy": "npm run clean && npm run build:types && npm run build:esm && npm run build:cjs",
64
64
  "build:types": "tsc -p tsconfig.types.json",
65
65
  "build:esm": "tsc -p tsconfig.esm.json",
66
66
  "build:cjs": "tsc -p tsconfig.cjs.json",
67
- "prepack": "npm run build:wasm && npm run build",
68
- "prepublishOnly": "npm run build:wasm && npm run build",
69
67
  "agent:dev": "tsx src/agent/cli/main.ts",
70
68
  "agent:doctor": "tsx src/agent/cli/main.ts --doctor",
71
69
  "agent:vscode:package": "node scripts/install-vscode-extension.mjs --no-code-install --no-settings",
@@ -87,7 +85,8 @@
87
85
  "benchmark": "tsx src/benchmarks/runner.ts",
88
86
  "benchmark:json": "tsx src/benchmarks/runner.ts --json",
89
87
  "test:coverage:html": "vitest run --coverage --reporter=default",
90
- "build:wasm": "cd crates/brass-runtime-wasm-engine && wasm-pack build --target nodejs --out-dir ../../wasm/pkg"
88
+ "build:wasm": "cd crates/brass-runtime-wasm-engine && wasm-pack build --target nodejs --out-dir ../../wasm/pkg",
89
+ "build:ts": "tsup"
91
90
  },
92
91
  "devDependencies": {
93
92
  "@types/node": "^22.15.0",
@@ -0,0 +1,92 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class BrassWasmChunkBuffer {
5
+ free(): void;
6
+ [Symbol.dispose](): void;
7
+ clear(): void;
8
+ is_empty(): boolean;
9
+ is_full(): boolean;
10
+ len(): number;
11
+ max_chunk_size(): number;
12
+ constructor(max_chunk_size: number);
13
+ push(value: any): boolean;
14
+ stats_json(): string;
15
+ take_chunk(): Array<any>;
16
+ }
17
+
18
+ export class BrassWasmFiberRegistry {
19
+ free(): void;
20
+ [Symbol.dispose](): void;
21
+ add_joiner(fiber_id: number): number;
22
+ drain_wakeup(): number;
23
+ drop_fiber(fiber_id: number): boolean;
24
+ mark_done(fiber_id: number, state: number, now_ms: number): number;
25
+ mark_queued(fiber_id: number, now_ms: number): boolean;
26
+ mark_running(fiber_id: number, now_ms: number): boolean;
27
+ mark_suspended(fiber_id: number, now_ms: number): boolean;
28
+ constructor();
29
+ register_fiber(fiber_id: number, parent_id: number, scope_id: number, now_ms: number): boolean;
30
+ state_of(fiber_id: number): number;
31
+ stats_json(): string;
32
+ wake(fiber_id: number): boolean;
33
+ wake_queue_len(): number;
34
+ }
35
+
36
+ export class BrassWasmRingBuffer {
37
+ free(): void;
38
+ [Symbol.dispose](): void;
39
+ capacity(): number;
40
+ clear(): void;
41
+ is_empty(): boolean;
42
+ len(): number;
43
+ constructor(initial_capacity: number, max_capacity: number);
44
+ push(value: any): number;
45
+ shift(): any;
46
+ }
47
+
48
+ export class BrassWasmSchedulerStateMachine {
49
+ free(): void;
50
+ [Symbol.dispose](): void;
51
+ /**
52
+ * Enter flushing. Returns the number of tasks this flush may run.
53
+ */
54
+ begin_flush(): number;
55
+ capacity(): number;
56
+ clear(): void;
57
+ /**
58
+ * Finish a flush. Returns the scheduling policy for the next flush:
59
+ * - 0 => schedule a micro flush
60
+ * - 1 => schedule a macro flush
61
+ * - 2 => no more work
62
+ */
63
+ end_flush(ran: number): number;
64
+ /**
65
+ * Enqueue a task ref and return the scheduling policy:
66
+ * - 0 => schedule a micro flush
67
+ * - 1 => schedule a macro flush
68
+ * - 2 => no new flush needed
69
+ * - 3 => queue full / task dropped
70
+ */
71
+ enqueue(task_ref: number): number;
72
+ is_flushing(): boolean;
73
+ is_scheduled(): boolean;
74
+ len(): number;
75
+ constructor(initial_capacity: number, max_capacity: number, flush_budget: number, micro_threshold: number);
76
+ shift(): number;
77
+ stats_json(): string;
78
+ }
79
+
80
+ export class BrassWasmVm {
81
+ free(): void;
82
+ [Symbol.dispose](): void;
83
+ create_fiber(program_json: string): number;
84
+ drop_fiber(fiber_id: number): void;
85
+ interrupt(fiber_id: number, reason_ref: number): string;
86
+ constructor();
87
+ poll(fiber_id: number): string;
88
+ provide_effect(fiber_id: number, root: number, nodes_json: string): string;
89
+ provide_error(fiber_id: number, error_ref: number): string;
90
+ provide_value(fiber_id: number, value_ref: number): string;
91
+ stats_json(): string;
92
+ }
@@ -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();
@@ -0,0 +1,62 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_brasswasmchunkbuffer_free: (a: number, b: number) => void;
5
+ export const __wbg_brasswasmfiberregistry_free: (a: number, b: number) => void;
6
+ export const __wbg_brasswasmringbuffer_free: (a: number, b: number) => void;
7
+ export const __wbg_brasswasmschedulerstatemachine_free: (a: number, b: number) => void;
8
+ export const __wbg_brasswasmvm_free: (a: number, b: number) => void;
9
+ export const brasswasmchunkbuffer_clear: (a: number) => void;
10
+ export const brasswasmchunkbuffer_is_empty: (a: number) => number;
11
+ export const brasswasmchunkbuffer_is_full: (a: number) => number;
12
+ export const brasswasmchunkbuffer_len: (a: number) => number;
13
+ export const brasswasmchunkbuffer_max_chunk_size: (a: number) => number;
14
+ export const brasswasmchunkbuffer_new: (a: number) => number;
15
+ export const brasswasmchunkbuffer_push: (a: number, b: any) => number;
16
+ export const brasswasmchunkbuffer_stats_json: (a: number) => [number, number];
17
+ export const brasswasmchunkbuffer_take_chunk: (a: number) => any;
18
+ export const brasswasmfiberregistry_add_joiner: (a: number, b: number) => number;
19
+ export const brasswasmfiberregistry_drain_wakeup: (a: number) => number;
20
+ export const brasswasmfiberregistry_drop_fiber: (a: number, b: number) => number;
21
+ export const brasswasmfiberregistry_mark_done: (a: number, b: number, c: number, d: number) => number;
22
+ export const brasswasmfiberregistry_mark_queued: (a: number, b: number, c: number) => number;
23
+ export const brasswasmfiberregistry_mark_running: (a: number, b: number, c: number) => number;
24
+ export const brasswasmfiberregistry_mark_suspended: (a: number, b: number, c: number) => number;
25
+ export const brasswasmfiberregistry_new: () => number;
26
+ export const brasswasmfiberregistry_register_fiber: (a: number, b: number, c: number, d: number, e: number) => number;
27
+ export const brasswasmfiberregistry_state_of: (a: number, b: number) => number;
28
+ export const brasswasmfiberregistry_stats_json: (a: number) => [number, number];
29
+ export const brasswasmfiberregistry_wake: (a: number, b: number) => number;
30
+ export const brasswasmfiberregistry_wake_queue_len: (a: number) => number;
31
+ export const brasswasmringbuffer_capacity: (a: number) => number;
32
+ export const brasswasmringbuffer_clear: (a: number) => void;
33
+ export const brasswasmringbuffer_is_empty: (a: number) => number;
34
+ export const brasswasmringbuffer_len: (a: number) => number;
35
+ export const brasswasmringbuffer_new: (a: number, b: number) => number;
36
+ export const brasswasmringbuffer_push: (a: number, b: any) => number;
37
+ export const brasswasmringbuffer_shift: (a: number) => any;
38
+ export const brasswasmschedulerstatemachine_begin_flush: (a: number) => number;
39
+ export const brasswasmschedulerstatemachine_capacity: (a: number) => number;
40
+ export const brasswasmschedulerstatemachine_clear: (a: number) => void;
41
+ export const brasswasmschedulerstatemachine_end_flush: (a: number, b: number) => number;
42
+ export const brasswasmschedulerstatemachine_enqueue: (a: number, b: number) => number;
43
+ export const brasswasmschedulerstatemachine_is_flushing: (a: number) => number;
44
+ export const brasswasmschedulerstatemachine_is_scheduled: (a: number) => number;
45
+ export const brasswasmschedulerstatemachine_len: (a: number) => number;
46
+ export const brasswasmschedulerstatemachine_new: (a: number, b: number, c: number, d: number) => number;
47
+ export const brasswasmschedulerstatemachine_shift: (a: number) => number;
48
+ export const brasswasmschedulerstatemachine_stats_json: (a: number) => [number, number];
49
+ export const brasswasmvm_create_fiber: (a: number, b: number, c: number) => number;
50
+ export const brasswasmvm_drop_fiber: (a: number, b: number) => void;
51
+ export const brasswasmvm_interrupt: (a: number, b: number, c: number) => [number, number];
52
+ export const brasswasmvm_new: () => number;
53
+ export const brasswasmvm_poll: (a: number, b: number) => [number, number];
54
+ export const brasswasmvm_provide_effect: (a: number, b: number, c: number, d: number, e: number) => [number, number];
55
+ export const brasswasmvm_provide_error: (a: number, b: number, c: number) => [number, number];
56
+ export const brasswasmvm_provide_value: (a: number, b: number, c: number) => [number, number];
57
+ export const brasswasmvm_stats_json: (a: number) => [number, number];
58
+ export const __wbindgen_externrefs: WebAssembly.Table;
59
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
60
+ export const __wbindgen_malloc: (a: number, b: number) => number;
61
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
62
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "brass-runtime-wasm-engine",
3
+ "description": "WASM fiber VM for brass-runtime",
4
+ "version": "0.2.0",
5
+ "license": "MIT",
6
+ "files": [
7
+ "brass_runtime_wasm_engine_bg.wasm",
8
+ "brass_runtime_wasm_engine.js",
9
+ "brass_runtime_wasm_engine.d.ts"
10
+ ],
11
+ "main": "brass_runtime_wasm_engine.js",
12
+ "types": "brass_runtime_wasm_engine.d.ts"
13
+ }