@hyperframes/studio-server 0.8.108 → 0.8.109

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/index.js CHANGED
@@ -9,11 +9,12 @@ import {
9
9
  parseSourceDocument,
10
10
  patchElementInHtml,
11
11
  probeElementInSource,
12
+ relinkSplitHalvesInHtml,
12
13
  removeElementFromHtml,
13
14
  splitElementInHtml,
14
15
  unwrapElementsFromHtml,
15
16
  wrapElementsInHtml
16
- } from "./chunk-W6TFBTP2.js";
17
+ } from "./chunk-Z4DIWF3Z.js";
17
18
  import {
18
19
  isCompositionSource,
19
20
  stampProjectHfIds
@@ -43,7 +44,7 @@ import {
43
44
  resolveProjectAndSignature,
44
45
  resolveProjectSignature,
45
46
  settledFileTag
46
- } from "./chunk-KUEG5MYA.js";
47
+ } from "./chunk-EPL4YKGI.js";
47
48
  import {
48
49
  getElementScreenshotClip
49
50
  } from "./chunk-W2SBTCO2.js";
@@ -2201,6 +2202,7 @@ async function foldAtomicCutFile(c, file, absPath, before, writer) {
2201
2202
  let after = before;
2202
2203
  let splitCount = 0;
2203
2204
  const skippedSelectors = /* @__PURE__ */ new Set();
2205
+ const rightHalfIds = [];
2204
2206
  const respond = (data, status) => status ? c.json(data, status) : c.json(data);
2205
2207
  const orderedTargets = file.targets.map((cut, index) => ({ cut, index })).sort((left, right) => {
2206
2208
  const locatorKey = (entry) => !entry.target.id && !entry.target.hfId && entry.target.selector ? entry.target.selector : null;
@@ -2231,6 +2233,7 @@ async function foldAtomicCutFile(c, file, absPath, before, writer) {
2231
2233
  }
2232
2234
  after = split.html;
2233
2235
  splitCount++;
2236
+ rightHalfIds.push(split.newId);
2234
2237
  if (!cut.originalId) continue;
2235
2238
  const block = extractGsapScriptBlock(after);
2236
2239
  if (!block) continue;
@@ -2257,6 +2260,7 @@ async function foldAtomicCutFile(c, file, absPath, before, writer) {
2257
2260
  after = block.replaceScript(script);
2258
2261
  }
2259
2262
  }
2263
+ after = relinkSplitHalvesInHtml(after, rightHalfIds);
2260
2264
  return {
2261
2265
  path: file.path,
2262
2266
  absPath,
@@ -4785,8 +4789,8 @@ import { createHash as createHash4, randomBytes } from "crypto";
4785
4789
  import { ensureHfIds as ensureHfIds3 } from "@hyperframes/parsers/hf-ids";
4786
4790
  import { readMediaOffsetSeconds } from "@hyperframes/parsers/media-duration";
4787
4791
  import { resolveRateSpec, sourceTimeAt } from "@hyperframes/core/speed-ramp";
4792
+ import { MEDIA_LINK_ATTR as LINK_ATTR, relinkSplitHalves } from "@hyperframes/core/media-link";
4788
4793
  var FREEZE_HOLD_SECONDS = 2;
4789
- var LINK_ATTR = "data-link";
4790
4794
  var EPSILON = 1e-3;
4791
4795
  var round3 = (value) => Math.round(value * 1e3) / 1e3;
4792
4796
  function numberAttr(el, name) {
@@ -4912,11 +4916,6 @@ function splitAll(html, elements, time) {
4912
4916
  }
4913
4917
  return { html: next, rightHalfIds };
4914
4918
  }
4915
- function relinkRightHalves(document, link, ids) {
4916
- if (!link) return;
4917
- const rightLink = uniqueLink(document, link);
4918
- for (const id of ids) document.getElementById(id)?.setAttribute(LINK_ATTR, rightLink);
4919
- }
4920
4919
  function applyFreezeFrameToHtml(html, input) {
4921
4920
  const hold = input.holdSeconds ?? FREEZE_HOLD_SECONDS;
4922
4921
  const { document: before } = parseSourceDocument(html);
@@ -4931,7 +4930,7 @@ function applyFreezeFrameToHtml(html, input) {
4931
4930
  );
4932
4931
  if (!cut) return null;
4933
4932
  const { document, wrappedFragment } = parseSourceDocument(cut.html);
4934
- relinkRightHalves(document, video.getAttribute(LINK_ATTR), cut.rightHalfIds);
4933
+ relinkSplitHalves(document, cut.rightHalfIds);
4935
4934
  shiftTracks(document, tracks, input.playhead, hold);
4936
4935
  const leftHalf = findTargetElement(document, input.target);
4937
4936
  if (!leftHalf?.parentElement) return null;
@@ -4949,14 +4948,6 @@ function applyFreezeFrameToHtml(html, input) {
4949
4948
  freezeId
4950
4949
  };
4951
4950
  }
4952
- function uniqueLink(document, base) {
4953
- const taken = new Set(
4954
- Array.from(document.querySelectorAll(`[${LINK_ATTR}]`)).map((el) => el.getAttribute(LINK_ATTR))
4955
- );
4956
- let candidate = `${base}-2`;
4957
- for (let n = 3; taken.has(candidate); n++) candidate = `${base}-${n}`;
4958
- return candidate;
4959
- }
4960
4951
 
4961
4952
  // src/routes/freezeFrame.ts
4962
4953
  var EXTRACT_TIMEOUT_MS = 3e4;