@viji-dev/core 0.10.0 → 0.11.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
@@ -463,6 +463,41 @@ export declare class AudioSystem {
463
463
  * context alive in `Pending activities` and leaks ~4 MB per cycle.
464
464
  */
465
465
  resetAudioState(): Promise<void>;
466
+ private sourceFedIndices;
467
+ /**
468
+ * Register a source-fed device channel (no MediaStream). Emits the
469
+ * `audio-stream-setup` identity to all sinks and starts the staleness
470
+ * timer. Idempotent.
471
+ */
472
+ addDeviceAnalysisChannel(streamIndex: number, deviceId: string): void;
473
+ /**
474
+ * Feed a controller analysis packet into a source-fed channel. Instant
475
+ * values pass through; the smoothed companions are derived host-side via
476
+ * the channel's envelope followers to absorb network packet bunching
477
+ * (§3.9 light smoothing). Missing `frequencyData`/`waveform` surface as
478
+ * empty arrays (the controller omits them unless the scene reads them).
479
+ */
480
+ feedDeviceAnalysis(streamIndex: number, payload: {
481
+ volume?: {
482
+ current?: number;
483
+ peak?: number;
484
+ };
485
+ bands?: {
486
+ low?: number;
487
+ lowMid?: number;
488
+ mid?: number;
489
+ highMid?: number;
490
+ high?: number;
491
+ };
492
+ spectral?: {
493
+ brightness?: number;
494
+ flatness?: number;
495
+ };
496
+ frequencyData?: Uint8Array;
497
+ waveformData?: Float32Array;
498
+ }): void;
499
+ /** Remove a source-fed device channel (sends a disconnected state). */
500
+ removeDeviceAnalysisChannel(streamIndex: number): void;
466
501
  /**
467
502
  * Add an additional audio stream (lightweight analysis, no beat detection).
468
503
  * When `meta` is provided, the stream identity is recorded and an
@@ -1006,6 +1041,59 @@ export declare type CVFeatureKey = typeof CV_FEATURE_KEYS[number];
1006
1041
  */
1007
1042
  declare type CVFrameRateMode = 'full' | 'half' | 'quarter' | 'eighth';
1008
1043
 
1044
+ /**
1045
+ * A controller-produced analysis packet ingested via
1046
+ * {@link VijiCore.setDeviceAnalysis} (remote analysis, Phase 3). The
1047
+ * controller analyzes its own device's audio/camera and ships results — no
1048
+ * media track for the analyzed signal crosses the wire.
1049
+ *
1050
+ * - `kind: 'audio'` — surfaces on `viji.devices[n].audio`. `payload` carries
1051
+ * instant `volume`/`bands`/`spectral`; the host derives the smoothed
1052
+ * companions and absorbs network jitter. Omit `frequencyData`/`waveform`
1053
+ * unless the device scene reads them (they are ~9 KB each).
1054
+ * - `kind: 'cv'` — surfaces on `viji.devices[n].video.cv` (requires the
1055
+ * device video track to be sent for display — the CV surface carrier).
1056
+ * `payload` carries dequantized `faces`/`hands`/`pose` in the same shapes
1057
+ * as `viji.video.cv`. Segmentation is excluded in v1.
1058
+ *
1059
+ * `seq` is a monotonic per-(device,kind) counter for latest-wins ordering on
1060
+ * an unreliable channel (every packet carries absolute values, so drops are
1061
+ * harmless). `captureTs` is the capture timestamp of the analyzed media.
1062
+ */
1063
+ export declare type DeviceAnalysisPacket = {
1064
+ kind: 'audio';
1065
+ seq?: number;
1066
+ captureTs?: number;
1067
+ payload: {
1068
+ volume?: {
1069
+ current?: number;
1070
+ peak?: number;
1071
+ };
1072
+ bands?: {
1073
+ low?: number;
1074
+ lowMid?: number;
1075
+ mid?: number;
1076
+ highMid?: number;
1077
+ high?: number;
1078
+ };
1079
+ spectral?: {
1080
+ brightness?: number;
1081
+ flatness?: number;
1082
+ };
1083
+ frequencyData?: Uint8Array;
1084
+ waveformData?: Float32Array;
1085
+ };
1086
+ } | {
1087
+ kind: 'cv';
1088
+ seq?: number;
1089
+ captureTs?: number;
1090
+ payload: {
1091
+ faces?: FaceData[];
1092
+ hands?: HandData[];
1093
+ pose?: PoseData | null;
1094
+ };
1095
+ };
1096
+
1009
1097
  /**
1010
1098
  * Device motion data sourced from the platform's `DeviceMotionEvent`. All
1011
1099
  * accelerations are in metres per second squared (m/s²); rotation rates are
@@ -2702,7 +2790,7 @@ declare type TrackingState = 'TRACKING' | 'LOCKED' | 'BREAKDOWN' | 'LOST';
2702
2790
  /** Returned by `on*` listener registration calls; invoke to unsubscribe. */
2703
2791
  export declare type Unsubscribe = () => void;
2704
2792
 
2705
- export declare const VERSION = "0.10.0";
2793
+ export declare const VERSION = "0.11.0";
2706
2794
 
2707
2795
  /**
2708
2796
  * Real-time video API: drawable frame, dimensions, and the source-side
@@ -3100,6 +3188,7 @@ export declare class VijiCore {
3100
3188
  private stateImportErrorListeners;
3101
3189
  private sceneRuntimeErrorListeners;
3102
3190
  private sceneConsoleListeners;
3191
+ private deviceCVRequestListeners;
3103
3192
  private stats;
3104
3193
  private performanceSnapshotListeners;
3105
3194
  private capabilityTransitionListeners;
@@ -4061,7 +4150,8 @@ export declare class VijiCore {
4061
4150
  */
4062
4151
  removeExternalDevice(deviceId: string): void;
4063
4152
  /**
4064
- * Get list of connected external devices (for host UI)
4153
+ * Get list of connected external devices (for host UI). Engine-scoped:
4154
+ * identical for every core sharing this core's media engines.
4065
4155
  * @returns Array of device metadata with id, name, and array index
4066
4156
  */
4067
4157
  getConnectedDevices(): Array<{
@@ -4069,6 +4159,32 @@ export declare class VijiCore {
4069
4159
  name: string;
4070
4160
  index: number;
4071
4161
  }>;
4162
+ /**
4163
+ * Ingest a controller-produced analysis packet for a registered device
4164
+ * (remote analysis, Phase 3). `kind:'audio'` surfaces on
4165
+ * `viji.devices[n].audio`; `kind:'cv'` surfaces on
4166
+ * `viji.devices[n].video.cv` (requires the device video track to be sent
4167
+ * for display — the CV surface carrier). Latest-wins by `seq`; unknown
4168
+ * devices / malformed packets are dropped silently. Engine-level: visible
4169
+ * to all cores sharing this core's media engines.
4170
+ *
4171
+ * @param deviceId Registered device identifier
4172
+ * @param packet `{ kind, seq?, captureTs?, payload }`
4173
+ */
4174
+ setDeviceAnalysis(deviceId: string, packet: DeviceAnalysisPacket): void;
4175
+ /**
4176
+ * Listen for device CV feature requests. Fires when a host scene toggles a
4177
+ * CV feature on a device stream (`viji.devices[n].video.cv.enableX`) —
4178
+ * device CV is always remote, so the app must relay this to the device's
4179
+ * controller over its own transport (the controller runs the inference and
4180
+ * ships results back via {@link setDeviceAnalysis}). The core never owns
4181
+ * the transport.
4182
+ *
4183
+ * Engine-level: one registry per shared engine group — subscribe once.
4184
+ * @returns Unsubscribe function.
4185
+ */
4186
+ onDeviceCVRequest(listener: (deviceId: string, feature: CVFeature, enabled: boolean) => void): Unsubscribe;
4187
+ private fireDeviceCVRequest;
4072
4188
  /**
4073
4189
  * Set video stream for an external device
4074
4190
  * Device camera will appear in viji.devices[].video
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-C-CGSJSn.js";
1
+ import { A as s, C as o, I as E, V as i, a as A, b as C } from "./index-Dfhuv8fL.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.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Universal execution engine for Viji Creative scenes",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",