@hyperframes/studio-server 0.8.120 → 0.8.122
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 +12 -9
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3276,8 +3276,8 @@ import { Readable } from "stream";
|
|
|
3276
3276
|
import { join as join8, resolve as resolve4 } from "path";
|
|
3277
3277
|
import { createHash } from "crypto";
|
|
3278
3278
|
import {
|
|
3279
|
+
AFTER_FONTS_SCRIPT_TYPE,
|
|
3279
3280
|
addScenePartsManifest,
|
|
3280
|
-
injectScriptsIntoHtml,
|
|
3281
3281
|
insertBeforeCloseTag as insertBeforeCloseTag2,
|
|
3282
3282
|
stripEmbeddedRuntimeScripts as stripEmbeddedRuntimeScripts2
|
|
3283
3283
|
} from "@hyperframes/core/compiler";
|
|
@@ -3295,7 +3295,7 @@ import {
|
|
|
3295
3295
|
rewriteCssAssetUrls,
|
|
3296
3296
|
rewriteInlineStyleAssetUrls
|
|
3297
3297
|
} from "@hyperframes/core";
|
|
3298
|
-
import { stripEmbeddedRuntimeScripts } from "@hyperframes/core/compiler";
|
|
3298
|
+
import { deferScriptsUntilFonts, stripEmbeddedRuntimeScripts } from "@hyperframes/core/compiler";
|
|
3299
3299
|
import { isFullHtmlDocument } from "@hyperframes/core/compiler/html-document";
|
|
3300
3300
|
import { gsapCdnDist } from "@hyperframes/core/gsap-cdn";
|
|
3301
3301
|
function rewriteRelativePaths(root, compPath, projectDir) {
|
|
@@ -3430,6 +3430,11 @@ function buildSubCompositionHtml(projectDir, compPath, runtimeUrl, baseHref, raw
|
|
|
3430
3430
|
rewrittenContent = contentDoc.body.innerHTML || rawComp;
|
|
3431
3431
|
}
|
|
3432
3432
|
rewrittenContent = stripEmbeddedRuntimeScripts(rewrittenContent);
|
|
3433
|
+
const { document: scriptsDoc } = parseHTML3(
|
|
3434
|
+
`<!DOCTYPE html><html><head></head><body>${rewrittenContent}</body></html>`
|
|
3435
|
+
);
|
|
3436
|
+
deferScriptsUntilFonts(scriptsDoc);
|
|
3437
|
+
rewrittenContent = scriptsDoc.body.innerHTML;
|
|
3433
3438
|
rewrittenContent = tagRootCompositionFile(rewrittenContent, compPath);
|
|
3434
3439
|
const indexPath = join6(projectDir, "index.html");
|
|
3435
3440
|
let headContent = "";
|
|
@@ -3658,7 +3663,8 @@ function injectMotionPathPluginIfNeeded(html) {
|
|
|
3658
3663
|
const match = html.match(gsapScript);
|
|
3659
3664
|
if (match) {
|
|
3660
3665
|
const version = match[0].match(/gsap@([\d.]+)/)?.[1];
|
|
3661
|
-
const
|
|
3666
|
+
const gsapTagType = match[0].match(/\stype=("[^"]*"|'[^']*')/i)?.[0] ?? "";
|
|
3667
|
+
const pluginTag = `<script${gsapTagType} src="${motionPathPluginUrl(version)}"></script>`;
|
|
3662
3668
|
const end = html.indexOf(match[0]) + match[0].length;
|
|
3663
3669
|
return html.slice(0, end) + "\n" + pluginTag + html.slice(end);
|
|
3664
3670
|
}
|
|
@@ -3680,12 +3686,9 @@ function injectStudioMotionScript(html, projectDir, activeCompositionPath) {
|
|
|
3680
3686
|
activeCompositionPath
|
|
3681
3687
|
});
|
|
3682
3688
|
if (!script) return html;
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
[script],
|
|
3687
|
-
false
|
|
3688
|
-
);
|
|
3689
|
+
const withDependencies = injectStudioMotionDependencies(html, manifestContent);
|
|
3690
|
+
const tag = `<script type="${AFTER_FONTS_SCRIPT_TYPE}">${script.replace(/<\/script/gi, "<\\/script")}</script>`;
|
|
3691
|
+
return insertBeforeCloseTag2(withDependencies, "body", tag) ?? `${withDependencies}${tag}`;
|
|
3689
3692
|
}
|
|
3690
3693
|
var GSAP_FALLBACK_ATTR = "data-hf-gsap-fallback";
|
|
3691
3694
|
var GSAP_CDN_FALLBACK_SCRIPT = `<script ${GSAP_FALLBACK_ATTR}>
|