@hyperframes/core 0.9.95 → 0.9.97

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.
Files changed (51) hide show
  1. package/dist/audibleVideo.d.ts +10 -0
  2. package/dist/audibleVideo.js +37 -0
  3. package/dist/generated/runtime-inline.js +1 -1
  4. package/dist/hyperframe.runtime.iife.js +67 -67
  5. package/dist/index.d.ts +1 -1
  6. package/dist/runtime/adapters/seek-dispatch.d.ts +40 -0
  7. package/dist/runtime/adapters/seek-dispatch.js +164 -0
  8. package/dist/runtime/assetUrl.d.ts +6 -0
  9. package/dist/runtime/assetUrl.js +8 -0
  10. package/dist/runtime/audioFx.d.ts +77 -0
  11. package/dist/runtime/audioFx.js +277 -0
  12. package/dist/runtime/bridge.d.ts +6 -0
  13. package/dist/runtime/bridge.js +20 -0
  14. package/dist/runtime/decodesFirst.d.ts +4 -0
  15. package/dist/runtime/decodesFirst.js +14 -0
  16. package/dist/runtime/editing/gsapSnapshot.js +12 -3
  17. package/dist/runtime/editing/gsapSnapshotLimits.d.ts +5 -3
  18. package/dist/runtime/editing/gsapSnapshotLimits.js +5 -3
  19. package/dist/runtime/editing/textCaret.d.ts +14 -0
  20. package/dist/runtime/editing/textCaret.js +98 -0
  21. package/dist/runtime/editing/textEdit.d.ts +8 -0
  22. package/dist/runtime/editing/textEdit.js +67 -10
  23. package/dist/runtime/editingPort.d.ts +3 -2
  24. package/dist/runtime/editingPort.js +2 -1
  25. package/dist/runtime/media.d.ts +113 -0
  26. package/dist/runtime/media.js +820 -0
  27. package/dist/runtime/mediaLoadFailure.d.ts +8 -0
  28. package/dist/runtime/mediaLoadFailure.js +58 -0
  29. package/dist/runtime/mediaProxy.d.ts +91 -0
  30. package/dist/runtime/mediaProxy.js +803 -0
  31. package/dist/runtime/playbackHealth.d.ts +31 -0
  32. package/dist/runtime/playbackHealth.js +137 -0
  33. package/dist/runtime/preloadMedia.d.ts +16 -0
  34. package/dist/runtime/preloadMedia.js +266 -0
  35. package/dist/runtime/previewCopies.d.ts +13 -0
  36. package/dist/runtime/previewCopies.js +80 -0
  37. package/dist/runtime/proxyWait.d.ts +3 -0
  38. package/dist/runtime/proxyWait.js +51 -0
  39. package/dist/runtime/runtimeLoad.d.ts +3 -0
  40. package/dist/runtime/runtimeLoad.js +13 -0
  41. package/dist/runtime/state.d.ts +7 -0
  42. package/dist/runtime/state.js +3 -0
  43. package/dist/runtime/timedClipHide.d.ts +12 -0
  44. package/dist/runtime/timedClipHide.js +94 -0
  45. package/dist/runtime/types.d.ts +29 -18
  46. package/dist/runtime/webAudioTransport.d.ts +243 -0
  47. package/dist/runtime/webAudioTransport.js +1176 -0
  48. package/dist/safePath.js +20 -11
  49. package/dist/terminalText.d.ts +1 -0
  50. package/dist/terminalText.js +17 -0
  51. package/package.json +12 -4
@@ -0,0 +1,8 @@
1
+ import { type MediaLoadStage } from "./protocol.js";
2
+ /** Tells the host once per element and stage that its media failed to load. `code` is the HTTP status of a fetch
3
+ * that answered or the element's MediaError code; `bytes` the size fetched before a decode failed. */
4
+ export declare function reportMediaLoadFailure(el: HTMLMediaElement, stage: MediaLoadStage, code: number | null, bytes?: number | null): void;
5
+ /** Reports each `<audio>` that fails to load; returns the cleanup. `error` does not bubble, so this listens in capture.
6
+ * A `<source>` child gets the error instead of its `<audio>`.
7
+ * Video is left out: mediaProxy answers a video's load error with a lighter copy, so it is not yet a failure. */
8
+ export declare function watchAudioLoadErrors(doc: Document): () => void;
@@ -0,0 +1,58 @@
1
+ import { postRuntimeMessage } from "./bridge.js";
2
+ import { unproxiedSrc } from "./proxySrc.js";
3
+ import { isAudioElement, isSourceElement } from "./domRealm.js";
4
+ import { isRenderMode } from "./mediaProxy.js";
5
+ import { RUNTIME_MEDIA_LOAD_FAILED } from "./protocol.js";
6
+ const reported = new WeakMap();
7
+ /** The file's extension, lower-cased, from the URL path; never its name. */
8
+ function extensionOf(el) {
9
+ const src = el.currentSrc || el.getAttribute("src") || "";
10
+ try {
11
+ const match = /\.([a-z0-9]{1,5})$/i.exec(new URL(src, document.baseURI).pathname);
12
+ return match?.[1]?.toLowerCase() ?? null;
13
+ }
14
+ catch {
15
+ return null;
16
+ }
17
+ }
18
+ /** Tells the host once per element and stage that its media failed to load. `code` is the HTTP status of a fetch
19
+ * that answered or the element's MediaError code; `bytes` the size fetched before a decode failed. */
20
+ export function reportMediaLoadFailure(el, stage, code, bytes = null) {
21
+ if (isRenderMode(el))
22
+ return;
23
+ const stages = reported.get(el) ?? new Set();
24
+ if (stages.has(stage))
25
+ return;
26
+ stages.add(stage);
27
+ reported.set(el, stages);
28
+ const asset = unproxiedSrc(el) ?? "";
29
+ const details = {
30
+ asset,
31
+ elementId: el.id || null,
32
+ kind: el.tagName.toLowerCase(),
33
+ stage,
34
+ code,
35
+ bytes,
36
+ extension: extensionOf(el),
37
+ };
38
+ postRuntimeMessage({
39
+ source: "hf-preview",
40
+ type: "diagnostic",
41
+ code: RUNTIME_MEDIA_LOAD_FAILED,
42
+ details,
43
+ });
44
+ console.info(`[hyperframes] ${RUNTIME_MEDIA_LOAD_FAILED}: "${asset}" failed at ${stage}${code === null ? "" : ` (${code})`}.`);
45
+ }
46
+ /** Reports each `<audio>` that fails to load; returns the cleanup. `error` does not bubble, so this listens in capture.
47
+ * A `<source>` child gets the error instead of its `<audio>`.
48
+ * Video is left out: mediaProxy answers a video's load error with a lighter copy, so it is not yet a failure. */
49
+ export function watchAudioLoadErrors(doc) {
50
+ const onError = (event) => {
51
+ const target = event.target;
52
+ const el = isSourceElement(target) ? target.parentElement : target;
53
+ if (isAudioElement(el))
54
+ reportMediaLoadFailure(el, "element", el.error?.code ?? null);
55
+ };
56
+ doc.addEventListener("error", onError, true);
57
+ return () => doc.removeEventListener("error", onError, true);
58
+ }
@@ -0,0 +1,91 @@
1
+ import { type PreviewQuality, type PreviewSourceFacts } from "../previewProxyBox.js";
2
+ /**
3
+ * One entry per project-root-relative asset pathname, injected by the
4
+ * server as `window.__HF_MEDIA_CODEC_MAP__` (see the plan's server-contract
5
+ * KTD). `representativeMime` is a coarse per-codec-family MIME string (e.g.
6
+ * `video/mp4; codecs="hvc1.1.6.L120.B0"` for hevc) fed to `canPlayType`;
7
+ * `null` when ffprobe couldn't produce one, in which case the browser check
8
+ * is skipped and `browserHostile` alone decides.
9
+ */
10
+ export type MediaCodecMapEntry = {
11
+ codecName: string;
12
+ browserHostile: boolean;
13
+ representativeMime: string | null;
14
+ /** Source carries an alpha channel and therefore needs a VP8/WebM proxy.
15
+ * Optional so pre-alpha-aware maps stay assignable; absent means "no alpha detected". */
16
+ hasAlpha?: boolean;
17
+ };
18
+ declare global {
19
+ interface Window {
20
+ __HF_MEDIA_CODEC_MAP__?: Record<string, MediaCodecMapEntry>;
21
+ }
22
+ }
23
+ type ProxyTrigger = "proactive" | "reactive" | "tertiary" | "light";
24
+ /** The host reports how large it shows this document; copies too small for it are replaced. */
25
+ export declare function setProxyDisplayScale(scale: number): void;
26
+ /**
27
+ * Render mode never proxies: the codec map arrives by injection (not a
28
+ * fetch, so determinism holds) but render always decodes the original via
29
+ * FFmpeg frame extraction, never a browser-side element. Mirrors the two
30
+ * render-mode signals already used elsewhere in the runtime — the global
31
+ * export-seek config (init.ts) and the per-element `__render_frame_<id>__`
32
+ * sibling image the producer's frame-injection pipeline creates during
33
+ * render (the same check `syncRuntimeMedia`'s `skipForInjectedVideo` makes
34
+ * in media.ts).
35
+ */
36
+ export declare function isRenderMode(el: HTMLMediaElement): boolean;
37
+ /** Each media tick re-decides a clip whose copy is still being made: the one on screen plays its own file, and every
38
+ * other, one that played its file and left the screen included, is held, so at most one oversized file decodes. */
39
+ export declare function decideFileTurn(el: HTMLMediaElement, onScreen: boolean): void;
40
+ export declare function swapToProxy(el: HTMLMediaElement, entry?: MediaCodecMapEntry | null, trigger?: ProxyTrigger, lightFacts?: PreviewSourceFacts): void;
41
+ /**
42
+ * Proactive trigger: consult the codec map before an element's first
43
+ * `load()` and swap ahead of time when the browser is known-unlikely to
44
+ * decode it, avoiding an error flash. `<audio>` is never proxied (per the
45
+ * plan's KTD — an HEVC container's AAC track demuxes fine regardless of the
46
+ * browser's video codec support).
47
+ */
48
+ export declare function maybeProxyProactively(el: HTMLMediaElement): void;
49
+ /** Each media pass: such a clip on screen shows the server's frame at the playhead; a capture waits for it. */
50
+ export declare function standInCaptureStill(el: HTMLMediaElement, onScreen: boolean): void;
51
+ /** The host's preview quality: below 1, heavy videos play lighter copies at the shown box times the level. */
52
+ export declare function setPreviewQuality(level: number): void;
53
+ /** The lower levels at which at least one video would get a lighter copy, by the same rule that makes them. */
54
+ export declare function levelsWithLighterCopies(): PreviewQuality[];
55
+ /** While on, makes those copies one at a time, starting none while `isBusy`. Off by default. */
56
+ export declare function setCopiesAhead(on: boolean, isBusy: () => boolean, isShown?: (el: HTMLMediaElement) => boolean): void;
57
+ /** The video files the composition plays, grouped by what they are, never by name. */
58
+ export declare function describeVideoSources(): Array<{
59
+ codec: string;
60
+ width: number;
61
+ height: number;
62
+ bitDepth: number;
63
+ count: number;
64
+ }>;
65
+ /** Asks again for the copies that failed, telling the server to forget why they did. */
66
+ export declare function retryPreviewCopies(): void;
67
+ /**
68
+ * Reactive trigger (the primary catch-all per the plan's KTD): a `<video>`
69
+ * reporting `videoWidth === 0` at `loadedmetadata` has an undecodable (or
70
+ * absent) video track — the common case for an HEVC+AAC file, which fires
71
+ * no error event because the AAC track satisfies the demuxer. Swaps once
72
+ * per element; if the element is already on its proxy src, the proxy
73
+ * itself is the one failing, so this only emits the failure diagnostic.
74
+ *
75
+ * No map, no swaps: the codec map global is only injected on surfaces where
76
+ * auto-proxying is enabled and served, so its absence means a `?hf-proxy=`
77
+ * request would 404 — never swap there. When the map is present but has no
78
+ * entry for this key, swapping stays allowed (unlisted-asset rescue). A
79
+ * mapped alpha entries select the VP8/WebM proxy variant.
80
+ */
81
+ export declare function handleMetadataForProxy(el: HTMLMediaElement): void;
82
+ /**
83
+ * Tertiary trigger: the `error` event, for the rarer zero-decodable-stream
84
+ * file (video-only hostile codec) where the demuxer has nothing to satisfy
85
+ * it and `loadedmetadata` never fires. Same guards and once-per-element
86
+ * behavior as the reactive path, plus one extra skip: an entry the scan
87
+ * mapped as browser-SAFE that still errors is a corrupt-but-safe file — an
88
+ * proxy of a broken source can't help, so only diagnose.
89
+ */
90
+ export declare function handleErrorForProxy(el: HTMLMediaElement): void;
91
+ export {};