@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/docs-api.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export const docsApi = {
2
2
  "version": "1.1.0",
3
- "coreVersion": "0.13.0",
4
- "generatedAt": "2026-08-12T18:47:23.752Z",
3
+ "coreVersion": "0.14.0",
4
+ "generatedAt": "2026-08-12T20:50:42.004Z",
5
5
  "navigation": [
6
6
  {
7
7
  "id": "getting-started",
@@ -1,4 +1,4 @@
1
- import { g as kn } from "./index-CkmT_70R.js";
1
+ import { g as kn } from "./index-BYp7SdOD.js";
2
2
  function jn(Oe, ot) {
3
3
  for (var ve = 0; ve < ot.length; ve++) {
4
4
  const Z = ot[ve];
@@ -1,4 +1,4 @@
1
- import { S as eB } from "./scene-analysis-DNN8jTaH.js";
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-Clz2HjaH.js", import.meta.url).href;
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-DGWIGRe8.js").then((g) => g.e), I = A.Essentia || A.default?.Essentia || A.default;
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.13.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.13.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
- import { C as E, I as o, V as s, a as C, b as I } from "./index-CkmT_70R.js";
1
+ import { C as E, I as o, V as s, a as C, b as I } from "./index-BYp7SdOD.js";
2
2
  export {
3
3
  E as CV_FEATURE_KEYS,
4
4
  o as INPUT_CAPABILITY_KEYS,
@@ -1,4 +1,4 @@
1
- class o {
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 s = this.stripCommentsAndStrings(e), i = {
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(s, i) : this.detectScriptCapabilities(s, i), i;
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 s = e.length;
78
- let i = 0;
79
- for (; i < s; ) {
80
- const r = e[i], a = i + 1 < s ? e[i + 1] : "";
81
- if (r === "/" && a === "/") {
82
- for (i += 2; i < s && e[i] !== `
83
- `; ) i++;
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 === "/" && a === "*") {
87
- for (i += 2; i < s && !(e[i] === "*" && e[i + 1] === "/"); ) i++;
88
- i += 2, t += " ";
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 (i++; i < s; ) {
94
- if (e[i] === "\\") {
95
- i += 2;
93
+ for (s++; s < i; ) {
94
+ if (e[s] === "\\") {
95
+ s += 2;
96
96
  continue;
97
97
  }
98
- if (e[i] === u) {
99
- i++;
98
+ if (e[s] === u) {
99
+ s++;
100
100
  break;
101
101
  }
102
- i++;
102
+ s++;
103
103
  }
104
104
  t += " ";
105
105
  continue;
106
106
  }
107
- t += r, i++;
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 s = this.stripCommentsAndStrings(e), i = {
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" ? (i.mouse.position = /\bu_mouse(\b|InCanvas|Delta|Wheel)/.test(s), i.mouse.left = /\bu_mouse(Left|Pressed|WasPressed|WasReleased)\b/.test(s), i.mouse.right = /\bu_mouseRight\b/.test(s), i.mouse.middle = /\bu_mouseMiddle\b/.test(s), i.pointer.position = /\bu_pointer(\b|Delta|InCanvas)/.test(s), i.pointer.down = /\bu_pointer(Down|WasPressed|WasReleased)\b/.test(s), i.touch = /\bu_touch/.test(s)) : (i.mouse.position = /\bmouse\.(x|y|deltaX|deltaY|wheelDelta|wheelX|wheelY|wasMoved)\b/.test(s), i.mouse.left = /\bmouse\.(leftButton|isPressed|wasPressed|wasReleased)\b/.test(s), i.mouse.right = /\bmouse\.rightButton\b/.test(s), i.mouse.middle = /\bmouse\.middleButton\b/.test(s), i.pointer.position = /\bpointer\.(x|y|deltaX|deltaY)\b/.test(s), i.pointer.down = /\bpointer\.(isDown|wasPressed|wasReleased)\b/.test(s), i.touch = /\btouches\./.test(s)), i;
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 = o.detectRendererType(n);
176
- return o.detectCapabilities(n, e);
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
- o as S,
184
+ a as S,
180
185
  b as a
181
186
  };
@@ -1,36 +1,80 @@
1
1
  /**
2
- * Analyzes a scene's source code and returns the capabilities it declares,
3
- * without constructing a core. Composes {@link SceneAnalyzer.detectRendererType}
4
- * and {@link SceneAnalyzer.detectCapabilities} — the same two steps `VijiCore`
5
- * performs at construction — so for a given core version the result is
6
- * identical to a booted core's `getSceneData().capabilities`.
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). The following properties are an intentional, kept
10
- * contract:
11
- * - **Pure and Node-safe** — static analysis only; the scene is never executed
12
- * and no DOM, canvas, or worker API is touched. Callable in a bare Node
13
- * process.
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
- * - **Inclusive-biased** — a capability the scene uses is never hidden; a
16
- * rare ambiguous case may report an extra one.
17
- * - **Safe on untrusted input** — linear-time scan and regexes with no throw
18
- * paths on any string input.
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
- * Note for consumers filtering on `video`: the flag means the scene reads the
21
- * video *image* (pixels/texture). Shader scenes that consume only CV result
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
- * @param sceneCode - The artist's scene code (native, p5, or shader)
26
- * @returns The set of capabilities the scene declares it uses
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 caps = analyzeSceneCapabilities(scene.code);
30
- * if (caps.audio) tags.push('audio');
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 analyzeSceneCapabilities(sceneCode: string): SceneCapabilities;
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
@@ -1,4 +1,4 @@
1
- import { a as i } from "./scene-analysis-DNN8jTaH.js";
1
+ import { a as n } from "./scene-analysis-CEQRlNUL.js";
2
2
  export {
3
- i as analyzeSceneCapabilities
3
+ n as analyzeScene
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viji-dev/core",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Universal execution engine for Viji Creative scenes",
5
5
  "type": "module",
6
6
  "sideEffects": false,