@lumencast/compiler 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.
package/src/index.ts CHANGED
@@ -1,20 +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
- LSMLOperatorInput,
20
- } 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,156 +1,197 @@
1
- // LSML 1.0 input types — what authors write.
2
- // Reference: lumencast-protocol/spec/LSML-1.md
3
-
4
- export type LSMLPrimitiveKind =
5
- | "stack"
6
- | "grid"
7
- | "frame"
8
- | "text"
9
- | "image"
10
- | "shape"
11
- | "media"
12
- | "repeat";
13
-
14
- export interface LSMLBindObject {
15
- /** Most primitives bind a `value` to a leaf path. */
16
- value?: string;
17
- /** image / media bind a `src`. */
18
- src?: string;
19
- /** repeat binds `items`. */
20
- items?: string;
21
- }
22
-
23
- export interface LSMLAnimateDirective {
24
- transition?: {
25
- duration?: number;
26
- easing?: "linear" | "ease-in" | "ease-out" | "ease-in-out" | "spring";
27
- stiffness?: number;
28
- damping?: number;
29
- };
30
- transform?: {
31
- translate?: [number, number];
32
- scale?: number | [number, number];
33
- rotate?: number;
34
- };
35
- opacity?: number;
36
- filter?: {
37
- blur?: number;
38
- brightness?: number;
39
- };
40
- }
41
-
42
- export interface LSMLBaseNode {
43
- kind: LSMLPrimitiveKind;
44
- id?: string;
45
- bind?: LSMLBindObject;
46
- bindStyle?: Record<string, string>;
47
- animate?: LSMLAnimateDirective;
48
- children?: LSMLNode[];
49
- }
50
-
51
- export interface LSMLStack extends LSMLBaseNode {
52
- kind: "stack";
53
- direction?: "horizontal" | "vertical";
54
- gap?: number;
55
- align?: "start" | "center" | "end" | "stretch";
56
- justify?: "start" | "center" | "end" | "space-between" | "space-around";
57
- padding?: number | [number, number, number, number];
58
- rtl?: "auto" | boolean;
59
- }
60
-
61
- export interface LSMLGrid extends LSMLBaseNode {
62
- kind: "grid";
63
- columns: number | unknown[];
64
- rows?: number | unknown[];
65
- gap?: number | [number, number];
66
- padding?: number | unknown[];
67
- }
68
-
69
- export interface LSMLFrame extends LSMLBaseNode {
70
- kind: "frame";
71
- size?: { w: number; h: number };
72
- position?: { x: number; y: number };
73
- background?: string;
74
- }
75
-
76
- export interface LSMLText extends LSMLBaseNode {
77
- kind: "text";
78
- style?: {
79
- fontSize?: number | string;
80
- fontWeight?: number;
81
- color?: string;
82
- textAlign?: "start" | "center" | "end" | "left" | "right";
83
- lineHeight?: number;
84
- };
85
- format?: { kind: string; [extra: string]: unknown };
86
- maxLines?: number;
87
- }
88
-
89
- export interface LSMLImage extends LSMLBaseNode {
90
- kind: "image";
91
- alt: string;
92
- size: { w: number; h: number };
93
- fit?: "contain" | "cover" | "fill" | "none";
94
- }
95
-
96
- export interface LSMLShape extends LSMLBaseNode {
97
- kind: "shape";
98
- geometry: "rect" | "circle" | "path";
99
- size?: { w: number; h: number };
100
- pathData?: string;
101
- fill?: string;
102
- stroke?: { color: string; width: number };
103
- cornerRadius?: number;
104
- ariaLabel?: string;
105
- }
106
-
107
- export interface LSMLMedia extends LSMLBaseNode {
108
- kind: "media";
109
- kind_hint: "video" | "audio";
110
- controls?: boolean;
111
- autoplay?: boolean;
112
- muted?: boolean;
113
- loop?: boolean;
114
- size?: { w: number; h: number };
115
- }
116
-
117
- export interface LSMLRepeat extends LSMLBaseNode {
118
- kind: "repeat";
119
- scope: string;
120
- key?: string;
121
- template: LSMLNode;
122
- limit?: number;
123
- }
124
-
125
- export type LSMLNode =
126
- | LSMLStack
127
- | LSMLGrid
128
- | LSMLFrame
129
- | LSMLText
130
- | LSMLImage
131
- | LSMLShape
132
- | LSMLMedia
133
- | LSMLRepeat;
134
-
135
- export interface LSMLOperatorInput {
136
- path: string;
137
- label: string;
138
- type: string;
139
- constraints?: Record<string, unknown>;
140
- writable_by: string[];
141
- group?: string;
142
- [extra: string]: unknown;
143
- }
144
-
145
- export interface LSMLBundle {
146
- lsml: "1.0";
147
- scene_id: string;
148
- scene_version: string;
149
- layout: LSMLNode;
150
- operator_inputs?: LSMLOperatorInput[];
151
- external_adapters?: unknown[];
152
- defaults?: Record<string, unknown>;
153
- assets?: { allowedHosts?: string[]; fonts?: unknown[]; preload?: string[] };
154
- i18n?: { default_locale?: string; locales?: Record<string, Record<string, string>> };
155
- metadata?: Record<string, unknown>;
156
- }
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
+ }