bun-plugin-stx 0.2.138 → 0.2.139
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.d.ts +1 -0
- package/dist/serve.js +9 -1
- package/package.json +1 -1
package/dist/serve.d.ts
CHANGED
package/dist/serve.js
CHANGED
|
@@ -8700,7 +8700,7 @@ var defaultConfigDir4 = resolve12(process20.cwd(), "config");
|
|
|
8700
8700
|
var defaultGeneratedDir4 = resolve12(process20.cwd(), "src/generated");
|
|
8701
8701
|
|
|
8702
8702
|
// src/serve.ts
|
|
8703
|
-
import { stateDir, stateDirName } from "@stacksjs/stx";
|
|
8703
|
+
import { extractPageResponseStatus, stateDir, stateDirName } from "@stacksjs/stx";
|
|
8704
8704
|
var defaultStxModule = import("@stacksjs/stx");
|
|
8705
8705
|
var REACTIVE_TEMPLATE_DIRECTIVE_RE = /@for|:for|@if|:if|@else|:else|x-for|x-if|x-else/;
|
|
8706
8706
|
function extractServerScriptsFromTemplate(content) {
|
|
@@ -9513,6 +9513,8 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9513
9513
|
}
|
|
9514
9514
|
async function processTemplate(filePath, reqCtx) {
|
|
9515
9515
|
const content = await Bun.file(filePath).text();
|
|
9516
|
+
if (reqCtx)
|
|
9517
|
+
reqCtx.responseStatus = extractPageResponseStatus(content) ?? 200;
|
|
9516
9518
|
const skipCacheHint = /(?:^|[^\w$])__stx_skip_cache\s*=\s*true/.test(content);
|
|
9517
9519
|
if (ENABLE_HTML_CACHE && !skipCacheHint) {
|
|
9518
9520
|
const cacheKey = htmlCacheKey(filePath);
|
|
@@ -9682,6 +9684,8 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9682
9684
|
}
|
|
9683
9685
|
async function processTemplateDynamic(filePath, paramNames, paramValues, routePath, reqCtx) {
|
|
9684
9686
|
const content = await Bun.file(filePath).text();
|
|
9687
|
+
if (reqCtx)
|
|
9688
|
+
reqCtx.responseStatus = extractPageResponseStatus(content) ?? 200;
|
|
9685
9689
|
const { serverScripts: dynServerScripts, templateContent } = extractServerScriptsFromTemplate(content);
|
|
9686
9690
|
const context = {
|
|
9687
9691
|
__filename: filePath,
|
|
@@ -10173,6 +10177,7 @@ ${html}`;
|
|
|
10173
10177
|
}
|
|
10174
10178
|
const content = await getRoute(path, reqCtx);
|
|
10175
10179
|
if (content) {
|
|
10180
|
+
const responseStatus = reqCtx.responseStatus ?? 200;
|
|
10176
10181
|
const isSpaNav = req.headers.get("X-STX-Router") === "true";
|
|
10177
10182
|
if (isSpaNav) {
|
|
10178
10183
|
const layoutMatch = content.match(/<!-- stx-layout: ([^ ]+) -->/);
|
|
@@ -10273,6 +10278,7 @@ ${trailingPageScripts.join(`
|
|
|
10273
10278
|
const titleMatch = content.match(/<title[^>]*>([\s\S]*?)<\/title>/i);
|
|
10274
10279
|
const pageTitle = titleMatch ? titleMatch[1].trim() : "";
|
|
10275
10280
|
return new Response(fragment, {
|
|
10281
|
+
status: responseStatus,
|
|
10276
10282
|
headers: {
|
|
10277
10283
|
"Content-Type": "text/html; charset=utf-8",
|
|
10278
10284
|
"X-STX-Fragment": "true",
|
|
@@ -10292,6 +10298,7 @@ ${trailingPageScripts.join(`
|
|
|
10292
10298
|
return runtimeCount === 1 ? match : "";
|
|
10293
10299
|
});
|
|
10294
10300
|
return new Response(injectHmrClient(cleaned), {
|
|
10301
|
+
status: responseStatus,
|
|
10295
10302
|
headers: {
|
|
10296
10303
|
"Content-Type": "text/html; charset=utf-8",
|
|
10297
10304
|
"Cache-Control": "no-store",
|
|
@@ -10302,6 +10309,7 @@ ${trailingPageScripts.join(`
|
|
|
10302
10309
|
const contentWithExt = await getRoute(`${path}.html`, reqCtx);
|
|
10303
10310
|
if (contentWithExt) {
|
|
10304
10311
|
return new Response(injectHmrClient(contentWithExt), {
|
|
10312
|
+
status: reqCtx.responseStatus ?? 200,
|
|
10305
10313
|
headers: {
|
|
10306
10314
|
"Content-Type": "text/html; charset=utf-8",
|
|
10307
10315
|
"Cache-Control": "no-store",
|
package/package.json
CHANGED