@hyperframes/studio-server 0.8.167 → 0.8.168

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.
@@ -174,9 +174,15 @@ function isHTMLElement(el) {
174
174
  const HTMLEl = el.ownerDocument?.defaultView?.HTMLElement;
175
175
  return HTMLEl ? el instanceof HTMLEl : el.nodeType === 1 && "style" in el;
176
176
  }
177
+ function mountsComposition(document, host, compositionId) {
178
+ if (host.hasAttribute("data-composition-src")) return true;
179
+ return host.children.length === 0 && querySelectorAllWithTemplates(document, "template").some(
180
+ (template) => template.id === `${compositionId}-template`
181
+ );
182
+ }
177
183
  function dedupeClonedCompositionId(document, clone) {
178
184
  const compositionId = clone.getAttribute("data-composition-id");
179
- if (!compositionId) return;
185
+ if (!compositionId || mountsComposition(document, clone, compositionId)) return;
180
186
  const usedCompositionIds = new Set(
181
187
  querySelectorAllWithTemplates(document, "[data-composition-id]").map(
182
188
  (node) => node.getAttribute("data-composition-id")
@@ -13,7 +13,7 @@ import {
13
13
  splitElementInHtml,
14
14
  unwrapElementsFromHtml,
15
15
  wrapElementsInHtml
16
- } from "../chunk-WUNFUTHB.js";
16
+ } from "../chunk-OF4B2ILS.js";
17
17
  export {
18
18
  dedupeClonedCompositionId,
19
19
  findTargetElement,
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  splitElementInHtml,
18
18
  unwrapElementsFromHtml,
19
19
  wrapElementsInHtml
20
- } from "./chunk-WUNFUTHB.js";
20
+ } from "./chunk-OF4B2ILS.js";
21
21
  import {
22
22
  isCompositionSource,
23
23
  stampProjectHfIds
@@ -568,8 +568,8 @@ function resolveTrack(root, desiredTrack, start, duration) {
568
568
  }
569
569
  function uniqueHostId(root, base) {
570
570
  const ids = /* @__PURE__ */ new Set([
571
- ...descendants(root, "[id]").map((element) => element.id),
572
- ...descendants(root, "[data-composition-id]").flatMap((element) => {
571
+ ...[root, ...descendants(root, "[id]")].map((element) => element.id),
572
+ ...[root, ...descendants(root, "[data-composition-id]")].flatMap((element) => {
573
573
  const id = element.getAttribute("data-composition-id");
574
574
  return id ? [id] : [];
575
575
  })
@@ -597,7 +597,8 @@ function insertCompositionIntoSource(input) {
597
597
  const height = positiveAttribute(sourceComposition, "data-height");
598
598
  const { document, root } = compositionRoot(input.parentSource);
599
599
  const parentDuration = positiveAttribute(root, "data-duration", "data-composition-duration");
600
- const base = (sourceComposition.getAttribute("data-composition-id") ?? "composition").replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || "composition";
600
+ const sourceCompositionId = sourceComposition.getAttribute("data-composition-id") ?? "";
601
+ const base = (sourceCompositionId || "composition").replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || "composition";
601
602
  const hostId = uniqueHostId(root, base);
602
603
  const track = resolveTrack(
603
604
  root,
@@ -616,7 +617,8 @@ function insertCompositionIntoSource(input) {
616
617
  host.id = hostId;
617
618
  host.className = "clip";
618
619
  host.setAttribute("data-hf-id", `hf-${randomUUID()}`);
619
- host.setAttribute("data-composition-id", hostId);
620
+ const mountedRootId = sourceCompositionId || hostId;
621
+ host.setAttribute("data-composition-id", mountedRootId);
620
622
  host.setAttribute("data-composition-src", relativeSourcePath(targetAbs, sourceAbs));
621
623
  host.setAttribute("data-start", String(Math.round(input.start * 100) / 100));
622
624
  host.setAttribute("data-duration", String(duration));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/studio-server",
3
- "version": "0.8.167",
3
+ "version": "0.8.168",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/heygen-com/hyperframes",
@@ -85,8 +85,8 @@
85
85
  "postcss": "^8.5.8",
86
86
  "postcss-selector-parser": "^7.1.2",
87
87
  "sharp": "^0.35.0",
88
- "@hyperframes/core": "0.8.167",
89
- "@hyperframes/parsers": "0.8.167"
88
+ "@hyperframes/parsers": "0.8.168",
89
+ "@hyperframes/core": "0.8.168"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@types/node": "^25.0.10",