@hyperframes/core 0.8.184 → 0.8.186

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/index.d.ts CHANGED
@@ -61,3 +61,4 @@ export { ITEM_TYPES, FILE_TYPES, ITEM_TYPE_DIRS, isExampleItem, isBlockItem, isC
61
61
  export { canaryBucket, evaluateCanary, parseCanaryOverride, type CanaryDecision, type CanaryInput, type CanaryReason, } from "./canary.js";
62
62
  export { CANARIES, canaryEnvVar, findCanary, overdueCanaries, type CanaryDefinition, } from "./canaryRegistry.js";
63
63
  export { HF_VFX_ATTR, HF_VFX_CHAIN_VERSION, HF_VFX, chainCapture, getVfxDef, parseVfxChain, serializeVfxChain, normalizeVfxParams, type HfVfxCapture, type HfVfxChain, type HfVfxDef, type HfVfxNode, type HfVfxParam, type HfVfxParamValues, } from "./vfx.js";
64
+ export { PAGE_DEVICE_SCALE_GLOBAL, PAGE_MOTION_BLUR_OFF_GLOBAL, acceleratedCanvasTrackerSource, } from "./pageMotionBlur.js";
package/dist/index.js CHANGED
@@ -64,3 +64,4 @@ export { canaryBucket, evaluateCanary, parseCanaryOverride, } from "./canary.js"
64
64
  export { CANARIES, canaryEnvVar, findCanary, overdueCanaries, } from "./canaryRegistry.js";
65
65
  // VFX chain (data-vfx-chain) — defs, chain parse/serialize/normalize
66
66
  export { HF_VFX_ATTR, HF_VFX_CHAIN_VERSION, HF_VFX, chainCapture, getVfxDef, parseVfxChain, serializeVfxChain, normalizeVfxParams, } from "./vfx.js";
67
+ export { PAGE_DEVICE_SCALE_GLOBAL, PAGE_MOTION_BLUR_OFF_GLOBAL, acceleratedCanvasTrackerSource, } from "./pageMotionBlur.js";
@@ -0,0 +1,11 @@
1
+ export declare const PAGE_MOTION_BLUR_OFF_GLOBAL = "__HF_PAGE_MOTION_BLUR_OFF__";
2
+ export declare const PAGE_DEVICE_SCALE_GLOBAL = "__HF_DEVICE_SCALE_FACTOR__";
3
+ export declare function supportsCaptureMotionBlur(win?: Window): boolean;
4
+ /**
5
+ * Remember canvases html-in-canvas cannot capture: WebGL, WebGPU, or handed to an OffscreenCanvas.
6
+ * Self-contained: the engine and the preview run its source ahead of every author script.
7
+ */
8
+ export declare function installAcceleratedCanvasTracker(): void;
9
+ export declare function isAcceleratedCanvas(canvas: HTMLCanvasElement): boolean;
10
+ /** The tracker as a script body, for `evaluateOnNewDocument` and inline `<script>` injection. */
11
+ export declare function acceleratedCanvasTrackerSource(): string;
@@ -0,0 +1,48 @@
1
+ import { htmlInCanvasForm } from "./htmlInCanvas.js";
2
+ // Engine-set: the off switch (its sub-frame blur runs, or the preview could not blur); the render scale (dpr falls back to 1).
3
+ export const PAGE_MOTION_BLUR_OFF_GLOBAL = "__HF_PAGE_MOTION_BLUR_OFF__";
4
+ export const PAGE_DEVICE_SCALE_GLOBAL = "__HF_DEVICE_SCALE_FACTOR__";
5
+ export function supportsCaptureMotionBlur(win = window) {
6
+ return htmlInCanvasForm(win) !== null;
7
+ }
8
+ const ACCELERATED_CANVASES_GLOBAL = "__hfAcceleratedCanvases";
9
+ /**
10
+ * Remember canvases html-in-canvas cannot capture: WebGL, WebGPU, or handed to an OffscreenCanvas.
11
+ * Self-contained: the engine and the preview run its source ahead of every author script.
12
+ */
13
+ export function installAcceleratedCanvasTracker() {
14
+ const key = "__hfAcceleratedCanvases";
15
+ const known = Reflect.get(window, key);
16
+ const seen = known instanceof WeakSet ? known : new WeakSet();
17
+ if (seen !== known)
18
+ Object.defineProperty(window, key, { value: seen });
19
+ const accelerated = ["webgl", "webgl2", "experimental-webgl", "webgpu"];
20
+ const wrap = (name, onCall) => {
21
+ const proto = HTMLCanvasElement.prototype;
22
+ const original = Reflect.get(proto, name);
23
+ if (typeof original !== "function" || "__hfAccelTracked" in original)
24
+ return;
25
+ const tracked = function (...args) {
26
+ const result = Reflect.apply(original, this, args);
27
+ onCall(this, args, result);
28
+ return result;
29
+ };
30
+ Object.defineProperty(tracked, "__hfAccelTracked", { value: true });
31
+ Object.defineProperty(proto, name, { value: tracked, writable: true, configurable: true });
32
+ };
33
+ wrap("getContext", (canvas, args, ctx) => {
34
+ if (ctx && accelerated.includes(String(args[0])))
35
+ seen.add(canvas);
36
+ });
37
+ wrap("transferControlToOffscreen", (canvas) => {
38
+ seen.add(canvas);
39
+ });
40
+ }
41
+ export function isAcceleratedCanvas(canvas) {
42
+ const seen = Reflect.get(window, ACCELERATED_CANVASES_GLOBAL);
43
+ return seen instanceof WeakSet && seen.has(canvas);
44
+ }
45
+ /** The tracker as a script body, for `evaluateOnNewDocument` and inline `<script>` injection. */
46
+ export function acceleratedCanvasTrackerSource() {
47
+ return `(${installAcceleratedCanvasTracker.toString()})();`;
48
+ }
@@ -1,11 +1,9 @@
1
1
  /**
2
2
  * The volume lane's gain for an element at a moment in its clip.
3
3
  *
4
- * Volume is not scheduled onto the gain AudioParam the way FX parameters are.
5
- * The runtime rewrites that gain every tick from `data-volume` and the GSAP
6
- * seeked value, which would erase a scheduled envelope within a frame — so the
7
- * lane feeds the same per-tick path the probed `volumeKeyframes` already use,
8
- * and the render still bakes it into the samples.
4
+ * Read per tick for a clip that sounds through `el.volume`. A clip the Web Audio
5
+ * transport routes plays its lane scheduled on a gain of its own
6
+ * (`attachClipStages`), out of reach of the per-tick gain write.
9
7
  */
10
8
  import { type HfAutomationLane } from "../audioAutomation.js";
11
9
  /** The lane for `target` inside a `data-automation` value, or null when absent or unreadable. */
@@ -1,11 +1,9 @@
1
1
  /**
2
2
  * The volume lane's gain for an element at a moment in its clip.
3
3
  *
4
- * Volume is not scheduled onto the gain AudioParam the way FX parameters are.
5
- * The runtime rewrites that gain every tick from `data-volume` and the GSAP
6
- * seeked value, which would erase a scheduled envelope within a frame — so the
7
- * lane feeds the same per-tick path the probed `volumeKeyframes` already use,
8
- * and the render still bakes it into the samples.
4
+ * Read per tick for a clip that sounds through `el.volume`. A clip the Web Audio
5
+ * transport routes plays its lane scheduled on a gain of its own
6
+ * (`attachClipStages`), out of reach of the per-tick gain write.
9
7
  */
10
8
  import { HF_AUDIO_AUTOMATION_ATTR, parseAutomation, sampleAutomationLane, VOLUME_TARGET, } from "../audioAutomation.js";
11
9
  /**
@@ -325,7 +325,8 @@ export function syncRuntimeMedia(params) {
325
325
  // there is one time base, and this is it.
326
326
  const laneGain = elementVolumeLaneGain(el, params.timeSeconds - origin);
327
327
  if (laneGain !== null) {
328
- authorVolume = clampAudioGain(laneGain);
328
+ const transportOwnsLane = params.isWebAudioRouted?.(el);
329
+ authorVolume = transportOwnsLane ? 1 : clampAudioGain(laneGain);
329
330
  }
330
331
  else if (clip.volumeKeyframes && clip.volumeKeyframes.length > 0) {
331
332
  // Keyframes probed from the GSAP timeline — same source as the renderer.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/core",
3
- "version": "0.8.184",
3
+ "version": "0.8.186",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -84,6 +84,10 @@
84
84
  "import": "./dist/keyframeDefaults.js",
85
85
  "types": "./dist/keyframeDefaults.d.ts"
86
86
  },
87
+ "./html-in-canvas": {
88
+ "import": "./dist/htmlInCanvas.js",
89
+ "types": "./dist/htmlInCanvas.d.ts"
90
+ },
87
91
  "./gsap-cdn": {
88
92
  "import": "./dist/gsapCdn.js",
89
93
  "types": "./dist/gsapCdn.d.ts"
@@ -381,9 +385,9 @@
381
385
  "linkedom": "^0.18.12",
382
386
  "postcss": "^8.5.8",
383
387
  "wawoff2": "^2.0.1",
384
- "@hyperframes/lint": "0.8.184",
385
- "@hyperframes/studio-server": "0.8.184",
386
- "@hyperframes/parsers": "0.8.184"
388
+ "@hyperframes/lint": "0.8.186",
389
+ "@hyperframes/studio-server": "0.8.186",
390
+ "@hyperframes/parsers": "0.8.186"
387
391
  },
388
392
  "devDependencies": {
389
393
  "@fontsource/archivo-black": "^5.2.8",