fix(core): parent-frame proxy bypass, data-preload-eager opt-out, configurable threshold

- Player: _adoptIframeMedia now skips media with preload="metadata" or
  "none", preventing parent-frame proxies from bypassing the preloader.
  MutationObserver extended to watch preload attribute changes so proxies
  are created just-in-time when the preloader promotes a clip.

- init.ts: lazy-mode demotion loop skips elements with data-preload-eager,
  letting power users keep specific clips eagerly buffered.

- mediaPreloader: reads window.__HF_LAZY_PRELOAD_THRESHOLD as an override,
  falling back to the default 6.
This commit is contained in:
Miguel Ángel
2026-05-11 19:37:06 -07:00
parent a96d99680f
commit 35eab94e69
5 changed files with 82 additions and 4 deletions
+5 -1
View File
@@ -38,7 +38,11 @@ export function createMediaPreloadManager(options?: {
function refresh(): void {
const cache = refreshRuntimeMediaCache(options);
clips = cache.mediaClips;
lazy = clips.length >= LAZY_THRESHOLD;
const configuredThreshold =
typeof (window as Record<string, unknown>).__HF_LAZY_PRELOAD_THRESHOLD === "number"
? ((window as Record<string, unknown>).__HF_LAZY_PRELOAD_THRESHOLD as number)
: LAZY_THRESHOLD;
lazy = clips.length >= configuredThreshold;
if (lazy && !activationEmitted) {
activationEmitted = true;
options?.onActivation?.(clips.length);