@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/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
- export interface LSMLAnimateDirective {
34
- transition?: {
35
- duration?: number;
36
- easing?: "linear" | "ease-in" | "ease-out" | "ease-in-out" | "spring";
37
- stiffness?: number;
38
- damping?: number;
39
- };
40
- transform?: {
41
- translate?: [number, number];
42
- scale?: number | [number, number];
43
- rotate?: number;
44
- };
45
- opacity?: number;
46
- filter?: {
47
- blur?: number;
48
- brightness?: number;
49
- };
50
- }
51
-
52
- export interface LSMLBaseNode {
53
- kind: LSMLPrimitiveKind;
54
- id?: string;
55
- bind?: LSMLBindObject;
56
- bindStyle?: Record<string, string>;
57
- /** 1.1+bind universal props to leaf paths. */
58
- bindUniversal?: Record<string, string>;
59
- animate?: LSMLAnimateDirective;
60
- children?: LSMLNode[];
61
- /** 1.1+ — visibility flag (LSML §5.4). Defaults to true. */
62
- visible?: boolean;
63
- /** 1.1+ — opacity 0..1 (LSML §5.4). Defaults to 1. */
64
- opacity?: number;
65
- /** 1.1+ — rotation in degrees (LSML §5.4). Defaults to 0. */
66
- rotation?: number;
67
- /** 1.1+ — per-axis sizing mode (LSML §5.4). */
68
- sizing?: { x?: "fixed" | "hug" | "fill"; y?: "fixed" | "hug" | "fill" };
69
- /** 1.1+ — universal position relative to parent (LSML §5.4). */
70
- position?: { x: number; y: number };
71
- /** Open-ended authoring metadata (LSML §17.4). Runtime ignores. */
72
- metadata?: Record<string, unknown>;
73
- }
74
-
75
- export interface LSMLStack extends LSMLBaseNode {
76
- kind: "stack";
77
- direction?: "horizontal" | "vertical";
78
- gap?: number;
79
- align?: "start" | "center" | "end" | "stretch";
80
- justify?: "start" | "center" | "end" | "space-between" | "space-around";
81
- padding?: number | [number, number, number, number];
82
- rtl?: "auto" | boolean;
83
- }
84
-
85
- export interface LSMLGrid extends LSMLBaseNode {
86
- kind: "grid";
87
- columns: number | unknown[];
88
- rows?: number | unknown[];
89
- gap?: number | [number, number];
90
- padding?: number | unknown[];
91
- }
92
-
93
- export interface LSMLFrame extends LSMLBaseNode {
94
- kind: "frame";
95
- size?: { w: number; h: number };
96
- position?: { x: number; y: number };
97
- background?: string;
98
- }
99
-
100
- export interface LSMLText extends LSMLBaseNode {
101
- kind: "text";
102
- style?: {
103
- fontSize?: number | string;
104
- fontWeight?: number;
105
- color?: string;
106
- textAlign?: "start" | "center" | "end" | "left" | "right";
107
- lineHeight?: number;
108
- };
109
- format?: { kind: string; [extra: string]: unknown };
110
- maxLines?: number;
111
- }
112
-
113
- export interface LSMLImage extends LSMLBaseNode {
114
- kind: "image";
115
- alt: string;
116
- size: { w: number; h: number };
117
- fit?: "contain" | "cover" | "fill" | "none";
118
- }
119
-
120
- export interface LSMLShape extends LSMLBaseNode {
121
- kind: "shape";
122
- geometry: "rect" | "circle" | "path";
123
- size?: { w: number; h: number };
124
- pathData?: string;
125
- fill?: string;
126
- stroke?: { color: string; width: number };
127
- cornerRadius?: number;
128
- ariaLabel?: string;
129
- }
130
-
131
- export interface LSMLMedia extends LSMLBaseNode {
132
- kind: "media";
133
- kind_hint: "video" | "audio";
134
- controls?: boolean;
135
- autoplay?: boolean;
136
- muted?: boolean;
137
- loop?: boolean;
138
- size?: { w: number; h: number };
139
- }
140
-
141
- export interface LSMLRepeat extends LSMLBaseNode {
142
- kind: "repeat";
143
- scope: string;
144
- key?: string;
145
- template: LSMLNode;
146
- limit?: number;
147
- }
148
-
149
- /** 1.1+ — `instance` primitive (LSML §4.9). Mounts a sub-scene by id with
150
- * bound parameters. */
151
- export interface LSMLInstance extends LSMLBaseNode {
152
- kind: "instance";
153
- scene_id: string;
154
- scene_version: string;
155
- size?: { w: number; h: number };
156
- fit?: "contain" | "cover" | "stretch";
157
- params?: Record<string, unknown>;
158
- bindParams?: Record<string, string>;
159
- }
160
-
161
- export type LSMLNode =
162
- | LSMLStack
163
- | LSMLGrid
164
- | LSMLFrame
165
- | LSMLText
166
- | LSMLImage
167
- | LSMLShape
168
- | LSMLMedia
169
- | LSMLRepeat
170
- | LSMLInstance;
171
-
172
- export interface LSMLOperatorInput {
173
- path: string;
174
- label: string;
175
- type: string;
176
- constraints?: Record<string, unknown>;
177
- writable_by: string[];
178
- group?: string;
179
- [extra: string]: unknown;
180
- }
181
-
182
- export interface LSMLBundle {
183
- lsml: "1.0" | "1.1";
184
- /** 1.1+ — informational schema URL for editor autocomplete (LSML §18.4). */
185
- $schema?: string;
186
- scene_id: string;
187
- scene_version: string;
188
- /** 1.1+ — capability profiles the bundle requires (LSML §17.3). */
189
- profiles?: string[];
190
- layout: LSMLNode;
191
- operator_inputs?: LSMLOperatorInput[];
192
- external_adapters?: unknown[];
193
- defaults?: Record<string, unknown>;
194
- assets?: { allowedHosts?: string[]; fonts?: unknown[]; preload?: string[] };
195
- i18n?: { default_locale?: string; locales?: Record<string, Record<string, string>> };
196
- metadata?: Record<string, unknown>;
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
+ }