@hyperframes/producer 0.4.13-alpha.1 → 0.4.13-alpha.3

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
@@ -100136,9 +100136,10 @@ ${right2.raw}`)
100136
100136
  return findings;
100137
100137
  },
100138
100138
  // missing_gsap_script
100139
- ({ scripts }) => {
100139
+ ({ scripts, rawSource, options }) => {
100140
100140
  const allScriptTexts = scripts.filter((s) => !/\bsrc\s*=/.test(s.attrs)).map((s) => s.content);
100141
100141
  const allScriptSrcs = scripts.map((s) => readAttr(`<script ${s.attrs}>`, "src") || "").filter(Boolean);
100142
+ const canInheritGsapFromHost = options.isSubComposition || rawSource.trimStart().toLowerCase().startsWith("<template");
100142
100143
  const usesGsap = allScriptTexts.some(
100143
100144
  (t) => /gsap\.(to|from|fromTo|timeline|set|registerPlugin)\b/.test(t)
100144
100145
  );
@@ -100146,7 +100147,7 @@ ${right2.raw}`)
100146
100147
  const hasInlineGsap = allScriptTexts.some(
100147
100148
  (t) => /\/\*\s*inlined:.*gsap/i.test(t) || /\b_gsScope\b/.test(t) || /\bGreenSock\b/.test(t) || /\bgsap\.(config|defaults|version)\b/.test(t) || t.length > 5e3 && /\bgsap\b/i.test(t)
100148
100149
  );
100149
- if (!usesGsap || hasGsapScript || hasInlineGsap) return [];
100150
+ if (!usesGsap || hasGsapScript || hasInlineGsap || canInheritGsapFromHost) return [];
100150
100151
  return [
100151
100152
  {
100152
100153
  code: "missing_gsap_script",
@@ -108469,9 +108470,20 @@ function dedupeElementsById(elements) {
108469
108470
  return Array.from(deduped.values());
108470
108471
  }
108471
108472
  var INLINE_SCRIPT_PATTERN = /<script\b([^>]*)>([\s\S]*?)<\/script>/gi;
108473
+ var COMPILER_MOUNT_BLOCK_START = "/* __HF_COMPILER_MOUNT_START__ */";
108474
+ var COMPILER_MOUNT_BLOCK_END = "/* __HF_COMPILER_MOUNT_END__ */";
108472
108475
  function stripJsComments(source2) {
108473
108476
  return source2.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
108474
108477
  }
108478
+ function stripCompilerMountBootstrap(source2) {
108479
+ return source2.replace(
108480
+ new RegExp(
108481
+ `${COMPILER_MOUNT_BLOCK_START.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}[\\s\\S]*?${COMPILER_MOUNT_BLOCK_END.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`,
108482
+ "g"
108483
+ ),
108484
+ ""
108485
+ );
108486
+ }
108475
108487
  function detectRenderModeHints(html) {
108476
108488
  const reasons = [];
108477
108489
  const { document: document2 } = parseHTML(html);
@@ -108486,7 +108498,7 @@ function detectRenderModeHints(html) {
108486
108498
  while ((scriptMatch = scriptPattern.exec(html)) !== null) {
108487
108499
  const attrs = scriptMatch[1] || "";
108488
108500
  if (/\bsrc\s*=/i.test(attrs)) continue;
108489
- const content = stripJsComments(scriptMatch[2] || "");
108501
+ const content = stripJsComments(stripCompilerMountBootstrap(scriptMatch[2] || ""));
108490
108502
  if (!/requestAnimationFrame\s*\(/.test(content)) continue;
108491
108503
  reasons.push({
108492
108504
  code: "requestAnimationFrame",
@@ -108858,6 +108870,7 @@ function inlineSubCompositions(html, subCompositions, projectDir) {
108858
108870
  }
108859
108871
  };
108860
108872
  if (!__compId) { __run(); return; }
108873
+ ${COMPILER_MOUNT_BLOCK_START}
108861
108874
  var __selector = '[data-composition-id="' + (__compId + '').replace(/"/g, '\\\\"') + '"]';
108862
108875
  var __attempt = 0;
108863
108876
  var __tryRun = function() {
@@ -108866,6 +108879,7 @@ function inlineSubCompositions(html, subCompositions, projectDir) {
108866
108879
  requestAnimationFrame(__tryRun);
108867
108880
  };
108868
108881
  __tryRun();
108882
+ ${COMPILER_MOUNT_BLOCK_END}
108869
108883
  })()`);
108870
108884
  }
108871
108885
  scriptEl.remove();