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
@@ -0,0 +1,115 @@
1
+ # Stack geometry helpers
2
+
3
+ MachinaLayout stack geometry helpers are pure query utilities for resolved layout documents. They make common stack arithmetic inspectable without introducing new layout primitives or changing resolver behavior.
4
+
5
+ ## Why these helpers exist
6
+
7
+ Apps with fixed chrome, content panes, sidebars, and inspectors often need to ask questions like:
8
+
9
+ - What rectangle is left after stack padding?
10
+ - How much of a stack main axis is consumed by direct children and gaps?
11
+ - Where is the interval between a header-like child and an inspector-like child?
12
+
13
+ The resolver already computes deterministic rectangles. These helpers expose that resolved state so humans and LLMs do not have to hand-copy padding, gap, and fixed/fill calculations.
14
+
15
+ ## Resolved-document query boundary
16
+
17
+ These helpers inspect existing rectangles. They do not:
18
+
19
+ - mutate the resolved layout document,
20
+ - recompute layout from `LayoutRow[]`,
21
+ - account for DOM measurements,
22
+ - inspect descendants when a helper is scoped to direct stack children,
23
+ - change `StackArrange` or `GridArrange` semantics.
24
+
25
+ They report resolved state, including resolved fill allocations, rather than pre-resolution authoring guesses.
26
+
27
+ ## `getArrangeContentRect(parentRect, arrange)`
28
+
29
+ `getArrangeContentRect` returns a fresh content rectangle for an arranger:
30
+
31
+ - `stack`: subtracts normalized stack padding and throws `StackContentNegative` if padding makes content negative.
32
+ - `grid`: subtracts normalized grid padding and throws `GridContentNegative` if padding makes content negative.
33
+ - omitted or unsupported arranger: returns a fresh copy of the parent rectangle.
34
+
35
+ ```ts
36
+ const contentRect = getArrangeContentRect(parent.rect, parent.arrange);
37
+ ```
38
+
39
+ ## `getStackContentRect(layout, parentId)`
40
+
41
+ `getStackContentRect` looks up a resolved stack parent and returns its content rectangle after stack padding.
42
+
43
+ ```ts
44
+ const content = getStackContentRect(layout, "scheduling-content");
45
+ ```
46
+
47
+ The parent must exist and must have `arrange.kind === "stack"`. A non-stack parent throws `ExpectedStackArrange`.
48
+
49
+ ## `getStackMainAxisMetrics(layout, parentId)`
50
+
51
+ `getStackMainAxisMetrics` returns main-axis and cross-axis data for a resolved stack parent:
52
+
53
+ - parent and content rectangles,
54
+ - normalized padding and gap,
55
+ - direct child ids in resolved child order,
56
+ - per-child rectangles and main/cross starts, ends, and sizes relative to the content rectangle,
57
+ - content main/cross sizes,
58
+ - total child main size,
59
+ - total gap size,
60
+ - used main size,
61
+ - unused main size.
62
+
63
+ Because the input is a resolved document, fill children are reported at their actual resolved sizes.
64
+
65
+ ```ts
66
+ const metrics = getStackMainAxisMetrics(layout, "root");
67
+ const remaining = metrics.unusedMainSize;
68
+ ```
69
+
70
+ ## `getStackChildRects(layout, parentId)`
71
+
72
+ `getStackChildRects` returns fresh direct-child rectangle copies keyed by child id.
73
+
74
+ ```ts
75
+ const childRects = getStackChildRects(layout, "root");
76
+ const sidebar = childRects.sidebar;
77
+ ```
78
+
79
+ Only direct stack children are returned. Descendant rectangles should be queried from `layout.nodes` or from a helper scoped to their own parent.
80
+
81
+ ## `getRemainingStackRect(layout, options)`
82
+
83
+ `getRemainingStackRect` is a narrow interval query over direct children of one resolved stack parent.
84
+
85
+ It computes the interval between:
86
+
87
+ - the latest `mainEnd` among `afterChildren`, or the content start when no `afterChildren` are provided, and
88
+ - the earliest `mainStart` among `beforeChildren`, or the content end when no `beforeChildren` are provided.
89
+
90
+ The returned rectangle preserves the full content cross-axis size.
91
+
92
+ ```ts
93
+ const shellContent = getRemainingStackRect(layout, {
94
+ parentId: "root",
95
+ afterChildren: ["hero"],
96
+ beforeChildren: ["inspector"],
97
+ });
98
+ ```
99
+
100
+ If the computed interval is negative, the helper throws `StackQueryInvalidRange`. This helper is a query helper, not a solver; it does not move children or search descendants.
101
+
102
+ ## Inspector/content shell example
103
+
104
+ ```ts
105
+ const metrics = getStackMainAxisMetrics(layout, "root");
106
+ const content = getStackContentRect(layout, "scheduling-content");
107
+
108
+ const interactiveRegion = getRemainingStackRect(layout, {
109
+ parentId: "root",
110
+ afterChildren: ["toolbar"],
111
+ beforeChildren: ["inspector"],
112
+ });
113
+ ```
114
+
115
+ This pattern is useful for app shells that place fixed controls around an interactive content region while still keeping all geometry framework-independent.
@@ -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,115 +1,127 @@
1
- {
2
- "name": "machinalayout",
3
- "version": "0.2.0",
4
- "type": "module",
5
- "scripts": {
6
- "typecheck": "tsc --noEmit",
7
- "build": "npm run typecheck && tsup --config tsup.config.ts --tsconfig tsconfig.build.json",
8
- "test": "vitest run",
9
- "format": "biome format --write .",
10
- "format:check": "biome format .",
11
- "lint": "biome lint .",
12
- "check": "biome check ."
13
- },
14
- "devDependencies": {
15
- "@biomejs/biome": "^2.4.15",
16
- "@testing-library/jest-dom": "^6.9.1",
17
- "@testing-library/react": "^16.3.2",
18
- "@types/react": "^19.2.14",
19
- "@types/react-dom": "^19.2.3",
20
- "@types/react-test-renderer": "^19.1.0",
21
- "@vue/test-utils": "^2.4.6",
22
- "jsdom": "^29.1.1",
23
- "react": "^19.2.6",
24
- "react-dom": "^19.2.6",
25
- "react-native": "^0.82.0",
26
- "react-test-renderer": "^19.2.6",
27
- "tsup": "^8.5.1",
28
- "typescript": "^5.6.3",
29
- "vitest": "^2.1.8",
30
- "vue": "^3.5.22"
31
- },
32
- "peerDependencies": {
33
- "react": ">=18 <20",
34
- "react-dom": ">=18 <20",
35
- "react-native": ">=0.72 <1",
36
- "vue": ">=3.4 <4"
37
- },
38
- "description": "Machine-native layout and text primitives for deterministic app UI records.",
39
- "license": "MIT",
40
- "author": "MachinaLayout contributors",
41
- "repository": {
42
- "type": "git",
43
- "url": "https://github.com/machinalayout/MachinaLayout.JS.git"
44
- },
45
- "homepage": "https://github.com/machinalayout/MachinaLayout.JS#readme",
46
- "bugs": {
47
- "url": "https://github.com/machinalayout/MachinaLayout.JS/issues"
48
- },
49
- "keywords": [
50
- "layout",
51
- "ui",
52
- "react",
53
- "typescript",
54
- "machina",
55
- "text",
56
- "rectangles"
57
- ],
58
- "main": "./dist/index.js",
59
- "module": "./dist/index.js",
60
- "types": "./dist/index.d.ts",
61
- "exports": {
62
- ".": {
63
- "types": "./dist/index.d.ts",
64
- "import": "./dist/index.js"
65
- },
66
- "./react": {
67
- "types": "./dist/react/index.d.ts",
68
- "import": "./dist/react/index.js"
69
- },
70
- "./text": {
71
- "types": "./dist/text/index.d.ts",
72
- "import": "./dist/text/index.js"
73
- },
74
- "./text/react": {
75
- "types": "./dist/text/react/index.d.ts",
76
- "import": "./dist/text/react/index.js"
77
- },
78
- "./package.json": "./package.json",
79
- "./react-native": {
80
- "types": "./dist/react-native/index.d.ts",
81
- "import": "./dist/react-native/index.js"
82
- },
83
- "./vue": {
84
- "types": "./dist/vue/index.d.ts",
85
- "import": "./dist/vue/index.js"
86
- },
87
- "./text/react-native": {
88
- "types": "./dist/text/react-native/index.d.ts",
89
- "import": "./dist/text/react-native/index.js"
90
- },
91
- "./text/vue": {
92
- "types": "./dist/text/vue/index.d.ts",
93
- "import": "./dist/text/vue/index.js"
94
- },
95
- "./dispatch": {
96
- "types": "./dist/dispatch/index.d.ts",
97
- "import": "./dist/dispatch/index.js"
98
- }
99
- },
100
- "files": [
101
- "dist",
102
- "README.md",
103
- "LICENSE",
104
- "docs"
105
- ],
106
- "sideEffects": false,
107
- "peerDependenciesMeta": {
108
- "react-native": {
109
- "optional": true
110
- },
111
- "vue": {
112
- "optional": true
113
- }
114
- }
115
- }
1
+ {
2
+ "name": "machinalayout",
3
+ "version": "0.3.1",
4
+ "type": "module",
5
+ "scripts": {
6
+ "typecheck": "tsc --noEmit",
7
+ "build": "npm run typecheck && tsup --config tsup.config.ts --tsconfig tsconfig.build.json",
8
+ "test": "vitest run",
9
+ "format": "biome format --write .",
10
+ "format:check": "biome format .",
11
+ "lint": "biome lint .",
12
+ "check": "biome check ."
13
+ },
14
+ "devDependencies": {
15
+ "@biomejs/biome": "^2.4.15",
16
+ "@testing-library/jest-dom": "^6.9.1",
17
+ "@testing-library/react": "^16.3.2",
18
+ "@types/react": "^19.2.14",
19
+ "@types/react-dom": "^19.2.3",
20
+ "@types/react-test-renderer": "^19.1.0",
21
+ "@vue/test-utils": "^2.4.6",
22
+ "jsdom": "^29.1.1",
23
+ "react": "^19.2.6",
24
+ "react-dom": "^19.2.6",
25
+ "react-native": "^0.82.0",
26
+ "react-test-renderer": "^19.2.6",
27
+ "tsup": "^8.5.1",
28
+ "typescript": "^5.6.3",
29
+ "vitest": "^2.1.8",
30
+ "vue": "^3.5.22"
31
+ },
32
+ "peerDependencies": {
33
+ "react": ">=18 <20",
34
+ "react-dom": ">=18 <20",
35
+ "react-native": ">=0.72 <1",
36
+ "vue": ">=3.4 <4"
37
+ },
38
+ "description": "Machine-native layout and text primitives for deterministic app UI records.",
39
+ "license": "MIT",
40
+ "author": "MachinaLayout contributors",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "https://github.com/machinalayout/MachinaLayout.JS.git"
44
+ },
45
+ "homepage": "https://github.com/machinalayout/MachinaLayout.JS#readme",
46
+ "bugs": {
47
+ "url": "https://github.com/machinalayout/MachinaLayout.JS/issues"
48
+ },
49
+ "keywords": [
50
+ "layout",
51
+ "ui",
52
+ "react",
53
+ "typescript",
54
+ "machina",
55
+ "text",
56
+ "rectangles"
57
+ ],
58
+ "main": "./dist/index.js",
59
+ "module": "./dist/index.js",
60
+ "types": "./dist/index.d.ts",
61
+ "exports": {
62
+ ".": {
63
+ "types": "./dist/index.d.ts",
64
+ "import": "./dist/index.js"
65
+ },
66
+ "./inspect": {
67
+ "types": "./dist/inspect/index.d.ts",
68
+ "import": "./dist/inspect/index.js"
69
+ },
70
+ "./handoff": {
71
+ "types": "./dist/handoff/index.d.ts",
72
+ "import": "./dist/handoff/index.js"
73
+ },
74
+ "./deus": {
75
+ "types": "./dist/deus/index.d.ts",
76
+ "import": "./dist/deus/index.js"
77
+ },
78
+ "./react": {
79
+ "types": "./dist/react/index.d.ts",
80
+ "import": "./dist/react/index.js"
81
+ },
82
+ "./text": {
83
+ "types": "./dist/text/index.d.ts",
84
+ "import": "./dist/text/index.js"
85
+ },
86
+ "./text/react": {
87
+ "types": "./dist/text/react/index.d.ts",
88
+ "import": "./dist/text/react/index.js"
89
+ },
90
+ "./package.json": "./package.json",
91
+ "./react-native": {
92
+ "types": "./dist/react-native/index.d.ts",
93
+ "import": "./dist/react-native/index.js"
94
+ },
95
+ "./vue": {
96
+ "types": "./dist/vue/index.d.ts",
97
+ "import": "./dist/vue/index.js"
98
+ },
99
+ "./text/react-native": {
100
+ "types": "./dist/text/react-native/index.d.ts",
101
+ "import": "./dist/text/react-native/index.js"
102
+ },
103
+ "./text/vue": {
104
+ "types": "./dist/text/vue/index.d.ts",
105
+ "import": "./dist/text/vue/index.js"
106
+ },
107
+ "./dispatch": {
108
+ "types": "./dist/dispatch/index.d.ts",
109
+ "import": "./dist/dispatch/index.js"
110
+ }
111
+ },
112
+ "files": [
113
+ "dist",
114
+ "README.md",
115
+ "LICENSE",
116
+ "docs"
117
+ ],
118
+ "sideEffects": false,
119
+ "peerDependenciesMeta": {
120
+ "react-native": {
121
+ "optional": true
122
+ },
123
+ "vue": {
124
+ "optional": true
125
+ }
126
+ }
127
+ }