@viji-dev/core 0.6.2 → 0.7.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.
@@ -1,9 +1,9 @@
1
- // Viji Artist API - Global Type Definitions
2
- // All types are placed inside declare global {} because this file uses export {}
3
- // for top-level await support, which makes it a module (where top-level declarations
4
- // would otherwise be module-scoped, not global).
5
-
6
- declare global {
1
+ // Viji Artist API - Global Type Definitions
2
+ // All types are placed inside declare global {} because this file uses export {}
3
+ // for top-level await support, which makes it a module (where top-level declarations
4
+ // would otherwise be module-scoped, not global).
5
+
6
+ declare global {
7
7
  /**
8
8
  * Real-time audio analysis for the main audio stream (`viji.audio`).
9
9
  * Provides volume, frequency bands, beat detection (with triggers, events, BPM),
@@ -118,7 +118,7 @@ declare global {
118
118
  */
119
119
  getWaveform: () => Float32Array;
120
120
  }
121
-
121
+
122
122
  /**
123
123
  * Lightweight audio analysis for additional or device audio streams. A strict
124
124
  * subset of `AudioAPI` that exposes volume, frequency bands, spectral features,
@@ -178,7 +178,7 @@ declare global {
178
178
  */
179
179
  getWaveform: () => Float32Array;
180
180
  }
181
-
181
+
182
182
  /**
183
183
  * Configuration object passed to `viji.button()`. The host renders a clickable
184
184
  * momentary button. The resulting `value` is `true` for one frame after press,
@@ -194,7 +194,7 @@ declare global {
194
194
  /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */
195
195
  category?: ParameterCategory;
196
196
  }
197
-
197
+
198
198
  /**
199
199
  * Reactive object returned by `viji.button()`. `value` is a momentary flag:
200
200
  * `true` for exactly one frame after the user clicks, then auto-resets to
@@ -212,7 +212,7 @@ declare global {
212
212
  /** Visibility category that controls when the parameter is shown. */
213
213
  category: ParameterCategory;
214
214
  }
215
-
215
+
216
216
  /**
217
217
  * Options accepted by `VijiCore.captureFrame()` for snapshotting the current
218
218
  * scene. Controls output format, encoding, and target resolution / aspect.
@@ -230,7 +230,7 @@ declare global {
230
230
  */
231
231
  resolution?: number | Resolution;
232
232
  }
233
-
233
+
234
234
  /**
235
235
  * Configuration object passed to `viji.color()`. Defines the color picker's
236
236
  * label and UI grouping/visibility.
@@ -245,7 +245,7 @@ declare global {
245
245
  /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */
246
246
  category?: ParameterCategory;
247
247
  }
248
-
248
+
249
249
  /**
250
250
  * Accepted input forms for color parameters. Internally normalized to canonical
251
251
  * lowercase 6-digit hex `#rrggbb`. See `viji.color()` for full documentation.
@@ -270,7 +270,7 @@ declare global {
270
270
  /** Brightness in 0..100. */
271
271
  b: number;
272
272
  };
273
-
273
+
274
274
  /**
275
275
  * Reactive object returned by `viji.color()`. `value` is always a canonical
276
276
  * lowercase 6-digit hex string; `rgb` and `hsb` are derived accessors that are
@@ -306,7 +306,7 @@ declare global {
306
306
  /** Visibility category that controls when the parameter is shown. */
307
307
  category: ParameterCategory;
308
308
  }
309
-
309
+
310
310
  /**
311
311
  * Configuration object passed to `viji.coordinate()`. The host renders a 2D
312
312
  * draggable pad; both `x` and `y` are clamped to `-1..1`.
@@ -323,7 +323,7 @@ declare global {
323
323
  /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */
324
324
  category?: ParameterCategory;
325
325
  }
326
-
326
+
327
327
  /**
328
328
  * Reactive object returned by `viji.coordinate()`. `value.x` and `value.y` are
329
329
  * always in `-1..1`; the host UI renders a draggable 2D pad.
@@ -342,7 +342,7 @@ declare global {
342
342
  /** Visibility category that controls when the parameter is shown. */
343
343
  category: ParameterCategory;
344
344
  }
345
-
345
+
346
346
  /**
347
347
  * Two-component coordinate, both axes in `-1..1` (centered on the canvas).
348
348
  * Returned and consumed by `viji.coordinate()`.
@@ -353,20 +353,20 @@ declare global {
353
353
  /** Vertical axis in `-1..1` (bottom to top, `0` = canvas center). */
354
354
  y: number;
355
355
  };
356
-
356
+
357
357
  /**
358
358
  * Identifier for an individual computer-vision feature pipeline. Returned by
359
359
  * `VideoAPI.cv.getActiveFeatures()` and used internally to track state.
360
360
  */
361
361
  type CVFeature = 'faceDetection' | 'faceMesh' | 'handTracking' | 'poseDetection' | 'bodySegmentation' | 'emotionDetection';
362
-
362
+
363
363
  /**
364
364
  * Computer-vision processing rate relative to the scene's render rate.
365
365
  * `'full'` runs CV every frame, `'half'` every other frame, `'quarter'` every
366
366
  * fourth, `'eighth'` every eighth. Lower rates reduce CPU/GPU cost.
367
367
  */
368
368
  type CVFrameRateMode = 'full' | 'half' | 'quarter' | 'eighth';
369
-
369
+
370
370
  /**
371
371
  * Device motion data sourced from the platform's `DeviceMotionEvent`. All
372
372
  * accelerations are in metres per second squared (m/s²); rotation rates are
@@ -405,7 +405,7 @@ declare global {
405
405
  /** Interval between sensor updates in milliseconds. */
406
406
  interval: number;
407
407
  }
408
-
408
+
409
409
  /**
410
410
  * DeviceOrientationEvent data
411
411
  * Matches native DeviceOrientationEvent structure
@@ -420,7 +420,7 @@ declare global {
420
420
  /** True if using magnetometer (compass) for absolute orientation */
421
421
  absolute: boolean;
422
422
  }
423
-
423
+
424
424
  /**
425
425
  * Sensor snapshot for the device running the scene. Both fields read `null`
426
426
  * when the corresponding sensor is unavailable or has not delivered a sample yet.
@@ -431,7 +431,7 @@ declare global {
431
431
  /** Orientation data (alpha/beta/gamma in degrees). `null` if no orientation sensor is available. */
432
432
  orientation: DeviceOrientationData | null;
433
433
  }
434
-
434
+
435
435
  /**
436
436
  * External device state (includes id and name)
437
437
  */
@@ -445,7 +445,7 @@ declare global {
445
445
  /** Device audio stream (null if not available) */
446
446
  audio: AudioStreamAPI | null;
447
447
  }
448
-
448
+
449
449
  /**
450
450
  * 52 ARKit-compatible face blendshape coefficients (each in 0..1) derived from
451
451
  * MediaPipe FaceLandmarker. All fields are `0` unless emotion detection is
@@ -557,7 +557,7 @@ declare global {
557
557
  /** Coefficient (0..1) for the tongue protruding. */
558
558
  tongueOut: number;
559
559
  }
560
-
560
+
561
561
  /**
562
562
  * One detected face produced by the video CV pipeline. Always carries `id`,
563
563
  * `bounds`, `center`, and `confidence`; the rest is populated only when the
@@ -625,14 +625,14 @@ declare global {
625
625
  /** 52 ARKit-compatible facial muscle coefficients. All zero unless emotion detection is enabled. */
626
626
  blendshapes: FaceBlendshapes;
627
627
  }
628
-
628
+
629
629
  /**
630
630
  * Render-loop pacing mode. `'full'` runs `render()` on every animation frame
631
631
  * (~60 FPS). `'half'` runs every second frame (~30 FPS), saving CPU/GPU on
632
632
  * lower-cost scenes.
633
633
  */
634
634
  type FrameRateMode = 'full' | 'half';
635
-
635
+
636
636
  /**
637
637
  * One named frequency band reported by the audio analyzer
638
638
  * (e.g., `{ name: 'low', min: 20, max: 120 }`). Frequencies are in Hertz.
@@ -645,7 +645,7 @@ declare global {
645
645
  /** Upper edge of the band in Hertz (exclusive). */
646
646
  max: number;
647
647
  }
648
-
648
+
649
649
  /**
650
650
  * One detected hand produced by the video CV pipeline. Carries 21 landmarks,
651
651
  * a palm shortcut, and ML-classified gesture confidence scores. Up to two
@@ -708,7 +708,7 @@ declare global {
708
708
  iLoveYou: number;
709
709
  };
710
710
  }
711
-
711
+
712
712
  /**
713
713
  * Configuration object passed to `viji.image()`. The host renders an upload
714
714
  * field; the user-supplied image becomes available as an `ImageBitmap` (Native)
@@ -724,7 +724,7 @@ declare global {
724
724
  /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */
725
725
  category?: ParameterCategory;
726
726
  }
727
-
727
+
728
728
  /**
729
729
  * Reactive object returned by `viji.image()`. `value` is `null` until the user
730
730
  * uploads an image; in P5 scenes a `.p5` accessor is also added at runtime so
@@ -744,7 +744,7 @@ declare global {
744
744
  /** Visibility category that controls when the parameter is shown. */
745
745
  category: ParameterCategory;
746
746
  }
747
-
747
+
748
748
  /**
749
749
  * Keyboard input state for the current frame: per-key press / hold / release
750
750
  * queries (case-insensitive), the live set of held keys, modifier flags, and
@@ -785,7 +785,7 @@ declare global {
785
785
  */
786
786
  textureData: Uint8Array;
787
787
  }
788
-
788
+
789
789
  /**
790
790
  * Mouse input state for the current frame: position, individual button states,
791
791
  * per-frame movement, scroll wheel, and frame-based press / release events.
@@ -825,7 +825,7 @@ declare global {
825
825
  /** `true` if the mouse moved this frame (any non-zero `deltaX` / `deltaY`). Resets each frame. */
826
826
  wasMoved: boolean;
827
827
  }
828
-
828
+
829
829
  /**
830
830
  * Configuration object passed to `viji.number()`. Defines the bounds, step,
831
831
  * label, and UI grouping/visibility for a precise numeric input.
@@ -846,7 +846,7 @@ declare global {
846
846
  /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */
847
847
  category?: ParameterCategory;
848
848
  }
849
-
849
+
850
850
  /**
851
851
  * Reactive object returned by `viji.number()`. Like `SliderParameter` but the
852
852
  * host UI renders a precise numeric input rather than a draggable slider.
@@ -869,14 +869,14 @@ declare global {
869
869
  /** Visibility category that controls when the parameter is shown. */
870
870
  category: ParameterCategory;
871
871
  }
872
-
872
+
873
873
  /**
874
874
  * Visibility category for a parameter. The host hides parameters whose category
875
875
  * is not currently available (e.g., `'audio'` controls hide when no audio
876
876
  * source is connected). `'general'` parameters are always visible.
877
877
  */
878
878
  type ParameterCategory = 'audio' | 'video' | 'interaction' | 'general';
879
-
879
+
880
880
  /**
881
881
  * Unified pointer that abstracts mouse and primary touch into a single input
882
882
  * stream. Recommended for click / drag / position-tracking interactions that
@@ -905,7 +905,7 @@ declare global {
905
905
  /** Currently active input source: `'touch'` when at least one touch is active, otherwise `'mouse'` (or `'none'` when the cursor is off-canvas). */
906
906
  type: 'mouse' | 'touch' | 'none';
907
907
  }
908
-
908
+
909
909
  /**
910
910
  * Detected body pose from MediaPipe BlazePose. `landmarks` contains 33 points;
911
911
  * the `face` / `torso` / `leftArm` / `rightArm` / `leftLeg` / `rightLeg` arrays
@@ -968,7 +968,7 @@ declare global {
968
968
  y: number;
969
969
  }[];
970
970
  }
971
-
971
+
972
972
  /**
973
973
  * Discrete pixel dimensions for a canvas, frame capture, or render target.
974
974
  */
@@ -978,7 +978,7 @@ declare global {
978
978
  /** Height in pixels (positive integer). */
979
979
  height: number;
980
980
  };
981
-
981
+
982
982
  /**
983
983
  * Per-pixel person/background segmentation mask. Mask dimensions reflect the
984
984
  * ML model's output and may differ from the source video frame.
@@ -991,7 +991,7 @@ declare global {
991
991
  /** Mask height in pixels. */
992
992
  height: number;
993
993
  }
994
-
994
+
995
995
  /**
996
996
  * Configuration object passed to `viji.select()`. The host renders the choices
997
997
  * as a dropdown or segmented control.
@@ -1008,7 +1008,7 @@ declare global {
1008
1008
  /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */
1009
1009
  category?: ParameterCategory;
1010
1010
  }
1011
-
1011
+
1012
1012
  /**
1013
1013
  * Reactive object returned by `viji.select()`. `value` matches the element type
1014
1014
  * of the configured `options` array (`string` or `number`).
@@ -1027,7 +1027,7 @@ declare global {
1027
1027
  /** Visibility category that controls when the parameter is shown. */
1028
1028
  category: ParameterCategory;
1029
1029
  }
1030
-
1030
+
1031
1031
  /**
1032
1032
  * Configuration object passed to `viji.slider()`. Defines the slider's bounds,
1033
1033
  * increment, label, and UI grouping/visibility.
@@ -1048,7 +1048,7 @@ declare global {
1048
1048
  /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */
1049
1049
  category?: ParameterCategory;
1050
1050
  }
1051
-
1051
+
1052
1052
  /**
1053
1053
  * Reactive object returned by `viji.slider()`. `value` updates in real-time as
1054
1054
  * the user drags the control; the remaining fields mirror the configuration.
@@ -1071,7 +1071,7 @@ declare global {
1071
1071
  /** Visibility category that controls when the parameter is shown. */
1072
1072
  category: ParameterCategory;
1073
1073
  }
1074
-
1074
+
1075
1075
  /**
1076
1076
  * Configuration object passed to `viji.text()`. The host renders a single-line
1077
1077
  * text input field.
@@ -1088,7 +1088,7 @@ declare global {
1088
1088
  /** Maximum character count enforced by the host UI. Default: `1000`. */
1089
1089
  maxLength?: number;
1090
1090
  }
1091
-
1091
+
1092
1092
  /**
1093
1093
  * Reactive object returned by `viji.text()`. `value` updates as the user types
1094
1094
  * and is enforced to be no longer than `maxLength` by the host UI.
@@ -1107,7 +1107,7 @@ declare global {
1107
1107
  /** Visibility category that controls when the parameter is shown. */
1108
1108
  category: ParameterCategory;
1109
1109
  }
1110
-
1110
+
1111
1111
  /**
1112
1112
  * Configuration object passed to `viji.toggle()`. Defines the on/off switch's
1113
1113
  * label and UI grouping/visibility.
@@ -1122,7 +1122,7 @@ declare global {
1122
1122
  /** Visibility category. The control hides when its capability is unavailable. Default: `'general'`. */
1123
1123
  category?: ParameterCategory;
1124
1124
  }
1125
-
1125
+
1126
1126
  /**
1127
1127
  * Reactive object returned by `viji.toggle()`. `value` flips between `true`
1128
1128
  * and `false` as the user interacts with the switch.
@@ -1139,7 +1139,7 @@ declare global {
1139
1139
  /** Visibility category that controls when the parameter is shown. */
1140
1140
  category: ParameterCategory;
1141
1141
  }
1142
-
1142
+
1143
1143
  /**
1144
1144
  * Multi-touch input state. Lists all active touches, plus per-frame
1145
1145
  * `started` / `moved` / `ended` arrays for frame-based gesture handling.
@@ -1161,7 +1161,7 @@ declare global {
1161
1161
  /** Convenience shortcut to `points[0]`, or `null` when no touches are active. */
1162
1162
  primary: TouchPoint | null;
1163
1163
  }
1164
-
1164
+
1165
1165
  /**
1166
1166
  * One active touch contact reported by `TouchAPI`. Position, pressure, radius,
1167
1167
  * rotation, per-frame movement, velocity, and lifecycle flags. Coordinates are
@@ -1210,9 +1210,9 @@ declare global {
1210
1210
  /** `true` for exactly one frame when this touch ends, then auto-resets. */
1211
1211
  isEnding: boolean;
1212
1212
  }
1213
-
1214
- const VERSION = "0.6.0";
1215
-
1213
+
1214
+ const VERSION = "0.7.0";
1215
+
1216
1216
  /**
1217
1217
  * Real-time video API: drawable frame, dimensions, and the source-side
1218
1218
  * properties of the connected stream. All computer-vision data and controls
@@ -1254,7 +1254,7 @@ declare global {
1254
1254
  */
1255
1255
  cv: VideoCVAPI;
1256
1256
  }
1257
-
1257
+
1258
1258
  /**
1259
1259
  * Computer-vision surface attached to a `VideoAPI`. Combines paired CV data
1260
1260
  * outputs (the analysed frame and its detection / segmentation results) with
@@ -1357,7 +1357,7 @@ declare global {
1357
1357
  /** Returns `true` if the CV worker is actively processing frames. */
1358
1358
  isProcessing(): boolean;
1359
1359
  }
1360
-
1360
+
1361
1361
  /**
1362
1362
  * The Viji API surface available to artist code as the global `viji` object.
1363
1363
  * Groups canvas access, timing, connected media APIs, user interaction, device
@@ -1511,14 +1511,14 @@ declare global {
1511
1511
  */
1512
1512
  useContext(type: 'webgl2'): WebGL2RenderingContext;
1513
1513
  }
1514
-
1515
- // Runtime global - the main viji object
1516
- const viji: VijiAPI;
1517
-
1518
- // Function type aliases (artists define their own render/setup functions)
1519
- type Render = (viji: VijiAPI) => void;
1520
- type Setup = (viji: VijiAPI) => void;
1521
- }
1522
-
1523
- // Module marker (enables top-level await in artist code)
1524
- export {};
1514
+
1515
+ // Runtime global - the main viji object
1516
+ const viji: VijiAPI;
1517
+
1518
+ // Function type aliases (artists define their own render/setup functions)
1519
+ type Render = (viji: VijiAPI) => void;
1520
+ type Setup = (viji: VijiAPI) => void;
1521
+ }
1522
+
1523
+ // Module marker (enables top-level await in artist code)
1524
+ export {};