cinematic-renderer2d 0.1.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/LICENSE +21 -0
- package/README.md +827 -0
- package/dist/angular.cjs +189 -0
- package/dist/angular.cjs.map +1 -0
- package/dist/angular.d.cts +577 -0
- package/dist/angular.d.ts +577 -0
- package/dist/angular.js +189 -0
- package/dist/angular.js.map +1 -0
- package/dist/cli/index.js +1243 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.cjs +182 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1663 -0
- package/dist/index.d.ts +1663 -0
- package/dist/index.js +182 -0
- package/dist/index.js.map +1 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/react.cjs +182 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +510 -0
- package/dist/react.d.ts +510 -0
- package/dist/react.js +182 -0
- package/dist/react.js.map +1 -0
- package/package.json +151 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1663 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quality and Performance Types for cinematicRenderer2D
|
|
3
|
+
*
|
|
4
|
+
* These types define the adaptive quality system that monitors performance
|
|
5
|
+
* and automatically adjusts rendering quality to maintain target frame rates.
|
|
6
|
+
*
|
|
7
|
+
* Requirements: 8.1, 8.2, 8.3, 8.4, 8.5 - Adaptive quality system
|
|
8
|
+
*/
|
|
9
|
+
type QualityLevel$1 = 'low' | 'medium' | 'high' | 'ultra' | 'auto';
|
|
10
|
+
interface QualitySettings {
|
|
11
|
+
/** Maximum number of particles to render */
|
|
12
|
+
particleCount: number;
|
|
13
|
+
/** Canvas resolution multiplier (0.5 = half resolution) */
|
|
14
|
+
canvasResolution: number;
|
|
15
|
+
/** Animation interpolation precision (higher = smoother) */
|
|
16
|
+
animationPrecision: number;
|
|
17
|
+
/** Whether to enable blur effects */
|
|
18
|
+
enableBlur: boolean;
|
|
19
|
+
/** Whether to enable shadow effects */
|
|
20
|
+
enableShadows: boolean;
|
|
21
|
+
/** Target frame rate for this quality level */
|
|
22
|
+
targetFps: number;
|
|
23
|
+
/** Whether to enable advanced visual effects */
|
|
24
|
+
enableAdvancedEffects: boolean;
|
|
25
|
+
/** Texture quality multiplier */
|
|
26
|
+
textureQuality: number;
|
|
27
|
+
/** Whether to use hardware acceleration */
|
|
28
|
+
useHardwareAcceleration: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface PerformanceMetrics {
|
|
31
|
+
/** Current frames per second */
|
|
32
|
+
fps: number;
|
|
33
|
+
/** Frame time in milliseconds */
|
|
34
|
+
frameTime: number;
|
|
35
|
+
/** Memory usage in MB */
|
|
36
|
+
memoryUsage?: number;
|
|
37
|
+
/** GPU memory usage in MB */
|
|
38
|
+
gpuMemory?: number;
|
|
39
|
+
/** Number of active particles */
|
|
40
|
+
activeParticles: number;
|
|
41
|
+
/** Number of active layers */
|
|
42
|
+
activeLayers: number;
|
|
43
|
+
/** Number of DOM nodes created */
|
|
44
|
+
domNodes: number;
|
|
45
|
+
/** Canvas draw calls per frame */
|
|
46
|
+
drawCalls: number;
|
|
47
|
+
/** Asset loading time in milliseconds */
|
|
48
|
+
assetLoadTime?: number;
|
|
49
|
+
/** Compilation time in milliseconds */
|
|
50
|
+
compilationTime?: number;
|
|
51
|
+
}
|
|
52
|
+
interface DeviceCapabilities {
|
|
53
|
+
/** Device memory in GB */
|
|
54
|
+
memory?: number;
|
|
55
|
+
/** Number of CPU cores */
|
|
56
|
+
cores?: number;
|
|
57
|
+
/** GPU information */
|
|
58
|
+
gpu?: string;
|
|
59
|
+
/** User prefers reduced motion */
|
|
60
|
+
prefersReducedMotion: boolean;
|
|
61
|
+
/** Device power mode */
|
|
62
|
+
powerMode?: 'high-performance' | 'balanced' | 'power-saver';
|
|
63
|
+
/** Screen refresh rate */
|
|
64
|
+
refreshRate?: number;
|
|
65
|
+
/** Device pixel ratio */
|
|
66
|
+
devicePixelRatio: number;
|
|
67
|
+
/** Whether device supports hardware acceleration */
|
|
68
|
+
supportsHardwareAcceleration: boolean;
|
|
69
|
+
/** Maximum texture size supported */
|
|
70
|
+
maxTextureSize?: number;
|
|
71
|
+
/** Whether device is mobile */
|
|
72
|
+
isMobile: boolean;
|
|
73
|
+
/** Network connection type */
|
|
74
|
+
connectionType?: 'slow-2g' | '2g' | '3g' | '4g' | '5g' | 'wifi' | 'ethernet';
|
|
75
|
+
}
|
|
76
|
+
/** Quality system configuration */
|
|
77
|
+
interface QualitySystemConfig {
|
|
78
|
+
/** How often to check performance (milliseconds) */
|
|
79
|
+
monitoringInterval: number;
|
|
80
|
+
/** FPS threshold for quality reduction */
|
|
81
|
+
fpsThreshold: number;
|
|
82
|
+
/** Number of consecutive bad frames before reducing quality */
|
|
83
|
+
badFrameThreshold: number;
|
|
84
|
+
/** Number of consecutive good frames before increasing quality */
|
|
85
|
+
goodFrameThreshold: number;
|
|
86
|
+
/** Whether to respect user preferences */
|
|
87
|
+
respectUserPreferences: boolean;
|
|
88
|
+
/** Whether to use device capability detection */
|
|
89
|
+
useDeviceDetection: boolean;
|
|
90
|
+
/** Custom quality level mappings */
|
|
91
|
+
customLevels?: Record<string, QualitySettings>;
|
|
92
|
+
}
|
|
93
|
+
/** Performance monitoring event data */
|
|
94
|
+
interface PerformanceEvent {
|
|
95
|
+
/** Event type */
|
|
96
|
+
type: 'fps-drop' | 'memory-warning' | 'quality-change' | 'performance-good';
|
|
97
|
+
/** Current performance metrics */
|
|
98
|
+
metrics: PerformanceMetrics;
|
|
99
|
+
/** Previous quality level (for quality-change events) */
|
|
100
|
+
previousQuality?: QualityLevel$1;
|
|
101
|
+
/** New quality level (for quality-change events) */
|
|
102
|
+
newQuality?: QualityLevel$1;
|
|
103
|
+
/** Timestamp of the event */
|
|
104
|
+
timestamp: number;
|
|
105
|
+
/** Additional context data */
|
|
106
|
+
context?: Record<string, any>;
|
|
107
|
+
}
|
|
108
|
+
/** Quality preset configurations */
|
|
109
|
+
declare const QUALITY_PRESETS: Record<QualityLevel$1, QualitySettings>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Main interface for the CinematicRenderer2D engine
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
interface ICinematicRenderer2D {
|
|
116
|
+
mount(): Promise<void>;
|
|
117
|
+
play(): void;
|
|
118
|
+
pause(): void;
|
|
119
|
+
stop(): void;
|
|
120
|
+
destroy(): void;
|
|
121
|
+
seek(timeMs: number): void;
|
|
122
|
+
goToEvent(eventId: string): void;
|
|
123
|
+
goToScene(sceneId: string): void;
|
|
124
|
+
setQuality(level: QualityLevel$1): void;
|
|
125
|
+
resize(width: number, height: number): void;
|
|
126
|
+
on(event: string, callback: Function): void;
|
|
127
|
+
off(event: string, callback: Function): void;
|
|
128
|
+
getCurrentTime(): number;
|
|
129
|
+
getDuration(): number;
|
|
130
|
+
isPlaying(): boolean;
|
|
131
|
+
isPaused(): boolean;
|
|
132
|
+
getCurrentEvent(): string | null;
|
|
133
|
+
getCurrentScene(): string | null;
|
|
134
|
+
getState(): PlaybackState;
|
|
135
|
+
getQuality(): QualityLevel$1;
|
|
136
|
+
isMounted(): boolean;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* JSON Specification Types for cinematicRenderer2D
|
|
141
|
+
*
|
|
142
|
+
* These types define the structure of JSON specifications that describe
|
|
143
|
+
* cinematic experiences with events, scenes, layers, and animations.
|
|
144
|
+
*
|
|
145
|
+
* Requirements: 3.1, 3.5 - JSON specification processing with schema versioning
|
|
146
|
+
*/
|
|
147
|
+
interface CinematicSpec {
|
|
148
|
+
/** Schema version for backward compatibility (e.g., "1.0.0") */
|
|
149
|
+
schemaVersion: string;
|
|
150
|
+
/** Engine configuration and global settings */
|
|
151
|
+
engine: EngineConfig;
|
|
152
|
+
/** Array of cinematic events that define high-level sequences */
|
|
153
|
+
events: CinematicEvent[];
|
|
154
|
+
/** Array of scenes containing layers and timing information */
|
|
155
|
+
scenes: CinematicScene[];
|
|
156
|
+
/** Optional asset definitions for preloading and caching */
|
|
157
|
+
assets?: AssetDefinition$1[];
|
|
158
|
+
}
|
|
159
|
+
interface EngineConfig {
|
|
160
|
+
/** Target frame rate (default: 60, supports up to 120fps) */
|
|
161
|
+
targetFps?: number;
|
|
162
|
+
/** Quality level for performance optimization */
|
|
163
|
+
quality?: QualityLevel;
|
|
164
|
+
/** Enable debug mode with performance overlay */
|
|
165
|
+
debug?: boolean;
|
|
166
|
+
/** Auto-start playback after mounting */
|
|
167
|
+
autoplay?: boolean;
|
|
168
|
+
}
|
|
169
|
+
interface CinematicEvent {
|
|
170
|
+
/** Unique identifier for the event */
|
|
171
|
+
id: string;
|
|
172
|
+
/** Human-readable name for the event */
|
|
173
|
+
name: string;
|
|
174
|
+
/** Array of scene IDs that make up this event */
|
|
175
|
+
scenes: string[];
|
|
176
|
+
/** Optional transitions between scenes */
|
|
177
|
+
transitions?: TransitionSpec[];
|
|
178
|
+
}
|
|
179
|
+
interface CinematicScene {
|
|
180
|
+
/** Unique identifier for the scene */
|
|
181
|
+
id: string;
|
|
182
|
+
/** Human-readable name for the scene */
|
|
183
|
+
name: string;
|
|
184
|
+
/** Duration of the scene in milliseconds */
|
|
185
|
+
duration: number;
|
|
186
|
+
/** Array of layers that make up this scene */
|
|
187
|
+
layers: LayerSpec[];
|
|
188
|
+
/** Optional audio tracks for this scene */
|
|
189
|
+
audio?: AudioTrackSpec[];
|
|
190
|
+
}
|
|
191
|
+
interface LayerSpec {
|
|
192
|
+
/** Unique identifier for the layer */
|
|
193
|
+
id: string;
|
|
194
|
+
/** Layer type - determines which renderer handles this layer */
|
|
195
|
+
type: LayerType;
|
|
196
|
+
/** Z-index for layer ordering (higher values render on top) */
|
|
197
|
+
zIndex: number;
|
|
198
|
+
/** Layer-specific configuration properties */
|
|
199
|
+
config: LayerConfig;
|
|
200
|
+
/** Optional animation tracks for this layer */
|
|
201
|
+
animations?: AnimationTrackSpec[];
|
|
202
|
+
}
|
|
203
|
+
/** Supported layer types for different rendering backends */
|
|
204
|
+
type LayerType = 'gradient' | 'image' | 'textBlock' | 'vignette' | 'glowOrb' | 'noiseOverlay' | 'particles' | 'starfield' | 'dust' | 'nebulaNoise' | 'webgl-custom';
|
|
205
|
+
/** Base configuration for all layer types */
|
|
206
|
+
interface LayerConfig {
|
|
207
|
+
/** Layer opacity (0-1) */
|
|
208
|
+
opacity?: number;
|
|
209
|
+
/** Layer visibility */
|
|
210
|
+
visible?: boolean;
|
|
211
|
+
/** Position and transform properties */
|
|
212
|
+
transform?: TransformConfig;
|
|
213
|
+
/** Layer-specific properties (varies by type) */
|
|
214
|
+
[key: string]: any;
|
|
215
|
+
}
|
|
216
|
+
/** Transform configuration for layer positioning and animation */
|
|
217
|
+
interface TransformConfig {
|
|
218
|
+
/** X position (pixels or percentage) */
|
|
219
|
+
x?: number | string;
|
|
220
|
+
/** Y position (pixels or percentage) */
|
|
221
|
+
y?: number | string;
|
|
222
|
+
/** Scale factor */
|
|
223
|
+
scale?: number;
|
|
224
|
+
/** Rotation in degrees */
|
|
225
|
+
rotation?: number;
|
|
226
|
+
/** Transform origin point */
|
|
227
|
+
origin?: string;
|
|
228
|
+
}
|
|
229
|
+
interface AnimationTrackSpec {
|
|
230
|
+
/** CSS property path to animate (e.g., 'opacity', 'transform.scale', 'filter.blur') */
|
|
231
|
+
property: string;
|
|
232
|
+
/** Starting value for the animation */
|
|
233
|
+
from: AnimationValue;
|
|
234
|
+
/** Ending value for the animation */
|
|
235
|
+
to: AnimationValue;
|
|
236
|
+
/** Animation start time in milliseconds */
|
|
237
|
+
startMs: number;
|
|
238
|
+
/** Animation end time in milliseconds */
|
|
239
|
+
endMs: number;
|
|
240
|
+
/** Easing function name or cubic-bezier values */
|
|
241
|
+
easing?: EasingType;
|
|
242
|
+
/** Whether to loop the animation */
|
|
243
|
+
loop?: boolean;
|
|
244
|
+
/** Whether to reverse the animation on each loop */
|
|
245
|
+
yoyo?: boolean;
|
|
246
|
+
}
|
|
247
|
+
/** Supported animation value types */
|
|
248
|
+
type AnimationValue = number | string | boolean | AnimationValueObject;
|
|
249
|
+
/** Complex animation values for multi-property animations */
|
|
250
|
+
interface AnimationValueObject {
|
|
251
|
+
[key: string]: number | string | boolean;
|
|
252
|
+
}
|
|
253
|
+
/** Supported easing function types */
|
|
254
|
+
type EasingType = 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'ease-in-sine' | 'ease-out-sine' | 'ease-in-out-sine' | 'ease-in-quad' | 'ease-out-quad' | 'ease-in-out-quad' | 'ease-in-cubic' | 'ease-out-cubic' | 'ease-in-out-cubic' | 'ease-in-quart' | 'ease-out-quart' | 'ease-in-out-quart' | 'ease-in-quint' | 'ease-out-quint' | 'ease-in-out-quint' | 'ease-in-expo' | 'ease-out-expo' | 'ease-in-out-expo' | 'ease-in-circ' | 'ease-out-circ' | 'ease-in-out-circ' | 'ease-in-back' | 'ease-out-back' | 'ease-in-out-back' | 'ease-in-elastic' | 'ease-out-elastic' | 'ease-in-out-elastic' | 'ease-in-bounce' | 'ease-out-bounce' | 'ease-in-out-bounce' | `cubic-bezier(${number},${number},${number},${number})`;
|
|
255
|
+
interface AudioTrackSpec {
|
|
256
|
+
/** Unique identifier for the audio track */
|
|
257
|
+
id: string;
|
|
258
|
+
/** Type of audio content */
|
|
259
|
+
type: AudioTrackType;
|
|
260
|
+
/** Source URL or asset ID for the audio file */
|
|
261
|
+
src: string;
|
|
262
|
+
/** Start time in milliseconds */
|
|
263
|
+
startMs: number;
|
|
264
|
+
/** End time in milliseconds (optional, defaults to audio duration) */
|
|
265
|
+
endMs?: number;
|
|
266
|
+
/** Volume level (0-1, default: 1) */
|
|
267
|
+
volume?: number;
|
|
268
|
+
/** Fade in duration in milliseconds */
|
|
269
|
+
fadeIn?: number;
|
|
270
|
+
/** Fade out duration in milliseconds */
|
|
271
|
+
fadeOut?: number;
|
|
272
|
+
/** Whether to loop the audio */
|
|
273
|
+
loop?: boolean;
|
|
274
|
+
}
|
|
275
|
+
/** Supported audio track types */
|
|
276
|
+
type AudioTrackType = 'voiceover' | 'ambience' | 'transition' | 'music' | 'sfx';
|
|
277
|
+
interface TransitionSpec {
|
|
278
|
+
/** Type of transition effect */
|
|
279
|
+
type: TransitionType;
|
|
280
|
+
/** Duration of the transition in milliseconds */
|
|
281
|
+
duration: number;
|
|
282
|
+
/** Easing function for the transition */
|
|
283
|
+
easing?: EasingType;
|
|
284
|
+
/** Additional transition-specific properties */
|
|
285
|
+
config?: TransitionConfig;
|
|
286
|
+
}
|
|
287
|
+
/** Supported transition types */
|
|
288
|
+
type TransitionType = 'fade' | 'slide' | 'zoom' | 'wipe' | 'dissolve' | 'blur';
|
|
289
|
+
/** Configuration for transition effects */
|
|
290
|
+
interface TransitionConfig {
|
|
291
|
+
/** Direction for slide/wipe transitions */
|
|
292
|
+
direction?: 'up' | 'down' | 'left' | 'right' | 'in' | 'out';
|
|
293
|
+
/** Blur amount for blur transitions */
|
|
294
|
+
blurAmount?: number;
|
|
295
|
+
/** Custom properties for advanced transitions */
|
|
296
|
+
[key: string]: any;
|
|
297
|
+
}
|
|
298
|
+
interface AssetDefinition$1 {
|
|
299
|
+
/** Unique identifier for the asset */
|
|
300
|
+
id: string;
|
|
301
|
+
/** Type of asset */
|
|
302
|
+
type: AssetType$1;
|
|
303
|
+
/** Source URL for the asset */
|
|
304
|
+
src: string;
|
|
305
|
+
/** Whether to preload this asset */
|
|
306
|
+
preload?: boolean;
|
|
307
|
+
/** Fallback asset ID or URL if loading fails */
|
|
308
|
+
fallback?: string;
|
|
309
|
+
/** Additional metadata for the asset */
|
|
310
|
+
metadata?: AssetMetadata$1;
|
|
311
|
+
}
|
|
312
|
+
/** Supported asset types */
|
|
313
|
+
type AssetType$1 = 'image' | 'video' | 'audio' | 'font' | 'json' | 'binary';
|
|
314
|
+
/** Asset metadata for optimization and caching */
|
|
315
|
+
interface AssetMetadata$1 {
|
|
316
|
+
/** Expected file size in bytes */
|
|
317
|
+
size?: number;
|
|
318
|
+
/** MIME type */
|
|
319
|
+
mimeType?: string;
|
|
320
|
+
/** Cache duration in milliseconds */
|
|
321
|
+
cacheDuration?: number;
|
|
322
|
+
/** Asset dimensions for images/videos */
|
|
323
|
+
dimensions?: {
|
|
324
|
+
width: number;
|
|
325
|
+
height: number;
|
|
326
|
+
};
|
|
327
|
+
/** Audio duration in milliseconds */
|
|
328
|
+
duration?: number;
|
|
329
|
+
}
|
|
330
|
+
type QualityLevel = 'low' | 'medium' | 'high' | 'ultra' | 'auto';
|
|
331
|
+
|
|
332
|
+
interface CinematicRenderer2DOptions {
|
|
333
|
+
container: HTMLElement;
|
|
334
|
+
spec: CinematicSpec;
|
|
335
|
+
autoplay?: boolean;
|
|
336
|
+
quality?: QualityLevel$1;
|
|
337
|
+
debug?: boolean;
|
|
338
|
+
}
|
|
339
|
+
type PlaybackState = 'idle' | 'loading' | 'ready' | 'playing' | 'paused' | 'stopped' | 'destroyed';
|
|
340
|
+
declare class CinematicRenderer2D implements ICinematicRenderer2D {
|
|
341
|
+
private _container;
|
|
342
|
+
private _spec;
|
|
343
|
+
private _compiledSpec;
|
|
344
|
+
private _options;
|
|
345
|
+
private eventListeners;
|
|
346
|
+
private _state;
|
|
347
|
+
private _currentTime;
|
|
348
|
+
private _duration;
|
|
349
|
+
private _currentEventId;
|
|
350
|
+
private _currentSceneId;
|
|
351
|
+
private _quality;
|
|
352
|
+
private _resizeListener;
|
|
353
|
+
private _scheduler;
|
|
354
|
+
private _qualitySystem;
|
|
355
|
+
private _audioSystem;
|
|
356
|
+
private _debugOverlay;
|
|
357
|
+
private _layerRegistry;
|
|
358
|
+
private _domRenderer;
|
|
359
|
+
private _canvas2DRenderer;
|
|
360
|
+
private _layers;
|
|
361
|
+
private _currentSceneLayers;
|
|
362
|
+
private _resizeObserver;
|
|
363
|
+
private _mounted;
|
|
364
|
+
constructor(options: CinematicRenderer2DOptions);
|
|
365
|
+
mount(): Promise<void>;
|
|
366
|
+
play(): void;
|
|
367
|
+
pause(): void;
|
|
368
|
+
stop(): void;
|
|
369
|
+
destroy(): void;
|
|
370
|
+
seek(timeMs: number): void;
|
|
371
|
+
goToEvent(eventId: string): void;
|
|
372
|
+
goToScene(sceneId: string): void;
|
|
373
|
+
setQuality(level: QualityLevel$1): void;
|
|
374
|
+
resize(width: number, height: number): void;
|
|
375
|
+
on(event: string, callback: Function): void;
|
|
376
|
+
off(event: string, callback: Function): void;
|
|
377
|
+
getCurrentTime(): number;
|
|
378
|
+
getDuration(): number;
|
|
379
|
+
isPlaying(): boolean;
|
|
380
|
+
isPaused(): boolean;
|
|
381
|
+
getCurrentEvent(): string | null;
|
|
382
|
+
getCurrentScene(): string | null;
|
|
383
|
+
getState(): PlaybackState;
|
|
384
|
+
getQuality(): QualityLevel$1;
|
|
385
|
+
isMounted(): boolean;
|
|
386
|
+
getCurrentFps(): number;
|
|
387
|
+
getPerformanceMetrics(): PerformanceMetrics;
|
|
388
|
+
getQualitySettings(): QualitySettings;
|
|
389
|
+
getDeviceCapabilities(): DeviceCapabilities;
|
|
390
|
+
setMasterVolume(volume: number): void;
|
|
391
|
+
getMasterVolume(): number;
|
|
392
|
+
isWebAudioAvailable(): boolean;
|
|
393
|
+
getActiveAudioTrackCount(): number;
|
|
394
|
+
isDebugEnabled(): boolean;
|
|
395
|
+
toggleDebug(): void;
|
|
396
|
+
showDebug(): void;
|
|
397
|
+
hideDebug(): void;
|
|
398
|
+
protected emit(event: string, ...args: any[]): void;
|
|
399
|
+
private _onFrame;
|
|
400
|
+
private _setState;
|
|
401
|
+
private _calculateDuration;
|
|
402
|
+
private _calculateEventStartTime;
|
|
403
|
+
private _calculateSceneStartTime;
|
|
404
|
+
private _updateCurrentEventAndScene;
|
|
405
|
+
private _setupContainer;
|
|
406
|
+
private _setupResizeObserver;
|
|
407
|
+
private _setupResizeListener;
|
|
408
|
+
private _initializeRenderers;
|
|
409
|
+
private _initializeLayers;
|
|
410
|
+
private _updateCurrentSceneLayers;
|
|
411
|
+
private _mountLayer;
|
|
412
|
+
private _renderCurrentFrame;
|
|
413
|
+
private _getCurrentScene;
|
|
414
|
+
private _getLayerConfig;
|
|
415
|
+
private _resetLayersToInitialState;
|
|
416
|
+
private _destroyAllLayers;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Abstract base class for rendering backends
|
|
421
|
+
*/
|
|
422
|
+
|
|
423
|
+
declare abstract class RenderBackend {
|
|
424
|
+
protected container: HTMLElement;
|
|
425
|
+
constructor(container: HTMLElement);
|
|
426
|
+
abstract initialize(): void;
|
|
427
|
+
abstract render(layers: ICinematicLayer[], context: FrameContext$1): void;
|
|
428
|
+
abstract resize(width: number, height: number): void;
|
|
429
|
+
abstract destroy(): void;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Asset Management Types for cinematicRenderer2D
|
|
434
|
+
*
|
|
435
|
+
* These types define the asset loading, caching, and management system
|
|
436
|
+
* that handles images, videos, audio files, and other resources.
|
|
437
|
+
*
|
|
438
|
+
* Requirements: 9.1, 9.2, 9.3, 9.4 - Comprehensive asset management
|
|
439
|
+
*/
|
|
440
|
+
interface Asset {
|
|
441
|
+
/** Unique identifier for the asset */
|
|
442
|
+
id: string;
|
|
443
|
+
/** Type of asset */
|
|
444
|
+
type: AssetType;
|
|
445
|
+
/** Source URL */
|
|
446
|
+
src: string;
|
|
447
|
+
/** Loaded asset data (varies by type) */
|
|
448
|
+
data: AssetData | null;
|
|
449
|
+
/** Whether the asset has finished loading */
|
|
450
|
+
loaded: boolean;
|
|
451
|
+
/** Loading error if any occurred */
|
|
452
|
+
error: Error | null;
|
|
453
|
+
/** Fallback asset ID or URL */
|
|
454
|
+
fallback?: string;
|
|
455
|
+
/** Asset metadata */
|
|
456
|
+
metadata: AssetMetadata;
|
|
457
|
+
/** Loading progress (0-1) */
|
|
458
|
+
progress: number;
|
|
459
|
+
/** Cache timestamp for expiration */
|
|
460
|
+
cachedAt?: number;
|
|
461
|
+
/** Asset size in bytes */
|
|
462
|
+
size?: number;
|
|
463
|
+
}
|
|
464
|
+
/** Union type for all possible asset data types */
|
|
465
|
+
type AssetData = HTMLImageElement | HTMLVideoElement | HTMLAudioElement | AudioBuffer | FontFace | ArrayBuffer | string | object;
|
|
466
|
+
/** Supported asset types */
|
|
467
|
+
type AssetType = 'image' | 'video' | 'audio' | 'font' | 'json' | 'binary' | 'text';
|
|
468
|
+
interface AssetDefinition {
|
|
469
|
+
/** Unique identifier for the asset */
|
|
470
|
+
id: string;
|
|
471
|
+
/** Type of asset */
|
|
472
|
+
type: AssetType;
|
|
473
|
+
/** Source URL for the asset */
|
|
474
|
+
src: string;
|
|
475
|
+
/** Whether to preload this asset */
|
|
476
|
+
preload?: boolean;
|
|
477
|
+
/** Fallback asset ID or URL if loading fails */
|
|
478
|
+
fallback?: string;
|
|
479
|
+
/** Additional metadata for the asset */
|
|
480
|
+
metadata?: Partial<AssetMetadata>;
|
|
481
|
+
}
|
|
482
|
+
/** Asset metadata for optimization and caching */
|
|
483
|
+
interface AssetMetadata {
|
|
484
|
+
/** Expected file size in bytes */
|
|
485
|
+
size: number;
|
|
486
|
+
/** MIME type */
|
|
487
|
+
mimeType: string;
|
|
488
|
+
/** Cache duration in milliseconds */
|
|
489
|
+
cacheDuration: number;
|
|
490
|
+
/** Asset dimensions for images/videos */
|
|
491
|
+
dimensions?: {
|
|
492
|
+
width: number;
|
|
493
|
+
height: number;
|
|
494
|
+
};
|
|
495
|
+
/** Audio/video duration in milliseconds */
|
|
496
|
+
duration?: number;
|
|
497
|
+
/** Compression quality (0-1) */
|
|
498
|
+
quality?: number;
|
|
499
|
+
/** Whether asset supports streaming */
|
|
500
|
+
streamable?: boolean;
|
|
501
|
+
/** Asset priority for loading order */
|
|
502
|
+
priority?: AssetPriority;
|
|
503
|
+
}
|
|
504
|
+
/** Asset loading priority levels */
|
|
505
|
+
type AssetPriority = 'critical' | 'high' | 'normal' | 'low' | 'lazy';
|
|
506
|
+
interface AssetLoadProgress {
|
|
507
|
+
/** Number of assets loaded */
|
|
508
|
+
loaded: number;
|
|
509
|
+
/** Total number of assets to load */
|
|
510
|
+
total: number;
|
|
511
|
+
/** Currently loading asset ID */
|
|
512
|
+
currentAsset?: string;
|
|
513
|
+
/** Overall progress percentage (0-100) */
|
|
514
|
+
percentage: number;
|
|
515
|
+
/** Loading speed in bytes per second */
|
|
516
|
+
speed?: number;
|
|
517
|
+
/** Estimated time remaining in milliseconds */
|
|
518
|
+
estimatedTimeRemaining?: number;
|
|
519
|
+
}
|
|
520
|
+
/** Asset loading options */
|
|
521
|
+
interface AssetLoadOptions {
|
|
522
|
+
/** Request timeout in milliseconds */
|
|
523
|
+
timeout?: number;
|
|
524
|
+
/** Number of retry attempts */
|
|
525
|
+
retries?: number;
|
|
526
|
+
/** Whether to use cache */
|
|
527
|
+
useCache?: boolean;
|
|
528
|
+
/** Custom headers for the request */
|
|
529
|
+
headers?: Record<string, string>;
|
|
530
|
+
/** CORS mode */
|
|
531
|
+
mode?: 'cors' | 'no-cors' | 'same-origin';
|
|
532
|
+
/** Credentials mode */
|
|
533
|
+
credentials?: 'omit' | 'same-origin' | 'include';
|
|
534
|
+
}
|
|
535
|
+
/** Asset cache configuration */
|
|
536
|
+
interface AssetCacheConfig {
|
|
537
|
+
/** Maximum cache size in bytes */
|
|
538
|
+
maxSize: number;
|
|
539
|
+
/** Default cache duration in milliseconds */
|
|
540
|
+
defaultDuration: number;
|
|
541
|
+
/** Cache storage type */
|
|
542
|
+
storageType: 'memory' | 'indexeddb' | 'localstorage';
|
|
543
|
+
/** Whether to compress cached assets */
|
|
544
|
+
compress: boolean;
|
|
545
|
+
/** Cache eviction strategy */
|
|
546
|
+
evictionStrategy: 'lru' | 'lfu' | 'fifo';
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Comprehensive asset management system for preloading and caching resources
|
|
551
|
+
*
|
|
552
|
+
* This system handles loading, caching, and management of various asset types
|
|
553
|
+
* including images, videos, audio files, fonts, and other resources with
|
|
554
|
+
* fallback handling, progress tracking, and performance optimization.
|
|
555
|
+
*
|
|
556
|
+
* Requirements: 9.1, 9.2, 9.3, 9.4
|
|
557
|
+
*/
|
|
558
|
+
|
|
559
|
+
interface AssetManagerConfig {
|
|
560
|
+
/** Maximum number of concurrent downloads */
|
|
561
|
+
maxConcurrentLoads?: number;
|
|
562
|
+
/** Default timeout for asset loading in milliseconds */
|
|
563
|
+
defaultTimeout?: number;
|
|
564
|
+
/** Default number of retry attempts */
|
|
565
|
+
defaultRetries?: number;
|
|
566
|
+
/** Cache configuration */
|
|
567
|
+
cache?: Partial<AssetCacheConfig>;
|
|
568
|
+
/** Base URL for relative asset paths */
|
|
569
|
+
baseUrl?: string;
|
|
570
|
+
}
|
|
571
|
+
interface AssetManagerEvents {
|
|
572
|
+
'progress': (progress: AssetLoadProgress) => void;
|
|
573
|
+
'asset-loaded': (asset: Asset) => void;
|
|
574
|
+
'asset-error': (assetId: string, error: Error) => void;
|
|
575
|
+
'complete': (assets: Asset[]) => void;
|
|
576
|
+
'cache-full': (cacheSize: number) => void;
|
|
577
|
+
}
|
|
578
|
+
declare class AssetManager {
|
|
579
|
+
private _assets;
|
|
580
|
+
private _eventListeners;
|
|
581
|
+
private _loadingQueue;
|
|
582
|
+
private _activeLoads;
|
|
583
|
+
private _config;
|
|
584
|
+
private _cacheSize;
|
|
585
|
+
private _loadStartTime;
|
|
586
|
+
private _loadedBytes;
|
|
587
|
+
constructor(config?: AssetManagerConfig);
|
|
588
|
+
/**
|
|
589
|
+
* Load multiple assets with progress tracking and fallback handling
|
|
590
|
+
*/
|
|
591
|
+
loadAssets(definitions: AssetDefinition[]): Promise<Asset[]>;
|
|
592
|
+
/**
|
|
593
|
+
* Get a loaded asset by ID
|
|
594
|
+
*/
|
|
595
|
+
getAsset(id: string): Asset | null;
|
|
596
|
+
/**
|
|
597
|
+
* Check if an asset is loaded
|
|
598
|
+
*/
|
|
599
|
+
isAssetLoaded(id: string): boolean;
|
|
600
|
+
/**
|
|
601
|
+
* Get all loaded assets
|
|
602
|
+
*/
|
|
603
|
+
getAllAssets(): Asset[];
|
|
604
|
+
/**
|
|
605
|
+
* Get assets by type
|
|
606
|
+
*/
|
|
607
|
+
getAssetsByType(type: AssetType): Asset[];
|
|
608
|
+
/**
|
|
609
|
+
* Preload a single asset
|
|
610
|
+
*/
|
|
611
|
+
preloadAsset(definition: AssetDefinition): Promise<Asset>;
|
|
612
|
+
/**
|
|
613
|
+
* Clear all cached assets
|
|
614
|
+
*/
|
|
615
|
+
clearCache(): void;
|
|
616
|
+
/**
|
|
617
|
+
* Remove specific asset from cache
|
|
618
|
+
*/
|
|
619
|
+
removeAsset(id: string): boolean;
|
|
620
|
+
/**
|
|
621
|
+
* Get cache statistics
|
|
622
|
+
*/
|
|
623
|
+
getCacheStats(): {
|
|
624
|
+
totalAssets: number;
|
|
625
|
+
cacheSize: number;
|
|
626
|
+
maxCacheSize: number;
|
|
627
|
+
cacheUtilization: number;
|
|
628
|
+
};
|
|
629
|
+
/**
|
|
630
|
+
* Add event listener
|
|
631
|
+
*/
|
|
632
|
+
on<K extends keyof AssetManagerEvents>(event: K, callback: AssetManagerEvents[K]): void;
|
|
633
|
+
/**
|
|
634
|
+
* Remove event listener
|
|
635
|
+
*/
|
|
636
|
+
off<K extends keyof AssetManagerEvents>(event: K, callback: AssetManagerEvents[K]): void;
|
|
637
|
+
private _createAsset;
|
|
638
|
+
private _createDefaultMetadata;
|
|
639
|
+
private _resolveUrl;
|
|
640
|
+
private _getMimeType;
|
|
641
|
+
private _sortByPriority;
|
|
642
|
+
private _loadSingleAsset;
|
|
643
|
+
private _loadAssetData;
|
|
644
|
+
private _loadImage;
|
|
645
|
+
private _loadVideo;
|
|
646
|
+
private _loadAudio;
|
|
647
|
+
private _loadFont;
|
|
648
|
+
private _loadJson;
|
|
649
|
+
private _loadText;
|
|
650
|
+
private _loadBinary;
|
|
651
|
+
private _fetchWithTimeout;
|
|
652
|
+
private _estimateAssetSize;
|
|
653
|
+
private _enforceCache;
|
|
654
|
+
private _emitProgress;
|
|
655
|
+
private _emit;
|
|
656
|
+
private _isPromiseSettled;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Context objects passed to layers during mount and update operations
|
|
661
|
+
*/
|
|
662
|
+
|
|
663
|
+
interface LayerMountContext {
|
|
664
|
+
container: HTMLElement;
|
|
665
|
+
canvas?: HTMLCanvasElement;
|
|
666
|
+
renderer: RenderBackend;
|
|
667
|
+
assetManager: AssetManager;
|
|
668
|
+
layerConfig: Record<string, any>;
|
|
669
|
+
}
|
|
670
|
+
interface FrameContext$1 {
|
|
671
|
+
timeMs: number;
|
|
672
|
+
deltaMs: number;
|
|
673
|
+
quality: QualityLevel$1;
|
|
674
|
+
viewport: {
|
|
675
|
+
width: number;
|
|
676
|
+
height: number;
|
|
677
|
+
};
|
|
678
|
+
devicePixelRatio: number;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Interface for cinematic layers - the building blocks of scenes
|
|
683
|
+
*/
|
|
684
|
+
|
|
685
|
+
interface ICinematicLayer {
|
|
686
|
+
readonly id: string;
|
|
687
|
+
readonly type: string;
|
|
688
|
+
readonly zIndex: number;
|
|
689
|
+
mount(ctx: LayerMountContext): void;
|
|
690
|
+
update(ctx: FrameContext$1): void;
|
|
691
|
+
destroy(): void;
|
|
692
|
+
resize?(width: number, height: number): void;
|
|
693
|
+
setVisible?(visible: boolean): void;
|
|
694
|
+
setOpacity?(opacity: number): void;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Compiled Runtime Types for cinematicRenderer2D
|
|
699
|
+
*
|
|
700
|
+
* These types represent the optimized, runtime-ready versions of the JSON specifications
|
|
701
|
+
* after parsing, validation, and compilation. All animation tracks are precompiled into
|
|
702
|
+
* optimized interpolation functions for maximum performance.
|
|
703
|
+
*
|
|
704
|
+
* Requirements: 3.1, 3.5 - Compiled runtime models with performance optimization
|
|
705
|
+
*/
|
|
706
|
+
|
|
707
|
+
interface CompiledSpec {
|
|
708
|
+
/** Map of event IDs to compiled event objects */
|
|
709
|
+
events: Map<string, CompiledEvent>;
|
|
710
|
+
/** Map of scene IDs to compiled scene objects */
|
|
711
|
+
scenes: Map<string, CompiledScene>;
|
|
712
|
+
/** Map of asset IDs to loaded asset objects */
|
|
713
|
+
assets: Map<string, Asset>;
|
|
714
|
+
/** Global engine configuration */
|
|
715
|
+
globalConfig: EngineConfig;
|
|
716
|
+
/** Schema version for compatibility checking */
|
|
717
|
+
schemaVersion: string;
|
|
718
|
+
/** Total duration of all content in milliseconds */
|
|
719
|
+
totalDuration: number;
|
|
720
|
+
/** Compilation timestamp for cache validation */
|
|
721
|
+
compiledAt: number;
|
|
722
|
+
}
|
|
723
|
+
interface CompiledEvent {
|
|
724
|
+
/** Unique identifier for the event */
|
|
725
|
+
id: string;
|
|
726
|
+
/** Human-readable name for the event */
|
|
727
|
+
name: string;
|
|
728
|
+
/** Array of compiled scene objects (not just IDs) */
|
|
729
|
+
scenes: CompiledScene[];
|
|
730
|
+
/** Compiled transition effects between scenes */
|
|
731
|
+
transitions: CompiledTransition[];
|
|
732
|
+
/** Total duration of this event in milliseconds */
|
|
733
|
+
duration: number;
|
|
734
|
+
/** Start time of this event in the global timeline */
|
|
735
|
+
startTime: number;
|
|
736
|
+
}
|
|
737
|
+
interface CompiledScene {
|
|
738
|
+
/** Unique identifier for the scene */
|
|
739
|
+
id: string;
|
|
740
|
+
/** Human-readable name for the scene */
|
|
741
|
+
name: string;
|
|
742
|
+
/** Duration of the scene in milliseconds */
|
|
743
|
+
duration: number;
|
|
744
|
+
/** Array of compiled layer objects with instances */
|
|
745
|
+
layers: CompiledLayer[];
|
|
746
|
+
/** Compiled audio tracks for this scene */
|
|
747
|
+
audioTracks: CompiledAudioTrack[];
|
|
748
|
+
/** Start time of this scene in the global timeline */
|
|
749
|
+
startTime: number;
|
|
750
|
+
/** End time of this scene in the global timeline */
|
|
751
|
+
endTime: number;
|
|
752
|
+
}
|
|
753
|
+
interface CompiledLayer {
|
|
754
|
+
/** Unique identifier for the layer */
|
|
755
|
+
id: string;
|
|
756
|
+
/** Layer type for renderer selection */
|
|
757
|
+
type: string;
|
|
758
|
+
/** Z-index for rendering order */
|
|
759
|
+
zIndex: number;
|
|
760
|
+
/** Instantiated layer object ready for rendering */
|
|
761
|
+
instance: ICinematicLayer;
|
|
762
|
+
/** Precompiled animation tracks for optimal performance */
|
|
763
|
+
animations: CompiledAnimationTrack[];
|
|
764
|
+
/** Initial configuration values */
|
|
765
|
+
initialConfig: Record<string, any>;
|
|
766
|
+
/** Whether this layer is currently active */
|
|
767
|
+
active: boolean;
|
|
768
|
+
}
|
|
769
|
+
interface CompiledAnimationTrack {
|
|
770
|
+
/** CSS property path being animated */
|
|
771
|
+
property: string;
|
|
772
|
+
/** Animation start time in milliseconds */
|
|
773
|
+
startMs: number;
|
|
774
|
+
/** Animation end time in milliseconds */
|
|
775
|
+
endMs: number;
|
|
776
|
+
/** Precompiled interpolation function for maximum performance */
|
|
777
|
+
interpolate: (progress: number) => any;
|
|
778
|
+
/** Whether the animation loops */
|
|
779
|
+
loop: boolean;
|
|
780
|
+
/** Whether the animation reverses on each loop */
|
|
781
|
+
yoyo: boolean;
|
|
782
|
+
/** Original easing type for debugging */
|
|
783
|
+
easingType: EasingType;
|
|
784
|
+
/** Current loop iteration (for looped animations) */
|
|
785
|
+
currentLoop: number;
|
|
786
|
+
/** Whether animation is currently in reverse (for yoyo) */
|
|
787
|
+
isReverse: boolean;
|
|
788
|
+
}
|
|
789
|
+
interface CompiledAudioTrack {
|
|
790
|
+
/** Unique identifier for the audio track */
|
|
791
|
+
id: string;
|
|
792
|
+
/** Type of audio content */
|
|
793
|
+
type: AudioTrackType;
|
|
794
|
+
/** Loaded asset reference */
|
|
795
|
+
asset: Asset;
|
|
796
|
+
/** Start time in milliseconds */
|
|
797
|
+
startMs: number;
|
|
798
|
+
/** End time in milliseconds */
|
|
799
|
+
endMs: number;
|
|
800
|
+
/** Volume level (0-1) */
|
|
801
|
+
volume: number;
|
|
802
|
+
/** Fade in duration in milliseconds */
|
|
803
|
+
fadeIn: number;
|
|
804
|
+
/** Fade out duration in milliseconds */
|
|
805
|
+
fadeOut: number;
|
|
806
|
+
/** Whether to loop the audio */
|
|
807
|
+
loop: boolean;
|
|
808
|
+
/** Audio context node for Web Audio API */
|
|
809
|
+
audioNode?: AudioNode;
|
|
810
|
+
/** HTML audio element for fallback */
|
|
811
|
+
audioElement?: HTMLAudioElement;
|
|
812
|
+
}
|
|
813
|
+
interface CompiledTransition {
|
|
814
|
+
/** Type of transition effect */
|
|
815
|
+
type: TransitionType;
|
|
816
|
+
/** Duration of the transition in milliseconds */
|
|
817
|
+
duration: number;
|
|
818
|
+
/** Precompiled easing function */
|
|
819
|
+
easingFunction: (t: number) => number;
|
|
820
|
+
/** Transition-specific configuration */
|
|
821
|
+
config: Record<string, any>;
|
|
822
|
+
/** Precompiled transition function for performance */
|
|
823
|
+
execute: (progress: number, fromElement: HTMLElement, toElement: HTMLElement) => void;
|
|
824
|
+
}
|
|
825
|
+
/** Animation interpolation function signature */
|
|
826
|
+
type InterpolationFunction = (progress: number) => any;
|
|
827
|
+
/** Easing function signature */
|
|
828
|
+
type EasingFunction = (t: number) => number;
|
|
829
|
+
/** Transition execution function signature */
|
|
830
|
+
type TransitionFunction = (progress: number, fromElement: HTMLElement, toElement: HTMLElement) => void;
|
|
831
|
+
/** Compilation context for tracking state during parsing */
|
|
832
|
+
interface CompilationContext {
|
|
833
|
+
/** Current schema version being processed */
|
|
834
|
+
schemaVersion: string;
|
|
835
|
+
/** Asset loading promises for dependency tracking */
|
|
836
|
+
assetPromises: Map<string, Promise<Asset>>;
|
|
837
|
+
/** Layer type registry for validation */
|
|
838
|
+
layerTypes: Set<string>;
|
|
839
|
+
/** Compilation warnings and errors */
|
|
840
|
+
diagnostics: CompilationDiagnostic[];
|
|
841
|
+
/** Performance optimization flags */
|
|
842
|
+
optimizations: CompilationOptimizations;
|
|
843
|
+
}
|
|
844
|
+
/** Compilation diagnostic information */
|
|
845
|
+
interface CompilationDiagnostic {
|
|
846
|
+
/** Severity level */
|
|
847
|
+
level: 'error' | 'warning' | 'info';
|
|
848
|
+
/** Human-readable message */
|
|
849
|
+
message: string;
|
|
850
|
+
/** Location in the source specification */
|
|
851
|
+
location?: {
|
|
852
|
+
path: string;
|
|
853
|
+
line?: number;
|
|
854
|
+
column?: number;
|
|
855
|
+
};
|
|
856
|
+
/** Error code for programmatic handling */
|
|
857
|
+
code?: string;
|
|
858
|
+
}
|
|
859
|
+
/** Compilation optimization settings */
|
|
860
|
+
interface CompilationOptimizations {
|
|
861
|
+
/** Precompile animation tracks */
|
|
862
|
+
precompileAnimations: boolean;
|
|
863
|
+
/** Optimize asset loading order */
|
|
864
|
+
optimizeAssetLoading: boolean;
|
|
865
|
+
/** Enable object pooling for particles */
|
|
866
|
+
enableObjectPooling: boolean;
|
|
867
|
+
/** Minimize DOM manipulations */
|
|
868
|
+
minimizeDOMUpdates: boolean;
|
|
869
|
+
/** Use Web Workers for heavy computations */
|
|
870
|
+
useWebWorkers: boolean;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
/**
|
|
874
|
+
* Layer Registry for managing layer types and instances
|
|
875
|
+
* Supports both built-in layer types and custom layer plugins
|
|
876
|
+
*/
|
|
877
|
+
|
|
878
|
+
type LayerFactory = (id: string, config: Record<string, any>) => ICinematicLayer;
|
|
879
|
+
declare class LayerRegistry {
|
|
880
|
+
private layerTypes;
|
|
881
|
+
private static instance;
|
|
882
|
+
constructor();
|
|
883
|
+
/**
|
|
884
|
+
* Get the global layer registry instance
|
|
885
|
+
*/
|
|
886
|
+
static getInstance(): LayerRegistry;
|
|
887
|
+
/**
|
|
888
|
+
* Register a custom layer type with a factory function
|
|
889
|
+
*/
|
|
890
|
+
registerLayerType(type: string, factory: LayerFactory): void;
|
|
891
|
+
/**
|
|
892
|
+
* Create a layer instance of the specified type
|
|
893
|
+
*/
|
|
894
|
+
createLayer(type: string, id: string, config: Record<string, any>): ICinematicLayer;
|
|
895
|
+
/**
|
|
896
|
+
* Check if a layer type is registered
|
|
897
|
+
*/
|
|
898
|
+
hasLayerType(type: string): boolean;
|
|
899
|
+
/**
|
|
900
|
+
* Get all registered layer type names
|
|
901
|
+
*/
|
|
902
|
+
getRegisteredTypes(): string[];
|
|
903
|
+
/**
|
|
904
|
+
* Get built-in layer types (DOM and Canvas2D)
|
|
905
|
+
*/
|
|
906
|
+
getBuiltInTypes(): {
|
|
907
|
+
dom: string[];
|
|
908
|
+
canvas2d: string[];
|
|
909
|
+
};
|
|
910
|
+
/**
|
|
911
|
+
* Check if a layer type is a built-in type
|
|
912
|
+
*/
|
|
913
|
+
isBuiltInType(type: string): boolean;
|
|
914
|
+
/**
|
|
915
|
+
* Get custom (non-built-in) layer types
|
|
916
|
+
*/
|
|
917
|
+
getCustomTypes(): string[];
|
|
918
|
+
/**
|
|
919
|
+
* Unregister a layer type (useful for testing or dynamic plugin management)
|
|
920
|
+
*/
|
|
921
|
+
unregisterLayerType(type: string): boolean;
|
|
922
|
+
/**
|
|
923
|
+
* Clear all custom layer types (keeps built-in types)
|
|
924
|
+
*/
|
|
925
|
+
clearCustomTypes(): void;
|
|
926
|
+
/**
|
|
927
|
+
* Register all built-in layer types
|
|
928
|
+
*/
|
|
929
|
+
private registerBuiltInLayers;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
/**
|
|
933
|
+
* Built-in layer type implementations
|
|
934
|
+
* DOM layers fully implemented for Task 7.1
|
|
935
|
+
* Canvas2D layers will be completed in Task 8.1
|
|
936
|
+
*/
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* Base class for built-in layers with common functionality
|
|
940
|
+
*/
|
|
941
|
+
declare abstract class BaseLayer implements ICinematicLayer {
|
|
942
|
+
readonly id: string;
|
|
943
|
+
readonly type: string;
|
|
944
|
+
readonly zIndex: number;
|
|
945
|
+
protected config: Record<string, any>;
|
|
946
|
+
protected mounted: boolean;
|
|
947
|
+
constructor(id: string, type: string, config: Record<string, any>);
|
|
948
|
+
abstract mount(ctx: LayerMountContext): void;
|
|
949
|
+
abstract update(ctx: FrameContext$1): void;
|
|
950
|
+
destroy(): void;
|
|
951
|
+
setVisible(_visible: boolean): void;
|
|
952
|
+
setOpacity(_opacity: number): void;
|
|
953
|
+
resize(_width: number, _height: number): void;
|
|
954
|
+
}
|
|
955
|
+
declare class GradientLayer extends BaseLayer {
|
|
956
|
+
private element?;
|
|
957
|
+
constructor(id: string, config: Record<string, any>);
|
|
958
|
+
mount(ctx: LayerMountContext): void;
|
|
959
|
+
update(ctx: FrameContext$1): void;
|
|
960
|
+
destroy(): void;
|
|
961
|
+
}
|
|
962
|
+
declare class ImageLayer extends BaseLayer {
|
|
963
|
+
private element?;
|
|
964
|
+
private img?;
|
|
965
|
+
constructor(id: string, config: Record<string, any>);
|
|
966
|
+
mount(ctx: LayerMountContext): void;
|
|
967
|
+
update(ctx: FrameContext$1): void;
|
|
968
|
+
destroy(): void;
|
|
969
|
+
}
|
|
970
|
+
declare class TextBlockLayer extends BaseLayer {
|
|
971
|
+
private element?;
|
|
972
|
+
constructor(id: string, config: Record<string, any>);
|
|
973
|
+
mount(ctx: LayerMountContext): void;
|
|
974
|
+
update(ctx: FrameContext$1): void;
|
|
975
|
+
destroy(): void;
|
|
976
|
+
}
|
|
977
|
+
declare class VignetteLayer extends BaseLayer {
|
|
978
|
+
private element?;
|
|
979
|
+
constructor(id: string, config: Record<string, any>);
|
|
980
|
+
mount(ctx: LayerMountContext): void;
|
|
981
|
+
update(ctx: FrameContext$1): void;
|
|
982
|
+
destroy(): void;
|
|
983
|
+
}
|
|
984
|
+
declare class GlowOrbLayer extends BaseLayer {
|
|
985
|
+
private element?;
|
|
986
|
+
constructor(id: string, config: Record<string, any>);
|
|
987
|
+
mount(ctx: LayerMountContext): void;
|
|
988
|
+
update(ctx: FrameContext$1): void;
|
|
989
|
+
destroy(): void;
|
|
990
|
+
}
|
|
991
|
+
declare class NoiseOverlayLayer extends BaseLayer {
|
|
992
|
+
private element?;
|
|
993
|
+
private canvas?;
|
|
994
|
+
private ctx?;
|
|
995
|
+
constructor(id: string, config: Record<string, any>);
|
|
996
|
+
mount(ctx: LayerMountContext): void;
|
|
997
|
+
update(ctx: FrameContext$1): void;
|
|
998
|
+
private generateNoise;
|
|
999
|
+
resize(_width: number, _height: number): void;
|
|
1000
|
+
destroy(): void;
|
|
1001
|
+
}
|
|
1002
|
+
declare class ParticlesLayer extends BaseLayer {
|
|
1003
|
+
private canvas?;
|
|
1004
|
+
private ctx?;
|
|
1005
|
+
private particles;
|
|
1006
|
+
private canvas2DRenderer?;
|
|
1007
|
+
constructor(id: string, config: Record<string, any>);
|
|
1008
|
+
mount(ctx: LayerMountContext): void;
|
|
1009
|
+
update(ctx: FrameContext$1): void;
|
|
1010
|
+
destroy(): void;
|
|
1011
|
+
}
|
|
1012
|
+
declare class StarfieldLayer extends BaseLayer {
|
|
1013
|
+
private canvas?;
|
|
1014
|
+
private ctx?;
|
|
1015
|
+
private stars;
|
|
1016
|
+
private canvas2DRenderer?;
|
|
1017
|
+
constructor(id: string, config: Record<string, any>);
|
|
1018
|
+
mount(ctx: LayerMountContext): void;
|
|
1019
|
+
update(ctx: FrameContext$1): void;
|
|
1020
|
+
destroy(): void;
|
|
1021
|
+
}
|
|
1022
|
+
declare class DustLayer extends BaseLayer {
|
|
1023
|
+
private canvas?;
|
|
1024
|
+
private ctx?;
|
|
1025
|
+
private dustParticles;
|
|
1026
|
+
private canvas2DRenderer?;
|
|
1027
|
+
constructor(id: string, config: Record<string, any>);
|
|
1028
|
+
mount(ctx: LayerMountContext): void;
|
|
1029
|
+
update(ctx: FrameContext$1): void;
|
|
1030
|
+
destroy(): void;
|
|
1031
|
+
}
|
|
1032
|
+
declare class NebulaNoiseLayer extends BaseLayer {
|
|
1033
|
+
private canvas?;
|
|
1034
|
+
private ctx?;
|
|
1035
|
+
private noiseData?;
|
|
1036
|
+
private canvas2DRenderer?;
|
|
1037
|
+
constructor(id: string, config: Record<string, any>);
|
|
1038
|
+
mount(ctx: LayerMountContext): void;
|
|
1039
|
+
update(ctx: FrameContext$1): void;
|
|
1040
|
+
private perlinNoise;
|
|
1041
|
+
private noise;
|
|
1042
|
+
private hexToRgb;
|
|
1043
|
+
destroy(): void;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* Animation track compilation system
|
|
1048
|
+
*
|
|
1049
|
+
* Provides high-performance animation compilation with comprehensive easing functions,
|
|
1050
|
+
* interpolation for different value types, and support for loops and yoyo effects.
|
|
1051
|
+
* All animations are precompiled at parse time to avoid per-frame calculations.
|
|
1052
|
+
*
|
|
1053
|
+
* Requirements: 6.1, 6.2, 6.3, 6.4, 6.5
|
|
1054
|
+
*/
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* Animation compilation system with optimized easing and interpolation functions
|
|
1058
|
+
*/
|
|
1059
|
+
declare class AnimationCompiler {
|
|
1060
|
+
/**
|
|
1061
|
+
* Compiles an animation track specification into an optimized runtime track
|
|
1062
|
+
*
|
|
1063
|
+
* @param track - Animation track specification to compile
|
|
1064
|
+
* @returns Compiled animation track with precompiled interpolation function
|
|
1065
|
+
*/
|
|
1066
|
+
static compileTrack(track: AnimationTrackSpec): CompiledAnimationTrack;
|
|
1067
|
+
/**
|
|
1068
|
+
* Compiles an easing function from string specification to optimized function
|
|
1069
|
+
*
|
|
1070
|
+
* @param easing - Easing type or cubic-bezier specification
|
|
1071
|
+
* @returns Optimized easing function that maps [0,1] to [0,1]
|
|
1072
|
+
*/
|
|
1073
|
+
static compileEasing(easing: EasingType): EasingFunction;
|
|
1074
|
+
/**
|
|
1075
|
+
* Compiles an interpolation function for animating between two values
|
|
1076
|
+
*
|
|
1077
|
+
* @param from - Starting value
|
|
1078
|
+
* @param to - Ending value
|
|
1079
|
+
* @param easingFunction - Easing function to apply
|
|
1080
|
+
* @returns Optimized interpolation function
|
|
1081
|
+
*/
|
|
1082
|
+
static compileInterpolation(from: AnimationValue, to: AnimationValue, easingFunction: EasingFunction): InterpolationFunction;
|
|
1083
|
+
/**
|
|
1084
|
+
* Creates a cubic-bezier easing function with the given control points
|
|
1085
|
+
*/
|
|
1086
|
+
private static cubicBezier;
|
|
1087
|
+
/**
|
|
1088
|
+
* Parses and compiles a cubic-bezier string specification
|
|
1089
|
+
*/
|
|
1090
|
+
private static compileCubicBezier;
|
|
1091
|
+
/**
|
|
1092
|
+
* Creates a back easing function with overshoot
|
|
1093
|
+
*/
|
|
1094
|
+
private static backEasing;
|
|
1095
|
+
/**
|
|
1096
|
+
* Creates an elastic easing function with oscillation
|
|
1097
|
+
*/
|
|
1098
|
+
private static elasticEasing;
|
|
1099
|
+
/**
|
|
1100
|
+
* Bounce easing out function
|
|
1101
|
+
*/
|
|
1102
|
+
private static bounceOut;
|
|
1103
|
+
/**
|
|
1104
|
+
* Determines the type of an animation value
|
|
1105
|
+
*/
|
|
1106
|
+
private static getValueType;
|
|
1107
|
+
/**
|
|
1108
|
+
* Compiles number interpolation with optimized performance
|
|
1109
|
+
*/
|
|
1110
|
+
private static compileNumberInterpolation;
|
|
1111
|
+
/**
|
|
1112
|
+
* Compiles string interpolation with CSS value support
|
|
1113
|
+
*/
|
|
1114
|
+
private static compileStringInterpolation;
|
|
1115
|
+
/**
|
|
1116
|
+
* Compiles boolean interpolation (discrete transition)
|
|
1117
|
+
*/
|
|
1118
|
+
private static compileBooleanInterpolation;
|
|
1119
|
+
/**
|
|
1120
|
+
* Compiles object interpolation for complex values
|
|
1121
|
+
*/
|
|
1122
|
+
private static compileObjectInterpolation;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* DOM-based rendering backend
|
|
1127
|
+
* Optimized for 60-120fps performance using CSS transforms and will-change properties
|
|
1128
|
+
*/
|
|
1129
|
+
|
|
1130
|
+
declare class DOMRenderer extends RenderBackend {
|
|
1131
|
+
private domContainer;
|
|
1132
|
+
private layerElements;
|
|
1133
|
+
private initialized;
|
|
1134
|
+
initialize(): void;
|
|
1135
|
+
render(layers: ICinematicLayer[], context: FrameContext$1): void;
|
|
1136
|
+
resize(width: number, height: number): void;
|
|
1137
|
+
destroy(): void;
|
|
1138
|
+
/**
|
|
1139
|
+
* Create a DOM element for a layer with performance optimizations
|
|
1140
|
+
*/
|
|
1141
|
+
createLayerElement(layerId: string, zIndex: number): HTMLElement;
|
|
1142
|
+
/**
|
|
1143
|
+
* Remove a layer element from the DOM
|
|
1144
|
+
*/
|
|
1145
|
+
removeLayerElement(layerId: string): void;
|
|
1146
|
+
/**
|
|
1147
|
+
* Get the DOM container for layers
|
|
1148
|
+
*/
|
|
1149
|
+
getDOMContainer(): HTMLElement;
|
|
1150
|
+
/**
|
|
1151
|
+
* Get a layer element by ID
|
|
1152
|
+
*/
|
|
1153
|
+
getLayerElement(layerId: string): HTMLElement | undefined;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
/**
|
|
1157
|
+
* Canvas2D-based rendering backend with devicePixelRatio scaling and object pooling
|
|
1158
|
+
*
|
|
1159
|
+
* This renderer handles particles, noise, and starfields with high performance
|
|
1160
|
+
* through object pooling and efficient canvas operations.
|
|
1161
|
+
*
|
|
1162
|
+
* Requirements: 4.2, 4.4 - Canvas2D rendering with devicePixelRatio and object pooling
|
|
1163
|
+
*/
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* Canvas2D renderer with devicePixelRatio scaling and performance monitoring
|
|
1167
|
+
*/
|
|
1168
|
+
declare class Canvas2DRenderer extends RenderBackend {
|
|
1169
|
+
private canvas;
|
|
1170
|
+
private ctx;
|
|
1171
|
+
private devicePixelRatio;
|
|
1172
|
+
private width;
|
|
1173
|
+
private height;
|
|
1174
|
+
private canvasWidth;
|
|
1175
|
+
private canvasHeight;
|
|
1176
|
+
private particlePool;
|
|
1177
|
+
private activeParticles;
|
|
1178
|
+
private performanceMetrics;
|
|
1179
|
+
private lastFrameTime;
|
|
1180
|
+
private frameCount;
|
|
1181
|
+
private fpsUpdateTime;
|
|
1182
|
+
constructor(container: HTMLElement);
|
|
1183
|
+
initialize(): void;
|
|
1184
|
+
render(layers: ICinematicLayer[], context: FrameContext$1): void;
|
|
1185
|
+
private renderParticleLayer;
|
|
1186
|
+
private renderNoiseLayer;
|
|
1187
|
+
private initializeParticle;
|
|
1188
|
+
private drawStar;
|
|
1189
|
+
private simpleNoise;
|
|
1190
|
+
private updatePerformanceMetrics;
|
|
1191
|
+
resize(width: number, height: number): void;
|
|
1192
|
+
destroy(): void;
|
|
1193
|
+
/**
|
|
1194
|
+
* Get current performance metrics
|
|
1195
|
+
*/
|
|
1196
|
+
getPerformanceMetrics(): PerformanceMetrics;
|
|
1197
|
+
/**
|
|
1198
|
+
* Create a canvas for a specific layer (used by layers that need their own canvas)
|
|
1199
|
+
*/
|
|
1200
|
+
createLayerCanvas(width: number, height: number): HTMLCanvasElement;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/**
|
|
1204
|
+
* Audio system with WebAudio API and HTMLAudio fallback
|
|
1205
|
+
*
|
|
1206
|
+
* This system handles audio playback for cinematic experiences with support for:
|
|
1207
|
+
* - WebAudio API for precise timing and effects
|
|
1208
|
+
* - HTMLAudio fallback for compatibility
|
|
1209
|
+
* - Multiple audio track types (voiceover, ambience, transition, music, sfx)
|
|
1210
|
+
* - Fade in/out effects and volume control
|
|
1211
|
+
* - Audio-visual timeline synchronization
|
|
1212
|
+
* - Graceful handling of autoplay restrictions
|
|
1213
|
+
*
|
|
1214
|
+
* Requirements: 7.1, 7.2, 7.3, 7.4, 7.5
|
|
1215
|
+
*/
|
|
1216
|
+
|
|
1217
|
+
interface AudioSystemConfig {
|
|
1218
|
+
/** Preferred audio context sample rate */
|
|
1219
|
+
sampleRate?: number;
|
|
1220
|
+
/** Master volume (0-1) */
|
|
1221
|
+
masterVolume?: number;
|
|
1222
|
+
/** Whether to use WebAudio API when available */
|
|
1223
|
+
preferWebAudio?: boolean;
|
|
1224
|
+
/** Maximum number of concurrent audio tracks */
|
|
1225
|
+
maxConcurrentTracks?: number;
|
|
1226
|
+
/** Default fade duration in milliseconds */
|
|
1227
|
+
defaultFadeDuration?: number;
|
|
1228
|
+
}
|
|
1229
|
+
interface AudioSystemEvents {
|
|
1230
|
+
'track-started': (trackId: string) => void;
|
|
1231
|
+
'track-ended': (trackId: string) => void;
|
|
1232
|
+
'track-error': (trackId: string, error: Error) => void;
|
|
1233
|
+
'context-suspended': () => void;
|
|
1234
|
+
'context-resumed': () => void;
|
|
1235
|
+
'autoplay-blocked': (trackId: string) => void;
|
|
1236
|
+
}
|
|
1237
|
+
declare class AudioSystem {
|
|
1238
|
+
private _config;
|
|
1239
|
+
private _eventListeners;
|
|
1240
|
+
private _audioContext;
|
|
1241
|
+
private _masterGainNode;
|
|
1242
|
+
private _activeTracks;
|
|
1243
|
+
private _compiledTracks;
|
|
1244
|
+
private _isInitialized;
|
|
1245
|
+
private _currentTime;
|
|
1246
|
+
private _isPlaying;
|
|
1247
|
+
private _userInteracted;
|
|
1248
|
+
constructor(config?: AudioSystemConfig);
|
|
1249
|
+
/**
|
|
1250
|
+
* Initialize the audio system
|
|
1251
|
+
*/
|
|
1252
|
+
initialize(): Promise<void>;
|
|
1253
|
+
/**
|
|
1254
|
+
* Load and compile audio tracks for a scene
|
|
1255
|
+
*/
|
|
1256
|
+
loadTracks(tracks: CompiledAudioTrack[]): Promise<void>;
|
|
1257
|
+
/**
|
|
1258
|
+
* Start playback of the audio system
|
|
1259
|
+
*/
|
|
1260
|
+
play(): void;
|
|
1261
|
+
/**
|
|
1262
|
+
* Pause playback of all audio tracks
|
|
1263
|
+
*/
|
|
1264
|
+
pause(): void;
|
|
1265
|
+
/**
|
|
1266
|
+
* Stop playback and reset all tracks
|
|
1267
|
+
*/
|
|
1268
|
+
stop(): void;
|
|
1269
|
+
/**
|
|
1270
|
+
* Update audio system with current timeline position
|
|
1271
|
+
*/
|
|
1272
|
+
update(timeMs: number): void;
|
|
1273
|
+
/**
|
|
1274
|
+
* Seek to a specific time position
|
|
1275
|
+
*/
|
|
1276
|
+
seek(timeMs: number): void;
|
|
1277
|
+
/**
|
|
1278
|
+
* Set master volume
|
|
1279
|
+
*/
|
|
1280
|
+
setMasterVolume(volume: number): void;
|
|
1281
|
+
/**
|
|
1282
|
+
* Get current master volume
|
|
1283
|
+
*/
|
|
1284
|
+
getMasterVolume(): number;
|
|
1285
|
+
/**
|
|
1286
|
+
* Check if audio context is available and active
|
|
1287
|
+
*/
|
|
1288
|
+
isWebAudioAvailable(): boolean;
|
|
1289
|
+
/**
|
|
1290
|
+
* Get current audio context state
|
|
1291
|
+
*/
|
|
1292
|
+
getAudioContextState(): AudioContextState | null;
|
|
1293
|
+
/**
|
|
1294
|
+
* Get active track count
|
|
1295
|
+
*/
|
|
1296
|
+
getActiveTrackCount(): number;
|
|
1297
|
+
/**
|
|
1298
|
+
* Destroy the audio system and clean up resources
|
|
1299
|
+
*/
|
|
1300
|
+
destroy(): void;
|
|
1301
|
+
/**
|
|
1302
|
+
* Add event listener
|
|
1303
|
+
*/
|
|
1304
|
+
on<K extends keyof AudioSystemEvents>(event: K, callback: AudioSystemEvents[K]): void;
|
|
1305
|
+
/**
|
|
1306
|
+
* Remove event listener
|
|
1307
|
+
*/
|
|
1308
|
+
off<K extends keyof AudioSystemEvents>(event: K, callback: AudioSystemEvents[K]): void;
|
|
1309
|
+
private _initializeWebAudio;
|
|
1310
|
+
private _createHTMLAudioElement;
|
|
1311
|
+
private _startTrack;
|
|
1312
|
+
private _startWebAudioTrack;
|
|
1313
|
+
private _startHTMLAudioTrack;
|
|
1314
|
+
private _pauseTrack;
|
|
1315
|
+
private _stopTrack;
|
|
1316
|
+
private _forceStopTrack;
|
|
1317
|
+
private _updateTrack;
|
|
1318
|
+
private _fadeHTMLAudio;
|
|
1319
|
+
private _setupUserInteractionDetection;
|
|
1320
|
+
private _emit;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
/**
|
|
1324
|
+
* Adaptive quality system for performance optimization
|
|
1325
|
+
*
|
|
1326
|
+
* This system monitors performance metrics and automatically adjusts
|
|
1327
|
+
* rendering quality to maintain target frame rates while respecting
|
|
1328
|
+
* user preferences and device capabilities.
|
|
1329
|
+
*
|
|
1330
|
+
* Requirements: 8.1, 8.2, 8.3, 8.4, 8.5
|
|
1331
|
+
*/
|
|
1332
|
+
|
|
1333
|
+
declare class QualitySystem {
|
|
1334
|
+
private currentQuality;
|
|
1335
|
+
private currentSettings;
|
|
1336
|
+
private deviceCapabilities;
|
|
1337
|
+
private config;
|
|
1338
|
+
private performanceHistory;
|
|
1339
|
+
private badFrameCount;
|
|
1340
|
+
private goodFrameCount;
|
|
1341
|
+
private lastQualityChange;
|
|
1342
|
+
private eventCallbacks;
|
|
1343
|
+
constructor(config?: Partial<QualitySystemConfig>);
|
|
1344
|
+
setQuality(level: QualityLevel$1): void;
|
|
1345
|
+
getCurrentQuality(): QualityLevel$1;
|
|
1346
|
+
getCurrentSettings(): QualitySettings;
|
|
1347
|
+
getDeviceCapabilities(): DeviceCapabilities;
|
|
1348
|
+
updatePerformanceMetrics(metrics: PerformanceMetrics): void;
|
|
1349
|
+
addEventListener(callback: (event: PerformanceEvent) => void): void;
|
|
1350
|
+
removeEventListener(callback: (event: PerformanceEvent) => void): void;
|
|
1351
|
+
private getQualitySettings;
|
|
1352
|
+
private getQualityPresets;
|
|
1353
|
+
private detectDeviceCapabilities;
|
|
1354
|
+
private detectHardwareAcceleration;
|
|
1355
|
+
private detectMobile;
|
|
1356
|
+
private detectConnectionType;
|
|
1357
|
+
private determineInitialQuality;
|
|
1358
|
+
private determineAutoQuality;
|
|
1359
|
+
private evaluatePerformanceAndAdjust;
|
|
1360
|
+
private reduceQuality;
|
|
1361
|
+
private increaseQuality;
|
|
1362
|
+
private checkPerformanceWarnings;
|
|
1363
|
+
private getRecentMetrics;
|
|
1364
|
+
private getLatestMetrics;
|
|
1365
|
+
private emitEvent;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
/**
|
|
1369
|
+
* JSON Specification Parser with Zod validation
|
|
1370
|
+
*
|
|
1371
|
+
* Provides comprehensive JSON schema validation, default value application,
|
|
1372
|
+
* and descriptive error message generation for cinematic specifications.
|
|
1373
|
+
* Supports schema versioning for backward compatibility.
|
|
1374
|
+
*
|
|
1375
|
+
* Requirements: 3.1, 3.2, 3.4, 3.5
|
|
1376
|
+
*/
|
|
1377
|
+
|
|
1378
|
+
/**
|
|
1379
|
+
* SpecParser class with comprehensive Zod validation and compilation
|
|
1380
|
+
*/
|
|
1381
|
+
declare class SpecParser {
|
|
1382
|
+
/**
|
|
1383
|
+
* Validates and parses a raw JSON specification into a validated CinematicSpec
|
|
1384
|
+
*
|
|
1385
|
+
* @param spec - Raw JSON specification to validate
|
|
1386
|
+
* @returns Validated CinematicSpec with applied defaults
|
|
1387
|
+
* @throws ZodError with descriptive validation messages
|
|
1388
|
+
*/
|
|
1389
|
+
static validate(spec: unknown): CinematicSpec;
|
|
1390
|
+
/**
|
|
1391
|
+
* Compiles a validated CinematicSpec into an optimized CompiledSpec
|
|
1392
|
+
*
|
|
1393
|
+
* @param spec - Validated CinematicSpec to compile
|
|
1394
|
+
* @returns CompiledSpec with precompiled animations and optimized runtime structures
|
|
1395
|
+
*/
|
|
1396
|
+
static parse(spec: CinematicSpec): CompiledSpec;
|
|
1397
|
+
/**
|
|
1398
|
+
* Validates specification based on schema version
|
|
1399
|
+
*/
|
|
1400
|
+
private static validateByVersion;
|
|
1401
|
+
/**
|
|
1402
|
+
* Compiles asset definitions into runtime assets
|
|
1403
|
+
*/
|
|
1404
|
+
private static compileAssets;
|
|
1405
|
+
/**
|
|
1406
|
+
* Compiles scene definitions into runtime scenes
|
|
1407
|
+
*/
|
|
1408
|
+
private static compileScenes;
|
|
1409
|
+
/**
|
|
1410
|
+
* Compiles layer specifications into runtime layers
|
|
1411
|
+
*/
|
|
1412
|
+
private static compileLayers;
|
|
1413
|
+
/**
|
|
1414
|
+
* Compiles animation tracks into optimized runtime animations
|
|
1415
|
+
*/
|
|
1416
|
+
private static compileAnimationTracks;
|
|
1417
|
+
/**
|
|
1418
|
+
* Compiles audio tracks into runtime audio objects
|
|
1419
|
+
*/
|
|
1420
|
+
private static compileAudioTracks;
|
|
1421
|
+
/**
|
|
1422
|
+
* Compiles event definitions into runtime events
|
|
1423
|
+
*/
|
|
1424
|
+
private static compileEvents;
|
|
1425
|
+
/**
|
|
1426
|
+
* Compiles transition specifications into runtime transitions
|
|
1427
|
+
*/
|
|
1428
|
+
private static compileTransitions;
|
|
1429
|
+
/**
|
|
1430
|
+
* Formats Zod validation errors into human-readable messages
|
|
1431
|
+
*/
|
|
1432
|
+
private static formatZodError;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* Frame scheduling system using requestAnimationFrame with FPS monitoring
|
|
1437
|
+
* and performance tracking for adaptive quality management.
|
|
1438
|
+
*
|
|
1439
|
+
* Requirements: 2.5, 8.1, 8.2, 8.3
|
|
1440
|
+
*/
|
|
1441
|
+
|
|
1442
|
+
interface FrameContext {
|
|
1443
|
+
/** Time elapsed since last frame in milliseconds */
|
|
1444
|
+
deltaMs: number;
|
|
1445
|
+
/** Current timestamp from performance.now() */
|
|
1446
|
+
currentTime: number;
|
|
1447
|
+
/** Current frames per second */
|
|
1448
|
+
fps: number;
|
|
1449
|
+
/** Frame number since start */
|
|
1450
|
+
frameNumber: number;
|
|
1451
|
+
/** Current performance metrics */
|
|
1452
|
+
metrics: PerformanceMetrics;
|
|
1453
|
+
}
|
|
1454
|
+
interface SchedulerOptions {
|
|
1455
|
+
/** Target FPS (default: 60) */
|
|
1456
|
+
targetFps?: number;
|
|
1457
|
+
/** FPS monitoring window size in frames (default: 60) */
|
|
1458
|
+
fpsWindowSize?: number;
|
|
1459
|
+
/** Performance monitoring interval in milliseconds (default: 1000) */
|
|
1460
|
+
monitoringInterval?: number;
|
|
1461
|
+
/** Whether to enable adaptive quality (default: true) */
|
|
1462
|
+
enableAdaptiveQuality?: boolean;
|
|
1463
|
+
}
|
|
1464
|
+
declare class Scheduler {
|
|
1465
|
+
private isRunning;
|
|
1466
|
+
private animationFrameId;
|
|
1467
|
+
private lastFrameTime;
|
|
1468
|
+
private frameCallbacks;
|
|
1469
|
+
private frameNumber;
|
|
1470
|
+
private frameTimes;
|
|
1471
|
+
private currentFps;
|
|
1472
|
+
private lastMonitoringTime;
|
|
1473
|
+
private performanceMetrics;
|
|
1474
|
+
private options;
|
|
1475
|
+
private qualityChangeCallbacks;
|
|
1476
|
+
constructor(options?: SchedulerOptions);
|
|
1477
|
+
start(): void;
|
|
1478
|
+
stop(): void;
|
|
1479
|
+
addFrameCallback(callback: (context: FrameContext) => void): void;
|
|
1480
|
+
removeFrameCallback(callback: (context: FrameContext) => void): void;
|
|
1481
|
+
addQualityChangeCallback(callback: (metrics: PerformanceMetrics) => void): void;
|
|
1482
|
+
removeQualityChangeCallback(callback: (metrics: PerformanceMetrics) => void): void;
|
|
1483
|
+
getCurrentFps(): number;
|
|
1484
|
+
getPerformanceMetrics(): PerformanceMetrics;
|
|
1485
|
+
updateMetrics(updates: Partial<PerformanceMetrics>): void;
|
|
1486
|
+
private scheduleFrame;
|
|
1487
|
+
private updateFpsTracking;
|
|
1488
|
+
private performPerformanceCheck;
|
|
1489
|
+
/** Get average frame time over the monitoring window */
|
|
1490
|
+
getAverageFrameTime(): number;
|
|
1491
|
+
/** Get frame time variance (measure of frame time consistency) */
|
|
1492
|
+
getFrameTimeVariance(): number;
|
|
1493
|
+
/** Check if performance is stable (low variance) */
|
|
1494
|
+
isPerformanceStable(): boolean;
|
|
1495
|
+
/** Get performance grade (A, B, C, D, F) */
|
|
1496
|
+
getPerformanceGrade(): string;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
/**
|
|
1500
|
+
* Debug overlay system for cinematicRenderer2D
|
|
1501
|
+
*
|
|
1502
|
+
* Provides real-time debugging information including FPS counter,
|
|
1503
|
+
* timeline info, layer status, and performance metrics.
|
|
1504
|
+
*/
|
|
1505
|
+
|
|
1506
|
+
interface DebugInfo {
|
|
1507
|
+
fps: number;
|
|
1508
|
+
currentTime: number;
|
|
1509
|
+
duration: number;
|
|
1510
|
+
currentEvent: string | null;
|
|
1511
|
+
currentScene: string | null;
|
|
1512
|
+
quality: QualityLevel$1;
|
|
1513
|
+
activeLayers: number;
|
|
1514
|
+
activeParticles: number;
|
|
1515
|
+
domNodes: number;
|
|
1516
|
+
drawCalls: number;
|
|
1517
|
+
memoryUsage?: number;
|
|
1518
|
+
isPlaying: boolean;
|
|
1519
|
+
isPaused: boolean;
|
|
1520
|
+
}
|
|
1521
|
+
interface DebugOverlayOptions {
|
|
1522
|
+
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
1523
|
+
opacity?: number;
|
|
1524
|
+
fontSize?: number;
|
|
1525
|
+
updateInterval?: number;
|
|
1526
|
+
showPerformanceGraph?: boolean;
|
|
1527
|
+
maxGraphPoints?: number;
|
|
1528
|
+
}
|
|
1529
|
+
declare class DebugOverlay {
|
|
1530
|
+
private renderer;
|
|
1531
|
+
private container;
|
|
1532
|
+
private overlayElement;
|
|
1533
|
+
private options;
|
|
1534
|
+
private updateTimer;
|
|
1535
|
+
private isVisible;
|
|
1536
|
+
private fpsHistory;
|
|
1537
|
+
private frameTimeHistory;
|
|
1538
|
+
private lastUpdateTime;
|
|
1539
|
+
constructor(renderer: CinematicRenderer2D, container: HTMLElement, options?: DebugOverlayOptions);
|
|
1540
|
+
show(): void;
|
|
1541
|
+
hide(): void;
|
|
1542
|
+
toggle(): void;
|
|
1543
|
+
destroy(): void;
|
|
1544
|
+
private createOverlay;
|
|
1545
|
+
private getOverlayStyles;
|
|
1546
|
+
private setupEventListeners;
|
|
1547
|
+
private startUpdating;
|
|
1548
|
+
private stopUpdating;
|
|
1549
|
+
private updateDisplay;
|
|
1550
|
+
private gatherDebugInfo;
|
|
1551
|
+
private generateDebugHTML;
|
|
1552
|
+
private generatePerformanceGraph;
|
|
1553
|
+
private updatePerformanceHistory;
|
|
1554
|
+
private getFpsColor;
|
|
1555
|
+
private getQualityColor;
|
|
1556
|
+
private getTargetFps;
|
|
1557
|
+
private getMemoryUsage;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
/**
|
|
1561
|
+
* Utility Types for cinematicRenderer2D
|
|
1562
|
+
*
|
|
1563
|
+
* Common utility types used throughout the cinematic rendering system.
|
|
1564
|
+
* These provide type safety and consistency across all modules.
|
|
1565
|
+
*/
|
|
1566
|
+
/** Viewport dimensions and properties */
|
|
1567
|
+
interface Viewport {
|
|
1568
|
+
/** Viewport width in pixels */
|
|
1569
|
+
width: number;
|
|
1570
|
+
/** Viewport height in pixels */
|
|
1571
|
+
height: number;
|
|
1572
|
+
/** Device pixel ratio */
|
|
1573
|
+
devicePixelRatio: number;
|
|
1574
|
+
/** Aspect ratio (width / height) */
|
|
1575
|
+
aspectRatio: number;
|
|
1576
|
+
}
|
|
1577
|
+
/** 2D point coordinates */
|
|
1578
|
+
interface Point2D {
|
|
1579
|
+
x: number;
|
|
1580
|
+
y: number;
|
|
1581
|
+
}
|
|
1582
|
+
/** 2D vector with magnitude and direction */
|
|
1583
|
+
interface Vector2D extends Point2D {
|
|
1584
|
+
/** Vector magnitude */
|
|
1585
|
+
magnitude?: number;
|
|
1586
|
+
/** Vector angle in radians */
|
|
1587
|
+
angle?: number;
|
|
1588
|
+
}
|
|
1589
|
+
/** Rectangle bounds */
|
|
1590
|
+
interface Rectangle {
|
|
1591
|
+
x: number;
|
|
1592
|
+
y: number;
|
|
1593
|
+
width: number;
|
|
1594
|
+
height: number;
|
|
1595
|
+
}
|
|
1596
|
+
/** Color representation in various formats */
|
|
1597
|
+
interface Color {
|
|
1598
|
+
/** Red component (0-255) */
|
|
1599
|
+
r: number;
|
|
1600
|
+
/** Green component (0-255) */
|
|
1601
|
+
g: number;
|
|
1602
|
+
/** Blue component (0-255) */
|
|
1603
|
+
b: number;
|
|
1604
|
+
/** Alpha component (0-1) */
|
|
1605
|
+
a?: number;
|
|
1606
|
+
}
|
|
1607
|
+
/** HSL color representation */
|
|
1608
|
+
interface HSLColor {
|
|
1609
|
+
/** Hue (0-360) */
|
|
1610
|
+
h: number;
|
|
1611
|
+
/** Saturation (0-100) */
|
|
1612
|
+
s: number;
|
|
1613
|
+
/** Lightness (0-100) */
|
|
1614
|
+
l: number;
|
|
1615
|
+
/** Alpha component (0-1) */
|
|
1616
|
+
a?: number;
|
|
1617
|
+
}
|
|
1618
|
+
/** Time-based value for animations */
|
|
1619
|
+
interface TimeValue {
|
|
1620
|
+
/** Value at this time */
|
|
1621
|
+
value: any;
|
|
1622
|
+
/** Time in milliseconds */
|
|
1623
|
+
time: number;
|
|
1624
|
+
/** Easing function to next keyframe */
|
|
1625
|
+
easing?: string;
|
|
1626
|
+
}
|
|
1627
|
+
/** Event listener callback signature */
|
|
1628
|
+
type EventCallback<T = any> = (data: T) => void;
|
|
1629
|
+
/** Disposable resource interface */
|
|
1630
|
+
interface Disposable {
|
|
1631
|
+
/** Clean up resources */
|
|
1632
|
+
dispose(): void;
|
|
1633
|
+
/** Whether the resource has been disposed */
|
|
1634
|
+
isDisposed: boolean;
|
|
1635
|
+
}
|
|
1636
|
+
/** Observable pattern for event emission */
|
|
1637
|
+
interface Observable<T> {
|
|
1638
|
+
/** Subscribe to events */
|
|
1639
|
+
subscribe(callback: EventCallback<T>): () => void;
|
|
1640
|
+
/** Unsubscribe from events */
|
|
1641
|
+
unsubscribe(callback: EventCallback<T>): void;
|
|
1642
|
+
/** Emit an event */
|
|
1643
|
+
emit(data: T): void;
|
|
1644
|
+
}
|
|
1645
|
+
/** Deep partial type for configuration objects */
|
|
1646
|
+
type DeepPartial<T> = {
|
|
1647
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
1648
|
+
};
|
|
1649
|
+
/** Make all properties required recursively */
|
|
1650
|
+
type DeepRequired<T> = {
|
|
1651
|
+
[P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : T[P];
|
|
1652
|
+
};
|
|
1653
|
+
|
|
1654
|
+
/**
|
|
1655
|
+
* cinematicRenderer2D - High-performance, framework-agnostic cinematic rendering library
|
|
1656
|
+
*
|
|
1657
|
+
* This library renders cinematic experiences from JSON specifications targeting 60-120fps performance.
|
|
1658
|
+
* It provides DOM, Canvas2D, and future WebGL rendering backends with adaptive quality systems.
|
|
1659
|
+
*/
|
|
1660
|
+
|
|
1661
|
+
declare const VERSION = "0.1.0";
|
|
1662
|
+
|
|
1663
|
+
export { AnimationCompiler, type CompiledAnimationTrack as AnimationTrack, type AnimationTrackSpec, type AnimationValue, type AnimationValueObject, type Asset, type AssetCacheConfig, type AssetData, type AssetDefinition$1 as AssetDefinition, type AssetLoadOptions, type AssetLoadProgress, AssetManager, type AssetMetadata$1 as AssetMetadata, type AssetPriority, type AssetType$1 as AssetType, AudioSystem, type AudioTrackSpec, type AudioTrackType, Canvas2DRenderer, type CinematicEvent, CinematicRenderer2D, type CinematicScene, type CinematicSpec, type Color, type CompilationContext, type CompilationDiagnostic, type CompilationOptimizations, type CompiledAnimationTrack, type CompiledAudioTrack, type CompiledEvent, type CompiledLayer, type CompiledScene, type CompiledSpec, type CompiledTransition, DOMRenderer, type DebugInfo, DebugOverlay, type DebugOverlayOptions, type DeepPartial, type DeepRequired, type DeviceCapabilities, type Disposable, DustLayer, type EasingFunction, type EasingType, type EngineConfig, type EventCallback, type FrameContext$1 as FrameContext, GlowOrbLayer, GradientLayer, type HSLColor, type ICinematicLayer, type ICinematicRenderer2D, ImageLayer, type InterpolationFunction, type LayerConfig, type LayerFactory, type LayerMountContext, LayerRegistry, type LayerSpec, type LayerType, NebulaNoiseLayer, NoiseOverlayLayer, type Observable, ParticlesLayer, type PerformanceEvent, type PerformanceMetrics, type PlaybackState, type Point2D, QUALITY_PRESETS, type QualityLevel, type QualitySettings, QualitySystem, type QualitySystemConfig, type Rectangle, RenderBackend, Scheduler, SpecParser, StarfieldLayer, TextBlockLayer, type TimeValue, type TransformConfig, type TransitionConfig, type TransitionFunction, type TransitionSpec, type TransitionType, VERSION, type Vector2D, type Viewport, VignetteLayer };
|