@viji-dev/core 0.3.9 → 0.3.11

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.
@@ -586,7 +586,7 @@ class IFrameManager {
586
586
  }
587
587
  function WorkerWrapper(options) {
588
588
  return new Worker(
589
- "" + new URL("assets/viji.worker-Dq0mIiTV.js", import.meta.url).href,
589
+ "" + new URL("assets/viji.worker-Bus3443t.js", import.meta.url).href,
590
590
  {
591
591
  type: "module",
592
592
  name: options?.name
@@ -1935,7 +1935,7 @@ class EssentiaOnsetDetection {
1935
1935
  this.initPromise = (async () => {
1936
1936
  try {
1937
1937
  const essentiaModule = await import("./essentia.js-core.es-DnrJE0uR.js");
1938
- const wasmModule = await import("./essentia-wasm.web-Cx2LFPy-.js").then((n) => n.e);
1938
+ const wasmModule = await import("./essentia-wasm.web-dGMOt-r-.js").then((n) => n.e);
1939
1939
  const EssentiaClass = essentiaModule.Essentia || essentiaModule.default?.Essentia || essentiaModule.default;
1940
1940
  let WASMModule = wasmModule.default || wasmModule.EssentiaWASM || wasmModule.default?.EssentiaWASM;
1941
1941
  if (!WASMModule) {
@@ -14544,11 +14544,17 @@ class VijiCore {
14544
14544
  isHeadless = false;
14545
14545
  // Audio stream management
14546
14546
  currentAudioStream = null;
14547
+ // ═══════════════════════════════════════════════════════════════════════════
14548
+ // VIDEO STREAM INDEX CONTRACT:
14549
+ // Index 0: ALWAYS reserved for main video (with CV) - even when absent
14550
+ // Index 1..N: Additional streams (no CV) - where N = videoStreams.length
14551
+ // Index N+1..: Device streams - dynamically allocated, tracked in deviceVideoStreamIndices
14552
+ // ═══════════════════════════════════════════════════════════════════════════
14547
14553
  // Separated video stream management
14548
14554
  videoStream = null;
14549
- // Main stream (CV enabled)
14555
+ // Main stream (CV enabled) - always index 0
14550
14556
  videoStreams = [];
14551
- // Additional streams (no CV)
14557
+ // Additional streams (no CV) - indices 1..N
14552
14558
  // Video coordinators
14553
14559
  mainVideoCoordinator = null;
14554
14560
  additionalCoordinators = [];
@@ -14556,6 +14562,8 @@ class VijiCore {
14556
14562
  directFrameSlots = 0;
14557
14563
  // Device video management (coordinators only, for cleanup)
14558
14564
  deviceVideoCoordinators = /* @__PURE__ */ new Map();
14565
+ // Track assigned stream indices to prevent collisions (indices start at 1 + videoStreams.length)
14566
+ deviceVideoStreamIndices = /* @__PURE__ */ new Map();
14559
14567
  // Auto-capture frame buffer (zero-copy transfer)
14560
14568
  latestFrameBuffer = null;
14561
14569
  autoCaptureEnabled = false;
@@ -16115,8 +16123,13 @@ class VijiCore {
16115
16123
  async setDeviceVideo(deviceId, stream) {
16116
16124
  this.validateReady();
16117
16125
  await this.clearDeviceVideo(deviceId);
16118
- const baseIndex = this.videoStream ? 1 : 0;
16119
- const streamIndex = baseIndex + this.videoStreams.length + this.deviceVideoCoordinators.size;
16126
+ const baseOffset = 1 + this.videoStreams.length;
16127
+ const usedIndices = new Set(this.deviceVideoStreamIndices.values());
16128
+ let streamIndex = baseOffset;
16129
+ while (usedIndices.has(streamIndex)) {
16130
+ streamIndex++;
16131
+ }
16132
+ this.deviceVideoStreamIndices.set(deviceId, streamIndex);
16120
16133
  const coordinator = new VideoCoordinator((message, transfer) => {
16121
16134
  if (this.workerManager) {
16122
16135
  if (message.type === "video-canvas-setup") {
@@ -16149,6 +16162,7 @@ class VijiCore {
16149
16162
  async clearDeviceVideo(deviceId) {
16150
16163
  const coordinator = this.deviceVideoCoordinators.get(deviceId);
16151
16164
  if (!coordinator) return;
16165
+ this.deviceVideoStreamIndices.delete(deviceId);
16152
16166
  coordinator.resetVideoState();
16153
16167
  this.deviceVideoCoordinators.delete(deviceId);
16154
16168
  this.syncDeviceStateToWorker();
@@ -16186,6 +16200,7 @@ class VijiCore {
16186
16200
  await this.clearDeviceVideo(deviceId);
16187
16201
  }
16188
16202
  this.deviceVideoCoordinators.clear();
16203
+ this.deviceVideoStreamIndices.clear();
16189
16204
  if (this.deviceSensorManager) {
16190
16205
  this.deviceSensorManager.destroy();
16191
16206
  this.deviceSensorManager = null;
@@ -16272,4 +16287,4 @@ export {
16272
16287
  VijiCoreError as b,
16273
16288
  getDefaultExportFromCjs as g
16274
16289
  };
16275
- //# sourceMappingURL=index-BVo5-V-R.js.map
16290
+ //# sourceMappingURL=index-DBTm0Ys2.js.map