hyperframes 0.7.103 → 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.
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.103" : "0.0.0-dev";
53
+ VERSION = true ? "0.7.104" : "0.0.0-dev";
54
54
  }
55
55
  });
56
56
 
@@ -98075,6 +98075,7 @@ function shouldWatchProjectFile(filename) {
98075
98075
  }
98076
98076
  function createProjectWatcher(projectDir) {
98077
98077
  const listeners = /* @__PURE__ */ new Set();
98078
+ const pendingPaths = /* @__PURE__ */ new Set();
98078
98079
  let debounceTimer = null;
98079
98080
  let watcher = null;
98080
98081
  try {
@@ -98082,10 +98083,16 @@ function createProjectWatcher(projectDir) {
98082
98083
  if (!filename) return;
98083
98084
  const relativePath = filename.toString();
98084
98085
  if (!shouldWatchProjectFile(relativePath)) return;
98086
+ pendingPaths.add(relativePath);
98085
98087
  if (debounceTimer) clearTimeout(debounceTimer);
98086
98088
  debounceTimer = setTimeout(() => {
98087
- for (const fn of listeners) {
98088
- 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
+ }
98089
98096
  }
98090
98097
  }, DEBOUNCE_MS);
98091
98098
  });
@@ -98104,6 +98111,7 @@ function createProjectWatcher(projectDir) {
98104
98111
  },
98105
98112
  close() {
98106
98113
  if (debounceTimer) clearTimeout(debounceTimer);
98114
+ pendingPaths.clear();
98107
98115
  watcher?.close();
98108
98116
  listeners.clear();
98109
98117
  }
@@ -107178,12 +107186,13 @@ function recordFileWriteReceipt(absPath, receipt) {
107178
107186
  current2.push({ ...receipt, recordedAt: now });
107179
107187
  receipts.set(absPath, current2);
107180
107188
  }
107181
- function consumeFileWriteReceipt(absPath) {
107189
+ function consumeFileWriteReceipt(absPath, expectedVersion) {
107182
107190
  const now = Date.now();
107183
107191
  const current2 = (receipts.get(absPath) ?? []).filter(
107184
107192
  (entry) => now - entry.recordedAt < RECEIPT_TTL_MS
107185
107193
  );
107186
- 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;
107187
107196
  if (current2.length > 0) receipts.set(absPath, current2);
107188
107197
  else receipts.delete(absPath);
107189
107198
  if (!receipt) return null;
@@ -107524,19 +107533,44 @@ function commitElementPatchBatches(projectDir, batches, writeFile4 = writeFileSy
107524
107533
  }
107525
107534
  return { durable: true, files };
107526
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
+ }
107527
107563
  function writeIfChanged(c3, projectDir, filePath, absPath, original, next) {
107528
107564
  if (next === original) {
107529
107565
  return c3.json({ ok: true, changed: false, content: original, path: filePath });
107530
107566
  }
107531
- const backup = snapshotBeforeWrite(projectDir, absPath);
107532
- if (backup.error) console.warn(`Failed to create backup for ${filePath}: ${backup.error}`);
107533
- writeFileSync42(absPath, next, "utf-8");
107567
+ const { backupPath } = writeMutationResult(c3, projectDir, filePath, absPath, next);
107534
107568
  return c3.json({
107535
107569
  ok: true,
107536
107570
  changed: true,
107537
107571
  content: next,
107538
107572
  path: filePath,
107539
- backupPath: backupPathForResponse(projectDir, backup.backupPath)
107573
+ backupPath
107540
107574
  });
107541
107575
  }
107542
107576
  function rejectUnsafeMutationValues(c3, unsafeFields) {
@@ -107904,10 +107938,13 @@ async function applyGsapMutations(c3, res, mutations) {
107904
107938
  return c3.json({ error: "file changed during GSAP mutation", conflict: true }, 409);
107905
107939
  }
107906
107940
  if (changed) {
107907
- const backup = snapshotBeforeWrite(res.project.dir, res.absPath);
107908
- if (backup.error) console.warn(`Failed to create backup for ${res.filePath}: ${backup.error}`);
107909
- backupPath = backupPathForResponse(res.project.dir, backup.backupPath);
107910
- 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;
107911
107948
  }
107912
107949
  const responsePayload = {
107913
107950
  ok: true,
@@ -108864,10 +108901,12 @@ function registerFileRoutes(api, adapter2) {
108864
108901
  }
108865
108902
  const backup = snapshotBeforeWrite(ctx.project.dir, ctx.absPath);
108866
108903
  if (backup.error) return c3.json({ error: `backup failed: ${backup.error}` }, 500);
108867
- writeFileSync42(ctx.absPath, insertion.html, "utf-8");
108868
- const version2 = fileContentVersion(insertion.html);
108869
- const writeToken = createWriteToken(c3.req.header("X-Hyperframes-Write-Token"));
108870
- 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
+ );
108871
108910
  c3.header("ETag", version2);
108872
108911
  return c3.json({
108873
108912
  ok: true,
@@ -109065,10 +109104,13 @@ function registerFileRoutes(api, adapter2) {
109065
109104
  version: version22
109066
109105
  });
109067
109106
  }
109068
- const backup = snapshotBeforeWrite(ctx.project.dir, ctx.absPath);
109069
- if (backup.error) console.warn(`Failed to create backup for ${ctx.filePath}: ${backup.error}`);
109070
- writeFileSync42(ctx.absPath, result.html, "utf-8");
109071
- 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
+ );
109072
109114
  c3.header("ETag", version2);
109073
109115
  return c3.json({
109074
109116
  ok: true,
@@ -109077,7 +109119,7 @@ function registerFileRoutes(api, adapter2) {
109077
109119
  newId: result.newId,
109078
109120
  path: ctx.filePath,
109079
109121
  version: version2,
109080
- backupPath: backupPathForResponse(ctx.project.dir, backup.backupPath)
109122
+ backupPath
109081
109123
  });
109082
109124
  });
109083
109125
  api.post("/projects/:id/file-mutations/patch-element/*", async (c3) => {
@@ -109112,16 +109154,20 @@ function registerFileRoutes(api, adapter2) {
109112
109154
  path: ctx.filePath
109113
109155
  });
109114
109156
  }
109115
- const backup = snapshotBeforeWrite(ctx.project.dir, ctx.absPath);
109116
- if (backup.error) console.warn(`Failed to create backup for ${ctx.filePath}: ${backup.error}`);
109117
- 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
+ );
109118
109164
  return c3.json({
109119
109165
  ok: true,
109120
109166
  changed: true,
109121
109167
  matched,
109122
109168
  content: patched,
109123
109169
  path: ctx.filePath,
109124
- backupPath: backupPathForResponse(ctx.project.dir, backup.backupPath)
109170
+ backupPath
109125
109171
  });
109126
109172
  });
109127
109173
  api.post("/projects/:id/file-mutations/patch-element-batches", async (c3) => {
@@ -109133,7 +109179,7 @@ function registerFileRoutes(api, adapter2) {
109133
109179
  }
109134
109180
  const unsafeFields = findUnsafeElementPatchBatchValues(body.batches);
109135
109181
  if (unsafeFields.length > 0) return rejectUnsafeMutationValues(c3, unsafeFields);
109136
- const result = commitElementPatchBatches(project.dir, body.batches);
109182
+ const result = commitElementPatchBatchesWithReceipts(c3, project.dir, body.batches);
109137
109183
  if ("error" in result) {
109138
109184
  return elementPatchBatchCommitErrorResponse(c3, result.error, result.sourceFile);
109139
109185
  }
@@ -109151,7 +109197,7 @@ function registerFileRoutes(api, adapter2) {
109151
109197
  if (unsafeFields.length > 0) {
109152
109198
  return rejectUnsafeMutationValues(c3, unsafeFields);
109153
109199
  }
109154
- const result = commitElementPatchBatches(ctx.project.dir, [batch]);
109200
+ const result = commitElementPatchBatchesWithReceipts(c3, ctx.project.dir, [batch]);
109155
109201
  if ("error" in result) {
109156
109202
  return elementPatchBatchCommitErrorResponse(c3, result.error, result.sourceFile);
109157
109203
  }
@@ -109207,16 +109253,20 @@ function registerFileRoutes(api, adapter2) {
109207
109253
  result.error === "grouped elements must share a single parent" ? 422 : 400
109208
109254
  );
109209
109255
  }
109210
- const backup = snapshotBeforeWrite(ctx.project.dir, ctx.absPath);
109211
- if (backup.error) console.warn(`Failed to create backup for ${ctx.filePath}: ${backup.error}`);
109212
- 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
+ );
109213
109263
  return c3.json({
109214
109264
  ok: true,
109215
109265
  changed: true,
109216
109266
  groupId: result.groupId,
109217
109267
  content: result.html,
109218
109268
  path: ctx.filePath,
109219
- backupPath: backupPathForResponse(ctx.project.dir, backup.backupPath)
109269
+ backupPath
109220
109270
  });
109221
109271
  });
109222
109272
  api.post("/projects/:id/file-mutations/unwrap-elements/*", async (c3) => {
@@ -132975,7 +133025,13 @@ function createStudioServer(options) {
132975
133025
  app.get("/api/events", (c3) => {
132976
133026
  return streamSSE4(c3, async (stream) => {
132977
133027
  const listener = (path2) => {
132978
- 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;
132979
133035
  stream.writeSSE({ event: "file-change", data: JSON.stringify(receipt ?? { path: path2 }) }).catch(() => {
132980
133036
  });
132981
133037
  };
@@ -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.103/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-CxC2vn2-.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-CxC2vn2-.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};