machinalayout 0.1.0 → 0.2.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 (45) hide show
  1. package/README.md +280 -49
  2. package/dist/chunk-BJOQRPPX.js +382 -0
  3. package/dist/chunk-HU6XYOH7.js +133 -0
  4. package/dist/chunk-KYWOCAHK.js +205 -0
  5. package/dist/chunk-RJYRJ3LD.js +0 -0
  6. package/dist/chunk-TR24ERZT.js +66 -0
  7. package/dist/dispatch/index.d.ts +49 -0
  8. package/dist/dispatch/index.js +217 -0
  9. package/dist/index.d.ts +15 -238
  10. package/dist/index.js +596 -591
  11. package/dist/react/index.d.ts +33 -0
  12. package/dist/react/index.js +7 -0
  13. package/dist/react-native/index.d.ts +30 -0
  14. package/dist/react-native/index.js +83 -0
  15. package/dist/text/index.d.ts +10 -0
  16. package/dist/text/index.js +9 -0
  17. package/dist/text/react/index.d.ts +14 -0
  18. package/dist/text/react/index.js +7 -0
  19. package/dist/text/react-native/index.d.ts +16 -0
  20. package/dist/text/react-native/index.js +155 -0
  21. package/dist/text/vue/index.d.ts +113 -0
  22. package/dist/text/vue/index.js +202 -0
  23. package/dist/types-BudfpzZX.d.ts +184 -0
  24. package/dist/types-C4poVJpR.d.ts +74 -0
  25. package/dist/vue/index.d.ts +173 -0
  26. package/dist/vue/index.js +111 -0
  27. package/docs/adapter-packaging-a0-plan.md +352 -0
  28. package/docs/adapters.md +19 -0
  29. package/docs/api-coherence-m8-audit.md +397 -0
  30. package/docs/error-codes.md +84 -0
  31. package/docs/grid-arrange-m5a-contract.md +480 -0
  32. package/docs/grid-arrange.md +51 -0
  33. package/docs/layout-interpolation.md +52 -0
  34. package/docs/machina-dispatch-d0-contract.md +496 -0
  35. package/docs/machina-dispatch.md +143 -0
  36. package/docs/named-layers.md +40 -0
  37. package/docs/react-adapter.md +51 -69
  38. package/docs/react-native-adapter.md +56 -0
  39. package/docs/react-native-text-renderer.md +50 -0
  40. package/docs/reference-alignment-m7a-contract.md +384 -0
  41. package/docs/reference-alignment.md +44 -0
  42. package/docs/responsive-variants.md +54 -0
  43. package/docs/vue-adapter.md +55 -0
  44. package/docs/vue-text-renderer.md +55 -0
  45. package/package.json +60 -5
@@ -0,0 +1,54 @@
1
+ # Responsive variants (M4b)
2
+
3
+ Responsive variants let a single flat `LayoutRow[]` express row-local overrides selected by `rootRect` dimensions.
4
+
5
+ ## Purpose
6
+
7
+ - Keep responsive behavior explicit and deterministic.
8
+ - Keep selection resolver-owned and driven only by caller-provided root geometry.
9
+ - Avoid userland row-array branching for common desktop/tablet/mobile style differences.
10
+
11
+ ## Authoring model
12
+
13
+ Add `variants` to a `LayoutRow`. Each variant has a `when` condition plus optional override fields.
14
+
15
+ ```ts
16
+ {
17
+ id: "sidebar",
18
+ parent: "root",
19
+ frame: { kind: "anchor", left: 0, top: 64, bottom: 0, width: 280 },
20
+ variants: [
21
+ {
22
+ when: { maxWidth: 800 },
23
+ frame: { kind: "anchor", left: 0, right: 0, top: 64, height: 56 },
24
+ slot: "mobileNav",
25
+ },
26
+ {
27
+ when: {},
28
+ slot: "desktopSidebar",
29
+ },
30
+ ],
31
+ }
32
+ ```
33
+
34
+ ## Selection semantics
35
+
36
+ - `resolveLayoutRows(rows, rootRect)` calls `selectLayoutRowsForRoot(rows, rootRect)` first.
37
+ - Conditions are inclusive (`>= min*`, `<= max*`).
38
+ - First matching variant wins.
39
+ - `when: {}` matches all root rects and can be used as a fallback.
40
+ - Effective rows are fresh copies and do not include `variants`.
41
+
42
+ ## Phase separation
43
+
44
+ - `compileLayoutRows(rows)` directly uses base row values only.
45
+ - Variants are an authoring-time input feature, not part of compiled or resolved node types.
46
+
47
+ ## Constraints and non-goals
48
+
49
+ M4b variants can override row metadata (`frame`, `arrange`, `offset`, `z`, `view`, `slot`, `debugLabel`) but cannot:
50
+
51
+ - change graph identity (`id`, `parent`, `order`),
52
+ - add/remove rows,
53
+ - use DOM measurement,
54
+ - use CSS media query semantics.
@@ -0,0 +1,55 @@
1
+ # Vue adapter (`machinalayout/vue`)
2
+
3
+ `MachinaVueView` renders a `ResolvedLayoutDocument` into DOM wrappers plus Vue view components.
4
+
5
+ - Import path: `import { MachinaVueView } from "machinalayout/vue";`
6
+ - Peer dependency: `vue` (`>=3.4 <4`).
7
+ - Machina layout stays record-shaped (`LayoutRow[]` -> resolved rectangles) across frameworks.
8
+
9
+ ## Shared model boundary
10
+
11
+ MachinaVueView uses Vue render functions internally so application code can stay record-shaped: layout rows describe geometry, and Vue components render inside the resolved rectangles.
12
+
13
+ You do not need to write `h()` calls, template layout loops, or directive ceremony to place boxes. Users can keep normal Vue SFC/template authoring for component internals, reactivity, and lifecycle.
14
+
15
+ ## Basic usage
16
+
17
+ ```vue
18
+ <script setup lang="ts">
19
+ import { MachinaVueView } from "machinalayout/vue";
20
+
21
+ const views = { Panel };
22
+ </script>
23
+
24
+ <template>
25
+ <MachinaVueView :layout="layout" :views="views" :view-data="viewData" :node-data="nodeData" />
26
+ </template>
27
+ ```
28
+
29
+ ## Stable view registry and data channels
30
+
31
+ Keep stable component references in `views`. Pass reactive/computed dynamic values through `viewData` and `nodeData`.
32
+
33
+ Avoid rebuilding component definitions as data carriers.
34
+
35
+ ## Props note
36
+
37
+ To avoid conflicts with Vue fallthrough attrs, root/node styling props are:
38
+
39
+ - `rootClass`, `rootStyle`
40
+ - `nodeClass`, `nodeStyle`
41
+
42
+ ## Supported
43
+
44
+ - `view ?? slot` lookup
45
+ - `viewData` / `nodeData`
46
+ - layer/z sorting (`layer z`, then `node z`, then sibling order)
47
+ - DOM containment/content-visibility policy
48
+ - debug mode
49
+ - parent-local coordinate normalization
50
+
51
+ ## Not included
52
+
53
+ - this package only renders layout boxes; text rendering is provided separately by `machinalayout/text/vue`
54
+ - portals/reparenting
55
+ - router/state abstraction layers
@@ -0,0 +1,55 @@
1
+ # Vue MachinaText renderer
2
+
3
+ `MachinaVueTextView` renders MachinaText content into DOM elements inside an already-owned rectangle.
4
+
5
+ ## Import
6
+
7
+ ```ts
8
+ import { MachinaVueTextView } from "machinalayout/text/vue";
9
+ ```
10
+
11
+ ## Peer dependency
12
+
13
+ - `vue` (Vue 3)
14
+
15
+ ## Accepted `text` inputs
16
+
17
+ - `string`
18
+ - `MachinaTextSource`
19
+ - `MachinaTextSpec`
20
+ - `MachinaTextDocument`
21
+
22
+ ## Supported rendering
23
+
24
+ - paragraphs (`p`)
25
+ - bullet lists (`ul`/`li`)
26
+ - inline strong/emphasis/code/link
27
+
28
+ ## Policy support
29
+
30
+ - `variant`
31
+ - `wrap`
32
+ - `overflow`
33
+ - `align`
34
+ - `leading`
35
+ - `blockGap`
36
+ - `listGap`
37
+ - `valign`
38
+
39
+ ## Notes
40
+
41
+ - Uses Vue `h()` internally so app code does not need render-function loops for the text AST.
42
+ - Supports `rootClass`/`rootStyle` plus `linkClass`/`linkStyle` and `codeClass`/`codeStyle` hooks.
43
+ - Link handling uses `onLinkClick` only (no routing dispatch integration).
44
+
45
+ ## Difference from React DOM text renderer
46
+
47
+ - Vue component API (`rootClass`/`rootStyle`) instead of React `className`/`style` prop names.
48
+ - Same parser/document model and text policy behavior.
49
+
50
+ ## Non-goals
51
+
52
+ - text measurement
53
+ - intrinsic sizing
54
+ - routing behavior
55
+ - editor/caret/selection behavior
package/package.json CHANGED
@@ -1,25 +1,39 @@
1
1
  {
2
2
  "name": "machinalayout",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "typecheck": "tsc --noEmit",
7
7
  "build": "npm run typecheck && tsup --config tsup.config.ts --tsconfig tsconfig.build.json",
8
- "test": "vitest run"
8
+ "test": "vitest run",
9
+ "format": "biome format --write .",
10
+ "format:check": "biome format .",
11
+ "lint": "biome lint .",
12
+ "check": "biome check ."
9
13
  },
10
14
  "devDependencies": {
15
+ "@biomejs/biome": "^2.4.15",
11
16
  "@testing-library/jest-dom": "^6.9.1",
12
17
  "@testing-library/react": "^16.3.2",
13
18
  "@types/react": "^19.2.14",
14
19
  "@types/react-dom": "^19.2.3",
20
+ "@types/react-test-renderer": "^19.1.0",
21
+ "@vue/test-utils": "^2.4.6",
15
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",
16
28
  "typescript": "^5.6.3",
17
29
  "vitest": "^2.1.8",
18
- "tsup": "^8.5.1"
30
+ "vue": "^3.5.22"
19
31
  },
20
32
  "peerDependencies": {
21
33
  "react": ">=18 <20",
22
- "react-dom": ">=18 <20"
34
+ "react-dom": ">=18 <20",
35
+ "react-native": ">=0.72 <1",
36
+ "vue": ">=3.4 <4"
23
37
  },
24
38
  "description": "Machine-native layout and text primitives for deterministic app UI records.",
25
39
  "license": "MIT",
@@ -48,6 +62,39 @@
48
62
  ".": {
49
63
  "types": "./dist/index.d.ts",
50
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"
51
98
  }
52
99
  },
53
100
  "files": [
@@ -56,5 +103,13 @@
56
103
  "LICENSE",
57
104
  "docs"
58
105
  ],
59
- "sideEffects": false
106
+ "sideEffects": false,
107
+ "peerDependenciesMeta": {
108
+ "react-native": {
109
+ "optional": true
110
+ },
111
+ "vue": {
112
+ "optional": true
113
+ }
114
+ }
60
115
  }