@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.
- package/dist/audibleVideo.d.ts +10 -0
- package/dist/audibleVideo.js +37 -0
- 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/editing/gsapSnapshot.js +12 -3
- package/dist/runtime/editing/gsapSnapshotLimits.d.ts +5 -3
- package/dist/runtime/editing/gsapSnapshotLimits.js +5 -3
- package/dist/runtime/editing/textCaret.d.ts +14 -0
- package/dist/runtime/editing/textCaret.js +98 -0
- package/dist/runtime/editing/textEdit.d.ts +8 -0
- package/dist/runtime/editing/textEdit.js +67 -10
- package/dist/runtime/editingPort.d.ts +3 -2
- package/dist/runtime/editingPort.js +2 -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 +243 -0
- package/dist/runtime/webAudioTransport.js +1176 -0
- package/dist/safePath.js +20 -11
- package/dist/terminalText.d.ts +1 -0
- package/dist/terminalText.js +17 -0
- package/package.json +12 -4
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { CLIP_HIDDEN_ATTR, olderShaderBuildOnPage, revealClip } from "./clipReveal.js";
|
|
2
|
+
import { capturePageIn, defersMediaIn, RUNTIME_STAMPED_ATTR, STUDIO_PREVIEW_MARK_META, STUDIO_PREVIEW_UPCOMING_ATTR, } from "../studioPreviewMark.js";
|
|
3
|
+
// Hides timed non-media clips from script evaluation until the first visibility pass decides them;
|
|
4
|
+
// before it, a paused page painted every clip at once. Media is left to init's media pass.
|
|
5
|
+
// The rule and its flag live on the page, so every runtime copy shares them.
|
|
6
|
+
const HIDE_ATTR = "data-hf-first-pass-hide";
|
|
7
|
+
const HIDE_UNTIL_FIRST_PASS = "[data-start]:not(video, audio, img) { visibility: hidden !important; }";
|
|
8
|
+
const PREVIEW_HIDE_UNTIL_FIRST_PASS = 'img[loading="lazy"] { display: none !important; }';
|
|
9
|
+
const SKIP_ATTR = "data-hf-skip-hidden-images";
|
|
10
|
+
export { CLIP_HIDDEN_ATTR };
|
|
11
|
+
const SKIPPABLE_CLIP = `[data-start]:not(video, audio, img, [${STUDIO_PREVIEW_UPCOMING_ATTR}], [${RUNTIME_STAMPED_ATTR}])`;
|
|
12
|
+
export const SKIPPED_CLIP = `${SKIPPABLE_CLIP}[${CLIP_HIDDEN_ATTR}]`;
|
|
13
|
+
const STUDIO_PREVIEW_MARK = `meta[name="${STUDIO_PREVIEW_MARK_META}"]`;
|
|
14
|
+
const CONTENTS_ATTR = "data-hf-hidden-clip-contents";
|
|
15
|
+
const HIDDEN_CLIP_DOUBLED_FOR_WEIGHT = `[${CLIP_HIDDEN_ATTR}][${CLIP_HIDDEN_ATTR}]`;
|
|
16
|
+
const HIDDEN_CLIP_BY_INLINE_STYLE = `[${CLIP_HIDDEN_ATTR}][style*="visibility: hidden"]`;
|
|
17
|
+
const skipHiddenImages = (clip) => `${SKIPPABLE_CLIP}${clip} img { display: none !important; }`;
|
|
18
|
+
const LAYER_OUTRANKING_UNLAYERED_IMPORTANT = "hf-hidden-clip";
|
|
19
|
+
const hideHiddenClipContents = (clip) => {
|
|
20
|
+
const filterOutputLayers = [clip, `${clip} *`]
|
|
21
|
+
.flatMap((layer) => [layer, `${layer}::before`, `${layer}::after`])
|
|
22
|
+
.join(", ");
|
|
23
|
+
const rules = `${clip} * { visibility: hidden !important; } ${filterOutputLayers} { filter: none !important; }`;
|
|
24
|
+
return `${rules} @layer ${LAYER_OUTRANKING_UNLAYERED_IMPORTANT} { ${rules} }`;
|
|
25
|
+
};
|
|
26
|
+
export function showHiddenClips(only = () => true) {
|
|
27
|
+
return showClips(Array.from(document.querySelectorAll(`[${CLIP_HIDDEN_ATTR}]`)).filter(only));
|
|
28
|
+
}
|
|
29
|
+
export function showClips(hidden) {
|
|
30
|
+
const putMarksBack = hidden.map((el) => revealClip(el));
|
|
31
|
+
return () => {
|
|
32
|
+
for (const el of hidden) {
|
|
33
|
+
if (el.style.getPropertyValue("visibility") !== "hidden")
|
|
34
|
+
el.style.setProperty("visibility", "hidden", "important");
|
|
35
|
+
}
|
|
36
|
+
for (const putMarkBack of putMarksBack)
|
|
37
|
+
putMarkBack();
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function appendStyle(parent, attr, css) {
|
|
41
|
+
const style = document.createElement("style");
|
|
42
|
+
style.setAttribute(attr, "");
|
|
43
|
+
style.textContent = css;
|
|
44
|
+
parent.appendChild(style);
|
|
45
|
+
}
|
|
46
|
+
export function defersMedia() {
|
|
47
|
+
return defersMediaIn(document);
|
|
48
|
+
}
|
|
49
|
+
/** True in Studio's preview, where hidden clips' images are neither fetched nor decoded until due. */
|
|
50
|
+
export function skipsHiddenImages() {
|
|
51
|
+
return document.querySelector(`style[${SKIP_ATTR}]`) !== null;
|
|
52
|
+
}
|
|
53
|
+
export function hideTimedClipsUntilFirstPass() {
|
|
54
|
+
if (typeof document === "undefined")
|
|
55
|
+
return;
|
|
56
|
+
const parent = document.head ?? document.documentElement;
|
|
57
|
+
if (!parent)
|
|
58
|
+
return;
|
|
59
|
+
const preview = document.querySelector(STUDIO_PREVIEW_MARK) !== null;
|
|
60
|
+
const capture = capturePageIn(document);
|
|
61
|
+
if (preview && !capture && !skipsHiddenImages())
|
|
62
|
+
appendStyle(parent, SKIP_ATTR, skipHiddenImages(HIDDEN_CLIP_DOUBLED_FOR_WEIGHT));
|
|
63
|
+
if (!document.querySelector(`style[${CONTENTS_ATTR}]`))
|
|
64
|
+
appendStyle(parent, CONTENTS_ATTR, hideHiddenClipContents(HIDDEN_CLIP_DOUBLED_FOR_WEIGHT));
|
|
65
|
+
const win = window;
|
|
66
|
+
// A runtime that already initialised may never run another pass to lift a new rule.
|
|
67
|
+
if (win.__hfFirstPassHidden || win.__hyperframeRuntimeBootstrapped)
|
|
68
|
+
return;
|
|
69
|
+
const css = preview
|
|
70
|
+
? `${HIDE_UNTIL_FIRST_PASS} ${PREVIEW_HIDE_UNTIL_FIRST_PASS}`
|
|
71
|
+
: HIDE_UNTIL_FIRST_PASS;
|
|
72
|
+
appendStyle(parent, HIDE_ATTR, css);
|
|
73
|
+
win.__hfFirstPassHidden = true;
|
|
74
|
+
}
|
|
75
|
+
/** True when this call lifted the rule; callers then re-register what skipped hidden elements (grading). */
|
|
76
|
+
export function revealTimedClipsAfterFirstPass() {
|
|
77
|
+
const win = window;
|
|
78
|
+
if (!win.__hfFirstPassHidden)
|
|
79
|
+
return false;
|
|
80
|
+
win.__hfFirstPassHidden = false;
|
|
81
|
+
for (const style of document.querySelectorAll(`style[${HIDE_ATTR}]`))
|
|
82
|
+
style.remove();
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
export function keepInlineHideRulesForOlderShaders() {
|
|
86
|
+
if (!olderShaderBuildOnPage())
|
|
87
|
+
return;
|
|
88
|
+
const skip = document.querySelector(`style[${SKIP_ATTR}]`);
|
|
89
|
+
if (skip)
|
|
90
|
+
skip.textContent = skipHiddenImages(HIDDEN_CLIP_BY_INLINE_STYLE);
|
|
91
|
+
const contents = document.querySelector(`style[${CONTENTS_ATTR}]`);
|
|
92
|
+
if (contents)
|
|
93
|
+
contents.textContent = hideHiddenClipContents(HIDDEN_CLIP_BY_INLINE_STYLE);
|
|
94
|
+
}
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type RuntimeJson = string | number | boolean | null | RuntimeJson[] | {
|
|
|
12
12
|
import type { HyperframeControlAction } from "../inline-scripts/runtimeContract.js";
|
|
13
13
|
import type { HyperframePickerElementInfo } from "../inline-scripts/pickerApi.js";
|
|
14
14
|
import type { RuntimeProtocolV1 } from "./protocol.js";
|
|
15
|
-
type RuntimeBridgeControlActionBase = HyperframeControlAction | "tick" | "set-volume" | "set-media-output-muted" | "set-native-media-sync-disabled" | "set-web-audio-media-disabled" | "set-idle-heartbeat" | "set-display-scale" | "set-preview-quality" | "set-copies-ahead" | "retry-preview-copies" | "request-preview-facts" | "set-root-duration" | "set-play-range" | "stop-media" | "flash-elements" | "scrub-audio";
|
|
15
|
+
type RuntimeBridgeControlActionBase = HyperframeControlAction | "tick" | "set-volume" | "set-media-output-muted" | "set-native-media-sync-disabled" | "set-web-audio-media-disabled" | "set-idle-heartbeat" | "set-display-scale" | "set-preview-quality" | "set-copies-ahead" | "retry-preview-copies" | "request-preview-facts" | "set-root-duration" | "set-play-range" | "stop-media" | "flash-elements" | "scrub-audio" | "set-parent-audio" | "audio-clock";
|
|
16
16
|
type RuntimeBridgeControlMessageBase = {
|
|
17
17
|
source: "hf-parent";
|
|
18
18
|
type: "control";
|
|
@@ -35,6 +35,9 @@ type RuntimeBridgeControlMessageBase = {
|
|
|
35
35
|
grading?: RuntimeJson;
|
|
36
36
|
compare?: RuntimeJson;
|
|
37
37
|
seekMode?: "drag" | "commit";
|
|
38
|
+
clips?: string[];
|
|
39
|
+
rate?: number;
|
|
40
|
+
at?: number;
|
|
38
41
|
};
|
|
39
42
|
export type RuntimeStateMessage = {
|
|
40
43
|
source: "hf-preview";
|
|
@@ -168,6 +171,12 @@ export type RuntimeMediaAutoplayBlockedMessage = {
|
|
|
168
171
|
type: "media-autoplay-blocked";
|
|
169
172
|
media: ParentCopy[];
|
|
170
173
|
};
|
|
174
|
+
/** The same list, asked for by a parent that plays the film's audio from decoded buffers (`set-parent-audio`). */
|
|
175
|
+
export type RuntimeParentCopiesMessage = {
|
|
176
|
+
source: "hf-preview";
|
|
177
|
+
type: "parent-copies";
|
|
178
|
+
media: ParentCopy[];
|
|
179
|
+
};
|
|
171
180
|
/**
|
|
172
181
|
* Posted by the runtime when `installRuntimeControlBridge` finishes registering
|
|
173
182
|
* its message listener — signals that subsequent control messages
|
|
@@ -260,25 +269,27 @@ export type PlaybackHeldBy = {
|
|
|
260
269
|
networkState: number;
|
|
261
270
|
fetchMs: number | FetchNotSeenToStart;
|
|
262
271
|
};
|
|
272
|
+
/** How playback went over the last few seconds of play. */
|
|
273
|
+
export type PlaybackHealthReport = {
|
|
274
|
+
droppedShare: number;
|
|
275
|
+
seconds: number;
|
|
276
|
+
choppy: boolean;
|
|
277
|
+
fps: number;
|
|
278
|
+
worstFrameMs: number;
|
|
279
|
+
skippedShare: number;
|
|
280
|
+
waitingShare: number;
|
|
281
|
+
frozenShare: number;
|
|
282
|
+
gapP50Ms: number;
|
|
283
|
+
gapP95Ms: number;
|
|
284
|
+
clockSource: "audio" | "webaudio" | "monotonic";
|
|
285
|
+
heldBy: PlaybackHeldBy | null;
|
|
286
|
+
mode: "play";
|
|
287
|
+
};
|
|
263
288
|
export type RuntimePreviewHealthMessage = {
|
|
264
289
|
source: "hf-preview";
|
|
265
290
|
type: "preview-health";
|
|
266
|
-
/**
|
|
267
|
-
health:
|
|
268
|
-
droppedShare: number;
|
|
269
|
-
seconds: number;
|
|
270
|
-
choppy: boolean;
|
|
271
|
-
fps: number;
|
|
272
|
-
worstFrameMs: number;
|
|
273
|
-
skippedShare: number;
|
|
274
|
-
waitingShare: number;
|
|
275
|
-
frozenShare: number;
|
|
276
|
-
gapP50Ms: number;
|
|
277
|
-
gapP95Ms: number;
|
|
278
|
-
clockSource: "audio" | "webaudio" | "monotonic";
|
|
279
|
-
heldBy: PlaybackHeldBy | null;
|
|
280
|
-
mode: "play";
|
|
281
|
-
} | null;
|
|
291
|
+
/** Null while paused, seeking or warming up. */
|
|
292
|
+
health: PlaybackHealthReport | null;
|
|
282
293
|
};
|
|
283
294
|
export type RuntimePreviewFactsMessage = {
|
|
284
295
|
source: "hf-preview";
|
|
@@ -299,7 +310,7 @@ export type RuntimePreviewFactsMessage = {
|
|
|
299
310
|
copiesReady: boolean;
|
|
300
311
|
};
|
|
301
312
|
};
|
|
302
|
-
export type RuntimeOutboundMessage = RuntimeStateMessage | RuntimePreviewCopiesMessage | RuntimePreviewHealthMessage | RuntimePreviewFactsMessage | RuntimeTimelineMessage | RuntimeDiagnosticMessage | RuntimePickerHoveredMessage | RuntimePickerCandidatesMessage | RuntimePickerPickedMessage | RuntimePickerPickedManyMessage | RuntimePickerCancelledMessage | RuntimeStageSizeMessage | RuntimeStaticCompositionMessage | RuntimeMediaAutoplayBlockedMessage | RuntimeReadyMessage | RuntimeAssetsReadyMessage | RuntimeDataErrorMessage | RuntimeDataAppliedMessage | RuntimeAnalyticsMessage | RuntimePerformanceMessage | RuntimeGroupLevelsMessage;
|
|
313
|
+
export type RuntimeOutboundMessage = RuntimeStateMessage | RuntimePreviewCopiesMessage | RuntimePreviewHealthMessage | RuntimePreviewFactsMessage | RuntimeTimelineMessage | RuntimeDiagnosticMessage | RuntimePickerHoveredMessage | RuntimePickerCandidatesMessage | RuntimePickerPickedMessage | RuntimePickerPickedManyMessage | RuntimePickerCancelledMessage | RuntimeStageSizeMessage | RuntimeStaticCompositionMessage | RuntimeMediaAutoplayBlockedMessage | RuntimeParentCopiesMessage | RuntimeReadyMessage | RuntimeAssetsReadyMessage | RuntimeDataErrorMessage | RuntimeDataAppliedMessage | RuntimeAnalyticsMessage | RuntimePerformanceMessage | RuntimeGroupLevelsMessage;
|
|
303
314
|
export type HeldSeek = Promise<void> | void;
|
|
304
315
|
export type RuntimePlayer = {
|
|
305
316
|
_timeline: RuntimeTimelineLike | null;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { type ElementFxHandle } from "./audioFx.js";
|
|
2
|
+
import { type AutomationTiming } from "../audio/audioFxAutomation.js";
|
|
3
|
+
import { type StereoLevel } from "./levelTap.js";
|
|
4
|
+
type BookedFades = {
|
|
5
|
+
node: GainNode;
|
|
6
|
+
rebook(timing: AutomationTiming): void;
|
|
7
|
+
};
|
|
8
|
+
type ScheduledSourceBase = {
|
|
9
|
+
el: HTMLMediaElement;
|
|
10
|
+
gainNode: GainNode;
|
|
11
|
+
/** The clip's volume lane, between its FX and `gainNode`; unity when it has none. */
|
|
12
|
+
laneNode: GainNode;
|
|
13
|
+
/** `data-volume` as clip gain, between the source and its FX. */
|
|
14
|
+
clipGainNode: GainNode;
|
|
15
|
+
/** FX chain spliced between source and gain, when the element carries one. */
|
|
16
|
+
fx?: ElementFxHandle | null;
|
|
17
|
+
/** The clip's fades booked on the audio clock, between the source and its clip gain; absent without a fade. */
|
|
18
|
+
fades?: BookedFades | null;
|
|
19
|
+
/** Stops re-aiming the lane and fades at a routed element's own position. */
|
|
20
|
+
unfollow?: () => void;
|
|
21
|
+
/** A routed element's first stage: unity except while `seekUnderDip` hides a seek. */
|
|
22
|
+
dipNode?: GainNode;
|
|
23
|
+
dipping?: boolean;
|
|
24
|
+
compositionStart: number;
|
|
25
|
+
mediaStart: number;
|
|
26
|
+
scheduledAt: number;
|
|
27
|
+
priorMuted: boolean;
|
|
28
|
+
priorVolume: number;
|
|
29
|
+
mediaPlaybackRate: number;
|
|
30
|
+
bounded: boolean;
|
|
31
|
+
};
|
|
32
|
+
export type ScheduledSource = ScheduledSourceBase & ({
|
|
33
|
+
sourceKind: "buffer";
|
|
34
|
+
sourceNode: AudioBufferSourceNode;
|
|
35
|
+
} | {
|
|
36
|
+
sourceKind: "media-element";
|
|
37
|
+
sourceNode: MediaElementAudioSourceNode;
|
|
38
|
+
});
|
|
39
|
+
export declare class WebAudioTransport {
|
|
40
|
+
/** Request options for every decode fetch, over `cache: "no-store"`. */
|
|
41
|
+
private readonly _fetchInit;
|
|
42
|
+
/** Aborted by `destroy()`, so a fetch or decode still in flight reports and keeps nothing for a gone player. */
|
|
43
|
+
private _fetches;
|
|
44
|
+
private readonly _busDocument;
|
|
45
|
+
private _givenContext;
|
|
46
|
+
private _ctx;
|
|
47
|
+
private _bufferCache;
|
|
48
|
+
private _decoding;
|
|
49
|
+
private _pendingDecodeBytes;
|
|
50
|
+
private _failedSrcs;
|
|
51
|
+
private _mediaElementSources;
|
|
52
|
+
private _handedOver;
|
|
53
|
+
private _activeSources;
|
|
54
|
+
private _masterGain;
|
|
55
|
+
/** Where the master bus chain lands; the program meter taps here. */
|
|
56
|
+
private _busOut;
|
|
57
|
+
/** The chain on the composition root, built on first schedule and kept for the session. */
|
|
58
|
+
private _master;
|
|
59
|
+
/** Preview volume and mute. Downstream of `_masterGain`; meters tap the program. */
|
|
60
|
+
private _monitorGain;
|
|
61
|
+
private _masterVolume;
|
|
62
|
+
private _masterMuted;
|
|
63
|
+
private _groups;
|
|
64
|
+
private _metering;
|
|
65
|
+
private _masterTap;
|
|
66
|
+
private _groupTaps;
|
|
67
|
+
private _rateAnchorCtx;
|
|
68
|
+
private _rateAnchorComp;
|
|
69
|
+
private _rate;
|
|
70
|
+
private _paused;
|
|
71
|
+
private _playGeneration;
|
|
72
|
+
private _playingCaptured;
|
|
73
|
+
private _suspendPending;
|
|
74
|
+
private _restTimer;
|
|
75
|
+
init(): Promise<boolean>;
|
|
76
|
+
/** `context`: one the caller opened inside a tap, which Safari only lets sound when made there. */
|
|
77
|
+
constructor(opts?: {
|
|
78
|
+
fetchInit?: RequestInit;
|
|
79
|
+
busDocument?: Document | null;
|
|
80
|
+
context?: AudioContext;
|
|
81
|
+
});
|
|
82
|
+
/** Builds the context on the calling thread: on Windows that opens the audio device and can block seconds. */
|
|
83
|
+
open(): boolean;
|
|
84
|
+
private wake;
|
|
85
|
+
private rest;
|
|
86
|
+
private suspendIfIdle;
|
|
87
|
+
get context(): AudioContext | null;
|
|
88
|
+
getTime(): number;
|
|
89
|
+
/** Drops decoded audio no listed element still points at. A playing source holds its own buffer. */
|
|
90
|
+
releaseDecodedExcept(els: readonly HTMLMediaElement[]): void;
|
|
91
|
+
/** One fetch and decode per source at a time: a play and a seek scheduling together share it. */
|
|
92
|
+
decodeAudioElement(el: HTMLMediaElement): Promise<AudioBuffer | null>;
|
|
93
|
+
fitsDecodeBudget(el: HTMLMediaElement): boolean;
|
|
94
|
+
private estimateDecodedBytes;
|
|
95
|
+
private decodedBytes;
|
|
96
|
+
/** Whether its length was read, for a source that has not failed for good and is not too long to decode. */
|
|
97
|
+
private mayDecode;
|
|
98
|
+
private fetchBytes;
|
|
99
|
+
private fetchAndDecode;
|
|
100
|
+
private decode;
|
|
101
|
+
startGeneration(): number;
|
|
102
|
+
currentGeneration(): number;
|
|
103
|
+
/**
|
|
104
|
+
* The element's cached MediaElementAudioSourceNode, building it on first use
|
|
105
|
+
* — or `null` when this element must not be captured at all.
|
|
106
|
+
*
|
|
107
|
+
* That second outcome is the whole point. `createMediaElementSource` cannot
|
|
108
|
+
* report that it produced a silent node: over a CORS-cross-origin resource
|
|
109
|
+
* the Web Audio spec asks the node for SILENCE rather than an exception, so
|
|
110
|
+
* the caller's `try/catch` never fires and the composition plays through
|
|
111
|
+
* with no audio and no error (#3458). The call also permanently reroutes the
|
|
112
|
+
* element away from its native output, so the question has to be settled
|
|
113
|
+
* before it, and there is no undo afterwards.
|
|
114
|
+
*
|
|
115
|
+
* `init.ts` routes on the same verdict before ever calling in, and
|
|
116
|
+
* `AudioRow.tsx`'s standalone preview player classifies over its own
|
|
117
|
+
* throwaway `AudioContext` before its own `createMediaElementSource` call —
|
|
118
|
+
* this method is A enforcement point, not THE enforcement point; every
|
|
119
|
+
* caller that can reach `createMediaElementSource` is expected to classify
|
|
120
|
+
* first. What this method DOES own is the cache below: `_mediaElementSources`
|
|
121
|
+
* is keyed by element identity, not by asset, so a cache hit alone says
|
|
122
|
+
* nothing about the element's CURRENT resource. Reclassifying on every call
|
|
123
|
+
* — cache hit included — means a `src` mutation an outer caller missed (a
|
|
124
|
+
* pooled element swapped from a same-origin clip to a cross-origin one
|
|
125
|
+
* without going through a fresh generation) can't leave a stale
|
|
126
|
+
* `web-audio` verdict silently attached to the new resource.
|
|
127
|
+
*/
|
|
128
|
+
private acquireMediaElementSource;
|
|
129
|
+
/**
|
|
130
|
+
* Route the browser's pitch-preserving HTMLMediaElement transport through the
|
|
131
|
+
* same FX, automation, element-gain, and master graph used by final audio.
|
|
132
|
+
* The media element remains the source-time/rate owner; Web Audio is strictly
|
|
133
|
+
* downstream and therefore never resamples it for Studio global speed.
|
|
134
|
+
*/
|
|
135
|
+
scheduleMediaElementPlayback(el: HTMLMediaElement, compositionStart: number, mediaStart: number, compositionTime: number, volume: number, generation: number, rate?: number, clipDuration?: number): Promise<ScheduledSource | null>;
|
|
136
|
+
/**
|
|
137
|
+
* A routed element keeps its own time: it starts late, is seeked and is steered by rate. Its lane and fades were
|
|
138
|
+
* booked against the context clock, so each time it starts or moves they are re-aimed at where it actually is.
|
|
139
|
+
*/
|
|
140
|
+
private followElement;
|
|
141
|
+
/**
|
|
142
|
+
* Seek a sounding routed element under a short gain dip: down, seek, and back up once it has landed, so the jump
|
|
143
|
+
* is neither a click nor a tempo change. False when the element is not routed and has no dip to hide it under.
|
|
144
|
+
*/
|
|
145
|
+
seekUnderDip(el: HTMLMediaElement, target: number): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* The gain a grouped member's signal should land on, building it on first
|
|
148
|
+
* use. A group's clock is COMPOSITION time (design doc §1.3) — it has no
|
|
149
|
+
* `data-start`, and a missing start parses as 0, which is exactly
|
|
150
|
+
* composition time — so its chain and volume lane are scheduled once here
|
|
151
|
+
* against that zero-offset timing, not the member's own clip-local timing.
|
|
152
|
+
* A group id with no matching `<hf-audio-group>` element still gets a bus
|
|
153
|
+
* (flat, no chain) so a hand-authored `data-audio-group` degrades to a
|
|
154
|
+
* plain sum rather than losing the member's audio.
|
|
155
|
+
*/
|
|
156
|
+
private groupInput;
|
|
157
|
+
startMetering(): void;
|
|
158
|
+
stopMetering(): void;
|
|
159
|
+
readLevels(): {
|
|
160
|
+
master: StereoLevel;
|
|
161
|
+
groups: Record<string, StereoLevel>;
|
|
162
|
+
};
|
|
163
|
+
private attachMasterTap;
|
|
164
|
+
private attachGroupTap;
|
|
165
|
+
/**
|
|
166
|
+
* Group mute, preview side — a separate gain from `input`'s volume fader
|
|
167
|
+
* so a mute toggle never fights `scheduleVolume`'s ramps on the
|
|
168
|
+
* same param (the same hazard the design doc flags for §2.1). A no-op
|
|
169
|
+
* until the group has an active member: at that point `groupInput` reads
|
|
170
|
+
* the element's own `data-hidden` for its initial value, so there is
|
|
171
|
+
* nothing to catch up on here.
|
|
172
|
+
*/
|
|
173
|
+
setGroupMuted(groupId: string, muted: boolean): void;
|
|
174
|
+
/**
|
|
175
|
+
* The master bus chain, between the sum of every clip and group and the monitor.
|
|
176
|
+
* A seek re-anchors it once per play generation; no root yet is retried next schedule.
|
|
177
|
+
*/
|
|
178
|
+
private ensureMasterBus;
|
|
179
|
+
/** Master, unless `el` belongs to a group — then that group's bus (built on
|
|
180
|
+
* first use, per `groupInput`). */
|
|
181
|
+
private resolveDestination;
|
|
182
|
+
/**
|
|
183
|
+
* The graph goes with it. Splicing alone left the FX handle alive and then
|
|
184
|
+
* UNREACHABLE — `stopAll()` disposes by walking `_activeSources`, which the
|
|
185
|
+
* splice just emptied of this entry. Every clip that finished naturally
|
|
186
|
+
* leaked its MutationObserver for the session, and each one still answered
|
|
187
|
+
* later `data-fx-chain` edits by rebuilding a whole graph (impulse response,
|
|
188
|
+
* chorus/phaser oscillators started and never stopped) around a dead
|
|
189
|
+
* source. Not disposed when the index is already -1: `stopAll()` has
|
|
190
|
+
* already done it, and `stop()` is what fired this event.
|
|
191
|
+
*/
|
|
192
|
+
private handleSourceEnded;
|
|
193
|
+
schedulePlayback(el: HTMLMediaElement, buffer: AudioBuffer, compositionStart: number, mediaStart: number, readCompositionTime: () => number, volume: number, generation: number, rate?: number, clipDuration?: number, windowStart?: number): Promise<ScheduledSource | null>;
|
|
194
|
+
/** Drops the routed element's source once a decoded buffer plays in its place; it stays silent until a stop. */
|
|
195
|
+
releaseRouted(el: HTMLMediaElement): void;
|
|
196
|
+
/** A decoded buffer plays what an element carried: it cannot hold pitch through a speed change. */
|
|
197
|
+
hasHandedOverSources(): boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Rebases the composition-time reference frame before swapping rate so
|
|
200
|
+
* `getTime()` stays continuous across the change. Sources scheduled to
|
|
201
|
+
* start in the future keep their original wallclock start time — callers
|
|
202
|
+
* that need rate-correct future starts should `stopAll()` and reschedule.
|
|
203
|
+
*
|
|
204
|
+
* Each decoded source's FX automation is re-aimed too. Lanes are committed to
|
|
205
|
+
* absolute context times when the source is scheduled, so bumping only
|
|
206
|
+
* `playbackRate` left every automated parameter running its original plan
|
|
207
|
+
* over audio moving at a different speed. The `stopAll()`+reschedule recovery
|
|
208
|
+
* in the runtime is no help here: it only fires for bounded sources, and a
|
|
209
|
+
* project-level music bed with no `data-duration` is unbounded, so it never
|
|
210
|
+
* recovered at all.
|
|
211
|
+
*/
|
|
212
|
+
setRate(rate: number): boolean;
|
|
213
|
+
private setBusRate;
|
|
214
|
+
hasBoundedActiveSources(): boolean;
|
|
215
|
+
stopAll(): void;
|
|
216
|
+
private reconnectHandedOver;
|
|
217
|
+
/** Stops what plays from media gone from the page, without sending it to the destination as a stop does. */
|
|
218
|
+
releaseDetached(): void;
|
|
219
|
+
private dispose;
|
|
220
|
+
setVolume(volume: number): void;
|
|
221
|
+
/**
|
|
222
|
+
* The per-element gain carries the clip's AUTHOR gain, which reaches
|
|
223
|
+
* MAX_AUDIO_GAIN — so it is clamped against that ceiling, not the spec's
|
|
224
|
+
* [0,1]. `setVolume` above is the opposite case and stays spec-clamped: the
|
|
225
|
+
* user's master volume is a fader, not a gain.
|
|
226
|
+
*
|
|
227
|
+
* Clamping this one at unity capped every static above-unity `data-volume` on
|
|
228
|
+
* the preview path while the render honoured it — the exact preview/render
|
|
229
|
+
* divergence this ceiling exists to close. Automation lanes hid it, because
|
|
230
|
+
* they schedule ramps onto the param directly and never pass through here.
|
|
231
|
+
*/
|
|
232
|
+
setElementVolume(el: HTMLMediaElement, volume: number, clipGain?: number, unfadedVolume?: number): void;
|
|
233
|
+
setMuted(muted: boolean): void;
|
|
234
|
+
private applyMasterGain;
|
|
235
|
+
ownsClock(): boolean;
|
|
236
|
+
/** Whether the transport currently plays THIS element (the runtime mutes it to
|
|
237
|
+
* avoid double audio; an unclaimed track stays audible). */
|
|
238
|
+
ownsElement(el: HTMLMediaElement): boolean;
|
|
239
|
+
/** Whether this element's native signal currently flows through the WebAudio graph. */
|
|
240
|
+
routesElement(el: HTMLMediaElement): boolean;
|
|
241
|
+
destroy(): void;
|
|
242
|
+
}
|
|
243
|
+
export {};
|