@hyperframes/core 0.8.58 → 0.8.60

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 (35) hide show
  1. package/dist/audioFade.d.ts +24 -0
  2. package/dist/audioFade.d.ts.map +1 -0
  3. package/dist/audioFade.js +56 -0
  4. package/dist/audioFade.js.map +1 -0
  5. package/dist/audioGain.d.ts +4 -0
  6. package/dist/audioGain.d.ts.map +1 -1
  7. package/dist/audioGain.js +12 -4
  8. package/dist/audioGain.js.map +1 -1
  9. package/dist/compositionReadiness.d.ts +12 -3
  10. package/dist/compositionReadiness.d.ts.map +1 -1
  11. package/dist/compositionReadiness.js +49 -5
  12. package/dist/compositionReadiness.js.map +1 -1
  13. package/dist/generated/audio-fx-runtime-inline.js +1 -1
  14. package/dist/generated/audio-fx-runtime-inline.js.map +1 -1
  15. package/dist/generated/runtime-inline.js +1 -1
  16. package/dist/generated/runtime-inline.js.map +1 -1
  17. package/dist/hyperframe.runtime.iife.js +25 -25
  18. package/dist/runtime/authoredTiming.d.ts +2 -0
  19. package/dist/runtime/authoredTiming.d.ts.map +1 -1
  20. package/dist/runtime/authoredTiming.js +2 -0
  21. package/dist/runtime/authoredTiming.js.map +1 -1
  22. package/dist/runtime/levelTap.d.ts +12 -0
  23. package/dist/runtime/levelTap.d.ts.map +1 -0
  24. package/dist/runtime/levelTap.js +38 -0
  25. package/dist/runtime/levelTap.js.map +1 -0
  26. package/dist/runtime/media.d.ts +115 -0
  27. package/dist/runtime/media.d.ts.map +1 -0
  28. package/dist/runtime/media.js +450 -0
  29. package/dist/runtime/media.js.map +1 -0
  30. package/dist/runtime/timeline.d.ts +14 -0
  31. package/dist/runtime/timeline.d.ts.map +1 -0
  32. package/dist/runtime/timeline.js +650 -0
  33. package/dist/runtime/timeline.js.map +1 -0
  34. package/docs/core.md +1 -0
  35. package/package.json +12 -4
@@ -0,0 +1,450 @@
1
+ import { swallow } from "./diagnostics.js";
2
+ import { isClipVisibleAt, isInClipWindow } from "./clipWindow.js";
3
+ import { interpolateVolumeGain } from "./mediaVolumeEnvelope.js";
4
+ import { elementVolumeLaneGain } from "./audioAutomationVolume.js";
5
+ import { fadeGain, NO_FADES, readElementFades } from "../audioFade.js";
6
+ import { readElementPlaybackRate, readElementRateSpec, readMediaStart } from "./playbackRate.js";
7
+ import { rateAt, sourceTimeAt, timeAtSourceTime } from "../speedRamp.js";
8
+ import { clampAudioGain } from "../audioGain.js";
9
+ import { isMemberGroupHidden } from "../audioGroups.js";
10
+ import { findInjectedRenderFrame } from "./renderFrameSibling.js";
11
+ export { readElementPlaybackRate, readElementRateSpec, resolveNaturalMediaTimelineDuration, } from "./playbackRate.js";
12
+ export function readElementPlaybackStart(el) {
13
+ return readMediaStart(el);
14
+ }
15
+ /**
16
+ * Resolve a media element's timeline window without conflating a video's
17
+ * authored display slot with the amount of source left to decode.
18
+ *
19
+ * An explicit video slot may outlive its source and holds the final frame.
20
+ * Audio remains source-bounded because it has no visual hold state.
21
+ */
22
+ export function resolveRuntimeMediaClipDuration(params) {
23
+ const mediaDuration = params.isVideo
24
+ ? (params.explicitDuration ?? params.sourceDuration)
25
+ : params.sourceDuration;
26
+ const candidates = (params.isVideo
27
+ ? [mediaDuration, params.hostRemaining]
28
+ : [mediaDuration, params.hostRemaining, params.explicitDuration]).filter((value) => value != null && Number.isFinite(value) && value >= 0);
29
+ return candidates.length > 0 ? Math.min(...candidates) : null;
30
+ }
31
+ export function refreshRuntimeMediaCache(params) {
32
+ const mediaEls = params?.elements ??
33
+ Array.from(document.querySelectorAll("video, audio"));
34
+ const timedMediaEls = params?.shouldIncludeElement
35
+ ? mediaEls.filter((el) => params.shouldIncludeElement?.(el))
36
+ : mediaEls.filter((el) => el.hasAttribute("data-start"));
37
+ const mediaClips = [];
38
+ const videoClips = [];
39
+ let maxMediaEnd = 0;
40
+ for (const el of timedMediaEls) {
41
+ const start = params?.resolveStartSeconds
42
+ ? params.resolveStartSeconds(el)
43
+ : Number.parseFloat(el.dataset.start ?? "0");
44
+ if (!Number.isFinite(start))
45
+ continue;
46
+ const mediaStart = readElementPlaybackStart(el);
47
+ const playbackRate = readElementPlaybackRate(el);
48
+ const rate = readElementRateSpec(el);
49
+ const loop = el.loop;
50
+ const sourceDuration = Number.isFinite(el.duration) && el.duration > 0 ? el.duration : null;
51
+ let duration = params?.resolveDurationSeconds?.(el) ?? Number.parseFloat(el.dataset.duration ?? "");
52
+ if ((!Number.isFinite(duration) || duration < 0) && sourceDuration != null) {
53
+ // Effective duration accounts for playback rate:
54
+ // at 0.5x, a 10s source plays for 20s on the timeline
55
+ duration = Math.max(0, timeAtSourceTime(rate, sourceDuration - mediaStart));
56
+ }
57
+ const hasKnownDuration = Number.isFinite(duration) && duration >= 0;
58
+ const end = hasKnownDuration ? start + duration : Number.POSITIVE_INFINITY;
59
+ const volumeRaw = Number.parseFloat(el.dataset.volume ?? "");
60
+ const clip = {
61
+ el,
62
+ start,
63
+ mediaStart,
64
+ duration: hasKnownDuration ? duration : Number.POSITIVE_INFINITY,
65
+ end,
66
+ volume: Number.isFinite(volumeRaw) ? volumeRaw : null,
67
+ playbackRate,
68
+ rate,
69
+ loop,
70
+ sourceDuration,
71
+ fades: readElementFades(el),
72
+ };
73
+ mediaClips.push(clip);
74
+ if (el.tagName === "VIDEO")
75
+ videoClips.push(clip);
76
+ if (Number.isFinite(end))
77
+ maxMediaEnd = Math.max(maxMediaEnd, end);
78
+ }
79
+ return { timedMediaEls, mediaClips, videoClips, maxMediaEnd };
80
+ }
81
+ // Per-element timeline→media offset from the previous tick. Used to tell a
82
+ // gradual drift (initial buffer catch-up, where offset grows ~16ms/tick) from
83
+ // a scrub (where offset jumps in one tick). Cleared when a clip becomes
84
+ // inactive so the next activation gets a hard resync on its first tick.
85
+ const lastOffset = new WeakMap();
86
+ // Desired source time from the previous active tick. Unlike `forceSync`, which
87
+ // also covers play/pause and rate changes, a decrease here identifies an actual
88
+ // backward transport seek within an audio clip.
89
+ const lastRelativeTime = new WeakMap();
90
+ const strictDriftSamples = new WeakMap();
91
+ // Elements that had a seek past their buffered range (common with streaming
92
+ // MP3 where preload="metadata" only fetches the first few seconds). After
93
+ // setting preload="auto" and calling load(), we mark the element so subsequent
94
+ // ticks don't restart the fetch in a loop while the browser downloads data.
95
+ // Cleared when the clip leaves its active window.
96
+ const seekLoadRetried = new WeakSet();
97
+ // Elements whose play() is in flight. The sync runs on a 50 ms poll and with
98
+ // a 1–2 s buffer that would fire 20–40 spurious play() calls per element —
99
+ // noise in devtools and, worse, each `.catch(() => {})` would swallow a real
100
+ // AbortError / NotAllowedError that should surface. Cleared on the `playing`
101
+ // event (actual playback started) or on `pause`/`error` (state ended).
102
+ const playRequested = new WeakSet();
103
+ function markPlayRequested(el) {
104
+ if (playRequested.has(el))
105
+ return;
106
+ playRequested.add(el);
107
+ const clear = () => playRequested.delete(el);
108
+ el.addEventListener("playing", clear, { once: true });
109
+ el.addEventListener("pause", clear, { once: true });
110
+ el.addEventListener("error", clear, { once: true });
111
+ }
112
+ // HTMLMediaElement.NETWORK_NO_SOURCE — no usable source (404 / unsupported).
113
+ const MEDIA_NETWORK_NO_SOURCE = 3;
114
+ // An element that errored or has no source can't play; re-issuing play() every
115
+ // tick just floods rejections. Skip it until its state changes (src reload).
116
+ function isUnplayable(el) {
117
+ return el.error != null || el.networkState === MEDIA_NETWORK_NO_SOURCE;
118
+ }
119
+ const lastRuntimeAppliedVolume = new WeakMap();
120
+ function clampVolume(volume) {
121
+ if (!Number.isFinite(volume))
122
+ return 1;
123
+ return Math.max(0, Math.min(1, volume));
124
+ }
125
+ /**
126
+ * Drop every per-source sync baseline tracked for `el` — offset drift
127
+ * samples, the seek-past-buffered-range retry latch, and the last
128
+ * runtime-applied volume — so the next `syncRuntimeMedia` tick treats it as
129
+ * a first tick (hard resync, fresh drift baseline) instead of comparing
130
+ * against state computed for a different file. Used both when a clip leaves
131
+ * its active window (below) and by the runtime's proxy-swap helper
132
+ * (mediaProxy.ts) right after an in-place `src` swap, which points the same
133
+ * element at a different file without ever leaving its active window.
134
+ */
135
+ export function evictMediaSyncState(el) {
136
+ lastOffset.delete(el);
137
+ lastRelativeTime.delete(el);
138
+ strictDriftSamples.delete(el);
139
+ seekLoadRetried.delete(el);
140
+ lastRuntimeAppliedVolume.delete(el);
141
+ }
142
+ /** Test-only seam: whether any per-source sync state is still tracked for `el`. */
143
+ export function hasMediaSyncStateForTest(el) {
144
+ return (lastOffset.has(el) ||
145
+ lastRelativeTime.has(el) ||
146
+ strictDriftSamples.has(el) ||
147
+ seekLoadRetried.has(el) ||
148
+ lastRuntimeAppliedVolume.has(el));
149
+ }
150
+ // fallow-ignore-next-line complexity
151
+ export function syncRuntimeMedia(params) {
152
+ const forceMuteAll = !!(params.outputMuted || params.userMuted);
153
+ for (const clip of params.clips) {
154
+ const { el } = clip;
155
+ if (!el.isConnected)
156
+ continue;
157
+ const clipRate = clip.rate ?? clip.playbackRate;
158
+ const isNonLoopVideo = el.tagName === "VIDEO" && !clip.loop;
159
+ const inWindow = isInClipWindow(params.timeSeconds, clip.start, clip.end);
160
+ // A video that runs to the composition end stays the visible frame at and past it, so it
161
+ // is held on the frame it shows at its own end rather than left on a stale one.
162
+ const isTerminalVideo = isNonLoopVideo &&
163
+ !inWindow &&
164
+ params.timeSeconds >= clip.end &&
165
+ isClipVisibleAt(params.timeSeconds, clip.start, clip.end, params.getCompositionDuration());
166
+ let relTime = sourceTimeAt(clipRate, Math.min(params.timeSeconds, clip.end) - clip.start) + clip.mediaStart;
167
+ const isHeldVideoTail = isTerminalVideo ||
168
+ (isNonLoopVideo && clip.sourceDuration != null && relTime >= clip.sourceDuration && inWindow);
169
+ if (isHeldVideoTail && clip.sourceDuration != null) {
170
+ relTime = Math.min(relTime, clip.sourceDuration);
171
+ }
172
+ const previousRelativeTime = lastRelativeTime.get(el);
173
+ const audioReenteredAfterBackwardSeek = el.tagName === "AUDIO" &&
174
+ (previousRelativeTime === undefined || relTime < previousRelativeTime - 0.04);
175
+ const canSeekEndedMediaBackward = !clip.loop &&
176
+ clip.sourceDuration != null &&
177
+ relTime >= clip.mediaStart &&
178
+ relTime < clip.sourceDuration &&
179
+ (isNonLoopVideo || audioReenteredAfterBackwardSeek);
180
+ // Ended media can re-enter playable source after a backward timeline seek
181
+ // without depending on the browser having reset `ended` first. Audio needs
182
+ // a fresh activation or a measured backward transport seek so ordinary EOF
183
+ // and non-seek force-sync transitions cannot replay its tail. A non-loop
184
+ // video additionally remains an active visual through
185
+ // its authored window, with tail seeks clamped to the final frame.
186
+ const isActive = (inWindow || isTerminalVideo) &&
187
+ relTime >= 0 &&
188
+ (!el.ended || clip.loop || isHeldVideoTail || canSeekEndedMediaBackward);
189
+ if (isActive) {
190
+ lastRelativeTime.set(el, relTime);
191
+ // Loop wrapping: when media reaches end, restart from mediaStart
192
+ if (clip.loop && clip.sourceDuration != null && clip.sourceDuration > 0) {
193
+ const loopLength = clip.sourceDuration - clip.mediaStart;
194
+ if (loopLength > 0 && relTime >= clip.sourceDuration) {
195
+ relTime = clip.mediaStart + ((relTime - clip.mediaStart) % loopLength);
196
+ }
197
+ }
198
+ const userVol = clampVolume(params.userVolume ?? 1);
199
+ const fallbackAuthorVolume = clampAudioGain(clip.volume ?? 1);
200
+ const previousRuntimeVolume = lastRuntimeAppliedVolume.get(el);
201
+ const currentElementVolume = clampVolume(el.volume);
202
+ let authorVolume;
203
+ // An explicit volume lane owns the fader. It is checked before the probed
204
+ // keyframes because the two would otherwise fight, and it is the one the
205
+ // author drew — `lint` warns when a track carries both.
206
+ // Clip-local, NOT `relTime`. A lane's `t` is "seconds from the start of
207
+ // the clip" (see HfAutomationPoint), and the render honours that: the wav
208
+ // is already cut with `-ss mediaStart`, so its t=0 IS the clip's start.
209
+ // `relTime` is MEDIA time — it carries mediaStart, scales by playbackRate
210
+ // and wraps on a loop — so feeding it here played the envelope at a
211
+ // different position than it renders, or ran it off the end entirely on a
212
+ // trimmed clip. The FX lanes on this same feature use clip-local elapsed;
213
+ // there is one time base, and this is it.
214
+ const laneGain = elementVolumeLaneGain(el, params.timeSeconds - clip.start);
215
+ if (laneGain !== null) {
216
+ authorVolume = clampAudioGain(laneGain);
217
+ }
218
+ else if (clip.volumeKeyframes && clip.volumeKeyframes.length > 0) {
219
+ // Keyframes probed from the GSAP timeline — same source as the renderer.
220
+ // Use the interpolated envelope value directly; no need to track GSAP changes.
221
+ // Index by elapsed time on the TIMELINE since the clip began, which is what
222
+ // a normalised envelope is keyed by (and what the renderer's PCM baker uses).
223
+ // `relTime` is a position inside the media SOURCE — it carries `mediaStart`
224
+ // and the playback rate — so it only coincides with the envelope's time base
225
+ // for an untrimmed clip playing at 1x from t=0.
226
+ const elapsedInClip = params.timeSeconds - clip.start;
227
+ authorVolume = clampAudioGain(interpolateVolumeGain(clip.volumeKeyframes, elapsedInClip));
228
+ }
229
+ else if (params.isWebAudioRouted?.(el)) {
230
+ authorVolume = fallbackAuthorVolume;
231
+ }
232
+ else if (previousRuntimeVolume === undefined) {
233
+ // First tick this clip is active. The transport has already seeked GSAP
234
+ // to the current time (seekTimelineAndAdapters runs before syncRuntimeMedia),
235
+ // so el.volume reflects the animated value — trust it rather than falling
236
+ // back to data-volume, which would clobber the GSAP-seeked position.
237
+ //
238
+ // Except above unity. `el.volume` is spec-bound to [0,1], so it cannot
239
+ // represent an authored boost, and reading it back can only lose the
240
+ // gain. Without this, a boosted clip opened at 0 dB for one tick and
241
+ // then jumped once the unchanged-since-last-tick branch below took over
242
+ // — audible, and invisible to any test that ticks more than once.
243
+ authorVolume = fallbackAuthorVolume > 1 ? fallbackAuthorVolume : currentElementVolume;
244
+ }
245
+ else if (Math.abs(currentElementVolume - previousRuntimeVolume) > 0.0001) {
246
+ // GSAP (or user code) changed el.volume between ticks — track it.
247
+ //
248
+ // Unity-capped on purpose, and it is not a hole in the ceiling: this
249
+ // reads back through `el.volume`, which the spec pins to [0,1], so it
250
+ // cannot observe an above-unity value however wide the clamp gets. A
251
+ // clip whose volume is actually animated takes the probed-keyframes
252
+ // branch above, which carries the authored gain unclamped; this branch
253
+ // is the fallback for elements no probe ran on.
254
+ authorVolume = currentElementVolume;
255
+ }
256
+ else {
257
+ // Volume unchanged since last tick — use data-volume as the baseline.
258
+ authorVolume = fallbackAuthorVolume;
259
+ }
260
+ // Clip-local fade on top of the resolved level, matching render's afade-after-volume.
261
+ const fades = clip.fades ?? NO_FADES;
262
+ if (fades.fadeIn > 0 || fades.fadeOut > 0) {
263
+ authorVolume *= fadeGain(params.timeSeconds - clip.start, clip.duration, fades);
264
+ }
265
+ // A data-hidden ancestor is silent in the export (audioMixer.ts drops
266
+ // it), so preview matches. Folded into the per-tick volume, not
267
+ // el.muted (RULES trap: el.muted is the transport's ownership flag).
268
+ // Two independent ways to be silent, and the second is not an ancestor
269
+ // question: membership lives on the MEMBER's `data-audio-group`, so a
270
+ // muted BUS is invisible to `closest()`. The render drops such members
271
+ // (`memberGroupHidden`), so without this the export was silent where the
272
+ // fallback played at full level.
273
+ const silencedByHidden = el.closest("[data-hidden]") !== null || isMemberGroupHidden(el.ownerDocument, el);
274
+ const effectiveVolume = silencedByHidden ? 0 : clampVolume(authorVolume * userVol);
275
+ el.volume = effectiveVolume;
276
+ lastRuntimeAppliedVolume.set(el, effectiveVolume);
277
+ params.onElementVolume?.(el, effectiveVolume, authorVolume);
278
+ // Mute only when force-muted or the transport owns this element; an unclaimed
279
+ // track stays audible via the HTMLMedia fallback.
280
+ if (forceMuteAll || params.isWebAudioOwned?.(el))
281
+ el.muted = true;
282
+ // Ensure full preload for every active media element. Streaming
283
+ // formats (MP3) may arrive with preload="metadata", which only
284
+ // buffers the first few seconds and causes seeks to silently fail
285
+ // past the buffered range. Setting this on every tick is cheap
286
+ // (no-op when already "auto") and catches elements whose preload
287
+ // was overridden after init.ts set it.
288
+ if (el.preload !== "auto")
289
+ el.preload = "auto";
290
+ try {
291
+ // Per-element rate × global transport rate
292
+ el.playbackRate = rateAt(clipRate, params.timeSeconds - clip.start) * params.playbackRate;
293
+ }
294
+ catch (err) {
295
+ // ignore unsupported playbackRate
296
+ swallow("runtime.media.site1", err);
297
+ }
298
+ // Drift correction — three tiers:
299
+ //
300
+ // 1. Hard sync (0.5s): first tick, timeline jumps (scrub), catastrophic
301
+ // drift (>3s). Unconditional seek — accepts brief rebuffer cost.
302
+ // Forcing el.currentTime every frame causes audible seek hiccups
303
+ // (readyState drops briefly), so we only hard-seek when necessary.
304
+ //
305
+ // 2. Strict sync (40ms, 2 consecutive samples): catches accumulated
306
+ // drift from pause/play toggling or browser media pipeline latency.
307
+ // Offset-stabilization guard (4ms/tick) prevents false corrections
308
+ // during initial buffering where offset grows naturally.
309
+ //
310
+ // 3. Force sync (20ms): on play/pause/seek/rate transitions, correct
311
+ // any drift >20ms immediately via the forceSync one-shot flag.
312
+ //
313
+ // The first tick a clip is active has no previous offset to compare —
314
+ // treated as hard resync so sub-compositions with non-zero mediaStart
315
+ // land on the right frame.
316
+ const STRICT_DRIFT_THRESHOLD = 0.04;
317
+ const STRICT_REQUIRED_SAMPLES = 2;
318
+ const currentElTime = el.currentTime || 0;
319
+ const drift = Math.abs(currentElTime - relTime);
320
+ const offset = relTime - currentElTime;
321
+ const prevOffset = lastOffset.get(el);
322
+ lastOffset.set(el, offset);
323
+ const firstTickOfClip = prevOffset === undefined;
324
+ const offsetJumped = !firstTickOfClip && Math.abs(offset - prevOffset) > 0.5;
325
+ const catastrophicDrift = drift > 3;
326
+ // A short audio clip can leave its native element paused just before EOF.
327
+ // When the timeline re-enters the clip, rewind stale forward state at the
328
+ // strict threshold; do not force cold audio forward while it buffers.
329
+ const staleAudioOnFirstTick = el.tagName === "AUDIO" &&
330
+ firstTickOfClip &&
331
+ currentElTime - relTime > STRICT_DRIFT_THRESHOLD;
332
+ const hardSync = (isHeldVideoTail && drift > 0.001) ||
333
+ (el.ended && canSeekEndedMediaBackward && drift > 0.001) ||
334
+ staleAudioOnFirstTick ||
335
+ (drift > 0.5 && (firstTickOfClip || offsetJumped || catastrophicDrift));
336
+ // Playing video elements use the browser's native decoder pipeline for
337
+ // timing. Seeking a playing video resets the decoder, causing a ~150ms
338
+ // freeze while it re-buffers — during which the monotonic clock advances,
339
+ // creating a perpetual seek→freeze→drift→seek stutter loop. Skip strict
340
+ // and force sync for playing videos; only hard sync (>0.5s) warrants
341
+ // the decoder-reset cost.
342
+ const isPlayingVideo = el.tagName === "VIDEO" && !el.paused;
343
+ // Only apply strict sync when offset has stabilized (not growing).
344
+ // During initial buffering, offset grows ~16ms/tick as the timeline
345
+ // advances while media stays at 0. Accumulated drift from pause/play
346
+ // toggling shows up as a stable, non-zero offset (delta near 0).
347
+ const offsetStabilized = prevOffset !== undefined && Math.abs(offset - prevOffset) < 0.004;
348
+ let strictSync = false;
349
+ if (!isPlayingVideo &&
350
+ !hardSync &&
351
+ !firstTickOfClip &&
352
+ offsetStabilized &&
353
+ drift > STRICT_DRIFT_THRESHOLD) {
354
+ const samples = (strictDriftSamples.get(el) ?? 0) + 1;
355
+ strictDriftSamples.set(el, samples);
356
+ if (samples >= STRICT_REQUIRED_SAMPLES) {
357
+ strictSync = true;
358
+ strictDriftSamples.set(el, 0);
359
+ }
360
+ }
361
+ else if (drift <= STRICT_DRIFT_THRESHOLD) {
362
+ strictDriftSamples.set(el, 0);
363
+ }
364
+ const forceSync = !isPlayingVideo && params.forceSync && drift > 0.02;
365
+ if (hardSync || strictSync || forceSync) {
366
+ // Skip the per-tick seek (and the `el.load()` drift-recovery retry
367
+ // below) for `<video>` elements that have a sibling
368
+ // `<img id="__render_frame_<id>__">`. The sibling is created only
369
+ // by the producer's frame-injection pipeline during render — its
370
+ // presence means the visual is painted from the `<img>` and the
371
+ // `<video>` is `visibility: hidden`. Audio is mixed by ffmpeg from
372
+ // source files in `runAudioStage`, never via Chrome's in-browser
373
+ // audio path. So the `<video>`'s `currentTime` has no observable
374
+ // effect during render, and the per-tick set just kicks Chrome's
375
+ // media pipeline for nothing. Preview is unaffected (the sibling
376
+ // only exists during render).
377
+ const skipForInjectedVideo = el.tagName === "VIDEO" && !!findInjectedRenderFrame(el);
378
+ if (!skipForInjectedVideo) {
379
+ try {
380
+ el.currentTime = relTime;
381
+ }
382
+ catch (err) {
383
+ swallow("runtime.media.site2", err);
384
+ }
385
+ if (Math.abs(el.currentTime - relTime) > 0.5 && !seekLoadRetried.has(el)) {
386
+ seekLoadRetried.add(el);
387
+ el.load();
388
+ try {
389
+ el.currentTime = relTime;
390
+ }
391
+ catch (err) {
392
+ swallow("runtime.media.site3", err);
393
+ }
394
+ }
395
+ }
396
+ playRequested.delete(el);
397
+ }
398
+ if (isHeldVideoTail) {
399
+ if (!el.paused)
400
+ el.pause();
401
+ }
402
+ else if (params.playing && el.paused && !playRequested.has(el) && !isUnplayable(el)) {
403
+ // `HTMLMediaElement.play()` is spec'd to queue playback and resolve
404
+ // once enough data is buffered, so we can unconditionally call it —
405
+ // no need to gate on `readyState` or defer to a `canplay` listener.
406
+ //
407
+ // The old `readyState < HAVE_FUTURE_DATA` branch called `el.load()`
408
+ // inside the listener, which *aborts* the in-flight fetch that
409
+ // `bindMediaMetadataListeners` already started at init time and
410
+ // restarts from zero. On slow networks this delayed playback by
411
+ // seconds. The canplay listener was also racey — the event could
412
+ // fire between `load()` and `addEventListener` attachment, wedging
413
+ // the element waiting for a callback that never came.
414
+ markPlayRequested(el);
415
+ void el.play().catch((err) => {
416
+ // If play() rejects — e.g. autoplay blocked, element removed
417
+ // mid-flight — drop the in-flight flag so a future sync tick can
418
+ // retry rather than getting stuck waiting for `playing`/`pause`.
419
+ playRequested.delete(el);
420
+ // `NotAllowedError` is the autoplay-gating browser response when
421
+ // the iframe has no user activation. Signal the parent exactly
422
+ // once so it can promote to parent-frame audio proxies. Retries
423
+ // here would be pointless — nothing the runtime does fixes it.
424
+ const name = err && typeof err === "object" && "name" in err
425
+ ? String(err.name ?? "")
426
+ : "";
427
+ if (name === "NotAllowedError")
428
+ params.onAutoplayBlocked?.();
429
+ });
430
+ }
431
+ else if (!params.playing && !el.paused) {
432
+ el.pause();
433
+ }
434
+ continue;
435
+ }
436
+ // Drop drift state when the element is not playable. If native audio EOF
437
+ // arrived slightly before the authored boundary, preserve only its desired
438
+ // source time while the transport remains inside that boundary. Otherwise
439
+ // the next poll would mistake the cleared baseline for a fresh activation
440
+ // and replay the tail. A real backward seek still decreases relTime, and a
441
+ // true outside-window transition clears every baseline as before.
442
+ const remainsInsideAuthoredWindow = isInClipWindow(params.timeSeconds, clip.start, clip.end);
443
+ evictMediaSyncState(el);
444
+ if (remainsInsideAuthoredWindow)
445
+ lastRelativeTime.set(el, relTime);
446
+ if (!el.paused)
447
+ el.pause();
448
+ }
449
+ }
450
+ //# sourceMappingURL=media.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.js","sourceRoot":"","sources":["../../src/runtime/media.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAuB,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAmB,MAAM,iBAAiB,CAAC;AACxF,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAiB,MAAM,iBAAiB,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,mCAAmC,GACpC,MAAM,mBAAmB,CAAC;AAE3B,MAAM,UAAU,wBAAwB,C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C,EAAE,CAAC,KAAK,EAAE,CAAC;YACb,CAAC;YACD,SAAS;QACX,CAAC;QACD,yEAAyE;QACzE,2EAA2E;QAC3E,0EAA0E;QAC1E,0EAA0E;QAC1E,2EAA2E;QAC3E,kEAAkE;QAClE,MAAM,2BAA2B,GAAG,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7F,mBAAmB,CAAC,EAAE,CAAC,CAAC;QACxB,IAAI,2BAA2B;YAAE,gBAAgB,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACnE,IAAI,CAAC,EAAE,CAAC,MAAM;YAAE,EAAE,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { RuntimeTimelineMessage, RuntimeTimelineLike } from "./types";
2
+ import { createRuntimeStartTimeResolver } from "./startResolver";
3
+ export declare function isRuntimeElementVisibleAt(rawNode: HTMLElement, options: {
4
+ currentTime: number;
5
+ compositionDuration: number;
6
+ canonicalFps: number;
7
+ exportRenderSeek: boolean;
8
+ timelineRegistry: Record<string, RuntimeTimelineLike | undefined>;
9
+ resolver: ReturnType<typeof createRuntimeStartTimeResolver>;
10
+ }): boolean;
11
+ export declare function collectRuntimeTimelinePayload(params: {
12
+ canonicalFps: number;
13
+ }): RuntimeTimelineMessage;
14
+ //# sourceMappingURL=timeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/runtime/timeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,sBAAsB,EAEtB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAgBjB,OAAO,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AAQjE,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE;IACP,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,SAAS,CAAC,CAAC;IAClE,QAAQ,EAAE,UAAU,CAAC,OAAO,8BAA8B,CAAC,CAAC;CAC7D,GACA,OAAO,CAiDT;AAmJD,wBAAgB,6BAA6B,CAAC,MAAM,EAAE;IACpD,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,sBAAsB,CAudzB"}