bun-plugin-stx 0.2.217 → 0.2.219

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.
Files changed (2) hide show
  1. package/dist/serve.js +16 -1
  2. package/package.json +1 -1
package/dist/serve.js CHANGED
@@ -8718,7 +8718,7 @@ var defaultConfigDir4 = /* @__PURE__ */ resolve12(process20.cwd(), "config");
8718
8718
  var defaultGeneratedDir4 = /* @__PURE__ */ resolve12(process20.cwd(), "src/generated");
8719
8719
 
8720
8720
  // src/serve.ts
8721
- import { BUILD_ID_HEADER, extractPageResponseStatus, findContainerRegion, getBuildId, mergeCrosswindConfig, stateDir, stateDirName } from "@stacksjs/stx";
8721
+ import { BUILD_ID_HEADER, extractPageResponseStatus, findContainerRegion, getBuildId, mergeCrosswindConfig, readResponseHeaders, readResponseStatus, stateDir, stateDirName } from "@stacksjs/stx";
8722
8722
  import { buildCodeFrame, locateFailureLine } from "@stacksjs/stx/build-message";
8723
8723
  import { clearBundleFailures, getBundleFailures } from "@stacksjs/stx/client-script-bundler";
8724
8724
  import { actionRedirectResponse, compressResponse, runPageAction as sharedRunPageAction } from "@stacksjs/stx";
@@ -9451,6 +9451,9 @@ function __stxOverlay(errs){
9451
9451
  if (Number.isInteger(status) && status >= 100 && status <= 599)
9452
9452
  full.responseStatus = status;
9453
9453
  };
9454
+ context.notFound = (status = 404) => {
9455
+ full.responseStatus = Number.isInteger(status) && status >= 400 && status <= 599 ? status : 404;
9456
+ };
9454
9457
  context.setResponseHeader = (name, value) => {
9455
9458
  const header = String(name ?? "").trim();
9456
9459
  if (!header)
@@ -9776,6 +9779,16 @@ function __stxOverlay(errs){
9776
9779
  if (result.cookies && result.cookies.length > 0)
9777
9780
  reqCtx.actionCookies = result.cookies;
9778
9781
  }
9782
+ function applyRecordedResponse(context, reqCtx) {
9783
+ if (!reqCtx)
9784
+ return;
9785
+ const status = readResponseStatus(context);
9786
+ if (status !== undefined)
9787
+ reqCtx.responseStatus = status;
9788
+ const headers = readResponseHeaders(context);
9789
+ if (headers)
9790
+ reqCtx.responseHeaders = { ...reqCtx.responseHeaders, ...headers };
9791
+ }
9779
9792
  async function processTemplate(filePath, reqCtx) {
9780
9793
  const content = await Bun.file(filePath).text();
9781
9794
  if (reqCtx)
@@ -9841,6 +9854,7 @@ function __stxOverlay(errs){
9841
9854
  let output = templateContent;
9842
9855
  const dependencies = new Set;
9843
9856
  output = await processDirectives(output, context, filePath, config5, dependencies);
9857
+ applyRecordedResponse(context, reqCtx);
9844
9858
  output = await injectRouterScript(output, getRouterInjectOptions());
9845
9859
  const directiveTemplateRe = REACTIVE_TEMPLATE_DIRECTIVE_RE;
9846
9860
  const hasDirectiveTemplates = new RegExp(`<template\\s[^>]*(?:${REACTIVE_TEMPLATE_DIRECTIVE_RE.source})`).test(output);
@@ -10021,6 +10035,7 @@ function __stxOverlay(errs){
10021
10035
  let output = templateContent;
10022
10036
  const dependencies = new Set;
10023
10037
  output = await processDirectives(output, context, filePath, config5, dependencies);
10038
+ applyRecordedResponse(context, reqCtx);
10024
10039
  if (paramNames.length > 0) {
10025
10040
  const serializedParams = JSON.stringify(paramsObj).replace(/</g, "\\u003C").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
10026
10041
  const paramsScript = `<script data-stx-route-params>(function(){var p=${serializedParams};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-plugin-stx",
3
3
  "type": "module",
4
- "version": "0.2.217",
4
+ "version": "0.2.219",
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",