@viji-dev/core 0.3.8 → 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.
@@ -586,7 +586,7 @@ class IFrameManager {
586
586
  }
587
587
  function WorkerWrapper(options) {
588
588
  return new Worker(
589
- "" + new URL("assets/viji.worker-D06up_1l.js", import.meta.url).href,
589
+ "" + new URL("assets/viji.worker-Dq0mIiTV.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-CIJgU60k.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) {
@@ -14277,6 +14277,10 @@ class VideoCoordinator {
14277
14277
  }
14278
14278
  this.ctx.drawImage(this.videoElement, 0, 0, this.canvas.width, this.canvas.height);
14279
14279
  const imageBitmap = await createImageBitmap(this.canvas);
14280
+ if (!this.isTransferRunning) {
14281
+ imageBitmap.close();
14282
+ return;
14283
+ }
14280
14284
  if (Math.random() < 0.01) {
14281
14285
  this.debugLog("✅ Frame captured and ImageBitmap created:", {
14282
14286
  videoDimensions: `${this.videoElement.videoWidth}x${this.videoElement.videoHeight}`,
@@ -14552,6 +14556,8 @@ class VijiCore {
14552
14556
  directFrameSlots = 0;
14553
14557
  // Device video management (coordinators only, for cleanup)
14554
14558
  deviceVideoCoordinators = /* @__PURE__ */ new Map();
14559
+ // Track assigned stream indices to prevent collisions on reconnect
14560
+ deviceVideoStreamIndices = /* @__PURE__ */ new Map();
14555
14561
  // Auto-capture frame buffer (zero-copy transfer)
14556
14562
  latestFrameBuffer = null;
14557
14563
  autoCaptureEnabled = false;
@@ -16111,8 +16117,13 @@ class VijiCore {
16111
16117
  async setDeviceVideo(deviceId, stream) {
16112
16118
  this.validateReady();
16113
16119
  await this.clearDeviceVideo(deviceId);
16114
- const baseIndex = this.videoStream ? 1 : 0;
16115
- 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);
16116
16127
  const coordinator = new VideoCoordinator((message, transfer) => {
16117
16128
  if (this.workerManager) {
16118
16129
  if (message.type === "video-canvas-setup") {
@@ -16145,6 +16156,7 @@ class VijiCore {
16145
16156
  async clearDeviceVideo(deviceId) {
16146
16157
  const coordinator = this.deviceVideoCoordinators.get(deviceId);
16147
16158
  if (!coordinator) return;
16159
+ this.deviceVideoStreamIndices.delete(deviceId);
16148
16160
  coordinator.resetVideoState();
16149
16161
  this.deviceVideoCoordinators.delete(deviceId);
16150
16162
  this.syncDeviceStateToWorker();
@@ -16182,6 +16194,7 @@ class VijiCore {
16182
16194
  await this.clearDeviceVideo(deviceId);
16183
16195
  }
16184
16196
  this.deviceVideoCoordinators.clear();
16197
+ this.deviceVideoStreamIndices.clear();
16185
16198
  if (this.deviceSensorManager) {
16186
16199
  this.deviceSensorManager.destroy();
16187
16200
  this.deviceSensorManager = null;
@@ -16268,4 +16281,4 @@ export {
16268
16281
  VijiCoreError as b,
16269
16282
  getDefaultExportFromCjs as g
16270
16283
  };
16271
- //# sourceMappingURL=index-o_qmrgB1.js.map
16284
+ //# sourceMappingURL=index-aXKP9TJe.js.map