hyperframes 0.8.60 → 0.8.61

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.8.60" : "0.0.0-dev";
53
+ VERSION = true ? "0.8.61" : "0.0.0-dev";
54
54
  }
55
55
  });
56
56
 
@@ -96241,10 +96241,10 @@ var init_shaderTransitions = __esm({
96241
96241
  const dist = Math.sqrt(uvx * uvx + uvy * uvy);
96242
96242
  const warp = fbm(ux * 4, uy * 4) * 0.5;
96243
96243
  const fromAng = p2 * (1 - dist) * 10 + warp * p2 * 3;
96244
- const fs3 = Math.sin(fromAng);
96244
+ const fs4 = Math.sin(fromAng);
96245
96245
  const fc = Math.cos(fromAng);
96246
- const fromUx = Math.max(0, Math.min(1, uvx * fc - uvy * fs3 + 0.5));
96247
- const fromUy = Math.max(0, Math.min(1, uvx * fs3 + uvy * fc + 0.5));
96246
+ const fromUx = Math.max(0, Math.min(1, uvx * fc - uvy * fs4 + 0.5));
96247
+ const fromUy = Math.max(0, Math.min(1, uvx * fs4 + uvy * fc + 0.5));
96248
96248
  const toAng = -(1 - p2) * (1 - dist) * 10 - warp * (1 - p2) * 3;
96249
96249
  const ts = Math.sin(toAng);
96250
96250
  const tc = Math.cos(toAng);
@@ -121554,19 +121554,21 @@ import { bodyLimit } from "hono/body-limit";
121554
121554
  import {
121555
121555
  closeSync as closeSync8,
121556
121556
  existsSync as existsSync37,
121557
- ftruncateSync as ftruncateSync2,
121558
121557
  openSync as openSync8,
121559
121558
  readFileSync as readFileSync52,
121560
- writeFileSync as writeFileSync52,
121559
+ writeFileSync as writeFileSync42,
121561
121560
  writeSync as writeSync2,
121562
121561
  mkdirSync as mkdirSync32,
121563
121562
  unlinkSync as unlinkSync23,
121564
121563
  rmSync as rmSync32,
121565
- statSync as statSync23,
121564
+ statSync as statSync32,
121565
+ fstatSync as fstatSync4,
121566
121566
  renameSync as renameSync22,
121567
121567
  readdirSync as readdirSync42
121568
121568
  } from "fs";
121569
121569
  import { resolve as resolve32, dirname as dirname32, join as join62 } from "path";
121570
+ import * as fs2 from "fs";
121571
+ import { randomUUID as randomUUID9 } from "crypto";
121570
121572
  import { spawn as spawn11 } from "child_process";
121571
121573
  import {
121572
121574
  existsSync as existsSync38,
@@ -121586,31 +121588,22 @@ import { basename as basename8, join as join42 } from "path";
121586
121588
  import { mkdirSync as mkdirSync22, readdirSync as readdirSync32, readFileSync as readFileSync26, unlinkSync as unlinkSync5, writeFileSync as writeFileSync32 } from "fs";
121587
121589
  import { Buffer as Buffer2 } from "buffer";
121588
121590
  import { join as join52, relative as relative22 } from "path";
121589
- import { createHash as createHash22, randomUUID as randomUUID9 } from "crypto";
121590
- import { readFileSync as readFileSync32, writeFileSync as writeFileSync42 } from "fs";
121591
+ import { createHash as createHash22, randomUUID as randomUUID22 } from "crypto";
121592
+ import { readFileSync as readFileSync32, statSync as statSync23 } from "fs";
121591
121593
  import { existsSync as existsSync211, readFileSync as readFileSync42, realpathSync as realpathSync8 } from "fs";
121592
- import { randomUUID as randomUUID22 } from "crypto";
121594
+ import { randomUUID as randomUUID32 } from "crypto";
121593
121595
  import { dirname as dirname22, relative as relative32, resolve as resolve24, sep as sep22 } from "path";
121594
- import { createReadStream as createReadStream3, existsSync as existsSync52, readFileSync as readFileSync82, statSync as statSync32 } from "fs";
121596
+ import { createReadStream as createReadStream3, existsSync as existsSync52, readFileSync as readFileSync82, statSync as statSync52 } from "fs";
121595
121597
  import { Readable as Readable2 } from "stream";
121596
121598
  import { join as join82, resolve as resolve42 } from "path";
121597
121599
  import { createHash as createHash32 } from "crypto";
121598
121600
  import { existsSync as existsSync42, readFileSync as readFileSync62 } from "fs";
121599
121601
  import { join as join72 } from "path";
121600
- import {
121601
- closeSync as closeSync22,
121602
- constants as constants4,
121603
- fstatSync as fstatSync4,
121604
- ftruncateSync as ftruncateSync22,
121605
- openSync as openSync22,
121606
- readFileSync as readFileSync72,
121607
- writeFileSync as writeFileSync62,
121608
- writeSync as writeSync22
121609
- } from "fs";
121602
+ import { closeSync as closeSync22, constants as constants4, fstatSync as fstatSync22, openSync as openSync22, readFileSync as readFileSync72, statSync as statSync42 } from "fs";
121610
121603
  import { readFileSync as readFileSync92 } from "fs";
121611
121604
  import { join as join92 } from "path";
121612
121605
  import { streamSSE } from "hono/streaming";
121613
- import { existsSync as existsSync62, readFileSync as readFileSync102, mkdirSync as mkdirSync42, unlinkSync as unlinkSync32, readdirSync as readdirSync52, statSync as statSync42 } from "fs";
121606
+ import { existsSync as existsSync62, readFileSync as readFileSync102, mkdirSync as mkdirSync42, unlinkSync as unlinkSync32, readdirSync as readdirSync52, statSync as statSync62 } from "fs";
121614
121607
  import { join as join102 } from "path";
121615
121608
  import {
121616
121609
  existsSync as existsSync72,
@@ -121619,15 +121612,15 @@ import {
121619
121612
  readdirSync as readdirSync62,
121620
121613
  renameSync as renameSync32,
121621
121614
  rmSync as rmSync42,
121622
- statSync as statSync52,
121615
+ statSync as statSync72,
121623
121616
  unlinkSync as unlinkSync42,
121624
- writeFileSync as writeFileSync72
121617
+ writeFileSync as writeFileSync52
121625
121618
  } from "fs";
121626
121619
  import { join as join112 } from "path";
121627
- import { createHash as createHash42, randomUUID as randomUUID32 } from "crypto";
121628
- import { existsSync as existsSync82, readFileSync as readFileSync122, statSync as statSync62 } from "fs";
121620
+ import { createHash as createHash42, randomUUID as randomUUID42 } from "crypto";
121621
+ import { existsSync as existsSync82, readFileSync as readFileSync122, statSync as statSync82 } from "fs";
121629
121622
  import { join as join122 } from "path";
121630
- import { closeSync as closeSync32, constants as constants22, fstatSync as fstatSync22, openSync as openSync32, readSync as readSync2 } from "fs";
121623
+ import { closeSync as closeSync32, constants as constants22, fstatSync as fstatSync32, openSync as openSync32, readSync as readSync2 } from "fs";
121631
121624
  import { streamSSE as streamSSE2 } from "hono/streaming";
121632
121625
  import { existsSync as existsSync92, mkdirSync as mkdirSync62 } from "fs";
121633
121626
  import { basename as basename22, dirname as dirname42, extname as extname22, join as join132 } from "path";
@@ -121826,6 +121819,20 @@ function getMimeType(path) {
121826
121819
  function isAudioFile2(name) {
121827
121820
  return (getMimeType(name) ?? "").startsWith("audio/");
121828
121821
  }
121822
+ function replaceFileAtomically(filePath, content, mode, operations = fs2) {
121823
+ const tempPath = `${filePath}.${process.pid}.${randomUUID9()}.tmp`;
121824
+ try {
121825
+ operations.writeFileSync(tempPath, content, { encoding: "utf-8", mode });
121826
+ operations.chmodSync(tempPath, mode);
121827
+ operations.renameSync(tempPath, filePath);
121828
+ } catch (error) {
121829
+ try {
121830
+ operations.unlinkSync(tempPath);
121831
+ } catch {
121832
+ }
121833
+ throw error;
121834
+ }
121835
+ }
121829
121836
  function buildWaveformCacheKey(assetPath, fingerprint) {
121830
121837
  const name = assetPath.replace(/[/\\]/g, "_");
121831
121838
  if (!fingerprint) return `${WAVEFORM_CACHE_VERSION}_${name}.json`;
@@ -122032,7 +122039,7 @@ function fileContentVersion(content) {
122032
122039
  }
122033
122040
  function createWriteToken(requestToken) {
122034
122041
  const token = requestToken?.trim();
122035
- return token && token.length <= 200 ? token : randomUUID9();
122042
+ return token && token.length <= 200 ? token : randomUUID22();
122036
122043
  }
122037
122044
  function recordFileWriteReceipt(absPath, receipt) {
122038
122045
  const now = Date.now();
@@ -122064,7 +122071,7 @@ function identifyFileWrite(absPath, expectedVersion) {
122064
122071
  const { path, version: version2, writeToken } = receipt;
122065
122072
  return { path, version: version2, writeToken };
122066
122073
  }
122067
- function applyFileMutations(projectDir, mutations, requestToken, writeFile3 = writeFileSync42) {
122074
+ function applyFileMutations(projectDir, mutations, requestToken, writeFile3 = (path, content) => replaceFileAtomically(path, content, statSync23(path).mode)) {
122068
122075
  const prepared = mutations.map((mutation) => ({
122069
122076
  ...mutation,
122070
122077
  before: mutation.before ?? readFileSync32(mutation.absPath, "utf-8")
@@ -122288,7 +122295,7 @@ function insertCompositionIntoSource(input2) {
122288
122295
  const host = document2.createElement("div");
122289
122296
  host.id = hostId;
122290
122297
  host.className = "clip";
122291
- host.setAttribute("data-hf-id", `hf-${randomUUID22()}`);
122298
+ host.setAttribute("data-hf-id", `hf-${randomUUID32()}`);
122292
122299
  host.setAttribute("data-composition-id", hostId);
122293
122300
  host.setAttribute("data-composition-src", relativeSourcePath(targetAbs, sourceAbs));
122294
122301
  host.setAttribute("data-start", String(Math.round(input2.start * 100) / 100));
@@ -122322,13 +122329,18 @@ async function resolveProjectPath(c3, adapter2, pathPrefix, opts) {
122322
122329
  if (!project) {
122323
122330
  return { error: c3.json({ error: "not found" }, 404) };
122324
122331
  }
122332
+ if (!existsSync37(project.dir)) {
122333
+ return {
122334
+ error: c3.json({ error: "not found", why: "project_dir_missing" }, 404)
122335
+ };
122336
+ }
122325
122337
  const filePath = decodeURIComponent(c3.req.path.replace(pathPrefix(project.id), ""));
122326
122338
  if (filePath.includes("\0")) {
122327
- return { error: c3.json({ error: "forbidden" }, 403) };
122339
+ return { error: c3.json({ error: "forbidden", why: "nul" }, 403) };
122328
122340
  }
122329
122341
  const absPath = resolveWithinProject(project.dir, filePath);
122330
122342
  if (!absPath) {
122331
- return { error: c3.json({ error: "forbidden" }, 403) };
122343
+ return { error: c3.json({ error: "forbidden", why: "outside_project" }, 403) };
122332
122344
  }
122333
122345
  if (opts?.mustExist && !existsSync37(absPath)) {
122334
122346
  return { error: c3.json({ error: "not found" }, 404) };
@@ -122387,7 +122399,7 @@ function foldElementPatches(originalContent, patches) {
122387
122399
  }
122388
122400
  return { content, matched };
122389
122401
  }
122390
- function commitElementPatchBatches(projectDir, batches, writeFile3 = writeFileSync52, requestToken) {
122402
+ function commitElementPatchBatches(projectDir, batches, writeFile3 = (path, content) => replaceFileAtomically(path, content, statSync32(path).mode), requestToken) {
122391
122403
  const resolvedPaths = /* @__PURE__ */ new Set();
122392
122404
  const prepared = [];
122393
122405
  for (const batch of batches) {
@@ -122448,7 +122460,7 @@ function commitElementPatchBatchesWithReceipts(c3, projectDir, batches) {
122448
122460
  return commitElementPatchBatches(
122449
122461
  projectDir,
122450
122462
  batches,
122451
- writeFileSync52,
122463
+ writeFileSync42,
122452
122464
  c3.req.header("X-Hyperframes-Write-Token")
122453
122465
  );
122454
122466
  }
@@ -122459,7 +122471,7 @@ function recordMutationReceipt(c3, filePath, absPath, html) {
122459
122471
  return { version: version2, writeToken };
122460
122472
  }
122461
122473
  function writeFileWithReceipt(c3, filePath, absPath, html) {
122462
- writeFileSync52(absPath, html, "utf-8");
122474
+ replaceFileAtomically(absPath, html, statSync32(absPath).mode);
122463
122475
  return recordMutationReceipt(c3, filePath, absPath, html);
122464
122476
  }
122465
122477
  function writeMutationResult(c3, projectDir, filePath, absPath, html) {
@@ -122548,7 +122560,7 @@ function updateReferences(projectDir, oldPath, newPath) {
122548
122560
  if (!content.includes(oldPath)) continue;
122549
122561
  const updated = content.split(oldPath).join(newPath);
122550
122562
  if (updated !== content) {
122551
- writeFileSync52(file, updated, "utf-8");
122563
+ replaceFileAtomically(file, updated, statSync32(file).mode);
122552
122564
  updatedCount++;
122553
122565
  }
122554
122566
  }
@@ -123637,7 +123649,7 @@ async function processUploadedFiles(formData, targetDir, projectDir) {
123637
123649
  try {
123638
123650
  const fd = openSync8(finalPath, "wx");
123639
123651
  try {
123640
- writeFileSync52(fd, buffer);
123652
+ writeFileSync42(fd, buffer);
123641
123653
  } finally {
123642
123654
  closeSync8(fd);
123643
123655
  }
@@ -123765,10 +123777,12 @@ function registerFileRoutes(api, adapter2) {
123765
123777
  }
123766
123778
  backup = snapshotBeforeWrite(res.project.dir, res.absPath);
123767
123779
  if (backup.error) return c3.json({ error: `backup failed: ${backup.error}` }, 500);
123768
- ftruncateSync2(fd, 0);
123769
- writeSync2(fd, body, 0, body.length, 0);
123770
- } finally {
123780
+ const mode = fstatSync4(fd).mode;
123771
123781
  closeSync8(fd);
123782
+ fd = null;
123783
+ replaceFileAtomically(res.absPath, body, mode);
123784
+ } finally {
123785
+ if (fd !== null) closeSync8(fd);
123772
123786
  }
123773
123787
  }
123774
123788
  const version2 = fileContentVersion(body);
@@ -123789,7 +123803,7 @@ function registerFileRoutes(api, adapter2) {
123789
123803
  ensureDir(res.absPath);
123790
123804
  const body = Buffer.from(await c3.req.arrayBuffer());
123791
123805
  try {
123792
- writeFileSync52(res.absPath, body, { flag: "wx" });
123806
+ writeFileSync42(res.absPath, body, { flag: "wx" });
123793
123807
  } catch (error) {
123794
123808
  if (!error || typeof error !== "object" || !("code" in error) || error.code !== "EEXIST") {
123795
123809
  throw error;
@@ -123801,7 +123815,7 @@ function registerFileRoutes(api, adapter2) {
123801
123815
  api.delete("/projects/:id/files/*", async (c3) => {
123802
123816
  const res = await resolveProjectFile(c3, adapter2, { mustExist: true });
123803
123817
  if ("error" in res) return res.error;
123804
- const stat = statSync23(res.absPath);
123818
+ const stat = statSync32(res.absPath);
123805
123819
  const backup = snapshotBeforeWrite(res.project.dir, res.absPath);
123806
123820
  if (backup.error) return c3.json({ error: `backup failed: ${backup.error}` }, 500);
123807
123821
  if (stat.isDirectory()) {
@@ -123991,7 +124005,7 @@ function registerFileRoutes(api, adapter2) {
123991
124005
  const written = [];
123992
124006
  try {
123993
124007
  for (const file of prepared) {
123994
- writeFileSync52(file.absPath, file.after, "utf-8");
124008
+ replaceFileAtomically(file.absPath, file.after, statSync32(file.absPath).mode);
123995
124009
  written.push(file);
123996
124010
  recordFileWriteReceipt(file.absPath, {
123997
124011
  path: file.path,
@@ -124008,7 +124022,7 @@ function registerFileRoutes(api, adapter2) {
124008
124022
  conflicts.push(file.path);
124009
124023
  continue;
124010
124024
  }
124011
- writeFileSync52(file.absPath, file.before, "utf-8");
124025
+ replaceFileAtomically(file.absPath, file.before, statSync32(file.absPath).mode);
124012
124026
  recordFileWriteReceipt(file.absPath, {
124013
124027
  path: file.path,
124014
124028
  version: fileContentVersion(file.before),
@@ -124335,7 +124349,7 @@ function registerFileRoutes(api, adapter2) {
124335
124349
  return c3.json({ error: "forbidden" }, 403);
124336
124350
  }
124337
124351
  ensureDir(destAbs);
124338
- writeFileSync52(destAbs, readFileSync52(srcAbs));
124352
+ writeFileSync42(destAbs, readFileSync52(srcAbs));
124339
124353
  return c3.json({ ok: true, path: copyPath }, 201);
124340
124354
  });
124341
124355
  const MAX_UPLOAD_BYTES = 500 * 1024 * 1024;
@@ -124428,7 +124442,7 @@ function registerFileRoutes(api, adapter2) {
124428
124442
  if (current2 !== body.expected) {
124429
124443
  return c3.json({ ok: true, restored: false, conflict: true });
124430
124444
  }
124431
- writeFileSync52(res.absPath, body.restore, "utf-8");
124445
+ replaceFileAtomically(res.absPath, body.restore, statSync32(res.absPath).mode);
124432
124446
  return c3.json({ ok: true, restored: true, conflict: false });
124433
124447
  });
124434
124448
  }
@@ -124606,7 +124620,7 @@ function persistHfIdsIfNeeded(filePath, html) {
124606
124620
  try {
124607
124621
  const current2 = readFileSync72(filePath, "utf-8");
124608
124622
  if (current2 === html) {
124609
- writeFileSync62(filePath, normalized2, "utf-8");
124623
+ replaceFileAtomically(filePath, normalized2, statSync42(filePath).mode);
124610
124624
  }
124611
124625
  } catch (err) {
124612
124626
  console.warn("[hyperframes] persistHfIdsIfNeeded: failed to write ids to disk:", err);
@@ -124631,21 +124645,23 @@ function stampFileHfIds(filePath) {
124631
124645
  }
124632
124646
  if (fd === null) return null;
124633
124647
  try {
124634
- if (!fstatSync4(fd).isFile()) return null;
124648
+ if (!fstatSync22(fd).isFile()) return null;
124635
124649
  const html = readFileSync72(fd, "utf-8");
124636
124650
  const normalized2 = ensureHfIds(html);
124637
124651
  const idsBefore = (html.match(/\bdata-hf-id=/g) ?? []).length;
124638
124652
  const idsAfter = (normalized2.match(/\bdata-hf-id=/g) ?? []).length;
124639
124653
  if (writable && idsAfter > idsBefore) {
124640
- ftruncateSync22(fd, 0);
124641
- writeSync22(fd, normalized2, 0, "utf-8");
124654
+ const mode = fstatSync22(fd).mode;
124655
+ closeSync22(fd);
124656
+ fd = null;
124657
+ replaceFileAtomically(filePath, normalized2, mode);
124642
124658
  }
124643
124659
  return normalized2;
124644
124660
  } catch (err) {
124645
124661
  console.warn("[hyperframes] stampFileHfIds: failed to stamp ids:", err);
124646
124662
  return null;
124647
124663
  } finally {
124648
- closeSync22(fd);
124664
+ if (fd !== null) closeSync22(fd);
124649
124665
  }
124650
124666
  }
124651
124667
  function isVariablesPayload(value) {
@@ -124920,7 +124936,7 @@ ${runtimeTag}`;
124920
124936
  c3.req.path.replace(`/projects/${project.id}/preview/comp/`, "").split("?")[0] ?? ""
124921
124937
  );
124922
124938
  const compFile = resolveWithinProject(project.dir, compPath);
124923
- if (!compFile || !existsSync52(compFile) || !statSync32(compFile).isFile()) {
124939
+ if (!compFile || !existsSync52(compFile) || !statSync52(compFile).isFile()) {
124924
124940
  return c3.text("not found", 404);
124925
124941
  }
124926
124942
  const compPathHash = createHash32("sha1").update(compPath).digest("hex");
@@ -124960,7 +124976,7 @@ ${runtimeTag}`;
124960
124976
  if (!file) {
124961
124977
  return c3.text("not found", 404);
124962
124978
  }
124963
- const stat = existsSync52(file) ? statSync32(file) : null;
124979
+ const stat = existsSync52(file) ? statSync52(file) : null;
124964
124980
  if (!stat?.isFile()) {
124965
124981
  return c3.text("not found", 404);
124966
124982
  }
@@ -125010,7 +125026,7 @@ ${runtimeTag}`;
125010
125026
  servedContentType = PROXY_VARIANT_CONFIG[proxyVariant].contentType;
125011
125027
  }
125012
125028
  const textBuffer = isText2 ? Buffer.from(readFileSync82(file, "utf-8"), "utf-8") : null;
125013
- const totalSize2 = textBuffer ? textBuffer.length : statSync32(servedPath).size;
125029
+ const totalSize2 = textBuffer ? textBuffer.length : statSync52(servedPath).size;
125014
125030
  const bodyFor = (start, end) => textBuffer ? new Uint8Array(textBuffer.subarray(start, end + 1)) : (
125015
125031
  // Node's web stream type and the DOM one do not overlap for tsc on
125016
125032
  // every platform's lib set; the double cast is the documented bridge.
@@ -125299,7 +125315,7 @@ function registerRenderRoutes(api, adapter2) {
125299
125315
  if (!existsSync62(rendersDir)) return c3.json({ renders: [] });
125300
125316
  const files = readdirSync52(rendersDir).filter((f) => f.endsWith(".mp4") || f.endsWith(".webm") || f.endsWith(".mov")).map((f) => {
125301
125317
  const fp = join102(rendersDir, f);
125302
- const stat = statSync42(fp);
125318
+ const stat = statSync62(fp);
125303
125319
  const rid = f.replace(/\.(mp4|webm|mov)$/, "");
125304
125320
  const metaPath = join102(rendersDir, `${rid}.meta.json`);
125305
125321
  let status = "complete";
@@ -125341,7 +125357,7 @@ function pruneThumbnailCache(cacheDir, protectedPaths, now = Date.now()) {
125341
125357
  if (!entry.isFile()) return [];
125342
125358
  const path = join112(cacheDir, entry.name);
125343
125359
  try {
125344
- const stats = statSync52(path);
125360
+ const stats = statSync72(path);
125345
125361
  return [{ path, bytes: stats.size, mtimeMs: stats.mtimeMs }];
125346
125362
  } catch {
125347
125363
  return [];
@@ -125367,9 +125383,9 @@ function pruneThumbnailCache(cacheDir, protectedPaths, now = Date.now()) {
125367
125383
  }
125368
125384
  }
125369
125385
  function writeThumbnailAtomically(path, buffer) {
125370
- const temporaryPath = `${path}.${process.pid}.${randomUUID32()}.tmp`;
125386
+ const temporaryPath = `${path}.${process.pid}.${randomUUID42()}.tmp`;
125371
125387
  try {
125372
- writeFileSync72(temporaryPath, buffer, { flag: "wx" });
125388
+ writeFileSync52(temporaryPath, buffer, { flag: "wx" });
125373
125389
  renameSync32(temporaryPath, path);
125374
125390
  } finally {
125375
125391
  rmSync42(temporaryPath, { force: true });
@@ -125409,7 +125425,7 @@ function registerThumbnailRoutes(api, adapter2) {
125409
125425
  if (existsSync72(htmlFile)) {
125410
125426
  const html = readFileSync112(htmlFile, "utf-8");
125411
125427
  sourceKey = `_${createHash42("sha1").update(html).digest("hex").slice(0, 16)}`;
125412
- sourceMtime = Math.round(statSync52(htmlFile).mtimeMs);
125428
+ sourceMtime = Math.round(statSync72(htmlFile).mtimeMs);
125413
125429
  if (!vpWidth) {
125414
125430
  const wMatch = html.match(/data-width=["'](\d+)["']/);
125415
125431
  const hMatch = html.match(/data-height=["'](\d+)["']/);
@@ -125422,14 +125438,14 @@ function registerThumbnailRoutes(api, adapter2) {
125422
125438
  if (existsSync72(manualEditsFile)) {
125423
125439
  const manualEditsContent = readFileSync112(manualEditsFile, "utf-8");
125424
125440
  manualEditsKey = `_${createHash42("sha1").update(manualEditsContent).digest("hex").slice(0, 16)}`;
125425
- sourceMtime = Math.max(sourceMtime, Math.round(statSync52(manualEditsFile).mtimeMs));
125441
+ sourceMtime = Math.max(sourceMtime, Math.round(statSync72(manualEditsFile).mtimeMs));
125426
125442
  }
125427
125443
  const motionFile = join112(project.dir, STUDIO_MOTION_PATH);
125428
125444
  let motionKey = "";
125429
125445
  if (existsSync72(motionFile)) {
125430
125446
  const motionContent = readFileSync112(motionFile, "utf-8");
125431
125447
  motionKey = `_${createHash42("sha1").update(motionContent).digest("hex").slice(0, 16)}`;
125432
- sourceMtime = Math.max(sourceMtime, Math.round(statSync52(motionFile).mtimeMs));
125448
+ sourceMtime = Math.max(sourceMtime, Math.round(statSync72(motionFile).mtimeMs));
125433
125449
  }
125434
125450
  const previewUrl = compPath === "index.html" ? `http://${c3.req.header("host")}/api/projects/${project.id}/preview` : `http://${c3.req.header("host")}/api/projects/${project.id}/preview/comp/${compPath}`;
125435
125451
  const cacheDir = join112(project.dir, ".thumbnails");
@@ -125510,7 +125526,7 @@ function registerWaveformRoutes(api, adapter2) {
125510
125526
  c3.req.path.replace(`/projects/${project.id}/waveform/`, "").split("?")[0] ?? ""
125511
125527
  );
125512
125528
  const audioPath = join122(project.dir, assetPath);
125513
- const stats = statSync62(audioPath, { throwIfNoEntry: false });
125529
+ const stats = statSync82(audioPath, { throwIfNoEntry: false });
125514
125530
  if (!stats) return c3.json({ error: "file not found" }, 404);
125515
125531
  const cacheDir = join122(project.dir, ".waveform-cache");
125516
125532
  const cachePath2 = join122(cacheDir, buildWaveformCacheKey(assetPath, stats));
@@ -125611,7 +125627,7 @@ function registerFontRoutes(api) {
125611
125627
  return c3.json({ error: "font file not accessible" }, 404);
125612
125628
  }
125613
125629
  try {
125614
- const stat = fstatSync22(fd);
125630
+ const stat = fstatSync32(fd);
125615
125631
  if (stat.size > SYSTEM_FONT_SIZE_LIMIT) {
125616
125632
  return c3.json({ error: "font file too large" }, 413);
125617
125633
  }
@@ -151860,7 +151876,10 @@ function createStudioServer(options) {
151860
151876
  } catch {
151861
151877
  }
151862
151878
  const receipt = version2 ? identifyFileWrite(absPath, version2) : null;
151863
- stream.writeSSE({ event: "file-change", data: JSON.stringify({ path, version: version2, ...receipt }) }).catch(() => {
151879
+ stream.writeSSE({
151880
+ event: "file-change",
151881
+ data: JSON.stringify({ path, version: version2, projectId: project.id, ...receipt })
151882
+ }).catch(() => {
151864
151883
  });
151865
151884
  };
151866
151885
  const wrappedListener = (changedPath) => {
@@ -156626,12 +156645,12 @@ var init_paths2 = __esm({
156626
156645
  });
156627
156646
 
156628
156647
  // src/auth/store.ts
156629
- import { promises as fs2 } from "fs";
156648
+ import { promises as fs3 } from "fs";
156630
156649
  import { dirname as dirname43 } from "path";
156631
156650
  async function readStore(path = credentialPath()) {
156632
156651
  let raw;
156633
156652
  try {
156634
- raw = await fs2.readFile(path, "utf8");
156653
+ raw = await fs3.readFile(path, "utf8");
156635
156654
  } catch (err) {
156636
156655
  if (err.code === "ENOENT") {
156637
156656
  return { credentials: {}, source: "absent" };
@@ -156652,14 +156671,14 @@ async function writeStore(credentials, path = credentialPath()) {
156652
156671
  await ensureDir2(dirname43(path));
156653
156672
  const body = JSON.stringify(serializeCredentials(credentials), null, 2);
156654
156673
  const tmp = `${path}.${process.pid}.${Date.now()}.tmp`;
156655
- await fs2.writeFile(tmp, `${body}
156674
+ await fs3.writeFile(tmp, `${body}
156656
156675
  `, { mode: FILE_MODE, encoding: "utf8" });
156657
- await fs2.chmod(tmp, FILE_MODE);
156658
- await fs2.rename(tmp, path);
156676
+ await fs3.chmod(tmp, FILE_MODE);
156677
+ await fs3.rename(tmp, path);
156659
156678
  }
156660
156679
  async function deleteStore(path = credentialPath()) {
156661
156680
  try {
156662
- await fs2.unlink(path);
156681
+ await fs3.unlink(path);
156663
156682
  } catch (err) {
156664
156683
  if (err.code === "ENOENT") return;
156665
156684
  throw err;
@@ -156687,16 +156706,16 @@ async function clearOAuth(path = credentialPath()) {
156687
156706
  }
156688
156707
  async function ensureDir2(dir) {
156689
156708
  try {
156690
- const stat = await fs2.stat(dir);
156709
+ const stat = await fs3.stat(dir);
156691
156710
  if (!stat.isDirectory()) {
156692
156711
  throw ErrInvalidStore(`${dir} exists and is not a directory`);
156693
156712
  }
156694
156713
  } catch (err) {
156695
156714
  if (err.code !== "ENOENT") throw err;
156696
- await fs2.mkdir(dir, { recursive: true, mode: DIR_MODE });
156715
+ await fs3.mkdir(dir, { recursive: true, mode: DIR_MODE });
156697
156716
  }
156698
156717
  try {
156699
- await fs2.chmod(dir, DIR_MODE);
156718
+ await fs3.chmod(dir, DIR_MODE);
156700
156719
  } catch {
156701
156720
  }
156702
156721
  }
@@ -102748,8 +102748,8 @@ async function runFontLocalize(io, localize) {
102748
102748
  }
102749
102749
 
102750
102750
  // src/version.ts
102751
- var VERSION = true ? "0.8.60" : "0.0.0-dev";
102752
- var PRODUCER_VERSION = true ? "0.8.60" : "0.0.0-dev";
102751
+ var VERSION = true ? "0.8.61" : "0.0.0-dev";
102752
+ var PRODUCER_VERSION = true ? "0.8.61" : "0.0.0-dev";
102753
102753
 
102754
102754
  // src/fontLocalizeCli.ts
102755
102755
  async function readStdin() {
@@ -1,4 +1,4 @@
1
- "use strict";var HyperframesPlayer=(()=>{var Ee=Object.defineProperty;var pn=Object.getOwnPropertyDescriptor;var fn=Object.getOwnPropertyNames;var hn=Object.prototype.hasOwnProperty;var bn=(n,e)=>{for(var t in e)Ee(n,t,{get:e[t],enumerable:!0})},gn=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of fn(e))!hn.call(n,r)&&r!==t&&Ee(n,r,{get:()=>e[r],enumerable:!(i=pn(e,r))||i.enumerable});return n};var _n=n=>gn(Ee({},"__esModule",{value:!0}),n);var Yi={};bn(Yi,{HyperframesPlayer:()=>Ae,SPEED_PRESETS:()=>xe,formatSpeed:()=>G,formatTime:()=>ie});function dt(n){return n.hasRuntime||n.runtimeInjected?!1:!!(n.hasNestedCompositions||n.hasTimelines&&n.attempts>=5)}function H(n){return typeof n=="object"&&n!==null}function ct(n){return H(n)&&typeof n.getDuration=="function"}function mt(n){return H(n)&&typeof n.duration=="function"&&typeof n.time=="function"&&typeof n.seek=="function"&&typeof n.play=="function"&&typeof n.pause=="function"}var L="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.8.60/dist/hyperframe.runtime.iife.js";function V(n){if(n===null)return null;let e=Number.parseInt(n,10);return Number.isFinite(e)&&e>0?e:null}function yn(n){let e=n?.querySelector("[data-composition-id][data-width][data-height]")??n?.querySelector("[data-width][data-height]");if(!e)return null;let t=V(e.getAttribute("data-width")),i=V(e.getAttribute("data-height"));return t!==null&&i!==null?{width:t,height:i}:null}var ne=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 i=!!(t.__hf||t.__player),r=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!this._iframe.contentDocument?.querySelector("[data-composition-src]");if(dt({hasRuntime:i,hasTimelines:r,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:e})){this._injectRuntime();return}if(this._runtimeInjected&&!i)return;let a=this._resolvePlaybackDurationAdapter(t);if(a&&a.getDuration()>0){this.stop();let s=yn(this._iframe.contentDocument);this._callbacks.onReady({duration:a.getDuration(),adapter:a,compositionSize:s});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||H(Reflect.get(e,"__player"))}_injectRuntime(){this._runtimeInjected=!0;try{let e=this._iframe.contentDocument;if(!e)return;let t=e.createElement("script");t.src=L,(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(!H(t))return null;let i=Object.keys(t);if(i.length===0)return null;let r=this._iframe.contentDocument?.querySelector("[data-composition-id]")?.getAttribute("data-composition-id"),o=r&&r in t?r:i[i.length-1],a=t[o];return mt(a)?a:null}_resolvePlaybackDurationAdapter(e){let t=Reflect.get(e,"__player");if(ct(t))return{kind:"runtime",getDuration:()=>t.getDuration()};let i=this._resolveDirectTimelineAdapterFromWindow(e);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}};var pt=`
1
+ "use strict";var HyperframesPlayer=(()=>{var Ee=Object.defineProperty;var pn=Object.getOwnPropertyDescriptor;var fn=Object.getOwnPropertyNames;var hn=Object.prototype.hasOwnProperty;var bn=(n,e)=>{for(var t in e)Ee(n,t,{get:e[t],enumerable:!0})},gn=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of fn(e))!hn.call(n,r)&&r!==t&&Ee(n,r,{get:()=>e[r],enumerable:!(i=pn(e,r))||i.enumerable});return n};var _n=n=>gn(Ee({},"__esModule",{value:!0}),n);var Yi={};bn(Yi,{HyperframesPlayer:()=>Ae,SPEED_PRESETS:()=>xe,formatSpeed:()=>G,formatTime:()=>ie});function dt(n){return n.hasRuntime||n.runtimeInjected?!1:!!(n.hasNestedCompositions||n.hasTimelines&&n.attempts>=5)}function H(n){return typeof n=="object"&&n!==null}function ct(n){return H(n)&&typeof n.getDuration=="function"}function mt(n){return H(n)&&typeof n.duration=="function"&&typeof n.time=="function"&&typeof n.seek=="function"&&typeof n.play=="function"&&typeof n.pause=="function"}var L="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.8.61/dist/hyperframe.runtime.iife.js";function V(n){if(n===null)return null;let e=Number.parseInt(n,10);return Number.isFinite(e)&&e>0?e:null}function yn(n){let e=n?.querySelector("[data-composition-id][data-width][data-height]")??n?.querySelector("[data-width][data-height]");if(!e)return null;let t=V(e.getAttribute("data-width")),i=V(e.getAttribute("data-height"));return t!==null&&i!==null?{width:t,height:i}:null}var ne=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 i=!!(t.__hf||t.__player),r=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!this._iframe.contentDocument?.querySelector("[data-composition-src]");if(dt({hasRuntime:i,hasTimelines:r,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:e})){this._injectRuntime();return}if(this._runtimeInjected&&!i)return;let a=this._resolvePlaybackDurationAdapter(t);if(a&&a.getDuration()>0){this.stop();let s=yn(this._iframe.contentDocument);this._callbacks.onReady({duration:a.getDuration(),adapter:a,compositionSize:s});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||H(Reflect.get(e,"__player"))}_injectRuntime(){this._runtimeInjected=!0;try{let e=this._iframe.contentDocument;if(!e)return;let t=e.createElement("script");t.src=L,(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(!H(t))return null;let i=Object.keys(t);if(i.length===0)return null;let r=this._iframe.contentDocument?.querySelector("[data-composition-id]")?.getAttribute("data-composition-id"),o=r&&r in t?r:i[i.length-1],a=t[o];return mt(a)?a:null}_resolvePlaybackDurationAdapter(e){let t=Reflect.get(e,"__player");if(ct(t))return{kind:"runtime",getDuration:()=>t.getDuration()};let i=this._resolveDirectTimelineAdapterFromWindow(e);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}};var pt=`
2
2
  :host {
3
3
  display: block;
4
4
  position: relative;
@@ -18,7 +18,7 @@ npx hyperframes init my-video --non-interactive # CI — flag-o
18
18
 
19
19
  **Default depends on TTY**: in a terminal, the CLI prompts for example/options (default: centered blank). Outside a TTY (CI, agents, piped output) it auto-switches to non-interactive and scaffolds that blank. Pass `--example` only to start from a named example. Pass `--non-interactive` to force flag-only mode on a TTY.
20
20
 
21
- Templates: `blank`, `warm-grain`, `play-mode`, `swiss-grid`, `vignelli`, `decision-tree`, `kinetic-type`, `product-promo`, `nyt-graph`, `vscode-theme-visualizer`. (The closed set of `hyperframes:example` items in `registry/registry.json` plus the bundled `blank` template. `hyperframes catalog` does not list examples — its `--type` takes only `block` or `component` — so this list has no live equivalent and is checked by `bun run lint:skills`.)
21
+ Templates: `blank`, `warm-grain`, `play-mode`, `swiss-grid`, `vignelli`, `decision-tree`, `kinetic-type`, `product-promo`, `nyt-graph`. (The closed set of `hyperframes:example` items in `registry/registry.json` plus the bundled `blank` template. `hyperframes catalog` does not list examples — its `--type` takes only `block` or `component` — so this list has no live equivalent and is checked by `bun run lint:skills`.)
22
22
 
23
23
  Other useful flags:
24
24
 
@@ -1,4 +1,4 @@
1
- var we=Object.defineProperty;var Ae=(s,i,e)=>i in s?we(s,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[i]=e;var h=(s,i,e)=>Ae(s,typeof i!="symbol"?i+"":i,e);import{r as he,i as Ee,a as w,b as ue,c as Ce,d as Te,s as Re,e as Se,F as Le}from"./index-Dpq2lkOm.js";function xe(s){return s.hasRuntime||s.runtimeInjected?!1:!!(s.hasNestedCompositions||s.hasTimelines&&s.attempts>=5)}function $(s){return typeof s=="object"&&s!==null}function Me(s){return $(s)&&typeof s.getDuration=="function"}function De(s){return $(s)&&typeof s.duration=="function"&&typeof s.time=="function"&&typeof s.seek=="function"&&typeof s.play=="function"&&typeof s.pause=="function"}function Pe(s){if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(s))throw new Error(`Invalid HyperFrames runtime version: ${s}`);return`https://cdn.jsdelivr.net/npm/@hyperframes/core@${s}/dist/hyperframe.runtime.iife.js`}const H=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:Pe("0.0.0-dev");function V(s){if(s===null)return null;const i=Number.parseInt(s,10);return Number.isFinite(i)&&i>0?i:null}function ke(s){const i=(s==null?void 0:s.querySelector("[data-composition-id][data-width][data-height]"))??(s==null?void 0:s.querySelector("[data-width][data-height]"));if(!i)return null;const e=V(i.getAttribute("data-width")),t=V(i.getAttribute("data-height"));return e!==null&&t!==null?{width:e,height:t}:null}class Ie{constructor(i,e){h(this,"_interval",null);h(this,"_runtimeInjected",!1);this._iframe=i,this._callbacks=e}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let i=0;this._interval=setInterval(()=>{var e;i++;try{const t=this._iframe.contentWindow;if(!t)return;const r=!!(t.__hf||t.__player),n=!!(t.__timelines&&Object.keys(t.__timelines).length>0),a=!!((e=this._iframe.contentDocument)!=null&&e.querySelector("[data-composition-src]"));if(xe({hasRuntime:r,hasTimelines:n,hasNestedCompositions:a,runtimeInjected:this._runtimeInjected,attempts:i})){this._injectRuntime();return}if(this._runtimeInjected&&!r)return;const d=this._resolvePlaybackDurationAdapter(t);if(d&&d.getDuration()>0){this.stop();const c=ke(this._iframe.contentDocument);this._callbacks.onReady({duration:d.getDuration(),adapter:d,compositionSize:c});return}}catch{}i>=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 i=this._iframe.contentWindow;return i?this._resolveDirectTimelineAdapterFromWindow(i):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(i){return this._resolveDirectTimelineAdapterFromWindow(i)}hasRuntimeBridge(i){return Reflect.get(i,"__hf")!==void 0||$(Reflect.get(i,"__player"))}_injectRuntime(){var i,e;this._runtimeInjected=!0;try{const t=this._iframe.contentDocument;if(!t)return;const r=t.createElement("script");r.src=H,(t.head||t.documentElement).appendChild(r),(e=(i=this._callbacks).onRuntimeInjected)==null||e.call(i)}catch{}}_resolveDirectTimelineAdapterFromWindow(i){var d,c;if(this.hasRuntimeBridge(i))return null;const e=Reflect.get(i,"__timelines");if(!$(e))return null;const t=Object.keys(e);if(t.length===0)return null;const r=(c=(d=this._iframe.contentDocument)==null?void 0:d.querySelector("[data-composition-id]"))==null?void 0:c.getAttribute("data-composition-id"),n=r&&r in e?r:t[t.length-1],a=e[n];return De(a)?a:null}_resolvePlaybackDurationAdapter(i){const e=Reflect.get(i,"__player");if(Me(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const t=this._resolveDirectTimelineAdapterFromWindow(i);return t?{kind:"direct-timeline",timeline:t,getDuration:()=>t.duration()}:null}}const Oe=`
1
+ var we=Object.defineProperty;var Ae=(s,i,e)=>i in s?we(s,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[i]=e;var h=(s,i,e)=>Ae(s,typeof i!="symbol"?i+"":i,e);import{r as he,i as Ee,a as w,b as ue,c as Ce,d as Te,s as Re,e as Se,F as Le}from"./index-BK36b0XY.js";function xe(s){return s.hasRuntime||s.runtimeInjected?!1:!!(s.hasNestedCompositions||s.hasTimelines&&s.attempts>=5)}function $(s){return typeof s=="object"&&s!==null}function Me(s){return $(s)&&typeof s.getDuration=="function"}function De(s){return $(s)&&typeof s.duration=="function"&&typeof s.time=="function"&&typeof s.seek=="function"&&typeof s.play=="function"&&typeof s.pause=="function"}function Pe(s){if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(s))throw new Error(`Invalid HyperFrames runtime version: ${s}`);return`https://cdn.jsdelivr.net/npm/@hyperframes/core@${s}/dist/hyperframe.runtime.iife.js`}const H=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:Pe("0.0.0-dev");function V(s){if(s===null)return null;const i=Number.parseInt(s,10);return Number.isFinite(i)&&i>0?i:null}function ke(s){const i=(s==null?void 0:s.querySelector("[data-composition-id][data-width][data-height]"))??(s==null?void 0:s.querySelector("[data-width][data-height]"));if(!i)return null;const e=V(i.getAttribute("data-width")),t=V(i.getAttribute("data-height"));return e!==null&&t!==null?{width:e,height:t}:null}class Ie{constructor(i,e){h(this,"_interval",null);h(this,"_runtimeInjected",!1);this._iframe=i,this._callbacks=e}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let i=0;this._interval=setInterval(()=>{var e;i++;try{const t=this._iframe.contentWindow;if(!t)return;const r=!!(t.__hf||t.__player),n=!!(t.__timelines&&Object.keys(t.__timelines).length>0),a=!!((e=this._iframe.contentDocument)!=null&&e.querySelector("[data-composition-src]"));if(xe({hasRuntime:r,hasTimelines:n,hasNestedCompositions:a,runtimeInjected:this._runtimeInjected,attempts:i})){this._injectRuntime();return}if(this._runtimeInjected&&!r)return;const d=this._resolvePlaybackDurationAdapter(t);if(d&&d.getDuration()>0){this.stop();const c=ke(this._iframe.contentDocument);this._callbacks.onReady({duration:d.getDuration(),adapter:d,compositionSize:c});return}}catch{}i>=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 i=this._iframe.contentWindow;return i?this._resolveDirectTimelineAdapterFromWindow(i):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(i){return this._resolveDirectTimelineAdapterFromWindow(i)}hasRuntimeBridge(i){return Reflect.get(i,"__hf")!==void 0||$(Reflect.get(i,"__player"))}_injectRuntime(){var i,e;this._runtimeInjected=!0;try{const t=this._iframe.contentDocument;if(!t)return;const r=t.createElement("script");r.src=H,(t.head||t.documentElement).appendChild(r),(e=(i=this._callbacks).onRuntimeInjected)==null||e.call(i)}catch{}}_resolveDirectTimelineAdapterFromWindow(i){var d,c;if(this.hasRuntimeBridge(i))return null;const e=Reflect.get(i,"__timelines");if(!$(e))return null;const t=Object.keys(e);if(t.length===0)return null;const r=(c=(d=this._iframe.contentDocument)==null?void 0:d.querySelector("[data-composition-id]"))==null?void 0:c.getAttribute("data-composition-id"),n=r&&r in e?r:t[t.length-1],a=e[n];return De(a)?a:null}_resolvePlaybackDurationAdapter(i){const e=Reflect.get(i,"__player");if(Me(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const t=this._resolveDirectTimelineAdapterFromWindow(i);return t?{kind:"direct-timeline",timeline:t,getDuration:()=>t.duration()}:null}}const Oe=`
2
2
  :host {
3
3
  display: block;
4
4
  position: relative;
@@ -1 +1 @@
1
- import{g as P}from"./index-Dpq2lkOm.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-BK36b0XY.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};