bun-plugin-stx 0.2.72 → 0.2.74
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/chunk-bpa1j7nx.js +9523 -0
- package/dist/serve.js +44 -7
- package/package.json +3 -3
- package/dist/chunk-v61e2x3s.js +0 -6206
package/dist/serve.js
CHANGED
|
@@ -8810,6 +8810,8 @@ async function serve(options) {
|
|
|
8810
8810
|
stxConfig._pluginComponentDirs = pluginLoaded._pluginComponentDirs;
|
|
8811
8811
|
if (pluginLoaded?._pluginPageDirs)
|
|
8812
8812
|
stxConfig._pluginPageDirs = pluginLoaded._pluginPageDirs;
|
|
8813
|
+
if (pluginLoaded?.analytics)
|
|
8814
|
+
stxConfig.analytics = pluginLoaded.analytics;
|
|
8813
8815
|
}
|
|
8814
8816
|
if (stxMod && typeof stxMod.preloadIconCollection === "function")
|
|
8815
8817
|
await stxMod.preloadIconCollection("lucide");
|
|
@@ -9016,6 +9018,7 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9016
9018
|
const extraProtectedPrefixes = authConfig?.protectedPaths ?? [];
|
|
9017
9019
|
let activeServeLocale = null;
|
|
9018
9020
|
let activeServeSearch = "";
|
|
9021
|
+
let activeServeHost = "";
|
|
9019
9022
|
function injectServeLocaleContext(context) {
|
|
9020
9023
|
if (!activeServeLocale)
|
|
9021
9024
|
return;
|
|
@@ -9027,17 +9030,20 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9027
9030
|
};
|
|
9028
9031
|
}
|
|
9029
9032
|
function injectServeRequestContext(context) {
|
|
9030
|
-
if (
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
|
|
9033
|
+
if (activeServeSearch) {
|
|
9034
|
+
context.__stxServeSearch = activeServeSearch;
|
|
9035
|
+
globalThis.__stxServeSearch = activeServeSearch;
|
|
9036
|
+
}
|
|
9037
|
+
if (activeServeHost)
|
|
9038
|
+
context.host = activeServeHost;
|
|
9034
9039
|
}
|
|
9035
9040
|
function htmlCacheKey(filePath) {
|
|
9036
9041
|
const loc = i18nConfig ? activeServeLocale ?? i18nConfig.defaultLocale : "";
|
|
9037
9042
|
const search = activeServeSearch || "";
|
|
9038
|
-
|
|
9043
|
+
const host = activeServeHost || "";
|
|
9044
|
+
if (!loc && !search && !host)
|
|
9039
9045
|
return filePath;
|
|
9040
|
-
return `${filePath}\x00${loc}\x00${search}`;
|
|
9046
|
+
return `${filePath}\x00${loc}\x00${search}\x00${host}`;
|
|
9041
9047
|
}
|
|
9042
9048
|
const builtInMiddleware = authConfig === null ? {} : {
|
|
9043
9049
|
auth: (_req, ctx) => {
|
|
@@ -9195,7 +9201,7 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9195
9201
|
return crosswindModule;
|
|
9196
9202
|
crosswindLoadAttempted = true;
|
|
9197
9203
|
try {
|
|
9198
|
-
const mod = await import("./chunk-
|
|
9204
|
+
const mod = await import("./chunk-bpa1j7nx.js");
|
|
9199
9205
|
crosswindModule = { CSSGenerator: mod.CSSGenerator, config: mod.config };
|
|
9200
9206
|
return crosswindModule;
|
|
9201
9207
|
} catch {
|
|
@@ -9352,11 +9358,13 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9352
9358
|
app: stxConfig.app || {},
|
|
9353
9359
|
..."strict" in stxConfig && { strict: stxConfig.strict },
|
|
9354
9360
|
..."router" in stxConfig && { router: stxConfig.router },
|
|
9361
|
+
..."debug" in stxConfig && { debug: stxConfig.debug },
|
|
9355
9362
|
..."skipDefaultSeoTags" in stxConfig && { skipDefaultSeoTags: stxConfig.skipDefaultSeoTags },
|
|
9356
9363
|
..."defaultTitle" in stxConfig && { defaultTitle: stxConfig.defaultTitle },
|
|
9357
9364
|
..."defaultDescription" in stxConfig && { defaultDescription: stxConfig.defaultDescription },
|
|
9358
9365
|
..."defaultImage" in stxConfig && { defaultImage: stxConfig.defaultImage },
|
|
9359
9366
|
..."seo" in stxConfig && { seo: stxConfig.seo },
|
|
9367
|
+
..."analytics" in stxConfig && { analytics: stxConfig.analytics },
|
|
9360
9368
|
..."_pluginComponentDirs" in stxConfig && { _pluginComponentDirs: stxConfig._pluginComponentDirs },
|
|
9361
9369
|
..."_pluginPageDirs" in stxConfig && { _pluginPageDirs: stxConfig._pluginPageDirs }
|
|
9362
9370
|
};
|
|
@@ -9518,11 +9526,13 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9518
9526
|
app: stxConfig.app || {},
|
|
9519
9527
|
..."strict" in stxConfig && { strict: stxConfig.strict },
|
|
9520
9528
|
..."router" in stxConfig && { router: stxConfig.router },
|
|
9529
|
+
..."debug" in stxConfig && { debug: stxConfig.debug },
|
|
9521
9530
|
..."skipDefaultSeoTags" in stxConfig && { skipDefaultSeoTags: stxConfig.skipDefaultSeoTags },
|
|
9522
9531
|
..."defaultTitle" in stxConfig && { defaultTitle: stxConfig.defaultTitle },
|
|
9523
9532
|
..."defaultDescription" in stxConfig && { defaultDescription: stxConfig.defaultDescription },
|
|
9524
9533
|
..."defaultImage" in stxConfig && { defaultImage: stxConfig.defaultImage },
|
|
9525
9534
|
..."seo" in stxConfig && { seo: stxConfig.seo },
|
|
9535
|
+
..."analytics" in stxConfig && { analytics: stxConfig.analytics },
|
|
9526
9536
|
..."_pluginComponentDirs" in stxConfig && { _pluginComponentDirs: stxConfig._pluginComponentDirs },
|
|
9527
9537
|
..."_pluginPageDirs" in stxConfig && { _pluginPageDirs: stxConfig._pluginPageDirs }
|
|
9528
9538
|
};
|
|
@@ -9675,6 +9685,31 @@ ${html}`;
|
|
|
9675
9685
|
async fetch(req) {
|
|
9676
9686
|
const url = new URL(req.url);
|
|
9677
9687
|
let path = url.pathname;
|
|
9688
|
+
const proxyRules = stxConfig.server?.proxy;
|
|
9689
|
+
if (proxyRules) {
|
|
9690
|
+
for (const [prefix, rule] of Object.entries(proxyRules)) {
|
|
9691
|
+
if (path !== prefix && !path.startsWith(prefix))
|
|
9692
|
+
continue;
|
|
9693
|
+
const ruleCfg = typeof rule === "string" ? { target: rule } : rule;
|
|
9694
|
+
const outPath = ruleCfg.rewrite ? ruleCfg.rewrite(path) : path;
|
|
9695
|
+
const target = new URL(ruleCfg.target);
|
|
9696
|
+
const outUrl = new URL(outPath + url.search, target);
|
|
9697
|
+
const headers = new Headers(req.headers);
|
|
9698
|
+
if (ruleCfg.changeOrigin !== false)
|
|
9699
|
+
headers.set("host", target.host);
|
|
9700
|
+
try {
|
|
9701
|
+
return await fetch(outUrl, {
|
|
9702
|
+
method: req.method,
|
|
9703
|
+
headers,
|
|
9704
|
+
body: req.body,
|
|
9705
|
+
redirect: "manual",
|
|
9706
|
+
...req.body ? { duplex: "half" } : {}
|
|
9707
|
+
});
|
|
9708
|
+
} catch (err) {
|
|
9709
|
+
return new Response(`[stx dev proxy] ${prefix} \u2192 ${ruleCfg.target} failed: ${err instanceof Error ? err.message : String(err)}`, { status: 502 });
|
|
9710
|
+
}
|
|
9711
|
+
}
|
|
9712
|
+
}
|
|
9678
9713
|
let i18nLocale = null;
|
|
9679
9714
|
if (i18nConfig && !url.pathname.startsWith("/api/")) {
|
|
9680
9715
|
const stripped = localeFromPath(url.pathname);
|
|
@@ -9695,6 +9730,7 @@ ${html}`;
|
|
|
9695
9730
|
const _i18nResp = await (async () => {
|
|
9696
9731
|
activeServeLocale = i18nLocale;
|
|
9697
9732
|
activeServeSearch = url.search;
|
|
9733
|
+
activeServeHost = req.headers.get("host") || "";
|
|
9698
9734
|
try {
|
|
9699
9735
|
if (req.method === "OPTIONS") {
|
|
9700
9736
|
return new Response(null, { headers: corsHeaders });
|
|
@@ -10130,6 +10166,7 @@ ${pageSetupScripts.join(`
|
|
|
10130
10166
|
} finally {
|
|
10131
10167
|
activeServeLocale = null;
|
|
10132
10168
|
activeServeSearch = "";
|
|
10169
|
+
activeServeHost = "";
|
|
10133
10170
|
}
|
|
10134
10171
|
})();
|
|
10135
10172
|
return applyI18nToResponse(_i18nResp, i18nLocale ?? (i18nConfig?.defaultLocale ?? "en"), path);
|
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.74",
|
|
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",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"typecheck": "bun tsc --noEmit"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@stacksjs/stx": "0.2.72",
|
|
77
|
-
"stx-router": "0.2.72"
|
|
76
|
+
"@stacksjs/stx": "^0.2.72",
|
|
77
|
+
"stx-router": "^0.2.72"
|
|
78
78
|
}
|
|
79
79
|
}
|