@viji-dev/core 0.3.9 → 0.3.10

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.
@@ -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-B3Bvwffq.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) {
@@ -14556,6 +14556,8 @@ class VijiCore {
14556
14556
  directFrameSlots = 0;
14557
14557
  // Device video management (coordinators only, for cleanup)
14558
14558
  deviceVideoCoordinators = /* @__PURE__ */ new Map();
14559
+ // Track assigned stream indices to prevent collisions on reconnect
14560
+ deviceVideoStreamIndices = /* @__PURE__ */ new Map();
14559
14561
  // Auto-capture frame buffer (zero-copy transfer)
14560
14562
  latestFrameBuffer = null;
14561
14563
  autoCaptureEnabled = false;
@@ -16115,8 +16117,13 @@ class VijiCore {
16115
16117
  async setDeviceVideo(deviceId, stream) {
16116
16118
  this.validateReady();
16117
16119
  await this.clearDeviceVideo(deviceId);
16118
- const baseIndex = this.videoStream ? 1 : 0;
16119
- const streamIndex = baseIndex + this.videoStreams.length + this.deviceVideoCoordinators.size;
16120
+ const baseOffset = (this.videoStream ? 1 : 0) + this.videoStreams.length;
16121
+ const usedIndices = new Set(this.deviceVideoStreamIndices.values());
16122
+ let streamIndex = baseOffset;
16123
+ while (usedIndices.has(streamIndex)) {
16124
+ streamIndex++;
16125
+ }
16126
+ this.deviceVideoStreamIndices.set(deviceId, streamIndex);
16120
16127
  const coordinator = new VideoCoordinator((message, transfer) => {
16121
16128
  if (this.workerManager) {
16122
16129
  if (message.type === "video-canvas-setup") {
@@ -16149,6 +16156,7 @@ class VijiCore {
16149
16156
  async clearDeviceVideo(deviceId) {
16150
16157
  const coordinator = this.deviceVideoCoordinators.get(deviceId);
16151
16158
  if (!coordinator) return;
16159
+ this.deviceVideoStreamIndices.delete(deviceId);
16152
16160
  coordinator.resetVideoState();
16153
16161
  this.deviceVideoCoordinators.delete(deviceId);
16154
16162
  this.syncDeviceStateToWorker();
@@ -16186,6 +16194,7 @@ class VijiCore {
16186
16194
  await this.clearDeviceVideo(deviceId);
16187
16195
  }
16188
16196
  this.deviceVideoCoordinators.clear();
16197
+ this.deviceVideoStreamIndices.clear();
16189
16198
  if (this.deviceSensorManager) {
16190
16199
  this.deviceSensorManager.destroy();
16191
16200
  this.deviceSensorManager = null;
@@ -16272,4 +16281,4 @@ export {
16272
16281
  VijiCoreError as b,
16273
16282
  getDefaultExportFromCjs as g
16274
16283
  };
16275
- //# sourceMappingURL=index-BVo5-V-R.js.map
16284
+ //# sourceMappingURL=index-aXKP9TJe.js.map