@hyperframes/studio-server 0.8.124 → 0.8.126

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
@@ -3283,7 +3283,9 @@ import { createHash } from "crypto";
3283
3283
  import {
3284
3284
  AFTER_FONTS_SCRIPT_TYPE,
3285
3285
  addScenePartsManifest,
3286
+ RUNTIME_BOOTSTRAP_ATTR as RUNTIME_BOOTSTRAP_ATTR2,
3286
3287
  insertBeforeCloseTag as insertBeforeCloseTag2,
3288
+ insertRuntimeTag,
3287
3289
  stripEmbeddedRuntimeScripts as stripEmbeddedRuntimeScripts2
3288
3290
  } from "@hyperframes/core/compiler";
3289
3291
  import { STUDIO_PREVIEW_MARK_META } from "@hyperframes/core/studio-preview-mark";
@@ -3300,7 +3302,11 @@ import {
3300
3302
  rewriteCssAssetUrls,
3301
3303
  rewriteInlineStyleAssetUrls
3302
3304
  } from "@hyperframes/core";
3303
- import { deferScriptsUntilFonts, stripEmbeddedRuntimeScripts } from "@hyperframes/core/compiler";
3305
+ import {
3306
+ deferScriptsUntilFonts,
3307
+ RUNTIME_BOOTSTRAP_ATTR,
3308
+ stripEmbeddedRuntimeScripts
3309
+ } from "@hyperframes/core/compiler";
3304
3310
  import { isFullHtmlDocument } from "@hyperframes/core/compiler/html-document";
3305
3311
  import { gsapCdnDist } from "@hyperframes/core/gsap-cdn";
3306
3312
  function rewriteRelativePaths(root, compPath, projectDir) {
@@ -3451,10 +3457,8 @@ ${headContent}`;
3451
3457
  if (compHeadContent) headContent += `
3452
3458
  ${compHeadContent}`;
3453
3459
  headContent = stripEmbeddedRuntimeScripts(headContent);
3454
- if (!headContent.includes("hyperframe.runtime") && !headContent.includes("hyperframes-preview-runtime")) {
3455
- headContent += `
3456
- <script data-hyperframes-preview-runtime="1" src="${runtimeUrl}"></script>`;
3457
- }
3460
+ headContent += `
3461
+ <script ${RUNTIME_BOOTSTRAP_ATTR}="1" src="${runtimeUrl}"></script>`;
3458
3462
  if (!headContent.includes("gsap")) {
3459
3463
  headContent += `
3460
3464
  <script src="${gsapCdnDist()}gsap.min.js"></script>`;
@@ -3644,6 +3648,10 @@ function parseStudioMotionManifestContent(content) {
3644
3648
  return { hasMotion: false, hasCustomEase: false };
3645
3649
  }
3646
3650
  }
3651
+ function withPreviewRuntime(html, runtimeUrl) {
3652
+ const tag = `<script ${RUNTIME_BOOTSTRAP_ATTR2}="1" src="${runtimeUrl}"></script>`;
3653
+ return insertRuntimeTag(stripEmbeddedRuntimeScripts2(html), tag);
3654
+ }
3647
3655
  function injectScriptTagIntoHead(html, scriptTag) {
3648
3656
  return insertBeforeCloseTag2(html, "head", `${scriptTag}
3649
3657
  `) ?? `${scriptTag}
@@ -3840,7 +3848,6 @@ function registerPreviewRoutes(api, adapter) {
3840
3848
  const previewBuilds = /* @__PURE__ */ new Map();
3841
3849
  async function buildPreview(project, previewVariables, builtKey, capture, signature) {
3842
3850
  const diskMain = resolveProjectMainHtml(project.dir, project.id);
3843
- const normalizedDisk = diskMain ? ensureHfIds2(diskMain.html) : null;
3844
3851
  try {
3845
3852
  let bundled = await adapter.bundle(project.dir, {
3846
3853
  stampHfIds: true,
@@ -3849,17 +3856,12 @@ function registerPreviewRoutes(api, adapter) {
3849
3856
  let mainCompositionPath = "index.html";
3850
3857
  if (!bundled) {
3851
3858
  if (!diskMain) return null;
3852
- bundled = stripEmbeddedRuntimeScripts2(normalizedDisk ?? diskMain.html);
3859
+ bundled = ensureHfIds2(diskMain.html);
3853
3860
  mainCompositionPath = diskMain.compositionPath;
3854
3861
  }
3862
+ bundled = withPreviewRuntime(bundled, adapter.runtimeUrl);
3855
3863
  recordPreviewReferences(project.dir, bundled);
3856
3864
  recordPreviewBuilt(project.dir);
3857
- if (!bundled.includes("hyperframe.runtime") && !bundled.includes("hyperframes-preview-runtime")) {
3858
- const runtimeTag = `<script src="${adapter.runtimeUrl}"></script>`;
3859
- bundled = insertBeforeCloseTag2(bundled, "body", `${runtimeTag}
3860
- `) ?? `${bundled}
3861
- ${runtimeTag}`;
3862
- }
3863
3865
  bundled = withPreviewBase(bundled, project.id);
3864
3866
  bundled = injectStudioPreviewAugmentations(
3865
3867
  ensureHfIds2(await transformPreviewHtml(bundled, adapter, project, mainCompositionPath)),
@@ -3885,7 +3887,10 @@ ${runtimeTag}`;
3885
3887
  } catch {
3886
3888
  const fallback = resolveProjectMainHtml(project.dir, project.id);
3887
3889
  if (fallback) {
3888
- const fallbackHtml = withPreviewBase(ensureHfIds2(fallback.html), project.id);
3890
+ const fallbackHtml = withPreviewBase(
3891
+ withPreviewRuntime(ensureHfIds2(fallback.html), adapter.runtimeUrl),
3892
+ project.id
3893
+ );
3889
3894
  let fallbackAugmented = injectStudioPreviewAugmentations(
3890
3895
  await transformPreviewHtml(fallbackHtml, adapter, project, fallback.compositionPath),
3891
3896
  adapter,