@viji-dev/core 0.17.0 → 0.18.0
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-p5.d.ts +7 -2
- package/dist/artist-global.d.ts +7 -2
- package/dist/artist-jsdoc.d.ts +1 -1
- package/dist/assets/viji.worker-CwvLwn6O.js +616 -0
- package/dist/docs-api.js +20 -5
- package/dist/{essentia-wasm.web-6LFlxl9Z.js → essentia-wasm.web-DclksH__.js} +1 -1
- package/dist/{index-BxSadexI.js → index-BFSuPQzu.js} +201 -157
- package/dist/index.d.ts +27 -8
- package/dist/index.js +1 -1
- package/package.json +117 -117
- package/dist/assets/viji.worker-Fw1ZBqRQ.js +0 -616
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { S as mB } from "./scene-analysis-2Ov0HS52.js";
|
|
2
|
-
const
|
|
2
|
+
const DQ = [
|
|
3
3
|
"audio",
|
|
4
4
|
"video",
|
|
5
5
|
"mouse",
|
|
@@ -8,7 +8,7 @@ const oQ = [
|
|
|
8
8
|
"touch",
|
|
9
9
|
"sensors",
|
|
10
10
|
"devices"
|
|
11
|
-
],
|
|
11
|
+
], hQ = [
|
|
12
12
|
"faceDetection",
|
|
13
13
|
"faceMesh",
|
|
14
14
|
"emotion",
|
|
@@ -16,7 +16,7 @@ const oQ = [
|
|
|
16
16
|
"poseDetection",
|
|
17
17
|
"segmentation"
|
|
18
18
|
];
|
|
19
|
-
class
|
|
19
|
+
class d extends Error {
|
|
20
20
|
constructor(A, B, I) {
|
|
21
21
|
super(A), this.code = B, this.context = I, this.name = "VijiCoreError";
|
|
22
22
|
}
|
|
@@ -178,15 +178,15 @@ class zB {
|
|
|
178
178
|
return this.iframeReadyTimeoutId = setTimeout(() => {
|
|
179
179
|
if (this.iframeReadyTimeoutId = null, this.iframeReadyRejecter) {
|
|
180
180
|
const Q = this.iframeReadyRejecter;
|
|
181
|
-
this.iframeReadyResolver = null, this.iframeReadyRejecter = null, Q(new
|
|
181
|
+
this.iframeReadyResolver = null, this.iframeReadyRejecter = null, Q(new d("IFrame load timeout", "IFRAME_TIMEOUT"));
|
|
182
182
|
}
|
|
183
183
|
}, 5e3), A.onerror = () => {
|
|
184
184
|
this.iframeReadyRejecter && this.iframeReadyRejecter(
|
|
185
|
-
new
|
|
185
|
+
new d("IFrame load failed", "IFRAME_LOAD_ERROR")
|
|
186
186
|
);
|
|
187
187
|
}, this.iframe = A, this.isInitialized = !0, A;
|
|
188
188
|
} catch (A) {
|
|
189
|
-
throw new
|
|
189
|
+
throw new d(
|
|
190
190
|
`Failed to create secure IFrame: ${A}`,
|
|
191
191
|
"IFRAME_CREATION_ERROR",
|
|
192
192
|
{ error: A }
|
|
@@ -200,7 +200,7 @@ class zB {
|
|
|
200
200
|
*/
|
|
201
201
|
async waitForReady() {
|
|
202
202
|
if (!this.iframeReadyPromise)
|
|
203
|
-
throw new
|
|
203
|
+
throw new d(
|
|
204
204
|
"IFrame not yet created — call createSecureIFrame() first",
|
|
205
205
|
"IFRAME_NOT_READY"
|
|
206
206
|
);
|
|
@@ -221,12 +221,12 @@ class zB {
|
|
|
221
221
|
*/
|
|
222
222
|
postEnvelope(A, B = []) {
|
|
223
223
|
if (!this.iframe?.contentWindow)
|
|
224
|
-
throw new
|
|
224
|
+
throw new d(
|
|
225
225
|
"IFrame contentWindow not available",
|
|
226
226
|
"IFRAME_NOT_READY"
|
|
227
227
|
);
|
|
228
228
|
if (this.lockedOrigin === null)
|
|
229
|
-
throw new
|
|
229
|
+
throw new d(
|
|
230
230
|
"IFrame origin not yet known — wait for iframe-ready first",
|
|
231
231
|
"IFRAME_ORIGIN_UNKNOWN"
|
|
232
232
|
);
|
|
@@ -440,7 +440,7 @@ class zB {
|
|
|
440
440
|
try {
|
|
441
441
|
if (this.iframeReadyTimeoutId !== null && (clearTimeout(this.iframeReadyTimeoutId), this.iframeReadyTimeoutId = null), this.iframeReadyRejecter) {
|
|
442
442
|
const A = this.iframeReadyRejecter;
|
|
443
|
-
this.iframeReadyResolver = null, this.iframeReadyRejecter = null, A(new
|
|
443
|
+
this.iframeReadyResolver = null, this.iframeReadyRejecter = null, A(new d("Initialization cancelled", "INITIALIZATION_CANCELLED"));
|
|
444
444
|
}
|
|
445
445
|
if (this.iframe?.contentWindow && this.lockedOrigin)
|
|
446
446
|
try {
|
|
@@ -605,7 +605,7 @@ class zB {
|
|
|
605
605
|
}
|
|
606
606
|
}
|
|
607
607
|
}
|
|
608
|
-
const VB = "" + new URL("assets/viji.worker-
|
|
608
|
+
const VB = "" + new URL("assets/viji.worker-CwvLwn6O.js", import.meta.url).href;
|
|
609
609
|
class XB {
|
|
610
610
|
constructor(A, B, I) {
|
|
611
611
|
this.iframeManager = A, this.sceneCode = B, this.init = I;
|
|
@@ -694,7 +694,7 @@ class XB {
|
|
|
694
694
|
this.bootstrapTimeoutId !== null && (clearTimeout(this.bootstrapTimeoutId), this.bootstrapTimeoutId = null);
|
|
695
695
|
const i = this.bootstrapReject;
|
|
696
696
|
this.bootstrapReject = null, i(
|
|
697
|
-
new
|
|
697
|
+
new d(
|
|
698
698
|
`Worker spawn blocked by host CSP: ${C.csp.violatedDirective} refused ${C.csp.blockedURI}. The embedding page's Content-Security-Policy must allow the viji worker (see the host integration contract: worker-src blob: data: https:).`,
|
|
699
699
|
"WORKER_SPAWN_CSP_BLOCKED",
|
|
700
700
|
{ csp: C.csp, message: C.message }
|
|
@@ -705,7 +705,7 @@ class XB {
|
|
|
705
705
|
const E = new Promise((C, i) => {
|
|
706
706
|
this.bootstrapReject = i, this.bootstrapTimeoutId = setTimeout(() => {
|
|
707
707
|
this.bootstrapTimeoutId = null, i(
|
|
708
|
-
new
|
|
708
|
+
new d(
|
|
709
709
|
"viji-ready timeout",
|
|
710
710
|
"WORKER_BOOTSTRAP_TIMEOUT"
|
|
711
711
|
)
|
|
@@ -731,7 +731,7 @@ class XB {
|
|
|
731
731
|
}, this.controlPort.onmessage = this.onControlPortMessageBound;
|
|
732
732
|
}
|
|
733
733
|
if (!this.controlPort)
|
|
734
|
-
throw new
|
|
734
|
+
throw new d(
|
|
735
735
|
"Control port unavailable when posting set-scene-code",
|
|
736
736
|
"WORKER_CREATION_ERROR"
|
|
737
737
|
);
|
|
@@ -746,10 +746,10 @@ class XB {
|
|
|
746
746
|
), this.sceneAnalysis.catch(() => {
|
|
747
747
|
}), this.isInitialized = !0;
|
|
748
748
|
} catch (A) {
|
|
749
|
-
throw A instanceof
|
|
749
|
+
throw A instanceof d && A.code === "INITIALIZATION_CANCELLED" ? A : this.isDestroyed ? new d(
|
|
750
750
|
"Initialization cancelled",
|
|
751
751
|
"INITIALIZATION_CANCELLED"
|
|
752
|
-
) : new
|
|
752
|
+
) : new d(
|
|
753
753
|
`Failed to create worker: ${A}`,
|
|
754
754
|
"WORKER_CREATION_ERROR",
|
|
755
755
|
{ error: A }
|
|
@@ -769,7 +769,7 @@ class XB {
|
|
|
769
769
|
return new Promise((E, C) => {
|
|
770
770
|
const i = setTimeout(() => {
|
|
771
771
|
this.pendingMessages.delete(Q), C(
|
|
772
|
-
new
|
|
772
|
+
new d(`Message timeout: ${A}`, "MESSAGE_TIMEOUT")
|
|
773
773
|
);
|
|
774
774
|
}, I);
|
|
775
775
|
this.pendingMessages.set(Q, {
|
|
@@ -803,7 +803,7 @@ class XB {
|
|
|
803
803
|
*/
|
|
804
804
|
relayHostToWorker(A) {
|
|
805
805
|
if (!this.iframeManager.ready && !this.isInitialized && !this.iframeManager.element) {
|
|
806
|
-
console.warn("Attempted to post message to destroyed worker");
|
|
806
|
+
console.warn("Attempted to post message to destroyed worker"), this.rejectPendingPost(A, new Error("iframe destroyed"));
|
|
807
807
|
return;
|
|
808
808
|
}
|
|
809
809
|
try {
|
|
@@ -820,9 +820,26 @@ class XB {
|
|
|
820
820
|
console.warn(
|
|
821
821
|
`Failed to relay host-to-worker message ${A.type}:`,
|
|
822
822
|
B
|
|
823
|
-
);
|
|
823
|
+
), this.rejectPendingPost(A, B);
|
|
824
824
|
}
|
|
825
825
|
}
|
|
826
|
+
/**
|
|
827
|
+
* A correlated RPC whose payload could not be posted (e.g. DataCloneError
|
|
828
|
+
* on a detached ImageBitmap, or the iframe already gone) would otherwise
|
|
829
|
+
* die only by its timeout with no cause attached. Reject the pending entry
|
|
830
|
+
* typed now and clear its timer (docs/14 rule 5). Fire-and-forget messages
|
|
831
|
+
* have no entry, so this is a no-op for them.
|
|
832
|
+
*/
|
|
833
|
+
rejectPendingPost(A, B) {
|
|
834
|
+
const I = this.pendingMessages.get(A.id);
|
|
835
|
+
I && (clearTimeout(I.timeout), this.pendingMessages.delete(A.id), I.reject(
|
|
836
|
+
new d(
|
|
837
|
+
`Failed to post ${A.type}: ${B?.message ?? String(B)}`,
|
|
838
|
+
"MESSAGE_POST_ERROR",
|
|
839
|
+
{ error: B, type: A.type }
|
|
840
|
+
)
|
|
841
|
+
));
|
|
842
|
+
}
|
|
826
843
|
/**
|
|
827
844
|
* Registers a handler for worker messages.
|
|
828
845
|
*/
|
|
@@ -844,10 +861,10 @@ class XB {
|
|
|
844
861
|
try {
|
|
845
862
|
if (this.isDestroyed = !0, this.bootstrapTimeoutId !== null && (clearTimeout(this.bootstrapTimeoutId), this.bootstrapTimeoutId = null), this.bootstrapReject) {
|
|
846
863
|
const A = this.bootstrapReject;
|
|
847
|
-
this.bootstrapReject = null, A(new
|
|
864
|
+
this.bootstrapReject = null, A(new d("Initialization cancelled", "INITIALIZATION_CANCELLED"));
|
|
848
865
|
}
|
|
849
866
|
this.pendingMessages.forEach(({ timeout: A, reject: B }) => {
|
|
850
|
-
clearTimeout(A), B(new
|
|
867
|
+
clearTimeout(A), B(new d("Worker destroyed", "WORKER_DESTROYED"));
|
|
851
868
|
}), this.pendingMessages.clear(), this.messageHandlers.clear(), this.onWorkerMessageBound && (this.iframeManager.offWorkerMessage(this.onWorkerMessageBound), this.onWorkerMessageBound = null), this.controlPort && this.onControlPortMessageBound && (this.controlPort.onmessage = null, this.onControlPortMessageBound = null), this.controlPort = null, this.isInitialized = !1;
|
|
852
869
|
} catch (A) {
|
|
853
870
|
console.warn("Error during worker cleanup:", A);
|
|
@@ -868,7 +885,7 @@ class XB {
|
|
|
868
885
|
*/
|
|
869
886
|
waitForSceneAnalysis() {
|
|
870
887
|
return this.sceneAnalysis ? this.sceneAnalysis : Promise.reject(
|
|
871
|
-
new
|
|
888
|
+
new d(
|
|
872
889
|
"scene-analysis awaited before set-scene-code was posted",
|
|
873
890
|
"WORKER_CREATION_ERROR"
|
|
874
891
|
)
|
|
@@ -883,7 +900,7 @@ class XB {
|
|
|
883
900
|
if (this.pendingMessages.has(B.id)) {
|
|
884
901
|
const Q = this.pendingMessages.get(B.id);
|
|
885
902
|
clearTimeout(Q.timeout), this.pendingMessages.delete(B.id), B.type === "error" ? Q.reject(
|
|
886
|
-
new
|
|
903
|
+
new d(
|
|
887
904
|
B.data?.message || "Worker error",
|
|
888
905
|
B.data?.code || "WORKER_ERROR",
|
|
889
906
|
B.data
|
|
@@ -910,13 +927,13 @@ async function KB(G) {
|
|
|
910
927
|
try {
|
|
911
928
|
const A = await fetch(G, { signal: AbortSignal.timeout(fA) });
|
|
912
929
|
if (!A.ok)
|
|
913
|
-
throw new
|
|
930
|
+
throw new d(
|
|
914
931
|
`Failed to fetch ${G}: ${A.status} ${A.statusText}`,
|
|
915
932
|
"WORKER_ASSET_FETCH_ERROR"
|
|
916
933
|
);
|
|
917
934
|
return await A.arrayBuffer();
|
|
918
935
|
} catch (A) {
|
|
919
|
-
throw A instanceof DOMException && A.name === "TimeoutError" ? new
|
|
936
|
+
throw A instanceof DOMException && A.name === "TimeoutError" ? new d(
|
|
920
937
|
`Timed out fetching ${G} after ${fA}ms`,
|
|
921
938
|
"WORKER_ASSET_FETCH_ERROR"
|
|
922
939
|
) : A;
|
|
@@ -1300,7 +1317,7 @@ class jB {
|
|
|
1300
1317
|
h.fluxHistory || (h.fluxHistory = []), h.fluxHistory.push(e), h.fluxHistory.length > 3 && h.fluxHistory.shift();
|
|
1301
1318
|
let F = e;
|
|
1302
1319
|
h.fluxHistory.length >= 2 && (F += h.fluxHistory[h.fluxHistory.length - 2] * 0.5), h.fluxHistory.length >= 3 && (F += h.fluxHistory[h.fluxHistory.length - 3] * 0.25), F /= 1.75, h.lastFlux = F, h.lastEnergy = D;
|
|
1303
|
-
const y = D - h.prevEnergy * 0.95, M = Math.max(F, F + y * 0.2),
|
|
1320
|
+
const y = D - h.prevEnergy * 0.95, M = Math.max(F, F + y * 0.2), J = M / Math.max(1e-3, Q), k = Math.min(1, J / 0.08), n = this.recentEnergies.get(a), l = this.recentFluxes.get(a);
|
|
1304
1321
|
n.push(D), l.push(F), n.length > this.STATS_WINDOW_SIZE && n.shift(), l.length > this.STATS_WINDOW_SIZE && l.shift();
|
|
1305
1322
|
const Y = 6e4 / this.currentBPM, U = Math.max(150, Math.min(350, Y * 0.45)), Z = Y / 4, S = a === "high" || a === "highMid" ? Z * 0.45 : Z * 0.9, p = Math.max(a === "high" || a === "highMid" ? 60 : 80, Math.min(a === "high" || a === "highMid" ? 150 : 250, S)), q = a === "low" ? U : p, T = a === "high" ? 0.85 : 1, X = h.cutoff * T, x = F > R.minFlux, _ = D > X, r = D > R.minThreshold, $ = I - h.lastOnsetTime > q, K = x && _ && r && $;
|
|
1306
1323
|
if (a === "low" || this.debugMode && a === "high") {
|
|
@@ -1636,7 +1653,7 @@ class TB {
|
|
|
1636
1653
|
if (!this.isInitialized)
|
|
1637
1654
|
return this.initPromise ? this.initPromise : (this.initPromise = (async () => {
|
|
1638
1655
|
try {
|
|
1639
|
-
const A = await import("./essentia.js-core.es-CC_3Ap1i.js"), B = await import("./essentia-wasm.web-
|
|
1656
|
+
const A = await import("./essentia.js-core.es-CC_3Ap1i.js"), B = await import("./essentia-wasm.web-DclksH__.js").then((g) => g.e), I = A.Essentia || A.default?.Essentia || A.default;
|
|
1640
1657
|
let Q = B.default || B.EssentiaWASM || B.default?.EssentiaWASM;
|
|
1641
1658
|
if (!Q)
|
|
1642
1659
|
throw new Error("WASM module not found - check essentia-wasm.web.js export");
|
|
@@ -1750,7 +1767,7 @@ class TB {
|
|
|
1750
1767
|
this.adaptiveLambda.snare,
|
|
1751
1768
|
// 1.4 - balanced
|
|
1752
1769
|
"snare"
|
|
1753
|
-
), y = this.detectionHistory.complex.slice(-3), M = this.detectionHistory.hfc.slice(-3),
|
|
1770
|
+
), y = this.detectionHistory.complex.slice(-3), M = this.detectionHistory.hfc.slice(-3), J = this.detectionHistory.flux.slice(-3), k = this.temporalIntegration(y, "kick"), n = this.temporalIntegration(M, "hat"), l = this.temporalIntegration(J, "snare"), Y = Math.min(5, Math.max(0, k)), U = Math.max(0, n), Z = Math.min(5, Math.max(0, l)), S = this.calculateSharpness(k, y), H = this.calculateSharpness(l, J), W = this.calculateSharpness(n, M), p = i - this.lastOnsetTime.kick, q = i - this.lastOnsetTime.snare, T = i - this.lastOnsetTime.hat, X = p >= this.minOnsetInterval.kick, x = q >= this.minOnsetInterval.snare, _ = T >= this.minOnsetInterval.hat, r = X && Y > c && Q.low > this.bandThresholds.low, $ = _ && U > e && (Q.high > this.bandThresholds.high || Q.highMid > this.bandThresholds.highMid), K = x && Z > F && Q.mid > this.bandThresholds.mid, z = Q.high + Q.highMid > 5e-4, f = Q.mid > 5e-4, b = $ && Q.high + Q.highMid > Q.mid * 2 + 1e-9, m = K && f && !b, V = $ && z, N = r || m || V;
|
|
1754
1771
|
r && (this.lastOnsetTime.kick = i), m && (this.lastOnsetTime.snare = i), V && (this.lastOnsetTime.hat = i), N && (this.lastOnsetTime.global = i), N && this.debugFrameCount++;
|
|
1755
1772
|
const u = Math.max(0, Math.min(1, Math.max(k, n, l)));
|
|
1756
1773
|
return {
|
|
@@ -2196,19 +2213,19 @@ class II {
|
|
|
2196
2213
|
for (let D = E; D <= C && D < g.length; D++) {
|
|
2197
2214
|
let h = 0, R = 0, w = 0;
|
|
2198
2215
|
for (let y = D; y < g.length; y++) {
|
|
2199
|
-
const M = g[y],
|
|
2200
|
-
h += M *
|
|
2216
|
+
const M = g[y], J = g[y - D];
|
|
2217
|
+
h += M * J, R += M * M, w += J * J;
|
|
2201
2218
|
}
|
|
2202
2219
|
const t = Math.sqrt(R * w) + 1e-8;
|
|
2203
2220
|
let c = h / t;
|
|
2204
2221
|
const e = this.fpsEstimate * 60 / D, F = Math.round(D / 2);
|
|
2205
2222
|
if (F >= E && F < g.length) {
|
|
2206
|
-
let y = 0, M = 0,
|
|
2223
|
+
let y = 0, M = 0, J = 0;
|
|
2207
2224
|
for (let n = F; n < g.length; n++) {
|
|
2208
2225
|
const l = g[n], Y = g[n - F];
|
|
2209
|
-
y += l * Y, M += l * l,
|
|
2226
|
+
y += l * Y, M += l * l, J += Y * Y;
|
|
2210
2227
|
}
|
|
2211
|
-
const k = y / (Math.sqrt(M *
|
|
2228
|
+
const k = y / (Math.sqrt(M * J) + 1e-8);
|
|
2212
2229
|
k > 0.4 && Math.abs(k - c) < 0.15 && (c *= 0.85);
|
|
2213
2230
|
}
|
|
2214
2231
|
e >= _B && e <= $B && (c *= 1.03), c > o && (o = c, i = D);
|
|
@@ -2393,9 +2410,9 @@ class II {
|
|
|
2393
2410
|
}
|
|
2394
2411
|
const y = [A.bpm, B.bpm];
|
|
2395
2412
|
let M = !1;
|
|
2396
|
-
for (const
|
|
2397
|
-
if (Math.abs(
|
|
2398
|
-
if (this.scoreGridAlignment(
|
|
2413
|
+
for (const J of y) {
|
|
2414
|
+
if (Math.abs(J - this.gridLockBPM) / this.gridLockBPM < 0.05) continue;
|
|
2415
|
+
if (this.scoreGridAlignment(J, this.getRecentOnsets(), I) > this.gridLockScore + 0.1 && c > 1500) {
|
|
2399
2416
|
M = !0;
|
|
2400
2417
|
break;
|
|
2401
2418
|
}
|
|
@@ -2403,13 +2420,13 @@ class II {
|
|
|
2403
2420
|
if (M)
|
|
2404
2421
|
this.gridLockMemoryBPM = this.gridLockBPM, this.gridLockMemoryTime = I, this.gridLockBPM = null;
|
|
2405
2422
|
else if (c > this.GRID_LOCK_DURATION_MS) {
|
|
2406
|
-
const
|
|
2407
|
-
e <
|
|
2423
|
+
const J = this.syncopationLevel > 0.6 ? 0.4 : 0.5;
|
|
2424
|
+
e < J && (this.gridLockMemoryBPM = this.gridLockBPM, this.gridLockMemoryTime = I, this.gridLockBPM = null);
|
|
2408
2425
|
} else if (c > 7e3)
|
|
2409
2426
|
this.gridLockMemoryBPM = this.gridLockBPM, this.gridLockMemoryTime = I, this.gridLockBPM = null;
|
|
2410
2427
|
else {
|
|
2411
|
-
const
|
|
2412
|
-
this.applyFinalBPM(
|
|
2428
|
+
const J = this.gridLockBPM;
|
|
2429
|
+
this.applyFinalBPM(J, 0.85, "combined", B.anchorBand, I), this.updateHypotheses(J, 0.85, I), this.updateDriftRate(J, I), this.detectTransition();
|
|
2413
2430
|
return;
|
|
2414
2431
|
}
|
|
2415
2432
|
}
|
|
@@ -2444,12 +2461,12 @@ class II {
|
|
|
2444
2461
|
];
|
|
2445
2462
|
let F = c;
|
|
2446
2463
|
const y = this.scoreGridAlignment(c, this.getRecentOnsets(), I), M = c / O * 0.5;
|
|
2447
|
-
let
|
|
2464
|
+
let J = 0;
|
|
2448
2465
|
if (this.gridLockMemoryBPM !== null) {
|
|
2449
2466
|
const l = I - this.gridLockMemoryTime;
|
|
2450
|
-
l < this.GRID_LOCK_MEMORY_DURATION_MS ? Math.abs(c - this.gridLockMemoryBPM) / this.gridLockMemoryBPM < 0.05 && (
|
|
2467
|
+
l < this.GRID_LOCK_MEMORY_DURATION_MS ? Math.abs(c - this.gridLockMemoryBPM) / this.gridLockMemoryBPM < 0.05 && (J = 0.2 * (1 - l / this.GRID_LOCK_MEMORY_DURATION_MS)) : this.gridLockMemoryBPM = null;
|
|
2451
2468
|
}
|
|
2452
|
-
let k = y + M +
|
|
2469
|
+
let k = y + M + J;
|
|
2453
2470
|
for (const l of e) {
|
|
2454
2471
|
if (l < IA || l > O || Math.abs(l - c) < 5) continue;
|
|
2455
2472
|
const Y = this.scoreGridAlignment(l, this.getRecentOnsets(), I), U = l / O * 0.5;
|
|
@@ -2516,7 +2533,7 @@ class II {
|
|
|
2516
2533
|
let e = A.bpm, F = -1;
|
|
2517
2534
|
for (const y of c) {
|
|
2518
2535
|
if (y < IA || y > O) continue;
|
|
2519
|
-
const M = this.scoreGridAlignment(y, this.getRecentOnsets(), I),
|
|
2536
|
+
const M = this.scoreGridAlignment(y, this.getRecentOnsets(), I), J = y === A.bpm || Math.abs(y - A.bpm) < 5 ? 0.1 : 0, k = M + J, n = y / O * 0.5;
|
|
2520
2537
|
let l = 0;
|
|
2521
2538
|
if (this.gridLockMemoryBPM !== null) {
|
|
2522
2539
|
const U = I - this.gridLockMemoryTime;
|
|
@@ -2541,11 +2558,11 @@ class II {
|
|
|
2541
2558
|
e + 8,
|
|
2542
2559
|
e + 10
|
|
2543
2560
|
];
|
|
2544
|
-
let M = e,
|
|
2561
|
+
let M = e, J = F;
|
|
2545
2562
|
for (const n of y) {
|
|
2546
2563
|
if (n < IA || n > O) continue;
|
|
2547
2564
|
const l = this.scoreGridAlignment(n, this.getRecentOnsets(), I), Y = n / O * 0.5, U = l + Y;
|
|
2548
|
-
U >
|
|
2565
|
+
U > J && (M = n, J = U);
|
|
2549
2566
|
}
|
|
2550
2567
|
let k = !0;
|
|
2551
2568
|
if (M > 140 && B.bpm >= 60 && B.bpm <= 150 && B.confidence > 0.5) {
|
|
@@ -2555,7 +2572,7 @@ class II {
|
|
|
2555
2572
|
Y > U * 0.8 && (M = B.bpm, i = B.bpm, s = "ioi", o = B.confidence, k = !1);
|
|
2556
2573
|
}
|
|
2557
2574
|
}
|
|
2558
|
-
k && (this.gridLockBPM = M, this.gridLockScore =
|
|
2575
|
+
k && (this.gridLockBPM = M, this.gridLockScore = J, this.gridLockTime = I, i = M);
|
|
2559
2576
|
}
|
|
2560
2577
|
} else
|
|
2561
2578
|
i = A.bpm, o = A.confidence * 0.7, s = "autocorr", this.methodAgreement = 0.3;
|
|
@@ -2707,19 +2724,19 @@ class II {
|
|
|
2707
2724
|
)), s.length < 10)
|
|
2708
2725
|
return 0;
|
|
2709
2726
|
const a = Math.min(2e3, E * 3), h = s.filter((y, M) => {
|
|
2710
|
-
const
|
|
2711
|
-
if (
|
|
2727
|
+
const J = s.filter((k) => k !== y && Math.abs(k.time - y.time) < a).map((k) => ({ time: k.time, interval: Math.abs(k.time - y.time) })).sort((k, n) => k.interval - n.interval);
|
|
2728
|
+
if (J.length < 2)
|
|
2712
2729
|
return !1;
|
|
2713
|
-
for (let k = 0; k < Math.min(3,
|
|
2714
|
-
const n =
|
|
2730
|
+
for (let k = 0; k < Math.min(3, J.length - 1); k++) {
|
|
2731
|
+
const n = J[k].interval, l = J[k + 1].interval;
|
|
2715
2732
|
if (Math.max(n, l) / Math.min(n, l) < 1.5)
|
|
2716
2733
|
return !0;
|
|
2717
2734
|
}
|
|
2718
2735
|
if (M < 3) {
|
|
2719
|
-
|
|
2736
|
+
J.slice(0, 4).map((n) => `${n.interval.toFixed(0)}ms`).join(", ");
|
|
2720
2737
|
const k = [];
|
|
2721
|
-
for (let n = 0; n < Math.min(3,
|
|
2722
|
-
const l = Math.max(
|
|
2738
|
+
for (let n = 0; n < Math.min(3, J.length - 1); n++) {
|
|
2739
|
+
const l = Math.max(J[n].interval, J[n + 1].interval) / Math.min(J[n].interval, J[n + 1].interval);
|
|
2723
2740
|
k.push(l.toFixed(2));
|
|
2724
2741
|
}
|
|
2725
2742
|
}
|
|
@@ -2737,8 +2754,8 @@ class II {
|
|
|
2737
2754
|
const l = Math.abs(y.time - n);
|
|
2738
2755
|
l < M && (M = l);
|
|
2739
2756
|
}
|
|
2740
|
-
const
|
|
2741
|
-
t +=
|
|
2757
|
+
const J = Math.min(0.5, M / E), k = Math.sqrt(y.strength / 1e3);
|
|
2758
|
+
t += J * k, c += k;
|
|
2742
2759
|
}
|
|
2743
2760
|
const e = t / (c + 1e-3);
|
|
2744
2761
|
return 1 - Math.min(1, e * 2);
|
|
@@ -3559,7 +3576,7 @@ class RI {
|
|
|
3559
3576
|
} else C.hat;
|
|
3560
3577
|
const e = this.eventBuffer.map((k) => k.event);
|
|
3561
3578
|
this.debugMode && e.length > 0 && g - (this.lastBufferLogTime || 0) > 2e3 && (this.lastBufferLogTime = g), this.updateEnvelopes(C, A, Q);
|
|
3562
|
-
const F = this.calculateConfidence(), y = this.calculateTrackingConfidence(B), M = this.state === "LOCKED" || this.state === "BREAKDOWN",
|
|
3579
|
+
const F = this.calculateConfidence(), y = this.calculateTrackingConfidence(B), M = this.state === "LOCKED" || this.state === "BREAKDOWN", J = this.createDebugInfo(B, I, g, y);
|
|
3563
3580
|
return {
|
|
3564
3581
|
kick: this.envelopes.kick.getValue(),
|
|
3565
3582
|
snare: this.envelopes.snare.getValue(),
|
|
@@ -3576,7 +3593,7 @@ class RI {
|
|
|
3576
3593
|
bar: I.getBar(),
|
|
3577
3594
|
confidence: F,
|
|
3578
3595
|
isLocked: M,
|
|
3579
|
-
debug:
|
|
3596
|
+
debug: J
|
|
3580
3597
|
// Phase 6: Optional debug fields
|
|
3581
3598
|
};
|
|
3582
3599
|
}
|
|
@@ -3853,10 +3870,10 @@ class RI {
|
|
|
3853
3870
|
return { kick: !1, snare: !1, hat: !1, any: !1 };
|
|
3854
3871
|
const t = A.ratios.bass, c = A.ratios.mid, e = A.ratios.treble;
|
|
3855
3872
|
(E > 1e-6 ? g / E : 1) > 0.6 && e < 0.55 && w < 0.45 && (D = !1);
|
|
3856
|
-
const y = performance.now(), M = y - this.lastKickTime,
|
|
3873
|
+
const y = performance.now(), M = y - this.lastKickTime, J = M > 30 && M < 251;
|
|
3857
3874
|
let n = I.low.onset && I.low.strength > 0.12 && // Strong complex phase onset
|
|
3858
3875
|
t > 0.35 && // Still bass-dominant
|
|
3859
|
-
!
|
|
3876
|
+
!J || I.low.onset && (I.low.isPrimary ?? !0) && t > 0.4 && !J && s && Q > C * 1.02;
|
|
3860
3877
|
if (n && this.lastKickTime > 0) {
|
|
3861
3878
|
const N = B.getState(), u = this.validateKickInterval(
|
|
3862
3879
|
M,
|
|
@@ -3879,7 +3896,7 @@ class RI {
|
|
|
3879
3896
|
const l = n;
|
|
3880
3897
|
if (I.low.onset && !l) {
|
|
3881
3898
|
const N = [];
|
|
3882
|
-
|
|
3899
|
+
J && N.push("tail"), t <= 0.4 && N.push("ratio"), Q <= C * 1.02 && N.push("floor"), s || N.push("noEnergy"), this.lastRejections.push({
|
|
3883
3900
|
type: "K",
|
|
3884
3901
|
reason: N.join(","),
|
|
3885
3902
|
values: {
|
|
@@ -3988,7 +4005,7 @@ class RI {
|
|
|
3988
4005
|
if (i > o) {
|
|
3989
4006
|
const a = (B.low.energy + B.lowMid.energy * 0.5) / i, D = (B.lowMid.energy * 0.5 + B.mid.energy + B.highMid.energy * 0.3) / i, h = (B.highMid.energy * 0.7 + B.high.energy) / i, R = this.profileSimilarity(a, D, h, this.kickProfile), w = this.profileSimilarity(a, D, h, this.snareProfile), t = this.profileSimilarity(a, D, h, this.hatProfile), c = Math.max(0.7, Math.min(1.3, C / Math.max(0.1, this.averageOnsetStrength))), e = 0.35 / c, F = 0.3 / c, y = 0.25 / c;
|
|
3990
4007
|
B.low.onset && R > e && a > 0.25 && (Q = !0, this.lastKickTime = performance.now());
|
|
3991
|
-
const M = performance.now() - this.lastKickTime,
|
|
4008
|
+
const M = performance.now() - this.lastKickTime, J = M < 20, k = !Q && B.mid.onset && !B.low.onset, n = M < 20, l = J && (Q && Math.abs(D - this.kickProfile.midRatio) < 0.15 || // Simultaneous with profile match
|
|
3992
4009
|
k && n || // Very close (<20ms) - always suppress
|
|
3993
4010
|
k && a < 0.3);
|
|
3994
4011
|
(B.mid.onset || B.low.onset && B.mid.onset) && w > F && D > 0.18 && (l || (g = !0)), (B.high.onset || B.highMid.onset) && t > y && h > 0.15 && !Q && !g && (E = !0), Q && g && (B.low.strength > B.mid.strength * 2.5 ? (this.debugMode, g = !1) : B.mid.strength > B.low.strength * 2.5 && (this.debugMode, Q = !1)), Q && E && B.low.strength > B.high.strength * 3 && (this.debugMode, E = !1), !B.low.isPrimary && Q && (this.debugMode, Q = !1), !B.mid.isPrimary && g && (this.debugMode, g = !1), !B.high.isPrimary && !B.highMid.isPrimary && E && (this.debugMode, E = !1);
|
|
@@ -5128,7 +5145,7 @@ P.prototype._transform4 = function() {
|
|
|
5128
5145
|
var a = g >>> 2;
|
|
5129
5146
|
for (E = 0; E < B; E += g)
|
|
5130
5147
|
for (var D = E + a, h = E, R = 0; h < D; h += 2, R += Q) {
|
|
5131
|
-
const w = h, t = w + a, c = t + a, e = c + a, F = A[w], y = A[w + 1], M = A[t],
|
|
5148
|
+
const w = h, t = w + a, c = t + a, e = c + a, F = A[w], y = A[w + 1], M = A[t], J = A[t + 1], k = A[c], n = A[c + 1], l = A[e], Y = A[e + 1], U = F, Z = y, S = s[R], H = o * s[R + 1], W = M * S - J * H, p = M * H + J * S, q = s[2 * R], T = o * s[2 * R + 1], X = k * q - n * T, x = k * T + n * q, _ = s[3 * R], r = o * s[3 * R + 1], $ = l * _ - Y * r, K = l * r + Y * _, z = U + X, f = Z + x, b = U - X, m = Z - x, V = W + $, N = p + K, u = o * (W - $), v = o * (p - K), AA = z + V, RA = f + N, YA = z - V, UA = f - N, SA = b + v, NA = m - u, bA = b - v, HA = m + u;
|
|
5132
5149
|
A[w] = AA, A[w + 1] = RA, A[t] = SA, A[t + 1] = NA, A[c] = YA, A[c + 1] = UA, A[e] = bA, A[e + 1] = HA;
|
|
5133
5150
|
}
|
|
5134
5151
|
}
|
|
@@ -5138,7 +5155,7 @@ P.prototype._singleTransform2 = function(A, B, I) {
|
|
|
5138
5155
|
Q[A] = s, Q[A + 1] = a, Q[A + 2] = D, Q[A + 3] = h;
|
|
5139
5156
|
};
|
|
5140
5157
|
P.prototype._singleTransform4 = function(A, B, I) {
|
|
5141
|
-
const Q = this._out, g = this._data, E = this._inv ? -1 : 1, C = I * 2, i = I * 3, o = g[B], s = g[B + 1], a = g[B + I], D = g[B + I + 1], h = g[B + C], R = g[B + C + 1], w = g[B + i], t = g[B + i + 1], c = o + h, e = s + R, F = o - h, y = s - R, M = a + w,
|
|
5158
|
+
const Q = this._out, g = this._data, E = this._inv ? -1 : 1, C = I * 2, i = I * 3, o = g[B], s = g[B + 1], a = g[B + I], D = g[B + I + 1], h = g[B + C], R = g[B + C + 1], w = g[B + i], t = g[B + i + 1], c = o + h, e = s + R, F = o - h, y = s - R, M = a + w, J = D + t, k = E * (a - w), n = E * (D - t), l = c + M, Y = e + J, U = F + n, Z = y - k, S = c - M, H = e - J, W = F - n, p = y + k;
|
|
5142
5159
|
Q[A] = l, Q[A + 1] = Y, Q[A + 2] = U, Q[A + 3] = Z, Q[A + 4] = S, Q[A + 5] = H, Q[A + 6] = W, Q[A + 7] = p;
|
|
5143
5160
|
};
|
|
5144
5161
|
P.prototype._realTransform4 = function() {
|
|
@@ -5159,7 +5176,7 @@ P.prototype._realTransform4 = function() {
|
|
|
5159
5176
|
var a = g >>> 1, D = a >>> 1, h = D >>> 1;
|
|
5160
5177
|
for (E = 0; E < B; E += g)
|
|
5161
5178
|
for (var R = 0, w = 0; R <= h; R += 2, w += Q) {
|
|
5162
|
-
var t = E + R, c = t + D, e = c + D, F = e + D, y = A[t], M = A[t + 1],
|
|
5179
|
+
var t = E + R, c = t + D, e = c + D, F = e + D, y = A[t], M = A[t + 1], J = A[c], k = A[c + 1], n = A[e], l = A[e + 1], Y = A[F], U = A[F + 1], Z = y, S = M, H = s[w], W = o * s[w + 1], p = J * H - k * W, q = J * W + k * H, T = s[2 * w], X = o * s[2 * w + 1], x = n * T - l * X, _ = n * X + l * T, r = s[3 * w], $ = o * s[3 * w + 1], K = Y * r - U * $, z = Y * $ + U * r, f = Z + x, b = S + _, m = Z - x, V = S - _, N = p + K, u = q + z, v = o * (p - K), AA = o * (q - z), RA = f + N, YA = b + u, UA = m + AA, SA = V - v;
|
|
5163
5180
|
if (A[t] = RA, A[t + 1] = YA, A[c] = UA, A[c + 1] = SA, R === 0) {
|
|
5164
5181
|
var NA = f - N, bA = b - u;
|
|
5165
5182
|
A[e] = NA, A[e + 1] = bA;
|
|
@@ -5177,8 +5194,8 @@ P.prototype._singleRealTransform2 = function(A, B, I) {
|
|
|
5177
5194
|
Q[A] = i, Q[A + 1] = 0, Q[A + 2] = o, Q[A + 3] = 0;
|
|
5178
5195
|
};
|
|
5179
5196
|
P.prototype._singleRealTransform4 = function(A, B, I) {
|
|
5180
|
-
const Q = this._out, g = this._data, E = this._inv ? -1 : 1, C = I * 2, i = I * 3, o = g[B], s = g[B + I], a = g[B + C], D = g[B + i], h = o + a, R = o - a, w = s + D, t = E * (s - D), c = h + w, e = R, F = -t, y = h - w, M = R,
|
|
5181
|
-
Q[A] = c, Q[A + 1] = 0, Q[A + 2] = e, Q[A + 3] = F, Q[A + 4] = y, Q[A + 5] = 0, Q[A + 6] = M, Q[A + 7] =
|
|
5197
|
+
const Q = this._out, g = this._data, E = this._inv ? -1 : 1, C = I * 2, i = I * 3, o = g[B], s = g[B + I], a = g[B + C], D = g[B + i], h = o + a, R = o - a, w = s + D, t = E * (s - D), c = h + w, e = R, F = -t, y = h - w, M = R, J = t;
|
|
5198
|
+
Q[A] = c, Q[A + 1] = 0, Q[A + 2] = e, Q[A + 3] = F, Q[A + 4] = y, Q[A + 5] = 0, Q[A + 6] = M, Q[A + 7] = J;
|
|
5182
5199
|
};
|
|
5183
5200
|
const dI = /* @__PURE__ */ lI(nI);
|
|
5184
5201
|
class iA {
|
|
@@ -5563,8 +5580,8 @@ class yA {
|
|
|
5563
5580
|
for (const [s, a] of Object.entries(C)) {
|
|
5564
5581
|
const D = Math.max(0, Math.floor(a.min / g * E)), h = Math.min(E - 1, Math.floor(a.max / g * E));
|
|
5565
5582
|
let R = 0, w = 0;
|
|
5566
|
-
for (let
|
|
5567
|
-
R += B[
|
|
5583
|
+
for (let J = D; J <= h; J++)
|
|
5584
|
+
R += B[J], w++;
|
|
5568
5585
|
const t = w > 0 ? R / w : 0, c = Q > 0 ? Math.min(1, t / Q) : 0;
|
|
5569
5586
|
o[s] = c;
|
|
5570
5587
|
const F = (A.bandNoiseFloor[s] ?? 1e-4) * 0.995 + t * 5e-3;
|
|
@@ -5654,9 +5671,9 @@ class yA {
|
|
|
5654
5671
|
if (this.debugMode && I - this.lastPhaseLogTime > 2e3) {
|
|
5655
5672
|
const e = this.pll.getState(), F = this.stateManager.getState();
|
|
5656
5673
|
console.log(`
|
|
5657
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`), console.log(`🎯 [TEMPO/PHASE/BAR] t=${(I / 1e3).toFixed(1)}s`), console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"), console.log("📊 BPM Status:"), console.log(` Final: ${D.bpm.toFixed(1)} BPM (source: ${this.lastBpmSource})`), console.log(` PLL: ${e.bpm.toFixed(1)} BPM`), console.log(` Tempo: ${i.bpm.toFixed(1)} BPM (conf=${i.confidence.toFixed(2)}, method=${i.method})`), console.log(` Agree: ${i.methodAgreement.toFixed(2)} | Anchor: ${i.anchorBand || "none"}`), console.log("📍 Phase & Bar:"), console.log(` Phase: ${e.phase.toFixed(3)} (${(e.phase * 100).toFixed(0)}% through beat)`), console.log(` Bar: ${e.bar + 1}/4`), console.log(` Drift: ${e.driftRate.toFixed(3)}`), console.log("🎚️ State:"), console.log(` State: ${F}`), console.log(` Locked: ${D.isLocked}`), console.log(` Conf: ${D.confidence.toFixed(2)}`), this.onsetLogBuffer.length > 0 ? (console.log(`🎵 Recent Onsets (last ${Math.min(10, this.onsetLogBuffer.length)}):`), this.onsetLogBuffer.slice(-10).forEach((M,
|
|
5674
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`), console.log(`🎯 [TEMPO/PHASE/BAR] t=${(I / 1e3).toFixed(1)}s`), console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"), console.log("📊 BPM Status:"), console.log(` Final: ${D.bpm.toFixed(1)} BPM (source: ${this.lastBpmSource})`), console.log(` PLL: ${e.bpm.toFixed(1)} BPM`), console.log(` Tempo: ${i.bpm.toFixed(1)} BPM (conf=${i.confidence.toFixed(2)}, method=${i.method})`), console.log(` Agree: ${i.methodAgreement.toFixed(2)} | Anchor: ${i.anchorBand || "none"}`), console.log("📍 Phase & Bar:"), console.log(` Phase: ${e.phase.toFixed(3)} (${(e.phase * 100).toFixed(0)}% through beat)`), console.log(` Bar: ${e.bar + 1}/4`), console.log(` Drift: ${e.driftRate.toFixed(3)}`), console.log("🎚️ State:"), console.log(` State: ${F}`), console.log(` Locked: ${D.isLocked}`), console.log(` Conf: ${D.confidence.toFixed(2)}`), this.onsetLogBuffer.length > 0 ? (console.log(`🎵 Recent Onsets (last ${Math.min(10, this.onsetLogBuffer.length)}):`), this.onsetLogBuffer.slice(-10).forEach((M, J) => {
|
|
5658
5675
|
const k = ((M.time - I) / 1e3).toFixed(2), n = `φ=${M.phase.toFixed(2)}`, l = `bar=${M.bar + 1}`;
|
|
5659
|
-
console.log(` ${
|
|
5676
|
+
console.log(` ${J + 1}. t=${k}s | ${M.type.padEnd(5)} | ${n} | ${l} | [${M.bands.join(",")}] | str=${M.strength.toFixed(2)}`);
|
|
5660
5677
|
})) : console.log("🎵 Recent Onsets: none detected"), console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
5661
5678
|
`), this.lastPhaseLogTime = I;
|
|
5662
5679
|
}
|
|
@@ -6687,7 +6704,7 @@ class lA {
|
|
|
6687
6704
|
const B = this.additionalStreams.indexOf(A);
|
|
6688
6705
|
if (B !== -1) return B;
|
|
6689
6706
|
if (this.additionalStreams.length >= lA.MAX_ADDITIONAL_VIDEO_STREAMS)
|
|
6690
|
-
throw new
|
|
6707
|
+
throw new d(
|
|
6691
6708
|
`Maximum additional video streams reached (${lA.MAX_ADDITIONAL_VIDEO_STREAMS})`,
|
|
6692
6709
|
"STREAM_LIMIT_REACHED"
|
|
6693
6710
|
);
|
|
@@ -6697,7 +6714,7 @@ class lA {
|
|
|
6697
6714
|
}
|
|
6698
6715
|
removeAdditionalStream(A) {
|
|
6699
6716
|
if (A < 0 || A >= this.additionalStreams.length)
|
|
6700
|
-
throw new
|
|
6717
|
+
throw new d(`Invalid stream index: ${A}`, "INVALID_INDEX");
|
|
6701
6718
|
this.additionalStreams[A].getTracks().forEach((B) => B.stop()), this.additionalStreams.splice(A, 1);
|
|
6702
6719
|
for (const B of this.additionalCaptures) B.destroy();
|
|
6703
6720
|
this.additionalCaptures = [];
|
|
@@ -6717,7 +6734,7 @@ class lA {
|
|
|
6717
6734
|
for (; I.has(Q); )
|
|
6718
6735
|
Q++;
|
|
6719
6736
|
if (Q >= MA)
|
|
6720
|
-
throw new
|
|
6737
|
+
throw new d(
|
|
6721
6738
|
`Maximum device video streams reached (${MA - kA})`,
|
|
6722
6739
|
"STREAM_LIMIT_REACHED"
|
|
6723
6740
|
);
|
|
@@ -8993,7 +9010,7 @@ class sA {
|
|
|
8993
9010
|
/** Take a reference. Called synchronously from the core constructor. */
|
|
8994
9011
|
addRef(A) {
|
|
8995
9012
|
if (this._destroyed)
|
|
8996
|
-
throw new
|
|
9013
|
+
throw new d("Media engine group has been disposed", "INSTANCE_DESTROYED");
|
|
8997
9014
|
return this.members.add(A), this;
|
|
8998
9015
|
}
|
|
8999
9016
|
/**
|
|
@@ -9030,7 +9047,7 @@ class sA {
|
|
|
9030
9047
|
*/
|
|
9031
9048
|
attachSink(A) {
|
|
9032
9049
|
if (this._destroyed)
|
|
9033
|
-
throw new
|
|
9050
|
+
throw new d("Media engine group has been disposed", "INSTANCE_DESTROYED");
|
|
9034
9051
|
this.sinks.set(A.id, A), this.audioSystem?.addSink(A.id, (B) => A.post(B.type, B.data)), this.videoEngine?.addSink(A), this.cvEngine?.addSink(A.id, A.post, A.consumesAnalysedFrame ?? !1);
|
|
9035
9052
|
}
|
|
9036
9053
|
/** Remove an attached core's sink (its delivery and CV desired sets die with it). */
|
|
@@ -9063,7 +9080,7 @@ class sA {
|
|
|
9063
9080
|
*/
|
|
9064
9081
|
ensureAudio() {
|
|
9065
9082
|
if (this._destroyed)
|
|
9066
|
-
throw new
|
|
9083
|
+
throw new d("Media engine group has been disposed", "INSTANCE_DESTROYED");
|
|
9067
9084
|
if (!this.audioSystem) {
|
|
9068
9085
|
this.audioSystem = new yA();
|
|
9069
9086
|
for (const A of this.sinks.values())
|
|
@@ -9076,7 +9093,7 @@ class sA {
|
|
|
9076
9093
|
}
|
|
9077
9094
|
ensureVideo() {
|
|
9078
9095
|
if (this._destroyed)
|
|
9079
|
-
throw new
|
|
9096
|
+
throw new d("Media engine group has been disposed", "INSTANCE_DESTROYED");
|
|
9080
9097
|
if (!this.videoEngine) {
|
|
9081
9098
|
this.videoEngine = new lA({
|
|
9082
9099
|
feed: (A, B) => {
|
|
@@ -9102,7 +9119,7 @@ class sA {
|
|
|
9102
9119
|
// ── CV engine (lazy; inference at host origin) ──────────────────────────
|
|
9103
9120
|
ensureCV() {
|
|
9104
9121
|
if (this._destroyed)
|
|
9105
|
-
throw new
|
|
9122
|
+
throw new d("Media engine group has been disposed", "INSTANCE_DESTROYED");
|
|
9106
9123
|
if (!this.cvEngine) {
|
|
9107
9124
|
this.cvEngine = new mI(), this.cvEngine.setDebugMode(this.debugMode), this.pendingCVFrameRateMode && this.cvEngine.setCVFrameRate(this.pendingCVFrameRateMode);
|
|
9108
9125
|
for (const A of this.sinks.values())
|
|
@@ -9298,7 +9315,7 @@ class sA {
|
|
|
9298
9315
|
const B = this.additionalAudioStreams.indexOf(A);
|
|
9299
9316
|
if (B !== -1) return B;
|
|
9300
9317
|
if (this.additionalAudioStreams.length >= sA.MAX_ADDITIONAL_AUDIO_STREAMS)
|
|
9301
|
-
throw new
|
|
9318
|
+
throw new d(
|
|
9302
9319
|
`Maximum additional audio streams reached (${sA.MAX_ADDITIONAL_AUDIO_STREAMS})`,
|
|
9303
9320
|
"STREAM_LIMIT_REACHED"
|
|
9304
9321
|
);
|
|
@@ -9313,7 +9330,7 @@ class sA {
|
|
|
9313
9330
|
}
|
|
9314
9331
|
async removeAdditionalAudioStream(A) {
|
|
9315
9332
|
if (A < 0 || A >= this.additionalAudioStreams.length)
|
|
9316
|
-
throw new
|
|
9333
|
+
throw new d(`Invalid audio stream index: ${A}`, "INVALID_INDEX");
|
|
9317
9334
|
this.beginConnectivityEdge();
|
|
9318
9335
|
try {
|
|
9319
9336
|
this.additionalAudioStreams[A].getTracks().forEach((B) => B.stop()), this.additionalAudioStreams.splice(A, 1), this.audioSystem && await this.audioSystem.reinitializeAdditionalChannels(
|
|
@@ -9644,7 +9661,7 @@ class XI {
|
|
|
9644
9661
|
const H = new Headers(), W = D.headers.get("content-type");
|
|
9645
9662
|
W && H.set("content-type", W), R && H.set("content-length", R), a = g.put(Q, new Response(S.readable, { status: 200, headers: H }));
|
|
9646
9663
|
}
|
|
9647
|
-
const
|
|
9664
|
+
const J = D.body.getReader();
|
|
9648
9665
|
let k = 0, n = !0, l = F, Y = [], U = 0;
|
|
9649
9666
|
const Z = async (S) => {
|
|
9650
9667
|
const H = l && s !== null, W = H ? S.slice().buffer : S.buffer;
|
|
@@ -9658,7 +9675,7 @@ class XI {
|
|
|
9658
9675
|
return n || l;
|
|
9659
9676
|
};
|
|
9660
9677
|
for (; ; ) {
|
|
9661
|
-
const { done: S, value: H } = await
|
|
9678
|
+
const { done: S, value: H } = await J.read();
|
|
9662
9679
|
if (S) break;
|
|
9663
9680
|
if (k += H.byteLength, Y.push(H), U += H.byteLength, U >= oB) {
|
|
9664
9681
|
const W = zA(Y, U);
|
|
@@ -10057,7 +10074,26 @@ function FB(G) {
|
|
|
10057
10074
|
return String(G);
|
|
10058
10075
|
}
|
|
10059
10076
|
}
|
|
10060
|
-
function gQ() {
|
|
10077
|
+
function gQ(G) {
|
|
10078
|
+
const A = {}, B = typeof ImageBitmap < "u";
|
|
10079
|
+
for (const [I, Q] of Object.entries(G)) {
|
|
10080
|
+
if (B && Q instanceof ImageBitmap && (Q.width === 0 || Q.height === 0)) {
|
|
10081
|
+
console.warn(
|
|
10082
|
+
`[Viji] initialParameters.${I}: ImageBitmap is closed (0x0) and cannot be sent to the scene; dropped.`
|
|
10083
|
+
);
|
|
10084
|
+
continue;
|
|
10085
|
+
}
|
|
10086
|
+
if (typeof Blob < "u" && Q instanceof Blob) {
|
|
10087
|
+
console.warn(
|
|
10088
|
+
`[Viji] initialParameters.${I}: File / Blob values are not seedable; decode to an ImageBitmap first, or use setParameter after onParametersDefined. Dropped.`
|
|
10089
|
+
);
|
|
10090
|
+
continue;
|
|
10091
|
+
}
|
|
10092
|
+
Object.defineProperty(A, I, { value: Q, enumerable: !0, writable: !0, configurable: !0 });
|
|
10093
|
+
}
|
|
10094
|
+
return A;
|
|
10095
|
+
}
|
|
10096
|
+
function EQ() {
|
|
10061
10097
|
const G = () => ({ trueCount: 0, falseCount: 0 });
|
|
10062
10098
|
return {
|
|
10063
10099
|
audio: G(),
|
|
@@ -10078,19 +10114,19 @@ function gQ() {
|
|
|
10078
10114
|
}
|
|
10079
10115
|
};
|
|
10080
10116
|
}
|
|
10081
|
-
function
|
|
10117
|
+
function CQ(G) {
|
|
10082
10118
|
const A = {};
|
|
10083
10119
|
let B = !1;
|
|
10084
10120
|
return G.errorCoalescingWindowMs !== void 0 && (A.errorCoalescingWindowMs = G.errorCoalescingWindowMs, B = !0), G.consoleCoalescingWindowMs !== void 0 && (A.consoleCoalescingWindowMs = G.consoleCoalescingWindowMs, B = !0), G.consoleArgMaxBytes !== void 0 && (A.consoleArgMaxBytes = G.consoleArgMaxBytes, B = !0), G.consoleMaxArgsPerCall !== void 0 && (A.consoleMaxArgsPerCall = G.consoleMaxArgsPerCall, B = !0), G.consoleMaxUniqueSignaturesPerSecond !== void 0 && (A.consoleMaxUniqueSignaturesPerSecond = G.consoleMaxUniqueSignaturesPerSecond, B = !0), B ? A : void 0;
|
|
10085
10121
|
}
|
|
10086
|
-
function
|
|
10122
|
+
function iQ(G) {
|
|
10087
10123
|
return (G.renderer === "native" || G.renderer === "p5" || G.renderer === "shader") && typeof G.consumesAnalysedFrame == "boolean" && typeof G.capabilities == "object" && G.capabilities !== null && typeof G.capabilities.cv == "object" && G.capabilities.cv !== null && (G.p5CanvasMode === void 0 || G.p5CanvasMode === "2d" || G.p5CanvasMode === "webgl");
|
|
10088
10124
|
}
|
|
10089
|
-
function
|
|
10125
|
+
function GQ(G, A) {
|
|
10090
10126
|
return G && A && typeof G == "object" && typeof A == "object" && "x" in G && "x" in A && "y" in G && "y" in A ? G.x === A.x && G.y === A.y : !1;
|
|
10091
10127
|
}
|
|
10092
10128
|
function yB(G, A, B) {
|
|
10093
|
-
return G === "coordinate" ?
|
|
10129
|
+
return G === "coordinate" ? GQ(A, B) : G === "gradient" ? QQ(A, B) : A === B;
|
|
10094
10130
|
}
|
|
10095
10131
|
class VA {
|
|
10096
10132
|
iframeManager = null;
|
|
@@ -10119,6 +10155,13 @@ class VA {
|
|
|
10119
10155
|
}
|
|
10120
10156
|
// Configuration
|
|
10121
10157
|
config;
|
|
10158
|
+
/**
|
|
10159
|
+
* `config.initialParameters` after `sanitizeInitialParameters` (set in
|
|
10160
|
+
* `initialize()`, cleared in `destroy()`). Overlaid onto `parameterValues`
|
|
10161
|
+
* when the worker reports its definitions, so the host table matches what
|
|
10162
|
+
* the worker seeded before frame 1. `null` when no seed was supplied.
|
|
10163
|
+
*/
|
|
10164
|
+
initialSeed = null;
|
|
10122
10165
|
// Headless mode tracking
|
|
10123
10166
|
isHeadless = !1;
|
|
10124
10167
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
@@ -10206,7 +10249,7 @@ class VA {
|
|
|
10206
10249
|
cpuMs: { min: 0, avg: 0, max: 0 },
|
|
10207
10250
|
frameIntervalMs: { min: 0, avg: 0, max: 0 }
|
|
10208
10251
|
},
|
|
10209
|
-
capabilities:
|
|
10252
|
+
capabilities: EQ()
|
|
10210
10253
|
};
|
|
10211
10254
|
// Live perf/capability listeners (Set-based, mirroring sceneRuntimeErrorListeners).
|
|
10212
10255
|
// Reporting is gated on listener presence (attaching is the implicit enable).
|
|
@@ -10241,7 +10284,7 @@ class VA {
|
|
|
10241
10284
|
}
|
|
10242
10285
|
async captureFrame(A = {}) {
|
|
10243
10286
|
if (!this.workerManager?.ready)
|
|
10244
|
-
throw new
|
|
10287
|
+
throw new d("Core not initialized", "NOT_INITIALIZED");
|
|
10245
10288
|
const B = A.format || "blob", I = await this.workerManager.sendMessage("capture-frame", {
|
|
10246
10289
|
format: B,
|
|
10247
10290
|
type: B === "blob" ? A.type : void 0,
|
|
@@ -10361,21 +10404,21 @@ class VA {
|
|
|
10361
10404
|
async initialize() {
|
|
10362
10405
|
try {
|
|
10363
10406
|
if (this.isDestroyed)
|
|
10364
|
-
throw new
|
|
10407
|
+
throw new d("Cannot initialize destroyed instance", "INSTANCE_DESTROYED");
|
|
10365
10408
|
if (this.isInitializing)
|
|
10366
|
-
throw new
|
|
10409
|
+
throw new d("Initialization already in progress", "CONCURRENT_INITIALIZATION");
|
|
10367
10410
|
if (this.engineGroupReleased)
|
|
10368
|
-
throw new
|
|
10411
|
+
throw new d(
|
|
10369
10412
|
"Cannot re-initialize after a failed initialization released the media engine reference",
|
|
10370
10413
|
"INSTANCE_DESTROYED"
|
|
10371
10414
|
);
|
|
10372
10415
|
if (this.isInitialized)
|
|
10373
|
-
throw new
|
|
10416
|
+
throw new d("Core already initialized", "ALREADY_INITIALIZED");
|
|
10374
10417
|
if (this.isInitializing = !0, this.debugLog(`Starting VijiCore initialization... (${this.instanceId})`), this.iframeManager = new zB(
|
|
10375
10418
|
this.config.hostContainer || null,
|
|
10376
10419
|
this.config.resolution,
|
|
10377
10420
|
this.config.visible ?? !0
|
|
10378
|
-
), await this.iframeManager.createSecureIFrame(), this.interactionManager = new fB(), this.setupInteractionSystem(), this.deviceSensorManager && this.setupDeviceSensors(), this.workerManager = new XB(
|
|
10421
|
+
), await this.iframeManager.createSecureIFrame(), this.interactionManager = new fB(), this.setupInteractionSystem(), this.deviceSensorManager && this.setupDeviceSensors(), this.initialSeed = this.config.initialParameters ? gQ(this.config.initialParameters) : null, this.workerManager = new XB(
|
|
10379
10422
|
this.iframeManager,
|
|
10380
10423
|
this.config.sceneCode,
|
|
10381
10424
|
{
|
|
@@ -10386,11 +10429,11 @@ class VA {
|
|
|
10386
10429
|
sc: this.config._sc,
|
|
10387
10430
|
rh: this.config._rh,
|
|
10388
10431
|
sk: this.config._sk,
|
|
10389
|
-
...this.
|
|
10390
|
-
reporterConfig:
|
|
10432
|
+
...this.initialSeed && { initialParameters: this.initialSeed },
|
|
10433
|
+
reporterConfig: CQ(this.config)
|
|
10391
10434
|
}
|
|
10392
10435
|
), this.setupCommunication(), await this.workerManager.createWorker(), this.isDestroyed)
|
|
10393
|
-
throw new
|
|
10436
|
+
throw new d("Initialization cancelled", "INITIALIZATION_CANCELLED");
|
|
10394
10437
|
const A = this.iframeManager.getIframeEnvironment();
|
|
10395
10438
|
(A?.workerSpawn === "blob" || A?.workerSpawn === "data") && (this.sceneWorkerSpawn = A.workerSpawn), this.capabilityReportingEnabled && this.workerManager.postMessage("enable-capability-reporting", { enabled: !0 }), this.renderLoopPaused && this.workerManager.postMessage("set-render-loop-paused", { paused: !0 }), (this.deviceSensorManager || this.engineGroup.getExternalDevices().length > 0) && this.syncDeviceStateToWorker();
|
|
10396
10439
|
const B = this.iframeManager.getEffectiveResolution();
|
|
@@ -10405,10 +10448,10 @@ class VA {
|
|
|
10405
10448
|
I = await this.workerManager.waitForSceneAnalysis();
|
|
10406
10449
|
} catch (Q) {
|
|
10407
10450
|
if (this.isDestroyed)
|
|
10408
|
-
throw new
|
|
10409
|
-
if (Q instanceof
|
|
10451
|
+
throw new d("Initialization cancelled", "INITIALIZATION_CANCELLED");
|
|
10452
|
+
if (Q instanceof d && Q.code === "MESSAGE_TIMEOUT" && this.analysisWindowSceneError) {
|
|
10410
10453
|
const g = this.analysisWindowSceneError;
|
|
10411
|
-
throw new
|
|
10454
|
+
throw new d(
|
|
10412
10455
|
`Scene failed before the analysis ack: ${g.message}`,
|
|
10413
10456
|
"SCENE_ANALYSIS_ERROR",
|
|
10414
10457
|
{ sceneError: g }
|
|
@@ -10419,9 +10462,9 @@ class VA {
|
|
|
10419
10462
|
this.isAwaitingSceneAnalysis = !1, this.analysisWindowSceneError = null;
|
|
10420
10463
|
}
|
|
10421
10464
|
if (this.isDestroyed)
|
|
10422
|
-
throw new
|
|
10423
|
-
if (!
|
|
10424
|
-
throw new
|
|
10465
|
+
throw new d("Initialization cancelled", "INITIALIZATION_CANCELLED");
|
|
10466
|
+
if (!iQ(I))
|
|
10467
|
+
throw new d("Malformed scene-analysis ack", "SCENE_ANALYSIS_ERROR");
|
|
10425
10468
|
this.sceneRenderer = I.renderer, this.sceneCapabilities = I.capabilities, I.p5CanvasMode !== void 0 && (this.sceneP5CanvasMode = I.p5CanvasMode), this.sceneConsumesAnalysedFrame = I.consumesAnalysedFrame;
|
|
10426
10469
|
try {
|
|
10427
10470
|
this.config.onRenderStart?.();
|
|
@@ -10437,7 +10480,7 @@ class VA {
|
|
|
10437
10480
|
}), this.notifyCapabilitiesChange(), this.workerManager.onMessage("auto-capture-result", (Q) => {
|
|
10438
10481
|
this.updateFrameBuffer(Q.bitmap, Q.timestamp);
|
|
10439
10482
|
}), this.config.audioStream && await this.setAudioStream(this.config.audioStream), this.isDestroyed)
|
|
10440
|
-
throw new
|
|
10483
|
+
throw new d("Initialization cancelled", "INITIALIZATION_CANCELLED");
|
|
10441
10484
|
for (const Q of this.config.audioStreams ?? [])
|
|
10442
10485
|
await this.engineGroup.addAdditionalAudioStream(Q);
|
|
10443
10486
|
this.stats.resolution = B, this.stats.scale = this.iframeManager.getScale(), this.updateFrameRateStats(), this.isInitialized = !0, this.isInitializing = !1, this.debugLog(`VijiCore initialized successfully (${this.instanceId}):`, {
|
|
@@ -10447,7 +10490,7 @@ class VA {
|
|
|
10447
10490
|
hasVideo: !!this.config.videoStream
|
|
10448
10491
|
});
|
|
10449
10492
|
} catch (A) {
|
|
10450
|
-
throw this.isInitializing = !1, await this.cleanup(), await this.releaseEngineGroupOnFailure(), A instanceof
|
|
10493
|
+
throw this.isInitializing = !1, await this.cleanup(), await this.releaseEngineGroupOnFailure(), A instanceof d && (A.code === "INITIALIZATION_CANCELLED" || A.code === "INSTANCE_DESTROYED" || A.code === "SCENE_DECRYPT_ERROR") ? A : new d(
|
|
10451
10494
|
`Failed to initialize VijiCore: ${A}`,
|
|
10452
10495
|
"INITIALIZATION_ERROR",
|
|
10453
10496
|
{ error: A }
|
|
@@ -10563,7 +10606,24 @@ class VA {
|
|
|
10563
10606
|
this.parameterValues.set(I, Q.defaultValue);
|
|
10564
10607
|
}
|
|
10565
10608
|
}
|
|
10566
|
-
|
|
10609
|
+
if (this.initialSeed)
|
|
10610
|
+
for (const B of this.parameterValues.keys()) {
|
|
10611
|
+
if (!Object.hasOwn(this.initialSeed, B)) continue;
|
|
10612
|
+
const I = this.initialSeed[B], Q = this.getParameterDefinition(B);
|
|
10613
|
+
if (Q?.type === "image") {
|
|
10614
|
+
(I === null || typeof ImageBitmap < "u" && I instanceof ImageBitmap) && this.parameterValues.set(B, I);
|
|
10615
|
+
continue;
|
|
10616
|
+
}
|
|
10617
|
+
if (Q?.type === "color" || Q?.type === "gradient") {
|
|
10618
|
+
try {
|
|
10619
|
+
this.parameterValues.set(B, this.normalizeParameterInput(B, I));
|
|
10620
|
+
} catch {
|
|
10621
|
+
}
|
|
10622
|
+
continue;
|
|
10623
|
+
}
|
|
10624
|
+
this.parameterValues.set(B, I);
|
|
10625
|
+
}
|
|
10626
|
+
this.parametersInitialized = !0, this.debugLog(`Parameters initialized: ${this.parameterValues.size} parameters in ${this.parameterGroups.size} groups`);
|
|
10567
10627
|
for (const B of this.parameterDefinedListeners)
|
|
10568
10628
|
try {
|
|
10569
10629
|
B(Array.from(this.parameterGroups.values()));
|
|
@@ -10594,7 +10654,7 @@ class VA {
|
|
|
10594
10654
|
*/
|
|
10595
10655
|
getParameterDefinition(A) {
|
|
10596
10656
|
for (const B of this.parameterGroups.values())
|
|
10597
|
-
if (B.parameters
|
|
10657
|
+
if (Object.hasOwn(B.parameters, A))
|
|
10598
10658
|
return B.parameters[A];
|
|
10599
10659
|
}
|
|
10600
10660
|
/**
|
|
@@ -10613,7 +10673,7 @@ class VA {
|
|
|
10613
10673
|
try {
|
|
10614
10674
|
return lB(B, { alpha: I.config?.alpha === !0 });
|
|
10615
10675
|
} catch (Q) {
|
|
10616
|
-
throw new
|
|
10676
|
+
throw new d(
|
|
10617
10677
|
`Invalid color value for parameter '${A}': ${Q.message}`,
|
|
10618
10678
|
"INVALID_COLOR_VALUE",
|
|
10619
10679
|
{ name: A, value: B }
|
|
@@ -10623,7 +10683,7 @@ class VA {
|
|
|
10623
10683
|
try {
|
|
10624
10684
|
return IQ(B, BQ(I.config ?? {}));
|
|
10625
10685
|
} catch (Q) {
|
|
10626
|
-
throw new
|
|
10686
|
+
throw new d(
|
|
10627
10687
|
`Invalid gradient value for parameter '${A}': ${Q.message}`,
|
|
10628
10688
|
"INVALID_GRADIENT_VALUE",
|
|
10629
10689
|
{ name: A, value: B }
|
|
@@ -10637,9 +10697,9 @@ class VA {
|
|
|
10637
10697
|
*/
|
|
10638
10698
|
async setParameter(A, B) {
|
|
10639
10699
|
if (this.validateReady(), !this.parametersInitialized)
|
|
10640
|
-
throw new
|
|
10700
|
+
throw new d("Parameters not yet initialized", "PARAMETERS_NOT_INITIALIZED");
|
|
10641
10701
|
if (!this.parameterValues.has(A))
|
|
10642
|
-
throw new
|
|
10702
|
+
throw new d(`Unknown parameter: ${A}`, "UNKNOWN_PARAMETER");
|
|
10643
10703
|
const I = this.getParameterDefinition(A);
|
|
10644
10704
|
if (I?.type === "image") {
|
|
10645
10705
|
await this.handleImageParameter(A, B);
|
|
@@ -10688,7 +10748,7 @@ class VA {
|
|
|
10688
10748
|
}
|
|
10689
10749
|
g !== I && this.notifyParameterListeners(A, I), this.debugLog(`Image parameter '${A}' ${I ? "loaded" : "cleared"} (${this.instanceId})`);
|
|
10690
10750
|
} catch (I) {
|
|
10691
|
-
throw new
|
|
10751
|
+
throw new d(
|
|
10692
10752
|
`Failed to load image for parameter '${A}': ${I}`,
|
|
10693
10753
|
"IMAGE_LOAD_ERROR",
|
|
10694
10754
|
{ error: I, name: A }
|
|
@@ -10703,7 +10763,7 @@ class VA {
|
|
|
10703
10763
|
*/
|
|
10704
10764
|
async setParameters(A) {
|
|
10705
10765
|
if (this.validateReady(), !this.parametersInitialized)
|
|
10706
|
-
throw new
|
|
10766
|
+
throw new d("Parameters not yet initialized", "PARAMETERS_NOT_INITIALIZED");
|
|
10707
10767
|
const B = [], I = [];
|
|
10708
10768
|
for (const [Q, g] of Object.entries(A)) {
|
|
10709
10769
|
if (!this.parameterValues.has(Q)) {
|
|
@@ -10865,7 +10925,7 @@ class VA {
|
|
|
10865
10925
|
*/
|
|
10866
10926
|
injectFrame(A, B) {
|
|
10867
10927
|
if (!this.workerManager?.ready)
|
|
10868
|
-
throw new
|
|
10928
|
+
throw new d("Core not ready", "NOT_READY");
|
|
10869
10929
|
this.ensureDirectFrameSlots(B + 1), this.workerManager.postMessage("video-frame-direct", {
|
|
10870
10930
|
imageBitmap: A,
|
|
10871
10931
|
streamIndex: VA.DIRECT_FRAME_BASE + B,
|
|
@@ -10911,7 +10971,7 @@ class VA {
|
|
|
10911
10971
|
*/
|
|
10912
10972
|
linkFrameSources(...A) {
|
|
10913
10973
|
if (!this.isInitialized)
|
|
10914
|
-
throw new
|
|
10974
|
+
throw new d(
|
|
10915
10975
|
"linkFrameSources requires an initialized core (the mixer renderer type is final only after initialize() resolves)",
|
|
10916
10976
|
"NOT_INITIALIZED"
|
|
10917
10977
|
);
|
|
@@ -11023,22 +11083,6 @@ class VA {
|
|
|
11023
11083
|
get parametersReady() {
|
|
11024
11084
|
return this.parametersInitialized;
|
|
11025
11085
|
}
|
|
11026
|
-
/**
|
|
11027
|
-
* Send all current parameter values to worker (used for initial sync)
|
|
11028
|
-
*/
|
|
11029
|
-
syncAllParametersToWorker() {
|
|
11030
|
-
if (!this.workerManager || this.parameterValues.size === 0)
|
|
11031
|
-
return;
|
|
11032
|
-
const A = [];
|
|
11033
|
-
for (const [B, I] of this.parameterValues)
|
|
11034
|
-
A.push({
|
|
11035
|
-
name: B,
|
|
11036
|
-
value: I
|
|
11037
|
-
});
|
|
11038
|
-
this.workerManager.postMessage("parameter-batch-update", {
|
|
11039
|
-
updates: A
|
|
11040
|
-
}), this.debugLog(`Synced ${A.length} parameter values to worker`);
|
|
11041
|
-
}
|
|
11042
11086
|
/**
|
|
11043
11087
|
* Add listener for when the scene's parameters are defined. Fires exactly once
|
|
11044
11088
|
* per scene load, after the scene registers its parameters — including scenes
|
|
@@ -11150,7 +11194,7 @@ class VA {
|
|
|
11150
11194
|
*/
|
|
11151
11195
|
importFullState(A, B) {
|
|
11152
11196
|
this.validateReady();
|
|
11153
|
-
const I =
|
|
11197
|
+
const I = aQ(A);
|
|
11154
11198
|
if (I) {
|
|
11155
11199
|
this.fireStateImportError(I);
|
|
11156
11200
|
return;
|
|
@@ -11331,7 +11375,7 @@ class VA {
|
|
|
11331
11375
|
*/
|
|
11332
11376
|
updateResolution() {
|
|
11333
11377
|
if (this.validateReady(), !this.iframeManager || !this.workerManager)
|
|
11334
|
-
throw new
|
|
11378
|
+
throw new d("Managers not available", "MANAGERS_NOT_READY");
|
|
11335
11379
|
const A = this.iframeManager.getEffectiveResolution();
|
|
11336
11380
|
this.workerManager.postMessage("resolution-update", {
|
|
11337
11381
|
effectiveWidth: A.width,
|
|
@@ -11818,7 +11862,7 @@ class VA {
|
|
|
11818
11862
|
*/
|
|
11819
11863
|
setResolution(A) {
|
|
11820
11864
|
if (this.validateReady(), !this.iframeManager || !this.workerManager)
|
|
11821
|
-
throw new
|
|
11865
|
+
throw new d("Managers not available", "MANAGERS_NOT_READY");
|
|
11822
11866
|
let B;
|
|
11823
11867
|
typeof A == "number" ? (B = this.iframeManager.updateScale(A), this.stats.scale = A) : B = this.iframeManager.updateExplicitResolution(A), this.workerManager.postMessage("resolution-update", {
|
|
11824
11868
|
effectiveWidth: B.width,
|
|
@@ -11868,7 +11912,7 @@ class VA {
|
|
|
11868
11912
|
*/
|
|
11869
11913
|
getStats() {
|
|
11870
11914
|
if (this.validateReady(), !this.iframeManager)
|
|
11871
|
-
throw new
|
|
11915
|
+
throw new d("IFrame manager not available", "MANAGER_NOT_READY");
|
|
11872
11916
|
return this.sceneWorkerSpawn !== void 0 && (this.stats.workerSpawn = this.sceneWorkerSpawn), this.mergeCVStats(), this.stats;
|
|
11873
11917
|
}
|
|
11874
11918
|
/**
|
|
@@ -11941,16 +11985,16 @@ class VA {
|
|
|
11941
11985
|
*/
|
|
11942
11986
|
async runFencedBenchmark(A) {
|
|
11943
11987
|
if (this.validateReady(), !this.workerManager?.ready)
|
|
11944
|
-
throw new
|
|
11988
|
+
throw new d("Core not initialized", "NOT_INITIALIZED");
|
|
11945
11989
|
if (!Number.isFinite(A) || A < 1)
|
|
11946
|
-
throw new
|
|
11990
|
+
throw new d("frameCount must be a positive integer", "INVALID_ARGUMENT");
|
|
11947
11991
|
if (this.autoCaptureEnabled || this.frameSourceCores.length > 0)
|
|
11948
|
-
throw new
|
|
11992
|
+
throw new d(
|
|
11949
11993
|
"runFencedBenchmark cannot run on a live compositor source or mixer",
|
|
11950
11994
|
"BENCHMARK_NOT_ALLOWED"
|
|
11951
11995
|
);
|
|
11952
11996
|
if (this.engineGroup.memberCount > 1)
|
|
11953
|
-
throw new
|
|
11997
|
+
throw new d(
|
|
11954
11998
|
"runFencedBenchmark cannot run on a core sharing media engines with other live cores",
|
|
11955
11999
|
"BENCHMARK_NOT_ALLOWED"
|
|
11956
12000
|
);
|
|
@@ -11972,7 +12016,7 @@ class VA {
|
|
|
11972
12016
|
*/
|
|
11973
12017
|
addExternalDevice(A) {
|
|
11974
12018
|
if (!this.deviceSensorManager)
|
|
11975
|
-
throw new
|
|
12019
|
+
throw new d(
|
|
11976
12020
|
"Device interaction not enabled. Set allowDeviceInteraction: true in config",
|
|
11977
12021
|
"DEVICE_INTERACTION_DISABLED"
|
|
11978
12022
|
);
|
|
@@ -12088,48 +12132,48 @@ class VA {
|
|
|
12088
12132
|
* Destroys the core instance and cleans up all resources
|
|
12089
12133
|
*/
|
|
12090
12134
|
async destroy() {
|
|
12091
|
-
this.isDestroyed || (this.isDestroyed = !0, this.refreshRateRafId !== null && (cancelAnimationFrame(this.refreshRateRafId), this.refreshRateRafId = null), this.parameterGroups.clear(), this.parameterValues.clear(), this.parameterListeners.clear(), this.parameterDefinedListeners.clear(), this.parameterErrorListeners.clear(), this.capabilitiesChangeListeners.clear(), this.stateImportErrorListeners.clear(), this.sceneRuntimeErrorListeners.clear(), this.sceneConsoleListeners.clear(), this.performanceSnapshotListeners.clear(), this.capabilityTransitionListeners.clear(), this.deviceCVRequestListeners.clear(), this.unlinkEventSource(), this.unlinkFrameSources(), this.deviceSensorManager && (this.deviceSensorManager.destroy(), this.deviceSensorManager = null), tA().abortDeliveries(this.instanceId), this.engineGroupReleased || (this.engineGroupReleased = !0, this.engineGroup.detachSink(this.instanceId), await this.engineGroup.release(this.groupMember)), this.latestFrameBuffer && (this.latestFrameBuffer.close(), this.latestFrameBuffer = null), this.directFrameSlots = 0, await this.cleanup(), this.debugLog(`VijiCore destroyed (${this.instanceId})`));
|
|
12135
|
+
this.isDestroyed || (this.isDestroyed = !0, this.refreshRateRafId !== null && (cancelAnimationFrame(this.refreshRateRafId), this.refreshRateRafId = null), this.parameterGroups.clear(), this.parameterValues.clear(), this.initialSeed = null, this.parameterListeners.clear(), this.parameterDefinedListeners.clear(), this.parameterErrorListeners.clear(), this.capabilitiesChangeListeners.clear(), this.stateImportErrorListeners.clear(), this.sceneRuntimeErrorListeners.clear(), this.sceneConsoleListeners.clear(), this.performanceSnapshotListeners.clear(), this.capabilityTransitionListeners.clear(), this.deviceCVRequestListeners.clear(), this.unlinkEventSource(), this.unlinkFrameSources(), this.deviceSensorManager && (this.deviceSensorManager.destroy(), this.deviceSensorManager = null), tA().abortDeliveries(this.instanceId), this.engineGroupReleased || (this.engineGroupReleased = !0, this.engineGroup.detachSink(this.instanceId), await this.engineGroup.release(this.groupMember)), this.latestFrameBuffer && (this.latestFrameBuffer.close(), this.latestFrameBuffer = null), this.directFrameSlots = 0, await this.cleanup(), this.debugLog(`VijiCore destroyed (${this.instanceId})`));
|
|
12092
12136
|
}
|
|
12093
12137
|
/**
|
|
12094
12138
|
* Validates that the core is ready for operations
|
|
12095
12139
|
*/
|
|
12096
12140
|
validateReady() {
|
|
12097
12141
|
if (this.isDestroyed)
|
|
12098
|
-
throw new
|
|
12142
|
+
throw new d("Core instance has been destroyed", "INSTANCE_DESTROYED");
|
|
12099
12143
|
if (!this.ready)
|
|
12100
|
-
throw new
|
|
12144
|
+
throw new d("Core is not ready", "CORE_NOT_READY");
|
|
12101
12145
|
}
|
|
12102
12146
|
/**
|
|
12103
12147
|
* Validates the provided configuration
|
|
12104
12148
|
*/
|
|
12105
12149
|
validateConfig(A) {
|
|
12106
12150
|
if (!A.hostContainer && !A.resolution)
|
|
12107
|
-
throw new
|
|
12151
|
+
throw new d(
|
|
12108
12152
|
"Headless mode (no hostContainer) requires explicit resolution",
|
|
12109
12153
|
"INVALID_CONFIG"
|
|
12110
12154
|
);
|
|
12111
12155
|
if (!A.hostContainer && typeof A.resolution == "number")
|
|
12112
|
-
throw new
|
|
12156
|
+
throw new d(
|
|
12113
12157
|
"Headless mode requires resolution object {width, height}, not scale",
|
|
12114
12158
|
"INVALID_CONFIG"
|
|
12115
12159
|
);
|
|
12116
12160
|
if (!A.sceneCode || typeof A.sceneCode != "string")
|
|
12117
|
-
throw new
|
|
12161
|
+
throw new d("sceneCode must be a non-empty string", "INVALID_CONFIG");
|
|
12118
12162
|
if (A.frameRateMode !== void 0 && !["full", "half", "quarter", "eighth"].includes(A.frameRateMode))
|
|
12119
|
-
throw new
|
|
12163
|
+
throw new d('frameRateMode must be one of "full", "half", "quarter", or "eighth"', "INVALID_CONFIG");
|
|
12120
12164
|
if (A.mediaSource) {
|
|
12121
12165
|
if (A.audioStream !== void 0 || A.videoStream !== void 0 || A.audioStreams !== void 0 || A.videoStreams !== void 0)
|
|
12122
|
-
throw new
|
|
12166
|
+
throw new d(
|
|
12123
12167
|
"mediaSource is mutually exclusive with audioStream/videoStream/audioStreams/videoStreams",
|
|
12124
12168
|
"INVALID_CONFIG"
|
|
12125
12169
|
);
|
|
12126
12170
|
if (A.mediaSource.isDestroyed)
|
|
12127
|
-
throw new
|
|
12171
|
+
throw new d(
|
|
12128
12172
|
"mediaSource references a destroyed core",
|
|
12129
12173
|
"INVALID_CONFIG"
|
|
12130
12174
|
);
|
|
12131
12175
|
if (A.mediaSource.engineGroup.fencedBenchmarkOwnerId !== null)
|
|
12132
|
-
throw new
|
|
12176
|
+
throw new d(
|
|
12133
12177
|
"mediaSource references a core with a fenced benchmark in flight",
|
|
12134
12178
|
"BENCHMARK_NOT_ALLOWED"
|
|
12135
12179
|
);
|
|
@@ -12146,7 +12190,7 @@ class VA {
|
|
|
12146
12190
|
}
|
|
12147
12191
|
}
|
|
12148
12192
|
}
|
|
12149
|
-
function
|
|
12193
|
+
function aQ(G) {
|
|
12150
12194
|
if (G === null || typeof G != "object")
|
|
12151
12195
|
return { code: "malformed", details: "payload is not an object" };
|
|
12152
12196
|
const A = G;
|
|
@@ -12157,12 +12201,12 @@ function GQ(G) {
|
|
|
12157
12201
|
expectedVersion: 1
|
|
12158
12202
|
} : typeof A.senderTime != "number" ? { code: "invalid-field", details: "senderTime must be a number", field: "senderTime" } : null;
|
|
12159
12203
|
}
|
|
12160
|
-
const
|
|
12204
|
+
const sQ = "0.18.0";
|
|
12161
12205
|
export {
|
|
12162
|
-
|
|
12163
|
-
|
|
12164
|
-
|
|
12206
|
+
hQ as C,
|
|
12207
|
+
DQ as I,
|
|
12208
|
+
sQ as V,
|
|
12165
12209
|
VA as a,
|
|
12166
|
-
|
|
12210
|
+
d as b,
|
|
12167
12211
|
lI as g
|
|
12168
12212
|
};
|