@viji-dev/core 0.9.0 → 0.10.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/dist/index.d.ts CHANGED
@@ -422,6 +422,16 @@ export declare class AudioSystem {
422
422
  * Tags with streamIndex and conditionally includes beat data (main channel only).
423
423
  */
424
424
  private sendChannelResults;
425
+ /**
426
+ * Deliver an analysis message to one sink with PER-SINK typed-array
427
+ * copies. The host→worker relay transfers `frequencyData`/`waveformData`
428
+ * buffers (zero-copy receive, `collectTransferables` case
429
+ * 'audio-analysis-update') — posting the same message object to N sinks
430
+ * would let the first post DETACH the buffers and starve every other
431
+ * sink (and the replay cache). One copy per sink per analysis frame is
432
+ * the unavoidable cost of a transfer-per-receiver delivery.
433
+ */
434
+ private deliverAnalysisMessage;
425
435
  /**
426
436
  * Register a result-delivery sink (one per attached core's worker) and
427
437
  * replay current state to it in FIFO order: the latest main-channel
@@ -2692,7 +2702,7 @@ declare type TrackingState = 'TRACKING' | 'LOCKED' | 'BREAKDOWN' | 'LOST';
2692
2702
  /** Returned by `on*` listener registration calls; invoke to unsubscribe. */
2693
2703
  export declare type Unsubscribe = () => void;
2694
2704
 
2695
- export declare const VERSION = "0.9.0";
2705
+ export declare const VERSION = "0.10.0";
2696
2706
 
2697
2707
  /**
2698
2708
  * Real-time video API: drawable frame, dimensions, and the source-side
@@ -2741,11 +2751,12 @@ export declare interface VideoAPI {
2741
2751
  * outputs (the analysed frame and its detection / segmentation results) with
2742
2752
  * the verbs that activate the underlying MediaPipe pipelines.
2743
2753
  *
2744
- * Available only on the main video stream (`viji.video.cv`). Additional
2745
- * streams (`viji.videoStreams[i].cv`) and device videos
2746
- * (`viji.devices[i].video.cv`) do not run CV; their `cv` surface exists for
2747
- * API consistency but the data fields stay at their empty defaults and the
2748
- * `enable*` verbs are no-ops.
2754
+ * Available on the main video stream (`viji.video.cv`) and on additional
2755
+ * streams (`viji.videoStreams[i].cv`) — same surface, same verbs, activated
2756
+ * per stream. `analysedFrame` is populated on the MAIN stream only; on other
2757
+ * streams it stays `null` (use `currentFrame`). Device videos
2758
+ * (`viji.devices[i].video.cv`) do not run CV yet; their `cv` surface exists
2759
+ * for API consistency with the data fields at their empty defaults.
2749
2760
  */
2750
2761
  export declare interface VideoCVAPI {
2751
2762
  /**
@@ -3079,6 +3090,7 @@ export declare class VijiCore {
3079
3090
  private sceneRenderer;
3080
3091
  private sceneCapabilities;
3081
3092
  private sceneP5CanvasMode?;
3093
+ private sceneConsumesAnalysedFrame;
3082
3094
  private sceneContextType?;
3083
3095
  private parametersInitialized;
3084
3096
  private parameterListeners;
@@ -3501,8 +3513,14 @@ export declare class VijiCore {
3501
3513
  */
3502
3514
  setFrameRate(mode: FrameRateMode): Promise<void>;
3503
3515
  /**
3504
- * Sets the CV processing frame rate mode (relative to scene frame rate)
3505
- * @param mode - CV processing rate: 'full', 'half', 'quarter', or 'eighth' of scene rate
3516
+ * Sets the CV processing frame rate mode, relative to the **video stream
3517
+ * delivery rate** (the capture's ~30 fps), not the scene render rate —
3518
+ * with shared engines, attached scenes may render at different rates, so
3519
+ * the capture rate is the only coherent base.
3520
+ *
3521
+ * Engine-level write: visible to ALL cores sharing this core's media
3522
+ * engines (same rule as the stream mutators).
3523
+ * @param mode - CV processing rate: 'full', 'half', 'quarter', or 'eighth' of the capture rate
3506
3524
  */
3507
3525
  setCVFrameRate(mode: CVFrameRateMode): Promise<void>;
3508
3526
  /**
@@ -3604,6 +3622,51 @@ export declare class VijiCore {
3604
3622
  */
3605
3623
  private get audioEngine();
3606
3624
  private ensureAudioEngine;
3625
+ /**
3626
+ * Host-side video control namespace. The `cv` sub-namespace lets host
3627
+ * code (as opposed to scene code) drive CV on the main video stream —
3628
+ * the controller use case: a scene-less headless core analyzing its
3629
+ * local camera and shipping results onward.
3630
+ */
3631
+ readonly video: {
3632
+ cv: {
3633
+ /**
3634
+ * Enable or disable a CV feature on the main video stream from the
3635
+ * host side. The host acts as one more consumer of the shared CV
3636
+ * engine: inference runs the union of all consumers' desired sets,
3637
+ * and host results arrive via {@link onResults} filtered to the
3638
+ * host-enabled features.
3639
+ *
3640
+ * Engine-level write: the underlying inference is visible to ALL
3641
+ * cores sharing this core's media engines (scenes still only receive
3642
+ * features they enabled themselves).
3643
+ *
3644
+ * @param feature - The CV feature to toggle
3645
+ * @param enabled - Whether the feature should run
3646
+ */
3647
+ enable: (feature: CVFeature, enabled: boolean) => void;
3648
+ /**
3649
+ * Subscribe to CV results on the host side, filtered to the features
3650
+ * enabled via {@link enable}. Fires once per completed inference with
3651
+ * the same result shapes the artist API exposes
3652
+ * (`faces`/`hands`/`pose`/`segmentation`).
3653
+ *
3654
+ * Engine-level: one listener registry per shared engine group —
3655
+ * subscribe once per app.
3656
+ *
3657
+ * @returns Unsubscribe function. Call to remove the listener.
3658
+ */
3659
+ onResults: (listener: (update: {
3660
+ streamIndex: number;
3661
+ results: {
3662
+ faces?: FaceData[];
3663
+ hands?: HandData[];
3664
+ pose?: PoseData | null;
3665
+ segmentation?: SegmentationData | null;
3666
+ };
3667
+ }) => void) => Unsubscribe;
3668
+ };
3669
+ };
3607
3670
  readonly audio: {
3608
3671
  /**
3609
3672
  * Beat control namespace
@@ -3911,6 +3974,13 @@ export declare class VijiCore {
3911
3974
  * Gets current performance statistics
3912
3975
  */
3913
3976
  getStats(): PerformanceStats;
3977
+ /**
3978
+ * Merge the shared CV engine's main-stream processing stats into
3979
+ * `stats.cv`. The cv block is absent until CV state exists (no engine, or
3980
+ * no features ever requested on the main stream) — same shape consumers
3981
+ * saw when the worker produced it.
3982
+ */
3983
+ private mergeCVStats;
3914
3984
  /**
3915
3985
  * Pauses the scene render loop — stops the worker from rendering. Intended to
3916
3986
  * be driven from the host on `document.hidden`, so a hidden tab doesn't keep
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as s, C as o, I as E, V as i, a as A, b as C } from "./index-CAx7Pxyl.js";
1
+ import { A as s, C as o, I as E, V as i, a as A, b as C } from "./index-C-CGSJSn.js";
2
2
  export {
3
3
  s as AudioSystem,
4
4
  o as CV_FEATURE_KEYS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viji-dev/core",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Universal execution engine for Viji Creative scenes",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -50,7 +50,7 @@
50
50
  "scripts": {
51
51
  "prebuild": "node scripts/prebuild-clean.mjs && node scripts/sync-version.mjs",
52
52
  "version": "npm run build && git add -A",
53
- "build": "vite build && node scripts/copy-tasks-assets.mjs && node scripts/build-artist-types.mjs && node scripts/build-docs-api.mjs",
53
+ "build": "vite build && node scripts/copy-tasks-assets.mjs && node scripts/build-artist-types.mjs && node scripts/lint-artist-types-drift.mjs && node scripts/build-docs-api.mjs",
54
54
  "build:docs": "node scripts/build-docs-api.mjs",
55
55
  "lint:ai-prompts-drift": "node scripts/lint-ai-prompts-drift.mjs",
56
56
  "dev": "node scripts/sync-version.mjs && vite build --watch",