hyperframes 0.7.74 → 0.7.75

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/cli.js CHANGED
@@ -50,7 +50,7 @@ var VERSION;
50
50
  var init_version = __esm({
51
51
  "src/version.ts"() {
52
52
  "use strict";
53
- VERSION = true ? "0.7.74" : "0.0.0-dev";
53
+ VERSION = true ? "0.7.75" : "0.0.0-dev";
54
54
  }
55
55
  });
56
56
 
@@ -117756,11 +117756,11 @@ async function runCaptureStage(input2) {
117756
117756
  captureCfg
117757
117757
  );
117758
117758
  captureBeyondViewport = session.options.captureBeyondViewport;
117759
- if (probeSession) {
117760
- prepareCaptureSessionForReuse(session, framesDir, videoInjector);
117761
- probeSession = null;
117762
- }
117763
117759
  try {
117760
+ if (probeSession) {
117761
+ prepareCaptureSessionForReuse(session, framesDir, videoInjector);
117762
+ probeSession = null;
117763
+ }
117764
117764
  if (!session.isInitialized) {
117765
117765
  await initializeSession(session);
117766
117766
  } else if (process.env.PRODUCER_EXPERIMENTAL_FAST_CAPTURE === "true") {
@@ -126411,6 +126411,51 @@ var init_assemble = __esm({
126411
126411
  import { randomBytes as randomBytes2 } from "crypto";
126412
126412
  import { existsSync as existsSync61, mkdirSync as mkdirSync34, readFileSync as readFileSync36, readdirSync as readdirSync21, rmSync as rmSync23, writeFileSync as writeFileSync25 } from "fs";
126413
126413
  import { extname as extname15, join as join70 } from "path";
126414
+ async function createVerifiedDistributedCaptureSession(serverUrl, framesDir, captureOptions, cfg, dependencies = distributedCaptureSessionDependencies) {
126415
+ const session = await dependencies.createCaptureSession(
126416
+ serverUrl,
126417
+ framesDir,
126418
+ captureOptions,
126419
+ null,
126420
+ cfg
126421
+ );
126422
+ try {
126423
+ await dependencies.assertSwiftShader(session.page, dependencies.readWebGlVendorInfo);
126424
+ await dependencies.initializeSession(session);
126425
+ return session;
126426
+ } catch (error) {
126427
+ await dependencies.closeCaptureSession(session).catch(() => {
126428
+ });
126429
+ throw error;
126430
+ }
126431
+ }
126432
+ function createChunkVideoFrameInjectorFactory(frameLookup) {
126433
+ return () => createVideoFrameInjector(frameLookup);
126434
+ }
126435
+ function isCaptureMode(value) {
126436
+ return value === "beginframe" || value === "screenshot" || value === "drawelement";
126437
+ }
126438
+ function shouldRetryChunkCaptureWithScreenshot(error) {
126439
+ const failure = classifyCaptureFailure(error);
126440
+ if (failure.kind === "cancelled" || failure.kind === "memory_exhaustion") return false;
126441
+ return /HeadlessExperimental\.beginFrame/i.test(failure.message) || /beginFrame probe timeout/i.test(failure.message) || /Another frame is pending|Frame still pending/i.test(failure.message);
126442
+ }
126443
+ async function runCaptureWithScreenshotFallback(input2) {
126444
+ try {
126445
+ return await input2.run(input2.forceScreenshot);
126446
+ } catch (error) {
126447
+ if (input2.forceScreenshot || !shouldRetryChunkCaptureWithScreenshot(error)) throw error;
126448
+ input2.onFallback?.(error);
126449
+ await input2.resetForScreenshotRetry();
126450
+ return await input2.run(true);
126451
+ }
126452
+ }
126453
+ async function beginFrameSessionNeedsScreenshotFallback(session, probe = probeBeginFrameLiveness) {
126454
+ if (session.launchCaptureMode !== "beginframe") return false;
126455
+ const timeoutMs = Number(process.env.PRODUCER_BEGINFRAME_PROBE_TIMEOUT_MS) > 0 ? Number(process.env.PRODUCER_BEGINFRAME_PROBE_TIMEOUT_MS) : 3e4;
126456
+ const probeTick = Math.max(0, session.beginFrameTimeTicks - 5 * session.beginFrameIntervalMs);
126457
+ return !await probe(session.page, timeoutMs, probeTick, session.beginFrameIntervalMs);
126458
+ }
126414
126459
  function rebuildExtractedFramesFromPlanDir(planDir, videos, indexMode = "dense-v1") {
126415
126460
  const result = [];
126416
126461
  for (const v2 of videos) {
@@ -126581,16 +126626,15 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath) {
126581
126626
  // the software-GPU clamp so buildChromeArgs includes BeginFrameControl.
126582
126627
  forceScreenshotExplicitlyOptedOut: !encoder.forceScreenshot
126583
126628
  };
126584
- const videoInjector = planVideos && planVideos.extracted.length > 0 ? createVideoFrameInjector(
126585
- createFrameLookupTable(
126586
- planVideos.videos,
126587
- rebuildExtractedFramesFromPlanDir(
126588
- planDir,
126589
- planVideos.extracted,
126590
- v2Manifest === null ? "dense-v1" : "sparse-v2"
126591
- )
126629
+ const videoFrameLookup = planVideos && planVideos.extracted.length > 0 ? createFrameLookupTable(
126630
+ planVideos.videos,
126631
+ rebuildExtractedFramesFromPlanDir(
126632
+ planDir,
126633
+ planVideos.extracted,
126634
+ v2Manifest === null ? "dense-v1" : "sparse-v2"
126592
126635
  )
126593
126636
  ) : null;
126637
+ const createChunkVideoFrameInjector = createChunkVideoFrameInjectorFactory(videoFrameLookup);
126594
126638
  const videoCaptureBeyondViewport = resolveVideoCaptureBeyondViewport(
126595
126639
  planVideos?.videos.length ?? 0
126596
126640
  );
@@ -126634,61 +126678,142 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath) {
126634
126678
  let encodeStageMs = 0;
126635
126679
  let captureMode;
126636
126680
  const capturePerfs = [];
126681
+ const captureAttempts = [];
126682
+ let forceScreenshotForChunk = encoder.forceScreenshot;
126637
126683
  try {
126638
- if (chunkWorkerCount === 1) {
126684
+ if (chunkWorkerCount === 1 || !forceScreenshotForChunk) {
126639
126685
  const bootStarted = Date.now();
126640
- session = await createCaptureSession(fileServer.url, framesDir, captureOptions, null, cfg);
126641
- await assertSwiftShader(session.page, readWebGlVendorInfoFromCanvas);
126642
- await initializeSession(session);
126686
+ session = await createVerifiedDistributedCaptureSession(
126687
+ fileServer.url,
126688
+ framesDir,
126689
+ captureOptions,
126690
+ cfg
126691
+ );
126643
126692
  sessionBootMs = Date.now() - bootStarted;
126693
+ const browserSelectedScreenshot = session.launchCaptureMode === "screenshot";
126694
+ const beginFrameStalled = !browserSelectedScreenshot && await beginFrameSessionNeedsScreenshotFallback(session);
126695
+ if (browserSelectedScreenshot) {
126696
+ forceScreenshotForChunk = true;
126697
+ log2.warn(
126698
+ "[renderChunk] Browser capability probe selected screenshot capture for the entire chunk",
126699
+ { chunkIndex }
126700
+ );
126701
+ if (chunkWorkerCount > 1) {
126702
+ await closeCaptureSession(session);
126703
+ session = null;
126704
+ }
126705
+ } else if (beginFrameStalled) {
126706
+ forceScreenshotForChunk = true;
126707
+ log2.warn(
126708
+ "[renderChunk] BeginFrame liveness probe failed; using screenshot capture for the entire chunk",
126709
+ { chunkIndex }
126710
+ );
126711
+ await closeCaptureSession(session).catch(() => {
126712
+ });
126713
+ session = null;
126714
+ if (chunkWorkerCount === 1) {
126715
+ const screenshotBootStarted = Date.now();
126716
+ const screenshotCfg = {
126717
+ ...cfg,
126718
+ forceScreenshot: true,
126719
+ forceScreenshotExplicitlyOptedOut: false
126720
+ };
126721
+ session = await createVerifiedDistributedCaptureSession(
126722
+ fileServer.url,
126723
+ framesDir,
126724
+ captureOptions,
126725
+ screenshotCfg
126726
+ );
126727
+ sessionBootMs += Date.now() - screenshotBootStarted;
126728
+ }
126729
+ } else if (chunkWorkerCount > 1) {
126730
+ await closeCaptureSession(session);
126731
+ session = null;
126732
+ }
126644
126733
  }
126645
126734
  const captureStarted = Date.now();
126646
- const capturePlan = createCapturePlan({
126647
- workerCount: chunkWorkerCount,
126648
- forceScreenshot: encoder.forceScreenshot,
126649
- useStreamingEncode: false,
126650
- useLayeredComposite: false,
126651
- usePageSideCompositing: false,
126652
- hasHdrContent: false,
126653
- needsAlpha: plan2.dimensions.format !== "mp4"
126654
- });
126655
- if (capturePlan.kind !== "sdr_disk") {
126656
- throw new Error(`Distributed chunk requires sdr_disk plan; got ${capturePlan.kind}`);
126657
- }
126658
- await runCaptureStage({
126659
- fileServer,
126660
- workDir,
126661
- framesDir,
126662
- job,
126663
- totalFrames: framesInChunk,
126664
- cfg,
126665
- plan: capturePlan,
126666
- log: log2,
126667
- probeSession: session,
126668
- captureAttempts: [],
126669
- // This sink also records each worker's effective capture mode. That
126670
- // makes a BeginFrame → screenshot fallback observable to adapters and
126671
- // end-to-end smoke tests instead of existing only in stderr.
126672
- dedupPerfs: capturePerfs,
126673
- buildCaptureOptions: () => captureOptions,
126674
- createRenderVideoFrameInjector: () => videoInjector,
126675
- abortSignal: void 0,
126676
- assertNotAborted: () => {
126735
+ captureMode = await runCaptureWithScreenshotFallback({
126736
+ forceScreenshot: forceScreenshotForChunk,
126737
+ // fallow-ignore-next-line complexity
126738
+ run: async (forceScreenshot) => {
126739
+ const captureCfg = cfg.forceScreenshot === forceScreenshot ? cfg : {
126740
+ ...cfg,
126741
+ forceScreenshot,
126742
+ forceScreenshotExplicitlyOptedOut: !forceScreenshot
126743
+ };
126744
+ if (chunkWorkerCount === 1 && session === null) {
126745
+ session = await createVerifiedDistributedCaptureSession(
126746
+ fileServer.url,
126747
+ framesDir,
126748
+ captureOptions,
126749
+ captureCfg
126750
+ );
126751
+ }
126752
+ const capturePlan = createCapturePlan({
126753
+ workerCount: chunkWorkerCount,
126754
+ forceScreenshot,
126755
+ useStreamingEncode: false,
126756
+ useLayeredComposite: false,
126757
+ usePageSideCompositing: false,
126758
+ hasHdrContent: false,
126759
+ needsAlpha: plan2.dimensions.format !== "mp4"
126760
+ });
126761
+ if (capturePlan.kind !== "sdr_disk") {
126762
+ throw new Error(`Distributed chunk requires sdr_disk plan; got ${capturePlan.kind}`);
126763
+ }
126764
+ const captureSession = session;
126765
+ session = null;
126766
+ await runCaptureStage({
126767
+ fileServer,
126768
+ workDir,
126769
+ framesDir,
126770
+ job,
126771
+ totalFrames: framesInChunk,
126772
+ cfg: captureCfg,
126773
+ plan: capturePlan,
126774
+ log: log2,
126775
+ probeSession: captureSession,
126776
+ captureAttempts,
126777
+ // This sink records each worker's effective capture mode so a
126778
+ // fallback remains observable to adapters and smoke tests.
126779
+ dedupPerfs: capturePerfs,
126780
+ buildCaptureOptions: () => captureOptions,
126781
+ createRenderVideoFrameInjector: createChunkVideoFrameInjector,
126782
+ abortSignal: void 0,
126783
+ assertNotAborted: () => {
126784
+ },
126785
+ frameRange: { startFrame: slice.startFrame, endFrame: slice.endFrame }
126786
+ });
126787
+ const observedModes = new Set(capturePerfs.map((perf) => perf.captureMode));
126788
+ if (observedModes.size !== 1 || ![...observedModes].every(isCaptureMode)) {
126789
+ throw new Error(
126790
+ `[renderChunk] capture workers reported invalid or inconsistent modes: ${[...observedModes].join(",") || "<none>"}`
126791
+ );
126792
+ }
126793
+ const [observedMode] = observedModes;
126794
+ if (!observedMode || !isCaptureMode(observedMode)) {
126795
+ throw new Error("[renderChunk] capture completed without an observed mode");
126796
+ }
126797
+ return observedMode;
126677
126798
  },
126678
- frameRange: { startFrame: slice.startFrame, endFrame: slice.endFrame }
126799
+ resetForScreenshotRetry: () => {
126800
+ rmSync23(workDir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
126801
+ mkdirSync34(framesDir, { recursive: true });
126802
+ capturePerfs.length = 0;
126803
+ captureAttempts.length = 0;
126804
+ job.framesRendered = 0;
126805
+ },
126806
+ onFallback: (error) => {
126807
+ log2.warn(
126808
+ "[renderChunk] BeginFrame capture failed; retrying the entire chunk once in screenshot mode",
126809
+ {
126810
+ chunkIndex,
126811
+ error: error instanceof Error ? error.message : String(error)
126812
+ }
126813
+ );
126814
+ }
126679
126815
  });
126680
126816
  captureStageMs = Date.now() - captureStarted;
126681
- session = null;
126682
- const observedModes = new Set(capturePerfs.map((perf) => perf.captureMode));
126683
- const validModes = /* @__PURE__ */ new Set(["beginframe", "screenshot", "drawelement"]);
126684
- if (observedModes.size !== 1 || ![...observedModes].every(
126685
- (mode) => validModes.has(mode)
126686
- )) {
126687
- throw new Error(
126688
- `[renderChunk] capture workers reported invalid or inconsistent modes: ${[...observedModes].join(",") || "<none>"}`
126689
- );
126690
- }
126691
- captureMode = [...observedModes][0];
126692
126817
  framesEncoded = framesInChunk;
126693
126818
  const isPngSequence = plan2.dimensions.format === "png-sequence";
126694
126819
  outputKind = isPngSequence ? "frame-dir" : "file";
@@ -126808,7 +126933,7 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath) {
126808
126933
  envRestore.restore();
126809
126934
  }
126810
126935
  }
126811
- var FFMPEG_VERSION_MISMATCH, PLAN_HASH_MISMATCH, MISSING_PLAN_ARTIFACT, CHUNK_INDEX_OUT_OF_RANGE, MISSING_RUNTIME_ENV_SNAPSHOT, LEGACY_DISTRIBUTED_VP9_CPU_USED, RenderChunkValidationError;
126936
+ var FFMPEG_VERSION_MISMATCH, PLAN_HASH_MISMATCH, MISSING_PLAN_ARTIFACT, CHUNK_INDEX_OUT_OF_RANGE, MISSING_RUNTIME_ENV_SNAPSHOT, LEGACY_DISTRIBUTED_VP9_CPU_USED, RenderChunkValidationError, distributedCaptureSessionDependencies;
126812
126937
  var init_renderChunk = __esm({
126813
126938
  "../producer/src/services/distributed/renderChunk.ts"() {
126814
126939
  "use strict";
@@ -126841,6 +126966,13 @@ var init_renderChunk = __esm({
126841
126966
  this.code = code;
126842
126967
  }
126843
126968
  };
126969
+ distributedCaptureSessionDependencies = {
126970
+ createCaptureSession,
126971
+ assertSwiftShader,
126972
+ initializeSession,
126973
+ closeCaptureSession,
126974
+ readWebGlVendorInfo: readWebGlVendorInfoFromCanvas
126975
+ };
126844
126976
  }
126845
126977
  });
126846
126978
 
@@ -1,4 +1,4 @@
1
- "use strict";var HyperframesPlayer=(()=>{var J=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Xe=(i,e)=>{for(var t in e)J(i,t,{get:e[t],enumerable:!0})},Ze=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qe(e))!Ye.call(i,n)&&n!==t&&J(i,n,{get:()=>e[n],enumerable:!(r=Ge(e,n))||r.enumerable});return i};var Qe=i=>Ze(J({},"__esModule",{value:!0}),i);var Lt={};Xe(Lt,{HyperframesPlayer:()=>Q,SPEED_PRESETS:()=>te,formatSpeed:()=>N,formatTime:()=>$});function ye(i){return i.hasRuntime||i.runtimeInjected?!1:!!(i.hasNestedCompositions||i.hasTimelines&&i.attempts>=5)}function I(i){return typeof i=="object"&&i!==null}function Ee(i){return I(i)&&typeof i.getDuration=="function"}function Se(i){return I(i)&&typeof i.duration=="function"&&typeof i.time=="function"&&typeof i.seek=="function"&&typeof i.play=="function"&&typeof i.pause=="function"}var Je="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.7.74/dist/hyperframe.runtime.iife.js";function D(i){if(i===null)return null;let e=Number.parseInt(i,10);return Number.isFinite(e)&&e>0?e:null}function Ke(i){let e=i?.querySelector("[data-composition-id][data-width][data-height]")??i?.querySelector("[data-width][data-height]");if(!e)return null;let t=D(e.getAttribute("data-width")),r=D(e.getAttribute("data-height"));return t!==null&&r!==null?{width:t,height:r}:null}var j=class{constructor(e,t){this._iframe=e;this._callbacks=t}_iframe;_callbacks;_interval=null;_runtimeInjected=!1;get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let e=0;this._interval=setInterval(()=>{e++;try{let t=this._iframe.contentWindow;if(!t)return;let r=!!(t.__hf||t.__player),n=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!this._iframe.contentDocument?.querySelector("[data-composition-src]");if(ye({hasRuntime:r,hasTimelines:n,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:e})){this._injectRuntime();return}if(this._runtimeInjected&&!r)return;let s=this._resolvePlaybackDurationAdapter(t);if(s&&s.getDuration()>0){this.stop();let l=Ke(this._iframe.contentDocument);this._callbacks.onReady({duration:s.getDuration(),adapter:s,compositionSize:l});return}}catch{}e>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{let e=this._iframe.contentWindow;return e?this._resolveDirectTimelineAdapterFromWindow(e):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(e){return this._resolveDirectTimelineAdapterFromWindow(e)}hasRuntimeBridge(e){return Reflect.get(e,"__hf")!==void 0||I(Reflect.get(e,"__player"))}_injectRuntime(){this._runtimeInjected=!0;try{let e=this._iframe.contentDocument;if(!e)return;let t=e.createElement("script");t.src=Je,(e.head||e.documentElement).appendChild(t),this._callbacks.onRuntimeInjected?.()}catch{}}_resolveDirectTimelineAdapterFromWindow(e){if(this.hasRuntimeBridge(e))return null;let t=Reflect.get(e,"__timelines");if(!I(t))return null;let r=Object.keys(t);if(r.length===0)return null;let n=this._iframe.contentDocument?.querySelector("[data-composition-id]")?.getAttribute("data-composition-id"),o=n&&n in t?n:r[r.length-1],s=t[o];return Se(s)?s:null}_resolvePlaybackDurationAdapter(e){let t=Reflect.get(e,"__player");if(Ee(t))return{kind:"runtime",getDuration:()=>t.getDuration()};let r=this._resolveDirectTimelineAdapterFromWindow(e);return r?{kind:"direct-timeline",timeline:r,getDuration:()=>r.duration()}:null}};var Te=`
1
+ "use strict";var HyperframesPlayer=(()=>{var J=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Xe=(i,e)=>{for(var t in e)J(i,t,{get:e[t],enumerable:!0})},Ze=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qe(e))!Ye.call(i,n)&&n!==t&&J(i,n,{get:()=>e[n],enumerable:!(r=Ge(e,n))||r.enumerable});return i};var Qe=i=>Ze(J({},"__esModule",{value:!0}),i);var Lt={};Xe(Lt,{HyperframesPlayer:()=>Q,SPEED_PRESETS:()=>te,formatSpeed:()=>N,formatTime:()=>$});function ye(i){return i.hasRuntime||i.runtimeInjected?!1:!!(i.hasNestedCompositions||i.hasTimelines&&i.attempts>=5)}function I(i){return typeof i=="object"&&i!==null}function Ee(i){return I(i)&&typeof i.getDuration=="function"}function Se(i){return I(i)&&typeof i.duration=="function"&&typeof i.time=="function"&&typeof i.seek=="function"&&typeof i.play=="function"&&typeof i.pause=="function"}var Je="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.7.75/dist/hyperframe.runtime.iife.js";function D(i){if(i===null)return null;let e=Number.parseInt(i,10);return Number.isFinite(e)&&e>0?e:null}function Ke(i){let e=i?.querySelector("[data-composition-id][data-width][data-height]")??i?.querySelector("[data-width][data-height]");if(!e)return null;let t=D(e.getAttribute("data-width")),r=D(e.getAttribute("data-height"));return t!==null&&r!==null?{width:t,height:r}:null}var j=class{constructor(e,t){this._iframe=e;this._callbacks=t}_iframe;_callbacks;_interval=null;_runtimeInjected=!1;get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let e=0;this._interval=setInterval(()=>{e++;try{let t=this._iframe.contentWindow;if(!t)return;let r=!!(t.__hf||t.__player),n=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!this._iframe.contentDocument?.querySelector("[data-composition-src]");if(ye({hasRuntime:r,hasTimelines:n,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:e})){this._injectRuntime();return}if(this._runtimeInjected&&!r)return;let s=this._resolvePlaybackDurationAdapter(t);if(s&&s.getDuration()>0){this.stop();let l=Ke(this._iframe.contentDocument);this._callbacks.onReady({duration:s.getDuration(),adapter:s,compositionSize:l});return}}catch{}e>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{let e=this._iframe.contentWindow;return e?this._resolveDirectTimelineAdapterFromWindow(e):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(e){return this._resolveDirectTimelineAdapterFromWindow(e)}hasRuntimeBridge(e){return Reflect.get(e,"__hf")!==void 0||I(Reflect.get(e,"__player"))}_injectRuntime(){this._runtimeInjected=!0;try{let e=this._iframe.contentDocument;if(!e)return;let t=e.createElement("script");t.src=Je,(e.head||e.documentElement).appendChild(t),this._callbacks.onRuntimeInjected?.()}catch{}}_resolveDirectTimelineAdapterFromWindow(e){if(this.hasRuntimeBridge(e))return null;let t=Reflect.get(e,"__timelines");if(!I(t))return null;let r=Object.keys(t);if(r.length===0)return null;let n=this._iframe.contentDocument?.querySelector("[data-composition-id]")?.getAttribute("data-composition-id"),o=n&&n in t?n:r[r.length-1],s=t[o];return Se(s)?s:null}_resolvePlaybackDurationAdapter(e){let t=Reflect.get(e,"__player");if(Ee(t))return{kind:"runtime",getDuration:()=>t.getDuration()};let r=this._resolveDirectTimelineAdapterFromWindow(e);return r?{kind:"direct-timeline",timeline:r,getDuration:()=>r.duration()}:null}};var Te=`
2
2
  :host {
3
3
  display: block;
4
4
  position: relative;
@@ -1,4 +1,4 @@
1
- var ce=Object.defineProperty;var pe=(r,t,e)=>t in r?ce(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var c=(r,t,e)=>pe(r,typeof t!="symbol"?t+"":t,e);import{r as ne,i as me,a as fe}from"./index-CBDJuOGW.js";function _e(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function F(r){return typeof r=="object"&&r!==null}function ge(r){return F(r)&&typeof r.getDuration=="function"}function ye(r){return F(r)&&typeof r.duration=="function"&&typeof r.time=="function"&&typeof r.seek=="function"&&typeof r.play=="function"&&typeof r.pause=="function"}function ve(r){if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(r))throw new Error(`Invalid HyperFrames runtime version: ${r}`);return`https://cdn.jsdelivr.net/npm/@hyperframes/core@${r}/dist/hyperframe.runtime.iife.js`}const be=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:ve("0.0.0-dev");function H(r){if(r===null)return null;const t=Number.parseInt(r,10);return Number.isFinite(t)&&t>0?t:null}function we(r){const t=(r==null?void 0:r.querySelector("[data-composition-id][data-width][data-height]"))??(r==null?void 0:r.querySelector("[data-width][data-height]"));if(!t)return null;const e=H(t.getAttribute("data-width")),i=H(t.getAttribute("data-height"));return e!==null&&i!==null?{width:e,height:i}:null}class Ae{constructor(t,e){c(this,"_interval",null);c(this,"_runtimeInjected",!1);this._iframe=t,this._callbacks=e}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let t=0;this._interval=setInterval(()=>{var e;t++;try{const i=this._iframe.contentWindow;if(!i)return;const s=!!(i.__hf||i.__player),o=!!(i.__timelines&&Object.keys(i.__timelines).length>0),d=!!((e=this._iframe.contentDocument)!=null&&e.querySelector("[data-composition-src]"));if(_e({hasRuntime:s,hasTimelines:o,hasNestedCompositions:d,runtimeInjected:this._runtimeInjected,attempts:t})){this._injectRuntime();return}if(this._runtimeInjected&&!s)return;const a=this._resolvePlaybackDurationAdapter(i);if(a&&a.getDuration()>0){this.stop();const h=we(this._iframe.contentDocument);this._callbacks.onReady({duration:a.getDuration(),adapter:a,compositionSize:h});return}}catch{}t>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{const t=this._iframe.contentWindow;return t?this._resolveDirectTimelineAdapterFromWindow(t):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(t){return this._resolveDirectTimelineAdapterFromWindow(t)}hasRuntimeBridge(t){return Reflect.get(t,"__hf")!==void 0||F(Reflect.get(t,"__player"))}_injectRuntime(){var t,e;this._runtimeInjected=!0;try{const i=this._iframe.contentDocument;if(!i)return;const s=i.createElement("script");s.src=be,(i.head||i.documentElement).appendChild(s),(e=(t=this._callbacks).onRuntimeInjected)==null||e.call(t)}catch{}}_resolveDirectTimelineAdapterFromWindow(t){var a,h;if(this.hasRuntimeBridge(t))return null;const e=Reflect.get(t,"__timelines");if(!F(e))return null;const i=Object.keys(e);if(i.length===0)return null;const s=(h=(a=this._iframe.contentDocument)==null?void 0:a.querySelector("[data-composition-id]"))==null?void 0:h.getAttribute("data-composition-id"),o=s&&s in e?s:i[i.length-1],d=e[o];return ye(d)?d:null}_resolvePlaybackDurationAdapter(t){const e=Reflect.get(t,"__player");if(ge(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const i=this._resolveDirectTimelineAdapterFromWindow(t);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}}const Ee=`
1
+ var ce=Object.defineProperty;var pe=(r,t,e)=>t in r?ce(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var c=(r,t,e)=>pe(r,typeof t!="symbol"?t+"":t,e);import{r as ne,i as me,a as fe}from"./index-DzDajONI.js";function _e(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function F(r){return typeof r=="object"&&r!==null}function ge(r){return F(r)&&typeof r.getDuration=="function"}function ye(r){return F(r)&&typeof r.duration=="function"&&typeof r.time=="function"&&typeof r.seek=="function"&&typeof r.play=="function"&&typeof r.pause=="function"}function ve(r){if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(r))throw new Error(`Invalid HyperFrames runtime version: ${r}`);return`https://cdn.jsdelivr.net/npm/@hyperframes/core@${r}/dist/hyperframe.runtime.iife.js`}const be=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:ve("0.0.0-dev");function H(r){if(r===null)return null;const t=Number.parseInt(r,10);return Number.isFinite(t)&&t>0?t:null}function we(r){const t=(r==null?void 0:r.querySelector("[data-composition-id][data-width][data-height]"))??(r==null?void 0:r.querySelector("[data-width][data-height]"));if(!t)return null;const e=H(t.getAttribute("data-width")),i=H(t.getAttribute("data-height"));return e!==null&&i!==null?{width:e,height:i}:null}class Ae{constructor(t,e){c(this,"_interval",null);c(this,"_runtimeInjected",!1);this._iframe=t,this._callbacks=e}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let t=0;this._interval=setInterval(()=>{var e;t++;try{const i=this._iframe.contentWindow;if(!i)return;const s=!!(i.__hf||i.__player),o=!!(i.__timelines&&Object.keys(i.__timelines).length>0),d=!!((e=this._iframe.contentDocument)!=null&&e.querySelector("[data-composition-src]"));if(_e({hasRuntime:s,hasTimelines:o,hasNestedCompositions:d,runtimeInjected:this._runtimeInjected,attempts:t})){this._injectRuntime();return}if(this._runtimeInjected&&!s)return;const a=this._resolvePlaybackDurationAdapter(i);if(a&&a.getDuration()>0){this.stop();const h=we(this._iframe.contentDocument);this._callbacks.onReady({duration:a.getDuration(),adapter:a,compositionSize:h});return}}catch{}t>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{const t=this._iframe.contentWindow;return t?this._resolveDirectTimelineAdapterFromWindow(t):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(t){return this._resolveDirectTimelineAdapterFromWindow(t)}hasRuntimeBridge(t){return Reflect.get(t,"__hf")!==void 0||F(Reflect.get(t,"__player"))}_injectRuntime(){var t,e;this._runtimeInjected=!0;try{const i=this._iframe.contentDocument;if(!i)return;const s=i.createElement("script");s.src=be,(i.head||i.documentElement).appendChild(s),(e=(t=this._callbacks).onRuntimeInjected)==null||e.call(t)}catch{}}_resolveDirectTimelineAdapterFromWindow(t){var a,h;if(this.hasRuntimeBridge(t))return null;const e=Reflect.get(t,"__timelines");if(!F(e))return null;const i=Object.keys(e);if(i.length===0)return null;const s=(h=(a=this._iframe.contentDocument)==null?void 0:a.querySelector("[data-composition-id]"))==null?void 0:h.getAttribute("data-composition-id"),o=s&&s in e?s:i[i.length-1],d=e[o];return ye(d)?d:null}_resolvePlaybackDurationAdapter(t){const e=Reflect.get(t,"__player");if(ge(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const i=this._resolveDirectTimelineAdapterFromWindow(t);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}}const Ee=`
2
2
  :host {
3
3
  display: block;
4
4
  position: relative;
@@ -1 +1 @@
1
- import{g as P}from"./index-CBDJuOGW.js";function j(c,d){for(var s=0;s<d.length;s++){const a=d[s];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in c)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(c,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var v={},w;function k(){if(w)return v;w=1,Object.defineProperty(v,"__esModule",{value:!0}),v.default=d;var c=window.OfflineAudioContext||window.webkitOfflineAudioContext;function d(e){var r=a(e);return r.start(0),[i,y,O(e.sampleRate),s].reduce(function(t,o){return o(t)},r.buffer.getChannelData(0))}function s(e){return e.sort(function(r,t){return t.count-r.count}).splice(0,5)[0].tempo}function a(e){var r=e.length,t=e.numberOfChannels,o=e.sampleRate,n=new c(t,r,o),u=n.createBufferSource();u.buffer=e;var f=n.createBiquadFilter();return f.type="lowpass",u.connect(f),f.connect(n.destination),u}function i(e){for(var r=[],t=.9,o=.3,n=15;r.length<n&&t>=o;)r=l(e,t),t-=.05;if(r.length<n)throw new Error("Could not find enough samples for a reliable detection.");return r}function l(e,r){for(var t=[],o=0,n=e.length;o<n;o+=1)e[o]>r&&(t.push(o),o+=1e4);return t}function y(e){var r=[];return e.forEach(function(t,o){for(var n=function(x){var g=e[o+x]-t,_=r.some(function(h){if(h.interval===g)return h.count+=1});_||r.push({interval:g,count:1})},u=0;u<10;u+=1)n(u)}),r}function O(e){return function(r){var t=[];return r.forEach(function(o){if(o.interval!==0){for(var n=60/(o.interval/e);n<90;)n*=2;for(;n>180;)n/=2;n=Math.round(n);var u=t.some(function(f){if(f.tempo===n)return f.count+=o.count});u||t.push({tempo:n,count:o.count})}}),t}}return v}var p,b;function q(){return b||(b=1,p=k().default),p}var m=q();const A=P(m),D=j({__proto__:null,default:A},[m]);export{D as i};
1
+ import{g as P}from"./index-DzDajONI.js";function j(c,d){for(var s=0;s<d.length;s++){const a=d[s];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in c)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(c,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var v={},w;function k(){if(w)return v;w=1,Object.defineProperty(v,"__esModule",{value:!0}),v.default=d;var c=window.OfflineAudioContext||window.webkitOfflineAudioContext;function d(e){var r=a(e);return r.start(0),[i,y,O(e.sampleRate),s].reduce(function(t,o){return o(t)},r.buffer.getChannelData(0))}function s(e){return e.sort(function(r,t){return t.count-r.count}).splice(0,5)[0].tempo}function a(e){var r=e.length,t=e.numberOfChannels,o=e.sampleRate,n=new c(t,r,o),u=n.createBufferSource();u.buffer=e;var f=n.createBiquadFilter();return f.type="lowpass",u.connect(f),f.connect(n.destination),u}function i(e){for(var r=[],t=.9,o=.3,n=15;r.length<n&&t>=o;)r=l(e,t),t-=.05;if(r.length<n)throw new Error("Could not find enough samples for a reliable detection.");return r}function l(e,r){for(var t=[],o=0,n=e.length;o<n;o+=1)e[o]>r&&(t.push(o),o+=1e4);return t}function y(e){var r=[];return e.forEach(function(t,o){for(var n=function(x){var g=e[o+x]-t,_=r.some(function(h){if(h.interval===g)return h.count+=1});_||r.push({interval:g,count:1})},u=0;u<10;u+=1)n(u)}),r}function O(e){return function(r){var t=[];return r.forEach(function(o){if(o.interval!==0){for(var n=60/(o.interval/e);n<90;)n*=2;for(;n>180;)n/=2;n=Math.round(n);var u=t.some(function(f){if(f.tempo===n)return f.count+=o.count});u||t.push({tempo:n,count:o.count})}}),t}}return v}var p,b;function q(){return b||(b=1,p=k().default),p}var m=q();const A=P(m),D=j({__proto__:null,default:A},[m]);export{D as i};
@@ -1,4 +1,4 @@
1
- import{n as Qi}from"./index-CBDJuOGW.js";/*!
1
+ import{n as Qi}from"./index-DzDajONI.js";/*!
2
2
  * Copyright (c) 2026-present, Vanilagy and contributors
3
3
  *
4
4
  * This Source Code Form is subject to the terms of the Mozilla Public