@hyperframes/core 0.9.94 → 0.9.96
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/atomicFile.js +14 -9
- package/dist/audibleVideo.d.ts +10 -0
- package/dist/audibleVideo.js +37 -0
- package/dist/compiler/htmlBundler.js +2 -0
- package/dist/compiler/index.d.ts +1 -0
- package/dist/compiler/index.js +1 -0
- package/dist/compiler/inlineSubCompositions.js +2 -1
- package/dist/compositionSource.d.ts +1 -0
- package/dist/compositionSource.js +22 -1
- package/dist/generated/runtime-inline.js +1 -1
- package/dist/hyperframe.runtime.iife.js +67 -67
- package/dist/index.d.ts +1 -1
- package/dist/runtime/adapters/seek-dispatch.d.ts +40 -0
- package/dist/runtime/adapters/seek-dispatch.js +164 -0
- package/dist/runtime/assetUrl.d.ts +6 -0
- package/dist/runtime/assetUrl.js +8 -0
- package/dist/runtime/audioFx.d.ts +77 -0
- package/dist/runtime/audioFx.js +277 -0
- package/dist/runtime/bridge.d.ts +6 -0
- package/dist/runtime/bridge.js +20 -0
- package/dist/runtime/decodesFirst.d.ts +4 -0
- package/dist/runtime/decodesFirst.js +14 -0
- package/dist/runtime/drawnBox.d.ts +29 -0
- package/dist/runtime/drawnBox.js +100 -0
- package/dist/runtime/editingDraft.d.ts +0 -11
- package/dist/runtime/editingDraft.js +1 -61
- package/dist/runtime/editingElement.js +3 -3
- package/dist/runtime/editingGestureStart.d.ts +2 -6
- package/dist/runtime/editingGestureStart.js +1 -40
- package/dist/runtime/editingHandles.d.ts +4 -0
- package/dist/runtime/editingHandles.js +9 -0
- package/dist/runtime/editingPort.d.ts +5 -0
- package/dist/runtime/editingPort.js +5 -1
- package/dist/runtime/media.d.ts +113 -0
- package/dist/runtime/media.js +820 -0
- package/dist/runtime/mediaLoadFailure.d.ts +8 -0
- package/dist/runtime/mediaLoadFailure.js +58 -0
- package/dist/runtime/mediaProxy.d.ts +91 -0
- package/dist/runtime/mediaProxy.js +803 -0
- package/dist/runtime/playbackHealth.d.ts +31 -0
- package/dist/runtime/playbackHealth.js +137 -0
- package/dist/runtime/preloadMedia.d.ts +16 -0
- package/dist/runtime/preloadMedia.js +266 -0
- package/dist/runtime/previewCopies.d.ts +13 -0
- package/dist/runtime/previewCopies.js +80 -0
- package/dist/runtime/proxyWait.d.ts +3 -0
- package/dist/runtime/proxyWait.js +51 -0
- package/dist/runtime/runtimeLoad.d.ts +3 -0
- package/dist/runtime/runtimeLoad.js +13 -0
- package/dist/runtime/state.d.ts +7 -0
- package/dist/runtime/state.js +3 -0
- package/dist/runtime/timedClipHide.d.ts +12 -0
- package/dist/runtime/timedClipHide.js +94 -0
- package/dist/runtime/types.d.ts +29 -18
- package/dist/runtime/webAudioTransport.d.ts +241 -0
- package/dist/runtime/webAudioTransport.js +1162 -0
- package/dist/safePath.d.ts +2 -0
- package/dist/safePath.js +41 -13
- package/dist/studioPreviewMark.js +2 -4
- package/dist/utils/inlineTextStyleRead.js +2 -4
- package/package.json +16 -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 {};
|