@viji-dev/core 0.3.1 → 0.3.3
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/artist-dts-p5.js +1 -1
- package/dist/artist-dts.js +1 -1
- package/dist/artist-global.d.ts +3 -1
- package/dist/artist-js-ambient.d.ts +47 -39
- package/dist/artist-jsdoc.d.ts +47 -39
- package/dist/assets/{viji.worker-Be0jZvYj.js → viji.worker-Cx1WpxdF.js} +146 -37
- package/dist/assets/viji.worker-Cx1WpxdF.js.map +1 -0
- package/dist/{essentia-wasm.web-D7gmeaO3.js → essentia-wasm.web-CQFnoLoE.js} +2 -2
- package/dist/{essentia-wasm.web-D7gmeaO3.js.map → essentia-wasm.web-CQFnoLoE.js.map} +1 -1
- package/dist/{index-BV1S8Ps-.js → index-BJPrSm-g.js} +105 -17
- package/dist/index-BJPrSm-g.js.map +1 -0
- package/dist/index.d.ts +24 -1
- package/dist/index.js +1 -1
- package/dist/shader-uniforms.js +125 -0
- package/package.json +1 -1
- package/dist/assets/viji.worker-Be0jZvYj.js.map +0 -1
- package/dist/index-BV1S8Ps-.js.map +0 -1
|
@@ -586,7 +586,7 @@ class IFrameManager {
|
|
|
586
586
|
}
|
|
587
587
|
function WorkerWrapper(options) {
|
|
588
588
|
return new Worker(
|
|
589
|
-
"" + new URL("assets/viji.worker-
|
|
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-
|
|
1938
|
+
const wasmModule = await import("./essentia-wasm.web-CQFnoLoE.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:
|
|
14314
|
+
data: {
|
|
14315
|
+
...config,
|
|
14316
|
+
streamIndex: this.streamIndex
|
|
14317
|
+
}
|
|
14307
14318
|
});
|
|
14308
14319
|
}
|
|
14309
14320
|
}
|
|
@@ -14419,7 +14430,8 @@ class DeviceSensorManager {
|
|
|
14419
14430
|
name: device.name,
|
|
14420
14431
|
motion: null,
|
|
14421
14432
|
orientation: null,
|
|
14422
|
-
geolocation: null
|
|
14433
|
+
geolocation: null,
|
|
14434
|
+
video: null
|
|
14423
14435
|
};
|
|
14424
14436
|
this.externalDevices.set(device.id, newDevice);
|
|
14425
14437
|
this.externalDeviceOrder.push(device.id);
|
|
@@ -14537,6 +14549,8 @@ class VijiCore {
|
|
|
14537
14549
|
additionalCoordinators = [];
|
|
14538
14550
|
// Direct frame injection
|
|
14539
14551
|
directFrameSlots = 0;
|
|
14552
|
+
// Device video management (coordinators only, for cleanup)
|
|
14553
|
+
deviceVideoCoordinators = /* @__PURE__ */ new Map();
|
|
14540
14554
|
// Auto-capture frame buffer (zero-copy transfer)
|
|
14541
14555
|
latestFrameBuffer = null;
|
|
14542
14556
|
autoCaptureEnabled = false;
|
|
@@ -14741,6 +14755,9 @@ class VijiCore {
|
|
|
14741
14755
|
if (this.videoStream) {
|
|
14742
14756
|
this.mainVideoCoordinator = new VideoCoordinator((message, transfer) => {
|
|
14743
14757
|
if (this.workerManager) {
|
|
14758
|
+
if (message.type === "video-canvas-setup") {
|
|
14759
|
+
message.data.streamType = "main";
|
|
14760
|
+
}
|
|
14744
14761
|
if (transfer && transfer.length > 0) {
|
|
14745
14762
|
this.workerManager.postMessage(message.type, message.data, transfer);
|
|
14746
14763
|
} else {
|
|
@@ -14752,14 +14769,18 @@ class VijiCore {
|
|
|
14752
14769
|
this.mainVideoCoordinator.handleVideoStreamUpdate({
|
|
14753
14770
|
videoStream: this.videoStream,
|
|
14754
14771
|
streamIndex: 0,
|
|
14755
|
-
|
|
14772
|
+
streamType: "main",
|
|
14756
14773
|
targetFrameRate: 30,
|
|
14757
14774
|
timestamp: performance.now()
|
|
14758
14775
|
});
|
|
14759
14776
|
}
|
|
14760
14777
|
for (let i = 0; i < this.videoStreams.length; i++) {
|
|
14778
|
+
const streamIndex = 1 + i;
|
|
14761
14779
|
const coordinator = new VideoCoordinator((message, transfer) => {
|
|
14762
14780
|
if (this.workerManager) {
|
|
14781
|
+
if (message.type === "video-canvas-setup") {
|
|
14782
|
+
message.data.streamType = "additional";
|
|
14783
|
+
}
|
|
14763
14784
|
if (transfer && transfer.length > 0) {
|
|
14764
14785
|
this.workerManager.postMessage(message.type, message.data, transfer);
|
|
14765
14786
|
} else {
|
|
@@ -14770,8 +14791,8 @@ class VijiCore {
|
|
|
14770
14791
|
coordinator.setDebugMode(this.debugMode);
|
|
14771
14792
|
coordinator.handleVideoStreamUpdate({
|
|
14772
14793
|
videoStream: this.videoStreams[i],
|
|
14773
|
-
streamIndex
|
|
14774
|
-
|
|
14794
|
+
streamIndex,
|
|
14795
|
+
streamType: "additional",
|
|
14775
14796
|
targetFrameRate: 30,
|
|
14776
14797
|
timestamp: performance.now()
|
|
14777
14798
|
});
|
|
@@ -15562,6 +15583,9 @@ class VijiCore {
|
|
|
15562
15583
|
if (stream && this.workerManager) {
|
|
15563
15584
|
this.mainVideoCoordinator = new VideoCoordinator((message, transfer) => {
|
|
15564
15585
|
if (this.workerManager) {
|
|
15586
|
+
if (message.type === "video-canvas-setup") {
|
|
15587
|
+
message.data.streamType = "main";
|
|
15588
|
+
}
|
|
15565
15589
|
if (transfer && transfer.length > 0) {
|
|
15566
15590
|
this.workerManager.postMessage(message.type, message.data, transfer);
|
|
15567
15591
|
} else {
|
|
@@ -15573,7 +15597,7 @@ class VijiCore {
|
|
|
15573
15597
|
this.mainVideoCoordinator.handleVideoStreamUpdate({
|
|
15574
15598
|
videoStream: stream,
|
|
15575
15599
|
streamIndex: 0,
|
|
15576
|
-
|
|
15600
|
+
streamType: "main",
|
|
15577
15601
|
targetFrameRate: 30,
|
|
15578
15602
|
timestamp: performance.now()
|
|
15579
15603
|
});
|
|
@@ -15623,8 +15647,12 @@ class VijiCore {
|
|
|
15623
15647
|
if (existingIndex !== -1) return existingIndex;
|
|
15624
15648
|
this.videoStreams.push(stream);
|
|
15625
15649
|
const newIndex = this.videoStreams.length - 1;
|
|
15650
|
+
const streamIndex = 1 + newIndex;
|
|
15626
15651
|
const coordinator = new VideoCoordinator((message, transfer) => {
|
|
15627
15652
|
if (this.workerManager) {
|
|
15653
|
+
if (message.type === "video-canvas-setup") {
|
|
15654
|
+
message.data.streamType = "additional";
|
|
15655
|
+
}
|
|
15628
15656
|
if (transfer && transfer.length > 0) {
|
|
15629
15657
|
this.workerManager.postMessage(message.type, message.data, transfer);
|
|
15630
15658
|
} else {
|
|
@@ -15635,8 +15663,8 @@ class VijiCore {
|
|
|
15635
15663
|
coordinator.setDebugMode(this.debugMode);
|
|
15636
15664
|
coordinator.handleVideoStreamUpdate({
|
|
15637
15665
|
videoStream: stream,
|
|
15638
|
-
streamIndex
|
|
15639
|
-
|
|
15666
|
+
streamIndex,
|
|
15667
|
+
streamType: "additional",
|
|
15640
15668
|
targetFrameRate: 30,
|
|
15641
15669
|
timestamp: performance.now()
|
|
15642
15670
|
});
|
|
@@ -15679,7 +15707,7 @@ class VijiCore {
|
|
|
15679
15707
|
this.additionalCoordinators[index].handleVideoStreamUpdate({
|
|
15680
15708
|
videoStream: stream,
|
|
15681
15709
|
streamIndex: 1 + index,
|
|
15682
|
-
|
|
15710
|
+
streamType: "additional",
|
|
15683
15711
|
targetFrameRate: 30,
|
|
15684
15712
|
timestamp: performance.now()
|
|
15685
15713
|
});
|
|
@@ -15692,8 +15720,12 @@ class VijiCore {
|
|
|
15692
15720
|
this.additionalCoordinators.forEach((coord) => coord.resetVideoState());
|
|
15693
15721
|
this.additionalCoordinators = [];
|
|
15694
15722
|
for (let i = 0; i < this.videoStreams.length; i++) {
|
|
15723
|
+
const streamIndex = 1 + i;
|
|
15695
15724
|
const coordinator = new VideoCoordinator((message, transfer) => {
|
|
15696
15725
|
if (this.workerManager) {
|
|
15726
|
+
if (message.type === "video-canvas-setup") {
|
|
15727
|
+
message.data.streamType = "additional";
|
|
15728
|
+
}
|
|
15697
15729
|
if (transfer && transfer.length > 0) {
|
|
15698
15730
|
this.workerManager.postMessage(message.type, message.data, transfer);
|
|
15699
15731
|
} else {
|
|
@@ -15704,8 +15736,8 @@ class VijiCore {
|
|
|
15704
15736
|
coordinator.setDebugMode(this.debugMode);
|
|
15705
15737
|
coordinator.handleVideoStreamUpdate({
|
|
15706
15738
|
videoStream: this.videoStreams[i],
|
|
15707
|
-
streamIndex
|
|
15708
|
-
|
|
15739
|
+
streamIndex,
|
|
15740
|
+
streamType: "additional",
|
|
15709
15741
|
targetFrameRate: 30,
|
|
15710
15742
|
timestamp: performance.now()
|
|
15711
15743
|
});
|
|
@@ -16051,6 +16083,9 @@ class VijiCore {
|
|
|
16051
16083
|
*/
|
|
16052
16084
|
removeExternalDevice(deviceId) {
|
|
16053
16085
|
if (!this.deviceSensorManager) return;
|
|
16086
|
+
if (this.deviceVideoCoordinators.has(deviceId)) {
|
|
16087
|
+
this.clearDeviceVideo(deviceId);
|
|
16088
|
+
}
|
|
16054
16089
|
this.deviceSensorManager.removeExternalDevice(deviceId);
|
|
16055
16090
|
this.syncDeviceStateToWorker();
|
|
16056
16091
|
this.debugLog(`External device removed: ${deviceId}`);
|
|
@@ -16063,6 +16098,55 @@ class VijiCore {
|
|
|
16063
16098
|
if (!this.deviceSensorManager) return [];
|
|
16064
16099
|
return this.deviceSensorManager.getExternalDeviceList();
|
|
16065
16100
|
}
|
|
16101
|
+
// ========================================
|
|
16102
|
+
// Device Video API
|
|
16103
|
+
// ========================================
|
|
16104
|
+
/**
|
|
16105
|
+
* Set video stream for an external device
|
|
16106
|
+
* Device camera will appear in viji.devices[].video
|
|
16107
|
+
* @param deviceId - Device identifier
|
|
16108
|
+
* @param stream - MediaStream from device camera
|
|
16109
|
+
*/
|
|
16110
|
+
async setDeviceVideo(deviceId, stream) {
|
|
16111
|
+
this.validateReady();
|
|
16112
|
+
await this.clearDeviceVideo(deviceId);
|
|
16113
|
+
const baseIndex = this.videoStream ? 1 : 0;
|
|
16114
|
+
const streamIndex = baseIndex + this.videoStreams.length + this.deviceVideoCoordinators.size;
|
|
16115
|
+
const coordinator = new VideoCoordinator((message, transfer) => {
|
|
16116
|
+
if (this.workerManager) {
|
|
16117
|
+
if (message.type === "video-canvas-setup") {
|
|
16118
|
+
message.data.deviceId = deviceId;
|
|
16119
|
+
message.data.streamType = "device";
|
|
16120
|
+
}
|
|
16121
|
+
if (transfer && transfer.length > 0) {
|
|
16122
|
+
this.workerManager.postMessage(message.type, message.data, transfer);
|
|
16123
|
+
} else {
|
|
16124
|
+
this.workerManager.postMessage(message.type, message.data);
|
|
16125
|
+
}
|
|
16126
|
+
}
|
|
16127
|
+
});
|
|
16128
|
+
coordinator.setDebugMode(this.debugMode);
|
|
16129
|
+
coordinator.handleVideoStreamUpdate({
|
|
16130
|
+
videoStream: stream,
|
|
16131
|
+
streamIndex,
|
|
16132
|
+
targetFrameRate: 30,
|
|
16133
|
+
// Same as all other videos
|
|
16134
|
+
timestamp: performance.now()
|
|
16135
|
+
});
|
|
16136
|
+
this.deviceVideoCoordinators.set(deviceId, coordinator);
|
|
16137
|
+
this.debugLog(`Device video set for ${deviceId} at index ${streamIndex}`);
|
|
16138
|
+
}
|
|
16139
|
+
/**
|
|
16140
|
+
* Clear video stream from device
|
|
16141
|
+
* @param deviceId - Device identifier
|
|
16142
|
+
*/
|
|
16143
|
+
async clearDeviceVideo(deviceId) {
|
|
16144
|
+
const coordinator = this.deviceVideoCoordinators.get(deviceId);
|
|
16145
|
+
if (!coordinator) return;
|
|
16146
|
+
coordinator.resetVideoState();
|
|
16147
|
+
this.deviceVideoCoordinators.delete(deviceId);
|
|
16148
|
+
this.debugLog(`Device video cleared for ${deviceId}`);
|
|
16149
|
+
}
|
|
16066
16150
|
/**
|
|
16067
16151
|
* Checks if the core is ready for use
|
|
16068
16152
|
*/
|
|
@@ -16091,6 +16175,10 @@ class VijiCore {
|
|
|
16091
16175
|
this.capabilitiesChangeListeners.clear();
|
|
16092
16176
|
this.unlinkEventSource();
|
|
16093
16177
|
this.unlinkFrameSources();
|
|
16178
|
+
for (const [deviceId] of this.deviceVideoCoordinators) {
|
|
16179
|
+
await this.clearDeviceVideo(deviceId);
|
|
16180
|
+
}
|
|
16181
|
+
this.deviceVideoCoordinators.clear();
|
|
16094
16182
|
if (this.deviceSensorManager) {
|
|
16095
16183
|
this.deviceSensorManager.destroy();
|
|
16096
16184
|
this.deviceSensorManager = null;
|
|
@@ -16177,4 +16265,4 @@ export {
|
|
|
16177
16265
|
VijiCoreError as b,
|
|
16178
16266
|
getDefaultExportFromCjs as g
|
|
16179
16267
|
};
|
|
16180
|
-
//# sourceMappingURL=index-
|
|
16268
|
+
//# sourceMappingURL=index-BJPrSm-g.js.map
|