@viji-dev/core 0.3.2 → 0.3.4

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-BGYUuaFF.js", import.meta.url).href,
589
+ "" + new URL("assets/viji.worker-Cx1WpxdF.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-Ca8e6Ylt.js").then((n) => n.e);
1938
+ const wasmModule = await import("./essentia-wasm.web-tiEk3E7k.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) {
@@ -14031,6 +14031,8 @@ class VideoCoordinator {
14031
14031
  hasTransferredCanvas = false;
14032
14032
  // Callback to send data to worker
14033
14033
  sendToWorker = null;
14034
+ // Stream identification for multi-stream support
14035
+ streamIndex = 0;
14034
14036
  // Debug logging control
14035
14037
  debugMode = false;
14036
14038
  /**
@@ -14063,6 +14065,9 @@ class VideoCoordinator {
14063
14065
  */
14064
14066
  handleVideoStreamUpdate(data) {
14065
14067
  try {
14068
+ if (data.streamIndex !== void 0) {
14069
+ this.streamIndex = data.streamIndex;
14070
+ }
14066
14071
  if (data.videoStream) {
14067
14072
  this.setVideoStream(data.videoStream);
14068
14073
  } else {
@@ -14166,13 +14171,15 @@ class VideoCoordinator {
14166
14171
  offscreenCanvas,
14167
14172
  width,
14168
14173
  height,
14169
- timestamp: performance.now()
14174
+ timestamp: performance.now(),
14175
+ streamIndex: this.streamIndex
14170
14176
  }
14171
14177
  }, [offscreenCanvas]);
14172
14178
  this.hasTransferredCanvas = true;
14173
14179
  this.debugLog("✅ OffscreenCanvas transferred to worker (correct approach)", {
14174
14180
  width,
14175
- height
14181
+ height,
14182
+ streamIndex: this.streamIndex
14176
14183
  });
14177
14184
  }
14178
14185
  } catch (error) {
@@ -14291,7 +14298,8 @@ class VideoCoordinator {
14291
14298
  type: "video-frame-update",
14292
14299
  data: {
14293
14300
  imageBitmap,
14294
- timestamp: performance.now()
14301
+ timestamp: performance.now(),
14302
+ streamIndex: this.streamIndex
14295
14303
  }
14296
14304
  }, [imageBitmap]);
14297
14305
  }
@@ -14303,7 +14311,10 @@ class VideoCoordinator {
14303
14311
  if (this.sendToWorker) {
14304
14312
  this.sendToWorker({
14305
14313
  type: "video-config-update",
14306
- data: config
14314
+ data: {
14315
+ ...config,
14316
+ streamIndex: this.streamIndex
14317
+ }
14307
14318
  });
14308
14319
  }
14309
14320
  }
@@ -14316,7 +14327,8 @@ class VideoCoordinator {
14316
14327
  type: "video-config-update",
14317
14328
  data: {
14318
14329
  disconnect: true,
14319
- timestamp: performance.now()
14330
+ timestamp: performance.now(),
14331
+ streamIndex: this.streamIndex
14320
14332
  }
14321
14333
  });
14322
14334
  }
@@ -14744,6 +14756,9 @@ class VijiCore {
14744
14756
  if (this.videoStream) {
14745
14757
  this.mainVideoCoordinator = new VideoCoordinator((message, transfer) => {
14746
14758
  if (this.workerManager) {
14759
+ if (message.type === "video-canvas-setup") {
14760
+ message.data.streamType = "main";
14761
+ }
14747
14762
  if (transfer && transfer.length > 0) {
14748
14763
  this.workerManager.postMessage(message.type, message.data, transfer);
14749
14764
  } else {
@@ -14761,8 +14776,12 @@ class VijiCore {
14761
14776
  });
14762
14777
  }
14763
14778
  for (let i = 0; i < this.videoStreams.length; i++) {
14779
+ const streamIndex = 1 + i;
14764
14780
  const coordinator = new VideoCoordinator((message, transfer) => {
14765
14781
  if (this.workerManager) {
14782
+ if (message.type === "video-canvas-setup") {
14783
+ message.data.streamType = "additional";
14784
+ }
14766
14785
  if (transfer && transfer.length > 0) {
14767
14786
  this.workerManager.postMessage(message.type, message.data, transfer);
14768
14787
  } else {
@@ -14773,7 +14792,7 @@ class VijiCore {
14773
14792
  coordinator.setDebugMode(this.debugMode);
14774
14793
  coordinator.handleVideoStreamUpdate({
14775
14794
  videoStream: this.videoStreams[i],
14776
- streamIndex: 1 + i,
14795
+ streamIndex,
14777
14796
  streamType: "additional",
14778
14797
  targetFrameRate: 30,
14779
14798
  timestamp: performance.now()
@@ -15565,6 +15584,9 @@ class VijiCore {
15565
15584
  if (stream && this.workerManager) {
15566
15585
  this.mainVideoCoordinator = new VideoCoordinator((message, transfer) => {
15567
15586
  if (this.workerManager) {
15587
+ if (message.type === "video-canvas-setup") {
15588
+ message.data.streamType = "main";
15589
+ }
15568
15590
  if (transfer && transfer.length > 0) {
15569
15591
  this.workerManager.postMessage(message.type, message.data, transfer);
15570
15592
  } else {
@@ -15626,8 +15648,12 @@ class VijiCore {
15626
15648
  if (existingIndex !== -1) return existingIndex;
15627
15649
  this.videoStreams.push(stream);
15628
15650
  const newIndex = this.videoStreams.length - 1;
15651
+ const streamIndex = 1 + newIndex;
15629
15652
  const coordinator = new VideoCoordinator((message, transfer) => {
15630
15653
  if (this.workerManager) {
15654
+ if (message.type === "video-canvas-setup") {
15655
+ message.data.streamType = "additional";
15656
+ }
15631
15657
  if (transfer && transfer.length > 0) {
15632
15658
  this.workerManager.postMessage(message.type, message.data, transfer);
15633
15659
  } else {
@@ -15638,7 +15664,7 @@ class VijiCore {
15638
15664
  coordinator.setDebugMode(this.debugMode);
15639
15665
  coordinator.handleVideoStreamUpdate({
15640
15666
  videoStream: stream,
15641
- streamIndex: 1 + newIndex,
15667
+ streamIndex,
15642
15668
  streamType: "additional",
15643
15669
  targetFrameRate: 30,
15644
15670
  timestamp: performance.now()
@@ -15695,8 +15721,12 @@ class VijiCore {
15695
15721
  this.additionalCoordinators.forEach((coord) => coord.resetVideoState());
15696
15722
  this.additionalCoordinators = [];
15697
15723
  for (let i = 0; i < this.videoStreams.length; i++) {
15724
+ const streamIndex = 1 + i;
15698
15725
  const coordinator = new VideoCoordinator((message, transfer) => {
15699
15726
  if (this.workerManager) {
15727
+ if (message.type === "video-canvas-setup") {
15728
+ message.data.streamType = "additional";
15729
+ }
15700
15730
  if (transfer && transfer.length > 0) {
15701
15731
  this.workerManager.postMessage(message.type, message.data, transfer);
15702
15732
  } else {
@@ -15707,7 +15737,7 @@ class VijiCore {
15707
15737
  coordinator.setDebugMode(this.debugMode);
15708
15738
  coordinator.handleVideoStreamUpdate({
15709
15739
  videoStream: this.videoStreams[i],
15710
- streamIndex: 1 + i,
15740
+ streamIndex,
15711
15741
  streamType: "additional",
15712
15742
  targetFrameRate: 30,
15713
15743
  timestamp: performance.now()
@@ -16105,6 +16135,7 @@ class VijiCore {
16105
16135
  timestamp: performance.now()
16106
16136
  });
16107
16137
  this.deviceVideoCoordinators.set(deviceId, coordinator);
16138
+ this.syncDeviceStateToWorker();
16108
16139
  this.debugLog(`Device video set for ${deviceId} at index ${streamIndex}`);
16109
16140
  }
16110
16141
  /**
@@ -16116,6 +16147,7 @@ class VijiCore {
16116
16147
  if (!coordinator) return;
16117
16148
  coordinator.resetVideoState();
16118
16149
  this.deviceVideoCoordinators.delete(deviceId);
16150
+ this.syncDeviceStateToWorker();
16119
16151
  this.debugLog(`Device video cleared for ${deviceId}`);
16120
16152
  }
16121
16153
  /**
@@ -16236,4 +16268,4 @@ export {
16236
16268
  VijiCoreError as b,
16237
16269
  getDefaultExportFromCjs as g
16238
16270
  };
16239
- //# sourceMappingURL=index-BTtBhJW4.js.map
16271
+ //# sourceMappingURL=index-C45WlX2a.js.map