bun-plugin-stx 0.2.189 → 0.2.191

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 CHANGED
@@ -189,6 +189,7 @@ export declare interface ServeRequestContext {
189
189
  method: string
190
190
  request?: Request
191
191
  responseStatus?: number
192
+ responseHeaders?: Record<string, string>
192
193
  actionRedirect?: string
193
194
  actionCookies?: string[]
194
195
  [key: string]: unknown
@@ -199,6 +200,7 @@ export declare interface ServeOptions {
199
200
  openPath?: string
200
201
  componentsDir?: string
201
202
  layoutsDir?: string
203
+ fallbackLayoutsDir?: string
202
204
  partialsDir?: string
203
205
  watchDirs?: string[]
204
206
  renderCache?: boolean
package/dist/serve.js CHANGED
@@ -9073,6 +9073,7 @@ async function serve(options) {
9073
9073
  } catch {}
9074
9074
  const componentsDir = options.componentsDir ?? stxConfig.componentsDir ?? defaultStxConfig.componentsDir;
9075
9075
  const layoutsDir = options.layoutsDir ?? stxConfig.layoutsDir ?? defaultStxConfig.layoutsDir;
9076
+ const fallbackLayoutsDir = options.fallbackLayoutsDir ?? stxConfig.fallbackLayoutsDir;
9076
9077
  const partialsDir = options.partialsDir ?? stxConfig.partialsDir ?? defaultStxConfig.partialsDir;
9077
9078
  const publicDir = options.publicDir ?? stxConfig.publicDir ?? "public";
9078
9079
  const stxModule = options.stxModule ? Promise.resolve(options.stxModule) : defaultStxModule;
@@ -9418,6 +9419,12 @@ function __stxOverlay(errs){
9418
9419
  if (Number.isInteger(status) && status >= 100 && status <= 599)
9419
9420
  full.responseStatus = status;
9420
9421
  };
9422
+ context.setResponseHeader = (name, value) => {
9423
+ const header = String(name ?? "").trim();
9424
+ if (!header)
9425
+ return;
9426
+ full.responseHeaders = { ...full.responseHeaders, [header]: String(value) };
9427
+ };
9421
9428
  }
9422
9429
  function htmlCacheKey(filePath, reqCtx) {
9423
9430
  if (RENDER_CACHE_VARY === "source")
@@ -9749,8 +9756,10 @@ function __stxOverlay(errs){
9749
9756
  const cacheKey = htmlCacheKey(filePath, reqCtx);
9750
9757
  const cachedEntry = htmlCache.get(cacheKey);
9751
9758
  if (cachedEntry && await templateSignatureFresh(cachedEntry.signature)) {
9752
- if (reqCtx)
9759
+ if (reqCtx) {
9753
9760
  reqCtx.responseStatus = cachedEntry.status;
9761
+ reqCtx.responseHeaders = cachedEntry.headers;
9762
+ }
9754
9763
  return cachedEntry.html;
9755
9764
  }
9756
9765
  }
@@ -9774,6 +9783,7 @@ function __stxOverlay(errs){
9774
9783
  root: process19.cwd(),
9775
9784
  ...componentsDir && { componentsDir },
9776
9785
  ...layoutsDir && { layoutsDir },
9786
+ ...fallbackLayoutsDir && { fallbackLayoutsDir },
9777
9787
  ...partialsDir && { partialsDir },
9778
9788
  autoShell: true,
9779
9789
  buildMode: "serve",
@@ -9817,7 +9827,7 @@ function __stxOverlay(errs){
9817
9827
  }
9818
9828
  if (ENABLE_HTML_CACHE && !context.__stx_skip_cache && !skipCacheHint && !isMutating && isRenderableCacheCandidate(output)) {
9819
9829
  const signature = await buildTemplateSignature(filePath, dependencies);
9820
- htmlCache.set(htmlCacheKey(filePath, reqCtx), { html: output, signature, status: reqCtx?.responseStatus ?? 200 });
9830
+ htmlCache.set(htmlCacheKey(filePath, reqCtx), { html: output, signature, status: reqCtx?.responseStatus ?? 200, headers: reqCtx?.responseHeaders });
9821
9831
  }
9822
9832
  return output;
9823
9833
  }
@@ -9960,6 +9970,7 @@ function __stxOverlay(errs){
9960
9970
  root: process19.cwd(),
9961
9971
  ...componentsDir && { componentsDir },
9962
9972
  ...layoutsDir && { layoutsDir },
9973
+ ...fallbackLayoutsDir && { fallbackLayoutsDir },
9963
9974
  ...partialsDir && { partialsDir },
9964
9975
  autoShell: true,
9965
9976
  buildMode: "serve",
@@ -10337,6 +10348,7 @@ ${html}`;
10337
10348
  ...defaultConfig4,
10338
10349
  ...componentsDir && { componentsDir },
10339
10350
  ...layoutsDir && { layoutsDir },
10351
+ ...fallbackLayoutsDir && { fallbackLayoutsDir },
10340
10352
  ...partialsDir && { partialsDir },
10341
10353
  autoShell: false
10342
10354
  };
@@ -10603,6 +10615,8 @@ ${trailingPageScripts.join(`
10603
10615
  "Cache-Control": "no-store",
10604
10616
  ...corsHeaders
10605
10617
  });
10618
+ for (const [name, value] of Object.entries(reqCtx.responseHeaders ?? {}))
10619
+ pageHeaders.set(name, value);
10606
10620
  for (const cookie of reqCtx.actionCookies ?? [])
10607
10621
  pageHeaders.append("Set-Cookie", cookie);
10608
10622
  return new Response(injectHmrClient(cleaned), {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-plugin-stx",
3
3
  "type": "module",
4
- "version": "0.2.189",
4
+ "version": "0.2.191",
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",