@hyperframes/studio-server 0.8.160 → 0.8.161

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.
@@ -67,16 +67,16 @@ function patchStyleAttrString(style, property, value) {
67
67
  }
68
68
 
69
69
  // src/helpers/sourceMutation.ts
70
+ var pinnedInSource = /* @__PURE__ */ new WeakMap();
70
71
  function parseSourceDocument(raw) {
71
72
  const source = ensureHfIds(raw);
72
73
  const hasDocumentShell = /<!doctype|<html[\s>]/i.test(source);
73
- if (hasDocumentShell) {
74
- return { document: parseHTML(source).document, wrappedFragment: false };
75
- }
76
- return {
77
- document: parseHTML(`<!DOCTYPE html><html><head></head><body>${source}</body></html>`).document,
78
- wrappedFragment: true
79
- };
74
+ const document = hasDocumentShell ? parseHTML(source).document : parseHTML(`<!DOCTYPE html><html><head></head><body>${source}</body></html>`).document;
75
+ pinnedInSource.set(
76
+ document,
77
+ new Set(Array.from(raw.matchAll(/\bdata-hf-id\s*=\s*["']?([^"'\s>]+)/gi), (m) => m[1]))
78
+ );
79
+ return { document, wrappedFragment: !hasDocumentShell };
80
80
  }
81
81
  function duplicateCssRulesForId(document, originalId, newId) {
82
82
  const idToken = `#${originalId}`;
@@ -141,14 +141,16 @@ function findTargetElement(document, target) {
141
141
  const el = findByHfId(document, target.hfId);
142
142
  if (el) return el;
143
143
  }
144
+ const pinned = pinnedInSource.get(document);
145
+ const unlessPinnedElsewhere = (el) => el && !(target.hfId && pinned?.has(el.getAttribute("data-hf-id") ?? "")) ? el : null;
144
146
  if (target.id) {
145
- const byId = document.getElementById(target.id);
147
+ const byId = unlessPinnedElsewhere(document.getElementById(target.id));
146
148
  if (byId) return byId;
147
149
  }
148
150
  if (!target.selector) return null;
149
151
  try {
150
152
  const matches = querySelectorAllWithTemplates(document, target.selector);
151
- return matches[target.selectorIndex ?? 0] ?? null;
153
+ return unlessPinnedElsewhere(matches[target.selectorIndex ?? 0]);
152
154
  } catch {
153
155
  return null;
154
156
  }
@@ -13,7 +13,7 @@ import {
13
13
  splitElementInHtml,
14
14
  unwrapElementsFromHtml,
15
15
  wrapElementsInHtml
16
- } from "../chunk-JBFOY5SI.js";
16
+ } from "../chunk-WUNFUTHB.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-JBFOY5SI.js";
20
+ } from "./chunk-WUNFUTHB.js";
21
21
  import {
22
22
  isCompositionSource,
23
23
  stampProjectHfIds
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/studio-server",
3
- "version": "0.8.160",
3
+ "version": "0.8.161",
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.160",
89
- "@hyperframes/parsers": "0.8.160"
88
+ "@hyperframes/core": "0.8.161",
89
+ "@hyperframes/parsers": "0.8.161"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@types/node": "^25.0.10",