bun-plugin-stx 0.2.154 → 0.2.155
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 +10 -2
- package/package.json +1 -1
package/dist/serve.js
CHANGED
|
@@ -9283,6 +9283,10 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9283
9283
|
};
|
|
9284
9284
|
context.__stxServeContext = full;
|
|
9285
9285
|
globalThis.__stxServeContext = full;
|
|
9286
|
+
context.setResponseStatus = (status) => {
|
|
9287
|
+
if (Number.isInteger(status) && status >= 100 && status <= 599)
|
|
9288
|
+
full.responseStatus = status;
|
|
9289
|
+
};
|
|
9286
9290
|
}
|
|
9287
9291
|
function htmlCacheKey(filePath, reqCtx) {
|
|
9288
9292
|
if (RENDER_CACHE_VARY === "source")
|
|
@@ -9604,8 +9608,11 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9604
9608
|
if (ENABLE_HTML_CACHE && !skipCacheHint) {
|
|
9605
9609
|
const cacheKey = htmlCacheKey(filePath, reqCtx);
|
|
9606
9610
|
const cachedEntry = htmlCache.get(cacheKey);
|
|
9607
|
-
if (cachedEntry && await templateSignatureFresh(cachedEntry.signature))
|
|
9611
|
+
if (cachedEntry && await templateSignatureFresh(cachedEntry.signature)) {
|
|
9612
|
+
if (reqCtx)
|
|
9613
|
+
reqCtx.responseStatus = cachedEntry.status;
|
|
9608
9614
|
return cachedEntry.html;
|
|
9615
|
+
}
|
|
9609
9616
|
}
|
|
9610
9617
|
const { serverScripts, templateContent } = extractServerScriptsFromTemplate(content);
|
|
9611
9618
|
const context = {
|
|
@@ -9669,13 +9676,14 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9669
9676
|
}
|
|
9670
9677
|
if (ENABLE_HTML_CACHE && !context.__stx_skip_cache && !skipCacheHint && isRenderableCacheCandidate(output)) {
|
|
9671
9678
|
const signature = await buildTemplateSignature(filePath, dependencies);
|
|
9672
|
-
htmlCache.set(htmlCacheKey(filePath, reqCtx), { html: output, signature });
|
|
9679
|
+
htmlCache.set(htmlCacheKey(filePath, reqCtx), { html: output, signature, status: reqCtx?.responseStatus ?? 200 });
|
|
9673
9680
|
}
|
|
9674
9681
|
return output;
|
|
9675
9682
|
}
|
|
9676
9683
|
async function getRoute(requestPath, reqCtx) {
|
|
9677
9684
|
const files = await discoverFiles();
|
|
9678
9685
|
let normalizedPath = requestPath.startsWith("/") ? requestPath.slice(1) : requestPath;
|
|
9686
|
+
normalizedPath = normalizedPath.replace(/\/+$/, "");
|
|
9679
9687
|
const possibleFiles = [];
|
|
9680
9688
|
for (const ext of [".stx", ".md", ".html", ""]) {
|
|
9681
9689
|
const directPath = normalizedPath.endsWith(ext) ? normalizedPath : `${normalizedPath}${ext}`;
|
package/package.json
CHANGED