@viji-dev/core 0.13.0 → 0.14.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-Clz2HjaH.js → viji.worker-ByIbGiBL.js} +14 -14
- package/dist/docs-api.js +2 -2
- package/dist/{essentia-wasm.web-DGWIGRe8.js → essentia-wasm.web-0tQ5KtU1.js} +1 -1
- package/dist/{index-CkmT_70R.js → index-BYp7SdOD.js} +4 -4
- package/dist/index.d.ts +24 -1
- package/dist/index.js +1 -1
- package/dist/{scene-analysis-DNN8jTaH.js → scene-analysis-CEQRlNUL.js} +30 -25
- package/dist/scene-analysis.d.ts +67 -23
- package/dist/scene-analysis.js +2 -2
- package/package.json +1 -1
package/dist/docs-api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as eB } from "./scene-analysis-
|
|
1
|
+
import { S as eB } from "./scene-analysis-CEQRlNUL.js";
|
|
2
2
|
const uI = [
|
|
3
3
|
"audio",
|
|
4
4
|
"video",
|
|
@@ -548,7 +548,7 @@ class nB {
|
|
|
548
548
|
}
|
|
549
549
|
}
|
|
550
550
|
}
|
|
551
|
-
const dB = "" + new URL("assets/viji.worker-
|
|
551
|
+
const dB = "" + new URL("assets/viji.worker-ByIbGiBL.js", import.meta.url).href;
|
|
552
552
|
class JB {
|
|
553
553
|
constructor(A, B, I) {
|
|
554
554
|
this.iframeManager = A, this.sceneCode = B, this.init = I;
|
|
@@ -1566,7 +1566,7 @@ class LB {
|
|
|
1566
1566
|
if (!this.isInitialized)
|
|
1567
1567
|
return this.initPromise ? this.initPromise : (this.initPromise = (async () => {
|
|
1568
1568
|
try {
|
|
1569
|
-
const A = await import("./essentia.js-core.es-CC_3Ap1i.js"), B = await import("./essentia-wasm.web-
|
|
1569
|
+
const A = await import("./essentia.js-core.es-CC_3Ap1i.js"), B = await import("./essentia-wasm.web-0tQ5KtU1.js").then((g) => g.e), I = A.Essentia || A.default?.Essentia || A.default;
|
|
1570
1570
|
let Q = B.default || B.EssentiaWASM || B.default?.EssentiaWASM;
|
|
1571
1571
|
if (!Q)
|
|
1572
1572
|
throw new Error("WASM module not found - check essentia-wasm.web.js export");
|
|
@@ -11601,7 +11601,7 @@ function WI(D) {
|
|
|
11601
11601
|
expectedVersion: 1
|
|
11602
11602
|
} : typeof A.senderTime != "number" ? { code: "invalid-field", details: "senderTime must be a number", field: "senderTime" } : null;
|
|
11603
11603
|
}
|
|
11604
|
-
const qI = "0.
|
|
11604
|
+
const qI = "0.14.0";
|
|
11605
11605
|
export {
|
|
11606
11606
|
rI as C,
|
|
11607
11607
|
uI as I,
|
package/dist/index.d.ts
CHANGED
|
@@ -1455,6 +1455,29 @@ export declare type Resolution = {
|
|
|
1455
1455
|
height: number;
|
|
1456
1456
|
};
|
|
1457
1457
|
|
|
1458
|
+
/**
|
|
1459
|
+
* Payload of the worker's `scene-analysis` ack — the correlated response to
|
|
1460
|
+
* `set-scene-code`. The worker runs static analysis (renderer, capabilities,
|
|
1461
|
+
* p5 canvas mode, analysedFrame consumption) after receiving the scene code
|
|
1462
|
+
* and **before** compiling it, and the host's `initialize()` awaits this ack
|
|
1463
|
+
* to assign the four `SceneData` fields exactly once. Carries booleans/enums
|
|
1464
|
+
* only — never scene source.
|
|
1465
|
+
*
|
|
1466
|
+
* Public since 0.14.0: this is also the return type of `analyzeScene`
|
|
1467
|
+
* (`@viji-dev/core/scene-analysis`), which the worker itself calls to build
|
|
1468
|
+
* the ack — one shape, one producer, two transports.
|
|
1469
|
+
*/
|
|
1470
|
+
export declare interface SceneAnalysisData {
|
|
1471
|
+
/** Detected renderer the scene targets. */
|
|
1472
|
+
renderer: RendererType;
|
|
1473
|
+
/** P5 canvas mode; present only when `renderer` is `'p5'`. */
|
|
1474
|
+
p5CanvasMode?: P5CanvasMode;
|
|
1475
|
+
/** Capabilities the scene's code declares it uses (inclusive-biased). */
|
|
1476
|
+
capabilities: SceneCapabilities;
|
|
1477
|
+
/** Whether the scene consumes per-frame analysed-frame bitmaps (CV). */
|
|
1478
|
+
consumesAnalysedFrame: boolean;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1458
1481
|
/**
|
|
1459
1482
|
* The set of engine capabilities a scene's code declares it uses, derived by
|
|
1460
1483
|
* static analysis of the scene source (no execution). Detection is
|
|
@@ -2285,7 +2308,7 @@ declare interface TouchPoint {
|
|
|
2285
2308
|
/** Returned by `on*` listener registration calls; invoke to unsubscribe. */
|
|
2286
2309
|
export declare type Unsubscribe = () => void;
|
|
2287
2310
|
|
|
2288
|
-
export declare const VERSION = "0.
|
|
2311
|
+
export declare const VERSION = "0.14.0";
|
|
2289
2312
|
|
|
2290
2313
|
/**
|
|
2291
2314
|
* Real-time video API: drawable frame, dimensions, and the source-side
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class a {
|
|
2
2
|
/**
|
|
3
3
|
* Detects the renderer type from scene code comments
|
|
4
4
|
*
|
|
@@ -44,7 +44,7 @@ class o {
|
|
|
44
44
|
* @returns The set of capabilities the scene declares it uses
|
|
45
45
|
*/
|
|
46
46
|
static detectCapabilities(e, t) {
|
|
47
|
-
const
|
|
47
|
+
const i = this.stripCommentsAndStrings(e), s = {
|
|
48
48
|
audio: !1,
|
|
49
49
|
video: !1,
|
|
50
50
|
mouse: !1,
|
|
@@ -63,7 +63,7 @@ class o {
|
|
|
63
63
|
segmentation: !1
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
return t === "shader" ? this.detectShaderCapabilities(
|
|
66
|
+
return t === "shader" ? this.detectShaderCapabilities(i, s) : this.detectScriptCapabilities(i, s), s;
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* Replaces comment spans and string/template literals with whitespace via a
|
|
@@ -74,37 +74,37 @@ class o {
|
|
|
74
74
|
*/
|
|
75
75
|
static stripCommentsAndStrings(e) {
|
|
76
76
|
let t = "";
|
|
77
|
-
const
|
|
78
|
-
let
|
|
79
|
-
for (;
|
|
80
|
-
const r = e[
|
|
81
|
-
if (r === "/" &&
|
|
82
|
-
for (
|
|
83
|
-
`; )
|
|
77
|
+
const i = e.length;
|
|
78
|
+
let s = 0;
|
|
79
|
+
for (; s < i; ) {
|
|
80
|
+
const r = e[s], o = s + 1 < i ? e[s + 1] : "";
|
|
81
|
+
if (r === "/" && o === "/") {
|
|
82
|
+
for (s += 2; s < i && e[s] !== `
|
|
83
|
+
`; ) s++;
|
|
84
84
|
continue;
|
|
85
85
|
}
|
|
86
|
-
if (r === "/" &&
|
|
87
|
-
for (
|
|
88
|
-
|
|
86
|
+
if (r === "/" && o === "*") {
|
|
87
|
+
for (s += 2; s < i && !(e[s] === "*" && e[s + 1] === "/"); ) s++;
|
|
88
|
+
s += 2, t += " ";
|
|
89
89
|
continue;
|
|
90
90
|
}
|
|
91
91
|
if (r === '"' || r === "'" || r === "`") {
|
|
92
92
|
const u = r;
|
|
93
|
-
for (
|
|
94
|
-
if (e[
|
|
95
|
-
|
|
93
|
+
for (s++; s < i; ) {
|
|
94
|
+
if (e[s] === "\\") {
|
|
95
|
+
s += 2;
|
|
96
96
|
continue;
|
|
97
97
|
}
|
|
98
|
-
if (e[
|
|
99
|
-
|
|
98
|
+
if (e[s] === u) {
|
|
99
|
+
s++;
|
|
100
100
|
break;
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
s++;
|
|
103
103
|
}
|
|
104
104
|
t += " ";
|
|
105
105
|
continue;
|
|
106
106
|
}
|
|
107
|
-
t += r,
|
|
107
|
+
t += r, s++;
|
|
108
108
|
}
|
|
109
109
|
return t;
|
|
110
110
|
}
|
|
@@ -163,19 +163,24 @@ class o {
|
|
|
163
163
|
return /\b(analysedFrame|getAnalysedFrameData)\b/.test(t) || /\bu_videoAnalysed\w*/.test(t);
|
|
164
164
|
}
|
|
165
165
|
static detectUsage(e, t) {
|
|
166
|
-
const
|
|
166
|
+
const i = this.stripCommentsAndStrings(e), s = {
|
|
167
167
|
mouse: { position: !1, left: !1, right: !1, middle: !1 },
|
|
168
168
|
pointer: { position: !1, down: !1 },
|
|
169
169
|
touch: !1
|
|
170
170
|
};
|
|
171
|
-
return t === "shader" ? (
|
|
171
|
+
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
172
|
}
|
|
173
173
|
}
|
|
174
174
|
function b(n) {
|
|
175
|
-
const e =
|
|
176
|
-
return
|
|
175
|
+
const e = a.detectRendererType(n), t = e === "p5" ? a.detectP5CanvasMode(n) : void 0;
|
|
176
|
+
return {
|
|
177
|
+
renderer: e,
|
|
178
|
+
...t !== void 0 && { p5CanvasMode: t },
|
|
179
|
+
capabilities: a.detectCapabilities(n, e),
|
|
180
|
+
consumesAnalysedFrame: a.detectAnalysedFrameUse(n)
|
|
181
|
+
};
|
|
177
182
|
}
|
|
178
183
|
export {
|
|
179
|
-
|
|
184
|
+
a as S,
|
|
180
185
|
b as a
|
|
181
186
|
};
|
package/dist/scene-analysis.d.ts
CHANGED
|
@@ -1,36 +1,80 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* without constructing a core. Composes
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* Full static scene analysis — everything the worker's `scene-analysis` ack
|
|
3
|
+
* carries, computed without constructing a core. Composes the same four
|
|
4
|
+
* statics the worker runs in phase 1 of scene load ({@link
|
|
5
|
+
* SceneAnalyzer.detectRendererType} → {@link SceneAnalyzer.detectP5CanvasMode}
|
|
6
|
+
* → {@link SceneAnalyzer.detectCapabilities} → {@link
|
|
7
|
+
* SceneAnalyzer.detectAnalysedFrameUse}), and the worker itself consumes this
|
|
8
|
+
* function to build the ack — so for a given core version the result is the
|
|
9
|
+
* exact payload a booted core's `initialize()` resolves its scene analysis
|
|
10
|
+
* with. Parity holds through shared code, not parallel composition.
|
|
7
11
|
*
|
|
8
12
|
* Intended for out-of-engine consumers (e.g. server-side persistence of
|
|
9
|
-
* per-scene capabilities
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
13
|
+
* per-scene capabilities; migration tooling that needs the renderer without
|
|
14
|
+
* booting a core). The following properties are an intentional, kept
|
|
15
|
+
* contract, covering all four fields:
|
|
16
|
+
* - **Pure and Node-safe** — static analysis only; the scene is never
|
|
17
|
+
* executed and no DOM, canvas, or worker API is touched. Callable in a
|
|
18
|
+
* bare Node process.
|
|
14
19
|
* - **Deterministic** — same code string, same result, within a core version.
|
|
15
|
-
* - **
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
20
|
+
* - **Raw-code input** — `renderer` and `p5CanvasMode` are comment-directive
|
|
21
|
+
* scans over the artist's original source, before any transpilation (the
|
|
22
|
+
* worker applies sucrase only after this analysis, and only to script
|
|
23
|
+
* scenes). Pass stored scene code as-is.
|
|
24
|
+
* - **Inclusive-biased** (`capabilities`) — a capability the scene uses is
|
|
25
|
+
* never hidden; a rare ambiguous case may report an extra one.
|
|
26
|
+
* - **Safe on untrusted input** — linear-time scans and regexes with no
|
|
27
|
+
* throw paths on any string input.
|
|
19
28
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* uniforms report `cv.*` without `video`, so a "reacts to the camera" filter
|
|
23
|
-
* should test `video || any cv key`.
|
|
29
|
+
* `p5CanvasMode` is present only when `renderer` is `'p5'`, mirroring the
|
|
30
|
+
* ack shape exactly.
|
|
24
31
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
32
|
+
* Note for consumers filtering on `capabilities.video`: the flag means the
|
|
33
|
+
* scene reads the video *image* (pixels/texture). Shader scenes that consume
|
|
34
|
+
* only CV result uniforms report `cv.*` without `video`, so a "reacts to the
|
|
35
|
+
* camera" filter should test `video || any cv key`.
|
|
36
|
+
*
|
|
37
|
+
* @param sceneCode - The artist's scene code (native, p5, or shader), raw
|
|
38
|
+
* @returns The complete static analysis — the worker's ack payload
|
|
27
39
|
* @example
|
|
28
40
|
* ```ts
|
|
29
|
-
* const
|
|
30
|
-
* if (
|
|
41
|
+
* const analysis = analyzeScene(scene.code);
|
|
42
|
+
* if (analysis.renderer === 'shader') return skip(scene);
|
|
43
|
+
* if (analysis.capabilities.audio) tags.push('audio');
|
|
31
44
|
* ```
|
|
32
45
|
*/
|
|
33
|
-
export declare function
|
|
46
|
+
export declare function analyzeScene(sceneCode: string): SceneAnalysisData;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* P5 main-canvas mode. Only meaningful when {@link SceneData.renderer} is
|
|
50
|
+
* `'p5'`: `'2d'` for the default 2D canvas, `'webgl'` for a WEBGL canvas.
|
|
51
|
+
*/
|
|
52
|
+
declare type P5CanvasMode = '2d' | 'webgl';
|
|
53
|
+
|
|
54
|
+
declare type RendererType = 'native' | 'p5' | 'shader';
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Payload of the worker's `scene-analysis` ack — the correlated response to
|
|
58
|
+
* `set-scene-code`. The worker runs static analysis (renderer, capabilities,
|
|
59
|
+
* p5 canvas mode, analysedFrame consumption) after receiving the scene code
|
|
60
|
+
* and **before** compiling it, and the host's `initialize()` awaits this ack
|
|
61
|
+
* to assign the four `SceneData` fields exactly once. Carries booleans/enums
|
|
62
|
+
* only — never scene source.
|
|
63
|
+
*
|
|
64
|
+
* Public since 0.14.0: this is also the return type of `analyzeScene`
|
|
65
|
+
* (`@viji-dev/core/scene-analysis`), which the worker itself calls to build
|
|
66
|
+
* the ack — one shape, one producer, two transports.
|
|
67
|
+
*/
|
|
68
|
+
declare interface SceneAnalysisData {
|
|
69
|
+
/** Detected renderer the scene targets. */
|
|
70
|
+
renderer: RendererType;
|
|
71
|
+
/** P5 canvas mode; present only when `renderer` is `'p5'`. */
|
|
72
|
+
p5CanvasMode?: P5CanvasMode;
|
|
73
|
+
/** Capabilities the scene's code declares it uses (inclusive-biased). */
|
|
74
|
+
capabilities: SceneCapabilities;
|
|
75
|
+
/** Whether the scene consumes per-frame analysed-frame bitmaps (CV). */
|
|
76
|
+
consumesAnalysedFrame: boolean;
|
|
77
|
+
}
|
|
34
78
|
|
|
35
79
|
/**
|
|
36
80
|
* The set of engine capabilities a scene's code declares it uses, derived by
|
package/dist/scene-analysis.js
CHANGED