bun-plugin-stx 0.2.706 → 0.2.708
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/serve.js +21 -3
- package/package.json +3 -3
package/dist/serve.js
CHANGED
|
@@ -8755,7 +8755,7 @@ var defaultConfigDir4 = /* @__PURE__ */ resolve12(process19.cwd(), "config");
|
|
|
8755
8755
|
var defaultGeneratedDir4 = /* @__PURE__ */ resolve12(process19.cwd(), "src/generated");
|
|
8756
8756
|
|
|
8757
8757
|
// src/serve.ts
|
|
8758
|
-
import { BUILD_ID_HEADER, decodeTitleEntities, externalScriptsOutsideContainer, extractPageResponseStatus, findContainerRegion, FRAGMENT_CACHE_CONTROL, getBuildId, mergeCssConfig, readResponseHeaders, readResponseStatus, renderFontCSS, SPA_NAV_HEADER, spaNavVaryHeaders, stateDir, stateDirName } from "@stacksjs/stx";
|
|
8758
|
+
import { BUILD_ID_HEADER, decodeTitleEntities, externalScriptsOutsideContainer, extractPageResponseStatus, findContainerRegion, FRAGMENT_CACHE_CONTROL, getBuildId, mergeCssConfig, pageHeadFragment, readResponseHeaders, readResponseStatus, renderFontCSS, SPA_NAV_HEADER, spaNavVaryHeaders, stateDir, stateDirName } from "@stacksjs/stx";
|
|
8759
8759
|
import { buildCodeFrame, locateFailureLine } from "@stacksjs/stx/build-message";
|
|
8760
8760
|
import { clearBundleFailures, getBundleFailures } from "@stacksjs/stx/client-script-bundler";
|
|
8761
8761
|
import { actionRedirectResponse, compressResponse, runPageAction as sharedRunPageAction } from "@stacksjs/stx";
|
|
@@ -10739,11 +10739,17 @@ ${block}`;
|
|
|
10739
10739
|
return res;
|
|
10740
10740
|
const stx = await siteStxPromise;
|
|
10741
10741
|
let html = await res.text();
|
|
10742
|
+
const fragmentHead = res.headers.get("X-STX-Fragment") === "true" ? /^<template data-stx-page-head="1">([\s\S]*?)<\/template>\n?/.exec(html) : null;
|
|
10743
|
+
let fragmentMetadata = fragmentHead ? `<head>${fragmentHead[1]}</head>` : null;
|
|
10744
|
+
if (fragmentHead)
|
|
10745
|
+
html = html.slice(fragmentHead[0].length);
|
|
10742
10746
|
if (siteConfig && stx.injectThemeBootstrap)
|
|
10743
10747
|
html = stx.injectThemeBootstrap(html, siteConfig);
|
|
10744
10748
|
if (siteConfig && stx.injectSeo) {
|
|
10745
10749
|
const pageMeta = (siteConfig.pages ?? {})[normalizedPath] ?? {};
|
|
10746
10750
|
html = stx.injectSeo(html, siteConfig, pageMeta, normalizedPath);
|
|
10751
|
+
if (fragmentMetadata !== null)
|
|
10752
|
+
fragmentMetadata = stx.injectSeo(fragmentMetadata, siteConfig, pageMeta, normalizedPath);
|
|
10747
10753
|
}
|
|
10748
10754
|
if (i18nConfig && stx.buildLangPickerScript) {
|
|
10749
10755
|
const pickerScript = stx.buildLangPickerScript(i18nConfig, locale);
|
|
@@ -10770,16 +10776,28 @@ ${block}`;
|
|
|
10770
10776
|
return `<a${before}href="${localized}${rest}"${after}>`;
|
|
10771
10777
|
});
|
|
10772
10778
|
}
|
|
10773
|
-
if (i18nConfig && stx.applyTranslations)
|
|
10779
|
+
if (i18nConfig && stx.applyTranslations) {
|
|
10774
10780
|
html = stx.applyTranslations(html, i18nConfig, locale);
|
|
10781
|
+
if (fragmentMetadata !== null)
|
|
10782
|
+
fragmentMetadata = stx.applyTranslations(fragmentMetadata, i18nConfig, locale);
|
|
10783
|
+
}
|
|
10775
10784
|
html = ensureRouterConfig(html);
|
|
10785
|
+
if (fragmentMetadata !== null)
|
|
10786
|
+
html = pageHeadFragment(fragmentMetadata) + html;
|
|
10776
10787
|
const headers = new Headers(res.headers);
|
|
10788
|
+
if (fragmentHead && i18nConfig)
|
|
10789
|
+
headers.set("X-STX-Layout-Group", `i18n:${locale}`);
|
|
10777
10790
|
const fragmentTitle = headers.get("X-STX-Title");
|
|
10778
10791
|
if (res.headers.get("X-STX-Fragment") === "true" && fragmentTitle && i18nConfig && stx.applyTranslations) {
|
|
10779
10792
|
const titleHtml = escapeHtml(decodeURIComponent(fragmentTitle));
|
|
10780
10793
|
const translated = stx.applyTranslations(titleHtml, i18nConfig, locale);
|
|
10781
10794
|
headers.set("X-STX-Title", encodeURIComponent(decodeTitleEntities(translated)));
|
|
10782
10795
|
}
|
|
10796
|
+
if (fragmentMetadata !== null) {
|
|
10797
|
+
const resolvedTitle = /<title\b[^>]*>([\s\S]*?)<\/title>/i.exec(fragmentMetadata);
|
|
10798
|
+
if (resolvedTitle)
|
|
10799
|
+
headers.set("X-STX-Title", encodeURIComponent(decodeTitleEntities(resolvedTitle[1])));
|
|
10800
|
+
}
|
|
10783
10801
|
headers.delete("content-length");
|
|
10784
10802
|
return new Response(html, {
|
|
10785
10803
|
status: res.status,
|
|
@@ -11377,7 +11395,7 @@ ${block}`;
|
|
|
11377
11395
|
const inlinePageScripts = pageSetupScripts.filter((script) => !externalPageScripts.includes(script));
|
|
11378
11396
|
const componentFactoryScripts = inlinePageScripts.filter((script) => script.includes("data-stx-component-factories"));
|
|
11379
11397
|
const trailingPageScripts = inlinePageScripts.filter((script) => !script.includes("data-stx-component-factories"));
|
|
11380
|
-
fragment = `${headStyles.join(`
|
|
11398
|
+
fragment = `${pageHeadFragment(content)}${headStyles.join(`
|
|
11381
11399
|
`)}
|
|
11382
11400
|
${externalPageScripts.join(`
|
|
11383
11401
|
`)}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bun-plugin-stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.708",
|
|
5
5
|
"description": "A Bun plugin that allows for using Laravel Blade-like syntax.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"typecheck": "bun tsc --noEmit"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@stacksjs/stx": "0.2.
|
|
78
|
-
"stx-router": "0.2.
|
|
77
|
+
"@stacksjs/stx": "0.2.708",
|
|
78
|
+
"stx-router": "0.2.708"
|
|
79
79
|
}
|
|
80
80
|
}
|