bun-plugin-stx 0.2.812 → 0.2.815
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 +23 -7
- package/package.json +3 -3
package/dist/serve.js
CHANGED
|
@@ -10364,7 +10364,17 @@ function __stxOverlay(errs){
|
|
|
10364
10364
|
return filePath;
|
|
10365
10365
|
if (reqCtx) {
|
|
10366
10366
|
try {
|
|
10367
|
-
|
|
10367
|
+
const request = reqCtx.request;
|
|
10368
|
+
const snapshot = request ? {
|
|
10369
|
+
...reqCtx,
|
|
10370
|
+
request: {
|
|
10371
|
+
...request,
|
|
10372
|
+
url: request.url,
|
|
10373
|
+
method: request.method,
|
|
10374
|
+
headers: [...request.headers.entries()].sort(([a], [b]) => a.localeCompare(b))
|
|
10375
|
+
}
|
|
10376
|
+
} : reqCtx;
|
|
10377
|
+
return `${filePath}\x00${JSON.stringify(snapshot)}`;
|
|
10368
10378
|
} catch {
|
|
10369
10379
|
return `${filePath}\x00uncacheable:${crypto.randomUUID()}`;
|
|
10370
10380
|
}
|
|
@@ -10378,6 +10388,12 @@ function __stxOverlay(errs){
|
|
|
10378
10388
|
return filePath;
|
|
10379
10389
|
return `${filePath}\x00${loc}\x00${search}\x00${host}\x00${cookies}\x00${ip}`;
|
|
10380
10390
|
}
|
|
10391
|
+
function allowsRenderCache(reqCtx) {
|
|
10392
|
+
const noStore = /(?:^|,)\s*no-store(?:\s*(?:=|,|$))/i;
|
|
10393
|
+
if (noStore.test(reqCtx?.request?.headers.get("cache-control") ?? ""))
|
|
10394
|
+
return false;
|
|
10395
|
+
return !Object.entries(reqCtx?.responseHeaders ?? {}).some(([name, value]) => name.toLowerCase() === "cache-control" && noStore.test(value));
|
|
10396
|
+
}
|
|
10381
10397
|
const builtInMiddleware = authConfig === null ? {} : {
|
|
10382
10398
|
auth: (_req, ctx) => {
|
|
10383
10399
|
const tok = ctx.cookies[authCookieName];
|
|
@@ -10701,8 +10717,8 @@ function __stxOverlay(errs){
|
|
|
10701
10717
|
reqCtx.responseStatus = extractPageResponseStatus(content) ?? 200;
|
|
10702
10718
|
const skipCacheHint = /(?:^|[^\w$])__stx_skip_cache\s*=\s*true/.test(content);
|
|
10703
10719
|
const isMutating = !!reqCtx && reqCtx.method !== "GET" && reqCtx.method !== "HEAD";
|
|
10704
|
-
|
|
10705
|
-
|
|
10720
|
+
const cacheKey = ENABLE_HTML_CACHE && !skipCacheHint && !isMutating && allowsRenderCache(reqCtx) ? htmlCacheKey(filePath, reqCtx) : undefined;
|
|
10721
|
+
if (cacheKey !== undefined) {
|
|
10706
10722
|
const cachedEntry = await readRenderCache(cacheKey);
|
|
10707
10723
|
if (cachedEntry && await templateSignatureFresh(cachedEntry.signature)) {
|
|
10708
10724
|
if (reqCtx) {
|
|
@@ -10782,9 +10798,9 @@ function __stxOverlay(errs){
|
|
|
10782
10798
|
} else {
|
|
10783
10799
|
output = output.replace(/<template[^>]*>/gi, "").replace(/<\/template>/gi, "");
|
|
10784
10800
|
}
|
|
10785
|
-
if (
|
|
10801
|
+
if (cacheKey !== undefined && !context.__stx_skip_cache && !skipCacheHint && !isMutating && allowsRenderCache(reqCtx) && isRenderableCacheCandidate(output) && placeholdersAreReady) {
|
|
10786
10802
|
const signature = await buildTemplateSignature(filePath, dependencies);
|
|
10787
|
-
rememberRender(
|
|
10803
|
+
rememberRender(cacheKey, { html: output, signature, status: reqCtx?.responseStatus ?? 200, headers: reqCtx?.responseHeaders }, ticket);
|
|
10788
10804
|
}
|
|
10789
10805
|
return output;
|
|
10790
10806
|
}
|
|
@@ -10906,7 +10922,7 @@ function __stxOverlay(errs){
|
|
|
10906
10922
|
}
|
|
10907
10923
|
const isMutating = !!reqCtx && reqCtx.method !== "GET" && reqCtx.method !== "HEAD";
|
|
10908
10924
|
const skipCacheHint = /(?:^|[^\w$])__stx_skip_cache\s*=\s*true/.test(content);
|
|
10909
|
-
const cacheShell = ENABLE_HTML_CACHE && RENDER_CACHE_VARY === "source" && paramNames.length > 0 && !isMutating && !skipCacheHint && !serverScriptsReadParams(dynServerScripts, paramNames);
|
|
10925
|
+
const cacheShell = ENABLE_HTML_CACHE && RENDER_CACHE_VARY === "source" && paramNames.length > 0 && !isMutating && !skipCacheHint && allowsRenderCache(reqCtx) && !serverScriptsReadParams(dynServerScripts, paramNames);
|
|
10910
10926
|
if (reqCtx)
|
|
10911
10927
|
reqCtx.params = paramsObj;
|
|
10912
10928
|
if (cacheShell) {
|
|
@@ -11005,7 +11021,7 @@ ${output}`;
|
|
|
11005
11021
|
if (!cacheShell)
|
|
11006
11022
|
return output;
|
|
11007
11023
|
const recordedResponse = readResponseStatus(context) !== undefined || !!readResponseHeaders(context);
|
|
11008
|
-
if (!context.__stx_skip_cache && !recordedResponse && isRenderableCacheCandidate(output) && placeholdersAreReady) {
|
|
11024
|
+
if (!context.__stx_skip_cache && !recordedResponse && allowsRenderCache(reqCtx) && isRenderableCacheCandidate(output) && placeholdersAreReady) {
|
|
11009
11025
|
const signature = await buildTemplateSignature(filePath, dependencies);
|
|
11010
11026
|
rememberRender(filePath, { html: output, signature, status: reqCtx?.responseStatus ?? 200, headers: reqCtx?.responseHeaders }, ticket);
|
|
11011
11027
|
}
|
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.815",
|
|
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.815",
|
|
78
|
+
"stx-router": "0.2.815"
|
|
79
79
|
}
|
|
80
80
|
}
|