@viji-dev/core 0.18.0 → 0.20.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 +1 -1
- package/dist/artist-global.d.ts +1 -1
- package/dist/assets/{viji.worker-CwvLwn6O.js → viji.worker-CV0DI4PF.js} +37 -37
- package/dist/docs-api.js +72 -72
- package/dist/{essentia-wasm.web-DclksH__.js → essentia-wasm.web-B9-7D9aP.js} +1 -1
- package/dist/{index-BFSuPQzu.js → index-Dw5Jy7so.js} +5 -5
- package/dist/index.d.ts +68 -3
- package/dist/index.js +1 -1
- package/dist/{scene-analysis-2Ov0HS52.js → scene-analysis-Bsf4JrzY.js} +83 -22
- package/dist/scene-analysis.d.ts +67 -2
- package/dist/scene-analysis.js +1 -1
- package/package.json +117 -117
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as mB } from "./scene-analysis-
|
|
1
|
+
import { S as mB } from "./scene-analysis-Bsf4JrzY.js";
|
|
2
2
|
const DQ = [
|
|
3
3
|
"audio",
|
|
4
4
|
"video",
|
|
@@ -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-CV0DI4PF.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;
|
|
@@ -1653,7 +1653,7 @@ class TB {
|
|
|
1653
1653
|
if (!this.isInitialized)
|
|
1654
1654
|
return this.initPromise ? this.initPromise : (this.initPromise = (async () => {
|
|
1655
1655
|
try {
|
|
1656
|
-
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-B9-7D9aP.js").then((g) => g.e), I = A.Essentia || A.default?.Essentia || A.default;
|
|
1657
1657
|
let Q = B.default || B.EssentiaWASM || B.default?.EssentiaWASM;
|
|
1658
1658
|
if (!Q)
|
|
1659
1659
|
throw new Error("WASM module not found - check essentia-wasm.web.js export");
|
|
@@ -10120,7 +10120,7 @@ function CQ(G) {
|
|
|
10120
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;
|
|
10121
10121
|
}
|
|
10122
10122
|
function iQ(G) {
|
|
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");
|
|
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 && typeof G.capabilities.sources == "object" && G.capabilities.sources !== null && (G.p5CanvasMode === void 0 || G.p5CanvasMode === "2d" || G.p5CanvasMode === "webgl");
|
|
10124
10124
|
}
|
|
10125
10125
|
function GQ(G, A) {
|
|
10126
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;
|
|
@@ -12201,7 +12201,7 @@ function aQ(G) {
|
|
|
12201
12201
|
expectedVersion: 1
|
|
12202
12202
|
} : typeof A.senderTime != "number" ? { code: "invalid-field", details: "senderTime must be a number", field: "senderTime" } : null;
|
|
12203
12203
|
}
|
|
12204
|
-
const sQ = "0.
|
|
12204
|
+
const sQ = "0.20.0";
|
|
12205
12205
|
export {
|
|
12206
12206
|
hQ as C,
|
|
12207
12207
|
DQ as I,
|
package/dist/index.d.ts
CHANGED
|
@@ -1144,7 +1144,10 @@ declare interface ImageParameter {
|
|
|
1144
1144
|
*
|
|
1145
1145
|
* Note: `parameters` is intentionally absent. It is a *declared-only* tag on
|
|
1146
1146
|
* {@link SceneCapabilities} (the scene defines tunable parameters), not a live
|
|
1147
|
-
* consumed signal, so it is not part of the per-frame capability set.
|
|
1147
|
+
* consumed signal, so it is not part of the per-frame capability set. The
|
|
1148
|
+
* nested `cv` and `sources` members of {@link SceneCapabilities} are likewise
|
|
1149
|
+
* outside this vocabulary (`cv` has its own, {@link CV_FEATURE_KEYS}; `sources`
|
|
1150
|
+
* is declared-only).
|
|
1148
1151
|
*/
|
|
1149
1152
|
export declare const INPUT_CAPABILITY_KEYS: readonly ["audio", "video", "mouse", "keyboard", "pointer", "touch", "sensors", "devices"];
|
|
1150
1153
|
|
|
@@ -1629,7 +1632,8 @@ export declare interface SceneAnalysisData {
|
|
|
1629
1632
|
*
|
|
1630
1633
|
* The input keys here are pinned to {@link INPUT_CAPABILITY_KEYS} and the `cv`
|
|
1631
1634
|
* keys to {@link CV_FEATURE_KEYS} by a compile-time guard (below), so this shape
|
|
1632
|
-
* cannot drift from the runtime vocabulary.
|
|
1635
|
+
* cannot drift from the runtime vocabulary. `parameters`, `cv`, and `sources`
|
|
1636
|
+
* are the declared-only members outside the per-frame input vocabulary.
|
|
1633
1637
|
*/
|
|
1634
1638
|
export declare interface SceneCapabilities {
|
|
1635
1639
|
/** Scene reads audio analysis (volume, bands, beat, FFT/waveform, or audio streams). */
|
|
@@ -1665,6 +1669,67 @@ export declare interface SceneCapabilities {
|
|
|
1665
1669
|
/** Scene uses body segmentation. */
|
|
1666
1670
|
segmentation: boolean;
|
|
1667
1671
|
};
|
|
1672
|
+
/**
|
|
1673
|
+
* Which input **source** each capability reads, for host routing UIs (e.g. a
|
|
1674
|
+
* controller deciding whether a phone camera belongs in the main slot or a
|
|
1675
|
+
* device slot). Declared-only (static analysis, like the flags above) and
|
|
1676
|
+
* inclusive-biased; not part of the per-frame {@link INPUT_CAPABILITY_KEYS}
|
|
1677
|
+
* vocabulary (same standing as `parameters` and `cv`).
|
|
1678
|
+
*
|
|
1679
|
+
* - `main`: the host's primary stream, index 0 (`viji.video` / `viji.audio`,
|
|
1680
|
+
* `u_video*` / `u_audio*`).
|
|
1681
|
+
* - `streams`: host-side additional compositor inputs, indices 1-99
|
|
1682
|
+
* (`viji.videoStreams` / `viji.audioStreams`, `u_videoStream*` /
|
|
1683
|
+
* `u_audioStream*`). Not routable from a controller; they set neither
|
|
1684
|
+
* `main` nor `device`.
|
|
1685
|
+
* - `device`: an external device slot, indices 100+ (`viji.devices[i].video`
|
|
1686
|
+
* / `.audio` / `.motion` / `.orientation`, `u_device{i}*`, `u_deviceCount`,
|
|
1687
|
+
* `u_externalDeviceCount`).
|
|
1688
|
+
*
|
|
1689
|
+
* Native/p5 scenes reach device members through a `.video` / `.audio` /
|
|
1690
|
+
* `.motion` / `.orientation` token after `viji.devices`. When a scene
|
|
1691
|
+
* references `viji.devices` but no such token is visible (destructuring,
|
|
1692
|
+
* `viji.devices.length`), all three `device` booleans report `true`: the
|
|
1693
|
+
* analyzer never hides a source a scene may use.
|
|
1694
|
+
*/
|
|
1695
|
+
sources: {
|
|
1696
|
+
/** Video image source. */
|
|
1697
|
+
video: {
|
|
1698
|
+
/**
|
|
1699
|
+
* Main camera. Shader scenes also report `true` when any `cv.*` flag is
|
|
1700
|
+
* set (CV runs on the main stream only; no device-CV uniforms exist).
|
|
1701
|
+
* Native/p5 CV `enable*` calls do NOT imply this: device cameras expose
|
|
1702
|
+
* the same CV surface (`viji.devices[i].video.cv`).
|
|
1703
|
+
*/
|
|
1704
|
+
main: boolean;
|
|
1705
|
+
/** Additional compositor video streams (`viji.videoStreams`, `u_videoStream*`). */
|
|
1706
|
+
streams: boolean;
|
|
1707
|
+
/** External device cameras (`viji.devices[i].video`, `u_device{i}`, `u_deviceCount`). */
|
|
1708
|
+
device: boolean;
|
|
1709
|
+
};
|
|
1710
|
+
/** Audio analysis source. */
|
|
1711
|
+
audio: {
|
|
1712
|
+
/** Main microphone / audio input (`viji.audio`, `u_audio*`). */
|
|
1713
|
+
main: boolean;
|
|
1714
|
+
/** Additional compositor audio streams (`viji.audioStreams`, `u_audioStream*`). */
|
|
1715
|
+
streams: boolean;
|
|
1716
|
+
/**
|
|
1717
|
+
* External device audio (`viji.devices[i].audio`). Always `false` for
|
|
1718
|
+
* shader scenes: no device-audio uniform family exists.
|
|
1719
|
+
*/
|
|
1720
|
+
device: boolean;
|
|
1721
|
+
};
|
|
1722
|
+
/** Motion / orientation sensor source. */
|
|
1723
|
+
sensors: {
|
|
1724
|
+
/** The host machine's own sensors (`viji.device`, `u_deviceAcceleration` and family). */
|
|
1725
|
+
internal: boolean;
|
|
1726
|
+
/**
|
|
1727
|
+
* External device sensors (`viji.devices[i].motion` / `.orientation`,
|
|
1728
|
+
* `u_device{i}Acceleration` and family, `u_externalDeviceCount`).
|
|
1729
|
+
*/
|
|
1730
|
+
device: boolean;
|
|
1731
|
+
};
|
|
1732
|
+
};
|
|
1668
1733
|
}
|
|
1669
1734
|
|
|
1670
1735
|
/**
|
|
@@ -2458,7 +2523,7 @@ declare interface TouchPoint {
|
|
|
2458
2523
|
/** Returned by `on*` listener registration calls; invoke to unsubscribe. */
|
|
2459
2524
|
export declare type Unsubscribe = () => void;
|
|
2460
2525
|
|
|
2461
|
-
export declare const VERSION = "0.
|
|
2526
|
+
export declare const VERSION = "0.20.0";
|
|
2462
2527
|
|
|
2463
2528
|
/**
|
|
2464
2529
|
* Real-time video API: drawable frame, dimensions, and the source-side
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class u {
|
|
2
2
|
/**
|
|
3
3
|
* Detects the renderer type from scene code comments
|
|
4
4
|
*
|
|
@@ -39,6 +39,15 @@ class a {
|
|
|
39
39
|
* - Shader scenes: matched against built-in `u_*` uniform usage (exact).
|
|
40
40
|
* - Native / p5 scenes: matched against `viji.*` usage tokens.
|
|
41
41
|
*
|
|
42
|
+
* The top-level flags are the per-frame cohort vocabulary
|
|
43
|
+
* (`INPUT_CAPABILITY_KEYS`) and are persisted downstream; their rules do
|
|
44
|
+
* not change. `sources` (0.20.0) is a declared-only refinement on top:
|
|
45
|
+
* per input kind, whether the scene reads the main stream, the additional
|
|
46
|
+
* compositor streams, or an external device slot. Same inclusive bias; a
|
|
47
|
+
* native/p5 scene that references `viji.devices` without a visible member
|
|
48
|
+
* token reports every `device` source as used. Shader scenes never report
|
|
49
|
+
* `audio.device` (no device-audio uniform family exists).
|
|
50
|
+
*
|
|
42
51
|
* @param sceneCode - The artist's scene code to analyze
|
|
43
52
|
* @param renderer - The renderer type (from {@link detectRendererType})
|
|
44
53
|
* @returns The set of capabilities the scene declares it uses
|
|
@@ -61,9 +70,14 @@ class a {
|
|
|
61
70
|
handTracking: !1,
|
|
62
71
|
poseDetection: !1,
|
|
63
72
|
segmentation: !1
|
|
73
|
+
},
|
|
74
|
+
sources: {
|
|
75
|
+
video: { main: !1, streams: !1, device: !1 },
|
|
76
|
+
audio: { main: !1, streams: !1, device: !1 },
|
|
77
|
+
sensors: { internal: !1, device: !1 }
|
|
64
78
|
}
|
|
65
79
|
};
|
|
66
|
-
return t === "shader" ? this.detectShaderCapabilities(i, s) : this.detectScriptCapabilities(i, s), s;
|
|
80
|
+
return t === "shader" ? (this.detectShaderCapabilities(i, s), this.detectShaderSources(i, s)) : (this.detectScriptCapabilities(i, s), this.detectScriptSources(i, s)), s;
|
|
67
81
|
}
|
|
68
82
|
/**
|
|
69
83
|
* Replaces comment spans and string/template literals with whitespace via a
|
|
@@ -77,25 +91,25 @@ class a {
|
|
|
77
91
|
const i = e.length;
|
|
78
92
|
let s = 0;
|
|
79
93
|
for (; s < i; ) {
|
|
80
|
-
const r = e[s],
|
|
81
|
-
if (r === "/" &&
|
|
94
|
+
const r = e[s], a = s + 1 < i ? e[s + 1] : "";
|
|
95
|
+
if (r === "/" && a === "/") {
|
|
82
96
|
for (s += 2; s < i && e[s] !== `
|
|
83
97
|
`; ) s++;
|
|
84
98
|
continue;
|
|
85
99
|
}
|
|
86
|
-
if (r === "/" &&
|
|
100
|
+
if (r === "/" && a === "*") {
|
|
87
101
|
for (s += 2; s < i && !(e[s] === "*" && e[s + 1] === "/"); ) s++;
|
|
88
102
|
s += 2, t += " ";
|
|
89
103
|
continue;
|
|
90
104
|
}
|
|
91
105
|
if (r === '"' || r === "'" || r === "`") {
|
|
92
|
-
const
|
|
106
|
+
const o = r;
|
|
93
107
|
for (s++; s < i; ) {
|
|
94
108
|
if (e[s] === "\\") {
|
|
95
109
|
s += 2;
|
|
96
110
|
continue;
|
|
97
111
|
}
|
|
98
|
-
if (e[s] ===
|
|
112
|
+
if (e[s] === o) {
|
|
99
113
|
s++;
|
|
100
114
|
break;
|
|
101
115
|
}
|
|
@@ -115,6 +129,9 @@ class a {
|
|
|
115
129
|
* (`u_device0`, `u_device0Resolution/Connected`) map to video+devices,
|
|
116
130
|
* sensor uniforms (`u_device0Acceleration`, …) map to sensors+devices, and
|
|
117
131
|
* the internal-device sensors (`u_deviceAcceleration`, …) map to sensors.
|
|
132
|
+
*
|
|
133
|
+
* These flag rules are the persisted cohort vocabulary and must not change;
|
|
134
|
+
* per-source refinement lives in {@link detectShaderSources}, run afterwards.
|
|
118
135
|
*/
|
|
119
136
|
static detectShaderCapabilities(e, t) {
|
|
120
137
|
/\bu_audio\w*/.test(e) && (t.audio = !0), /\bu_video\w*/.test(e) && (t.video = !0), /\bu_mouse\w*/.test(e) && (t.mouse = !0), /\bu_key\w*/.test(e) && (t.keyboard = !0), /\bu_touch\w*/.test(e) && (t.touch = !0), /\bu_pointer\w*/.test(e) && (t.pointer = !0), /\bu_device(Acceleration|AccelerationGravity|RotationRate|OrientationAbsolute|Orientation)\b/.test(e) && (t.sensors = !0), /\bu_device[0-7](AccelerationGravity|Acceleration|RotationRate|Orientation)\b/.test(e) && (t.sensors = !0, t.devices = !0), /\bu_externalDeviceCount\b/.test(e) && (t.devices = !0, t.sensors = !0), (/\bu_deviceCount\b/.test(e) || /\bu_device[0-7](Resolution|Connected)?\b/.test(e)) && (t.video = !0, t.devices = !0), /\bu_face\w*/.test(e) && (t.cv.faceDetection = !0), /\bu_face0(Neutral|Happy|Sad|Angry|Surprised|Disgusted|Fearful)\b/.test(e) && (t.cv.emotion = !0), (/\bu_face0HeadPose\b/.test(e) || /\bu_videoAnalysed\w*/.test(e) || /\bu_face0(Brow|Cheek|Eye|Jaw|Mouth|Nose|Tongue)\w*/.test(e)) && (t.cv.faceMesh = !0), (/\bu_handCount\b/.test(e) || /\bu_(left|right)Hand\w*/.test(e)) && (t.cv.handTracking = !0), (/\bu_pose\w*/.test(e) || /\bu_(nose|leftShoulder|rightShoulder|leftElbow|rightElbow|leftWrist|rightWrist|leftHip|rightHip|leftKnee|rightKnee|leftAnkle|rightAnkle)Position\b/.test(e)) && (t.cv.poseDetection = !0), /\bu_segmentation\w*/.test(e) && (t.cv.segmentation = !0);
|
|
@@ -123,21 +140,54 @@ class a {
|
|
|
123
140
|
* Native / p5 capability detection from `viji.*` usage tokens. CV features
|
|
124
141
|
* are keyed on their canonical `enable*` method names (the canonical
|
|
125
142
|
* signal — a scene must enable a feature to receive its data).
|
|
143
|
+
*
|
|
144
|
+
* These flag rules are the persisted cohort vocabulary and must not change;
|
|
145
|
+
* per-source refinement lives in {@link detectScriptSources}, run afterwards.
|
|
126
146
|
*/
|
|
127
147
|
static detectScriptCapabilities(e, t) {
|
|
128
148
|
/\bviji\.audio/.test(e) && (t.audio = !0), /\bviji\.video/.test(e) && (t.video = !0), /\bviji\.mouse/.test(e) && (t.mouse = !0), /\bviji\.keyboard/.test(e) && (t.keyboard = !0), /\bviji\.touches/.test(e) && (t.touch = !0), /\bviji\.pointer/.test(e) && (t.pointer = !0), /\bviji\.device\b/.test(e) && (t.sensors = !0), /\bviji\.devices/.test(e) && (t.devices = !0), /\bviji\.(slider|color|toggle|select|text|number|image|button|coordinate|gradient)\s*\(/.test(e) && (t.parameters = !0), /\benableFaceDetection\b/.test(e) && (t.cv.faceDetection = !0), /\benableFaceMesh\b/.test(e) && (t.cv.faceMesh = !0), /\benableEmotionDetection\b/.test(e) && (t.cv.emotion = !0), /\benableHandTracking\b/.test(e) && (t.cv.handTracking = !0), /\benablePoseDetection\b/.test(e) && (t.cv.poseDetection = !0), /\benableBodySegmentation\b/.test(e) && (t.cv.segmentation = !0);
|
|
129
149
|
}
|
|
130
150
|
/**
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
|
|
151
|
+
* Shader per-source refinement (`caps.sources`) from built-in uniform usage.
|
|
152
|
+
* Runs after {@link detectShaderCapabilities} because `video.main` also
|
|
153
|
+
* follows from any `cv.*` flag: CV runs on the main stream only and no
|
|
154
|
+
* device-CV uniforms exist. The `u_*Stream*` families are host compositor
|
|
155
|
+
* inputs and report `streams`, never `main` or `device`. No device-audio
|
|
156
|
+
* uniform family exists, so `audio.device` stays `false`. The device-sensor
|
|
157
|
+
* regexes repeat the flag rules above on purpose: the two surfaces must not
|
|
158
|
+
* disagree.
|
|
159
|
+
*/
|
|
160
|
+
static detectShaderSources(e, t) {
|
|
161
|
+
const i = t.sources, s = Object.values(t.cv).some(Boolean);
|
|
162
|
+
i.video.main = s || /\bu_video(?!Stream)\w*/.test(e), i.video.streams = /\bu_videoStream\w*/.test(e), i.video.device = /\bu_deviceCount\b/.test(e) || /\bu_device[0-7](Resolution|Connected)?\b/.test(e), i.audio.main = /\bu_audio(?!Stream)\w*/.test(e), i.audio.streams = /\bu_audioStream\w*/.test(e), i.sensors.internal = /\bu_device(Acceleration|AccelerationGravity|RotationRate|OrientationAbsolute|Orientation)\b/.test(e), i.sensors.device = /\bu_device[0-7](AccelerationGravity|Acceleration|RotationRate|Orientation)\b/.test(e) || /\bu_externalDeviceCount\b/.test(e);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Native / p5 per-source refinement (`caps.sources`) from `viji.*` tokens.
|
|
166
|
+
* `main` / `streams` / `internal` are exact-token matches (`\b` after the
|
|
167
|
+
* name keeps `viji.videoStreams` out of `video.main`). CV `enable*` calls do
|
|
168
|
+
* not imply `video.main`: device cameras expose the same CV surface, so the
|
|
169
|
+
* receiver decides. Device sources come from {@link detectScriptDeviceSources}.
|
|
140
170
|
*/
|
|
171
|
+
static detectScriptSources(e, t) {
|
|
172
|
+
const i = t.sources;
|
|
173
|
+
i.video.main = /\bviji\.video\b/.test(e), i.video.streams = /\bviji\.videoStreams\b/.test(e), i.audio.main = /\bviji\.audio\b/.test(e), i.audio.streams = /\bviji\.audioStreams\b/.test(e), i.sensors.internal = /\bviji\.device\b/.test(e), /\bviji\.devices\b/.test(e) && this.detectScriptDeviceSources(e, t);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Which members a native / p5 scene reads off `viji.devices[i]`. Device
|
|
177
|
+
* elements are reached through aliases (`for (const d of viji.devices)`,
|
|
178
|
+
* `devices.filter(d => d.video)`), so the signal is the member token itself:
|
|
179
|
+
* `.video`, `.audio`, `.motion` / `.orientation`. The main-stream and
|
|
180
|
+
* internal-sensor member chains (`viji.video.cv…`, `viji.device.motion…`)
|
|
181
|
+
* are removed first, whole chain not just the head token, so their own
|
|
182
|
+
* members cannot leak into the device result. If `viji.devices` is
|
|
183
|
+
* referenced and no member token survives (destructuring,
|
|
184
|
+
* `viji.devices.length`), every device source reports `true`: inclusive
|
|
185
|
+
* bias, the scene may read any of them.
|
|
186
|
+
*/
|
|
187
|
+
static detectScriptDeviceSources(e, t) {
|
|
188
|
+
const i = e.replace(/\bviji\.(video|audio|device)\b(\s*\??\.\s*[A-Za-z_$][\w$]*)*/g, " "), s = /\.video\b/.test(i), r = /\.audio\b/.test(i), a = /\.(motion|orientation)\b/.test(i), o = !s && !r && !a, b = t.sources;
|
|
189
|
+
b.video.device = s || o, b.audio.device = r || o, b.sensors.device = a || o;
|
|
190
|
+
}
|
|
141
191
|
/**
|
|
142
192
|
* Whether the scene statically consumes the CV analysed frame. Gates
|
|
143
193
|
* per-sink `analysedFrame` bitmap delivery from the shared CV engine to
|
|
@@ -162,6 +212,17 @@ class a {
|
|
|
162
212
|
const t = this.stripCommentsAndStrings(e);
|
|
163
213
|
return /\b(analysedFrame|getAnalysedFrameData)\b/.test(t) || /\bu_videoAnalysed\w*/.test(t);
|
|
164
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Detects which specific interaction inputs a scene reads (positions and
|
|
217
|
+
* mouse buttons), for the worker's consumed-meaningfully evaluation. Renderer-
|
|
218
|
+
* aware: shader scenes are read from built-in uniform usage, native/p5 from
|
|
219
|
+
* `mouse.*` / `pointer.*` / `touches.*` member access. Comments/strings are
|
|
220
|
+
* stripped first. Inclusive-biased like {@link detectCapabilities}.
|
|
221
|
+
*
|
|
222
|
+
* @param sceneCode - The artist's scene code to analyze
|
|
223
|
+
* @param renderer - The renderer type (from {@link detectRendererType})
|
|
224
|
+
* @returns The interaction-input usage mask
|
|
225
|
+
*/
|
|
165
226
|
static detectUsage(e, t) {
|
|
166
227
|
const i = this.stripCommentsAndStrings(e), s = {
|
|
167
228
|
mouse: { position: !1, left: !1, right: !1, middle: !1 },
|
|
@@ -171,16 +232,16 @@ class a {
|
|
|
171
232
|
return t === "shader" ? (s.mouse.position = /\bu_mouse(\b|InCanvas|Delta|Wheel)/.test(i), s.mouse.left = /\bu_mouse(Left|Pressed|WasPressed|WasReleased)\b/.test(i), s.mouse.right = /\bu_mouseRight\b/.test(i), s.mouse.middle = /\bu_mouseMiddle\b/.test(i), s.pointer.position = /\bu_pointer(\b|Delta|InCanvas)/.test(i), s.pointer.down = /\bu_pointer(Down|WasPressed|WasReleased)\b/.test(i), s.touch = /\bu_touch/.test(i)) : (s.mouse.position = /\bmouse\.(x|y|deltaX|deltaY|wheelDelta|wheelX|wheelY|wasMoved)\b/.test(i), s.mouse.left = /\bmouse\.(leftButton|isPressed|wasPressed|wasReleased)\b/.test(i), s.mouse.right = /\bmouse\.rightButton\b/.test(i), s.mouse.middle = /\bmouse\.middleButton\b/.test(i), s.pointer.position = /\bpointer\.(x|y|deltaX|deltaY)\b/.test(i), s.pointer.down = /\bpointer\.(isDown|wasPressed|wasReleased)\b/.test(i), s.touch = /\btouches\./.test(i)), s;
|
|
172
233
|
}
|
|
173
234
|
}
|
|
174
|
-
function
|
|
175
|
-
const e =
|
|
235
|
+
function l(n) {
|
|
236
|
+
const e = u.detectRendererType(n), t = e === "p5" ? u.detectP5CanvasMode(n) : void 0;
|
|
176
237
|
return {
|
|
177
238
|
renderer: e,
|
|
178
239
|
...t !== void 0 && { p5CanvasMode: t },
|
|
179
|
-
capabilities:
|
|
180
|
-
consumesAnalysedFrame:
|
|
240
|
+
capabilities: u.detectCapabilities(n, e),
|
|
241
|
+
consumesAnalysedFrame: u.detectAnalysedFrameUse(n)
|
|
181
242
|
};
|
|
182
243
|
}
|
|
183
244
|
export {
|
|
184
|
-
|
|
185
|
-
|
|
245
|
+
u as S,
|
|
246
|
+
l as a
|
|
186
247
|
};
|
package/dist/scene-analysis.d.ts
CHANGED
|
@@ -32,7 +32,10 @@
|
|
|
32
32
|
* Note for consumers filtering on `capabilities.video`: the flag means the
|
|
33
33
|
* scene reads the video *image* (pixels/texture). Shader scenes that consume
|
|
34
34
|
* only CV result uniforms report `cv.*` without `video`, so a "reacts to the
|
|
35
|
-
* camera" filter should test `video || any cv key`.
|
|
35
|
+
* camera" filter should test `video || any cv key`. Consumers that need to
|
|
36
|
+
* know *which* slot the scene reads (main stream, compositor streams, or an
|
|
37
|
+
* external device) read `capabilities.sources` (0.20.0); the top-level flags
|
|
38
|
+
* keep their 0.19.0 meaning (a shader `u_device{i}` still sets `video`).
|
|
36
39
|
*
|
|
37
40
|
* @param sceneCode - The artist's scene code (native, p5, or shader), raw
|
|
38
41
|
* @returns The complete static analysis — the worker's ack payload
|
|
@@ -86,7 +89,8 @@ declare interface SceneAnalysisData {
|
|
|
86
89
|
*
|
|
87
90
|
* The input keys here are pinned to {@link INPUT_CAPABILITY_KEYS} and the `cv`
|
|
88
91
|
* keys to {@link CV_FEATURE_KEYS} by a compile-time guard (below), so this shape
|
|
89
|
-
* cannot drift from the runtime vocabulary.
|
|
92
|
+
* cannot drift from the runtime vocabulary. `parameters`, `cv`, and `sources`
|
|
93
|
+
* are the declared-only members outside the per-frame input vocabulary.
|
|
90
94
|
*/
|
|
91
95
|
declare interface SceneCapabilities {
|
|
92
96
|
/** Scene reads audio analysis (volume, bands, beat, FFT/waveform, or audio streams). */
|
|
@@ -122,6 +126,67 @@ declare interface SceneCapabilities {
|
|
|
122
126
|
/** Scene uses body segmentation. */
|
|
123
127
|
segmentation: boolean;
|
|
124
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* Which input **source** each capability reads, for host routing UIs (e.g. a
|
|
131
|
+
* controller deciding whether a phone camera belongs in the main slot or a
|
|
132
|
+
* device slot). Declared-only (static analysis, like the flags above) and
|
|
133
|
+
* inclusive-biased; not part of the per-frame {@link INPUT_CAPABILITY_KEYS}
|
|
134
|
+
* vocabulary (same standing as `parameters` and `cv`).
|
|
135
|
+
*
|
|
136
|
+
* - `main`: the host's primary stream, index 0 (`viji.video` / `viji.audio`,
|
|
137
|
+
* `u_video*` / `u_audio*`).
|
|
138
|
+
* - `streams`: host-side additional compositor inputs, indices 1-99
|
|
139
|
+
* (`viji.videoStreams` / `viji.audioStreams`, `u_videoStream*` /
|
|
140
|
+
* `u_audioStream*`). Not routable from a controller; they set neither
|
|
141
|
+
* `main` nor `device`.
|
|
142
|
+
* - `device`: an external device slot, indices 100+ (`viji.devices[i].video`
|
|
143
|
+
* / `.audio` / `.motion` / `.orientation`, `u_device{i}*`, `u_deviceCount`,
|
|
144
|
+
* `u_externalDeviceCount`).
|
|
145
|
+
*
|
|
146
|
+
* Native/p5 scenes reach device members through a `.video` / `.audio` /
|
|
147
|
+
* `.motion` / `.orientation` token after `viji.devices`. When a scene
|
|
148
|
+
* references `viji.devices` but no such token is visible (destructuring,
|
|
149
|
+
* `viji.devices.length`), all three `device` booleans report `true`: the
|
|
150
|
+
* analyzer never hides a source a scene may use.
|
|
151
|
+
*/
|
|
152
|
+
sources: {
|
|
153
|
+
/** Video image source. */
|
|
154
|
+
video: {
|
|
155
|
+
/**
|
|
156
|
+
* Main camera. Shader scenes also report `true` when any `cv.*` flag is
|
|
157
|
+
* set (CV runs on the main stream only; no device-CV uniforms exist).
|
|
158
|
+
* Native/p5 CV `enable*` calls do NOT imply this: device cameras expose
|
|
159
|
+
* the same CV surface (`viji.devices[i].video.cv`).
|
|
160
|
+
*/
|
|
161
|
+
main: boolean;
|
|
162
|
+
/** Additional compositor video streams (`viji.videoStreams`, `u_videoStream*`). */
|
|
163
|
+
streams: boolean;
|
|
164
|
+
/** External device cameras (`viji.devices[i].video`, `u_device{i}`, `u_deviceCount`). */
|
|
165
|
+
device: boolean;
|
|
166
|
+
};
|
|
167
|
+
/** Audio analysis source. */
|
|
168
|
+
audio: {
|
|
169
|
+
/** Main microphone / audio input (`viji.audio`, `u_audio*`). */
|
|
170
|
+
main: boolean;
|
|
171
|
+
/** Additional compositor audio streams (`viji.audioStreams`, `u_audioStream*`). */
|
|
172
|
+
streams: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* External device audio (`viji.devices[i].audio`). Always `false` for
|
|
175
|
+
* shader scenes: no device-audio uniform family exists.
|
|
176
|
+
*/
|
|
177
|
+
device: boolean;
|
|
178
|
+
};
|
|
179
|
+
/** Motion / orientation sensor source. */
|
|
180
|
+
sensors: {
|
|
181
|
+
/** The host machine's own sensors (`viji.device`, `u_deviceAcceleration` and family). */
|
|
182
|
+
internal: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* External device sensors (`viji.devices[i].motion` / `.orientation`,
|
|
185
|
+
* `u_device{i}Acceleration` and family, `u_externalDeviceCount`).
|
|
186
|
+
*/
|
|
187
|
+
device: boolean;
|
|
188
|
+
};
|
|
189
|
+
};
|
|
125
190
|
}
|
|
126
191
|
|
|
127
192
|
export { }
|
package/dist/scene-analysis.js
CHANGED