@viji-dev/core 0.3.27 → 0.3.29

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.
@@ -199,6 +199,18 @@ class IFrameManager {
199
199
  getScale() {
200
200
  return this.scale;
201
201
  }
202
+ /**
203
+ * Gets the actual ratio of canvas pixels to display (CSS) pixels.
204
+ * Works correctly for both scale-based and explicit resolution modes.
205
+ */
206
+ getDisplayScale() {
207
+ if (this.isHeadless) return 1;
208
+ if (this.explicitResolution && this.hostContainer) {
209
+ const rect = this.hostContainer.getBoundingClientRect();
210
+ return rect.width > 0 ? this.explicitResolution.width / rect.width : 1;
211
+ }
212
+ return Math.max(0.1, Math.min(1, this.scale));
213
+ }
202
214
  // ========================================
203
215
  // Device Sensor Support
204
216
  // ========================================
@@ -578,7 +590,7 @@ class IFrameManager {
578
590
  }
579
591
  function WorkerWrapper(options) {
580
592
  return new Worker(
581
- "" + new URL("assets/viji.worker-jTmB7qoQ.js", import.meta.url).href,
593
+ "" + new URL("assets/viji.worker-CQSJ0SiO.js", import.meta.url).href,
582
594
  {
583
595
  type: "module",
584
596
  name: options?.name
@@ -586,9 +598,12 @@ function WorkerWrapper(options) {
586
598
  );
587
599
  }
588
600
  class WorkerManager {
589
- constructor(sceneCode, offscreenCanvas) {
601
+ constructor(sceneCode, offscreenCanvas, isHeadless = false, initialSC, initialRH) {
590
602
  this.sceneCode = sceneCode;
591
603
  this.offscreenCanvas = offscreenCanvas;
604
+ this.isHeadless = isHeadless;
605
+ this.initialSC = initialSC;
606
+ this.initialRH = initialRH;
592
607
  }
593
608
  worker = null;
594
609
  messageId = 0;
@@ -755,7 +770,10 @@ class WorkerManager {
755
770
  id,
756
771
  timestamp: Date.now(),
757
772
  data: {
758
- canvas: this.offscreenCanvas
773
+ canvas: this.offscreenCanvas,
774
+ isHeadless: this.isHeadless,
775
+ sc: this.initialSC,
776
+ rh: this.initialRH
759
777
  }
760
778
  };
761
779
  return new Promise((resolve, reject) => {
@@ -1732,7 +1750,7 @@ class EssentiaOnsetDetection {
1732
1750
  this.initPromise = (async () => {
1733
1751
  try {
1734
1752
  const essentiaModule = await import("./essentia.js-core.es-DnrJE0uR.js");
1735
- const wasmModule = await import("./essentia-wasm.web-DtvIO6D8.js").then((n) => n.e);
1753
+ const wasmModule = await import("./essentia-wasm.web-BiywsbGL.js").then((n) => n.e);
1736
1754
  const EssentiaClass = essentiaModule.Essentia || essentiaModule.default?.Essentia || essentiaModule.default;
1737
1755
  let WASMModule = wasmModule.default || wasmModule.EssentiaWASM || wasmModule.default?.EssentiaWASM;
1738
1756
  if (!WASMModule) {
@@ -14788,6 +14806,19 @@ class VijiCore {
14788
14806
  getDebugMode() {
14789
14807
  return this.debugMode;
14790
14808
  }
14809
+ /**
14810
+ * Update the session capability token at runtime.
14811
+ * Forwards the signed JWT to the worker for verification.
14812
+ */
14813
+ updateSessionConfig(token) {
14814
+ this.workerManager?.postMessage("sc-update", { t: token });
14815
+ }
14816
+ /**
14817
+ * Set a cosmetic render hint for the branding overlay (logo variant / position).
14818
+ */
14819
+ setRenderHint(hint) {
14820
+ this.workerManager?.postMessage("rh-update", { h: hint });
14821
+ }
14791
14822
  /**
14792
14823
  * Show the core's iframe (make it visible in the host container).
14793
14824
  * No-op for headless cores.
@@ -14833,10 +14864,18 @@ class VijiCore {
14833
14864
  }
14834
14865
  this.workerManager = new WorkerManager(
14835
14866
  this.config.sceneCode,
14836
- offscreenCanvas
14867
+ offscreenCanvas,
14868
+ this.isHeadless,
14869
+ this.config._sc,
14870
+ this.config._rh
14837
14871
  );
14838
14872
  this.setupCommunication();
14839
14873
  await this.workerManager.createWorker();
14874
+ try {
14875
+ this.config.onRenderStart?.();
14876
+ } catch (e) {
14877
+ console.warn("[Viji] onRenderStart callback error:", e);
14878
+ }
14840
14879
  this.audioSystem = new AudioSystem((message) => {
14841
14880
  if (this.workerManager) {
14842
14881
  this.workerManager.postMessage(message.type, message.data);
@@ -14894,7 +14933,8 @@ class VijiCore {
14894
14933
  const effectiveResolution = this.iframeManager.getEffectiveResolution();
14895
14934
  this.workerManager.postMessage("resolution-update", {
14896
14935
  effectiveWidth: effectiveResolution.width,
14897
- effectiveHeight: effectiveResolution.height
14936
+ effectiveHeight: effectiveResolution.height,
14937
+ displayScale: this.iframeManager.getDisplayScale()
14898
14938
  });
14899
14939
  await this.detectScreenRefreshRate();
14900
14940
  this.workerManager.postMessage("refresh-rate-update", {
@@ -15633,7 +15673,8 @@ class VijiCore {
15633
15673
  const effectiveResolution = this.iframeManager.getEffectiveResolution();
15634
15674
  this.workerManager.postMessage("resolution-update", {
15635
15675
  effectiveWidth: effectiveResolution.width,
15636
- effectiveHeight: effectiveResolution.height
15676
+ effectiveHeight: effectiveResolution.height,
15677
+ displayScale: this.iframeManager.getDisplayScale()
15637
15678
  });
15638
15679
  this.stats.resolution = effectiveResolution;
15639
15680
  this.stats.scale = this.iframeManager.getScale();
@@ -16111,7 +16152,8 @@ class VijiCore {
16111
16152
  }
16112
16153
  this.workerManager.postMessage("resolution-update", {
16113
16154
  effectiveWidth: effectiveResolution.width,
16114
- effectiveHeight: effectiveResolution.height
16155
+ effectiveHeight: effectiveResolution.height,
16156
+ displayScale: this.iframeManager.getDisplayScale()
16115
16157
  });
16116
16158
  this.stats.resolution = effectiveResolution;
16117
16159
  this.debugLog(`Resolution: ${effectiveResolution.width}x${effectiveResolution.height}`);
@@ -16397,4 +16439,4 @@ export {
16397
16439
  VijiCoreError as b,
16398
16440
  getDefaultExportFromCjs as g
16399
16441
  };
16400
- //# sourceMappingURL=index-9YDi9UBP.js.map
16442
+ //# sourceMappingURL=index-CrmZANt9.js.map