@timber-js/app 0.2.0-alpha.92 → 0.2.0-alpha.93

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.
@@ -41,9 +41,18 @@ export interface ActionDispatchConfig {
41
41
  * (React's progressive enhancement hidden fields)
42
42
  */
43
43
  export declare function isActionRequest(req: Request): boolean;
44
- /** Signal from handleFormAction to re-render the page with flash data instead of redirecting. */
44
+ /**
45
+ * Signal from handleFormAction to re-render the page with flash data instead of redirecting.
46
+ *
47
+ * Carries `setCookieHeaders` snapshotted from the action's request-context ALS
48
+ * scope so the rerender pipeline (which establishes its own fresh cookie jar)
49
+ * can append them to the final HTML response. Without this, cookies set inside
50
+ * the action via `defineCookie().setCookie()` are silently dropped on the
51
+ * no-JS validation-failure path. See LOCAL-740.
52
+ */
45
53
  export interface FormRerender {
46
54
  rerender: FormFlashData;
55
+ setCookieHeaders: string[];
47
56
  }
48
57
  /**
49
58
  * Handle a server action request.
@@ -1 +1 @@
1
- {"version":3,"file":"action-handler.d.ts","sourceRoot":"","sources":["../../src/server/action-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AASH,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAOtE,OAAO,EAAwC,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE/F,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMrD,4CAA4C;AAC5C,MAAM,WAAW,oBAAoB;IACnC,0BAA0B;IAC1B,IAAI,EAAE,UAAU,CAAC;IACjB,kEAAkE;IAClE,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,gDAAgD;IAChD,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B;;;;OAIG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BAAsB,mBAAmB,CACvC,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,QAAQ,GAAG,YAAY,GAAG,IAAI,CAAC,CAgEzC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/rsc-entry/index.ts"],"names":[],"mappings":"AAuBA,OAAO,uCAAuC,CAAC;AA0C/C,OAAO,EAKL,KAAK,mBAAmB,EACzB,MAAM,cAAc,CAAC;AAoCtB;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,mBAAmB,EAAE,KAAK,IAAI,GACtF,IAAI,CAEN;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,CAE5E;AAqjBD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAInE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;8BA5SrC,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;AA8ShD,wBAAiE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/rsc-entry/index.ts"],"names":[],"mappings":"AAuBA,OAAO,uCAAuC,CAAC;AA0C/C,OAAO,EAKL,KAAK,mBAAmB,EACzB,MAAM,cAAc,CAAC;AAoCtB;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,mBAAmB,EAAE,KAAK,IAAI,GACtF,IAAI,CAEN;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,CAE5E;AA4jBD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAInE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;8BAnTrC,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;AAqThD,wBAAiE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timber-js/app",
3
- "version": "0.2.0-alpha.92",
3
+ "version": "0.2.0-alpha.93",
4
4
  "description": "Vite-native React framework built for Servers and Serverless Platforms — correct HTTP semantics, real status codes, pages that work without JavaScript",
5
5
  "keywords": [
6
6
  "cloudflare-workers",
@@ -89,9 +89,18 @@ export function isActionRequest(req: Request): boolean {
89
89
 
90
90
  // ─── Handler ──────────────────────────────────────────────────────────────
91
91
 
92
- /** Signal from handleFormAction to re-render the page with flash data instead of redirecting. */
92
+ /**
93
+ * Signal from handleFormAction to re-render the page with flash data instead of redirecting.
94
+ *
95
+ * Carries `setCookieHeaders` snapshotted from the action's request-context ALS
96
+ * scope so the rerender pipeline (which establishes its own fresh cookie jar)
97
+ * can append them to the final HTML response. Without this, cookies set inside
98
+ * the action via `defineCookie().setCookie()` are silently dropped on the
99
+ * no-JS validation-failure path. See LOCAL-740.
100
+ */
93
101
  export interface FormRerender {
94
102
  rerender: FormFlashData;
103
+ setCookieHeaders: string[];
95
104
  }
96
105
 
97
106
  /**
@@ -150,11 +159,20 @@ export async function handleActionRequest(
150
159
  result = await handleFormAction(req, config);
151
160
  }
152
161
 
153
- // Apply cookie jar to action responses
162
+ // Apply cookie jar to action responses.
163
+ //
164
+ // For Response results we append Set-Cookie directly. For FormRerender
165
+ // signals we snapshot the headers here, before this ALS scope exits, so
166
+ // the caller can apply them to the rerender pipeline's response (which
167
+ // runs in its own request-context scope with a fresh cookie jar).
168
+ // See LOCAL-740 — without this snapshot, cookies set inside a no-JS
169
+ // form action that returns validation errors are silently dropped.
154
170
  if (result instanceof Response) {
155
171
  for (const value of getSetCookieHeaders()) {
156
172
  result.headers.append('Set-Cookie', value);
157
173
  }
174
+ } else if (result && 'rerender' in result) {
175
+ result.setCookieHeaders = getSetCookieHeaders();
158
176
  }
159
177
  return result;
160
178
  });
@@ -339,6 +357,8 @@ async function handleFormAction(
339
357
  ...errorResult,
340
358
  submittedValues,
341
359
  },
360
+ // Filled in by handleActionRequest before the ALS scope exits.
361
+ setCookieHeaders: [],
342
362
  };
343
363
  }
344
364
 
@@ -368,5 +388,6 @@ async function handleFormAction(
368
388
  );
369
389
  }
370
390
 
371
- return { rerender: actionResult };
391
+ // setCookieHeaders is filled in by handleActionRequest before the ALS scope exits.
392
+ return { rerender: actionResult, setCookieHeaders: [] };
372
393
  }
@@ -447,6 +447,13 @@ async function createRequestHandler(manifest: typeof routeManifest, runtimeConfi
447
447
  // Server components read it via getFormFlash() and pass it to
448
448
  // client form components as the initial useActionState value.
449
449
  const response = await runWithFormFlash(formRerender.rerender, () => pipeline(req));
450
+ // Apply Set-Cookie headers snapshotted from the action's ALS scope.
451
+ // The pipeline above runs in its own request context with a fresh
452
+ // cookie jar, so cookies set inside the action would otherwise be
453
+ // silently dropped on the no-JS rerender path. See LOCAL-740.
454
+ for (const value of formRerender.setCookieHeaders) {
455
+ response.headers.append('Set-Cookie', value);
456
+ }
450
457
  return response;
451
458
  }
452
459
  return actionResponse;