@stacksjs/stx 0.2.131 → 0.2.133
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/cli.js +473 -470
- package/dist/craft.js +258 -255
- package/dist/process.js +3 -1
- package/dist/pwa.js +269 -266
- package/dist/runtime-injection.js +16 -3
- package/dist/ssg.js +230 -227
- package/dist/style-scoping.d.ts +9 -0
- package/dist/style-scoping.js +10 -0
- package/package.json +5 -5
|
@@ -61,8 +61,21 @@ ${browserScript}`);
|
|
|
61
61
|
` + template;
|
|
62
62
|
}
|
|
63
63
|
export async function injectSignalsRuntime(template, options) {
|
|
64
|
-
if (template.includes("window.stx.state") || template.includes("STX Signals Runtime"))
|
|
64
|
+
if (template.includes("data-stx-runtime") || template.includes("window.stx.state") || template.includes("STX Signals Runtime"))
|
|
65
65
|
return template;
|
|
66
|
+
if (options.buildMode === "serve") {
|
|
67
|
+
const runtimeScript = '<script data-stx-runtime src="/_stx/runtime.js"></script>', firstScriptInDoc = template.indexOf("<script");
|
|
68
|
+
if (firstScriptInDoc !== -1)
|
|
69
|
+
return template.slice(0, firstScriptInDoc) + runtimeScript + `
|
|
70
|
+
` + template.slice(firstScriptInDoc);
|
|
71
|
+
if (template.includes("</head>")) {
|
|
72
|
+
const idx = template.indexOf("</head>");
|
|
73
|
+
return template.slice(0, idx) + runtimeScript + `
|
|
74
|
+
` + template.slice(idx);
|
|
75
|
+
}
|
|
76
|
+
return runtimeScript + `
|
|
77
|
+
` + template;
|
|
78
|
+
}
|
|
66
79
|
if (options.buildMode === "compile") {
|
|
67
80
|
const runtimeScript = '<script data-stx-runtime src="/__stx/runtime.__STX_HASH__.js"></script>', firstScriptInDoc = template.indexOf("<script");
|
|
68
81
|
if (firstScriptInDoc !== -1)
|
|
@@ -96,7 +109,7 @@ export async function injectSignalsRuntime(template, options) {
|
|
|
96
109
|
export async function injectRouterScript(template, options) {
|
|
97
110
|
if (!template.includes("</body>"))
|
|
98
111
|
return template;
|
|
99
|
-
if (template.includes("__stxRouter)return") || template.includes("__stxRouter=true"))
|
|
112
|
+
if (template.includes("data-stx-router") || template.includes("__stxRouter)return") || template.includes("__stxRouter=true"))
|
|
100
113
|
return template;
|
|
101
114
|
const routerConfig = options?.router;
|
|
102
115
|
let configScript = "";
|
|
@@ -128,7 +141,7 @@ export async function injectRouterScript(template, options) {
|
|
|
128
141
|
configScript = `<script>window.__stxRouterConfig=${JSON.stringify(configObj)};</script>
|
|
129
142
|
`;
|
|
130
143
|
}
|
|
131
|
-
const { getCachedRouterScript } = await import("./caching.js"), routerScript = options?.buildMode === "compile" ? '<script src="/__stx/router.__STX_HASH__.js"></script>' : `<script>${await getCachedRouterScript()}</script>`, bodyCloseIdx = template.lastIndexOf("</body>");
|
|
144
|
+
const { getCachedRouterScript } = await import("./caching.js"), routerScript = options?.buildMode === "compile" ? '<script data-stx-router src="/__stx/router.__STX_HASH__.js"></script>' : options?.buildMode === "serve" ? '<script data-stx-router src="/_stx/router.js"></script>' : `<script data-stx-router>${await getCachedRouterScript()}</script>`, bodyCloseIdx = template.lastIndexOf("</body>");
|
|
132
145
|
return template.slice(0, bodyCloseIdx) + configScript + routerScript + `
|
|
133
146
|
</body>` + template.slice(bodyCloseIdx + 7);
|
|
134
147
|
}
|