@viewscript/renderer 0.1.0-202605140639

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 (89) hide show
  1. package/dist/ast/types.d.ts +403 -0
  2. package/dist/ast/types.js +33 -0
  3. package/dist/compiler/chunk-splitter.d.ts +98 -0
  4. package/dist/compiler/chunk-splitter.js +361 -0
  5. package/dist/index.d.ts +55 -0
  6. package/dist/index.js +17 -0
  7. package/dist/rasterizer/__tests__/error-distribution.test.d.ts +7 -0
  8. package/dist/rasterizer/__tests__/error-distribution.test.js +322 -0
  9. package/dist/rasterizer/canvas-mapper.d.ts +280 -0
  10. package/dist/rasterizer/canvas-mapper.js +414 -0
  11. package/dist/rasterizer/error-distribution.d.ts +143 -0
  12. package/dist/rasterizer/error-distribution.js +231 -0
  13. package/dist/rasterizer/gradient-mapper.d.ts +223 -0
  14. package/dist/rasterizer/gradient-mapper.js +352 -0
  15. package/dist/rasterizer/topology-rounding.d.ts +151 -0
  16. package/dist/rasterizer/topology-rounding.js +347 -0
  17. package/dist/runtime/__tests__/event-backpressure.test.d.ts +10 -0
  18. package/dist/runtime/__tests__/event-backpressure.test.js +190 -0
  19. package/dist/runtime/event-backpressure.d.ts +393 -0
  20. package/dist/runtime/event-backpressure.js +458 -0
  21. package/dist/runtime/render-loop.d.ts +277 -0
  22. package/dist/runtime/render-loop.js +435 -0
  23. package/dist/runtime/wasm-resource-manager.d.ts +122 -0
  24. package/dist/runtime/wasm-resource-manager.js +253 -0
  25. package/dist/runtime/wgpu-renderer-adapter.d.ts +168 -0
  26. package/dist/runtime/wgpu-renderer-adapter.js +230 -0
  27. package/dist/semantic/__tests__/semantic-translator.test.d.ts +4 -0
  28. package/dist/semantic/__tests__/semantic-translator.test.js +203 -0
  29. package/dist/semantic/semantic-translator.d.ts +229 -0
  30. package/dist/semantic/semantic-translator.js +398 -0
  31. package/package.json +28 -0
  32. package/playwright-report/data/0bafe4e0863f0e244bba68a838f73241f8f2efaa.md +226 -0
  33. package/playwright-report/data/9281aca8abfb06c6cecb35d5ddd13d61f8c752d8.md +226 -0
  34. package/playwright-report/index.html +90 -0
  35. package/playwright.config.ts +160 -0
  36. package/screenshot-chrome.png +0 -0
  37. package/screenshots/visual-demo-verification.png +0 -0
  38. package/screenshots/visual-demo.png +0 -0
  39. package/src/ast/types.ts +473 -0
  40. package/src/compiler/chunk-splitter.ts +534 -0
  41. package/src/index.ts +62 -0
  42. package/src/rasterizer/__tests__/error-distribution.test.ts +382 -0
  43. package/src/rasterizer/canvas-mapper.ts +677 -0
  44. package/src/rasterizer/error-distribution.ts +344 -0
  45. package/src/rasterizer/gradient-mapper.ts +563 -0
  46. package/src/rasterizer/topology-rounding.ts +499 -0
  47. package/src/runtime/__tests__/event-backpressure.test.ts +254 -0
  48. package/src/runtime/event-backpressure.ts +622 -0
  49. package/src/runtime/render-loop.ts +660 -0
  50. package/src/runtime/wasm-resource-manager.ts +349 -0
  51. package/src/runtime/wgpu-renderer-adapter.ts +318 -0
  52. package/src/semantic/__tests__/semantic-translator.test.ts +263 -0
  53. package/src/semantic/semantic-translator.ts +637 -0
  54. package/test-results/.last-run.json +4 -0
  55. package/tests/e2e/async-race.spec.ts +612 -0
  56. package/tests/e2e/bilayer-sync.spec.ts +405 -0
  57. package/tests/e2e/failures/.gitkeep +0 -0
  58. package/tests/e2e/fullstack.spec.ts +681 -0
  59. package/tests/e2e/g1-continuity.spec.ts +703 -0
  60. package/tests/e2e/golden/.gitkeep +0 -0
  61. package/tests/e2e/golden/conic-color-wheel.raw +0 -0
  62. package/tests/e2e/golden/conic-color-wheel.sha256 +1 -0
  63. package/tests/e2e/golden/conic-rotated.raw +0 -0
  64. package/tests/e2e/golden/conic-rotated.sha256 +1 -0
  65. package/tests/e2e/golden/linear-45deg.raw +0 -0
  66. package/tests/e2e/golden/linear-45deg.sha256 +1 -0
  67. package/tests/e2e/golden/linear-horizontal.raw +0 -0
  68. package/tests/e2e/golden/linear-horizontal.sha256 +1 -0
  69. package/tests/e2e/golden/linear-multi-stop.raw +0 -0
  70. package/tests/e2e/golden/linear-multi-stop.sha256 +1 -0
  71. package/tests/e2e/golden/radial-circle-center.raw +0 -0
  72. package/tests/e2e/golden/radial-circle-center.sha256 +1 -0
  73. package/tests/e2e/golden/radial-offset.raw +0 -0
  74. package/tests/e2e/golden/radial-offset.sha256 +1 -0
  75. package/tests/e2e/golden/tile-mirror.raw +0 -0
  76. package/tests/e2e/golden/tile-mirror.sha256 +1 -0
  77. package/tests/e2e/golden/tile-repeat.raw +0 -0
  78. package/tests/e2e/golden/tile-repeat.sha256 +1 -0
  79. package/tests/e2e/gradient-animation.spec.ts +606 -0
  80. package/tests/e2e/memory-stability.spec.ts +396 -0
  81. package/tests/e2e/path-topology.spec.ts +674 -0
  82. package/tests/e2e/performance-profile.spec.ts +501 -0
  83. package/tests/e2e/screenshot.spec.ts +60 -0
  84. package/tests/e2e/test-harness.html +1005 -0
  85. package/tests/e2e/text-layout.spec.ts +451 -0
  86. package/tests/e2e/visual-demo.html +340 -0
  87. package/tests/e2e/visual-regression.spec.ts +335 -0
  88. package/tsconfig.json +12 -0
  89. package/vitest.config.ts +8 -0
@@ -0,0 +1,403 @@
1
+ /**
2
+ * ViewScript Renderer AST: Bilayer Orthogonal Architecture
3
+ *
4
+ * This module defines the type system for the dual-layer rendering model:
5
+ * - Canvas Layer: Visual representation (wgpu draw commands)
6
+ * - DOM Layer: Interaction regions (accessibility, events, focus)
7
+ *
8
+ * ## Architectural Invariants
9
+ *
10
+ * 1. Every logical entity has exactly one EntityId
11
+ * 2. An entity MAY have a CanvasNode (visual), a DOMNode (interactive), or both
12
+ * 3. Canvas and DOM nodes are synchronized via shared EntityId
13
+ * 4. DOM nodes have NO visual properties; Canvas nodes have NO interaction logic
14
+ *
15
+ * ## Data Flow
16
+ *
17
+ * ```
18
+ * IR (.vs) Renderer AST
19
+ * ────────────────────────────────────────────────────────
20
+ *
21
+ * ┌─────────────┐ ┌─────────────────────────────┐
22
+ * │ Constraint │ │ RenderableEntity │
23
+ * │ Graph │ ──▶ │ ┌─────────┐ ┌───────────┐ │
24
+ * │ (P-dim) │ │ │ Canvas │ │ DOM │ │
25
+ * └─────────────┘ │ │ Node │ │ Node │ │
26
+ * │ └─────────┘ └───────────┘ │
27
+ * │ ▲ ▲ │
28
+ * │ └─────┬─────┘ │
29
+ * │ EntityId │
30
+ * └─────────────────────────────┘
31
+ * ```
32
+ */
33
+ /** Unique identifier for all P-dimension entities. */
34
+ export type EntityId = number;
35
+ /** Unique identifier for constraints. */
36
+ export type ConstraintId = number;
37
+ /** Unique identifier for render chunks (for progressive loading). */
38
+ export type ChunkId = string;
39
+ /**
40
+ * Rational number representation for exact arithmetic.
41
+ * Used before rasterization to pixel coordinates.
42
+ */
43
+ export interface Rational {
44
+ numerator: bigint;
45
+ denominator: bigint;
46
+ }
47
+ /**
48
+ * P-dimension vector with exact rational coordinates.
49
+ * T is included for animation/state-dependent positioning.
50
+ */
51
+ export interface PVector {
52
+ x: Rational;
53
+ y: Rational;
54
+ z: Rational;
55
+ t: Rational;
56
+ }
57
+ /**
58
+ * Rasterized coordinates for actual rendering.
59
+ * Produced by the topology-preserving rounding algorithm.
60
+ */
61
+ export interface RasterCoord {
62
+ /** X in device pixels */
63
+ x: number;
64
+ /** Y in device pixels */
65
+ y: number;
66
+ /** Z-index for layering */
67
+ zIndex: number;
68
+ }
69
+ /**
70
+ * Base interface for all Canvas layer nodes.
71
+ * These produce wgpu draw commands.
72
+ */
73
+ export interface CanvasNodeBase {
74
+ /** Discriminant for node type */
75
+ readonly kind: string;
76
+ /** Back-reference to logical entity */
77
+ entityId: EntityId;
78
+ /** Pre-rasterization coordinates */
79
+ bounds: PVectorBounds;
80
+ /** Rasterized coordinates (computed by rounding algorithm) */
81
+ rasterBounds: RasterBounds;
82
+ /** Z-order for painter's algorithm */
83
+ zOrder: number;
84
+ /** Chunk this node belongs to (for progressive loading) */
85
+ chunkId: ChunkId;
86
+ }
87
+ export interface PVectorBounds {
88
+ topLeft: PVector;
89
+ bottomRight: PVector;
90
+ }
91
+ export interface RasterBounds {
92
+ x: number;
93
+ y: number;
94
+ width: number;
95
+ height: number;
96
+ }
97
+ /**
98
+ * Path-based canvas node (curves, shapes).
99
+ */
100
+ export interface CanvasPathNode extends CanvasNodeBase {
101
+ kind: 'path';
102
+ /** SVG-like path commands, pre-compiled */
103
+ pathData: PathCommand[];
104
+ /** Fill style (solid, gradient, pattern) */
105
+ fill: FillStyle | null;
106
+ /** Stroke style */
107
+ stroke: StrokeStyle | null;
108
+ }
109
+ export type PathCommand = {
110
+ type: 'M';
111
+ x: Rational;
112
+ y: Rational;
113
+ } | {
114
+ type: 'L';
115
+ x: Rational;
116
+ y: Rational;
117
+ } | {
118
+ type: 'C';
119
+ x1: Rational;
120
+ y1: Rational;
121
+ x2: Rational;
122
+ y2: Rational;
123
+ x: Rational;
124
+ y: Rational;
125
+ } | {
126
+ type: 'Q';
127
+ x1: Rational;
128
+ y1: Rational;
129
+ x: Rational;
130
+ y: Rational;
131
+ } | {
132
+ type: 'A';
133
+ rx: Rational;
134
+ ry: Rational;
135
+ rotation: number;
136
+ largeArc: boolean;
137
+ sweep: boolean;
138
+ x: Rational;
139
+ y: Rational;
140
+ } | {
141
+ type: 'Z';
142
+ };
143
+ export interface FillStyle {
144
+ type: 'solid' | 'linear-gradient' | 'radial-gradient' | 'pattern';
145
+ color?: string;
146
+ stops?: GradientStop[];
147
+ patternRef?: EntityId;
148
+ }
149
+ export interface GradientStop {
150
+ offset: Rational;
151
+ color: string;
152
+ }
153
+ export interface StrokeStyle {
154
+ color: string;
155
+ width: Rational;
156
+ lineCap: 'butt' | 'round' | 'square';
157
+ lineJoin: 'miter' | 'round' | 'bevel';
158
+ dashArray?: Rational[];
159
+ }
160
+ /**
161
+ * Text canvas node.
162
+ */
163
+ export interface CanvasTextNode extends CanvasNodeBase {
164
+ kind: 'text';
165
+ /** Text content (may be Q-dimension bound) */
166
+ content: string | QDimensionRef;
167
+ /** Font specification */
168
+ font: FontSpec;
169
+ /** Text layout results (computed) */
170
+ glyphs: GlyphRun[];
171
+ }
172
+ export interface FontSpec {
173
+ family: string;
174
+ size: Rational;
175
+ weight: number;
176
+ style: 'normal' | 'italic' | 'oblique';
177
+ }
178
+ export interface GlyphRun {
179
+ glyphIds: number[];
180
+ positions: RasterCoord[];
181
+ }
182
+ /**
183
+ * Image canvas node (Q-dimension source).
184
+ */
185
+ export interface CanvasImageNode extends CanvasNodeBase {
186
+ kind: 'image';
187
+ /** Reference to Q-dimension image source */
188
+ source: QDimensionRef;
189
+ /** How to fit the image in bounds */
190
+ fit: 'fill' | 'contain' | 'cover' | 'none';
191
+ }
192
+ /**
193
+ * Group node for hierarchical transforms.
194
+ */
195
+ export interface CanvasGroupNode extends CanvasNodeBase {
196
+ kind: 'group';
197
+ /** Child nodes */
198
+ children: CanvasNode[];
199
+ /** Transform matrix (2D affine) */
200
+ transform: AffineTransform;
201
+ /** Clip path (optional) */
202
+ clipPath?: PathCommand[];
203
+ /** Opacity (0-1) */
204
+ opacity: number;
205
+ }
206
+ export interface AffineTransform {
207
+ a: number;
208
+ b: number;
209
+ c: number;
210
+ d: number;
211
+ tx: number;
212
+ ty: number;
213
+ }
214
+ export type CanvasNode = CanvasPathNode | CanvasTextNode | CanvasImageNode | CanvasGroupNode;
215
+ /**
216
+ * Base interface for all DOM layer nodes.
217
+ * These produce invisible DOM elements for interaction.
218
+ */
219
+ export interface DOMNodeBase {
220
+ /** Discriminant for node type */
221
+ readonly kind: string;
222
+ /** Back-reference to logical entity (MUST match CanvasNode if paired) */
223
+ entityId: EntityId;
224
+ /** Position synchronized with Canvas layer */
225
+ rasterBounds: RasterBounds;
226
+ /** ARIA attributes for accessibility */
227
+ aria: ARIAAttributes;
228
+ /** Tab index for keyboard navigation (-1 = not focusable) */
229
+ tabIndex: number;
230
+ }
231
+ export interface ARIAAttributes {
232
+ role?: string;
233
+ label?: string;
234
+ describedBy?: EntityId;
235
+ labelledBy?: EntityId;
236
+ hidden?: boolean;
237
+ expanded?: boolean;
238
+ selected?: boolean;
239
+ checked?: boolean | 'mixed';
240
+ disabled?: boolean;
241
+ live?: 'off' | 'polite' | 'assertive';
242
+ }
243
+ /**
244
+ * Interactive region (clickable, focusable).
245
+ */
246
+ export interface DOMInteractiveNode extends DOMNodeBase {
247
+ kind: 'interactive';
248
+ /** Event bindings (Q-dimension triggers) */
249
+ events: EventBinding[];
250
+ /** Cursor style when hovering */
251
+ cursor: string;
252
+ }
253
+ export interface EventBinding {
254
+ /** DOM event type */
255
+ type: 'click' | 'pointerdown' | 'pointerup' | 'pointermove' | 'focus' | 'blur' | 'keydown' | 'keyup';
256
+ /** Constraint to update on event (T-vector mutation) */
257
+ targetConstraint: ConstraintId;
258
+ /** How to compute the new value */
259
+ valueMapping: EventValueMapping;
260
+ }
261
+ export type EventValueMapping = {
262
+ type: 'constant';
263
+ value: Rational;
264
+ } | {
265
+ type: 'toggle';
266
+ values: [Rational, Rational];
267
+ } | {
268
+ type: 'increment';
269
+ delta: Rational;
270
+ } | {
271
+ type: 'pointer-x';
272
+ } | {
273
+ type: 'pointer-y';
274
+ } | {
275
+ type: 'pointer-delta-x';
276
+ } | {
277
+ type: 'pointer-delta-y';
278
+ };
279
+ /**
280
+ * Text input region.
281
+ */
282
+ export interface DOMInputNode extends DOMNodeBase {
283
+ kind: 'input';
284
+ /** Input type */
285
+ inputType: 'text' | 'number' | 'password' | 'email' | 'search';
286
+ /** Constraint bound to input value */
287
+ valueConstraint: ConstraintId;
288
+ /** Placeholder text */
289
+ placeholder?: string;
290
+ /** Max length */
291
+ maxLength?: number;
292
+ }
293
+ /**
294
+ * Scroll container region.
295
+ */
296
+ export interface DOMScrollNode extends DOMNodeBase {
297
+ kind: 'scroll';
298
+ /** Scroll direction */
299
+ direction: 'horizontal' | 'vertical' | 'both';
300
+ /** Constraints bound to scroll position */
301
+ scrollXConstraint?: ConstraintId;
302
+ scrollYConstraint?: ConstraintId;
303
+ /** Content size (for scrollbar calculation) */
304
+ contentSize: {
305
+ width: Rational;
306
+ height: Rational;
307
+ };
308
+ }
309
+ /**
310
+ * Focus trap region (for modals, dialogs).
311
+ */
312
+ export interface DOMFocusTrapNode extends DOMNodeBase {
313
+ kind: 'focus-trap';
314
+ /** First and last focusable children */
315
+ focusableChildren: EntityId[];
316
+ }
317
+ export type DOMNode = DOMInteractiveNode | DOMInputNode | DOMScrollNode | DOMFocusTrapNode;
318
+ /**
319
+ * Reference to Q-dimension (unpredictable) data.
320
+ */
321
+ export interface QDimensionRef {
322
+ /** Type of Q-dimension source */
323
+ type: 'user-input' | 'fetch' | 'image' | 'video' | 'audio' | 'shader' | 'time';
324
+ /** Source identifier */
325
+ sourceId: string;
326
+ /** Current value (runtime state, not in IR) */
327
+ currentValue?: unknown;
328
+ }
329
+ /**
330
+ * A complete renderable entity combining Canvas and DOM representations.
331
+ *
332
+ * ## Pairing Rules
333
+ *
334
+ * | Entity Type | Canvas Node | DOM Node |
335
+ * |-----------------|-------------|-------------|
336
+ * | Static shape | Required | None |
337
+ * | Button | Required | Required |
338
+ * | Text input | Required | Required |
339
+ * | Decorative img | Required | None |
340
+ * | Interactive img | Required | Required |
341
+ * | Scroll area | Optional | Required |
342
+ * | Focus trap | None | Required |
343
+ */
344
+ export interface RenderableEntity {
345
+ /** Unique identifier */
346
+ id: EntityId;
347
+ /** Human-readable name (for debugging) */
348
+ name?: string;
349
+ /** Canvas layer representation (visual) */
350
+ canvas: CanvasNode | null;
351
+ /** DOM layer representation (interactive) */
352
+ dom: DOMNode | null;
353
+ /** Constraints that affect this entity */
354
+ dependentConstraints: ConstraintId[];
355
+ /** Entities that this entity references */
356
+ referencedEntities: EntityId[];
357
+ /** Chunk membership */
358
+ chunkId: ChunkId;
359
+ }
360
+ /**
361
+ * The complete render tree produced by the compiler.
362
+ */
363
+ export interface RenderTree {
364
+ /** All renderable entities, indexed by EntityId */
365
+ entities: Map<EntityId, RenderableEntity>;
366
+ /** Root entity IDs (top-level elements) */
367
+ roots: EntityId[];
368
+ /** Chunk definitions for progressive loading */
369
+ chunks: Map<ChunkId, Chunk>;
370
+ /** Viewport configuration */
371
+ viewport: ViewportConfig;
372
+ /** Device pixel ratio for rasterization */
373
+ devicePixelRatio: number;
374
+ }
375
+ export interface Chunk {
376
+ id: ChunkId;
377
+ /** Entities in this chunk */
378
+ entityIds: EntityId[];
379
+ /** Dependencies on other chunks */
380
+ dependsOn: ChunkId[];
381
+ /** Is this the initial chunk? */
382
+ isInitial: boolean;
383
+ /** Trigger conditions for lazy loading */
384
+ loadTriggers: LoadTrigger[];
385
+ }
386
+ export type LoadTrigger = {
387
+ type: 'immediate';
388
+ } | {
389
+ type: 'viewport-intersect';
390
+ entityId: EntityId;
391
+ } | {
392
+ type: 'event';
393
+ eventType: string;
394
+ targetEntity: EntityId;
395
+ } | {
396
+ type: 'constraint-change';
397
+ constraintId: ConstraintId;
398
+ };
399
+ export interface ViewportConfig {
400
+ width: Rational;
401
+ height: Rational;
402
+ unitsPerPixel: Rational;
403
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * ViewScript Renderer AST: Bilayer Orthogonal Architecture
3
+ *
4
+ * This module defines the type system for the dual-layer rendering model:
5
+ * - Canvas Layer: Visual representation (wgpu draw commands)
6
+ * - DOM Layer: Interaction regions (accessibility, events, focus)
7
+ *
8
+ * ## Architectural Invariants
9
+ *
10
+ * 1. Every logical entity has exactly one EntityId
11
+ * 2. An entity MAY have a CanvasNode (visual), a DOMNode (interactive), or both
12
+ * 3. Canvas and DOM nodes are synchronized via shared EntityId
13
+ * 4. DOM nodes have NO visual properties; Canvas nodes have NO interaction logic
14
+ *
15
+ * ## Data Flow
16
+ *
17
+ * ```
18
+ * IR (.vs) Renderer AST
19
+ * ────────────────────────────────────────────────────────
20
+ *
21
+ * ┌─────────────┐ ┌─────────────────────────────┐
22
+ * │ Constraint │ │ RenderableEntity │
23
+ * │ Graph │ ──▶ │ ┌─────────┐ ┌───────────┐ │
24
+ * │ (P-dim) │ │ │ Canvas │ │ DOM │ │
25
+ * └─────────────┘ │ │ Node │ │ Node │ │
26
+ * │ └─────────┘ └───────────┘ │
27
+ * │ ▲ ▲ │
28
+ * │ └─────┬─────┘ │
29
+ * │ EntityId │
30
+ * └─────────────────────────────┘
31
+ * ```
32
+ */
33
+ export {};
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Chunk Splitting Strategy for Progressive Loading
3
+ *
4
+ * This module implements static analysis to partition the constraint graph
5
+ * into Initial and Lazy chunks, enabling Qwik/Wiz-style progressive hydration.
6
+ *
7
+ * ## Core Principle: T-Vector Reachability Analysis
8
+ *
9
+ * An entity belongs to the Initial Chunk if and only if:
10
+ * 1. It is visible at T=0 (initial render time), AND
11
+ * 2. It is reachable from the viewport bounds at T=0
12
+ *
13
+ * An entity belongs to a Lazy Chunk if:
14
+ * 1. It becomes visible only after T changes (user interaction), OR
15
+ * 2. It is outside the initial viewport (below the fold), OR
16
+ * 3. It depends on Q-dimension data that hasn't loaded yet
17
+ *
18
+ * ## Algorithm Overview
19
+ *
20
+ * ```
21
+ * INPUT: Constraint Graph G = (Entities, Constraints)
22
+ * Viewport V = (width, height)
23
+ * Initial Time T₀ = 0
24
+ *
25
+ * OUTPUT: Partition P = { Chunk₀ (initial), Chunk₁, Chunk₂, ... }
26
+ *
27
+ * ALGORITHM:
28
+ * 1. Evaluate all constraints at T=T₀ to get initial positions
29
+ * 2. Mark entities intersecting V as "initially visible"
30
+ * 3. For each Q-dimension binding (event handler):
31
+ * a. Trace which constraints are affected when event fires
32
+ * b. Group affected entities into event-specific lazy chunks
33
+ * 4. For entities below the fold:
34
+ * a. Create viewport-intersection lazy chunks
35
+ * 5. Compute chunk dependency DAG
36
+ * ```
37
+ */
38
+ import type { EntityId, ConstraintId, ChunkId, Chunk, Rational } from '../ast/types';
39
+ interface IRConstraint {
40
+ id: ConstraintId;
41
+ target: EntityId;
42
+ component: 'x' | 'y' | 'z' | 't';
43
+ relation: 'eq' | 'lt' | 'le' | 'gt' | 'ge';
44
+ term: IRConstraintTerm;
45
+ }
46
+ type IRConstraintTerm = {
47
+ type: 'const';
48
+ value: Rational;
49
+ } | {
50
+ type: 'ref';
51
+ entityId: EntityId;
52
+ component: 'x' | 'y' | 'z' | 't';
53
+ } | {
54
+ type: 'linear';
55
+ coefficient: Rational;
56
+ entityId: EntityId;
57
+ component: 'x' | 'y' | 'z' | 't';
58
+ offset: Rational;
59
+ };
60
+ interface IRModule {
61
+ entities: EntityId[];
62
+ constraints: IRConstraint[];
63
+ eventBindings: EventBinding[];
64
+ imports: IRImport[];
65
+ }
66
+ interface EventBinding {
67
+ sourceEntity: EntityId;
68
+ eventType: string;
69
+ targetConstraint: ConstraintId;
70
+ }
71
+ interface IRImport {
72
+ path: string;
73
+ exportedEntities: EntityId[];
74
+ }
75
+ interface ViewportBounds {
76
+ x: number;
77
+ y: number;
78
+ width: number;
79
+ height: number;
80
+ }
81
+ /**
82
+ * Static analysis result for chunk splitting.
83
+ */
84
+ export interface ChunkSplitResult {
85
+ /** The initial chunk (loaded immediately) */
86
+ initialChunk: Chunk;
87
+ /** Lazy chunks (loaded on demand) */
88
+ lazyChunks: Chunk[];
89
+ /** Mapping from entity to chunk */
90
+ entityToChunk: Map<EntityId, ChunkId>;
91
+ /** Chunk dependency DAG */
92
+ chunkDependencies: Map<ChunkId, Set<ChunkId>>;
93
+ }
94
+ /**
95
+ * Main chunk splitting function.
96
+ */
97
+ export declare function splitIntoChunks(ir: IRModule, viewport: ViewportBounds): ChunkSplitResult;
98
+ export {};