bun-plugin-stx 0.2.74 → 0.2.76
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 +17 -3
- package/package.json +1 -1
package/dist/serve.js
CHANGED
|
@@ -9019,6 +9019,9 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9019
9019
|
let activeServeLocale = null;
|
|
9020
9020
|
let activeServeSearch = "";
|
|
9021
9021
|
let activeServeHost = "";
|
|
9022
|
+
let activeServeCookies = {};
|
|
9023
|
+
let activeServeCookieHeader = "";
|
|
9024
|
+
let activeServeIp = "";
|
|
9022
9025
|
function injectServeLocaleContext(context) {
|
|
9023
9026
|
if (!activeServeLocale)
|
|
9024
9027
|
return;
|
|
@@ -9036,14 +9039,18 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9036
9039
|
}
|
|
9037
9040
|
if (activeServeHost)
|
|
9038
9041
|
context.host = activeServeHost;
|
|
9042
|
+
context.cookies = activeServeCookies;
|
|
9043
|
+
if (activeServeIp)
|
|
9044
|
+
context.ip = activeServeIp;
|
|
9039
9045
|
}
|
|
9040
9046
|
function htmlCacheKey(filePath) {
|
|
9041
9047
|
const loc = i18nConfig ? activeServeLocale ?? i18nConfig.defaultLocale : "";
|
|
9042
9048
|
const search = activeServeSearch || "";
|
|
9043
9049
|
const host = activeServeHost || "";
|
|
9044
|
-
|
|
9050
|
+
const cookies = activeServeCookieHeader;
|
|
9051
|
+
if (!loc && !search && !host && !cookies)
|
|
9045
9052
|
return filePath;
|
|
9046
|
-
return `${filePath}\x00${loc}\x00${search}\x00${host}`;
|
|
9053
|
+
return `${filePath}\x00${loc}\x00${search}\x00${host}\x00${cookies}`;
|
|
9047
9054
|
}
|
|
9048
9055
|
const builtInMiddleware = authConfig === null ? {} : {
|
|
9049
9056
|
auth: (_req, ctx) => {
|
|
@@ -9512,6 +9519,7 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9512
9519
|
const { processDirectives, extractVariables, defaultConfig: defaultConfig4, injectRouterScript: injectRouter, resetHead: resetHeadDyn } = await stxModule;
|
|
9513
9520
|
resetHeadDyn();
|
|
9514
9521
|
injectServeLocaleContext(context);
|
|
9522
|
+
injectServeRequestContext(context);
|
|
9515
9523
|
for (const scriptBody of dynServerScripts) {
|
|
9516
9524
|
await extractVariables(scriptBody, context, filePath);
|
|
9517
9525
|
}
|
|
@@ -9682,7 +9690,7 @@ ${html}`;
|
|
|
9682
9690
|
_server = bunServe({
|
|
9683
9691
|
port: actualPort,
|
|
9684
9692
|
idleTimeout: 0,
|
|
9685
|
-
async fetch(req) {
|
|
9693
|
+
async fetch(req, server) {
|
|
9686
9694
|
const url = new URL(req.url);
|
|
9687
9695
|
let path = url.pathname;
|
|
9688
9696
|
const proxyRules = stxConfig.server?.proxy;
|
|
@@ -9731,6 +9739,9 @@ ${html}`;
|
|
|
9731
9739
|
activeServeLocale = i18nLocale;
|
|
9732
9740
|
activeServeSearch = url.search;
|
|
9733
9741
|
activeServeHost = req.headers.get("host") || "";
|
|
9742
|
+
activeServeCookieHeader = req.headers.get("cookie") || "";
|
|
9743
|
+
activeServeCookies = parseCookies(req);
|
|
9744
|
+
activeServeIp = server.requestIP(req)?.address || (req.headers.get("x-forwarded-for") || "").split(",")[0].trim();
|
|
9734
9745
|
try {
|
|
9735
9746
|
if (req.method === "OPTIONS") {
|
|
9736
9747
|
return new Response(null, { headers: corsHeaders });
|
|
@@ -10167,6 +10178,9 @@ ${pageSetupScripts.join(`
|
|
|
10167
10178
|
activeServeLocale = null;
|
|
10168
10179
|
activeServeSearch = "";
|
|
10169
10180
|
activeServeHost = "";
|
|
10181
|
+
activeServeCookieHeader = "";
|
|
10182
|
+
activeServeCookies = {};
|
|
10183
|
+
activeServeIp = "";
|
|
10170
10184
|
}
|
|
10171
10185
|
})();
|
|
10172
10186
|
return applyI18nToResponse(_i18nResp, i18nLocale ?? (i18nConfig?.defaultLocale ?? "en"), path);
|
package/package.json
CHANGED