@nanobpm/bojtos-react 0.8.0 → 0.9.1

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.
@@ -1,4 +1,4 @@
1
- import { type ActivateInstruction, type AgentResult, type DispatchOptions, type EngineVariant, type FormResult, type JobHandler, type ProcessInstanceSearchQueryResult, type ResourceResult, type RoundResult, type Snapshot, type UserTaskSearchQueryResult, type VariableSearchQueryResult, type WasmEvent, type WasmSource } from "@nanobpm/bojtos-kit";
1
+ import { type ActivateInstruction, type AgentResult, type DispatchOptions, type EngineReadModel, type EngineVariant, type FormResult, type JobHandler, type ProcessInstanceSearchQueryResult, type ResourceResult, type RoundResult, type Snapshot, type UserTaskSearchQueryResult, type VariableSearchQueryResult, type WasmEvent, type WasmSource } from "@nanobpm/bojtos-kit";
2
2
  /** Lifecycle of the in-browser engine load. */
3
3
  export type BojtosPhase = "loading" | "ready" | "error";
4
4
  export interface UseBojtosOptions {
@@ -202,6 +202,15 @@ export interface ReadModelBojtosControls extends BojtosControls {
202
202
  * engine is ready.
203
203
  */
204
204
  getResourceByKey(resourceKey: string): ResourceResult | null;
205
+ /**
206
+ * This session's engine read-model handle as `@nanobpm/engine-testkit`'s
207
+ * structural `EngineReadModel` port — feed it straight to `assertThatInstance`
208
+ * / `assertThatUserTask`. Returns `null` until the engine is ready (or on a
209
+ * lean-variant hook). Like the other read queries it is a pull projection: the
210
+ * handle reads live engine state on each call, so re-read it (keyed on
211
+ * {@link readModelVersion}) rather than caching its results.
212
+ */
213
+ readModel(): EngineReadModel | null;
205
214
  /**
206
215
  * A monotonically increasing counter bumped after every command / worker round
207
216
  * (and on deploy / reset). It is the reactivity signal for the pull read
package/dist/useBojtos.js CHANGED
@@ -223,6 +223,7 @@ export function useBojtos({ bpmn, wasm, maxEvents, variant, }) {
223
223
  const searchVariables = useCallback((filterJson) => selectReadModel(readModelRef.current, (rm) => rm.searchVariables(filterJson)), []);
224
224
  const getFormByKey = useCallback((formKey) => selectReadModel(readModelRef.current, (rm) => rm.getFormByKey(formKey)), []);
225
225
  const getResourceByKey = useCallback((resourceKey) => selectReadModel(readModelRef.current, (rm) => rm.getResourceByKey(resourceKey)), []);
226
+ const readModel = useCallback(() => selectReadModel(readModelRef.current, (rm) => rm.readModel()), []);
226
227
  return {
227
228
  phase,
228
229
  error,
@@ -254,6 +255,7 @@ export function useBojtos({ bpmn, wasm, maxEvents, variant, }) {
254
255
  searchVariables,
255
256
  getFormByKey,
256
257
  getResourceByKey,
258
+ readModel,
257
259
  readModelVersion,
258
260
  };
259
261
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nanobpm/bojtos-react",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "description": "React binding for the Bojtos in-browser BPMN demo framework (ADR 0043): the useBojtos hook (owns the engine session + reactive snapshot/event state) and the <BpmnRuntimeView> live token/incident diagram. Built on @nanobpm/bojtos-kit; the console test-run panel is its first consumer.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -24,6 +24,9 @@
24
24
  "src"
25
25
  ],
26
26
  "sideEffects": false,
27
+ "engines": {
28
+ "node": ">=22.6"
29
+ },
27
30
  "scripts": {
28
31
  "build": "tsc -p tsconfig.json",
29
32
  "typecheck": "tsc -p tsconfig.json --noEmit",
@@ -32,7 +35,7 @@
32
35
  "test:ci": "node --experimental-strip-types --test test/*.test.ts"
33
36
  },
34
37
  "dependencies": {
35
- "@nanobpm/bojtos-kit": "^0.8.0"
38
+ "@nanobpm/bojtos-kit": "^0.9.1"
36
39
  },
37
40
  "peerDependencies": {
38
41
  "bpmn-js": ">=17",
package/src/useBojtos.ts CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  type DispatchOptions,
8
8
  dispatchRound,
9
9
  dispatchWorkers,
10
+ type EngineReadModel,
10
11
  type EngineVariant,
11
12
  type FormResult,
12
13
  type JobHandler,
@@ -262,6 +263,15 @@ export interface ReadModelBojtosControls extends BojtosControls {
262
263
  * engine is ready.
263
264
  */
264
265
  getResourceByKey(resourceKey: string): ResourceResult | null;
266
+ /**
267
+ * This session's engine read-model handle as `@nanobpm/engine-testkit`'s
268
+ * structural `EngineReadModel` port — feed it straight to `assertThatInstance`
269
+ * / `assertThatUserTask`. Returns `null` until the engine is ready (or on a
270
+ * lean-variant hook). Like the other read queries it is a pull projection: the
271
+ * handle reads live engine state on each call, so re-read it (keyed on
272
+ * {@link readModelVersion}) rather than caching its results.
273
+ */
274
+ readModel(): EngineReadModel | null;
265
275
  /**
266
276
  * A monotonically increasing counter bumped after every command / worker round
267
277
  * (and on deploy / reset). It is the reactivity signal for the pull read
@@ -685,6 +695,10 @@ export function useBojtos({
685
695
  ),
686
696
  [],
687
697
  );
698
+ const readModel = useCallback(
699
+ () => selectReadModel(readModelRef.current, (rm) => rm.readModel()),
700
+ [],
701
+ );
688
702
 
689
703
  return {
690
704
  phase,
@@ -717,6 +731,7 @@ export function useBojtos({
717
731
  searchVariables,
718
732
  getFormByKey,
719
733
  getResourceByKey,
734
+ readModel,
720
735
  readModelVersion,
721
736
  };
722
737
  }