@viji-dev/core 0.7.4 → 0.7.5

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.
@@ -7351,6 +7351,15 @@ class C1 {
7351
7351
  currentSourceMap = null;
7352
7352
  /** Lifecycle marker; flipped by the runtime after first successful render. */
7353
7353
  hasProducedFirstFrame = !1;
7354
+ /**
7355
+ * Monotonic envelope sequence number. Used to give every outbound envelope
7356
+ * a unique `id` even when two fires share the same `signatureHash` and
7357
+ * `firstSeenAt` (which they do under cumulative semantics — `firstSeenAt`
7358
+ * is constant across windows for a recurring signature, so the sequence
7359
+ * counter is what disambiguates the leading-edge of burst N from the
7360
+ * trailing rollup of burst N-1).
7361
+ */
7362
+ envelopeSeq = 0;
7354
7363
  constructor(e, n = {}) {
7355
7364
  this.config = { ...R1, ...n }, this.post = e, this.errorChannel = new Ti(
7356
7365
  this.config.errorCoalescingWindowMs,
@@ -7536,7 +7545,7 @@ class C1 {
7536
7545
  postEnvelope(e, n) {
7537
7546
  this.post({
7538
7547
  type: e,
7539
- id: `${e}_${n.signatureHash}_${n.firstSeenAt}`,
7548
+ id: `${e}_${n.signatureHash}_${++this.envelopeSeq}`,
7540
7549
  timestamp: Date.now(),
7541
7550
  data: n
7542
7551
  });
@@ -7552,30 +7561,38 @@ class Ti {
7552
7561
  setWindowMs(e) {
7553
7562
  this.windowMs = e;
7554
7563
  }
7564
+ /**
7565
+ * `true` iff this signature has been observed at least once in the current
7566
+ * session. Used by the console rate-cap to charge the per-second budget
7567
+ * only for genuinely new signatures (a known signature in a fresh burst
7568
+ * is not a new signature).
7569
+ */
7555
7570
  hasPending(e) {
7556
7571
  return this.pending.has(e);
7557
7572
  }
7558
7573
  emit(e, n) {
7559
7574
  const s = Date.now(), i = this.pending.get(e);
7560
7575
  if (i) {
7561
- i.payload.count++, i.payload.lastSeenAt = s;
7576
+ if (i.payload.count++, i.payload.lastSeenAt = s, i.timer !== null) return;
7577
+ this.emitFn(i.payload), i.lastEmittedCount = i.payload.count, i.timer = setTimeout(() => this.flush(e), this.windowMs);
7562
7578
  return;
7563
7579
  }
7564
7580
  n.count = 1, n.firstSeenAt = s, n.lastSeenAt = s, this.emitFn(n);
7565
7581
  const o = setTimeout(() => this.flush(e), this.windowMs);
7566
- this.pending.set(e, { payload: n, timer: o });
7582
+ this.pending.set(e, { payload: n, timer: o, lastEmittedCount: 1 });
7567
7583
  }
7568
7584
  flush(e) {
7569
7585
  const n = this.pending.get(e);
7570
- n && (this.pending.delete(e), clearTimeout(n.timer), n.payload.count > 1 && this.emitFn(n.payload));
7586
+ !n || n.timer === null || (clearTimeout(n.timer), n.timer = null, n.payload.count > n.lastEmittedCount && (this.emitFn(n.payload), n.lastEmittedCount = n.payload.count));
7571
7587
  }
7572
7588
  flushAndClear() {
7573
- for (const [e] of this.pending)
7574
- this.flush(e);
7589
+ for (const e of this.pending.values())
7590
+ e.timer !== null && (clearTimeout(e.timer), e.timer = null, e.payload.count > e.lastEmittedCount && this.emitFn(e.payload));
7591
+ this.pending.clear();
7575
7592
  }
7576
7593
  destroy() {
7577
7594
  for (const e of this.pending.values())
7578
- clearTimeout(e.timer);
7595
+ e.timer !== null && clearTimeout(e.timer);
7579
7596
  this.pending.clear();
7580
7597
  }
7581
7598
  }
@@ -25076,4 +25093,4 @@ throw new Error("Scene code must define a render function");`, o = Object.getPro
25076
25093
  }
25077
25094
  }
25078
25095
  self.setSceneCode = Md;
25079
- //# sourceMappingURL=viji.worker-Dq2EQ0Wd.js.map
25096
+ //# sourceMappingURL=viji.worker-CXp6CGrq.js.map
package/dist/docs-api.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export const docsApi = {
2
2
  "version": "1.1.0",
3
3
  "coreVersion": "0.7.4",
4
- "generatedAt": "2026-05-21T11:34:26.940Z",
4
+ "generatedAt": "2026-05-22T14:07:51.895Z",
5
5
  "navigation": [
6
6
  {
7
7
  "id": "getting-started",
@@ -1,4 +1,4 @@
1
- import { g as kn } from "./index-DmQ5U_50.js";
1
+ import { g as kn } from "./index-B1JJ8Mko.js";
2
2
  function jn(Oe, ot) {
3
3
  for (var ve = 0; ve < ot.length; ve++) {
4
4
  const Z = ot[ve];
@@ -3374,4 +3374,4 @@ const xn = /* @__PURE__ */ kn(yi), Ln = /* @__PURE__ */ jn({
3374
3374
  export {
3375
3375
  Ln as e
3376
3376
  };
3377
- //# sourceMappingURL=essentia-wasm.web-BgpNs-yB.js.map
3377
+ //# sourceMappingURL=essentia-wasm.web-Bh9tTilM.js.map
@@ -536,7 +536,7 @@ class DB {
536
536
  }
537
537
  }
538
538
  }
539
- const oB = "" + new URL("assets/viji.worker-Dq2EQ0Wd.js", import.meta.url).href, hB = new URL("assets/wasm/vision_wasm_internal.js", import.meta.url).href, RB = new URL("assets/wasm/vision_wasm_internal.wasm", import.meta.url).href, wB = new URL("assets/wasm/vision_wasm_nosimd_internal.js", import.meta.url).href, sB = new URL("assets/wasm/vision_wasm_nosimd_internal.wasm", import.meta.url).href;
539
+ const oB = "" + new URL("assets/viji.worker-CXp6CGrq.js", import.meta.url).href, hB = new URL("assets/wasm/vision_wasm_internal.js", import.meta.url).href, RB = new URL("assets/wasm/vision_wasm_internal.wasm", import.meta.url).href, wB = new URL("assets/wasm/vision_wasm_nosimd_internal.js", import.meta.url).href, sB = new URL("assets/wasm/vision_wasm_nosimd_internal.wasm", import.meta.url).href;
540
540
  class FB {
541
541
  constructor(A, B, I) {
542
542
  this.iframeManager = A, this.sceneCode = B, this.init = I;
@@ -1520,7 +1520,7 @@ class YB {
1520
1520
  if (!this.isInitialized)
1521
1521
  return this.initPromise ? this.initPromise : (this.initPromise = (async () => {
1522
1522
  try {
1523
- const A = await import("./essentia.js-core.es-CC_3Ap1i.js"), B = await import("./essentia-wasm.web-BgpNs-yB.js").then((g) => g.e), I = A.Essentia || A.default?.Essentia || A.default;
1523
+ const A = await import("./essentia.js-core.es-CC_3Ap1i.js"), B = await import("./essentia-wasm.web-Bh9tTilM.js").then((g) => g.e), I = A.Essentia || A.default?.Essentia || A.default;
1524
1524
  let Q = B.default || B.EssentiaWASM || B.default?.EssentiaWASM;
1525
1525
  if (!Q)
1526
1526
  throw new Error("WASM module not found - check essentia-wasm.web.js export");
@@ -8406,4 +8406,4 @@ export {
8406
8406
  S as b,
8407
8407
  vB as g
8408
8408
  };
8409
- //# sourceMappingURL=index-DmQ5U_50.js.map
8409
+ //# sourceMappingURL=index-B1JJ8Mko.js.map
package/dist/index.d.ts CHANGED
@@ -1721,6 +1721,10 @@ export declare type Resolution = {
1721
1721
  * inspection, a per-argument byte cap (`consoleArgMaxBytes`), and an argument
1722
1722
  * count cap (`consoleMaxArgsPerCall`). High-cardinality logs are rate-limited
1723
1723
  * by `consoleMaxUniqueSignaturesPerSecond`.
1724
+ *
1725
+ * Coalescing semantics match `SceneRuntimeError`: `count` and `firstSeenAt`
1726
+ * are cumulative for the scene session (monotonically non-decreasing across
1727
+ * coalescing windows), reset only when the worker terminates.
1724
1728
  */
1725
1729
  export declare interface SceneConsoleMessage {
1726
1730
  /** Console method invoked. */
@@ -1729,9 +1733,19 @@ export declare interface SceneConsoleMessage {
1729
1733
  args: string[];
1730
1734
  /** Stable hash of `level` and the stringified arguments, used for coalescing. */
1731
1735
  signatureHash: string;
1732
- /** Number of occurrences of this signature accumulated in the current window. */
1736
+ /**
1737
+ * Cumulative number of occurrences of this signature since it was first
1738
+ * seen in this scene session. Monotonically non-decreasing across
1739
+ * coalescing windows; each fire carries the up-to-date total. Consumers
1740
+ * that maintain a per-signature view should REPLACE their stored count
1741
+ * with this value on each fire, not add to it.
1742
+ */
1733
1743
  count: number;
1734
- /** Millisecond timestamp of the first occurrence of this signature in the current window. */
1744
+ /**
1745
+ * Millisecond timestamp of the FIRST occurrence of this signature in this
1746
+ * scene session. Set once and unchanged for every subsequent fire of the
1747
+ * same signature.
1748
+ */
1735
1749
  firstSeenAt: number;
1736
1750
  /** Millisecond timestamp of the most recent occurrence. */
1737
1751
  lastSeenAt: number;
@@ -1759,9 +1773,15 @@ export declare type SceneErrorCode = 'SCENE_CODE_ERROR' | 'RENDER_ERROR' | 'UNCA
1759
1773
  /**
1760
1774
  * Structured scene runtime error envelope surfaced via `VijiCore.onSceneRuntimeError`.
1761
1775
  *
1762
- * Identical signatures are coalesced inside the worker: the first occurrence in
1763
- * a window fires with `count: 1`, subsequent occurrences increment `count`, and
1764
- * a trailing rollup fires at window close if more than one occurrence was seen.
1776
+ * Identical signatures are coalesced inside the worker. The first ever
1777
+ * occurrence of a signature in this scene session fires immediately with
1778
+ * `count: 1`; further occurrences within the coalescing window are absorbed
1779
+ * silently and emitted as a single trailing rollup with the up-to-date
1780
+ * cumulative count at window close. Subsequent bursts of the same signature
1781
+ * refire a leading edge with the up-to-date cumulative count and re-arm the
1782
+ * rollup timer. `count` and `firstSeenAt` are cumulative for the scene
1783
+ * session — they persist across coalescing windows and are reset only when
1784
+ * the worker terminates (scene teardown).
1765
1785
  *
1766
1786
  * The host-side `console.error('Scene error:', data)` tee continues to fire
1767
1787
  * alongside the listener (never silenced based on listener presence).
@@ -1785,9 +1805,20 @@ export declare interface SceneRuntimeError {
1785
1805
  code: SceneErrorCode;
1786
1806
  /** Stable hash of `message` and the first artist stack frame, used for coalescing. */
1787
1807
  signatureHash: string;
1788
- /** Number of occurrences of this signature accumulated in the current window. */
1808
+ /**
1809
+ * Cumulative number of occurrences of this signature since it was first
1810
+ * seen in this scene session. Monotonically non-decreasing across
1811
+ * coalescing windows; each fire carries the up-to-date total. Consumers
1812
+ * that maintain a per-signature view should REPLACE their stored count
1813
+ * with this value on each fire, not add to it.
1814
+ */
1789
1815
  count: number;
1790
- /** Millisecond timestamp of the first occurrence of this signature in the current window. */
1816
+ /**
1817
+ * Millisecond timestamp of the FIRST occurrence of this signature in this
1818
+ * scene session. Set once and unchanged for every subsequent fire of the
1819
+ * same signature — `Date.now() - firstSeenAt` is the lifetime of the
1820
+ * signature in this session, useful for chronicity reasoning.
1821
+ */
1791
1822
  firstSeenAt: number;
1792
1823
  /** Millisecond timestamp of the most recent occurrence. */
1793
1824
  lastSeenAt: number;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as a, V as i, a as s, b as e } from "./index-DmQ5U_50.js";
1
+ import { A as a, V as i, a as s, b as e } from "./index-B1JJ8Mko.js";
2
2
  export {
3
3
  a as AudioSystem,
4
4
  i as VERSION,
package/package.json CHANGED
@@ -1,100 +1,100 @@
1
- {
2
- "name": "@viji-dev/core",
3
- "version": "0.7.4",
4
- "description": "Universal execution engine for Viji Creative scenes",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "import": "./dist/index.js",
12
- "types": "./dist/index.d.ts"
13
- },
14
- "./artist-global": {
15
- "types": "./dist/artist-global.d.ts"
16
- },
17
- "./artist-dts": {
18
- "import": "./dist/artist-dts.js",
19
- "types": "./dist/artist-dts.d.ts"
20
- },
21
- "./artist-jsdoc": {
22
- "types": "./dist/artist-jsdoc.d.ts"
23
- },
24
- "./artist-js-ambient": {
25
- "types": "./dist/artist-js-ambient.d.ts"
26
- },
27
- "./artist-dts-p5": {
28
- "import": "./dist/artist-dts-p5.js",
29
- "types": "./dist/artist-dts-p5.d.ts"
30
- },
31
- "./artist-global-p5": {
32
- "types": "./dist/artist-global-p5.d.ts"
33
- },
34
- "./shader-uniforms": {
35
- "import": "./dist/shader-uniforms.js",
36
- "types": "./dist/shader-uniforms.d.ts"
37
- },
38
- "./docs-api": {
39
- "import": "./dist/docs-api.js",
40
- "types": "./dist/docs-api.d.ts"
41
- }
42
- },
43
- "files": [
44
- "dist/*.js",
45
- "dist/*.d.ts",
46
- "dist/assets",
47
- "!dist/**/*.map",
48
- "README.md"
49
- ],
50
- "scripts": {
51
- "prebuild": "node scripts/prebuild-clean.mjs",
52
- "build": "vite build && node scripts/copy-tasks-assets.mjs && node scripts/build-artist-types.mjs && node scripts/build-docs-api.mjs",
53
- "build:docs": "node scripts/build-docs-api.mjs",
54
- "lint:ai-prompts-drift": "node scripts/lint-ai-prompts-drift.mjs",
55
- "dev": "vite build --watch",
56
- "integration": "vite --config integration-example/vite.config.ts",
57
- "test": "vitest",
58
- "test:coverage": "vitest --coverage",
59
- "type-check": "tsc --noEmit",
60
- "lint": "eslint src --ext .ts"
61
- },
62
- "keywords": [
63
- "viji",
64
- "creative",
65
- "webgl",
66
- "audio-reactive",
67
- "canvas",
68
- "webworker"
69
- ],
70
- "author": "Viji Team",
71
- "license": "SEE LICENSE IN LICENSE",
72
- "devDependencies": {
73
- "@types/node": "^20.0.0",
74
- "@types/p5": "^1.7.6",
75
- "@typescript-eslint/eslint-plugin": "^6.0.0",
76
- "@typescript-eslint/parser": "^6.0.0",
77
- "@vitest/coverage-v8": "^1.0.0",
78
- "dts-bundle-generator": "^9.5.1",
79
- "eslint": "^8.0.0",
80
- "github-slugger": "^2.0.0",
81
- "happy-dom": "^18.0.1",
82
- "mdast-util-to-string": "^4.0.0",
83
- "remark-parse": "^11.0.0",
84
- "typescript": "^5.0.0",
85
- "unified": "^11.0.5",
86
- "vite": "^5.0.0",
87
- "vite-plugin-dts": "^3.0.0",
88
- "vitest": "^1.0.0"
89
- },
90
- "engines": {
91
- "node": ">=18.0.0"
92
- },
93
- "dependencies": {
94
- "@mediapipe/tasks-vision": "^0.10.20",
95
- "@noble/curves": "^2.2.0",
96
- "essentia.js": "^0.1.3",
97
- "fft.js": "^4.0.4",
98
- "sucrase": "^3.35.1"
99
- }
100
- }
1
+ {
2
+ "name": "@viji-dev/core",
3
+ "version": "0.7.5",
4
+ "description": "Universal execution engine for Viji Creative scenes",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ },
14
+ "./artist-global": {
15
+ "types": "./dist/artist-global.d.ts"
16
+ },
17
+ "./artist-dts": {
18
+ "import": "./dist/artist-dts.js",
19
+ "types": "./dist/artist-dts.d.ts"
20
+ },
21
+ "./artist-jsdoc": {
22
+ "types": "./dist/artist-jsdoc.d.ts"
23
+ },
24
+ "./artist-js-ambient": {
25
+ "types": "./dist/artist-js-ambient.d.ts"
26
+ },
27
+ "./artist-dts-p5": {
28
+ "import": "./dist/artist-dts-p5.js",
29
+ "types": "./dist/artist-dts-p5.d.ts"
30
+ },
31
+ "./artist-global-p5": {
32
+ "types": "./dist/artist-global-p5.d.ts"
33
+ },
34
+ "./shader-uniforms": {
35
+ "import": "./dist/shader-uniforms.js",
36
+ "types": "./dist/shader-uniforms.d.ts"
37
+ },
38
+ "./docs-api": {
39
+ "import": "./dist/docs-api.js",
40
+ "types": "./dist/docs-api.d.ts"
41
+ }
42
+ },
43
+ "files": [
44
+ "dist/*.js",
45
+ "dist/*.d.ts",
46
+ "dist/assets",
47
+ "!dist/**/*.map",
48
+ "README.md"
49
+ ],
50
+ "scripts": {
51
+ "prebuild": "node scripts/prebuild-clean.mjs",
52
+ "build": "vite build && node scripts/copy-tasks-assets.mjs && node scripts/build-artist-types.mjs && node scripts/build-docs-api.mjs",
53
+ "build:docs": "node scripts/build-docs-api.mjs",
54
+ "lint:ai-prompts-drift": "node scripts/lint-ai-prompts-drift.mjs",
55
+ "dev": "vite build --watch",
56
+ "integration": "vite --config integration-example/vite.config.ts",
57
+ "test": "vitest",
58
+ "test:coverage": "vitest --coverage",
59
+ "type-check": "tsc --noEmit",
60
+ "lint": "eslint src --ext .ts"
61
+ },
62
+ "keywords": [
63
+ "viji",
64
+ "creative",
65
+ "webgl",
66
+ "audio-reactive",
67
+ "canvas",
68
+ "webworker"
69
+ ],
70
+ "author": "Viji Team",
71
+ "license": "SEE LICENSE IN LICENSE",
72
+ "devDependencies": {
73
+ "@types/node": "^20.0.0",
74
+ "@types/p5": "^1.7.6",
75
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
76
+ "@typescript-eslint/parser": "^6.0.0",
77
+ "@vitest/coverage-v8": "^1.0.0",
78
+ "dts-bundle-generator": "^9.5.1",
79
+ "eslint": "^8.0.0",
80
+ "github-slugger": "^2.0.0",
81
+ "happy-dom": "^18.0.1",
82
+ "mdast-util-to-string": "^4.0.0",
83
+ "remark-parse": "^11.0.0",
84
+ "typescript": "^5.0.0",
85
+ "unified": "^11.0.5",
86
+ "vite": "^5.0.0",
87
+ "vite-plugin-dts": "^3.0.0",
88
+ "vitest": "^1.0.0"
89
+ },
90
+ "engines": {
91
+ "node": ">=18.0.0"
92
+ },
93
+ "dependencies": {
94
+ "@mediapipe/tasks-vision": "^0.10.20",
95
+ "@noble/curves": "^2.2.0",
96
+ "essentia.js": "^0.1.3",
97
+ "fft.js": "^4.0.4",
98
+ "sucrase": "^3.35.1"
99
+ }
100
+ }