@lumencast/compiler 0.2.0 → 0.4.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/dist/.tsbuildinfo +1 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +36 -0
- package/dist/compile.js.map +1 -1
- package/dist/lsml-types.d.ts +19 -7
- package/dist/lsml-types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/compile.ts +361 -325
- package/src/index.ts +21 -21
- package/src/lsml-types.ts +210 -197
package/src/index.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
// Public surface of @lumencast/compiler.
|
|
2
|
-
|
|
3
|
-
export { compileBundle, type CompileOptions } from "./compile.js";
|
|
4
|
-
export { canonicalize, hashBundle, ZERO_HASH } from "./canonicalize.js";
|
|
5
|
-
export type {
|
|
6
|
-
LSMLBundle,
|
|
7
|
-
LSMLNode,
|
|
8
|
-
LSMLPrimitiveKind,
|
|
9
|
-
LSMLBindObject,
|
|
10
|
-
LSMLAnimateDirective,
|
|
11
|
-
LSMLStack,
|
|
12
|
-
LSMLGrid,
|
|
13
|
-
LSMLFrame,
|
|
14
|
-
LSMLText,
|
|
15
|
-
LSMLImage,
|
|
16
|
-
LSMLShape,
|
|
17
|
-
LSMLMedia,
|
|
18
|
-
LSMLRepeat,
|
|
19
|
-
LSMLInstance,
|
|
20
|
-
LSMLOperatorInput,
|
|
21
|
-
} from "./lsml-types.js";
|
|
1
|
+
// Public surface of @lumencast/compiler.
|
|
2
|
+
|
|
3
|
+
export { compileBundle, type CompileOptions } from "./compile.js";
|
|
4
|
+
export { canonicalize, hashBundle, ZERO_HASH } from "./canonicalize.js";
|
|
5
|
+
export type {
|
|
6
|
+
LSMLBundle,
|
|
7
|
+
LSMLNode,
|
|
8
|
+
LSMLPrimitiveKind,
|
|
9
|
+
LSMLBindObject,
|
|
10
|
+
LSMLAnimateDirective,
|
|
11
|
+
LSMLStack,
|
|
12
|
+
LSMLGrid,
|
|
13
|
+
LSMLFrame,
|
|
14
|
+
LSMLText,
|
|
15
|
+
LSMLImage,
|
|
16
|
+
LSMLShape,
|
|
17
|
+
LSMLMedia,
|
|
18
|
+
LSMLRepeat,
|
|
19
|
+
LSMLInstance,
|
|
20
|
+
LSMLOperatorInput,
|
|
21
|
+
} from "./lsml-types.js";
|
package/src/lsml-types.ts
CHANGED
|
@@ -1,197 +1,210 @@
|
|
|
1
|
-
// LSML 1.0 / 1.1 input types — what authors write.
|
|
2
|
-
// Reference: lumencast-protocol/spec/LSML-1.md
|
|
3
|
-
//
|
|
4
|
-
// 1.1 additions (additive over 1.0) :
|
|
5
|
-
// - `instance` primitive (§4.9)
|
|
6
|
-
// - Universal props (`visible` / `sizing` / `opacity` / `rotation`)
|
|
7
|
-
// on every primitive (§5.4)
|
|
8
|
-
// - `bindUniversal` field on every primitive
|
|
9
|
-
// - Multi-fill `fills[]` on `shape` (§4.6 + §4.12)
|
|
10
|
-
// - Stacked `backgrounds[]` on `frame` (§4.3)
|
|
11
|
-
// - Bundle-level `$schema`, `profiles[]` (§17.3)
|
|
12
|
-
|
|
13
|
-
export type LSMLPrimitiveKind =
|
|
14
|
-
| "stack"
|
|
15
|
-
| "grid"
|
|
16
|
-
| "frame"
|
|
17
|
-
| "text"
|
|
18
|
-
| "image"
|
|
19
|
-
| "shape"
|
|
20
|
-
| "media"
|
|
21
|
-
| "repeat"
|
|
22
|
-
| "instance";
|
|
23
|
-
|
|
24
|
-
export interface LSMLBindObject {
|
|
25
|
-
/** Most primitives bind a `value` to a leaf path. */
|
|
26
|
-
value?: string;
|
|
27
|
-
/** image / media bind a `src`. */
|
|
28
|
-
src?: string;
|
|
29
|
-
/** repeat binds `items`. */
|
|
30
|
-
items?: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
/** 1.1
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/** 1.1+ — universal
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
1
|
+
// LSML 1.0 / 1.1 input types — what authors write.
|
|
2
|
+
// Reference: lumencast-protocol/spec/LSML-1.md
|
|
3
|
+
//
|
|
4
|
+
// 1.1 additions (additive over 1.0) :
|
|
5
|
+
// - `instance` primitive (§4.9)
|
|
6
|
+
// - Universal props (`visible` / `sizing` / `opacity` / `rotation`)
|
|
7
|
+
// on every primitive (§5.4)
|
|
8
|
+
// - `bindUniversal` field on every primitive
|
|
9
|
+
// - Multi-fill `fills[]` on `shape` (§4.6 + §4.12)
|
|
10
|
+
// - Stacked `backgrounds[]` on `frame` (§4.3)
|
|
11
|
+
// - Bundle-level `$schema`, `profiles[]` (§17.3)
|
|
12
|
+
|
|
13
|
+
export type LSMLPrimitiveKind =
|
|
14
|
+
| "stack"
|
|
15
|
+
| "grid"
|
|
16
|
+
| "frame"
|
|
17
|
+
| "text"
|
|
18
|
+
| "image"
|
|
19
|
+
| "shape"
|
|
20
|
+
| "media"
|
|
21
|
+
| "repeat"
|
|
22
|
+
| "instance";
|
|
23
|
+
|
|
24
|
+
export interface LSMLBindObject {
|
|
25
|
+
/** Most primitives bind a `value` to a leaf path. */
|
|
26
|
+
value?: string;
|
|
27
|
+
/** image / media bind a `src`. */
|
|
28
|
+
src?: string;
|
|
29
|
+
/** repeat binds `items`. */
|
|
30
|
+
items?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The visual state an `animate` directive can target (and, via `from`,
|
|
34
|
+
* start from). `from` carries the same fields ; it is the mount-time
|
|
35
|
+
* initial state that makes an authored `animate` play *on mount* without
|
|
36
|
+
* any operator delta or KeyframePlayer. */
|
|
37
|
+
export interface LSMLAnimateState {
|
|
38
|
+
transform?: {
|
|
39
|
+
translate?: [number, number];
|
|
40
|
+
scale?: number | [number, number];
|
|
41
|
+
rotate?: number;
|
|
42
|
+
};
|
|
43
|
+
opacity?: number;
|
|
44
|
+
filter?: {
|
|
45
|
+
blur?: number;
|
|
46
|
+
brightness?: number;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface LSMLAnimateDirective extends LSMLAnimateState {
|
|
51
|
+
transition?: {
|
|
52
|
+
duration?: number;
|
|
53
|
+
easing?: "linear" | "ease-in" | "ease-out" | "ease-in-out" | "spring";
|
|
54
|
+
stiffness?: number;
|
|
55
|
+
damping?: number;
|
|
56
|
+
};
|
|
57
|
+
/** LSML 1.1 — mount-time initial state. When present, the element
|
|
58
|
+
* mounts with these values and animates to its declared target
|
|
59
|
+
* (`opacity` / `transform` on the directive) on mount. When absent,
|
|
60
|
+
* behaviour is unchanged (no mount-play ; rétro-compatible). */
|
|
61
|
+
from?: LSMLAnimateState;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface LSMLBaseNode {
|
|
65
|
+
kind: LSMLPrimitiveKind;
|
|
66
|
+
id?: string;
|
|
67
|
+
bind?: LSMLBindObject;
|
|
68
|
+
bindStyle?: Record<string, string>;
|
|
69
|
+
/** 1.1+ — bind universal props to leaf paths. */
|
|
70
|
+
bindUniversal?: Record<string, string>;
|
|
71
|
+
animate?: LSMLAnimateDirective;
|
|
72
|
+
children?: LSMLNode[];
|
|
73
|
+
/** 1.1+ — visibility flag (LSML §5.4). Defaults to true. */
|
|
74
|
+
visible?: boolean;
|
|
75
|
+
/** 1.1+ — opacity 0..1 (LSML §5.4). Defaults to 1. */
|
|
76
|
+
opacity?: number;
|
|
77
|
+
/** 1.1+ — rotation in degrees (LSML §5.4). Defaults to 0. */
|
|
78
|
+
rotation?: number;
|
|
79
|
+
/** 1.1+ — per-axis sizing mode (LSML §5.4). */
|
|
80
|
+
sizing?: { x?: "fixed" | "hug" | "fill"; y?: "fixed" | "hug" | "fill" };
|
|
81
|
+
/** 1.1+ — universal position relative to parent (LSML §5.4). */
|
|
82
|
+
position?: { x: number; y: number };
|
|
83
|
+
/** Open-ended authoring metadata (LSML §17.4). Runtime ignores. */
|
|
84
|
+
metadata?: Record<string, unknown>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface LSMLStack extends LSMLBaseNode {
|
|
88
|
+
kind: "stack";
|
|
89
|
+
direction?: "horizontal" | "vertical";
|
|
90
|
+
gap?: number;
|
|
91
|
+
align?: "start" | "center" | "end" | "stretch";
|
|
92
|
+
justify?: "start" | "center" | "end" | "space-between" | "space-around";
|
|
93
|
+
padding?: number | [number, number, number, number];
|
|
94
|
+
rtl?: "auto" | boolean;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface LSMLGrid extends LSMLBaseNode {
|
|
98
|
+
kind: "grid";
|
|
99
|
+
columns: number | unknown[];
|
|
100
|
+
rows?: number | unknown[];
|
|
101
|
+
gap?: number | [number, number];
|
|
102
|
+
padding?: number | unknown[];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface LSMLFrame extends LSMLBaseNode {
|
|
106
|
+
kind: "frame";
|
|
107
|
+
size?: { w: number; h: number };
|
|
108
|
+
position?: { x: number; y: number };
|
|
109
|
+
background?: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface LSMLText extends LSMLBaseNode {
|
|
113
|
+
kind: "text";
|
|
114
|
+
style?: {
|
|
115
|
+
fontSize?: number | string;
|
|
116
|
+
fontFamily?: string;
|
|
117
|
+
fontWeight?: number;
|
|
118
|
+
color?: string;
|
|
119
|
+
textAlign?: "start" | "center" | "end" | "left" | "right";
|
|
120
|
+
lineHeight?: number;
|
|
121
|
+
};
|
|
122
|
+
format?: { kind: string; [extra: string]: unknown };
|
|
123
|
+
maxLines?: number;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface LSMLImage extends LSMLBaseNode {
|
|
127
|
+
kind: "image";
|
|
128
|
+
alt: string;
|
|
129
|
+
size: { w: number; h: number };
|
|
130
|
+
fit?: "contain" | "cover" | "fill" | "none";
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface LSMLShape extends LSMLBaseNode {
|
|
134
|
+
kind: "shape";
|
|
135
|
+
geometry: "rect" | "circle" | "path";
|
|
136
|
+
size?: { w: number; h: number };
|
|
137
|
+
pathData?: string;
|
|
138
|
+
fill?: string;
|
|
139
|
+
stroke?: { color: string; width: number };
|
|
140
|
+
cornerRadius?: number;
|
|
141
|
+
ariaLabel?: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface LSMLMedia extends LSMLBaseNode {
|
|
145
|
+
kind: "media";
|
|
146
|
+
kind_hint: "video" | "audio";
|
|
147
|
+
controls?: boolean;
|
|
148
|
+
autoplay?: boolean;
|
|
149
|
+
muted?: boolean;
|
|
150
|
+
loop?: boolean;
|
|
151
|
+
size?: { w: number; h: number };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface LSMLRepeat extends LSMLBaseNode {
|
|
155
|
+
kind: "repeat";
|
|
156
|
+
scope: string;
|
|
157
|
+
key?: string;
|
|
158
|
+
template: LSMLNode;
|
|
159
|
+
limit?: number;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** 1.1+ — `instance` primitive (LSML §4.9). Mounts a sub-scene by id with
|
|
163
|
+
* bound parameters. */
|
|
164
|
+
export interface LSMLInstance extends LSMLBaseNode {
|
|
165
|
+
kind: "instance";
|
|
166
|
+
scene_id: string;
|
|
167
|
+
scene_version: string;
|
|
168
|
+
size?: { w: number; h: number };
|
|
169
|
+
fit?: "contain" | "cover" | "stretch";
|
|
170
|
+
params?: Record<string, unknown>;
|
|
171
|
+
bindParams?: Record<string, string>;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export type LSMLNode =
|
|
175
|
+
| LSMLStack
|
|
176
|
+
| LSMLGrid
|
|
177
|
+
| LSMLFrame
|
|
178
|
+
| LSMLText
|
|
179
|
+
| LSMLImage
|
|
180
|
+
| LSMLShape
|
|
181
|
+
| LSMLMedia
|
|
182
|
+
| LSMLRepeat
|
|
183
|
+
| LSMLInstance;
|
|
184
|
+
|
|
185
|
+
export interface LSMLOperatorInput {
|
|
186
|
+
path: string;
|
|
187
|
+
label: string;
|
|
188
|
+
type: string;
|
|
189
|
+
constraints?: Record<string, unknown>;
|
|
190
|
+
writable_by: string[];
|
|
191
|
+
group?: string;
|
|
192
|
+
[extra: string]: unknown;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface LSMLBundle {
|
|
196
|
+
lsml: "1.0" | "1.1";
|
|
197
|
+
/** 1.1+ — informational schema URL for editor autocomplete (LSML §18.4). */
|
|
198
|
+
$schema?: string;
|
|
199
|
+
scene_id: string;
|
|
200
|
+
scene_version: string;
|
|
201
|
+
/** 1.1+ — capability profiles the bundle requires (LSML §17.3). */
|
|
202
|
+
profiles?: string[];
|
|
203
|
+
layout: LSMLNode;
|
|
204
|
+
operator_inputs?: LSMLOperatorInput[];
|
|
205
|
+
external_adapters?: unknown[];
|
|
206
|
+
defaults?: Record<string, unknown>;
|
|
207
|
+
assets?: { allowedHosts?: string[]; fonts?: unknown[]; preload?: string[] };
|
|
208
|
+
i18n?: { default_locale?: string; locales?: Record<string, Record<string, string>> };
|
|
209
|
+
metadata?: Record<string, unknown>;
|
|
210
|
+
}
|