@viji-dev/core 0.2.3 → 0.2.5
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 +12 -0
- package/README.md +8 -6
- package/dist/artist-dts.js +1 -1
- package/dist/artist-global.d.ts +313 -654
- package/dist/artist-jsdoc.d.ts +235 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +20 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
package/dist/artist-global.d.ts
CHANGED
|
@@ -1,658 +1,317 @@
|
|
|
1
1
|
declare namespace VijiCore {
|
|
2
|
-
declare interface AnalysisConfiguration {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
declare interface AudioAPI {
|
|
11
|
-
isConnected: boolean;
|
|
12
|
-
volume: {
|
|
13
|
-
rms: number;
|
|
14
|
-
peak: number;
|
|
15
|
-
};
|
|
16
|
-
beat?: {
|
|
17
|
-
isKick: boolean;
|
|
18
|
-
confidence: number;
|
|
19
|
-
};
|
|
20
|
-
bands: Record<string, number>;
|
|
21
|
-
getFrequencyData: () => Uint8Array;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare interface CaptureFrameOptions {
|
|
25
|
-
/** MIME type for output, e.g., 'image/png', 'image/jpeg', 'image/webp' */
|
|
26
|
-
type?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Target resolution.
|
|
29
|
-
* - number: scale factor relative to current canvas size (e.g., 0.5 = 50%)
|
|
30
|
-
* - { width, height }: exact output size; if aspect ratio differs from canvas,
|
|
31
|
-
* the source is center-cropped to match the target aspect ratio before scaling
|
|
32
|
-
*/
|
|
33
|
-
resolution?: number | {
|
|
34
|
-
width: number;
|
|
35
|
-
height: number;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
declare interface ColorConfig {
|
|
40
|
-
label: string;
|
|
41
|
-
description?: string;
|
|
42
|
-
group?: string;
|
|
43
|
-
category?: ParameterCategory;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
declare interface ColorParameter {
|
|
47
|
-
value: string;
|
|
48
|
-
label: string;
|
|
49
|
-
description?: string;
|
|
50
|
-
group: string;
|
|
51
|
-
category: ParameterCategory;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
declare interface CoreCapabilities {
|
|
55
|
-
/** Audio input is active and connected */
|
|
56
|
-
hasAudio: boolean;
|
|
57
|
-
/** Video input is active and connected */
|
|
58
|
-
hasVideo: boolean;
|
|
59
|
-
/** User interactions (mouse, touch, keyboard) are enabled */
|
|
60
|
-
hasInteraction: boolean;
|
|
61
|
-
/** General parameters are always available */
|
|
62
|
-
hasGeneral: boolean;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
declare interface FaceData {
|
|
66
|
-
bounds: {
|
|
67
|
-
x: number;
|
|
68
|
-
y: number;
|
|
69
|
-
width: number;
|
|
70
|
-
height: number;
|
|
71
|
-
};
|
|
72
|
-
confidence: number;
|
|
73
|
-
landmarks: {
|
|
74
|
-
x: number;
|
|
75
|
-
y: number;
|
|
76
|
-
}[];
|
|
77
|
-
expressions: Record<string, number>;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
declare interface FrameRateInfo {
|
|
81
|
-
mode: FrameRateMode;
|
|
82
|
-
screenRefreshRate: number;
|
|
83
|
-
effectiveRefreshRate: number;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
declare type FrameRateMode = 'full' | 'half';
|
|
87
|
-
|
|
88
|
-
declare interface FrequencyBand {
|
|
89
|
-
name: string;
|
|
90
|
-
min: number;
|
|
91
|
-
max: number;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
declare interface HandData {
|
|
95
|
-
palm: {
|
|
96
|
-
x: number;
|
|
97
|
-
y: number;
|
|
98
|
-
};
|
|
99
|
-
fingers: {
|
|
100
|
-
x: number;
|
|
101
|
-
y: number;
|
|
102
|
-
}[];
|
|
103
|
-
gestures: Record<string, boolean>;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
declare interface KeyboardAPI {
|
|
107
|
-
isPressed(key: string): boolean;
|
|
108
|
-
wasPressed(key: string): boolean;
|
|
109
|
-
wasReleased(key: string): boolean;
|
|
110
|
-
activeKeys: Set<string>;
|
|
111
|
-
pressedThisFrame: Set<string>;
|
|
112
|
-
releasedThisFrame: Set<string>;
|
|
113
|
-
lastKeyPressed: string;
|
|
114
|
-
lastKeyReleased: string;
|
|
115
|
-
shift: boolean;
|
|
116
|
-
ctrl: boolean;
|
|
117
|
-
alt: boolean;
|
|
118
|
-
meta: boolean;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
declare interface MouseAPI {
|
|
122
|
-
x: number;
|
|
123
|
-
y: number;
|
|
124
|
-
isInCanvas: boolean;
|
|
125
|
-
isPressed: boolean;
|
|
126
|
-
leftButton: boolean;
|
|
127
|
-
rightButton: boolean;
|
|
128
|
-
middleButton: boolean;
|
|
129
|
-
velocity: {
|
|
130
|
-
x: number;
|
|
131
|
-
y: number;
|
|
132
|
-
};
|
|
133
|
-
deltaX: number;
|
|
134
|
-
deltaY: number;
|
|
135
|
-
wheelDelta: number;
|
|
136
|
-
wheelX: number;
|
|
137
|
-
wheelY: number;
|
|
138
|
-
wasPressed: boolean;
|
|
139
|
-
wasReleased: boolean;
|
|
140
|
-
wasMoved: boolean;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
declare interface NumberConfig {
|
|
144
|
-
min?: number;
|
|
145
|
-
max?: number;
|
|
146
|
-
step?: number;
|
|
147
|
-
label: string;
|
|
148
|
-
description?: string;
|
|
149
|
-
group?: string;
|
|
150
|
-
category?: ParameterCategory;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
declare interface NumberParameter {
|
|
154
|
-
value: number;
|
|
155
|
-
min: number;
|
|
156
|
-
max: number;
|
|
157
|
-
step: number;
|
|
158
|
-
label: string;
|
|
159
|
-
description?: string;
|
|
160
|
-
group: string;
|
|
161
|
-
category: ParameterCategory;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
declare interface ParameterAPI {
|
|
165
|
-
define(groups: ParameterGroup[]): void;
|
|
166
|
-
[key: string]: any;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
declare type ParameterCategory = 'audio' | 'video' | 'interaction' | 'general';
|
|
170
|
-
|
|
171
|
-
declare interface ParameterConfig {
|
|
172
|
-
min?: number;
|
|
173
|
-
max?: number;
|
|
174
|
-
step?: number;
|
|
175
|
-
options?: string[] | number[];
|
|
176
|
-
maxLength?: number;
|
|
177
|
-
label?: string;
|
|
178
|
-
description?: string;
|
|
179
|
-
hidden?: boolean;
|
|
180
|
-
precision?: number;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
declare interface ParameterDefinition {
|
|
184
|
-
type: 'slider' | 'color' | 'toggle' | 'select' | 'text' | 'number';
|
|
185
|
-
defaultValue: any;
|
|
186
|
-
label?: string;
|
|
187
|
-
description?: string;
|
|
188
|
-
group?: string;
|
|
189
|
-
category?: ParameterCategory;
|
|
190
|
-
config?: ParameterConfig;
|
|
191
|
-
validate?: (value: any) => boolean;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
declare interface ParameterGroup {
|
|
195
|
-
groupName: string;
|
|
196
|
-
category?: ParameterCategory;
|
|
197
|
-
description?: string;
|
|
198
|
-
collapsed?: boolean;
|
|
199
|
-
order?: number;
|
|
200
|
-
parameters: Record<string, ParameterDefinition>;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
declare type ParameterValue = string | number | boolean;
|
|
204
|
-
|
|
205
|
-
declare interface PerformanceStats {
|
|
206
|
-
frameTime: number;
|
|
207
|
-
resolution: Resolution;
|
|
208
|
-
scale: number;
|
|
209
|
-
frameRate: FrameRateInfo;
|
|
210
|
-
memoryUsage?: number;
|
|
211
|
-
activeStreams?: number;
|
|
212
|
-
parameterCount?: number;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
declare type Resolution = {
|
|
216
|
-
width: number;
|
|
217
|
-
height: number;
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
declare interface SelectConfig {
|
|
221
|
-
options: string[] | number[];
|
|
222
|
-
label: string;
|
|
223
|
-
description?: string;
|
|
224
|
-
group?: string;
|
|
225
|
-
category?: ParameterCategory;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
declare interface SelectParameter {
|
|
229
|
-
value: string | number;
|
|
230
|
-
options: string[] | number[];
|
|
231
|
-
label: string;
|
|
232
|
-
description?: string;
|
|
233
|
-
group: string;
|
|
234
|
-
category: ParameterCategory;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
declare interface SliderConfig {
|
|
238
|
-
min?: number;
|
|
239
|
-
max?: number;
|
|
240
|
-
step?: number;
|
|
241
|
-
label: string;
|
|
242
|
-
description?: string;
|
|
243
|
-
group?: string;
|
|
244
|
-
category?: ParameterCategory;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
declare interface SliderParameter {
|
|
248
|
-
value: number;
|
|
249
|
-
min: number;
|
|
250
|
-
max: number;
|
|
251
|
-
step: number;
|
|
252
|
-
label: string;
|
|
253
|
-
description?: string;
|
|
254
|
-
group: string;
|
|
255
|
-
category: ParameterCategory;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
declare interface TextConfig {
|
|
259
|
-
label: string;
|
|
260
|
-
description?: string;
|
|
261
|
-
group?: string;
|
|
262
|
-
category?: ParameterCategory;
|
|
263
|
-
maxLength?: number;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
declare interface TextParameter {
|
|
267
|
-
value: string;
|
|
268
|
-
maxLength?: number;
|
|
269
|
-
label: string;
|
|
270
|
-
description?: string;
|
|
271
|
-
group: string;
|
|
272
|
-
category: ParameterCategory;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
declare interface ToggleConfig {
|
|
276
|
-
label: string;
|
|
277
|
-
description?: string;
|
|
278
|
-
group?: string;
|
|
279
|
-
category?: ParameterCategory;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
declare interface ToggleParameter {
|
|
283
|
-
value: boolean;
|
|
284
|
-
label: string;
|
|
285
|
-
description?: string;
|
|
286
|
-
group: string;
|
|
287
|
-
category: ParameterCategory;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
declare interface TouchAPI {
|
|
291
|
-
points: TouchPoint[];
|
|
292
|
-
count: number;
|
|
293
|
-
started: TouchPoint[];
|
|
294
|
-
moved: TouchPoint[];
|
|
295
|
-
ended: TouchPoint[];
|
|
296
|
-
primary: TouchPoint | null;
|
|
297
|
-
gestures: TouchGestureAPI;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
declare interface TouchGestureAPI {
|
|
301
|
-
isPinching: boolean;
|
|
302
|
-
isRotating: boolean;
|
|
303
|
-
isPanning: boolean;
|
|
304
|
-
isTapping: boolean;
|
|
305
|
-
pinchScale: number;
|
|
306
|
-
pinchDelta: number;
|
|
307
|
-
rotationAngle: number;
|
|
308
|
-
rotationDelta: number;
|
|
309
|
-
panDelta: {
|
|
310
|
-
x: number;
|
|
311
|
-
y: number;
|
|
312
|
-
};
|
|
313
|
-
tapCount: number;
|
|
314
|
-
lastTapTime: number;
|
|
315
|
-
tapPosition: {
|
|
316
|
-
x: number;
|
|
317
|
-
y: number;
|
|
318
|
-
} | null;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
declare interface TouchPoint {
|
|
322
|
-
id: number;
|
|
323
|
-
x: number;
|
|
324
|
-
y: number;
|
|
325
|
-
pressure: number;
|
|
326
|
-
radius: number;
|
|
327
|
-
radiusX: number;
|
|
328
|
-
radiusY: number;
|
|
329
|
-
rotationAngle: number;
|
|
330
|
-
force: number;
|
|
331
|
-
deltaX: number;
|
|
332
|
-
deltaY: number;
|
|
333
|
-
velocity: {
|
|
334
|
-
x: number;
|
|
335
|
-
y: number;
|
|
336
|
-
};
|
|
337
|
-
isNew: boolean;
|
|
338
|
-
isActive: boolean;
|
|
339
|
-
isEnding: boolean;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
declare const VERSION = "0.2.2";
|
|
343
|
-
|
|
344
|
-
declare interface VideoAPI {
|
|
345
|
-
isConnected: boolean;
|
|
346
|
-
currentFrame: OffscreenCanvas | null;
|
|
347
|
-
frameWidth: number;
|
|
348
|
-
frameHeight: number;
|
|
349
|
-
frameRate: number;
|
|
350
|
-
getFrameData: () => ImageData | null;
|
|
351
|
-
faces: FaceData[];
|
|
352
|
-
hands: HandData[];
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
declare interface VijiAPI {
|
|
356
|
-
canvas: OffscreenCanvas;
|
|
357
|
-
ctx?: OffscreenCanvasRenderingContext2D;
|
|
358
|
-
gl?: WebGL2RenderingContext;
|
|
359
|
-
width: number;
|
|
360
|
-
height: number;
|
|
361
|
-
pixelRatio: number;
|
|
362
|
-
time: number;
|
|
363
|
-
deltaTime: number;
|
|
364
|
-
frameCount: number;
|
|
365
|
-
fps: number;
|
|
366
|
-
audio: AudioAPI;
|
|
367
|
-
video: VideoAPI;
|
|
368
|
-
mouse: MouseAPI;
|
|
369
|
-
keyboard: KeyboardAPI;
|
|
370
|
-
touches: TouchAPI[];
|
|
371
|
-
slider: (defaultValue: number, config: SliderConfig) => SliderParameter;
|
|
372
|
-
color: (defaultValue: string, config: ColorConfig) => ColorParameter;
|
|
373
|
-
toggle: (defaultValue: boolean, config: ToggleConfig) => ToggleParameter;
|
|
374
|
-
select: (defaultValue: string | number, config: SelectConfig) => SelectParameter;
|
|
375
|
-
text: (defaultValue: string, config: TextConfig) => TextParameter;
|
|
376
|
-
number: (defaultValue: number, config: NumberConfig) => NumberParameter;
|
|
377
|
-
useContext(type: '2d' | 'webgl'): OffscreenCanvasRenderingContext2D | WebGLRenderingContext | WebGL2RenderingContext | null;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Main VijiCore class - Universal execution engine for creative scenes.
|
|
382
|
-
*
|
|
383
|
-
* Orchestrates secure IFrame + WebWorker execution with controlled communication.
|
|
384
|
-
* Provides the foundation for scene execution across platform and SDK contexts.
|
|
385
|
-
*/
|
|
386
|
-
declare class VijiCore {
|
|
387
|
-
private iframeManager;
|
|
388
|
-
private workerManager;
|
|
389
|
-
private interactionManager;
|
|
390
|
-
private audioSystem;
|
|
391
|
-
private videoCoordinator;
|
|
392
|
-
private isInitialized;
|
|
393
|
-
private isDestroyed;
|
|
394
|
-
private isInitializing;
|
|
395
|
-
private instanceId;
|
|
396
|
-
private screenRefreshRate;
|
|
397
|
-
private debugMode;
|
|
398
|
-
/**
|
|
399
|
-
* Debug logging helper
|
|
400
|
-
*/
|
|
401
|
-
private debugLog;
|
|
402
|
-
private config;
|
|
403
|
-
private currentAudioStream;
|
|
404
|
-
private currentVideoStream;
|
|
405
|
-
private currentInteractionEnabled;
|
|
406
|
-
private parameterGroups;
|
|
407
|
-
private parameterValues;
|
|
408
|
-
private parametersInitialized;
|
|
409
|
-
private parameterListeners;
|
|
410
|
-
private parameterDefinedListeners;
|
|
411
|
-
private parameterErrorListeners;
|
|
412
|
-
private capabilitiesChangeListeners;
|
|
413
|
-
private stats;
|
|
414
|
-
constructor(config: VijiCoreConfig);
|
|
415
|
-
/**
|
|
416
|
-
* Capture current scene frame as an image Blob.
|
|
417
|
-
* Resolution can be a scale (0-1+) or explicit width/height with center-crop.
|
|
418
|
-
*/
|
|
419
|
-
captureFrame(options?: CaptureFrameOptions): Promise<Blob>;
|
|
420
|
-
/**
|
|
421
|
-
* Enable or disable debug logging
|
|
422
|
-
*/
|
|
423
|
-
setDebugMode(enabled: boolean): void;
|
|
424
|
-
/**
|
|
425
|
-
* Get current debug mode status
|
|
426
|
-
*/
|
|
427
|
-
getDebugMode(): boolean;
|
|
428
|
-
/**
|
|
429
|
-
* Initializes the core components in sequence
|
|
430
|
-
*/
|
|
431
|
-
initialize(): Promise<void>;
|
|
432
|
-
/**
|
|
433
|
-
* Creates canvas with retry logic to handle timing issues
|
|
434
|
-
*/
|
|
435
|
-
private createCanvasWithRetry;
|
|
436
|
-
/**
|
|
437
|
-
* Sets up the interaction system for Phase 7
|
|
438
|
-
*/
|
|
439
|
-
private setupInteractionSystem;
|
|
440
|
-
/**
|
|
441
|
-
* Sets up communication between components
|
|
442
|
-
*/
|
|
443
|
-
private setupCommunication;
|
|
444
|
-
/**
|
|
445
|
-
* Handle parameter definitions received from worker
|
|
446
|
-
*/
|
|
447
|
-
private handleParametersDefined;
|
|
448
|
-
/**
|
|
449
|
-
* Handle parameter validation errors
|
|
450
|
-
*/
|
|
451
|
-
private handleParameterError;
|
|
452
|
-
/**
|
|
453
|
-
* Set a single parameter value
|
|
454
|
-
*/
|
|
455
|
-
setParameter(name: string, value: ParameterValue): Promise<void>;
|
|
456
|
-
/**
|
|
457
|
-
* Set multiple parameter values efficiently
|
|
458
|
-
*/
|
|
459
|
-
setParameters(values: Record<string, ParameterValue>): Promise<void>;
|
|
460
|
-
/**
|
|
461
|
-
* Get current parameter value
|
|
462
|
-
*/
|
|
463
|
-
getParameter(name: string): ParameterValue | undefined;
|
|
464
|
-
/**
|
|
465
|
-
* Get all current parameter values
|
|
466
|
-
*/
|
|
467
|
-
getParameterValues(): Record<string, ParameterValue>;
|
|
468
|
-
/**
|
|
469
|
-
* Get parameter groups (for UI generation)
|
|
470
|
-
*/
|
|
471
|
-
getParameterGroups(): ParameterGroup[];
|
|
472
|
-
/**
|
|
473
|
-
* Get current core capabilities (what's currently active)
|
|
474
|
-
*/
|
|
475
|
-
getCapabilities(): CoreCapabilities;
|
|
476
|
-
/**
|
|
477
|
-
* Get parameter groups filtered by active capabilities
|
|
478
|
-
*/
|
|
479
|
-
getVisibleParameterGroups(): ParameterGroup[];
|
|
480
|
-
/**
|
|
481
|
-
* Check if a specific parameter category is currently active
|
|
482
|
-
*/
|
|
483
|
-
isCategoryActive(category: ParameterCategory): boolean;
|
|
484
|
-
/**
|
|
485
|
-
* Check if parameters have been initialized
|
|
486
|
-
*/
|
|
487
|
-
get parametersReady(): boolean;
|
|
488
|
-
/**
|
|
489
|
-
* Send all current parameter values to worker (used for initial sync)
|
|
490
|
-
*/
|
|
491
|
-
private syncAllParametersToWorker;
|
|
492
|
-
/**
|
|
493
|
-
* Add listener for when parameters are defined
|
|
494
|
-
*/
|
|
495
|
-
onParametersDefined(listener: (groups: ParameterGroup[]) => void): void;
|
|
496
|
-
/**
|
|
497
|
-
* Remove parameter defined listener
|
|
498
|
-
*/
|
|
499
|
-
offParametersDefined(listener: (groups: ParameterGroup[]) => void): void;
|
|
500
|
-
/**
|
|
501
|
-
* Add listener for parameter value changes
|
|
502
|
-
*/
|
|
503
|
-
onParameterChange(parameterName: string, listener: (value: ParameterValue) => void): void;
|
|
504
|
-
/**
|
|
505
|
-
* Remove parameter change listener
|
|
506
|
-
*/
|
|
507
|
-
offParameterChange(parameterName: string, listener: (value: ParameterValue) => void): void;
|
|
508
|
-
/**
|
|
509
|
-
* Add listener for parameter errors
|
|
510
|
-
*/
|
|
511
|
-
onParameterError(listener: (error: {
|
|
512
|
-
message: string;
|
|
513
|
-
code: string;
|
|
514
|
-
}) => void): void;
|
|
515
|
-
/**
|
|
516
|
-
* Add listener for when core capabilities change (audio/video/interaction state)
|
|
517
|
-
*/
|
|
518
|
-
onCapabilitiesChange(listener: (capabilities: CoreCapabilities) => void): void;
|
|
519
|
-
/**
|
|
520
|
-
* Remove capabilities change listener
|
|
521
|
-
*/
|
|
522
|
-
removeCapabilitiesListener(listener: (capabilities: CoreCapabilities) => void): void;
|
|
523
|
-
/**
|
|
524
|
-
* Notify capability change listeners
|
|
525
|
-
*/
|
|
526
|
-
private notifyCapabilitiesChange;
|
|
527
|
-
/**
|
|
528
|
-
* Remove parameter error listener
|
|
529
|
-
*/
|
|
530
|
-
offParameterError(listener: (error: {
|
|
531
|
-
message: string;
|
|
532
|
-
code: string;
|
|
533
|
-
}) => void): void;
|
|
534
|
-
/**
|
|
535
|
-
* Notify parameter change listeners
|
|
536
|
-
*/
|
|
537
|
-
private notifyParameterListeners;
|
|
538
|
-
/**
|
|
539
|
-
* Sets the frame rate to full speed (every animation frame)
|
|
540
|
-
*/
|
|
541
|
-
setFullFrameRate(): Promise<void>;
|
|
542
|
-
/**
|
|
543
|
-
* Sets the frame rate to half speed (every second animation frame)
|
|
544
|
-
*/
|
|
545
|
-
setHalfFrameRate(): Promise<void>;
|
|
546
|
-
/**
|
|
547
|
-
* Updates the canvas resolution by sending effective dimensions to the worker
|
|
548
|
-
*/
|
|
549
|
-
updateResolution(): void;
|
|
550
|
-
/**
|
|
551
|
-
* Sets the audio stream for analysis
|
|
552
|
-
*/
|
|
553
|
-
setAudioStream(audioStream: MediaStream | null): Promise<void>;
|
|
554
|
-
/**
|
|
555
|
-
* Sets the video stream for processing
|
|
556
|
-
*/
|
|
557
|
-
setVideoStream(videoStream: MediaStream | null): Promise<void>;
|
|
558
|
-
/**
|
|
559
|
-
* Gets the current audio stream
|
|
560
|
-
*/
|
|
561
|
-
getAudioStream(): MediaStream | null;
|
|
562
|
-
/**
|
|
563
|
-
* Gets the current video stream
|
|
564
|
-
*/
|
|
565
|
-
getVideoStream(): MediaStream | null;
|
|
566
|
-
/**
|
|
567
|
-
* Enables or disables user interactions (mouse, keyboard, touch) at runtime
|
|
568
|
-
*/
|
|
569
|
-
setInteractionEnabled(enabled: boolean): Promise<void>;
|
|
570
|
-
/**
|
|
571
|
-
* Gets the current interaction enabled state
|
|
572
|
-
*/
|
|
573
|
-
getInteractionEnabled(): boolean;
|
|
574
|
-
/**
|
|
575
|
-
* Updates audio analysis configuration
|
|
576
|
-
*/
|
|
577
|
-
setAudioAnalysisConfig(config: {
|
|
578
|
-
fftSize?: number;
|
|
579
|
-
smoothing?: number;
|
|
580
|
-
}): Promise<void>;
|
|
581
|
-
/**
|
|
582
|
-
* Updates the canvas resolution by scale
|
|
583
|
-
*/
|
|
584
|
-
setResolution(scale: number): void;
|
|
585
|
-
/**
|
|
586
|
-
* Detects the screen refresh rate
|
|
587
|
-
*/
|
|
588
|
-
private detectScreenRefreshRate;
|
|
589
|
-
/**
|
|
590
|
-
* Updates frame rate statistics
|
|
591
|
-
*/
|
|
592
|
-
private updateFrameRateStats;
|
|
593
|
-
/**
|
|
594
|
-
* Gets current performance statistics
|
|
595
|
-
*/
|
|
596
|
-
getStats(): PerformanceStats;
|
|
597
|
-
/**
|
|
598
|
-
* Checks if the core is ready for use
|
|
599
|
-
*/
|
|
600
|
-
get ready(): boolean;
|
|
601
|
-
/**
|
|
602
|
-
* Gets the current configuration
|
|
603
|
-
*/
|
|
604
|
-
get configuration(): Readonly<VijiCoreConfig>;
|
|
605
|
-
/**
|
|
606
|
-
* Destroys the core instance and cleans up all resources
|
|
607
|
-
*/
|
|
608
|
-
destroy(): Promise<void>;
|
|
609
|
-
/**
|
|
610
|
-
* Validates that the core is ready for operations
|
|
611
|
-
*/
|
|
612
|
-
private validateReady;
|
|
613
|
-
/**
|
|
614
|
-
* Validates the provided configuration
|
|
615
|
-
*/
|
|
616
|
-
private validateConfig;
|
|
617
|
-
/**
|
|
618
|
-
* Cleans up all resources
|
|
619
|
-
*/
|
|
620
|
-
private cleanup;
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
declare interface VijiCoreConfig {
|
|
624
|
-
/** Container element where the scene will be rendered */
|
|
625
|
-
hostContainer: HTMLElement;
|
|
626
|
-
/** Artist scene code to execute */
|
|
627
|
-
sceneCode: string;
|
|
628
|
-
/** Frame rate mode - 'full' for every animation frame, 'half' for every second frame */
|
|
629
|
-
frameRateMode?: FrameRateMode;
|
|
630
|
-
/** Enable automatic performance optimization */
|
|
631
|
-
autoOptimize?: boolean;
|
|
632
|
-
/** Audio input stream */
|
|
633
|
-
audioStream?: MediaStream;
|
|
634
|
-
/** Video input stream */
|
|
635
|
-
videoStream?: MediaStream;
|
|
636
|
-
/** Audio analysis configuration */
|
|
637
|
-
analysisConfig?: AnalysisConfiguration;
|
|
638
|
-
/** Initial parameter values */
|
|
639
|
-
parameters?: ParameterGroup[];
|
|
640
|
-
/** Disable input processing (for preview instances) */
|
|
641
|
-
noInputs?: boolean;
|
|
642
|
-
/** Enable user interaction events */
|
|
643
|
-
allowUserInteraction?: boolean;
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
declare class VijiCoreError extends Error {
|
|
647
|
-
code: string;
|
|
648
|
-
context?: any | undefined;
|
|
649
|
-
constructor(message: string, code: string, context?: any | undefined);
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
{ }
|
|
2
|
+
declare interface AnalysisConfiguration {
|
|
3
|
+
fftSize?: number;
|
|
4
|
+
smoothing?: number;
|
|
5
|
+
frequencyBands?: FrequencyBand[];
|
|
6
|
+
beatDetection?: boolean;
|
|
7
|
+
onsetDetection?: boolean;
|
|
8
|
+
}
|
|
653
9
|
|
|
10
|
+
declare interface AudioAPI {
|
|
11
|
+
isConnected: boolean;
|
|
12
|
+
volume: {
|
|
13
|
+
rms: number;
|
|
14
|
+
peak: number;
|
|
15
|
+
};
|
|
16
|
+
beat?: {
|
|
17
|
+
isKick: boolean;
|
|
18
|
+
confidence: number;
|
|
19
|
+
};
|
|
20
|
+
bands: Record<string, number>;
|
|
21
|
+
getFrequencyData: () => Uint8Array;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare interface CaptureFrameOptions {
|
|
25
|
+
/** MIME type for output, e.g., 'image/png', 'image/jpeg', 'image/webp' */
|
|
26
|
+
type?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Target resolution.
|
|
29
|
+
* - number: scale factor relative to current canvas size (e.g., 0.5 = 50%)
|
|
30
|
+
* - { width, height }: exact output size; if aspect ratio differs from canvas,
|
|
31
|
+
* the source is center-cropped to match the target aspect ratio before scaling
|
|
32
|
+
*/
|
|
33
|
+
resolution?: number | {
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare interface ColorConfig {
|
|
40
|
+
label: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
group?: string;
|
|
43
|
+
category?: ParameterCategory;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare interface ColorParameter {
|
|
47
|
+
value: string;
|
|
48
|
+
label: string;
|
|
49
|
+
description?: string;
|
|
50
|
+
group: string;
|
|
51
|
+
category: ParameterCategory;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
declare interface FaceData {
|
|
55
|
+
bounds: {
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
width: number;
|
|
59
|
+
height: number;
|
|
60
|
+
};
|
|
61
|
+
confidence: number;
|
|
62
|
+
landmarks: {
|
|
63
|
+
x: number;
|
|
64
|
+
y: number;
|
|
65
|
+
}[];
|
|
66
|
+
expressions: Record<string, number>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare type FrameRateMode = 'full' | 'half';
|
|
70
|
+
|
|
71
|
+
declare interface FrequencyBand {
|
|
72
|
+
name: string;
|
|
73
|
+
min: number;
|
|
74
|
+
max: number;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
declare interface HandData {
|
|
78
|
+
palm: {
|
|
79
|
+
x: number;
|
|
80
|
+
y: number;
|
|
81
|
+
};
|
|
82
|
+
fingers: {
|
|
83
|
+
x: number;
|
|
84
|
+
y: number;
|
|
85
|
+
}[];
|
|
86
|
+
gestures: Record<string, boolean>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
declare interface KeyboardAPI {
|
|
90
|
+
isPressed(key: string): boolean;
|
|
91
|
+
wasPressed(key: string): boolean;
|
|
92
|
+
wasReleased(key: string): boolean;
|
|
93
|
+
activeKeys: Set<string>;
|
|
94
|
+
pressedThisFrame: Set<string>;
|
|
95
|
+
releasedThisFrame: Set<string>;
|
|
96
|
+
lastKeyPressed: string;
|
|
97
|
+
lastKeyReleased: string;
|
|
98
|
+
shift: boolean;
|
|
99
|
+
ctrl: boolean;
|
|
100
|
+
alt: boolean;
|
|
101
|
+
meta: boolean;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
declare interface MouseAPI {
|
|
105
|
+
x: number;
|
|
106
|
+
y: number;
|
|
107
|
+
isInCanvas: boolean;
|
|
108
|
+
isPressed: boolean;
|
|
109
|
+
leftButton: boolean;
|
|
110
|
+
rightButton: boolean;
|
|
111
|
+
middleButton: boolean;
|
|
112
|
+
velocity: {
|
|
113
|
+
x: number;
|
|
114
|
+
y: number;
|
|
115
|
+
};
|
|
116
|
+
deltaX: number;
|
|
117
|
+
deltaY: number;
|
|
118
|
+
wheelDelta: number;
|
|
119
|
+
wheelX: number;
|
|
120
|
+
wheelY: number;
|
|
121
|
+
wasPressed: boolean;
|
|
122
|
+
wasReleased: boolean;
|
|
123
|
+
wasMoved: boolean;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
declare interface NumberConfig {
|
|
127
|
+
min?: number;
|
|
128
|
+
max?: number;
|
|
129
|
+
step?: number;
|
|
130
|
+
label: string;
|
|
131
|
+
description?: string;
|
|
132
|
+
group?: string;
|
|
133
|
+
category?: ParameterCategory;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
declare interface NumberParameter {
|
|
137
|
+
value: number;
|
|
138
|
+
min: number;
|
|
139
|
+
max: number;
|
|
140
|
+
step: number;
|
|
141
|
+
label: string;
|
|
142
|
+
description?: string;
|
|
143
|
+
group: string;
|
|
144
|
+
category: ParameterCategory;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
declare type ParameterCategory = 'audio' | 'video' | 'interaction' | 'general';
|
|
148
|
+
|
|
149
|
+
declare type Resolution = {
|
|
150
|
+
width: number;
|
|
151
|
+
height: number;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
declare interface SelectConfig {
|
|
155
|
+
options: string[] | number[];
|
|
156
|
+
label: string;
|
|
157
|
+
description?: string;
|
|
158
|
+
group?: string;
|
|
159
|
+
category?: ParameterCategory;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
declare interface SelectParameter {
|
|
163
|
+
value: string | number;
|
|
164
|
+
options: string[] | number[];
|
|
165
|
+
label: string;
|
|
166
|
+
description?: string;
|
|
167
|
+
group: string;
|
|
168
|
+
category: ParameterCategory;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
declare interface SliderConfig {
|
|
172
|
+
min?: number;
|
|
173
|
+
max?: number;
|
|
174
|
+
step?: number;
|
|
175
|
+
label: string;
|
|
176
|
+
description?: string;
|
|
177
|
+
group?: string;
|
|
178
|
+
category?: ParameterCategory;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
declare interface SliderParameter {
|
|
182
|
+
value: number;
|
|
183
|
+
min: number;
|
|
184
|
+
max: number;
|
|
185
|
+
step: number;
|
|
186
|
+
label: string;
|
|
187
|
+
description?: string;
|
|
188
|
+
group: string;
|
|
189
|
+
category: ParameterCategory;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
declare interface TextConfig {
|
|
193
|
+
label: string;
|
|
194
|
+
description?: string;
|
|
195
|
+
group?: string;
|
|
196
|
+
category?: ParameterCategory;
|
|
197
|
+
maxLength?: number;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
declare interface TextParameter {
|
|
201
|
+
value: string;
|
|
202
|
+
maxLength?: number;
|
|
203
|
+
label: string;
|
|
204
|
+
description?: string;
|
|
205
|
+
group: string;
|
|
206
|
+
category: ParameterCategory;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
declare interface ToggleConfig {
|
|
210
|
+
label: string;
|
|
211
|
+
description?: string;
|
|
212
|
+
group?: string;
|
|
213
|
+
category?: ParameterCategory;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
declare interface ToggleParameter {
|
|
217
|
+
value: boolean;
|
|
218
|
+
label: string;
|
|
219
|
+
description?: string;
|
|
220
|
+
group: string;
|
|
221
|
+
category: ParameterCategory;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
declare interface TouchAPI {
|
|
225
|
+
points: TouchPoint[];
|
|
226
|
+
count: number;
|
|
227
|
+
started: TouchPoint[];
|
|
228
|
+
moved: TouchPoint[];
|
|
229
|
+
ended: TouchPoint[];
|
|
230
|
+
primary: TouchPoint | null;
|
|
231
|
+
gestures: TouchGestureAPI;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
declare interface TouchGestureAPI {
|
|
235
|
+
isPinching: boolean;
|
|
236
|
+
isRotating: boolean;
|
|
237
|
+
isPanning: boolean;
|
|
238
|
+
isTapping: boolean;
|
|
239
|
+
pinchScale: number;
|
|
240
|
+
pinchDelta: number;
|
|
241
|
+
rotationAngle: number;
|
|
242
|
+
rotationDelta: number;
|
|
243
|
+
panDelta: {
|
|
244
|
+
x: number;
|
|
245
|
+
y: number;
|
|
246
|
+
};
|
|
247
|
+
tapCount: number;
|
|
248
|
+
lastTapTime: number;
|
|
249
|
+
tapPosition: {
|
|
250
|
+
x: number;
|
|
251
|
+
y: number;
|
|
252
|
+
} | null;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
declare interface TouchPoint {
|
|
256
|
+
id: number;
|
|
257
|
+
x: number;
|
|
258
|
+
y: number;
|
|
259
|
+
pressure: number;
|
|
260
|
+
radius: number;
|
|
261
|
+
radiusX: number;
|
|
262
|
+
radiusY: number;
|
|
263
|
+
rotationAngle: number;
|
|
264
|
+
force: number;
|
|
265
|
+
deltaX: number;
|
|
266
|
+
deltaY: number;
|
|
267
|
+
velocity: {
|
|
268
|
+
x: number;
|
|
269
|
+
y: number;
|
|
270
|
+
};
|
|
271
|
+
isNew: boolean;
|
|
272
|
+
isActive: boolean;
|
|
273
|
+
isEnding: boolean;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
declare const VERSION = "0.2.4";
|
|
277
|
+
|
|
278
|
+
declare interface VideoAPI {
|
|
279
|
+
isConnected: boolean;
|
|
280
|
+
currentFrame: OffscreenCanvas | null;
|
|
281
|
+
frameWidth: number;
|
|
282
|
+
frameHeight: number;
|
|
283
|
+
frameRate: number;
|
|
284
|
+
getFrameData: () => ImageData | null;
|
|
285
|
+
faces: FaceData[];
|
|
286
|
+
hands: HandData[];
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
declare interface VijiAPI {
|
|
290
|
+
canvas: OffscreenCanvas;
|
|
291
|
+
ctx?: OffscreenCanvasRenderingContext2D;
|
|
292
|
+
gl?: WebGL2RenderingContext;
|
|
293
|
+
width: number;
|
|
294
|
+
height: number;
|
|
295
|
+
pixelRatio: number;
|
|
296
|
+
time: number;
|
|
297
|
+
deltaTime: number;
|
|
298
|
+
frameCount: number;
|
|
299
|
+
fps: number;
|
|
300
|
+
audio: AudioAPI;
|
|
301
|
+
video: VideoAPI;
|
|
302
|
+
mouse: MouseAPI;
|
|
303
|
+
keyboard: KeyboardAPI;
|
|
304
|
+
touches: TouchAPI[];
|
|
305
|
+
slider: (defaultValue: number, config: SliderConfig) => SliderParameter;
|
|
306
|
+
color: (defaultValue: string, config: ColorConfig) => ColorParameter;
|
|
307
|
+
toggle: (defaultValue: boolean, config: ToggleConfig) => ToggleParameter;
|
|
308
|
+
select: (defaultValue: string | number, config: SelectConfig) => SelectParameter;
|
|
309
|
+
text: (defaultValue: string, config: TextConfig) => TextParameter;
|
|
310
|
+
number: (defaultValue: number, config: NumberConfig) => NumberParameter;
|
|
311
|
+
useContext(type: '2d'): OffscreenCanvasRenderingContext2D;
|
|
312
|
+
useContext(type: 'webgl'): WebGLRenderingContext | WebGL2RenderingContext;
|
|
313
|
+
}
|
|
654
314
|
}
|
|
655
315
|
|
|
656
|
-
|
|
657
|
-
declare
|
|
658
|
-
declare function render(viji: VijiCore.ArtistAPI): void;
|
|
316
|
+
declare const viji: VijiCore.VijiAPI;
|
|
317
|
+
declare function render(viji: VijiCore.VijiAPI): void;
|