machinalayout 0.1.0 → 0.3.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.
- package/README.md +295 -49
- package/dist/chunk-2ZQ2RFFI.js +400 -0
- package/dist/chunk-33CKBEJH.js +186 -0
- package/dist/chunk-BJOQRPPX.js +382 -0
- package/dist/chunk-KYWOCAHK.js +205 -0
- package/dist/chunk-RJYRJ3LD.js +0 -0
- package/dist/chunk-SVWYWI7I.js +59 -0
- package/dist/chunk-VREK57S3.js +13 -0
- package/dist/chunk-ZVDE7PX4.js +222 -0
- package/dist/debugOverlay-pJpj0n5H.d.ts +125 -0
- package/dist/deus/index.d.ts +14 -0
- package/dist/deus/index.js +26 -0
- package/dist/dispatch/index.d.ts +49 -0
- package/dist/dispatch/index.js +217 -0
- package/dist/handoff/index.d.ts +44 -0
- package/dist/handoff/index.js +83 -0
- package/dist/index.d.ts +54 -236
- package/dist/index.js +753 -583
- package/dist/inspect/index.d.ts +8 -0
- package/dist/inspect/index.js +97 -0
- package/dist/react/index.d.ts +41 -0
- package/dist/react/index.js +9 -0
- package/dist/react-native/index.d.ts +30 -0
- package/dist/react-native/index.js +84 -0
- package/dist/screenCatalog-ZjonGiOi.d.ts +46 -0
- package/dist/text/index.d.ts +10 -0
- package/dist/text/index.js +9 -0
- package/dist/text/react/index.d.ts +14 -0
- package/dist/text/react/index.js +7 -0
- package/dist/text/react-native/index.d.ts +16 -0
- package/dist/text/react-native/index.js +155 -0
- package/dist/text/vue/index.d.ts +113 -0
- package/dist/text/vue/index.js +202 -0
- package/dist/types-B90jb3RW.d.ts +184 -0
- package/dist/types-C4poVJpR.d.ts +74 -0
- package/dist/types-DLYAhNXw.d.ts +32 -0
- package/dist/vue/index.d.ts +173 -0
- package/dist/vue/index.js +112 -0
- package/docs/adapter-packaging-a0-plan.md +352 -0
- package/docs/adapters.md +19 -0
- package/docs/api-coherence-m8-audit.md +397 -0
- package/docs/deusmachina.md +108 -0
- package/docs/error-codes.md +95 -0
- package/docs/grid-arrange-m5a-contract.md +480 -0
- package/docs/grid-arrange.md +51 -0
- package/docs/inspection-and-handoff.md +126 -0
- package/docs/layout-interpolation.md +52 -0
- package/docs/machina-dispatch-d0-contract.md +496 -0
- package/docs/machina-dispatch.md +143 -0
- package/docs/named-layers.md +40 -0
- package/docs/react-adapter.md +63 -58
- package/docs/react-native-adapter.md +56 -0
- package/docs/react-native-text-renderer.md +50 -0
- package/docs/reference-alignment-m7a-contract.md +384 -0
- package/docs/reference-alignment.md +44 -0
- package/docs/responsive-variants.md +54 -0
- package/docs/screen-catalog-and-viewports.md +124 -0
- package/docs/stack-geometry-helpers.md +115 -0
- package/docs/vue-adapter.md +55 -0
- package/docs/vue-text-renderer.md +55 -0
- package/package.json +127 -60
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { M as MachinaDomSummary } from '../types-DLYAhNXw.js';
|
|
2
|
+
import { M as MachinaViewport, a as MachinaScreenViewportTask } from '../screenCatalog-ZjonGiOi.js';
|
|
3
|
+
import '../types-B90jb3RW.js';
|
|
4
|
+
|
|
5
|
+
type MachinaHandoffArtifactPaths = {
|
|
6
|
+
screenshot?: string;
|
|
7
|
+
domSummary?: string;
|
|
8
|
+
layoutSnapshot?: string;
|
|
9
|
+
manifest: string;
|
|
10
|
+
};
|
|
11
|
+
type MachinaHandoffBundleManifest = {
|
|
12
|
+
schemaVersion: 1;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
route?: string;
|
|
15
|
+
fixture?: string;
|
|
16
|
+
screenKey?: string;
|
|
17
|
+
viewportKey?: string;
|
|
18
|
+
viewport?: MachinaViewport;
|
|
19
|
+
tags?: readonly string[];
|
|
20
|
+
artifactBaseName?: string;
|
|
21
|
+
artifacts: MachinaHandoffArtifactPaths;
|
|
22
|
+
metadata?: Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
type WriteMachinaHandoffBundleInput = {
|
|
25
|
+
outputDir: string;
|
|
26
|
+
artifactBaseName?: string;
|
|
27
|
+
screenshotPath?: string;
|
|
28
|
+
domSummary?: MachinaDomSummary;
|
|
29
|
+
layoutSnapshot?: unknown;
|
|
30
|
+
task?: MachinaScreenViewportTask;
|
|
31
|
+
route?: string;
|
|
32
|
+
fixture?: string;
|
|
33
|
+
tags?: readonly string[];
|
|
34
|
+
metadata?: Record<string, unknown>;
|
|
35
|
+
createdAt?: string;
|
|
36
|
+
};
|
|
37
|
+
type WriteMachinaHandoffBundleResult = {
|
|
38
|
+
manifest: MachinaHandoffBundleManifest;
|
|
39
|
+
paths: MachinaHandoffArtifactPaths;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
declare function writeMachinaHandoffBundle(input: WriteMachinaHandoffBundleInput): Promise<WriteMachinaHandoffBundleResult>;
|
|
43
|
+
|
|
44
|
+
export { type MachinaHandoffArtifactPaths, type MachinaHandoffBundleManifest, type WriteMachinaHandoffBundleInput, type WriteMachinaHandoffBundleResult, writeMachinaHandoffBundle };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
slugMachinaArtifactName
|
|
3
|
+
} from "../chunk-33CKBEJH.js";
|
|
4
|
+
import "../chunk-VREK57S3.js";
|
|
5
|
+
|
|
6
|
+
// src/handoff/writeMachinaHandoffBundle.ts
|
|
7
|
+
import { copyFile, mkdir, writeFile } from "fs/promises";
|
|
8
|
+
import path from "path";
|
|
9
|
+
function artifactBaseName(input) {
|
|
10
|
+
const candidate = input.artifactBaseName ?? input.task?.artifactBaseName ?? [
|
|
11
|
+
input.route ?? input.task?.route,
|
|
12
|
+
input.fixture ?? input.task?.fixture,
|
|
13
|
+
input.task?.viewportKey
|
|
14
|
+
].filter((part) => typeof part === "string" && part.trim() !== "").join("-") ?? "";
|
|
15
|
+
return slugMachinaArtifactName(candidate === "" ? "machina-handoff" : candidate);
|
|
16
|
+
}
|
|
17
|
+
function orderedUnique(...groups) {
|
|
18
|
+
const result = [];
|
|
19
|
+
for (const group of groups) {
|
|
20
|
+
for (const tag of group ?? []) {
|
|
21
|
+
if (!result.includes(tag)) result.push(tag);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return result.length === 0 ? void 0 : result;
|
|
25
|
+
}
|
|
26
|
+
function json(value) {
|
|
27
|
+
return `${JSON.stringify(value, null, 2)}
|
|
28
|
+
`;
|
|
29
|
+
}
|
|
30
|
+
function screenshotExtension(screenshotPath) {
|
|
31
|
+
const extension = path.extname(screenshotPath);
|
|
32
|
+
return extension === "" ? ".png" : extension;
|
|
33
|
+
}
|
|
34
|
+
async function writeMachinaHandoffBundle(input) {
|
|
35
|
+
if (typeof input.outputDir !== "string" || input.outputDir.trim() === "") {
|
|
36
|
+
throw new Error("outputDir must be a non-empty string");
|
|
37
|
+
}
|
|
38
|
+
const outputDir = path.resolve(input.outputDir);
|
|
39
|
+
await mkdir(outputDir, { recursive: true });
|
|
40
|
+
const base = artifactBaseName(input);
|
|
41
|
+
const artifactNames = { manifest: `${base}__handoff.json` };
|
|
42
|
+
const paths = {
|
|
43
|
+
manifest: path.join(outputDir, artifactNames.manifest)
|
|
44
|
+
};
|
|
45
|
+
if (input.screenshotPath !== void 0) {
|
|
46
|
+
artifactNames.screenshot = `${base}__screenshot${screenshotExtension(input.screenshotPath)}`;
|
|
47
|
+
paths.screenshot = path.join(outputDir, artifactNames.screenshot);
|
|
48
|
+
await copyFile(input.screenshotPath, paths.screenshot);
|
|
49
|
+
}
|
|
50
|
+
if (input.domSummary !== void 0) {
|
|
51
|
+
artifactNames.domSummary = `${base}__dom-summary.json`;
|
|
52
|
+
paths.domSummary = path.join(outputDir, artifactNames.domSummary);
|
|
53
|
+
await writeFile(paths.domSummary, json(input.domSummary), "utf8");
|
|
54
|
+
}
|
|
55
|
+
if (input.layoutSnapshot !== void 0) {
|
|
56
|
+
artifactNames.layoutSnapshot = `${base}__machina-snapshot.json`;
|
|
57
|
+
paths.layoutSnapshot = path.join(outputDir, artifactNames.layoutSnapshot);
|
|
58
|
+
await writeFile(paths.layoutSnapshot, json(input.layoutSnapshot), "utf8");
|
|
59
|
+
}
|
|
60
|
+
const tags = orderedUnique(input.task?.tags, input.tags);
|
|
61
|
+
const manifest = {
|
|
62
|
+
schemaVersion: 1,
|
|
63
|
+
createdAt: input.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
64
|
+
artifacts: artifactNames
|
|
65
|
+
};
|
|
66
|
+
const route = input.route ?? input.task?.route;
|
|
67
|
+
const fixture = input.fixture ?? input.task?.fixture;
|
|
68
|
+
if (route !== void 0) manifest.route = route;
|
|
69
|
+
if (fixture !== void 0) manifest.fixture = fixture;
|
|
70
|
+
if (input.task !== void 0) {
|
|
71
|
+
manifest.screenKey = input.task.screenKey;
|
|
72
|
+
manifest.viewportKey = input.task.viewportKey;
|
|
73
|
+
manifest.viewport = input.task.viewport;
|
|
74
|
+
}
|
|
75
|
+
if (tags !== void 0) manifest.tags = tags;
|
|
76
|
+
manifest.artifactBaseName = base;
|
|
77
|
+
if (input.metadata !== void 0) manifest.metadata = input.metadata;
|
|
78
|
+
await writeFile(paths.manifest, json(manifest), "utf8");
|
|
79
|
+
return { manifest, paths };
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
writeMachinaHandoffBundle
|
|
83
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,128 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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, 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';
|
|
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
|
+
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
|
+
import 'react';
|
|
9
|
+
import './debugOverlay-pJpj0n5H.js';
|
|
10
|
+
|
|
11
|
+
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";
|
|
126
12
|
declare class MachinaLayoutError extends Error {
|
|
127
13
|
readonly code: MachinaLayoutErrorCode;
|
|
128
14
|
constructor(code: MachinaLayoutErrorCode, message: string);
|
|
@@ -141,6 +27,8 @@ declare function applyOffset(rect: Rect, parentRect: Rect, offset?: OffsetSpec):
|
|
|
141
27
|
|
|
142
28
|
declare function compileLayoutRows(rows: LayoutRow[]): LayoutDocument;
|
|
143
29
|
|
|
30
|
+
declare function selectLayoutRowsForRoot(rows: LayoutRow[], rootRect: Rect): LayoutRow[];
|
|
31
|
+
|
|
144
32
|
declare function resolveFrame(parent: Rect, frame: FrameSpec): Rect;
|
|
145
33
|
|
|
146
34
|
declare function resolveLayoutDocument(document: LayoutDocument, rootRect: Rect): ResolvedLayoutDocument;
|
|
@@ -153,117 +41,47 @@ declare function flattenResolvedTree(tree: ResolvedLayoutTree): ResolvedLayoutNo
|
|
|
153
41
|
|
|
154
42
|
declare function formatRect(rect: Rect): string;
|
|
155
43
|
|
|
156
|
-
type
|
|
44
|
+
type StackChildMetric = {
|
|
157
45
|
id: NodeId;
|
|
158
46
|
rect: Rect;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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;
|
|
47
|
+
mainStart: number;
|
|
48
|
+
mainEnd: number;
|
|
49
|
+
mainSize: number;
|
|
50
|
+
crossStart: number;
|
|
51
|
+
crossEnd: number;
|
|
52
|
+
crossSize: number;
|
|
53
|
+
frameKind: FrameSpec["kind"];
|
|
54
|
+
z?: number;
|
|
55
|
+
layer?: LayerName;
|
|
266
56
|
};
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
57
|
+
type StackMainAxisMetrics = {
|
|
58
|
+
parentId: NodeId;
|
|
59
|
+
axis: StackAxis;
|
|
60
|
+
parentRect: Rect;
|
|
61
|
+
contentRect: Rect;
|
|
62
|
+
padding: EdgeInsets;
|
|
63
|
+
gap: number;
|
|
64
|
+
childIds: NodeId[];
|
|
65
|
+
childMetrics: StackChildMetric[];
|
|
66
|
+
contentMainSize: number;
|
|
67
|
+
contentCrossSize: number;
|
|
68
|
+
totalChildMainSize: number;
|
|
69
|
+
totalGapSize: number;
|
|
70
|
+
usedMainSize: number;
|
|
71
|
+
unusedMainSize: number;
|
|
72
|
+
};
|
|
73
|
+
declare function getArrangeContentRect(parentRect: Rect, arrange?: ArrangeSpec): Rect;
|
|
74
|
+
declare function getStackContentRect(layout: ResolvedLayoutDocument, parentId: NodeId): Rect;
|
|
75
|
+
declare function getStackMainAxisMetrics(layout: ResolvedLayoutDocument, parentId: NodeId): StackMainAxisMetrics;
|
|
76
|
+
declare function getStackChildRects(layout: ResolvedLayoutDocument, parentId: NodeId): Record<NodeId, Rect>;
|
|
77
|
+
declare function getRemainingStackRect(layout: ResolvedLayoutDocument, options: {
|
|
78
|
+
parentId: NodeId;
|
|
79
|
+
afterChildren?: NodeId[];
|
|
80
|
+
beforeChildren?: NodeId[];
|
|
81
|
+
}): Rect;
|
|
82
|
+
|
|
83
|
+
declare function lerpNumber(a: number, b: number, t: number): number;
|
|
84
|
+
declare function lerpRect(a: Rect, b: Rect, t: number): Rect;
|
|
85
|
+
declare function lerpResolvedLayouts(a: ResolvedLayoutDocument, b: ResolvedLayoutDocument, t: number): ResolvedLayoutDocument;
|
|
86
|
+
|
|
87
|
+
export { ArrangeSpec, EdgeInsets, FrameSpec, LayerName, LayoutDocument, LayoutRow, MachinaLayoutError, type MachinaLayoutErrorCode, NodeId, OffsetSpec, Rect, ResolvedLayoutDocument, ResolvedLayoutNode, ResolvedLayoutTree, StackAxis, type StackChildMetric, type StackMainAxisMetrics, UiLength, applyOffset, assertFiniteNumber, assertNonNegativeGap, assertNonNegativePadding, assertNonNegativeSize, compileLayoutRows, flattenResolvedTree, formatRect, getArrangeContentRect, getRemainingStackRect, getStackChildRects, getStackContentRect, getStackMainAxisMetrics, lerpNumber, lerpRect, lerpResolvedLayouts, normalizePadding, resolveFrame, resolveLayoutDocument, resolveLayoutRows, resolveUiLength, selectLayoutRowsForRoot, toResolvedTree };
|