machinalayout 0.3.0 → 0.3.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.
package/README.md CHANGED
@@ -397,5 +397,5 @@ This repo uses Biome.
397
397
  - [Z-order and containment](docs/z-order-and-containment.md)
398
398
  - [Error code reference](docs/error-codes.md)
399
399
  - [MachinaDispatch runtime guide](docs/machina-dispatch.md)
400
- - [DeusMachina behavioral kernel](docs/deusmachina.md)
400
+ - [DeusMachina behavioral kernel and framework bindings](docs/deusmachina.md)
401
401
  - Dispatch sample: [`samples/dispatch-counter`](samples/dispatch-counter/README.md) (uses `machinalayout/dispatch`)
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import { M as MachinaDebugOverlayMode } from './debugOverlay-fWLv1cS7.js';
3
+ import { R as ResolvedLayoutDocument, N as NodeId, a as Rect, b as ResolvedLayoutNode } from './types-CYgsjDai.js';
4
+
5
+ type MachinaSlotProps<TViewData = unknown, TNodeData = unknown> = {
6
+ id: NodeId;
7
+ rect: Rect;
8
+ debugLabel?: string;
9
+ node: ResolvedLayoutNode;
10
+ viewKey?: string;
11
+ viewData?: TViewData;
12
+ nodeData?: TNodeData;
13
+ };
14
+ type MachinaRenderLayer = {
15
+ z: number;
16
+ };
17
+ type MachinaReactDebugOverlayOptions = {
18
+ mode?: MachinaDebugOverlayMode;
19
+ labels?: boolean;
20
+ borders?: boolean;
21
+ selectedNodeId?: string;
22
+ };
23
+ type MachinaReactViewProps = {
24
+ layout: ResolvedLayoutDocument;
25
+ views?: Record<string, React.ComponentType<MachinaSlotProps>>;
26
+ viewData?: Record<string, unknown>;
27
+ nodeData?: Record<NodeId, unknown>;
28
+ className?: string;
29
+ style?: React.CSSProperties;
30
+ nodeClassName?: string;
31
+ debug?: boolean;
32
+ nodeContainment?: "none" | "layout-paint" | "strict";
33
+ nodeContentVisibility?: "none" | "auto";
34
+ nodeContainIntrinsicSize?: string;
35
+ layers?: Record<string, MachinaRenderLayer>;
36
+ defaultLayer?: string;
37
+ debugOverlay?: MachinaReactDebugOverlayOptions;
38
+ };
39
+ declare function MachinaReactView(props: MachinaReactViewProps): React.JSX.Element;
40
+
41
+ export { type MachinaReactDebugOverlayOptions as M, MachinaReactView as a, type MachinaReactViewProps as b, type MachinaSlotProps as c };
@@ -0,0 +1,63 @@
1
+ import {
2
+ createDeusSnapshot,
3
+ stepDeusMachine
4
+ } from "./chunk-2ZQ2RFFI.js";
5
+
6
+ // src/react-common/useDeusMachine.ts
7
+ import { useCallback, useEffect, useRef, useState } from "react";
8
+ function resolveInitialBoard(initialBoard) {
9
+ return typeof initialBoard === "function" ? initialBoard() : initialBoard;
10
+ }
11
+ function useDeusMachine(machine, initialBoard) {
12
+ const initialBoardRef = useRef(initialBoard);
13
+ initialBoardRef.current = initialBoard;
14
+ const createSnapshot = useCallback(
15
+ (board) => createDeusSnapshot(machine, resolveInitialBoard(board ?? initialBoardRef.current)),
16
+ [machine]
17
+ );
18
+ const [snapshot, setSnapshot] = useState(() => createSnapshot());
19
+ const snapshotRef = useRef(snapshot);
20
+ const [lastTrace, setLastTrace] = useState(null);
21
+ const didMountRef = useRef(false);
22
+ useEffect(() => {
23
+ if (!didMountRef.current) {
24
+ didMountRef.current = true;
25
+ return;
26
+ }
27
+ const nextSnapshot = createSnapshot();
28
+ snapshotRef.current = nextSnapshot;
29
+ setSnapshot(nextSnapshot);
30
+ setLastTrace(null);
31
+ }, [createSnapshot]);
32
+ const dispatch = useCallback(
33
+ (event) => {
34
+ const result = stepDeusMachine(machine, snapshotRef.current, event);
35
+ snapshotRef.current = result.snapshot;
36
+ setSnapshot(result.snapshot);
37
+ setLastTrace(result.trace);
38
+ return result;
39
+ },
40
+ [machine]
41
+ );
42
+ const reset = useCallback(
43
+ (board) => {
44
+ const nextSnapshot = createSnapshot(board);
45
+ snapshotRef.current = nextSnapshot;
46
+ setSnapshot(nextSnapshot);
47
+ setLastTrace(null);
48
+ },
49
+ [createSnapshot]
50
+ );
51
+ return {
52
+ snapshot,
53
+ board: snapshot.board,
54
+ state: snapshot.state,
55
+ dispatch,
56
+ lastTrace,
57
+ reset
58
+ };
59
+ }
60
+
61
+ export {
62
+ useDeusMachine
63
+ };
@@ -0,0 +1,36 @@
1
+ import { e as DeusMachine } from './types-CWaup8Z6.js';
2
+
3
+ type MachinaDebugOverlayMode = "collapsed" | "nonInteractiveOverlay" | "interactivePanel";
4
+ type MachinaDebugOverlayBoard = {
5
+ mode: MachinaDebugOverlayMode;
6
+ labels: boolean;
7
+ borders: boolean;
8
+ selectedNodeId?: string;
9
+ };
10
+ type MachinaDebugOverlayEvent = {
11
+ type: "showOverlay";
12
+ } | {
13
+ type: "openPanel";
14
+ nodeId?: string;
15
+ } | {
16
+ type: "collapse";
17
+ } | {
18
+ type: "toggleLabels";
19
+ } | {
20
+ type: "toggleBorders";
21
+ } | {
22
+ type: "selectNode";
23
+ nodeId: string;
24
+ };
25
+ type MachinaDebugOverlayBehavior = {
26
+ visible: boolean;
27
+ pointerEvents: "none" | "auto";
28
+ consumesLayoutSpace: boolean;
29
+ showPanel: boolean;
30
+ showLabels: boolean;
31
+ showBorders: boolean;
32
+ };
33
+ declare function createMachinaDebugOverlayMachine(): DeusMachine<MachinaDebugOverlayBoard, MachinaDebugOverlayEvent>;
34
+ declare function getMachinaDebugOverlayBehavior(board: MachinaDebugOverlayBoard): MachinaDebugOverlayBehavior;
35
+
36
+ export { type MachinaDebugOverlayMode as M, type MachinaDebugOverlayBehavior as a, type MachinaDebugOverlayBoard as b, type MachinaDebugOverlayEvent as c, createMachinaDebugOverlayMachine as d, getMachinaDebugOverlayBehavior as g };
@@ -1,5 +1,6 @@
1
- import { U as UtilityCandidate, J as JudgeUtilityOptions, a as UtilityJudgment, D as DeusEvent, b as DeusMachine, c as DeusSnapshot, d as DeusStatePath, e as DeusStepTrace, f as DeusStepResult } from '../debugOverlay-pJpj0n5H.js';
2
- export { g as DeusAction, h as DeusMachinaError, i as DeusStateRow, j as DeusTransitionRow, k as DeusTransitionTrace, l as DeusUtilityTransitionCandidate, M as MachinaDebugOverlayBehavior, m as MachinaDebugOverlayBoard, n as MachinaDebugOverlayEvent, o as MachinaDebugOverlayMode, p as UtilityCandidateResult, q as UtilityScore, r as createMachinaDebugOverlayMachine, s as getMachinaDebugOverlayBehavior } from '../debugOverlay-pJpj0n5H.js';
1
+ import { U as UtilityCandidate, J as JudgeUtilityOptions, f as UtilityJudgment, D as DeusEvent, e as DeusMachine, a as DeusSnapshot, b as DeusStatePath, d as DeusStepTrace, c as DeusStepResult } from '../types-CWaup8Z6.js';
2
+ export { g as DeusAction, h as DeusMachinaError, i as DeusStateRow, j as DeusTransitionRow, k as DeusTransitionTrace, l as DeusUtilityTransitionCandidate, m as UtilityCandidateResult, n as UtilityScore } from '../types-CWaup8Z6.js';
3
+ export { a as MachinaDebugOverlayBehavior, b as MachinaDebugOverlayBoard, c as MachinaDebugOverlayEvent, M as MachinaDebugOverlayMode, d as createMachinaDebugOverlayMachine, g as getMachinaDebugOverlayBehavior } from '../debugOverlay-fWLv1cS7.js';
3
4
 
4
5
  declare function judgeUtility<TContext, TKey extends string = string>(context: TContext, candidates: readonly UtilityCandidate<TContext, TKey>[], options?: JudgeUtilityOptions<TKey>): UtilityJudgment<TKey>;
5
6
 
@@ -1,6 +1,6 @@
1
- import { M as MachinaDomSummary } from '../types-DLYAhNXw.js';
1
+ import { M as MachinaDomSummary } from '../types-bJlg6wno.js';
2
2
  import { M as MachinaViewport, a as MachinaScreenViewportTask } from '../screenCatalog-ZjonGiOi.js';
3
- import '../types-B90jb3RW.js';
3
+ import '../types-CYgsjDai.js';
4
4
 
5
5
  type MachinaHandoffArtifactPaths = {
6
6
  screenshot?: string;
package/dist/index.d.ts CHANGED
@@ -1,12 +1,13 @@
1
- import { E as EdgeInsets, U as UiLength, R as Rect, O as OffsetSpec, L as LayoutRow, c as LayoutDocument, F as FrameSpec, b as ResolvedLayoutDocument, d as ResolvedLayoutTree, a as ResolvedLayoutNode, N as NodeId, e as LayerName, S as StackAxis, A as ArrangeSpec } from './types-B90jb3RW.js';
2
- export { f as AbsoluteFrame, g as AnchorFrame, C as CellFrame, h as EdgeRef, i as FillFrame, j as FixedFrame, G as GridArrange, k as GridTrack, l as GuideFrame, m as GuideLength, n as LayoutNode, o as LayoutRowVariant, p as LayoutVariantCondition, q as RectEdge, r as RootFrame, s as StackAlign, t as StackArrange, u as StackJustify } from './types-B90jb3RW.js';
3
- export { MachinaReactDebugOverlayOptions, MachinaReactView, MachinaReactViewProps, MachinaSlotProps } from './react/index.js';
1
+ import { E as EdgeInsets, U as UiLength, a as Rect, O as OffsetSpec, L as LayoutRow, c as LayoutDocument, F as FrameSpec, R as ResolvedLayoutDocument, d as ResolvedLayoutTree, b as ResolvedLayoutNode, N as NodeId, e as LayerName, S as StackAxis, A as ArrangeSpec } from './types-CYgsjDai.js';
2
+ export { f as AbsoluteFrame, g as AnchorFrame, C as CellFrame, h as EdgeRef, i as FillFrame, j as FixedFrame, G as GridArrange, k as GridTrack, l as GuideFrame, m as GuideLength, n as LayoutNode, o as LayoutRowVariant, p as LayoutVariantCondition, q as RectEdge, r as RootFrame, s as StackAlign, t as StackArrange, u as StackJustify } from './types-CYgsjDai.js';
3
+ export { M as MachinaReactDebugOverlayOptions, a as MachinaReactView, b as MachinaReactViewProps, c as MachinaSlotProps } from './MachinaReactView-Bau5bErA.js';
4
4
  export { c as MachinaBulletItem, d as MachinaInline, e as MachinaTextAlign, f as MachinaTextBlock, g as MachinaTextDiagnostic, h as MachinaTextDiagnosticCode, i as MachinaTextDiagnosticLevel, b as MachinaTextDocument, j as MachinaTextLeading, k as MachinaTextOverflow, a as MachinaTextSource, M as MachinaTextSpec, l as MachinaTextVariant, m as MachinaTextVerticalAlign, n as MachinaTextWrap, P as ParseMachinaTextResult } from './types-C4poVJpR.js';
5
5
  export { parseMachinaText, parseMachinaTextInline } from './text/index.js';
6
6
  export { MachinaTextView, MachinaTextViewProps } from './text/react/index.js';
7
7
  export { b as MachinaScreen, c as MachinaScreenCatalog, a as MachinaScreenViewportTask, M as MachinaViewport, d as MachinaViewportMatrix, e as createViewportMatrix, f as defineMachinaScreens, g as defineMachinaViewports, h as expandScreenViewportTasks, i as getMachinaViewport, s as slugMachinaArtifactName } from './screenCatalog-ZjonGiOi.js';
8
8
  import 'react';
9
- import './debugOverlay-pJpj0n5H.js';
9
+ import './debugOverlay-fWLv1cS7.js';
10
+ import './types-CWaup8Z6.js';
10
11
 
11
12
  type MachinaLayoutErrorCode = "EmptyRows" | "MissingRoot" | "MultipleRoots" | "DuplicateId" | "InvalidId" | "MissingParent" | "UnknownParent" | "SelfParent" | "Cycle" | "UnreachableNode" | "NonFiniteNumber" | "InvalidLengthUnit" | "InvalidZ" | "InvalidVariantCondition" | "NegativeSize" | "NegativeGap" | "NegativePadding" | "InvalidAnchorHorizontal" | "InvalidAnchorVertical" | "NegativeResolvedSize" | "FixedFrameWithoutArranger" | "FillFrameWithoutArranger" | "InvalidFillWeight" | "StackChildMustBeFixed" | "StackContentNegative" | "StackOverflow" | "ExpectedStackArrange" | "StackQueryInvalidRange" | "CellFrameWithoutGrid" | "GridChildMustBeCell" | "InvalidGridTrack" | "InvalidGridCell" | "GridContentNegative" | "GridOverflow" | "RootFrameNotRoot" | "RootFrameWithoutRoot" | "IncompatibleLayouts" | "GuideTargetNotFound" | "GuideSelfReference" | "GuideReferenceCycle" | "GuideInvalidEdgeForAxis" | "GuideTooManyReferencesPerAxis" | "InvalidGuideFrame" | "GuideTargetUnresolved" | "InvalidViewport" | "DuplicateViewportKey" | "UnknownViewportKey" | "InvalidScreen" | "DuplicateScreenKey" | "UnknownScreenKey";
12
13
  declare class MachinaLayoutError extends Error {
package/dist/index.js CHANGED
@@ -8,8 +8,7 @@ import {
8
8
  } from "./chunk-33CKBEJH.js";
9
9
  import {
10
10
  MachinaReactView
11
- } from "./chunk-ZVDE7PX4.js";
12
- import "./chunk-2ZQ2RFFI.js";
11
+ } from "./chunk-MSTBFD7H.js";
13
12
  import "./chunk-RJYRJ3LD.js";
14
13
  import {
15
14
  MachinaTextView
@@ -18,12 +17,14 @@ import {
18
17
  parseMachinaText,
19
18
  parseMachinaTextInline
20
19
  } from "./chunk-BJOQRPPX.js";
20
+ import "./chunk-ZIGW44D5.js";
21
21
  import {
22
22
  toResolvedTree
23
23
  } from "./chunk-SVWYWI7I.js";
24
24
  import {
25
25
  MachinaLayoutError
26
26
  } from "./chunk-VREK57S3.js";
27
+ import "./chunk-2ZQ2RFFI.js";
27
28
 
28
29
  // src/validation.ts
29
30
  function assertFiniteNumber(value, fieldName) {
@@ -1,6 +1,6 @@
1
- import { S as SummarizeMachinaDomOptions, M as MachinaDomSummary } from '../types-DLYAhNXw.js';
2
- export { a as MachinaDomSummaryNode } from '../types-DLYAhNXw.js';
3
- import '../types-B90jb3RW.js';
1
+ import { S as SummarizeMachinaDomOptions, M as MachinaDomSummary } from '../types-bJlg6wno.js';
2
+ export { a as MachinaDomSummaryNode } from '../types-bJlg6wno.js';
3
+ import '../types-CYgsjDai.js';
4
4
 
5
5
  type DomRoot = ParentNode | Element | Document;
6
6
  declare function summarizeMachinaDom(rootOrOptions?: DomRoot | SummarizeMachinaDomOptions): MachinaDomSummary;
@@ -1,41 +1,6 @@
1
- import React from 'react';
2
- import { o as MachinaDebugOverlayMode } from '../debugOverlay-pJpj0n5H.js';
3
- import { b as ResolvedLayoutDocument, N as NodeId, R as Rect, a as ResolvedLayoutNode } from '../types-B90jb3RW.js';
4
-
5
- type MachinaSlotProps<TViewData = unknown, TNodeData = unknown> = {
6
- id: NodeId;
7
- rect: Rect;
8
- debugLabel?: string;
9
- node: ResolvedLayoutNode;
10
- viewKey?: string;
11
- viewData?: TViewData;
12
- nodeData?: TNodeData;
13
- };
14
- type MachinaRenderLayer = {
15
- z: number;
16
- };
17
- type MachinaReactDebugOverlayOptions = {
18
- mode?: MachinaDebugOverlayMode;
19
- labels?: boolean;
20
- borders?: boolean;
21
- selectedNodeId?: string;
22
- };
23
- type MachinaReactViewProps = {
24
- layout: ResolvedLayoutDocument;
25
- views?: Record<string, React.ComponentType<MachinaSlotProps>>;
26
- viewData?: Record<string, unknown>;
27
- nodeData?: Record<NodeId, unknown>;
28
- className?: string;
29
- style?: React.CSSProperties;
30
- nodeClassName?: string;
31
- debug?: boolean;
32
- nodeContainment?: "none" | "layout-paint" | "strict";
33
- nodeContentVisibility?: "none" | "auto";
34
- nodeContainIntrinsicSize?: string;
35
- layers?: Record<string, MachinaRenderLayer>;
36
- defaultLayer?: string;
37
- debugOverlay?: MachinaReactDebugOverlayOptions;
38
- };
39
- declare function MachinaReactView(props: MachinaReactViewProps): React.JSX.Element;
40
-
41
- export { type MachinaReactDebugOverlayOptions, MachinaReactView, type MachinaReactViewProps, type MachinaSlotProps };
1
+ export { U as UseDeusMachineResult, u as useDeusMachine } from '../useDeusMachine-2w2u_dki.js';
2
+ export { M as MachinaReactDebugOverlayOptions, a as MachinaReactView, b as MachinaReactViewProps, c as MachinaSlotProps } from '../MachinaReactView-Bau5bErA.js';
3
+ import '../types-CWaup8Z6.js';
4
+ import 'react';
5
+ import '../debugOverlay-fWLv1cS7.js';
6
+ import '../types-CYgsjDai.js';
@@ -1,9 +1,13 @@
1
1
  import {
2
2
  MachinaReactView
3
- } from "../chunk-ZVDE7PX4.js";
4
- import "../chunk-2ZQ2RFFI.js";
3
+ } from "../chunk-MSTBFD7H.js";
4
+ import {
5
+ useDeusMachine
6
+ } from "../chunk-ZIGW44D5.js";
5
7
  import "../chunk-SVWYWI7I.js";
6
8
  import "../chunk-VREK57S3.js";
9
+ import "../chunk-2ZQ2RFFI.js";
7
10
  export {
8
- MachinaReactView
11
+ MachinaReactView,
12
+ useDeusMachine
9
13
  };
@@ -1,6 +1,8 @@
1
+ export { U as UseDeusMachineResult, u as useDeusMachine } from '../useDeusMachine-2w2u_dki.js';
1
2
  import React from 'react';
2
3
  import { StyleProp, ViewStyle } from 'react-native';
3
- import { N as NodeId, R as Rect, a as ResolvedLayoutNode, b as ResolvedLayoutDocument } from '../types-B90jb3RW.js';
4
+ import { N as NodeId, a as Rect, b as ResolvedLayoutNode, R as ResolvedLayoutDocument } from '../types-CYgsjDai.js';
5
+ import '../types-CWaup8Z6.js';
4
6
 
5
7
  type MachinaNativeSlotProps<TViewData = unknown, TNodeData = unknown> = {
6
8
  id: NodeId;
@@ -1,7 +1,11 @@
1
+ import {
2
+ useDeusMachine
3
+ } from "../chunk-ZIGW44D5.js";
1
4
  import {
2
5
  toResolvedTree
3
6
  } from "../chunk-SVWYWI7I.js";
4
7
  import "../chunk-VREK57S3.js";
8
+ import "../chunk-2ZQ2RFFI.js";
5
9
 
6
10
  // src/react-native/MachinaReactNativeView.tsx
7
11
  import React from "react";
@@ -80,5 +84,6 @@ function MachinaReactNativeView(props) {
80
84
  );
81
85
  }
82
86
  export {
83
- MachinaReactNativeView
87
+ MachinaReactNativeView,
88
+ useDeusMachine
84
89
  };
@@ -89,37 +89,4 @@ type DeusStepResult<TBoard> = {
89
89
  trace: DeusStepTrace;
90
90
  };
91
91
 
92
- type MachinaDebugOverlayMode = "collapsed" | "nonInteractiveOverlay" | "interactivePanel";
93
- type MachinaDebugOverlayBoard = {
94
- mode: MachinaDebugOverlayMode;
95
- labels: boolean;
96
- borders: boolean;
97
- selectedNodeId?: string;
98
- };
99
- type MachinaDebugOverlayEvent = {
100
- type: "showOverlay";
101
- } | {
102
- type: "openPanel";
103
- nodeId?: string;
104
- } | {
105
- type: "collapse";
106
- } | {
107
- type: "toggleLabels";
108
- } | {
109
- type: "toggleBorders";
110
- } | {
111
- type: "selectNode";
112
- nodeId: string;
113
- };
114
- type MachinaDebugOverlayBehavior = {
115
- visible: boolean;
116
- pointerEvents: "none" | "auto";
117
- consumesLayoutSpace: boolean;
118
- showPanel: boolean;
119
- showLabels: boolean;
120
- showBorders: boolean;
121
- };
122
- declare function createMachinaDebugOverlayMachine(): DeusMachine<MachinaDebugOverlayBoard, MachinaDebugOverlayEvent>;
123
- declare function getMachinaDebugOverlayBehavior(board: MachinaDebugOverlayBoard): MachinaDebugOverlayBehavior;
124
-
125
- export { type DeusEvent as D, type JudgeUtilityOptions as J, type MachinaDebugOverlayBehavior as M, type UtilityCandidate as U, type UtilityJudgment as a, type DeusMachine as b, type DeusSnapshot as c, type DeusStatePath as d, type DeusStepTrace as e, type DeusStepResult as f, type DeusAction as g, DeusMachinaError as h, type DeusStateRow as i, type DeusTransitionRow as j, type DeusTransitionTrace as k, type DeusUtilityTransitionCandidate as l, type MachinaDebugOverlayBoard as m, type MachinaDebugOverlayEvent as n, type MachinaDebugOverlayMode as o, type UtilityCandidateResult as p, type UtilityScore as q, createMachinaDebugOverlayMachine as r, getMachinaDebugOverlayBehavior as s };
92
+ export { type DeusEvent as D, type JudgeUtilityOptions as J, type UtilityCandidate as U, type DeusSnapshot as a, type DeusStatePath as b, type DeusStepResult as c, type DeusStepTrace as d, type DeusMachine as e, type UtilityJudgment as f, type DeusAction as g, DeusMachinaError as h, type DeusStateRow as i, type DeusTransitionRow as j, type DeusTransitionTrace as k, type DeusUtilityTransitionCandidate as l, type UtilityCandidateResult as m, type UtilityScore as n };
@@ -181,4 +181,4 @@ type ResolvedLayoutTree = {
181
181
  children: ResolvedLayoutTree[];
182
182
  };
183
183
 
184
- export type { ArrangeSpec as A, CellFrame as C, EdgeInsets as E, FrameSpec as F, GridArrange as G, LayoutRow as L, NodeId as N, OffsetSpec as O, Rect as R, StackAxis as S, UiLength as U, ResolvedLayoutNode as a, ResolvedLayoutDocument as b, LayoutDocument as c, ResolvedLayoutTree as d, LayerName as e, AbsoluteFrame as f, AnchorFrame as g, EdgeRef as h, FillFrame as i, FixedFrame as j, GridTrack as k, GuideFrame as l, GuideLength as m, LayoutNode as n, LayoutRowVariant as o, LayoutVariantCondition as p, RectEdge as q, RootFrame as r, StackAlign as s, StackArrange as t, StackJustify as u };
184
+ export type { ArrangeSpec as A, CellFrame as C, EdgeInsets as E, FrameSpec as F, GridArrange as G, LayoutRow as L, NodeId as N, OffsetSpec as O, ResolvedLayoutDocument as R, StackAxis as S, UiLength as U, Rect as a, ResolvedLayoutNode as b, LayoutDocument as c, ResolvedLayoutTree as d, LayerName as e, AbsoluteFrame as f, AnchorFrame as g, EdgeRef as h, FillFrame as i, FixedFrame as j, GridTrack as k, GuideFrame as l, GuideLength as m, LayoutNode as n, LayoutRowVariant as o, LayoutVariantCondition as p, RectEdge as q, RootFrame as r, StackAlign as s, StackArrange as t, StackJustify as u };
@@ -1,4 +1,4 @@
1
- import { R as Rect } from './types-B90jb3RW.js';
1
+ import { a as Rect } from './types-CYgsjDai.js';
2
2
 
3
3
  type MachinaDomSummaryNode = {
4
4
  nodeId?: string;
@@ -0,0 +1,14 @@
1
+ import { D as DeusEvent, a as DeusSnapshot, b as DeusStatePath, c as DeusStepResult, d as DeusStepTrace, e as DeusMachine } from './types-CWaup8Z6.js';
2
+
3
+ type UseDeusMachineResult<TBoard, TEvent extends DeusEvent> = {
4
+ snapshot: DeusSnapshot<TBoard>;
5
+ board: TBoard;
6
+ state: DeusStatePath;
7
+ dispatch: (event: TEvent) => DeusStepResult<TBoard>;
8
+ lastTrace: DeusStepTrace | null;
9
+ reset: (board?: TBoard | (() => TBoard)) => void;
10
+ };
11
+ type InitialBoard<TBoard> = TBoard | (() => TBoard);
12
+ declare function useDeusMachine<TBoard, TEvent extends DeusEvent>(machine: DeusMachine<TBoard, TEvent>, initialBoard: InitialBoard<TBoard>): UseDeusMachineResult<TBoard, TEvent>;
13
+
14
+ export { type UseDeusMachineResult as U, useDeusMachine as u };
@@ -1,6 +1,18 @@
1
1
  import * as vue from 'vue';
2
- import { PropType, Component, StyleValue } from 'vue';
3
- import { N as NodeId, R as Rect, a as ResolvedLayoutNode, b as ResolvedLayoutDocument } from '../types-B90jb3RW.js';
2
+ import { Ref, ComputedRef, PropType, Component, StyleValue } from 'vue';
3
+ import { D as DeusEvent, a as DeusSnapshot, b as DeusStatePath, c as DeusStepResult, d as DeusStepTrace, e as DeusMachine } from '../types-CWaup8Z6.js';
4
+ import { N as NodeId, a as Rect, b as ResolvedLayoutNode, R as ResolvedLayoutDocument } from '../types-CYgsjDai.js';
5
+
6
+ type UseVueDeusMachineResult<TBoard, TEvent extends DeusEvent> = {
7
+ snapshot: Ref<DeusSnapshot<TBoard>>;
8
+ board: ComputedRef<TBoard>;
9
+ state: ComputedRef<DeusStatePath>;
10
+ dispatch: (event: TEvent) => DeusStepResult<TBoard>;
11
+ lastTrace: Ref<DeusStepTrace | null>;
12
+ reset: (board?: TBoard | (() => TBoard)) => void;
13
+ };
14
+ type InitialBoard<TBoard> = TBoard | (() => TBoard);
15
+ declare function useDeusMachine<TBoard, TEvent extends DeusEvent>(machine: DeusMachine<TBoard, TEvent>, initialBoard: InitialBoard<TBoard>): UseVueDeusMachineResult<TBoard, TEvent>;
4
16
 
5
17
  type MachinaVueSlotProps<TViewData = unknown, TNodeData = unknown> = {
6
18
  id: NodeId;
@@ -170,4 +182,4 @@ declare const MachinaVueView: vue.DefineComponent<vue.ExtractPropTypes<{
170
182
  nodeContainIntrinsicSize: string;
171
183
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
172
184
 
173
- export { type MachinaVueLayer, type MachinaVueSlotProps, MachinaVueView, type MachinaVueViewProps };
185
+ export { type MachinaVueLayer, type MachinaVueSlotProps, MachinaVueView, type MachinaVueViewProps, type UseVueDeusMachineResult, useDeusMachine };
package/dist/vue/index.js CHANGED
@@ -2,9 +2,42 @@ import {
2
2
  toResolvedTree
3
3
  } from "../chunk-SVWYWI7I.js";
4
4
  import "../chunk-VREK57S3.js";
5
+ import {
6
+ createDeusSnapshot,
7
+ stepDeusMachine
8
+ } from "../chunk-2ZQ2RFFI.js";
9
+
10
+ // src/vue/useDeusMachine.ts
11
+ import { computed, ref } from "vue";
12
+ function resolveInitialBoard(initialBoard) {
13
+ return typeof initialBoard === "function" ? initialBoard() : initialBoard;
14
+ }
15
+ function useDeusMachine(machine, initialBoard) {
16
+ const createSnapshot = (board) => createDeusSnapshot(machine, resolveInitialBoard(board ?? initialBoard));
17
+ const snapshot = ref(createSnapshot());
18
+ const lastTrace = ref(null);
19
+ const dispatch = (event) => {
20
+ const result = stepDeusMachine(machine, snapshot.value, event);
21
+ snapshot.value = result.snapshot;
22
+ lastTrace.value = result.trace;
23
+ return result;
24
+ };
25
+ const reset = (board) => {
26
+ snapshot.value = createSnapshot(board);
27
+ lastTrace.value = null;
28
+ };
29
+ return {
30
+ snapshot,
31
+ board: computed(() => snapshot.value.board),
32
+ state: computed(() => snapshot.value.state),
33
+ dispatch,
34
+ lastTrace,
35
+ reset
36
+ };
37
+ }
5
38
 
6
39
  // src/vue/MachinaVueView.ts
7
- import { computed, defineComponent, h } from "vue";
40
+ import { computed as computed2, defineComponent, h } from "vue";
8
41
  var normalizeLayerZ = (v) => v === void 0 || !Number.isFinite(v) || !Number.isInteger(v) || v < -5 || v > 5 ? 0 : v;
9
42
  var getEffectiveLayer = (n, d) => n.layer ?? d;
10
43
  var getEffectiveLayerZ = (n, l, d) => normalizeLayerZ(l[getEffectiveLayer(n, d)]?.z);
@@ -33,7 +66,7 @@ var MachinaVueView = defineComponent({
33
66
  nodeContainIntrinsicSize: { type: String, default: void 0 }
34
67
  },
35
68
  setup(props) {
36
- const tree = computed(() => toResolvedTree(props.layout));
69
+ const tree = computed2(() => toResolvedTree(props.layout));
37
70
  const renderNode = (node, parentRect) => {
38
71
  const viewKey = node.view ?? node.slot;
39
72
  const View = viewKey ? props.views[viewKey] : void 0;
@@ -108,5 +141,6 @@ var MachinaVueView = defineComponent({
108
141
  }
109
142
  });
110
143
  export {
111
- MachinaVueView
144
+ MachinaVueView,
145
+ useDeusMachine
112
146
  };
@@ -106,3 +106,86 @@ Labels and borders remain controlled by the board booleans; `false` stays false
106
106
  ## Non-goals
107
107
 
108
108
  DeusMachina intentionally does not include async workflows, tools, actors, persistence, LLM calls, schedulers, nested authoring syntax, uncontrolled React state, or a visual editor.
109
+
110
+ ## Framework bindings
111
+
112
+ M26b adds thin framework bindings for the DeusMachina kernel from the existing adapter subpaths:
113
+
114
+ ```ts
115
+ import { useDeusMachine } from "machinalayout/react";
116
+ import { useDeusMachine as useNativeDeusMachine } from "machinalayout/react-native";
117
+ import { useDeusMachine as useVueDeusMachine } from "machinalayout/vue";
118
+ ```
119
+
120
+ The bindings wrap `createDeusSnapshot` and `stepDeusMachine`; `machinalayout/deus` remains framework-free and does not import React, React Native, or Vue. They do not add stores, context providers, async workflows, persistence, actors, or router integration.
121
+
122
+ All bindings return the current `snapshot`, `board`, `state`, `dispatch`, `lastTrace`, and `reset`. Deus actions keep the kernel's mutable board convention: user actions may mutate the board in place, and the bindings trigger framework updates by replacing the snapshot wrapper after every dispatch. They do not deep-clone, freeze, proxy, or sandbox the board.
123
+
124
+ Define machines outside render/setup when possible. The React and React Native hooks reset the snapshot when the `machine` reference changes; the Vue composable expects a stable machine input.
125
+
126
+ `reset()` recreates the snapshot with `stepIndex: 0` and clears `lastTrace`. Pass a board value or factory to reset to that board; omit the argument to reuse the original initial board/factory.
127
+
128
+ ### React debug overlay example
129
+
130
+ ```tsx
131
+ import {
132
+ createMachinaDebugOverlayMachine,
133
+ getMachinaDebugOverlayBehavior,
134
+ type MachinaDebugOverlayBoard,
135
+ type MachinaDebugOverlayEvent,
136
+ } from "machinalayout/deus";
137
+ import { useDeusMachine } from "machinalayout/react";
138
+
139
+ const debugMachine = createMachinaDebugOverlayMachine();
140
+
141
+ function DebugControls() {
142
+ const debug = useDeusMachine<MachinaDebugOverlayBoard, MachinaDebugOverlayEvent>(debugMachine, {
143
+ mode: "collapsed",
144
+ labels: true,
145
+ borders: true,
146
+ });
147
+ const behavior = getMachinaDebugOverlayBehavior(debug.board);
148
+
149
+ return (
150
+ <>
151
+ <button onClick={() => debug.dispatch({ type: "showOverlay" })}>Overlay</button>
152
+ <button onClick={() => debug.dispatch({ type: "openPanel" })}>Panel</button>
153
+ <button onClick={() => debug.dispatch({ type: "collapse" })}>Collapse</button>
154
+ <pre>{JSON.stringify(behavior, null, 2)}</pre>
155
+ </>
156
+ );
157
+ }
158
+ ```
159
+
160
+ ### React Native debug overlay example
161
+
162
+ ```tsx
163
+ import { Button, Text, View } from "react-native";
164
+ import { createMachinaDebugOverlayMachine, getMachinaDebugOverlayBehavior } from "machinalayout/deus";
165
+ import { useDeusMachine } from "machinalayout/react-native";
166
+
167
+ const debugMachine = createMachinaDebugOverlayMachine();
168
+
169
+ function NativeDebugControls() {
170
+ const debug = useDeusMachine(debugMachine, { mode: "collapsed", labels: true, borders: true });
171
+ const behavior = getMachinaDebugOverlayBehavior(debug.board);
172
+ return (
173
+ <View>
174
+ <Button title="Overlay" onPress={() => debug.dispatch({ type: "showOverlay" })} />
175
+ <Text>{behavior.visible ? "visible" : "hidden"}</Text>
176
+ </View>
177
+ );
178
+ }
179
+ ```
180
+
181
+ ### Vue debug overlay example
182
+
183
+ ```ts
184
+ import { computed } from "vue";
185
+ import { createMachinaDebugOverlayMachine, getMachinaDebugOverlayBehavior } from "machinalayout/deus";
186
+ import { useDeusMachine } from "machinalayout/vue";
187
+
188
+ const debugMachine = createMachinaDebugOverlayMachine();
189
+ const debug = useDeusMachine(debugMachine, { mode: "collapsed", labels: true, borders: true });
190
+ const behavior = computed(() => getMachinaDebugOverlayBehavior(debug.board.value));
191
+ ```
@@ -113,3 +113,7 @@ Modes:
113
113
  - `interactivePanel`: overlay labels/borders can render with a small panel and `pointer-events: auto` for human inspection.
114
114
 
115
115
  The prop is controlled. M26 does not add React state management or hooks; DeusMachina provides the standalone behavior helpers used to derive the rendering semantics. In `nonInteractiveOverlay`, overlay artifacts use `pointer-events: none` and do not consume layout space; in `collapsed`, overlay artifacts are not rendered. Labels and borders remain controlled booleans and do not change existing `data-machina-*` attributes on node wrappers.
116
+
117
+ ## DeusMachina hook
118
+
119
+ `machinalayout/react` exports `useDeusMachine(machine, initialBoard)`. The hook is a thin wrapper around the DeusMachina kernel and returns `snapshot`, `board`, `state`, `dispatch`, `lastTrace`, and `reset`. It follows the mutable board contract: actions may mutate the board, while the hook replaces the snapshot object after dispatch so React re-renders. Keep machine definitions stable; changing the machine reference resets the hook snapshot.
@@ -54,3 +54,7 @@ Keep `views` stable (component references). Send changing values through `viewDa
54
54
  - this package only renders layout boxes; text rendering is provided separately by `machinalayout/text/react-native`
55
55
  - portals/reparenting
56
56
  - DOM-only features
57
+
58
+ ## DeusMachina hook
59
+
60
+ `machinalayout/react-native` exports the same `useDeusMachine(machine, initialBoard)` contract as the React adapter without importing the DOM adapter. It returns `snapshot`, `board`, `state`, `dispatch`, `lastTrace`, and `reset`, and re-renders by replacing the snapshot wrapper while preserving the mutable board convention.
@@ -53,3 +53,7 @@ To avoid conflicts with Vue fallthrough attrs, root/node styling props are:
53
53
  - this package only renders layout boxes; text rendering is provided separately by `machinalayout/text/vue`
54
54
  - portals/reparenting
55
55
  - router/state abstraction layers
56
+
57
+ ## DeusMachina composable
58
+
59
+ `machinalayout/vue` exports `useDeusMachine(machine, initialBoard)`. The composable returns `snapshot` and `lastTrace` refs, computed `board` and `state`, plus `dispatch` and `reset`. It wraps `createDeusSnapshot` and `stepDeusMachine`; board mutations are visible through `debug.board.value` because dispatch assigns a new snapshot object. Keep the machine input stable.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "machinalayout",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "typecheck": "tsc --noEmit",
@@ -1,9 +1,9 @@
1
- import {
2
- getMachinaDebugOverlayBehavior
3
- } from "./chunk-2ZQ2RFFI.js";
4
1
  import {
5
2
  toResolvedTree
6
3
  } from "./chunk-SVWYWI7I.js";
4
+ import {
5
+ getMachinaDebugOverlayBehavior
6
+ } from "./chunk-2ZQ2RFFI.js";
7
7
 
8
8
  // src/react/MachinaReactView.tsx
9
9
  import React from "react";