@flighthq/flow 0.5.1-next.920.da8f530 → 0.6.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.
Files changed (44) hide show
  1. package/README.md +2 -2
  2. package/dist/.tsbuildinfo.contract +1 -0
  3. package/dist/.tsbuildinfo.runtime +1 -0
  4. package/dist/contract.d.ts +6 -2
  5. package/dist/contract.d.ts.map +1 -1
  6. package/dist/contract.flow-types.d.ts +3 -0
  7. package/dist/contract.flow-types.d.ts.map +1 -0
  8. package/dist/contract.flow-types.js +2 -0
  9. package/dist/contract.flow-types.js.map +1 -0
  10. package/dist/contract.js +5 -2
  11. package/dist/contract.js.map +1 -1
  12. package/dist/flow.d.ts +46 -11
  13. package/dist/flow.d.ts.map +1 -1
  14. package/dist/flow.js +176 -71
  15. package/dist/flow.js.map +1 -1
  16. package/dist/flowGuards.d.ts +23 -0
  17. package/dist/flowGuards.d.ts.map +1 -0
  18. package/dist/flowGuards.js +78 -0
  19. package/dist/flowGuards.js.map +1 -0
  20. package/dist/flowStackCompat.d.ts +20 -0
  21. package/dist/flowStackCompat.d.ts.map +1 -0
  22. package/dist/flowStackCompat.js +47 -0
  23. package/dist/flowStackCompat.js.map +1 -0
  24. package/dist/flowTransitions.d.ts +3 -0
  25. package/dist/flowTransitions.d.ts.map +1 -0
  26. package/dist/flowTransitions.js +14 -0
  27. package/dist/flowTransitions.js.map +1 -0
  28. package/dist/flowTypes.d.ts +33 -0
  29. package/dist/flowTypes.d.ts.map +1 -0
  30. package/dist/flowTypes.js +4 -0
  31. package/dist/flowTypes.js.map +1 -0
  32. package/dist/index.d.ts +3 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +4 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/types.d.ts +24 -0
  37. package/dist/types.d.ts.map +1 -0
  38. package/dist/types.js +4 -0
  39. package/dist/types.js.map +1 -0
  40. package/package.json +6 -4
  41. package/src/flow.test.ts +440 -175
  42. package/src/flowGuards.test.ts +146 -0
  43. package/src/flowStackCompat.test.ts +99 -0
  44. package/src/flowTransitions.test.ts +26 -0
@@ -0,0 +1,23 @@
1
+ import type { LogStateRaw } from '@flighthq/log/contract';
2
+ import type { FlowGuardStateRef } from './flow.ts';
3
+ import type { FlowGuardKind } from './types.ts';
4
+ export declare function disableFlowGuards(state: FlowGuardStateRef): void;
5
+ /**
6
+ * Install the opt-in guards with the approved enable-time context: a caller-owned log state and a
7
+ * live clock invoked at operation time.
8
+ */
9
+ export declare function enableFlowGuards(state: FlowGuardStateRef, logState: LogStateRaw, clock: () => number): void;
10
+ /**
11
+ * The canonical TS string for a guard kind (D9e).
12
+ */
13
+ export declare function getFlowGuardKindString(value: FlowGuardKind): string;
14
+ /**
15
+ * Parses a guard kind string back to the enum (D9e); None for unknown names.
16
+ */
17
+ export declare function parseFlowGuardKind(value: string): FlowGuardKind | null;
18
+ /**
19
+ * Reports a flow guard violation when enabled, with the exact TS key/channel/payload. The clock is
20
+ * invoked at call time; no hidden state or frozen timestamp is involved.
21
+ */
22
+ export declare function reportFlowGuard(state: Readonly<FlowGuardStateRef>, kind: FlowGuardKind): void;
23
+ //# sourceMappingURL=flowGuards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowGuards.d.ts","sourceRoot":"","sources":["../src/flowGuards.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAqB,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAUhD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAIhE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,MAAM,GAAG,IAAI,CAI3G;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAUnE;AAUD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAYtE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,CAmB7F"}
@@ -0,0 +1,78 @@
1
+ // Generated from crates/flight-flow/src/flow_guards.rs by flight-compiler.
2
+ // Rust is authoritative; run `npm run generate` after changing it.
3
+ import { logOnce } from '@flighthq/log/contract';
4
+ export function disableFlowGuards(state) {
5
+ let guardState = state;
6
+ guardState.enabled = false;
7
+ guardState.context = null;
8
+ }
9
+ /**
10
+ * Install the opt-in guards with the approved enable-time context: a caller-owned log state and a
11
+ * live clock invoked at operation time.
12
+ */
13
+ export function enableFlowGuards(state, logState, clock) {
14
+ let guardState = state;
15
+ guardState.enabled = true;
16
+ guardState.context = { logState: logState, clock: clock };
17
+ }
18
+ /**
19
+ * The canonical TS string for a guard kind (D9e).
20
+ */
21
+ export function getFlowGuardKindString(value) {
22
+ return (() => {
23
+ const matchValue = value;
24
+ switch (matchValue) {
25
+ case 'duplicate-state-push':
26
+ return 'duplicate-state-push';
27
+ case 'transition-during-transition':
28
+ return 'transition-during-transition';
29
+ }
30
+ })();
31
+ }
32
+ function getFlowGuardLogKind(value) {
33
+ return value.kind;
34
+ }
35
+ function normalizeFlowGuardLogLevel(value) {
36
+ return value;
37
+ }
38
+ /**
39
+ * Parses a guard kind string back to the enum (D9e); None for unknown names.
40
+ */
41
+ export function parseFlowGuardKind(value) {
42
+ return (() => {
43
+ const matchValue = value;
44
+ switch (matchValue) {
45
+ case 'duplicate-state-push':
46
+ return 'duplicate-state-push';
47
+ case 'transition-during-transition':
48
+ return 'transition-during-transition';
49
+ default:
50
+ return null;
51
+ }
52
+ })();
53
+ }
54
+ /**
55
+ * Reports a flow guard violation when enabled, with the exact TS key/channel/payload. The clock is
56
+ * invoked at call time; no hidden state or frozen timestamp is involved.
57
+ */
58
+ export function reportFlowGuard(state, kind) {
59
+ const [maybeContext, enabled] = (() => {
60
+ const guardState = state;
61
+ return [guardState.context, guardState.enabled];
62
+ })();
63
+ if (!enabled) {
64
+ return;
65
+ }
66
+ if (maybeContext === null) {
67
+ return;
68
+ }
69
+ const activeContext = maybeContext;
70
+ const kindString = getFlowGuardKindString(kind);
71
+ const data = { kind: String(kindString) };
72
+ const dataKind = getFlowGuardLogKind(data);
73
+ const key = `flow:${dataKind}`;
74
+ const logData = data;
75
+ const level = normalizeFlowGuardLogLevel(2);
76
+ logOnce(activeContext.logState, activeContext.clock(), key, level, logData, 'flow');
77
+ }
78
+ //# sourceMappingURL=flowGuards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowGuards.js","sourceRoot":"","sources":["../src/flowGuards.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,mEAAmE;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAcjD,MAAM,UAAU,iBAAiB,CAAC,KAAwB;IACxD,IAAI,UAAU,GAAG,KAAM,CAAC;IACxB,UAAU,CAAC,OAAO,GAAG,KAAK,CAAC;IAC3B,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAwB,EAAE,QAAqB,EAAE,KAAmB;IACnG,IAAI,UAAU,GAAG,KAAM,CAAC;IACxB,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;IAC1B,UAAU,CAAC,OAAO,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC5D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAoB;IACzD,OAAO,CAAC,GAAG,EAAE;QACX,MAAM,UAAU,GAAG,KAAK,CAAC;QACzB,QAAQ,UAAU,EAAE,CAAC;YACnB,KAAK,sBAAsB;gBACzB,OAAO,sBAAsB,CAAC;YAChC,KAAK,8BAA8B;gBACjC,OAAO,8BAA8B,CAAC;QAC1C,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;AACP,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAiC;IAC5D,OAAO,KAAK,CAAC,IAAI,CAAC;AACpB,CAAC;AAED,SAAS,0BAA0B,CAAC,KAAwB;IAC1D,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,OAAO,CAAC,GAAG,EAAE;QACX,MAAM,UAAU,GAAG,KAAK,CAAC;QACzB,QAAQ,UAAU,EAAE,CAAC;YACnB,KAAK,sBAAsB;gBACzB,OAAO,sBAAsB,CAAC;YAChC,KAAK,8BAA8B;gBACjC,OAAO,8BAA8B,CAAC;YACxC;gBACE,OAAO,IAAI,CAAC;QAChB,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;AACP,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAkC,EAAE,IAAmB;IACrF,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE;QACpC,MAAM,UAAU,GAAG,KAAM,CAAC;QAC1B,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC,CAAC,EAAE,CAAC;IACL,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IACD,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC1B,OAAO;IACT,CAAC;IACD,MAAM,aAAa,GAAG,YAAa,CAAC;IACpC,MAAM,UAAU,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;IAC1C,MAAM,QAAQ,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,QAAQ,QAAQ,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAsB,IAAI,CAAC;IACxC,MAAM,KAAK,GAAG,0BAA0B,CAAC,CAAC,CAAC,CAAC;IAC5C,OAAO,CAAC,aAAa,CAAC,QAAQ,EAAE,aAAa,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AACtF,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { Entity } from '@flighthq/entity/contract';
2
+ import type { FlowGuardStateRef } from './flow.ts';
3
+ import type { FlowStackRaw, FlowState } from './flowTypes.ts';
4
+ /** Entity/OOP companion for the tree-shakeable Flow stack free functions. */
5
+ export declare class FlowStack extends Entity {
6
+ readonly raw: FlowStackRaw;
7
+ constructor(raw?: FlowStackRaw);
8
+ static create(): FlowStack;
9
+ static from(raw: FlowStackRaw): FlowStack;
10
+ get states(): FlowState[];
11
+ activeState(): FlowState | null;
12
+ clearStack(): void;
13
+ popState(): FlowState | null;
14
+ pushState(state: FlowState, guards: Readonly<FlowGuardStateRef>): void;
15
+ replaceState(state: FlowState, guards: Readonly<FlowGuardStateRef>): void;
16
+ stackDepth(): number;
17
+ updateStack(deltaTime: number): void;
18
+ visibleStates(out: FlowState[]): void;
19
+ }
20
+ //# sourceMappingURL=flowStackCompat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowStackCompat.d.ts","sourceRoot":"","sources":["../src/flowStackCompat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAsB,MAAM,2BAA2B,CAAC;AAavE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE9D,6EAA6E;AAC7E,qBAAa,SAAU,SAAQ,MAAM;IACnC,SAAiB,GAAG,EAAE,YAAY,CAAC;IAEnC,YAAY,GAAG,GAAE,YAAgC,EAEhD;IAED,OAAgB,MAAM,IAAI,SAAS,CAElC;IAED,OAAgB,IAAI,CAAC,GAAG,EAAE,YAAY,GAAG,SAAS,CAKjD;IAED,IAAI,MAAM,IAAI,SAAS,EAAE,CAExB;IAED,WAAW,IAAI,SAAS,GAAG,IAAI,CAE9B;IAED,UAAU,IAAI,IAAI,CAEjB;IAED,QAAQ,IAAI,SAAS,GAAG,IAAI,CAE3B;IAED,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAErE;IAED,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAExE;IAED,UAAU,IAAI,MAAM,CAEnB;IAED,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAEnC;IAED,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,IAAI,CAEpC;CACF"}
@@ -0,0 +1,47 @@
1
+ import { Entity, getEntityWrapperAs } from '@flighthq/entity/contract';
2
+ import { clearFlowStack, createFlowStack, getActiveFlowState, getFlowStackDepth, getFlowStackVisibleStates, popFlowState, pushFlowState, replaceFlowState, updateFlowStack, } from './flow.js';
3
+ /** Entity/OOP companion for the tree-shakeable Flow stack free functions. */
4
+ export class FlowStack extends Entity {
5
+ constructor(raw = createFlowStack()) {
6
+ super(raw);
7
+ }
8
+ static create() {
9
+ return new FlowStack();
10
+ }
11
+ static from(raw) {
12
+ const existing = getEntityWrapperAs(raw);
13
+ if (existing === null)
14
+ return new FlowStack(raw);
15
+ if (existing instanceof FlowStack)
16
+ return existing;
17
+ throw new TypeError('FlowStackRaw is already attached to an incompatible OOP wrapper');
18
+ }
19
+ get states() {
20
+ return this.raw.states;
21
+ }
22
+ activeState() {
23
+ return getActiveFlowState(this.raw);
24
+ }
25
+ clearStack() {
26
+ clearFlowStack(this.raw);
27
+ }
28
+ popState() {
29
+ return popFlowState(this.raw);
30
+ }
31
+ pushState(state, guards) {
32
+ pushFlowState(this.raw, state, guards);
33
+ }
34
+ replaceState(state, guards) {
35
+ replaceFlowState(this.raw, state, guards);
36
+ }
37
+ stackDepth() {
38
+ return getFlowStackDepth(this.raw);
39
+ }
40
+ updateStack(deltaTime) {
41
+ updateFlowStack(this.raw, deltaTime);
42
+ }
43
+ visibleStates(out) {
44
+ getFlowStackVisibleStates(out, this.raw);
45
+ }
46
+ }
47
+ //# sourceMappingURL=flowStackCompat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowStackCompat.js","sourceRoot":"","sources":["../src/flowStackCompat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEvE,OAAO,EACL,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EACzB,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,eAAe,GAChB,MAAM,WAAW,CAAC;AAInB,6EAA6E;AAC7E,MAAM,OAAO,SAAU,SAAQ,MAAM;IAGnC,YAAY,GAAG,GAAiB,eAAe,EAAE;QAC/C,KAAK,CAAC,GAAG,CAAC,CAAC;IACb,CAAC;IAED,MAAM,CAAU,MAAM;QACpB,OAAO,IAAI,SAAS,EAAE,CAAC;IACzB,CAAC;IAED,MAAM,CAAU,IAAI,CAAC,GAAiB;QACpC,MAAM,QAAQ,GAAG,kBAAkB,CAAS,GAAG,CAAC,CAAC;QACjD,IAAI,QAAQ,KAAK,IAAI;YAAE,OAAO,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC;QACjD,IAAI,QAAQ,YAAY,SAAS;YAAE,OAAO,QAAQ,CAAC;QACnD,MAAM,IAAI,SAAS,CAAC,iEAAiE,CAAC,CAAC;IACzF,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,WAAW;QACT,OAAO,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;IAED,UAAU;QACR,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,QAAQ;QACN,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,SAAS,CAAC,KAAgB,EAAE,MAAmC;QAC7D,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,YAAY,CAAC,KAAgB,EAAE,MAAmC;QAChE,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,UAAU;QACR,OAAO,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAED,WAAW,CAAC,SAAiB;QAC3B,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IACvC,CAAC;IAED,aAAa,CAAC,GAAgB;QAC5B,yBAAyB,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ import type { FlowGuardStateRef } from './flow.ts';
2
+ export declare function runFlowTransition(guards: Readonly<FlowGuardStateRef>, operation: (depth: number) => void): void;
3
+ //# sourceMappingURL=flowTransitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowTransitions.d.ts","sourceRoot":"","sources":["../src/flowTransitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAInD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAS/G"}
@@ -0,0 +1,14 @@
1
+ // TypeScript's narrow unwind adapter for Rust's `Drop` transition guard. The portable state-stack
2
+ // behavior is generated in flow.ts; only the target's cleanup construct lives here.
3
+ export function runFlowTransition(guards, operation) {
4
+ const mutableGuards = guards;
5
+ const depth = mutableGuards.transitionDepth;
6
+ mutableGuards.transitionDepth += 1;
7
+ try {
8
+ operation(depth);
9
+ }
10
+ finally {
11
+ mutableGuards.transitionDepth -= 1;
12
+ }
13
+ }
14
+ //# sourceMappingURL=flowTransitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowTransitions.js","sourceRoot":"","sources":["../src/flowTransitions.ts"],"names":[],"mappings":"AAEA,kGAAkG;AAClG,oFAAoF;AACpF,MAAM,UAAU,iBAAiB,CAAC,MAAmC,EAAE,SAAkC;IACvG,MAAM,aAAa,GAAG,MAA2B,CAAC;IAClD,MAAM,KAAK,GAAG,aAAa,CAAC,eAAe,CAAC;IAC5C,aAAa,CAAC,eAAe,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC;QACH,SAAS,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;YAAS,CAAC;QACT,aAAa,CAAC,eAAe,IAAI,CAAC,CAAC;IACrC,CAAC;AACH,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { EntityRaw } from '@flighthq/entity/contract';
2
+ /**
3
+ * A lifecycle callback stored on a flow state (D9 stored capturing form).
4
+ */
5
+ export type FlowCallback = () => void;
6
+ /**
7
+ * A per-frame update callback stored on a flow state.
8
+ */
9
+ export type FlowUpdateCallback = (arg0: number) => void;
10
+ /**
11
+ * A single application state in a flow stack. Plain data: callers construct it with a literal
12
+ * (TS `FlowState` does not extend Entity). The stack stores it behind `Ref`, matching TS object
13
+ * identity and enabling real re-entrant transitions.
14
+ */
15
+ export interface FlowState {
16
+ name?: string;
17
+ onEnter?: FlowCallback;
18
+ onExit?: FlowCallback;
19
+ onPause?: FlowCallback;
20
+ onResume?: FlowCallback;
21
+ onUpdate?: FlowUpdateCallback;
22
+ renderBelow?: boolean;
23
+ updateBelow?: boolean;
24
+ }
25
+ /**
26
+ * The flow-state stack. `states` is ordered bottom-to-top, so the last element is the active top;
27
+ * each state is a shared `Ref`, so duplicate detection is `Arc::ptrEq` exactly as TS compares
28
+ * object references.
29
+ */
30
+ export interface FlowStackRaw extends EntityRaw {
31
+ states: FlowState[];
32
+ }
33
+ //# sourceMappingURL=flowTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowTypes.d.ts","sourceRoot":"","sources":["../src/flowTypes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC;AAEtC;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAExD;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC7C,MAAM,EAAE,SAAS,EAAE,CAAC;CACrB"}
@@ -0,0 +1,4 @@
1
+ // Generated from crates/flight-flow/src/flow_types.rs by flight-compiler.
2
+ // Rust is authoritative; run `npm run generate` after changing it.
3
+ export {};
4
+ //# sourceMappingURL=flowTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowTypes.js","sourceRoot":"","sources":["../src/flowTypes.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,mEAAmE"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
- export { clearFlowStack, createFlowStack, getActiveFlowState, getFlowStackDepth, getFlowStackVisibleStates, popFlowState, pushFlowState, replaceFlowState, updateFlowStack, } from './contract';
1
+ export { clearFlowStack, createFlowStack, disableFlowGuards, enableFlowGuards, getActiveFlowState, getFlowGuardKindString, getFlowStackDepth, getFlowStackVisibleStates, parseFlowGuardKind, popFlowState, pushFlowState, replaceFlowState, updateFlowStack, } from './contract.ts';
2
+ export type { FlowGuardContext, FlowGuardKind, FlowGuardState, FlowStackRaw, FlowState } from './contract.ts';
3
+ export { FlowStack } from './flowStackCompat.ts';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EACzB,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,eAAe,GAChB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC9G,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,5 @@
1
- export { clearFlowStack, createFlowStack, getActiveFlowState, getFlowStackDepth, getFlowStackVisibleStates, popFlowState, pushFlowState, replaceFlowState, updateFlowStack, } from './contract';
1
+ // Generated from crates/flight-flow/src/lib.rs by flight-compiler.
2
+ // Rust is authoritative; run `npm run generate` after changing it.
3
+ export { clearFlowStack, createFlowStack, disableFlowGuards, enableFlowGuards, getActiveFlowState, getFlowGuardKindString, getFlowStackDepth, getFlowStackVisibleStates, parseFlowGuardKind, popFlowState, pushFlowState, replaceFlowState, updateFlowStack, } from './contract.js';
4
+ export { FlowStack } from './flowStackCompat.js';
2
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EACzB,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,eAAe,GAChB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,mEAAmE;AAEnE,OAAO,EACL,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,eAAe,GAChB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { LogStateRaw } from '@flighthq/log/contract';
2
+ /**
3
+ * The kind of flow guard violation detected during a stack transition. The strings match the TS
4
+ * string union exactly (D9e).
5
+ */
6
+ export type FlowGuardKind = 'duplicate-state-push' | 'transition-during-transition';
7
+ /**
8
+ * Approved enable-time guard context: explicit caller-owned log state plus a live clock invoked at
9
+ * operation time (never a frozen timestamp or hidden clock).
10
+ */
11
+ export interface FlowGuardContext {
12
+ logState: LogStateRaw;
13
+ clock: () => number;
14
+ }
15
+ /**
16
+ * Explicit diagnostics state for the opt-in flow guards (D5). Plain Rust-only dispatch state: the
17
+ * caller creates it with a literal and shares it with re-entrant transition callbacks.
18
+ */
19
+ export interface FlowGuardState {
20
+ enabled: boolean;
21
+ transitionDepth: number;
22
+ context: FlowGuardContext | null;
23
+ }
24
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,sBAAsB,GAAG,8BAA8B,CAAC;AAEpF;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,WAAW,CAAC;IACtB,KAAK,EAAE,MAAM,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAClC"}
package/dist/types.js ADDED
@@ -0,0 +1,4 @@
1
+ // Generated from crates/flight-flow/src/types.rs by flight-compiler.
2
+ // Rust is authoritative; run `npm run generate` after changing it.
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,mEAAmE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/flow",
3
- "version": "0.5.1-next.920.da8f530",
3
+ "version": "0.6.0",
4
4
  "author": "Joshua Granick and other contributors",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -32,17 +32,19 @@
32
32
  "scripts": {
33
33
  "build": "tsc -b",
34
34
  "clean": "tsc -b --clean",
35
+ "generate": "tsx ../../scripts/generate-rust-package.ts --crate flight-flow --package flow --lenient",
36
+ "generate:check": "tsx ../../scripts/generate-rust-package.ts --crate flight-flow --package flow --lenient --check",
35
37
  "test": "vitest run --config vitest.config.ts",
36
38
  "test:watch": "vitest --watch --config vitest.config.ts",
37
39
  "prepack": "npm run clean && npm run clean:dist && npm run build",
38
40
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
39
41
  },
40
42
  "dependencies": {
41
- "@flighthq/entity": "0.5.1-next.920.da8f530",
42
- "@flighthq/types": "0.5.1-next.920.da8f530"
43
+ "@flighthq/entity": "0.6.0",
44
+ "@flighthq/log": "0.6.0"
43
45
  },
44
46
  "devDependencies": {
45
- "typescript": "^5.3.0"
47
+ "typescript": "^7.0.2"
46
48
  },
47
49
  "description": "Application mode/screen flow-state stack — a plain-data stack of application states (boot, menu, play, pause, game-over) with a paired enter/exit/pause/resume/update lifecycle driven by push/pop/replace/clear transitions, transparent-overlay update-below/render-below flags, an update pass that ticks the active state and any opted-in states beneath it, and active-state/depth/visible-states queries; direct lifecycle callbacks (single-owner, deterministic order), not signals",
48
50
  "sideEffects": false