@nanobpm/engine-wasm 0.3.1 → 0.5.0

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 ADDED
@@ -0,0 +1,112 @@
1
+ # @nanobpm/engine-wasm
2
+
3
+ The nanobpmn engine (`engine-core`) compiled to **WebAssembly** for in-browser
4
+ BPMN execution. Deploy a diagram, start instances, activate/complete jobs, drive
5
+ the virtual clock, and read live snapshots/traces — all client-side, with no
6
+ gateway. It is the substrate for the [Bojtos](https://github.com/nanobpm/bojtos)
7
+ demo framework (ADR 0043) and the console test-run panel.
8
+
9
+ The package ships **two independent engines** from one install, selectable by
10
+ **import path**:
11
+
12
+ | Import | Engine | Wire size (brotli) | Use it for |
13
+ | --- | --- | ---: | --- |
14
+ | `@nanobpm/engine-wasm` | **lean** — primary state only | ~252 KB | demos, the modeler, debuggers, anything that reads via `snapshot()` / `events()` |
15
+ | `@nanobpm/engine-wasm/readmodel` | **read-model** — lean surface **+** the gateway's C8-style REST read methods | ~561 KB | full-surface app testing in CI that wants gateway read parity |
16
+
17
+ ## Why two binaries (not a runtime toggle)
18
+
19
+ Each variant is its own `wasm-pack --target web` JS glue + `_bg.wasm`. A bundler
20
+ follows the static module graph, so it only emits the wasm for the subpath you
21
+ actually import — wasm **cannot** be tree-shaken out of a single fat build. So:
22
+
23
+ - Lean-only pages pay **zero** read-model weight (the +309 KB brotli never lands).
24
+ - You can `await import("@nanobpm/engine-wasm/readmodel")` to code-split the
25
+ heavy engine behind a runtime decision.
26
+ - You can even instantiate **both** on one page.
27
+
28
+ The read-model variant is the lean engine **plus** an in-memory wasm SQLite read
29
+ model (the same projection the gateway serves from), exposing the REST read
30
+ surface the lean engine lacks.
31
+
32
+ ## Install
33
+
34
+ ```sh
35
+ npm install @nanobpm/engine-wasm
36
+ ```
37
+
38
+ ## Usage — lean (default)
39
+
40
+ ```js
41
+ import init, { TestEngine } from "@nanobpm/engine-wasm";
42
+
43
+ await init(); // instantiate the wasm module
44
+ const engine = new TestEngine();
45
+
46
+ engine.deploy(bpmnXml); // deploy a BPMN diagram
47
+ const handle = engine.createInstance("my-process", "{}");
48
+ const snap = JSON.parse(engine.snapshot()); // live primary state
49
+ const trace = JSON.parse(engine.events()); // the event log
50
+ engine.reset(); // back to a clean engine
51
+ ```
52
+
53
+ The lean surface covers primary state and execution: `deploy`, `createInstance`,
54
+ `snapshot`, `events`, job ops (`activateJobs`, `completeJob`, `failJob`,
55
+ `updateRetries`, `throwError`), user-task ops (`completeUserTask`,
56
+ `assignUserTask`, …), messaging/signals, the virtual clock (`advanceTime`,
57
+ `tickNow`), and `reset`. It links **no** SQLite / read-model code.
58
+
59
+ ## Usage — read-model
60
+
61
+ ```js
62
+ import init, { TestEngine } from "@nanobpm/engine-wasm/readmodel";
63
+
64
+ await init();
65
+ const engine = new TestEngine();
66
+
67
+ engine.deploy(bpmnXml);
68
+ engine.createInstance("my-process", "{}");
69
+
70
+ // Same lean surface as above, PLUS the gateway's REST read channel:
71
+ const form = JSON.parse(engine.getFormByKey("2251799813685250"));
72
+ const open = JSON.parse(engine.searchUserTasks(JSON.stringify({ state: "CREATED" })));
73
+ const insts = JSON.parse(engine.searchProcessInstances("{}"));
74
+ const res = JSON.parse(engine.getResourceByKey("2251799813685251"));
75
+ const vars = JSON.parse(engine.searchVariables("{}"));
76
+ ```
77
+
78
+ ### Read methods (read-model subpath only)
79
+
80
+ Each returns the same JSON shapes the Camunda v2 REST surface returns; each
81
+ delegates to the in-memory read model, kept current after every command and
82
+ cleared by `reset()`.
83
+
84
+ - **`getFormByKey(formKey)`** → the latest deployed form for `formKey`
85
+ (`{ tenantId, formId, schema, version, formKey }`), or `null`.
86
+ Mirrors `GET /forms/{formKey}`.
87
+ - **`searchUserTasks(filterJson)`** → `{ items, page }`. Honours an optional
88
+ `{ state? }` filter (e.g. `"CREATED"`) through the read model.
89
+ Mirrors `POST /user-tasks/search`.
90
+ - **`searchProcessInstances(filterJson)`** → `{ items, page }`. Body is
91
+ shape-validated; filter/sort/page fields are not yet honoured (returns every
92
+ instance). Mirrors `POST /process-instances/search`.
93
+ - **`getResourceByKey(resourceKey)`** → the generic resource, or `null`.
94
+ Mirrors `GET /resources/{resourceKey}`.
95
+ - **`searchVariables(filterJson)`** → `{ items, page }`. Body is shape-validated;
96
+ long values are truncated with `isTruncated: true`.
97
+ Mirrors `POST /variables/search`.
98
+
99
+ ## Choosing a subpath
100
+
101
+ - **Reach for lean** for demos, the modeler, debuggers/adapters, and anything
102
+ that only inspects `snapshot()` / `events()`. Keeping these paths lean is the
103
+ whole point of the split — the +309 KB brotli must never ship in a demo page.
104
+ - **Reach for `/readmodel`** when you need gateway read parity — full-surface app
105
+ testing in CI — instead of hand-rolling shadow read stores in JS/TS.
106
+
107
+ ## References
108
+
109
+ - Epic [#796](https://github.com/Magikcraft/nano-bpm/issues/796) — the read
110
+ channel via a wasm SQLite read model (size table, toolchain note, downstream
111
+ consumers).
112
+ - ADR 0043 — Bojtos (the demo framework this engine backs).
@@ -83,11 +83,52 @@ export class TestEngine {
83
83
  correlateMessage(message_name: string, correlation_key: string, variables_json: string): string;
84
84
  /**
85
85
  * Start a new instance of `process_id`, seeding it with the given variables
86
- * (a JSON object string; pass `"{}"` or `""` for none). Returns the
87
- * post-run [`Snapshot`] with a top-level `created` field holding the new
88
- * instance key.
86
+ * (a JSON object string; pass `"{}"` or `""` for none). `version` selects a
87
+ * specific process **version** number (Zeebe by-id semantics); pass
88
+ * `undefined`/`null` (or a non-positive value) for the latest version.
89
+ * Returns the post-run [`Snapshot`] with a top-level `created` field holding
90
+ * the new instance key.
89
91
  */
90
- createInstance(process_id: string, variables_json: string): string;
92
+ createInstance(process_id: string, variables_json: string, version?: number | null): string;
93
+ /**
94
+ * Stop debugging, keeping the state the run produced. If the run is paused
95
+ * mid-command, that in-flight command is first **finished normally** (its
96
+ * breakpoints are cleared and it is resumed once) so the engine lands on the
97
+ * same run-to-completion (RTC) quiescent state a plain command would produce
98
+ * — never a partial, non-RTC intermediate one that later mutators could
99
+ * build on (the hole [`TestEngine::guard_paused`] exists to prevent). To
100
+ * discard the run's state entirely instead, use [`TestEngine::reset`].
101
+ */
102
+ debugClear(): void;
103
+ /**
104
+ * Begin a **debug** run of a `CreateInstance` command: deploy first (as
105
+ * usual), then call this to start the instance under the stepping executor,
106
+ * pausing at the first breakpoint (or running to completion if none match).
107
+ *
108
+ * `breakpoints_json` is a JSON array of `{ kind, id? }`:
109
+ * ```json
110
+ * [{ "kind": "elementActivated", "id": "Task_Charge" },
111
+ * { "kind": "elementCompleted", "id": "Gateway_1" },
112
+ * { "kind": "processCompleted" },
113
+ * { "kind": "everyStep" }]
114
+ * ```
115
+ * Returns the debug state JSON (see [`TestEngine::debug_state`]). Starting a
116
+ * new debug run replaces any previous *finished* session; it is rejected
117
+ * while a run is still paused (`debugIsPaused`) — resume or clear that run
118
+ * first, so its intermediate state isn't stranded live in the engine.
119
+ */
120
+ debugCreateInstance(process_id: string, variables_json: string, breakpoints_json: string): string;
121
+ /**
122
+ * Resume a paused debug run until the next breakpoint or completion. No-op if
123
+ * no session is active or it has already finished. Returns the debug state.
124
+ */
125
+ debugResume(): string;
126
+ /**
127
+ * Advance a paused debug run by exactly one step, then pause again (unless
128
+ * that step drained the command). No-op if no session is active or it has
129
+ * already finished. Returns the debug state.
130
+ */
131
+ debugStep(): string;
91
132
  /**
92
133
  * Parse and deploy a BPMN resource. Returns a JSON object
93
134
  * `{ "processIds": [...], "snapshot": {...} }` on success, or throws a
@@ -104,6 +145,15 @@ export class TestEngine {
104
145
  * With no retries left this raises an incident (visible in the snapshot).
105
146
  */
106
147
  failJob(job_key: string, retries: number, message: string): string;
148
+ /**
149
+ * Migrate a running process instance to a target process definition (Zeebe
150
+ * "migrate process instance"): re-point every active element instance at the
151
+ * mapped element of `target_process_definition_key` and re-home the instance.
152
+ * `mapping_instructions_json` is a JSON array of
153
+ * `{ sourceElementId: string, targetElementId: string }`. Returns the
154
+ * snapshot.
155
+ */
156
+ migrate(instance_key: string, target_process_definition_key: string, mapping_instructions_json: string): string;
107
157
  /**
108
158
  * Modify a running process instance (Zeebe "modify process instance"): move
109
159
  * tokens by terminating existing element instances and/or activating new
@@ -179,6 +229,10 @@ export class TestEngine {
179
229
  * the `Created` state. Returns the snapshot.
180
230
  */
181
231
  updateUserTask(user_task_key: string, changeset_json: string): string;
232
+ /**
233
+ * Whether a debug run is currently paused at a breakpoint.
234
+ */
235
+ readonly debugIsPaused: boolean;
182
236
  /**
183
237
  * The current virtual clock (milliseconds).
184
238
  */
@@ -199,10 +253,16 @@ export interface InitOutput {
199
253
  readonly testengine_completeJob: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
200
254
  readonly testengine_completeUserTask: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
201
255
  readonly testengine_correlateMessage: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
202
- readonly testengine_createInstance: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
256
+ readonly testengine_createInstance: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
257
+ readonly testengine_debugClear: (a: number) => void;
258
+ readonly testengine_debugCreateInstance: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
259
+ readonly testengine_debugIsPaused: (a: number) => number;
260
+ readonly testengine_debugResume: (a: number, b: number) => void;
261
+ readonly testengine_debugStep: (a: number, b: number) => void;
203
262
  readonly testengine_deploy: (a: number, b: number, c: number, d: number) => void;
204
263
  readonly testengine_events: (a: number, b: number) => void;
205
264
  readonly testengine_failJob: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
265
+ readonly testengine_migrate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
206
266
  readonly testengine_modify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
207
267
  readonly testengine_new: () => number;
208
268
  readonly testengine_now: (a: number) => number;
@@ -361,14 +361,17 @@ export class TestEngine {
361
361
  }
362
362
  /**
363
363
  * Start a new instance of `process_id`, seeding it with the given variables
364
- * (a JSON object string; pass `"{}"` or `""` for none). Returns the
365
- * post-run [`Snapshot`] with a top-level `created` field holding the new
366
- * instance key.
364
+ * (a JSON object string; pass `"{}"` or `""` for none). `version` selects a
365
+ * specific process **version** number (Zeebe by-id semantics); pass
366
+ * `undefined`/`null` (or a non-positive value) for the latest version.
367
+ * Returns the post-run [`Snapshot`] with a top-level `created` field holding
368
+ * the new instance key.
367
369
  * @param {string} process_id
368
370
  * @param {string} variables_json
371
+ * @param {number | null} [version]
369
372
  * @returns {string}
370
373
  */
371
- createInstance(process_id, variables_json) {
374
+ createInstance(process_id, variables_json, version) {
372
375
  let deferred4_0;
373
376
  let deferred4_1;
374
377
  try {
@@ -377,7 +380,7 @@ export class TestEngine {
377
380
  const len0 = WASM_VECTOR_LEN;
378
381
  const ptr1 = passStringToWasm0(variables_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
379
382
  const len1 = WASM_VECTOR_LEN;
380
- wasm.testengine_createInstance(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
383
+ wasm.testengine_createInstance(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(version) ? Number.MAX_SAFE_INTEGER : (version) >> 0);
381
384
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
382
385
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
383
386
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -396,6 +399,136 @@ export class TestEngine {
396
399
  wasm.__wbindgen_export3(deferred4_0, deferred4_1, 1);
397
400
  }
398
401
  }
402
+ /**
403
+ * Stop debugging, keeping the state the run produced. If the run is paused
404
+ * mid-command, that in-flight command is first **finished normally** (its
405
+ * breakpoints are cleared and it is resumed once) so the engine lands on the
406
+ * same run-to-completion (RTC) quiescent state a plain command would produce
407
+ * — never a partial, non-RTC intermediate one that later mutators could
408
+ * build on (the hole [`TestEngine::guard_paused`] exists to prevent). To
409
+ * discard the run's state entirely instead, use [`TestEngine::reset`].
410
+ */
411
+ debugClear() {
412
+ wasm.testengine_debugClear(this.__wbg_ptr);
413
+ }
414
+ /**
415
+ * Begin a **debug** run of a `CreateInstance` command: deploy first (as
416
+ * usual), then call this to start the instance under the stepping executor,
417
+ * pausing at the first breakpoint (or running to completion if none match).
418
+ *
419
+ * `breakpoints_json` is a JSON array of `{ kind, id? }`:
420
+ * ```json
421
+ * [{ "kind": "elementActivated", "id": "Task_Charge" },
422
+ * { "kind": "elementCompleted", "id": "Gateway_1" },
423
+ * { "kind": "processCompleted" },
424
+ * { "kind": "everyStep" }]
425
+ * ```
426
+ * Returns the debug state JSON (see [`TestEngine::debug_state`]). Starting a
427
+ * new debug run replaces any previous *finished* session; it is rejected
428
+ * while a run is still paused (`debugIsPaused`) — resume or clear that run
429
+ * first, so its intermediate state isn't stranded live in the engine.
430
+ * @param {string} process_id
431
+ * @param {string} variables_json
432
+ * @param {string} breakpoints_json
433
+ * @returns {string}
434
+ */
435
+ debugCreateInstance(process_id, variables_json, breakpoints_json) {
436
+ let deferred5_0;
437
+ let deferred5_1;
438
+ try {
439
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
440
+ const ptr0 = passStringToWasm0(process_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
441
+ const len0 = WASM_VECTOR_LEN;
442
+ const ptr1 = passStringToWasm0(variables_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
443
+ const len1 = WASM_VECTOR_LEN;
444
+ const ptr2 = passStringToWasm0(breakpoints_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
445
+ const len2 = WASM_VECTOR_LEN;
446
+ wasm.testengine_debugCreateInstance(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
447
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
448
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
449
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
450
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
451
+ var ptr4 = r0;
452
+ var len4 = r1;
453
+ if (r3) {
454
+ ptr4 = 0; len4 = 0;
455
+ throw takeObject(r2);
456
+ }
457
+ deferred5_0 = ptr4;
458
+ deferred5_1 = len4;
459
+ return getStringFromWasm0(ptr4, len4);
460
+ } finally {
461
+ wasm.__wbindgen_add_to_stack_pointer(16);
462
+ wasm.__wbindgen_export3(deferred5_0, deferred5_1, 1);
463
+ }
464
+ }
465
+ /**
466
+ * Whether a debug run is currently paused at a breakpoint.
467
+ * @returns {boolean}
468
+ */
469
+ get debugIsPaused() {
470
+ const ret = wasm.testengine_debugIsPaused(this.__wbg_ptr);
471
+ return ret !== 0;
472
+ }
473
+ /**
474
+ * Resume a paused debug run until the next breakpoint or completion. No-op if
475
+ * no session is active or it has already finished. Returns the debug state.
476
+ * @returns {string}
477
+ */
478
+ debugResume() {
479
+ let deferred2_0;
480
+ let deferred2_1;
481
+ try {
482
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
483
+ wasm.testengine_debugResume(retptr, this.__wbg_ptr);
484
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
485
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
486
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
487
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
488
+ var ptr1 = r0;
489
+ var len1 = r1;
490
+ if (r3) {
491
+ ptr1 = 0; len1 = 0;
492
+ throw takeObject(r2);
493
+ }
494
+ deferred2_0 = ptr1;
495
+ deferred2_1 = len1;
496
+ return getStringFromWasm0(ptr1, len1);
497
+ } finally {
498
+ wasm.__wbindgen_add_to_stack_pointer(16);
499
+ wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
500
+ }
501
+ }
502
+ /**
503
+ * Advance a paused debug run by exactly one step, then pause again (unless
504
+ * that step drained the command). No-op if no session is active or it has
505
+ * already finished. Returns the debug state.
506
+ * @returns {string}
507
+ */
508
+ debugStep() {
509
+ let deferred2_0;
510
+ let deferred2_1;
511
+ try {
512
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
513
+ wasm.testengine_debugStep(retptr, this.__wbg_ptr);
514
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
515
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
516
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
517
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
518
+ var ptr1 = r0;
519
+ var len1 = r1;
520
+ if (r3) {
521
+ ptr1 = 0; len1 = 0;
522
+ throw takeObject(r2);
523
+ }
524
+ deferred2_0 = ptr1;
525
+ deferred2_1 = len1;
526
+ return getStringFromWasm0(ptr1, len1);
527
+ } finally {
528
+ wasm.__wbindgen_add_to_stack_pointer(16);
529
+ wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
530
+ }
531
+ }
399
532
  /**
400
533
  * Parse and deploy a BPMN resource. Returns a JSON object
401
534
  * `{ "processIds": [...], "snapshot": {...} }` on success, or throws a
@@ -494,6 +627,48 @@ export class TestEngine {
494
627
  wasm.__wbindgen_export3(deferred4_0, deferred4_1, 1);
495
628
  }
496
629
  }
630
+ /**
631
+ * Migrate a running process instance to a target process definition (Zeebe
632
+ * "migrate process instance"): re-point every active element instance at the
633
+ * mapped element of `target_process_definition_key` and re-home the instance.
634
+ * `mapping_instructions_json` is a JSON array of
635
+ * `{ sourceElementId: string, targetElementId: string }`. Returns the
636
+ * snapshot.
637
+ * @param {string} instance_key
638
+ * @param {string} target_process_definition_key
639
+ * @param {string} mapping_instructions_json
640
+ * @returns {string}
641
+ */
642
+ migrate(instance_key, target_process_definition_key, mapping_instructions_json) {
643
+ let deferred5_0;
644
+ let deferred5_1;
645
+ try {
646
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
647
+ const ptr0 = passStringToWasm0(instance_key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
648
+ const len0 = WASM_VECTOR_LEN;
649
+ const ptr1 = passStringToWasm0(target_process_definition_key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
650
+ const len1 = WASM_VECTOR_LEN;
651
+ const ptr2 = passStringToWasm0(mapping_instructions_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
652
+ const len2 = WASM_VECTOR_LEN;
653
+ wasm.testengine_migrate(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
654
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
655
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
656
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
657
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
658
+ var ptr4 = r0;
659
+ var len4 = r1;
660
+ if (r3) {
661
+ ptr4 = 0; len4 = 0;
662
+ throw takeObject(r2);
663
+ }
664
+ deferred5_0 = ptr4;
665
+ deferred5_1 = len4;
666
+ return getStringFromWasm0(ptr4, len4);
667
+ } finally {
668
+ wasm.__wbindgen_add_to_stack_pointer(16);
669
+ wasm.__wbindgen_export3(deferred5_0, deferred5_1, 1);
670
+ }
671
+ }
497
672
  /**
498
673
  * Modify a running process instance (Zeebe "modify process instance"): move
499
674
  * tokens by terminating existing element instances and/or activating new
@@ -847,7 +1022,7 @@ if (Symbol.dispose) TestEngine.prototype[Symbol.dispose] = TestEngine.prototype.
847
1022
  function __wbg_get_imports() {
848
1023
  const import0 = {
849
1024
  __proto__: null,
850
- __wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
1025
+ __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
851
1026
  throw new Error(getStringFromWasm0(arg0, arg1));
852
1027
  },
853
1028
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
@@ -911,6 +1086,10 @@ heap.push(undefined, null, true, false);
911
1086
 
912
1087
  let heap_next = heap.length;
913
1088
 
1089
+ function isLikeNone(x) {
1090
+ return x === undefined || x === null;
1091
+ }
1092
+
914
1093
  function passStringToWasm0(arg, malloc, realloc) {
915
1094
  if (realloc === undefined) {
916
1095
  const buf = cachedTextEncoder.encode(arg);
@@ -995,11 +1174,15 @@ function __wbg_finalize_init(instance, module) {
995
1174
 
996
1175
  async function __wbg_load(module, imports) {
997
1176
  if (typeof Response === 'function' && module instanceof Response) {
1177
+ if (!module.ok) {
1178
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
1179
+ }
1180
+
998
1181
  if (typeof WebAssembly.instantiateStreaming === 'function') {
999
1182
  try {
1000
1183
  return await WebAssembly.instantiateStreaming(module, imports);
1001
1184
  } catch (e) {
1002
- const validResponse = module.ok && expectedResponseType(module.type);
1185
+ const validResponse = expectedResponseType(module.type);
1003
1186
 
1004
1187
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1005
1188
  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);
Binary file
@@ -11,10 +11,16 @@ export const testengine_completeAgentJob: (a: number, b: number, c: number, d: n
11
11
  export const testengine_completeJob: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
12
12
  export const testengine_completeUserTask: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
13
13
  export const testengine_correlateMessage: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
14
- export const testengine_createInstance: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
14
+ export const testengine_createInstance: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
15
+ export const testengine_debugClear: (a: number) => void;
16
+ export const testengine_debugCreateInstance: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
17
+ export const testengine_debugIsPaused: (a: number) => number;
18
+ export const testengine_debugResume: (a: number, b: number) => void;
19
+ export const testengine_debugStep: (a: number, b: number) => void;
15
20
  export const testengine_deploy: (a: number, b: number, c: number, d: number) => void;
16
21
  export const testengine_events: (a: number, b: number) => void;
17
22
  export const testengine_failJob: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
23
+ export const testengine_migrate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
18
24
  export const testengine_modify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
19
25
  export const testengine_new: () => number;
20
26
  export const testengine_now: (a: number) => number;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nanobpm/engine-wasm",
3
- "version": "0.3.1",
4
- "description": "The nanobpmn engine (engine-core) compiled to WebAssembly for in-browser BPMN execution: deploy a diagram, start instances, activate/complete jobs, and read live snapshots/traces. The substrate for the Bojtos demo framework (ADR 0043) and the console test-run panel.",
3
+ "version": "0.5.0",
4
+ "description": "The nanobpmn engine (engine-core) compiled to WebAssembly for in-browser BPMN execution: deploy a diagram, start instances, activate/complete jobs, and read live snapshots/traces. Published as two subpath entrypoints — a lean baseline engine (default) and a read-model engine (the gateway's C8-style REST read surface). The substrate for the Bojtos demo framework (ADR 0043) and the console test-run panel.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -9,21 +9,31 @@
9
9
  "url": "https://github.com/Magikcraft/nano-bpm",
10
10
  "directory": "engine-wasm/pkg"
11
11
  },
12
- "main": "./nanobpmn_engine.js",
13
- "module": "./nanobpmn_engine.js",
14
- "types": "./nanobpmn_engine.d.ts",
12
+ "main": "./lean/nanobpmn_engine.js",
13
+ "module": "./lean/nanobpmn_engine.js",
14
+ "types": "./lean/nanobpmn_engine.d.ts",
15
15
  "exports": {
16
16
  ".": {
17
- "types": "./nanobpmn_engine.d.ts",
18
- "default": "./nanobpmn_engine.js"
17
+ "types": "./lean/nanobpmn_engine.d.ts",
18
+ "default": "./lean/nanobpmn_engine.js"
19
19
  },
20
- "./nanobpmn_engine_bg.wasm": "./nanobpmn_engine_bg.wasm"
20
+ "./readmodel": {
21
+ "types": "./readmodel/nanobpmn_engine.d.ts",
22
+ "default": "./readmodel/nanobpmn_engine.js"
23
+ },
24
+ "./lean/nanobpmn_engine_bg.wasm": "./lean/nanobpmn_engine_bg.wasm",
25
+ "./readmodel/nanobpmn_engine_bg.wasm": "./readmodel/nanobpmn_engine_bg.wasm"
21
26
  },
22
27
  "files": [
23
- "nanobpmn_engine.js",
24
- "nanobpmn_engine.d.ts",
25
- "nanobpmn_engine_bg.wasm",
26
- "nanobpmn_engine_bg.wasm.d.ts"
28
+ "lean/nanobpmn_engine.js",
29
+ "lean/nanobpmn_engine.d.ts",
30
+ "lean/nanobpmn_engine_bg.wasm",
31
+ "lean/nanobpmn_engine_bg.wasm.d.ts",
32
+ "readmodel/nanobpmn_engine.js",
33
+ "readmodel/nanobpmn_engine.d.ts",
34
+ "readmodel/nanobpmn_engine_bg.wasm",
35
+ "readmodel/nanobpmn_engine_bg.wasm.d.ts",
36
+ "README.md"
27
37
  ],
28
38
  "sideEffects": [
29
39
  "./snippets/*"