hyperframes 0.7.102 → 0.7.104

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.
@@ -145,11 +145,23 @@
145
145
 
146
146
  // ../core/src/beats/beatDetection.ts
147
147
  var bpmDetectivePromise = null;
148
- function loadBpmDetective() {
149
- if (!bpmDetectivePromise) {
150
- bpmDetectivePromise = Promise.resolve().then(() => __toESM(require_lib(), 1)).then((m) => (m.default ?? m) || null).catch(() => null);
148
+ var defaultBpmDetectiveImport = () => (
149
+ // @ts-ignore -- no type declarations for bpm-detective
150
+ Promise.resolve().then(() => __toESM(require_lib(), 1))
151
+ );
152
+ function loadBpmDetective(importFn = defaultBpmDetectiveImport) {
153
+ const useCache = importFn === defaultBpmDetectiveImport;
154
+ if (useCache && bpmDetectivePromise) {
155
+ return bpmDetectivePromise;
151
156
  }
152
- return bpmDetectivePromise;
157
+ const promise = importFn().then((m) => (m.default ?? m) || null).catch(() => {
158
+ if (useCache) bpmDetectivePromise = null;
159
+ return null;
160
+ });
161
+ if (useCache) {
162
+ bpmDetectivePromise = promise;
163
+ }
164
+ return promise;
153
165
  }
154
166
  var WINDOW_SIZE = 1024;
155
167
  var HOP_SIZE = 512;
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.102" : "0.0.0-dev";
53
+ VERSION = true ? "0.7.104" : "0.0.0-dev";
54
54
  }
55
55
  });
56
56
 
@@ -62451,26 +62451,6 @@ var init_canaryRegistry = __esm({
62451
62451
  description: "Inert. Second calibration point, and an independence check against calibration-10.",
62452
62452
  owner: "vance",
62453
62453
  sunsetAfter: "2026-09-15"
62454
- },
62455
- // ── Real rollouts ────────────────────────────────────────────────────────
62456
- {
62457
- name: "de-parallel-router",
62458
- // Ramp 5 -> 25 -> 100. This gates the DEFAULT-ON behaviour (uncapped, no
62459
- // telemetry precondition), not the old capped trial — so 0 means the
62460
- // router is off for everyone and is a full revert without a release.
62461
- //
62462
- // Calibration validated the bucketer first: 9.62%/49.76% against 10%/50%
62463
- // targets at n=13,547, overrides and CI both attributable, sustained
62464
- // cohort flips at 0.10% — an order of magnitude under this feature's own
62465
- // ~2.79% revert rate.
62466
- //
62467
- // At each step split revert rate by cpu_count and is_docker. Hold at 5
62468
- // until PRINFRA-372 is resolved: `--workers auto` crashes every worker on
62469
- // macOS arm64 while `--workers 1` is clean, and the router forces 3.
62470
- percentage: 5,
62471
- description: "Route auto multi-worker renders to verified parallel drawElement streaming (HF_DE_PARALLEL_ROUTER). Ramp only alongside the per-install circuit breaker.",
62472
- owner: "vance",
62473
- sunsetAfter: "2026-10-01"
62474
62454
  }
62475
62455
  ];
62476
62456
  }
@@ -90918,9 +90898,6 @@ function resolveCanary(name) {
90918
90898
  decisions.set(name, decision);
90919
90899
  return decision;
90920
90900
  }
90921
- function isCanaryEnabled(name) {
90922
- return resolveCanary(name).enabled;
90923
- }
90924
90901
  function canaryDecisionsForStudio() {
90925
90902
  const out = {};
90926
90903
  for (const canary of CANARIES) {
@@ -98098,6 +98075,7 @@ function shouldWatchProjectFile(filename) {
98098
98075
  }
98099
98076
  function createProjectWatcher(projectDir) {
98100
98077
  const listeners = /* @__PURE__ */ new Set();
98078
+ const pendingPaths = /* @__PURE__ */ new Set();
98101
98079
  let debounceTimer = null;
98102
98080
  let watcher = null;
98103
98081
  try {
@@ -98105,10 +98083,16 @@ function createProjectWatcher(projectDir) {
98105
98083
  if (!filename) return;
98106
98084
  const relativePath = filename.toString();
98107
98085
  if (!shouldWatchProjectFile(relativePath)) return;
98086
+ pendingPaths.add(relativePath);
98108
98087
  if (debounceTimer) clearTimeout(debounceTimer);
98109
98088
  debounceTimer = setTimeout(() => {
98110
- for (const fn of listeners) {
98111
- fn(relativePath);
98089
+ const changedPaths = [...pendingPaths];
98090
+ pendingPaths.clear();
98091
+ debounceTimer = null;
98092
+ for (const changedPath of changedPaths) {
98093
+ for (const fn of listeners) {
98094
+ fn(changedPath);
98095
+ }
98112
98096
  }
98113
98097
  }, DEBOUNCE_MS);
98114
98098
  });
@@ -98127,6 +98111,7 @@ function createProjectWatcher(projectDir) {
98127
98111
  },
98128
98112
  close() {
98129
98113
  if (debounceTimer) clearTimeout(debounceTimer);
98114
+ pendingPaths.clear();
98130
98115
  watcher?.close();
98131
98116
  listeners.clear();
98132
98117
  }
@@ -107201,12 +107186,13 @@ function recordFileWriteReceipt(absPath, receipt) {
107201
107186
  current2.push({ ...receipt, recordedAt: now });
107202
107187
  receipts.set(absPath, current2);
107203
107188
  }
107204
- function consumeFileWriteReceipt(absPath) {
107189
+ function consumeFileWriteReceipt(absPath, expectedVersion) {
107205
107190
  const now = Date.now();
107206
107191
  const current2 = (receipts.get(absPath) ?? []).filter(
107207
107192
  (entry) => now - entry.recordedAt < RECEIPT_TTL_MS
107208
107193
  );
107209
- const receipt = current2.shift() ?? null;
107194
+ const receiptIndex = current2.findIndex((entry) => entry.version === expectedVersion);
107195
+ const receipt = receiptIndex === -1 ? null : current2.splice(receiptIndex, 1)[0] ?? null;
107210
107196
  if (current2.length > 0) receipts.set(absPath, current2);
107211
107197
  else receipts.delete(absPath);
107212
107198
  if (!receipt) return null;
@@ -107547,19 +107533,44 @@ function commitElementPatchBatches(projectDir, batches, writeFile4 = writeFileSy
107547
107533
  }
107548
107534
  return { durable: true, files };
107549
107535
  }
107536
+ function commitElementPatchBatchesWithReceipts(c3, projectDir, batches) {
107537
+ const result = commitElementPatchBatches(projectDir, batches);
107538
+ if ("error" in result || !result.durable) return result;
107539
+ for (const file of result.files) {
107540
+ if (!file.changed) continue;
107541
+ const absPath = resolveWithinProject(projectDir, file.sourceFile);
107542
+ if (!absPath) throw new Error(`Committed element patch escaped project: ${file.sourceFile}`);
107543
+ recordMutationReceipt(c3, file.sourceFile, absPath, file.after);
107544
+ }
107545
+ return result;
107546
+ }
107547
+ function recordMutationReceipt(c3, filePath, absPath, html) {
107548
+ const version2 = fileContentVersion(html);
107549
+ const writeToken = createWriteToken(c3.req.header("X-Hyperframes-Write-Token"));
107550
+ recordFileWriteReceipt(absPath, { path: filePath, version: version2, writeToken });
107551
+ return { version: version2, writeToken };
107552
+ }
107553
+ function writeFileWithReceipt(c3, filePath, absPath, html) {
107554
+ writeFileSync42(absPath, html, "utf-8");
107555
+ return recordMutationReceipt(c3, filePath, absPath, html);
107556
+ }
107557
+ function writeMutationResult(c3, projectDir, filePath, absPath, html) {
107558
+ const backup = snapshotBeforeWrite(projectDir, absPath);
107559
+ if (backup.error) console.warn(`Failed to create backup for ${filePath}: ${backup.error}`);
107560
+ const { version: version2 } = writeFileWithReceipt(c3, filePath, absPath, html);
107561
+ return { backupPath: backupPathForResponse(projectDir, backup.backupPath), version: version2 };
107562
+ }
107550
107563
  function writeIfChanged(c3, projectDir, filePath, absPath, original, next) {
107551
107564
  if (next === original) {
107552
107565
  return c3.json({ ok: true, changed: false, content: original, path: filePath });
107553
107566
  }
107554
- const backup = snapshotBeforeWrite(projectDir, absPath);
107555
- if (backup.error) console.warn(`Failed to create backup for ${filePath}: ${backup.error}`);
107556
- writeFileSync42(absPath, next, "utf-8");
107567
+ const { backupPath } = writeMutationResult(c3, projectDir, filePath, absPath, next);
107557
107568
  return c3.json({
107558
107569
  ok: true,
107559
107570
  changed: true,
107560
107571
  content: next,
107561
107572
  path: filePath,
107562
- backupPath: backupPathForResponse(projectDir, backup.backupPath)
107573
+ backupPath
107563
107574
  });
107564
107575
  }
107565
107576
  function rejectUnsafeMutationValues(c3, unsafeFields) {
@@ -107927,10 +107938,13 @@ async function applyGsapMutations(c3, res, mutations) {
107927
107938
  return c3.json({ error: "file changed during GSAP mutation", conflict: true }, 409);
107928
107939
  }
107929
107940
  if (changed) {
107930
- const backup = snapshotBeforeWrite(res.project.dir, res.absPath);
107931
- if (backup.error) console.warn(`Failed to create backup for ${res.filePath}: ${backup.error}`);
107932
- backupPath = backupPathForResponse(res.project.dir, backup.backupPath);
107933
- writeFileSync42(res.absPath, newHtml, "utf-8");
107941
+ backupPath = writeMutationResult(
107942
+ c3,
107943
+ res.project.dir,
107944
+ res.filePath,
107945
+ res.absPath,
107946
+ newHtml
107947
+ ).backupPath;
107934
107948
  }
107935
107949
  const responsePayload = {
107936
107950
  ok: true,
@@ -108887,10 +108901,12 @@ function registerFileRoutes(api, adapter2) {
108887
108901
  }
108888
108902
  const backup = snapshotBeforeWrite(ctx.project.dir, ctx.absPath);
108889
108903
  if (backup.error) return c3.json({ error: `backup failed: ${backup.error}` }, 500);
108890
- writeFileSync42(ctx.absPath, insertion.html, "utf-8");
108891
- const version2 = fileContentVersion(insertion.html);
108892
- const writeToken = createWriteToken(c3.req.header("X-Hyperframes-Write-Token"));
108893
- recordFileWriteReceipt(ctx.absPath, { path: ctx.filePath, version: version2, writeToken });
108904
+ const { version: version2, writeToken } = writeFileWithReceipt(
108905
+ c3,
108906
+ ctx.filePath,
108907
+ ctx.absPath,
108908
+ insertion.html
108909
+ );
108894
108910
  c3.header("ETag", version2);
108895
108911
  return c3.json({
108896
108912
  ok: true,
@@ -109088,10 +109104,13 @@ function registerFileRoutes(api, adapter2) {
109088
109104
  version: version22
109089
109105
  });
109090
109106
  }
109091
- const backup = snapshotBeforeWrite(ctx.project.dir, ctx.absPath);
109092
- if (backup.error) console.warn(`Failed to create backup for ${ctx.filePath}: ${backup.error}`);
109093
- writeFileSync42(ctx.absPath, result.html, "utf-8");
109094
- const version2 = fileContentVersion(result.html);
109107
+ const { version: version2, backupPath } = writeMutationResult(
109108
+ c3,
109109
+ ctx.project.dir,
109110
+ ctx.filePath,
109111
+ ctx.absPath,
109112
+ result.html
109113
+ );
109095
109114
  c3.header("ETag", version2);
109096
109115
  return c3.json({
109097
109116
  ok: true,
@@ -109100,7 +109119,7 @@ function registerFileRoutes(api, adapter2) {
109100
109119
  newId: result.newId,
109101
109120
  path: ctx.filePath,
109102
109121
  version: version2,
109103
- backupPath: backupPathForResponse(ctx.project.dir, backup.backupPath)
109122
+ backupPath
109104
109123
  });
109105
109124
  });
109106
109125
  api.post("/projects/:id/file-mutations/patch-element/*", async (c3) => {
@@ -109135,16 +109154,20 @@ function registerFileRoutes(api, adapter2) {
109135
109154
  path: ctx.filePath
109136
109155
  });
109137
109156
  }
109138
- const backup = snapshotBeforeWrite(ctx.project.dir, ctx.absPath);
109139
- if (backup.error) console.warn(`Failed to create backup for ${ctx.filePath}: ${backup.error}`);
109140
- writeFileSync42(ctx.absPath, patched, "utf-8");
109157
+ const { backupPath } = writeMutationResult(
109158
+ c3,
109159
+ ctx.project.dir,
109160
+ ctx.filePath,
109161
+ ctx.absPath,
109162
+ patched
109163
+ );
109141
109164
  return c3.json({
109142
109165
  ok: true,
109143
109166
  changed: true,
109144
109167
  matched,
109145
109168
  content: patched,
109146
109169
  path: ctx.filePath,
109147
- backupPath: backupPathForResponse(ctx.project.dir, backup.backupPath)
109170
+ backupPath
109148
109171
  });
109149
109172
  });
109150
109173
  api.post("/projects/:id/file-mutations/patch-element-batches", async (c3) => {
@@ -109156,7 +109179,7 @@ function registerFileRoutes(api, adapter2) {
109156
109179
  }
109157
109180
  const unsafeFields = findUnsafeElementPatchBatchValues(body.batches);
109158
109181
  if (unsafeFields.length > 0) return rejectUnsafeMutationValues(c3, unsafeFields);
109159
- const result = commitElementPatchBatches(project.dir, body.batches);
109182
+ const result = commitElementPatchBatchesWithReceipts(c3, project.dir, body.batches);
109160
109183
  if ("error" in result) {
109161
109184
  return elementPatchBatchCommitErrorResponse(c3, result.error, result.sourceFile);
109162
109185
  }
@@ -109174,7 +109197,7 @@ function registerFileRoutes(api, adapter2) {
109174
109197
  if (unsafeFields.length > 0) {
109175
109198
  return rejectUnsafeMutationValues(c3, unsafeFields);
109176
109199
  }
109177
- const result = commitElementPatchBatches(ctx.project.dir, [batch]);
109200
+ const result = commitElementPatchBatchesWithReceipts(c3, ctx.project.dir, [batch]);
109178
109201
  if ("error" in result) {
109179
109202
  return elementPatchBatchCommitErrorResponse(c3, result.error, result.sourceFile);
109180
109203
  }
@@ -109230,16 +109253,20 @@ function registerFileRoutes(api, adapter2) {
109230
109253
  result.error === "grouped elements must share a single parent" ? 422 : 400
109231
109254
  );
109232
109255
  }
109233
- const backup = snapshotBeforeWrite(ctx.project.dir, ctx.absPath);
109234
- if (backup.error) console.warn(`Failed to create backup for ${ctx.filePath}: ${backup.error}`);
109235
- writeFileSync42(ctx.absPath, result.html, "utf-8");
109256
+ const { backupPath } = writeMutationResult(
109257
+ c3,
109258
+ ctx.project.dir,
109259
+ ctx.filePath,
109260
+ ctx.absPath,
109261
+ result.html
109262
+ );
109236
109263
  return c3.json({
109237
109264
  ok: true,
109238
109265
  changed: true,
109239
109266
  groupId: result.groupId,
109240
109267
  content: result.html,
109241
109268
  path: ctx.filePath,
109242
- backupPath: backupPathForResponse(ctx.project.dir, backup.backupPath)
109269
+ backupPath
109243
109270
  });
109244
109271
  });
109245
109272
  api.post("/projects/:id/file-mutations/unwrap-elements/*", async (c3) => {
@@ -132998,7 +133025,13 @@ function createStudioServer(options) {
132998
133025
  app.get("/api/events", (c3) => {
132999
133026
  return streamSSE4(c3, async (stream) => {
133000
133027
  const listener = (path2) => {
133001
- const receipt = consumeFileWriteReceipt(resolve38(projectDir, path2));
133028
+ const absPath = resolve38(projectDir, path2);
133029
+ let version2 = null;
133030
+ try {
133031
+ version2 = fileContentVersion(readFileSync40(absPath, "utf-8"));
133032
+ } catch {
133033
+ }
133034
+ const receipt = version2 ? consumeFileWriteReceipt(absPath, version2) : null;
133002
133035
  stream.writeSSE({ event: "file-change", data: JSON.stringify(receipt ?? { path: path2 }) }).catch(() => {
133003
133036
  });
133004
133037
  };
@@ -140456,10 +140489,6 @@ function applyDeParallelRouterCircuitBreaker(quiet) {
140456
140489
  }
140457
140490
  return false;
140458
140491
  }
140459
- if (!isCanaryEnabled("de-parallel-router")) {
140460
- applyDeParallelRouterBreaker();
140461
- return false;
140462
- }
140463
140492
  return true;
140464
140493
  }
140465
140494
  function resolveDeParallelRouterOutcome(job) {
@@ -140669,7 +140698,6 @@ var init_render = __esm({
140669
140698
  "src/commands/render.ts"() {
140670
140699
  "use strict";
140671
140700
  init_commandResult();
140672
- init_canary2();
140673
140701
  init_dist();
140674
140702
  init_plan2();
140675
140703
  init_projectConfig();
@@ -1,4 +1,4 @@
1
- "use strict";var HyperframesPlayer=(()=>{var J=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ze=Object.prototype.hasOwnProperty;var Qe=(i,e)=>{for(var t in e)J(i,t,{get:e[t],enumerable:!0})},Je=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Xe(e))!Ze.call(i,n)&&n!==t&&J(i,n,{get:()=>e[n],enumerable:!(r=Ye(e,n))||r.enumerable});return i};var Ke=i=>Je(J({},"__esModule",{value:!0}),i);var Lt={};Qe(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 et="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.7.102/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 tt(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=tt(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=et,(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 Ye=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ze=Object.prototype.hasOwnProperty;var Qe=(i,e)=>{for(var t in e)J(i,t,{get:e[t],enumerable:!0})},Je=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Xe(e))!Ze.call(i,n)&&n!==t&&J(i,n,{get:()=>e[n],enumerable:!(r=Ye(e,n))||r.enumerable});return i};var Ke=i=>Je(J({},"__esModule",{value:!0}),i);var Lt={};Qe(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 et="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.7.104/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 tt(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=tt(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=et,(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 me=Object.defineProperty;var fe=(r,t,e)=>t in r?me(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var c=(r,t,e)=>fe(r,typeof t!="symbol"?t+"":t,e);import{r as ne,i as _e,a as ge}from"./index-DN614u1l.js";function ye(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function F(r){return typeof r=="object"&&r!==null}function ve(r){return F(r)&&typeof r.getDuration=="function"}function be(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 we(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 Ae=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:we("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 Ee(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 Ce{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(ye({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=Ee(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=Ae,(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 be(d)?d:null}_resolvePlaybackDurationAdapter(t){const e=Reflect.get(t,"__player");if(ve(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const i=this._resolveDirectTimelineAdapterFromWindow(t);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}}const Te=`
1
+ var me=Object.defineProperty;var fe=(r,t,e)=>t in r?me(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var c=(r,t,e)=>fe(r,typeof t!="symbol"?t+"":t,e);import{r as ne,i as _e,a as ge}from"./index-DzfDa1ci.js";function ye(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function F(r){return typeof r=="object"&&r!==null}function ve(r){return F(r)&&typeof r.getDuration=="function"}function be(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 we(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 Ae=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:we("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 Ee(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 Ce{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(ye({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=Ee(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=Ae,(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 be(d)?d:null}_resolvePlaybackDurationAdapter(t){const e=Reflect.get(t,"__player");if(ve(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const i=this._resolveDirectTimelineAdapterFromWindow(t);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}}const Te=`
2
2
  :host {
3
3
  display: block;
4
4
  position: relative;
@@ -1 +1 @@
1
- import{g as P}from"./index-DN614u1l.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-DzfDa1ci.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};