hyperframes 0.7.87 → 0.7.88

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.87" : "0.0.0-dev";
53
+ VERSION = true ? "0.7.88" : "0.0.0-dev";
54
54
  }
55
55
  });
56
56
 
@@ -68786,6 +68786,8 @@ var init_runFfmpeg = __esm({
68786
68786
  // ../engine/src/utils/ffprobe.ts
68787
68787
  import { spawn as spawn3 } from "child_process";
68788
68788
  import { readFileSync as readFileSync3 } from "fs";
68789
+ import * as zlib from "zlib";
68790
+ import { StringDecoder } from "string_decoder";
68789
68791
  import { basename as basename2, extname } from "path";
68790
68792
  function redactFfprobeInput(stderr, filePath) {
68791
68793
  if (!filePath) return stderr;
@@ -68811,12 +68813,26 @@ function sanitizeFfprobeDiagnostic(stderr, filePath) {
68811
68813
  return `\u2026${redacted.slice(-(FFPROBE_ERROR_MAX_CHARS - 1))}`;
68812
68814
  }
68813
68815
  async function runFfprobe(filePath, argsWithoutInput, signal) {
68816
+ if (filePath === "-") {
68817
+ throw new Error('[FFmpeg] Refusing to probe "-": stdin is not a supported input path.');
68818
+ }
68814
68819
  const command2 = getFfprobeBinary();
68815
- const proc = spawn3(command2, ["-v", "error", ...argsWithoutInput, "--", filePath]);
68820
+ const proc = spawn3(command2, ["-v", "error", ...argsWithoutInput, "--", filePath], {
68821
+ // Nothing is ever written to the child's stdin; leaving it as a pipe is
68822
+ // what lets a stdin-reading invocation block indefinitely.
68823
+ stdio: ["ignore", "pipe", "pipe"]
68824
+ });
68816
68825
  trackChildProcess(proc);
68826
+ const decoder = new StringDecoder("utf8");
68817
68827
  let stdout2 = "";
68828
+ let stdoutTruncated = false;
68818
68829
  proc.stdout.on("data", (data2) => {
68819
- stdout2 += data2.toString();
68830
+ if (stdoutTruncated) return;
68831
+ stdout2 += decoder.write(data2);
68832
+ if (stdout2.length > FFPROBE_STDOUT_MAX_CHARS) {
68833
+ stdoutTruncated = true;
68834
+ stdout2 = "";
68835
+ }
68820
68836
  });
68821
68837
  const managed = new ManagedChildProcess(proc, {
68822
68838
  signal,
@@ -68824,6 +68840,12 @@ async function runFfprobe(filePath, argsWithoutInput, signal) {
68824
68840
  stderrMaxBytes: FFPROBE_STDERR_MAX_BYTES
68825
68841
  });
68826
68842
  const outcome = await managed.wait();
68843
+ stdout2 += decoder.end();
68844
+ if (stdoutTruncated) {
68845
+ throw new Error(
68846
+ `[FFmpeg] ffprobe output exceeded ${FFPROBE_STDOUT_MAX_CHARS} characters; refusing to parse a truncated result.`
68847
+ );
68848
+ }
68827
68849
  if (outcome.reason === "spawn_error") {
68828
68850
  if (outcome.error?.code === "ENOENT") {
68829
68851
  const configured = process.env[FFPROBE_PATH_ENV]?.trim();
@@ -68850,10 +68872,10 @@ function parseProbeJson(stdout2) {
68850
68872
  );
68851
68873
  }
68852
68874
  }
68853
- function crc32(buf) {
68854
- let crc = 4294967295;
68855
- for (let i2 = 0; i2 < buf.length; i2++) {
68856
- crc ^= buf[i2] ?? 0;
68875
+ function crc32Fallback(data2, seed) {
68876
+ let crc = seed ^ 4294967295;
68877
+ for (let i2 = 0; i2 < data2.length; i2++) {
68878
+ crc ^= data2[i2] ?? 0;
68857
68879
  for (let bit = 0; bit < 8; bit++) {
68858
68880
  const mask = -(crc & 1);
68859
68881
  crc = crc >>> 1 ^ 3988292384 & mask;
@@ -68861,6 +68883,11 @@ function crc32(buf) {
68861
68883
  }
68862
68884
  return (crc ^ 4294967295) >>> 0;
68863
68885
  }
68886
+ function chunkCrc32(chunkType, chunkData) {
68887
+ const typeBytes = Buffer.from(chunkType, "ascii");
68888
+ if (nativeCrc32) return nativeCrc32(chunkData, nativeCrc32(typeBytes));
68889
+ return crc32Fallback(chunkData, crc32Fallback(typeBytes, 0));
68890
+ }
68864
68891
  function extractPngMetadataFromBuffer(buf) {
68865
68892
  if (buf.length < 8 || buf[0] !== 137 || buf[1] !== 80 || buf[2] !== 78 || buf[3] !== 71 || buf[4] !== 13 || buf[5] !== 10 || buf[6] !== 26 || buf[7] !== 10) {
68866
68893
  return null;
@@ -68876,9 +68903,8 @@ function extractPngMetadataFromBuffer(buf) {
68876
68903
  if (pos + 12 + chunkLen > buf.length) return null;
68877
68904
  const chunkData = buf.subarray(pos + 8, pos + 8 + chunkLen);
68878
68905
  const chunkCrc = buf.readUInt32BE(pos + 8 + chunkLen);
68879
- const chunkBytes = Buffer.concat([Buffer.from(chunkType, "ascii"), chunkData]);
68880
- if (crc32(chunkBytes) !== chunkCrc) return null;
68881
- if (chunkType === "IHDR" && chunkLen >= 8) {
68906
+ if (chunkCrc32(chunkType, chunkData) !== chunkCrc) return null;
68907
+ if (chunkType === "IHDR" && chunkLen >= 13 && width === 0 && height === 0) {
68882
68908
  width = buf.readUInt32BE(pos + 8);
68883
68909
  height = buf.readUInt32BE(pos + 12);
68884
68910
  }
@@ -68895,11 +68921,15 @@ function extractPngMetadataFromBuffer(buf) {
68895
68921
  colorSpace: matrixCode === 9 ? "bt2020nc" : matrixCode === 0 ? "gbr" : `unknown-${matrixCode}`
68896
68922
  };
68897
68923
  }
68924
+ if (width > 0 && height > 0 && colorSpaceFromCicp !== null) break;
68898
68925
  if (chunkType === "IEND") break;
68899
68926
  pos += 12 + chunkLen;
68900
68927
  }
68901
68928
  return width > 0 && height > 0 ? { width, height, colorSpace: colorSpaceFromCicp } : null;
68902
68929
  }
68930
+ function pixelFormatHasAlpha(pixelFormat) {
68931
+ return /^(?:yuva|rgba|argb|bgra|abgr|gbrap|ya|ayuv)/i.test(pixelFormat);
68932
+ }
68903
68933
  function extractStillImageMetadata(filePath) {
68904
68934
  if (extname(filePath).toLowerCase() !== ".png") return null;
68905
68935
  try {
@@ -68919,22 +68949,28 @@ function readTagCI(tags, name) {
68919
68949
  function parseFrameRate(frameRateStr) {
68920
68950
  if (!frameRateStr) return 0;
68921
68951
  const parts = frameRateStr.split("/");
68922
- if (parts.length === 2) {
68923
- const num2 = parseFloat(parts[0] ?? "");
68924
- const den = parseFloat(parts[1] ?? "");
68925
- if (Number.isFinite(num2) && Number.isFinite(den) && den !== 0) {
68926
- return Math.round(num2 / den * 100) / 100;
68927
- }
68928
- return 0;
68929
- }
68930
- const parsed = parseFloat(frameRateStr);
68931
- return Number.isFinite(parsed) ? parsed : 0;
68952
+ if (parts.length > 2) return 0;
68953
+ const strict = (part) => part === void 0 || part.trim() === "" ? NaN : Number(part.trim());
68954
+ const raw = parts.length === 2 ? (() => {
68955
+ const num2 = strict(parts[0]);
68956
+ const den = strict(parts[1]);
68957
+ if (!Number.isFinite(num2) || !Number.isFinite(den) || den === 0) return NaN;
68958
+ return num2 / den;
68959
+ })() : strict(frameRateStr);
68960
+ if (!Number.isFinite(raw) || raw <= 0) return 0;
68961
+ const rounded = Math.round(raw * 100) / 100;
68962
+ if (!Number.isFinite(rounded)) return 0;
68963
+ return rounded > 0 ? rounded : 0.01;
68932
68964
  }
68933
68965
  async function extractMediaMetadata(filePath) {
68934
68966
  const cached2 = videoMetadataCache.get(filePath);
68935
68967
  if (cached2) return cached2;
68936
68968
  const probePromise = (async () => {
68937
- const stillImageMeta = extractStillImageMetadata(filePath);
68969
+ let stillImageMetaMemo;
68970
+ const stillImage = () => {
68971
+ stillImageMetaMemo ??= extractStillImageMetadata(filePath);
68972
+ return stillImageMetaMemo;
68973
+ };
68938
68974
  let output = null;
68939
68975
  try {
68940
68976
  const stdout2 = await runFfprobe(filePath, [
@@ -68945,10 +68981,11 @@ async function extractMediaMetadata(filePath) {
68945
68981
  ]);
68946
68982
  output = parseProbeJson(stdout2);
68947
68983
  } catch (error) {
68948
- if (!stillImageMeta) throw error;
68984
+ if (!stillImage()) throw error;
68949
68985
  }
68950
68986
  const videoStream = output?.streams.find((s2) => s2.codec_type === "video");
68951
68987
  if (!videoStream) {
68988
+ const stillImageMeta = stillImage();
68952
68989
  if (stillImageMeta) {
68953
68990
  return {
68954
68991
  durationSeconds: 0,
@@ -68972,18 +69009,23 @@ async function extractMediaMetadata(filePath) {
68972
69009
  const colorTransfer = videoStream.color_transfer || "";
68973
69010
  const colorPrimaries = videoStream.color_primaries || "";
68974
69011
  const colorSpaceVal = videoStream.color_space || "";
68975
- const ffprobeColorSpace = colorTransfer || colorPrimaries || colorSpaceVal ? { colorTransfer, colorPrimaries, colorSpace: colorSpaceVal } : null;
68976
- const colorSpace = ffprobeColorSpace ?? stillImageMeta?.colorSpace ?? null;
69012
+ const cicp = colorTransfer && colorPrimaries && colorSpaceVal ? null : stillImage()?.colorSpace;
69013
+ const merged = {
69014
+ colorTransfer: colorTransfer || cicp?.colorTransfer || "",
69015
+ colorPrimaries: colorPrimaries || cicp?.colorPrimaries || "",
69016
+ colorSpace: colorSpaceVal || cicp?.colorSpace || ""
69017
+ };
69018
+ const colorSpace = merged.colorTransfer || merged.colorPrimaries || merged.colorSpace ? merged : null;
68977
69019
  const pixelFormat = videoStream.pix_fmt || "";
68978
69020
  const alphaMode = readTagCI(videoStream.tags, "alpha_mode");
68979
- const hasAlpha = /(^|[^a-z])yuva|rgba|argb|bgra|gbrap|gray[a-z0-9]*a/i.test(pixelFormat) || alphaMode === "1";
69021
+ const hasAlpha = pixelFormatHasAlpha(pixelFormat) || alphaMode === "1";
68980
69022
  const containerDuration = output?.format.duration ? parseFloat(output.format.duration) : 0;
68981
69023
  const streamDuration = videoStream.duration ? parseFloat(videoStream.duration) : 0;
68982
69024
  return {
68983
69025
  durationSeconds: containerDuration,
68984
69026
  videoStreamDurationSeconds: streamDuration > 0 ? streamDuration : containerDuration,
68985
- width: videoStream.width || stillImageMeta?.width || 0,
68986
- height: videoStream.height || stillImageMeta?.height || 0,
69027
+ width: videoStream.width || stillImage()?.width || 0,
69028
+ height: videoStream.height || stillImage()?.height || 0,
68987
69029
  fps,
68988
69030
  videoCodec: videoStream.codec_name || "unknown",
68989
69031
  hasAudio: output?.streams.some((s2) => s2.codec_type === "audio") ?? false,
@@ -69016,20 +69058,29 @@ async function extractAudioMetadata(filePath, options) {
69016
69058
  const streamDuration = audioStream.duration ? parseFloat(audioStream.duration) : void 0;
69017
69059
  const sampleRate = audioStream.sample_rate ? parseInt(audioStream.sample_rate) : 44100;
69018
69060
  const audioCodec = audioStream.codec_name || "unknown";
69019
- if (audioCodec === "aac" && sampleRate > 0) {
69020
- const packetStdout = await runFfprobe(filePath, [
69021
- "-select_streams",
69022
- "a:0",
69023
- "-count_packets",
69024
- "-show_entries",
69025
- "stream=nb_read_packets",
69026
- "-print_format",
69027
- "json"
69028
- ]);
69029
- const packetOutput = parseProbeJson(packetStdout);
69030
- const packetCount = Number(packetOutput.streams[0]?.nb_read_packets);
69031
- if (Number.isFinite(packetCount) && packetCount > 0) {
69032
- durationSeconds = packetCount * AAC_LC_SAMPLES_PER_PACKET / sampleRate;
69061
+ const isAacLc = /^\s*LC\s*$/i.test(audioStream.profile ?? "");
69062
+ if (audioCodec === "aac" && isAacLc && sampleRate > 0) {
69063
+ try {
69064
+ const packetStdout = await runFfprobe(
69065
+ filePath,
69066
+ [
69067
+ "-select_streams",
69068
+ "a:0",
69069
+ "-count_packets",
69070
+ "-show_entries",
69071
+ "stream=nb_read_packets",
69072
+ "-print_format",
69073
+ "json"
69074
+ ],
69075
+ options?.signal
69076
+ );
69077
+ const packetOutput = parseProbeJson(packetStdout);
69078
+ const packetCount = Number(packetOutput.streams[0]?.nb_read_packets);
69079
+ if (Number.isFinite(packetCount) && packetCount > 0) {
69080
+ durationSeconds = packetCount * AAC_LC_SAMPLES_PER_PACKET / sampleRate;
69081
+ }
69082
+ } catch (error) {
69083
+ if (options?.signal?.aborted) throw error;
69033
69084
  }
69034
69085
  }
69035
69086
  return {
@@ -69097,7 +69148,7 @@ async function analyzeKeyframeIntervalsUncached(filePath) {
69097
69148
  isProblematic: maxInterval > 2
69098
69149
  };
69099
69150
  }
69100
- var FFPROBE_STDERR_MAX_BYTES, FFPROBE_ERROR_MAX_CHARS, videoMetadataCache, audioMetadataCache, AAC_LC_SAMPLES_PER_PACKET, extractVideoMetadata, keyframeCache;
69151
+ var FFPROBE_STDERR_MAX_BYTES, FFPROBE_STDOUT_MAX_CHARS, FFPROBE_ERROR_MAX_CHARS, videoMetadataCache, audioMetadataCache, AAC_LC_SAMPLES_PER_PACKET, nativeCrc32, extractVideoMetadata, keyframeCache;
69101
69152
  var init_ffprobe = __esm({
69102
69153
  "../engine/src/utils/ffprobe.ts"() {
69103
69154
  "use strict";
@@ -69106,10 +69157,12 @@ var init_ffprobe = __esm({
69106
69157
  init_managedChildProcess();
69107
69158
  init_processTracker();
69108
69159
  FFPROBE_STDERR_MAX_BYTES = 8 * 1024;
69160
+ FFPROBE_STDOUT_MAX_CHARS = 8e6;
69109
69161
  FFPROBE_ERROR_MAX_CHARS = 4 * 1024;
69110
69162
  videoMetadataCache = /* @__PURE__ */ new Map();
69111
69163
  audioMetadataCache = /* @__PURE__ */ new Map();
69112
69164
  AAC_LC_SAMPLES_PER_PACKET = 1024;
69165
+ nativeCrc32 = typeof zlib.crc32 === "function" ? zlib.crc32 : void 0;
69113
69166
  extractVideoMetadata = extractMediaMetadata;
69114
69167
  keyframeCache = /* @__PURE__ */ new Map();
69115
69168
  }
@@ -97057,7 +97110,7 @@ function colorLabel(input2) {
97057
97110
  }
97058
97111
  return "SDR/unknown";
97059
97112
  }
97060
- function pixelFormatHasAlpha(pixFmt) {
97113
+ function pixelFormatHasAlpha2(pixFmt) {
97061
97114
  return pixFmt !== void 0 && ALPHA_PIX_FMT_RE.test(pixFmt.toLowerCase());
97062
97115
  }
97063
97116
  function classifyMediaColor(stream) {
@@ -97151,7 +97204,7 @@ async function probeAssetCodec(filePath, runner) {
97151
97204
  if (metadata.kind !== "video" || metadata.probeError) return null;
97152
97205
  const codecName = metadata.color.codecName;
97153
97206
  if (!codecName) return null;
97154
- return codecFactsFor(codecName, pixelFormatHasAlpha(metadata.color.pixelFormat));
97207
+ return codecFactsFor(codecName, pixelFormatHasAlpha2(metadata.color.pixelFormat));
97155
97208
  }
97156
97209
  function createMediaCodecProbeCache() {
97157
97210
  return /* @__PURE__ */ new Map();
@@ -155962,7 +156015,7 @@ __export(src_exports3, {
155962
156015
  });
155963
156016
  import http3 from "http";
155964
156017
  import https from "https";
155965
- import zlib from "zlib";
156018
+ import zlib2 from "zlib";
155966
156019
  import Stream2, { PassThrough as PassThrough2, pipeline as pump } from "stream";
155967
156020
  import { Buffer as Buffer4 } from "buffer";
155968
156021
  async function fetch3(url, options_) {
@@ -156134,11 +156187,11 @@ async function fetch3(url, options_) {
156134
156187
  return;
156135
156188
  }
156136
156189
  const zlibOptions = {
156137
- flush: zlib.Z_SYNC_FLUSH,
156138
- finishFlush: zlib.Z_SYNC_FLUSH
156190
+ flush: zlib2.Z_SYNC_FLUSH,
156191
+ finishFlush: zlib2.Z_SYNC_FLUSH
156139
156192
  };
156140
156193
  if (codings === "gzip" || codings === "x-gzip") {
156141
- body = pump(body, zlib.createGunzip(zlibOptions), (error) => {
156194
+ body = pump(body, zlib2.createGunzip(zlibOptions), (error) => {
156142
156195
  if (error) {
156143
156196
  reject(error);
156144
156197
  }
@@ -156155,13 +156208,13 @@ async function fetch3(url, options_) {
156155
156208
  });
156156
156209
  raw.once("data", (chunk) => {
156157
156210
  if ((chunk[0] & 15) === 8) {
156158
- body = pump(body, zlib.createInflate(), (error) => {
156211
+ body = pump(body, zlib2.createInflate(), (error) => {
156159
156212
  if (error) {
156160
156213
  reject(error);
156161
156214
  }
156162
156215
  });
156163
156216
  } else {
156164
- body = pump(body, zlib.createInflateRaw(), (error) => {
156217
+ body = pump(body, zlib2.createInflateRaw(), (error) => {
156165
156218
  if (error) {
156166
156219
  reject(error);
156167
156220
  }
@@ -156179,7 +156232,7 @@ async function fetch3(url, options_) {
156179
156232
  return;
156180
156233
  }
156181
156234
  if (codings === "br") {
156182
- body = pump(body, zlib.createBrotliDecompress(), (error) => {
156235
+ body = pump(body, zlib2.createBrotliDecompress(), (error) => {
156183
156236
  if (error) {
156184
156237
  reject(error);
156185
156238
  }
@@ -166296,7 +166349,7 @@ var require_limiter = __commonJS({
166296
166349
  var require_permessage_deflate = __commonJS({
166297
166350
  "../../node_modules/.bun/ws@8.20.0/node_modules/ws/lib/permessage-deflate.js"(exports, module) {
166298
166351
  "use strict";
166299
- var zlib2 = __require("zlib");
166352
+ var zlib3 = __require("zlib");
166300
166353
  var bufferUtil = require_buffer_util();
166301
166354
  var Limiter = require_limiter();
166302
166355
  var { kStatusCode } = require_constants();
@@ -166563,8 +166616,8 @@ var require_permessage_deflate = __commonJS({
166563
166616
  const endpoint = this._isServer ? "client" : "server";
166564
166617
  if (!this._inflate) {
166565
166618
  const key2 = `${endpoint}_max_window_bits`;
166566
- const windowBits = typeof this.params[key2] !== "number" ? zlib2.Z_DEFAULT_WINDOWBITS : this.params[key2];
166567
- this._inflate = zlib2.createInflateRaw({
166619
+ const windowBits = typeof this.params[key2] !== "number" ? zlib3.Z_DEFAULT_WINDOWBITS : this.params[key2];
166620
+ this._inflate = zlib3.createInflateRaw({
166568
166621
  ...this._options.zlibInflateOptions,
166569
166622
  windowBits
166570
166623
  });
@@ -166614,8 +166667,8 @@ var require_permessage_deflate = __commonJS({
166614
166667
  const endpoint = this._isServer ? "server" : "client";
166615
166668
  if (!this._deflate) {
166616
166669
  const key2 = `${endpoint}_max_window_bits`;
166617
- const windowBits = typeof this.params[key2] !== "number" ? zlib2.Z_DEFAULT_WINDOWBITS : this.params[key2];
166618
- this._deflate = zlib2.createDeflateRaw({
166670
+ const windowBits = typeof this.params[key2] !== "number" ? zlib3.Z_DEFAULT_WINDOWBITS : this.params[key2];
166671
+ this._deflate = zlib3.createDeflateRaw({
166619
166672
  ...this._options.zlibDeflateOptions,
166620
166673
  windowBits
166621
166674
  });
@@ -166625,7 +166678,7 @@ var require_permessage_deflate = __commonJS({
166625
166678
  }
166626
166679
  this._deflate[kCallback] = callback;
166627
166680
  this._deflate.write(data2);
166628
- this._deflate.flush(zlib2.Z_SYNC_FLUSH, () => {
166681
+ this._deflate.flush(zlib3.Z_SYNC_FLUSH, () => {
166629
166682
  if (!this._deflate) {
166630
166683
  return;
166631
166684
  }
@@ -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.87/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.88/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-BblzZ6Av.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-DbY124Po.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-BblzZ6Av.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-DbY124Po.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-BblzZ6Av.js";/*!
1
+ import{n as Qi}from"./index-DbY124Po.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