bun-plugin-stx 0.2.175 → 0.2.177

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
@@ -190,6 +190,7 @@ export declare interface ServeRequestContext {
190
190
  request?: Request
191
191
  responseStatus?: number
192
192
  actionRedirect?: string
193
+ actionCookies?: string[]
193
194
  [key: string]: unknown
194
195
  }
195
196
  export declare interface ServeOptions {
package/dist/serve.js CHANGED
@@ -8721,7 +8721,7 @@ var defaultGeneratedDir4 = /* @__PURE__ */ resolve12(process20.cwd(), "src/gener
8721
8721
  import { BUILD_ID_HEADER, extractPageResponseStatus, findContainerRegion, getBuildId, mergeCrosswindConfig, 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
- import { compressResponse, runPageAction as sharedRunPageAction } from "@stacksjs/stx";
8724
+ import { actionRedirectResponse, compressResponse, runPageAction as sharedRunPageAction } from "@stacksjs/stx";
8725
8725
  var defaultStxModule = import("@stacksjs/stx");
8726
8726
  var REACTIVE_TEMPLATE_DIRECTIVE_RE = /@for|:for|@if|:if|@else|:else|x-for|x-if|x-else/;
8727
8727
  function extractServerScriptsFromTemplate(content) {
@@ -9667,7 +9667,7 @@ function __stxOverlay(errs){
9667
9667
  const userConfig = await crosswindUserConfigPromise;
9668
9668
  const merged = mergeCrosswindConfig(cw.config, userConfig);
9669
9669
  const generatorConfig = merged.config;
9670
- const { includePreflight, minify } = merged;
9670
+ const { includePreflight, minify, tokenCSS } = merged;
9671
9671
  for (const cls of merged.safelist)
9672
9672
  classes.add(cls);
9673
9673
  const cacheKey = [...classes].sort().join(" ");
@@ -9714,7 +9714,7 @@ function __stxOverlay(errs){
9714
9714
  shortcutCSS += `@media (prefers-color-scheme: dark) { .dark .${name} { ${darkDecls.join(" ")} } }
9715
9715
  `;
9716
9716
  }
9717
- const finalCss = baseCss + shortcutCSS;
9717
+ const finalCss = tokenCSS + baseCss + shortcutCSS;
9718
9718
  crosswindCssCache.set(cacheKey, finalCss);
9719
9719
  return finalCss;
9720
9720
  } catch (error) {
@@ -9733,6 +9733,8 @@ function __stxOverlay(errs){
9733
9733
  });
9734
9734
  if (result.redirect)
9735
9735
  reqCtx.actionRedirect = result.redirect;
9736
+ if (result.cookies && result.cookies.length > 0)
9737
+ reqCtx.actionCookies = result.cookies;
9736
9738
  }
9737
9739
  async function processTemplate(filePath, reqCtx) {
9738
9740
  const content = await Bun.file(filePath).text();
@@ -10437,10 +10439,10 @@ ${html}`;
10437
10439
  }
10438
10440
  const content = await getRoute(path, reqCtx);
10439
10441
  if (reqCtx.actionRedirect) {
10440
- return new Response(null, {
10441
- status: 303,
10442
- headers: { ...corsHeaders, Location: reqCtx.actionRedirect }
10443
- });
10442
+ const redirectResponse = actionRedirectResponse(reqCtx.actionRedirect, reqCtx.actionCookies);
10443
+ for (const [key, value] of Object.entries(corsHeaders))
10444
+ redirectResponse.headers.set(key, value);
10445
+ return redirectResponse;
10444
10446
  }
10445
10447
  if (content) {
10446
10448
  const responseStatus = reqCtx.responseStatus ?? 200;
@@ -10591,13 +10593,16 @@ ${trailingPageScripts.join(`
10591
10593
  } catch {}
10592
10594
  }
10593
10595
  }
10596
+ const pageHeaders = new Headers({
10597
+ "Content-Type": "text/html; charset=utf-8",
10598
+ "Cache-Control": "no-store",
10599
+ ...corsHeaders
10600
+ });
10601
+ for (const cookie of reqCtx.actionCookies ?? [])
10602
+ pageHeaders.append("Set-Cookie", cookie);
10594
10603
  return new Response(injectHmrClient(cleaned), {
10595
10604
  status: pageRenderFailed ? 500 : responseStatus,
10596
- headers: {
10597
- "Content-Type": "text/html; charset=utf-8",
10598
- "Cache-Control": "no-store",
10599
- ...corsHeaders
10600
- }
10605
+ headers: pageHeaders
10601
10606
  });
10602
10607
  }
10603
10608
  if (!isStaticAssetPath(path)) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-plugin-stx",
3
3
  "type": "module",
4
- "version": "0.2.175",
4
+ "version": "0.2.177",
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",