machinalayout 0.2.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.
Files changed (37) hide show
  1. package/README.md +15 -0
  2. package/dist/MachinaReactView-Bau5bErA.d.ts +41 -0
  3. package/dist/chunk-2ZQ2RFFI.js +400 -0
  4. package/dist/chunk-33CKBEJH.js +186 -0
  5. package/dist/{chunk-HU6XYOH7.js → chunk-MSTBFD7H.js} +106 -17
  6. package/dist/{chunk-TR24ERZT.js → chunk-SVWYWI7I.js} +3 -10
  7. package/dist/chunk-VREK57S3.js +13 -0
  8. package/dist/chunk-ZIGW44D5.js +63 -0
  9. package/dist/debugOverlay-fWLv1cS7.d.ts +36 -0
  10. package/dist/deus/index.d.ts +15 -0
  11. package/dist/deus/index.js +26 -0
  12. package/dist/handoff/index.d.ts +44 -0
  13. package/dist/handoff/index.js +83 -0
  14. package/dist/index.d.ts +47 -5
  15. package/dist/index.js +169 -3
  16. package/dist/inspect/index.d.ts +8 -0
  17. package/dist/inspect/index.js +97 -0
  18. package/dist/react/index.d.ts +6 -33
  19. package/dist/react/index.js +9 -3
  20. package/dist/react-native/index.d.ts +3 -1
  21. package/dist/react-native/index.js +8 -2
  22. package/dist/screenCatalog-ZjonGiOi.d.ts +46 -0
  23. package/dist/types-CWaup8Z6.d.ts +92 -0
  24. package/dist/{types-BudfpzZX.d.ts → types-CYgsjDai.d.ts} +1 -1
  25. package/dist/types-bJlg6wno.d.ts +32 -0
  26. package/dist/useDeusMachine-2w2u_dki.d.ts +14 -0
  27. package/dist/vue/index.d.ts +15 -3
  28. package/dist/vue/index.js +39 -4
  29. package/docs/deusmachina.md +191 -0
  30. package/docs/error-codes.md +11 -0
  31. package/docs/inspection-and-handoff.md +126 -0
  32. package/docs/react-adapter.md +27 -0
  33. package/docs/react-native-adapter.md +4 -0
  34. package/docs/screen-catalog-and-viewports.md +124 -0
  35. package/docs/stack-geometry-helpers.md +115 -0
  36. package/docs/vue-adapter.md +4 -0
  37. package/package.json +127 -115
package/dist/index.js CHANGED
@@ -1,6 +1,14 @@
1
+ import {
2
+ createViewportMatrix,
3
+ defineMachinaScreens,
4
+ defineMachinaViewports,
5
+ expandScreenViewportTasks,
6
+ getMachinaViewport,
7
+ slugMachinaArtifactName
8
+ } from "./chunk-33CKBEJH.js";
1
9
  import {
2
10
  MachinaReactView
3
- } from "./chunk-HU6XYOH7.js";
11
+ } from "./chunk-MSTBFD7H.js";
4
12
  import "./chunk-RJYRJ3LD.js";
5
13
  import {
6
14
  MachinaTextView
@@ -9,10 +17,14 @@ import {
9
17
  parseMachinaText,
10
18
  parseMachinaTextInline
11
19
  } from "./chunk-BJOQRPPX.js";
20
+ import "./chunk-ZIGW44D5.js";
12
21
  import {
13
- MachinaLayoutError,
14
22
  toResolvedTree
15
- } from "./chunk-TR24ERZT.js";
23
+ } from "./chunk-SVWYWI7I.js";
24
+ import {
25
+ MachinaLayoutError
26
+ } from "./chunk-VREK57S3.js";
27
+ import "./chunk-2ZQ2RFFI.js";
16
28
 
17
29
  // src/validation.ts
18
30
  function assertFiniteNumber(value, fieldName) {
@@ -947,6 +959,149 @@ function formatRect(rect) {
947
959
  return `x=${rect.x} y=${rect.y} w=${rect.width} h=${rect.height}`;
948
960
  }
949
961
 
962
+ // src/stackGeometry.ts
963
+ function copyRect(rect) {
964
+ return { x: rect.x, y: rect.y, width: rect.width, height: rect.height };
965
+ }
966
+ function applyPadding(parentRect, padding) {
967
+ return {
968
+ x: parentRect.x + padding.left,
969
+ y: parentRect.y + padding.top,
970
+ width: parentRect.width - padding.left - padding.right,
971
+ height: parentRect.height - padding.top - padding.bottom
972
+ };
973
+ }
974
+ function assertContentNonNegative(contentRect, code) {
975
+ if (contentRect.width < 0 || contentRect.height < 0) {
976
+ throw new MachinaLayoutError(
977
+ code,
978
+ `${code === "StackContentNegative" ? "stack" : "grid"} content size cannot be negative after applying padding`
979
+ );
980
+ }
981
+ }
982
+ function requireNode(layout, nodeId) {
983
+ const node = layout.nodes[nodeId];
984
+ if (!node) throw new MachinaLayoutError("InvalidId", `node id not found: ${nodeId}`);
985
+ return node;
986
+ }
987
+ function requireStackArrange(layout, parentId) {
988
+ const parent = requireNode(layout, parentId);
989
+ if (parent.arrange?.kind !== "stack") {
990
+ throw new MachinaLayoutError(
991
+ "ExpectedStackArrange",
992
+ `expected stack arrange for node: ${parentId}`
993
+ );
994
+ }
995
+ return parent.arrange;
996
+ }
997
+ function getArrangeContentRect(parentRect, arrange) {
998
+ if (!arrange) return copyRect(parentRect);
999
+ if (arrange.kind === "stack") {
1000
+ const contentRect = applyPadding(parentRect, normalizePadding(arrange.padding));
1001
+ assertContentNonNegative(contentRect, "StackContentNegative");
1002
+ return contentRect;
1003
+ }
1004
+ if (arrange.kind === "grid") {
1005
+ const contentRect = applyPadding(parentRect, normalizePadding(arrange.padding));
1006
+ assertContentNonNegative(contentRect, "GridContentNegative");
1007
+ return contentRect;
1008
+ }
1009
+ return copyRect(parentRect);
1010
+ }
1011
+ function getStackContentRect(layout, parentId) {
1012
+ const parent = requireNode(layout, parentId);
1013
+ const arrange = requireStackArrange(layout, parentId);
1014
+ return getArrangeContentRect(parent.rect, arrange);
1015
+ }
1016
+ function getStackMainAxisMetrics(layout, parentId) {
1017
+ const parent = requireNode(layout, parentId);
1018
+ const arrange = requireStackArrange(layout, parentId);
1019
+ const contentRect = getArrangeContentRect(parent.rect, arrange);
1020
+ const isHorizontal = arrange.axis === "horizontal";
1021
+ const childIds = [...layout.children[parentId] ?? []];
1022
+ const childMetrics = childIds.map((id) => {
1023
+ const child = requireNode(layout, id);
1024
+ const rect = copyRect(child.rect);
1025
+ const mainStart = isHorizontal ? rect.x - contentRect.x : rect.y - contentRect.y;
1026
+ const mainSize = isHorizontal ? rect.width : rect.height;
1027
+ const crossStart = isHorizontal ? rect.y - contentRect.y : rect.x - contentRect.x;
1028
+ const crossSize = isHorizontal ? rect.height : rect.width;
1029
+ return {
1030
+ id,
1031
+ rect,
1032
+ mainStart,
1033
+ mainEnd: mainStart + mainSize,
1034
+ mainSize,
1035
+ crossStart,
1036
+ crossEnd: crossStart + crossSize,
1037
+ crossSize,
1038
+ frameKind: child.frame.kind,
1039
+ z: child.z,
1040
+ layer: child.layer
1041
+ };
1042
+ });
1043
+ const contentMainSize = isHorizontal ? contentRect.width : contentRect.height;
1044
+ const contentCrossSize = isHorizontal ? contentRect.height : contentRect.width;
1045
+ const totalChildMainSize = childMetrics.reduce((sum, metric) => sum + metric.mainSize, 0);
1046
+ const totalGapSize = (arrange.gap ?? 0) * Math.max(0, childMetrics.length - 1);
1047
+ const usedMainSize = totalChildMainSize + totalGapSize;
1048
+ return {
1049
+ parentId,
1050
+ axis: arrange.axis,
1051
+ parentRect: copyRect(parent.rect),
1052
+ contentRect,
1053
+ padding: normalizePadding(arrange.padding),
1054
+ gap: arrange.gap ?? 0,
1055
+ childIds,
1056
+ childMetrics,
1057
+ contentMainSize,
1058
+ contentCrossSize,
1059
+ totalChildMainSize,
1060
+ totalGapSize,
1061
+ usedMainSize,
1062
+ unusedMainSize: contentMainSize - usedMainSize
1063
+ };
1064
+ }
1065
+ function getStackChildRects(layout, parentId) {
1066
+ requireStackArrange(layout, parentId);
1067
+ const rects = {};
1068
+ for (const childId of layout.children[parentId] ?? []) {
1069
+ rects[childId] = copyRect(requireNode(layout, childId).rect);
1070
+ }
1071
+ return rects;
1072
+ }
1073
+ function getRemainingStackRect(layout, options) {
1074
+ const metrics = getStackMainAxisMetrics(layout, options.parentId);
1075
+ const byId = new Map(metrics.childMetrics.map((metric) => [metric.id, metric]));
1076
+ const after = options.afterChildren ?? [];
1077
+ const before = options.beforeChildren ?? [];
1078
+ const start = after.length === 0 ? 0 : Math.max(...after.map((id) => requireStackMetric(byId, id).mainEnd));
1079
+ const end = before.length === 0 ? metrics.contentMainSize : Math.min(...before.map((id) => requireStackMetric(byId, id).mainStart));
1080
+ const size = end - start;
1081
+ if (size < 0) {
1082
+ throw new MachinaLayoutError(
1083
+ "StackQueryInvalidRange",
1084
+ `remaining stack interval is negative for parent: ${options.parentId}`
1085
+ );
1086
+ }
1087
+ return metrics.axis === "horizontal" ? {
1088
+ x: metrics.contentRect.x + start,
1089
+ y: metrics.contentRect.y,
1090
+ width: size,
1091
+ height: metrics.contentRect.height
1092
+ } : {
1093
+ x: metrics.contentRect.x,
1094
+ y: metrics.contentRect.y + start,
1095
+ width: metrics.contentRect.width,
1096
+ height: size
1097
+ };
1098
+ }
1099
+ function requireStackMetric(metrics, childId) {
1100
+ const metric = metrics.get(childId);
1101
+ if (!metric) throw new MachinaLayoutError("InvalidId", `stack child id not found: ${childId}`);
1102
+ return metric;
1103
+ }
1104
+
950
1105
  // src/lerp.ts
951
1106
  function assertFiniteNumber2(value) {
952
1107
  if (!Number.isFinite(value)) {
@@ -1056,8 +1211,18 @@ export {
1056
1211
  assertNonNegativePadding,
1057
1212
  assertNonNegativeSize,
1058
1213
  compileLayoutRows,
1214
+ createViewportMatrix,
1215
+ defineMachinaScreens,
1216
+ defineMachinaViewports,
1217
+ expandScreenViewportTasks,
1059
1218
  flattenResolvedTree,
1060
1219
  formatRect,
1220
+ getArrangeContentRect,
1221
+ getMachinaViewport,
1222
+ getRemainingStackRect,
1223
+ getStackChildRects,
1224
+ getStackContentRect,
1225
+ getStackMainAxisMetrics,
1061
1226
  lerpNumber,
1062
1227
  lerpRect,
1063
1228
  lerpResolvedLayouts,
@@ -1069,5 +1234,6 @@ export {
1069
1234
  resolveLayoutRows,
1070
1235
  resolveUiLength,
1071
1236
  selectLayoutRowsForRoot,
1237
+ slugMachinaArtifactName,
1072
1238
  toResolvedTree
1073
1239
  };
@@ -0,0 +1,8 @@
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
+
5
+ type DomRoot = ParentNode | Element | Document;
6
+ declare function summarizeMachinaDom(rootOrOptions?: DomRoot | SummarizeMachinaDomOptions): MachinaDomSummary;
7
+
8
+ export { MachinaDomSummary, SummarizeMachinaDomOptions, summarizeMachinaDom };
@@ -0,0 +1,97 @@
1
+ // src/inspect/summarizeMachinaDom.ts
2
+ var DEFAULT_SELECTOR = "[data-machina-node-id]";
3
+ var DEFAULT_MAX_TEXT_LENGTH = 120;
4
+ function getGlobalDocument() {
5
+ return typeof document === "undefined" ? void 0 : document;
6
+ }
7
+ function isOptions(value) {
8
+ if (value === void 0 || value === null || typeof value !== "object") return false;
9
+ return "root" in value || "selector" in value || "includeTextExcerpt" in value || "includeA11y" in value || "generatedAt" in value || "maxTextLength" in value || "includeEmptyNodes" in value;
10
+ }
11
+ function readOptionalAttribute(element, name) {
12
+ const value = element.getAttribute(name);
13
+ return value === null || value === "" ? void 0 : value;
14
+ }
15
+ function rectFromElement(element) {
16
+ const rect = element.getBoundingClientRect();
17
+ return { x: rect.x, y: rect.y, width: rect.width, height: rect.height };
18
+ }
19
+ function textExcerpt(element, maxLength) {
20
+ const normalized = (element.textContent ?? "").replace(/\s+/g, " ").trim();
21
+ if (normalized === "") return void 0;
22
+ return normalized.length > maxLength ? normalized.slice(0, maxLength) : normalized;
23
+ }
24
+ function canMatchRoot(root) {
25
+ return typeof root.matches === "function";
26
+ }
27
+ function queryMatchingElements(root, selector) {
28
+ const matches = Array.from(root.querySelectorAll(selector));
29
+ if (canMatchRoot(root) && root.matches(selector)) return [root, ...matches];
30
+ return matches;
31
+ }
32
+ function nearestMatchingAncestor(element, selected, root) {
33
+ let parent = element.parentElement;
34
+ while (parent) {
35
+ if (selected.has(parent)) return parent;
36
+ if (parent === root) return void 0;
37
+ parent = parent.parentElement;
38
+ }
39
+ return void 0;
40
+ }
41
+ function makeSummaryNode(element, options) {
42
+ const node = {
43
+ tagName: element.tagName.toLowerCase(),
44
+ rect: rectFromElement(element),
45
+ children: []
46
+ };
47
+ const nodeId = readOptionalAttribute(element, "data-machina-node-id");
48
+ const view = readOptionalAttribute(element, "data-machina-view");
49
+ const slot = readOptionalAttribute(element, "data-machina-slot");
50
+ const debugLabel = readOptionalAttribute(element, "data-machina-debug-label");
51
+ const layer = readOptionalAttribute(element, "data-machina-layer");
52
+ if (nodeId !== void 0) node.nodeId = nodeId;
53
+ if (view !== void 0) node.view = view;
54
+ if (slot !== void 0) node.slot = slot;
55
+ if (debugLabel !== void 0) node.debugLabel = debugLabel;
56
+ if (layer !== void 0) node.layer = layer;
57
+ if (options.includeA11y) {
58
+ const role = readOptionalAttribute(element, "role");
59
+ const ariaLabel = readOptionalAttribute(element, "aria-label");
60
+ if (role !== void 0) node.role = role;
61
+ if (ariaLabel !== void 0) node.ariaLabel = ariaLabel;
62
+ }
63
+ if (options.includeTextExcerpt) {
64
+ const excerpt = textExcerpt(element, options.maxTextLength);
65
+ if (excerpt !== void 0) node.textExcerpt = excerpt;
66
+ }
67
+ return node;
68
+ }
69
+ function summarizeMachinaDom(rootOrOptions) {
70
+ const options = isOptions(rootOrOptions) ? rootOrOptions : { root: rootOrOptions };
71
+ const selector = options.selector ?? DEFAULT_SELECTOR;
72
+ const root = options.root ?? getGlobalDocument();
73
+ const summary = { schemaVersion: 1, rootSelector: selector, nodes: [] };
74
+ if (options.generatedAt !== void 0) summary.generatedAt = options.generatedAt;
75
+ if (root === void 0 || typeof root.querySelectorAll !== "function") return summary;
76
+ const elements = queryMatchingElements(root, selector);
77
+ const selected = new Set(elements);
78
+ const nodeByElement = /* @__PURE__ */ new Map();
79
+ const nodeOptions = {
80
+ includeTextExcerpt: options.includeTextExcerpt ?? false,
81
+ includeA11y: options.includeA11y ?? false,
82
+ maxTextLength: options.maxTextLength ?? DEFAULT_MAX_TEXT_LENGTH
83
+ };
84
+ for (const element of elements) nodeByElement.set(element, makeSummaryNode(element, nodeOptions));
85
+ for (const element of elements) {
86
+ const node = nodeByElement.get(element);
87
+ if (!node) continue;
88
+ const parent = nearestMatchingAncestor(element, selected, root);
89
+ const parentNode = parent === void 0 ? void 0 : nodeByElement.get(parent);
90
+ if (parentNode) parentNode.children.push(node);
91
+ else summary.nodes.push(node);
92
+ }
93
+ return summary;
94
+ }
95
+ export {
96
+ summarizeMachinaDom
97
+ };
@@ -1,33 +1,6 @@
1
- import React from 'react';
2
- import { b as ResolvedLayoutDocument, N as NodeId, R as Rect, a as ResolvedLayoutNode } from '../types-BudfpzZX.js';
3
-
4
- type MachinaSlotProps<TViewData = unknown, TNodeData = unknown> = {
5
- id: NodeId;
6
- rect: Rect;
7
- debugLabel?: string;
8
- node: ResolvedLayoutNode;
9
- viewKey?: string;
10
- viewData?: TViewData;
11
- nodeData?: TNodeData;
12
- };
13
- type MachinaRenderLayer = {
14
- z: number;
15
- };
16
- type MachinaReactViewProps = {
17
- layout: ResolvedLayoutDocument;
18
- views?: Record<string, React.ComponentType<MachinaSlotProps>>;
19
- viewData?: Record<string, unknown>;
20
- nodeData?: Record<NodeId, unknown>;
21
- className?: string;
22
- style?: React.CSSProperties;
23
- nodeClassName?: string;
24
- debug?: boolean;
25
- nodeContainment?: "none" | "layout-paint" | "strict";
26
- nodeContentVisibility?: "none" | "auto";
27
- nodeContainIntrinsicSize?: string;
28
- layers?: Record<string, MachinaRenderLayer>;
29
- defaultLayer?: string;
30
- };
31
- declare function MachinaReactView(props: MachinaReactViewProps): React.JSX.Element;
32
-
33
- export { 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,7 +1,13 @@
1
1
  import {
2
2
  MachinaReactView
3
- } from "../chunk-HU6XYOH7.js";
4
- import "../chunk-TR24ERZT.js";
3
+ } from "../chunk-MSTBFD7H.js";
4
+ import {
5
+ useDeusMachine
6
+ } from "../chunk-ZIGW44D5.js";
7
+ import "../chunk-SVWYWI7I.js";
8
+ import "../chunk-VREK57S3.js";
9
+ import "../chunk-2ZQ2RFFI.js";
5
10
  export {
6
- MachinaReactView
11
+ MachinaReactView,
12
+ useDeusMachine
7
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-BudfpzZX.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,6 +1,11 @@
1
+ import {
2
+ useDeusMachine
3
+ } from "../chunk-ZIGW44D5.js";
1
4
  import {
2
5
  toResolvedTree
3
- } from "../chunk-TR24ERZT.js";
6
+ } from "../chunk-SVWYWI7I.js";
7
+ import "../chunk-VREK57S3.js";
8
+ import "../chunk-2ZQ2RFFI.js";
4
9
 
5
10
  // src/react-native/MachinaReactNativeView.tsx
6
11
  import React from "react";
@@ -79,5 +84,6 @@ function MachinaReactNativeView(props) {
79
84
  );
80
85
  }
81
86
  export {
82
- MachinaReactNativeView
87
+ MachinaReactNativeView,
88
+ useDeusMachine
83
89
  };
@@ -0,0 +1,46 @@
1
+ type MachinaViewport = {
2
+ key: string;
3
+ width: number;
4
+ height: number;
5
+ deviceScaleFactor?: number;
6
+ label?: string;
7
+ tags?: readonly string[];
8
+ };
9
+ type MachinaViewportMatrix = readonly MachinaViewport[];
10
+ type MachinaScreen = {
11
+ key: string;
12
+ route: string;
13
+ fixture?: string;
14
+ viewports?: readonly string[];
15
+ tags?: readonly string[];
16
+ title?: string;
17
+ metadata?: Record<string, unknown>;
18
+ };
19
+ type MachinaScreenCatalog = {
20
+ screens: Record<string, MachinaScreen>;
21
+ order: string[];
22
+ };
23
+ type MachinaScreenViewportTask = {
24
+ key: string;
25
+ screenKey: string;
26
+ viewportKey: string;
27
+ route: string;
28
+ fixture?: string;
29
+ viewport: MachinaViewport;
30
+ screen: MachinaScreen;
31
+ tags: readonly string[];
32
+ artifactBaseName: string;
33
+ };
34
+ type ExpandOptions = {
35
+ screenKeys?: readonly string[];
36
+ viewportKeys?: readonly string[];
37
+ tags?: readonly string[];
38
+ };
39
+ declare function defineMachinaViewports(viewports: readonly MachinaViewport[]): MachinaViewportMatrix;
40
+ declare function createViewportMatrix(preset?: "standard-responsive" | "desktop-only" | "mobile-first"): MachinaViewportMatrix;
41
+ declare function defineMachinaScreens(screens: readonly MachinaScreen[]): MachinaScreenCatalog;
42
+ declare function slugMachinaArtifactName(input: string): string;
43
+ declare function getMachinaViewport(viewports: MachinaViewportMatrix, key: string): MachinaViewport;
44
+ declare function expandScreenViewportTasks(catalog: MachinaScreenCatalog, viewports: MachinaViewportMatrix, options?: ExpandOptions): MachinaScreenViewportTask[];
45
+
46
+ export { type MachinaViewport as M, type MachinaScreenViewportTask as a, type MachinaScreen as b, type MachinaScreenCatalog as c, type MachinaViewportMatrix as d, createViewportMatrix as e, defineMachinaScreens as f, defineMachinaViewports as g, expandScreenViewportTasks as h, getMachinaViewport as i, slugMachinaArtifactName as s };
@@ -0,0 +1,92 @@
1
+ declare class DeusMachinaError extends Error {
2
+ readonly code: string;
3
+ constructor(code: string, message: string);
4
+ }
5
+ type UtilityScore<TContext> = number | ((context: TContext) => number);
6
+ type UtilityCandidate<TContext, TKey extends string = string> = {
7
+ key: TKey;
8
+ when?: (context: TContext) => boolean;
9
+ score: UtilityScore<TContext>;
10
+ reason?: string | ((context: TContext) => string);
11
+ };
12
+ type UtilityCandidateResult<TKey extends string = string> = {
13
+ key: TKey;
14
+ eligible: boolean;
15
+ score: number;
16
+ index: number;
17
+ reason?: string;
18
+ };
19
+ type UtilityJudgment<TKey extends string = string> = {
20
+ selected: UtilityCandidateResult<TKey> | null;
21
+ candidates: UtilityCandidateResult<TKey>[];
22
+ };
23
+ type JudgeUtilityOptions<TKey extends string = string> = {
24
+ previousKey?: TKey;
25
+ hysteresis?: number;
26
+ };
27
+ type DeusStatePath = readonly string[];
28
+ type DeusEvent = {
29
+ type: string;
30
+ };
31
+ type DeusAction<TBoard, TEvent extends DeusEvent> = (board: TBoard, event: TEvent) => void;
32
+ type DeusStateRow<TBoard, TEvent extends DeusEvent> = {
33
+ path: DeusStatePath;
34
+ onEnter?: DeusAction<TBoard, TEvent>;
35
+ onExit?: DeusAction<TBoard, TEvent>;
36
+ };
37
+ type DeusUtilityTransitionCandidate<TBoard, TEvent extends DeusEvent, TKey extends string = string> = {
38
+ key: TKey;
39
+ when?: (board: TBoard, event: TEvent) => boolean;
40
+ score: number | ((board: TBoard, event: TEvent) => number);
41
+ do?: DeusAction<TBoard, TEvent>;
42
+ reason?: string | ((board: TBoard, event: TEvent) => string);
43
+ };
44
+ type DeusTransitionRow<TBoard, TEvent extends DeusEvent> = {
45
+ key: string;
46
+ from: DeusStatePath;
47
+ event?: TEvent["type"];
48
+ to?: DeusStatePath | ((board: TBoard, event: TEvent) => DeusStatePath);
49
+ when?: (board: TBoard, event: TEvent) => boolean;
50
+ score?: number | ((board: TBoard, event: TEvent) => number);
51
+ do?: DeusAction<TBoard, TEvent>;
52
+ reason?: string | ((board: TBoard, event: TEvent) => string);
53
+ utility?: readonly DeusUtilityTransitionCandidate<TBoard, TEvent>[];
54
+ hysteresis?: {
55
+ previous: (board: TBoard) => string | undefined;
56
+ margin: number;
57
+ };
58
+ };
59
+ type DeusMachine<TBoard, TEvent extends DeusEvent> = {
60
+ initial: DeusStatePath;
61
+ states: readonly DeusStateRow<TBoard, TEvent>[];
62
+ transitions: readonly DeusTransitionRow<TBoard, TEvent>[];
63
+ };
64
+ type DeusSnapshot<TBoard> = {
65
+ state: DeusStatePath;
66
+ board: TBoard;
67
+ stepIndex: number;
68
+ };
69
+ type DeusTransitionTrace = {
70
+ key: string;
71
+ from: DeusStatePath;
72
+ to?: DeusStatePath;
73
+ event?: string;
74
+ eligible: boolean;
75
+ score: number;
76
+ index: number;
77
+ reason?: string;
78
+ utility?: UtilityJudgment<string>;
79
+ };
80
+ type DeusStepTrace = {
81
+ stateBefore: DeusStatePath;
82
+ stateAfter: DeusStatePath;
83
+ event: string;
84
+ selectedTransition?: DeusTransitionTrace;
85
+ transitions: DeusTransitionTrace[];
86
+ };
87
+ type DeusStepResult<TBoard> = {
88
+ snapshot: DeusSnapshot<TBoard>;
89
+ trace: DeusStepTrace;
90
+ };
91
+
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 { AbsoluteFrame 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, StackAlign as S, UiLength as U, ResolvedLayoutNode as a, ResolvedLayoutDocument as b, LayoutDocument as c, ResolvedLayoutTree as d, AnchorFrame as e, ArrangeSpec as f, EdgeRef as g, FillFrame as h, FixedFrame as i, GridTrack as j, GuideFrame as k, GuideLength as l, LayerName as m, LayoutNode as n, LayoutRowVariant as o, LayoutVariantCondition as p, RectEdge as q, RootFrame as r, StackArrange as s, StackAxis 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 };
@@ -0,0 +1,32 @@
1
+ import { a as Rect } from './types-CYgsjDai.js';
2
+
3
+ type MachinaDomSummaryNode = {
4
+ nodeId?: string;
5
+ view?: string;
6
+ slot?: string;
7
+ debugLabel?: string;
8
+ layer?: string;
9
+ tagName: string;
10
+ role?: string;
11
+ ariaLabel?: string;
12
+ textExcerpt?: string;
13
+ rect: Rect;
14
+ children: MachinaDomSummaryNode[];
15
+ };
16
+ type MachinaDomSummary = {
17
+ schemaVersion: 1;
18
+ rootSelector?: string;
19
+ generatedAt?: string;
20
+ nodes: MachinaDomSummaryNode[];
21
+ };
22
+ type SummarizeMachinaDomOptions = {
23
+ root?: ParentNode | Element | Document;
24
+ selector?: string;
25
+ includeTextExcerpt?: boolean;
26
+ includeA11y?: boolean;
27
+ maxTextLength?: number;
28
+ includeEmptyNodes?: boolean;
29
+ generatedAt?: string;
30
+ };
31
+
32
+ export type { MachinaDomSummary as M, SummarizeMachinaDomOptions as S, MachinaDomSummaryNode as a };
@@ -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-BudfpzZX.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 };