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
package/dist/index.d.ts CHANGED
@@ -1,128 +1,12 @@
1
- import React from 'react';
2
-
3
- type NodeId = string;
4
- type Rect = {
5
- x: number;
6
- y: number;
7
- width: number;
8
- height: number;
9
- };
10
- type AbsoluteFrame = {
11
- kind: "absolute";
12
- x: number;
13
- y: number;
14
- width: number;
15
- height: number;
16
- };
17
- type UiLength = number | {
18
- unit: "px";
19
- value: number;
20
- } | {
21
- unit: "ui";
22
- value: number;
23
- };
24
- type OffsetSpec = {
25
- x?: UiLength;
26
- y?: UiLength;
27
- };
28
- type AnchorFrame = {
29
- kind: "anchor";
30
- left?: UiLength;
31
- right?: UiLength;
32
- top?: UiLength;
33
- bottom?: UiLength;
34
- width?: UiLength;
35
- height?: UiLength;
36
- };
37
- type RootFrame = {
38
- kind: "root";
39
- };
40
- type FixedFrame = {
41
- kind: "fixed";
42
- width: number;
43
- height: number;
44
- };
45
- type FillFrame = {
46
- kind: "fill";
47
- weight?: number;
48
- cross?: number | "fill";
49
- };
50
- type FrameSpec = RootFrame | AbsoluteFrame | AnchorFrame | FixedFrame | FillFrame;
51
- type StackAxis = "horizontal" | "vertical";
52
- type StackJustify = "start" | "center" | "end" | "space-between";
53
- type StackAlign = "start" | "center" | "end";
54
- type EdgeInsets = {
55
- top: number;
56
- right: number;
57
- bottom: number;
58
- left: number;
59
- };
60
- type StackArrange = {
61
- kind: "stack";
62
- axis: StackAxis;
63
- gap?: number;
64
- padding?: number | EdgeInsets;
65
- justify?: StackJustify;
66
- align?: StackAlign;
67
- };
68
- type ArrangeSpec = StackArrange;
69
- type LayoutRow = {
70
- id: NodeId;
71
- parent?: NodeId;
72
- order?: number;
73
- z?: number;
74
- frame: FrameSpec;
75
- arrange?: ArrangeSpec;
76
- view?: string;
77
- slot?: string;
78
- debugLabel?: string;
79
- offset?: OffsetSpec;
80
- };
81
- type LayoutNode = {
82
- id: NodeId;
83
- z?: number;
84
- frame: FrameSpec;
85
- arrange?: ArrangeSpec;
86
- view?: string;
87
- slot?: string;
88
- debugLabel?: string;
89
- offset?: OffsetSpec;
90
- };
91
- type LayoutDocument = {
92
- rootId: NodeId;
93
- nodes: Record<NodeId, LayoutNode>;
94
- children: Record<NodeId, NodeId[]>;
95
- };
96
- type ResolvedLayoutNode = {
97
- id: NodeId;
98
- z?: number;
99
- rect: Rect;
100
- frame: FrameSpec;
101
- arrange?: ArrangeSpec;
102
- view?: string;
103
- slot?: string;
104
- debugLabel?: string;
105
- offset?: OffsetSpec;
106
- };
107
- type ResolvedLayoutDocument = {
108
- rootId: NodeId;
109
- nodes: Record<NodeId, ResolvedLayoutNode>;
110
- children: Record<NodeId, NodeId[]>;
111
- };
112
- type ResolvedLayoutTree = {
113
- id: NodeId;
114
- z?: number;
115
- rect: Rect;
116
- frame: FrameSpec;
117
- arrange?: ArrangeSpec;
118
- view?: string;
119
- slot?: string;
120
- debugLabel?: string;
121
- offset?: OffsetSpec;
122
- children: ResolvedLayoutTree[];
123
- };
124
-
125
- type MachinaLayoutErrorCode = "EmptyRows" | "MissingRoot" | "MultipleRoots" | "DuplicateId" | "InvalidId" | "MissingParent" | "UnknownParent" | "SelfParent" | "Cycle" | "UnreachableNode" | "NonFiniteNumber" | "InvalidLengthUnit" | "InvalidZ" | "NegativeSize" | "NegativeGap" | "NegativePadding" | "InvalidAnchorHorizontal" | "InvalidAnchorVertical" | "NegativeResolvedSize" | "FixedFrameWithoutArranger" | "FillFrameWithoutArranger" | "InvalidFillWeight" | "StackChildMustBeFixed" | "StackContentNegative" | "StackOverflow" | "RootFrameNotRoot" | "RootFrameWithoutRoot";
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 } from './types-BudfpzZX.js';
2
+ export { A as AbsoluteFrame, e as AnchorFrame, f as ArrangeSpec, C as CellFrame, g as EdgeRef, h as FillFrame, i as FixedFrame, G as GridArrange, j as GridTrack, k as GuideFrame, l as GuideLength, m as LayerName, n as LayoutNode, o as LayoutRowVariant, p as LayoutVariantCondition, N as NodeId, q as RectEdge, r as RootFrame, S as StackAlign, s as StackArrange, t as StackAxis, u as StackJustify } from './types-BudfpzZX.js';
3
+ export { MachinaReactView, MachinaReactViewProps, MachinaSlotProps } from './react/index.js';
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
+ export { parseMachinaText, parseMachinaTextInline } from './text/index.js';
6
+ export { MachinaTextView, MachinaTextViewProps } from './text/react/index.js';
7
+ import 'react';
8
+
9
+ 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" | "CellFrameWithoutGrid" | "GridChildMustBeCell" | "InvalidGridTrack" | "InvalidGridCell" | "GridContentNegative" | "GridOverflow" | "RootFrameNotRoot" | "RootFrameWithoutRoot" | "IncompatibleLayouts" | "GuideTargetNotFound" | "GuideSelfReference" | "GuideReferenceCycle" | "GuideInvalidEdgeForAxis" | "GuideTooManyReferencesPerAxis" | "InvalidGuideFrame" | "GuideTargetUnresolved";
126
10
  declare class MachinaLayoutError extends Error {
127
11
  readonly code: MachinaLayoutErrorCode;
128
12
  constructor(code: MachinaLayoutErrorCode, message: string);
@@ -141,6 +25,8 @@ declare function applyOffset(rect: Rect, parentRect: Rect, offset?: OffsetSpec):
141
25
 
142
26
  declare function compileLayoutRows(rows: LayoutRow[]): LayoutDocument;
143
27
 
28
+ declare function selectLayoutRowsForRoot(rows: LayoutRow[], rootRect: Rect): LayoutRow[];
29
+
144
30
  declare function resolveFrame(parent: Rect, frame: FrameSpec): Rect;
145
31
 
146
32
  declare function resolveLayoutDocument(document: LayoutDocument, rootRect: Rect): ResolvedLayoutDocument;
@@ -153,117 +39,8 @@ declare function flattenResolvedTree(tree: ResolvedLayoutTree): ResolvedLayoutNo
153
39
 
154
40
  declare function formatRect(rect: Rect): string;
155
41
 
156
- type MachinaSlotProps<TViewData = unknown, TNodeData = unknown> = {
157
- id: NodeId;
158
- rect: Rect;
159
- debugLabel?: string;
160
- node: ResolvedLayoutNode;
161
- viewKey?: string;
162
- viewData?: TViewData;
163
- nodeData?: TNodeData;
164
- };
165
- type MachinaReactViewProps = {
166
- layout: ResolvedLayoutDocument;
167
- views?: Record<string, React.ComponentType<MachinaSlotProps>>;
168
- viewData?: Record<string, unknown>;
169
- nodeData?: Record<NodeId, unknown>;
170
- className?: string;
171
- style?: React.CSSProperties;
172
- nodeClassName?: string;
173
- debug?: boolean;
174
- nodeContainment?: "none" | "layout-paint" | "strict";
175
- nodeContentVisibility?: "none" | "auto";
176
- nodeContainIntrinsicSize?: string;
177
- };
178
- declare function MachinaReactView(props: MachinaReactViewProps): React.JSX.Element;
179
-
180
- type MachinaTextSource = {
181
- kind: "plain";
182
- text: string;
183
- } | {
184
- kind: "machina-text";
185
- text: string;
186
- };
187
- type MachinaTextVariant = "body" | "label" | "caption" | "title" | "mono";
188
- type MachinaTextWrap = "word" | "none";
189
- type MachinaTextOverflow = "clip" | "ellipsis" | "scroll";
190
- type MachinaTextAlign = "start" | "center" | "end";
191
- type MachinaTextLeading = "tight" | "normal" | "loose" | number;
192
- type MachinaTextVerticalAlign = "top" | "center" | "bottom";
193
- type MachinaTextSpec = {
194
- kind: "text";
195
- source: MachinaTextSource;
196
- variant?: MachinaTextVariant;
197
- wrap?: MachinaTextWrap;
198
- overflow?: MachinaTextOverflow;
199
- align?: MachinaTextAlign;
200
- leading?: MachinaTextLeading;
201
- blockGap?: number;
202
- listGap?: number;
203
- valign?: MachinaTextVerticalAlign;
204
- };
205
- type MachinaTextDocument = {
206
- blocks: MachinaTextBlock[];
207
- };
208
- type MachinaTextBlock = {
209
- kind: "paragraph";
210
- inline: MachinaInline[];
211
- } | {
212
- kind: "bulletList";
213
- items: MachinaBulletItem[];
214
- };
215
- type MachinaBulletItem = {
216
- inline: MachinaInline[];
217
- children?: MachinaBulletItem[];
218
- };
219
- type MachinaInline = {
220
- kind: "text";
221
- text: string;
222
- } | {
223
- kind: "strong";
224
- children: MachinaInline[];
225
- } | {
226
- kind: "emphasis";
227
- children: MachinaInline[];
228
- } | {
229
- kind: "code";
230
- text: string;
231
- } | {
232
- kind: "link";
233
- href: string;
234
- children: MachinaInline[];
235
- };
236
- type MachinaTextDiagnosticLevel = "error" | "warning";
237
- type MachinaTextDiagnosticCode = "unsupported_syntax" | "heading_forbidden" | "max_list_depth_exceeded" | "malformed_link" | "unclosed_inline" | "invalid_escape";
238
- type MachinaTextDiagnostic = {
239
- code: MachinaTextDiagnosticCode;
240
- message: string;
241
- index: number;
242
- length: number;
243
- line: number;
244
- column: number;
245
- level: MachinaTextDiagnosticLevel;
246
- };
247
- type ParseMachinaTextResult = {
248
- ok: boolean;
249
- document: MachinaTextDocument;
250
- diagnostics: MachinaTextDiagnostic[];
251
- };
252
-
253
- declare function parseMachinaTextInline(text: string): {
254
- inline: MachinaInline[];
255
- diagnostics: MachinaTextDiagnostic[];
256
- };
257
- declare function parseMachinaText(source: MachinaTextSource | string): ParseMachinaTextResult;
258
-
259
- type MachinaTextViewProps = {
260
- text: MachinaTextSpec | MachinaTextSource | MachinaTextDocument | string;
261
- className?: string;
262
- style?: React.CSSProperties;
263
- linkTarget?: React.HTMLAttributeAnchorTarget;
264
- onLinkClick?: (href: string, event: React.MouseEvent<HTMLAnchorElement>) => void;
265
- showDiagnostics?: boolean;
266
- };
267
- declare function MachinaTextView(props: MachinaTextViewProps): React.JSX.Element;
42
+ declare function lerpNumber(a: number, b: number, t: number): number;
43
+ declare function lerpRect(a: Rect, b: Rect, t: number): Rect;
44
+ declare function lerpResolvedLayouts(a: ResolvedLayoutDocument, b: ResolvedLayoutDocument, t: number): ResolvedLayoutDocument;
268
45
 
269
- export { type AbsoluteFrame, type AnchorFrame, type ArrangeSpec, type EdgeInsets, type FillFrame, type FixedFrame, type FrameSpec, type LayoutDocument, type LayoutNode, type LayoutRow, type MachinaBulletItem, type MachinaInline, MachinaLayoutError, type MachinaLayoutErrorCode, MachinaReactView, type MachinaReactViewProps, type MachinaSlotProps, type MachinaTextAlign, type MachinaTextBlock, type MachinaTextDiagnostic, type MachinaTextDiagnosticCode, type MachinaTextDiagnosticLevel, type MachinaTextDocument, type MachinaTextLeading, type MachinaTextOverflow, type MachinaTextSource, type MachinaTextSpec, type MachinaTextVariant, type MachinaTextVerticalAlign, MachinaTextView, type MachinaTextViewProps, type MachinaTextWrap, type NodeId, type OffsetSpec, type ParseMachinaTextResult, type Rect, type ResolvedLayoutDocument, type ResolvedLayoutNode, type ResolvedLayoutTree, type RootFrame, type StackAlign, type StackArrange, type StackAxis, type StackJustify, type UiLength, applyOffset, assertFiniteNumber, assertNonNegativeGap, assertNonNegativePadding, assertNonNegativeSize, compileLayoutRows, flattenResolvedTree, formatRect, normalizePadding, parseMachinaText, parseMachinaTextInline, resolveFrame, resolveLayoutDocument, resolveLayoutRows, resolveUiLength, toResolvedTree };
46
+ export { EdgeInsets, FrameSpec, LayoutDocument, LayoutRow, MachinaLayoutError, type MachinaLayoutErrorCode, OffsetSpec, Rect, ResolvedLayoutDocument, ResolvedLayoutNode, ResolvedLayoutTree, UiLength, applyOffset, assertFiniteNumber, assertNonNegativeGap, assertNonNegativePadding, assertNonNegativeSize, compileLayoutRows, flattenResolvedTree, formatRect, lerpNumber, lerpRect, lerpResolvedLayouts, normalizePadding, resolveFrame, resolveLayoutDocument, resolveLayoutRows, resolveUiLength, selectLayoutRowsForRoot, toResolvedTree };