@timber-js/app 0.2.0-alpha.210 → 0.2.0-alpha.212

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 (158) hide show
  1. package/agent-skill.md +10 -5
  2. package/dist/_chunks/{actions-Rjk4htmA.js → actions-CCdnVtWm.js} +8 -6
  3. package/dist/_chunks/actions-CCdnVtWm.js.map +1 -0
  4. package/dist/_chunks/{als-registry-DaxkVjt5.js → als-registry-BZqHCtq-.js} +2 -4
  5. package/dist/_chunks/als-registry-BZqHCtq-.js.map +1 -0
  6. package/dist/_chunks/{cache-api-DGdYfNJn.js → cache-api-LA3sBpUS.js} +5 -5
  7. package/dist/_chunks/{cache-api-DGdYfNJn.js.map → cache-api-LA3sBpUS.js.map} +1 -1
  8. package/dist/_chunks/{chains-BoO51joc.js → chains-BfoPFraI.js} +5 -146
  9. package/dist/_chunks/chains-BfoPFraI.js.map +1 -0
  10. package/dist/_chunks/classify-BT66U83D.js +147 -0
  11. package/dist/_chunks/classify-BT66U83D.js.map +1 -0
  12. package/dist/_chunks/{cli-check-ajNY3B2e.js → cli-check-BfQ54-UJ.js} +3 -3
  13. package/dist/_chunks/{cli-check-ajNY3B2e.js.map → cli-check-BfQ54-UJ.js.map} +1 -1
  14. package/dist/_chunks/{cli-schema-sync-D2eI8jEg.js → cli-schema-sync-czh2dsLs.js} +2 -2
  15. package/dist/_chunks/{cli-schema-sync-D2eI8jEg.js.map → cli-schema-sync-czh2dsLs.js.map} +1 -1
  16. package/dist/_chunks/client-dep-entries-CQwpb8dI.js +66 -0
  17. package/dist/_chunks/client-dep-entries-CQwpb8dI.js.map +1 -0
  18. package/dist/_chunks/{convention-lint-DLmhGsRS.js → convention-lint-BEVW4EID.js} +3 -3
  19. package/dist/_chunks/{convention-lint-DLmhGsRS.js.map → convention-lint-BEVW4EID.js.map} +1 -1
  20. package/dist/_chunks/{dev-server-v97rQH4b.js → dev-server-FKxptbnI.js} +2 -2
  21. package/dist/_chunks/{dev-server-v97rQH4b.js.map → dev-server-FKxptbnI.js.map} +1 -1
  22. package/dist/_chunks/{json-lossy-check-CVuRs2hG.js → json-lossy-check-C8zBY2uZ.js} +2 -2
  23. package/dist/_chunks/{json-lossy-check-CVuRs2hG.js.map → json-lossy-check-C8zBY2uZ.js.map} +1 -1
  24. package/dist/_chunks/{live-graph-9cSnn_h9.js → live-graph-C_4v-fHv.js} +4 -3
  25. package/dist/_chunks/{live-graph-9cSnn_h9.js.map → live-graph-C_4v-fHv.js.map} +1 -1
  26. package/dist/_chunks/{logger-BP0LN6vP.js → logger-CbLdcy-W.js} +2 -2
  27. package/dist/_chunks/{logger-BP0LN6vP.js.map → logger-CbLdcy-W.js.map} +1 -1
  28. package/dist/_chunks/{poison-scan-vGV7Re0B.js → poison-scan-C92liMAr.js} +2 -4
  29. package/dist/_chunks/poison-scan-C92liMAr.js.map +1 -0
  30. package/dist/_chunks/{scanner-DmqdxzbW.js → scanner-CQt12vE2.js} +2 -2
  31. package/dist/_chunks/{scanner-DmqdxzbW.js.map → scanner-CQt12vE2.js.map} +1 -1
  32. package/dist/_chunks/{sizeof-BM1409x2.js → sizeof-QPE5nd3u.js} +2 -2
  33. package/dist/_chunks/{sizeof-BM1409x2.js.map → sizeof-QPE5nd3u.js.map} +1 -1
  34. package/dist/_chunks/{walkers-Czu2jXFq.js → walkers-DAT4avhZ.js} +3 -3
  35. package/dist/_chunks/{walkers-Czu2jXFq.js.map → walkers-DAT4avhZ.js.map} +1 -1
  36. package/dist/adapters/cloudflare-kv-cache.js +1 -1
  37. package/dist/analyze/classify.d.ts +2 -0
  38. package/dist/analyze/classify.d.ts.map +1 -1
  39. package/dist/analyze/crawl-entry.js +3 -2
  40. package/dist/analyze/crawl-entry.js.map +1 -1
  41. package/dist/analyze/graph-command.js +2 -2
  42. package/dist/analyze/poison-scan.d.ts.map +1 -1
  43. package/dist/cache/index.js +2 -2
  44. package/dist/cache/stores/memory.js +1 -1
  45. package/dist/cdn/workers-cache-purge.js +1 -1
  46. package/dist/cli.js +3 -3
  47. package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -1
  48. package/dist/client/browser-entry/hydrate.d.ts.map +1 -1
  49. package/dist/client/browser-entry/router-init.d.ts.map +1 -1
  50. package/dist/client/form.d.ts +17 -64
  51. package/dist/client/form.d.ts.map +1 -1
  52. package/dist/client/index.d.ts +2 -2
  53. package/dist/client/index.d.ts.map +1 -1
  54. package/dist/client/index.js +23 -51
  55. package/dist/client/index.js.map +1 -1
  56. package/dist/client/internal.js +25 -25
  57. package/dist/client/internal.js.map +1 -1
  58. package/dist/client/navigation-api.d.ts +25 -63
  59. package/dist/client/navigation-api.d.ts.map +1 -1
  60. package/dist/client/router-lifecycle.d.ts +17 -11
  61. package/dist/client/router-lifecycle.d.ts.map +1 -1
  62. package/dist/client/router-pipeline.d.ts +0 -1
  63. package/dist/client/router-pipeline.d.ts.map +1 -1
  64. package/dist/client/router-types.d.ts +14 -45
  65. package/dist/client/router-types.d.ts.map +1 -1
  66. package/dist/client/router.d.ts.map +1 -1
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +44 -7
  69. package/dist/index.js.map +1 -1
  70. package/dist/plugins/client-dep-entries.d.ts +44 -0
  71. package/dist/plugins/client-dep-entries.d.ts.map +1 -0
  72. package/dist/plugins/content.d.ts.map +1 -1
  73. package/dist/plugins/entries.d.ts +6 -0
  74. package/dist/plugins/entries.d.ts.map +1 -1
  75. package/dist/plugins/shims.d.ts.map +1 -1
  76. package/dist/routing/index.js +2 -2
  77. package/dist/rsc-runtime/rsc.d.ts +1 -1
  78. package/dist/rsc-runtime/rsc.d.ts.map +1 -1
  79. package/dist/server/action-client.d.ts +9 -5
  80. package/dist/server/action-client.d.ts.map +1 -1
  81. package/dist/server/action-handler.d.ts +27 -8
  82. package/dist/server/action-handler.d.ts.map +1 -1
  83. package/dist/server/als-registry.d.ts +22 -2
  84. package/dist/server/als-registry.d.ts.map +1 -1
  85. package/dist/server/client-error-message.d.ts +12 -0
  86. package/dist/server/client-error-message.d.ts.map +1 -0
  87. package/dist/server/form-state-embed.d.ts +32 -0
  88. package/dist/server/form-state-embed.d.ts.map +1 -0
  89. package/dist/server/index.d.ts +0 -2
  90. package/dist/server/index.d.ts.map +1 -1
  91. package/dist/server/index.js +7 -40
  92. package/dist/server/index.js.map +1 -1
  93. package/dist/server/internal.js +10 -6
  94. package/dist/server/internal.js.map +1 -1
  95. package/dist/server/logger.d.ts +1 -0
  96. package/dist/server/logger.d.ts.map +1 -1
  97. package/dist/server/pipeline.d.ts +20 -6
  98. package/dist/server/pipeline.d.ts.map +1 -1
  99. package/dist/server/request-context.d.ts +27 -2
  100. package/dist/server/request-context.d.ts.map +1 -1
  101. package/dist/server/route-element-builder.d.ts.map +1 -1
  102. package/dist/server/rsc-entry/action-dispatcher.d.ts +6 -5
  103. package/dist/server/rsc-entry/action-dispatcher.d.ts.map +1 -1
  104. package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
  105. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  106. package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
  107. package/dist/server/ssr-bridge-types.d.ts +8 -0
  108. package/dist/server/ssr-bridge-types.d.ts.map +1 -1
  109. package/dist/server/ssr-entry.d.ts.map +1 -1
  110. package/dist/server/ssr-render.d.ts +3 -0
  111. package/dist/server/ssr-render.d.ts.map +1 -1
  112. package/docs/api/31-api-client.mdx +9 -3
  113. package/docs/learn/08-forms-and-actions.mdx +21 -28
  114. package/package.json +1 -1
  115. package/src/analyze/classify.ts +1 -1
  116. package/src/analyze/poison-scan.ts +1 -4
  117. package/src/client/browser-entry/action-dispatch.ts +74 -18
  118. package/src/client/browser-entry/hydrate.ts +18 -0
  119. package/src/client/browser-entry/router-init.ts +4 -18
  120. package/src/client/form.tsx +33 -98
  121. package/src/client/index.ts +2 -2
  122. package/src/client/navigation-api.ts +47 -173
  123. package/src/client/navigation-transition.ts +2 -2
  124. package/src/client/router-lifecycle.ts +40 -20
  125. package/src/client/router-pipeline.ts +3 -9
  126. package/src/client/router-types.ts +14 -49
  127. package/src/client/router.ts +38 -58
  128. package/src/index.ts +21 -2
  129. package/src/plugins/client-dep-entries.ts +78 -0
  130. package/src/plugins/content.ts +26 -1
  131. package/src/plugins/entries.ts +7 -0
  132. package/src/plugins/shims.ts +0 -2
  133. package/src/rsc-runtime/rsc.ts +3 -0
  134. package/src/rsc-runtime/vendor-types.d.ts +14 -0
  135. package/src/server/action-client.ts +18 -20
  136. package/src/server/action-handler.ts +133 -95
  137. package/src/server/als-registry.ts +23 -9
  138. package/src/server/client-error-message.ts +18 -0
  139. package/src/server/form-state-embed.ts +63 -0
  140. package/src/server/index.ts +0 -4
  141. package/src/server/logger.ts +6 -1
  142. package/src/server/pipeline.ts +27 -8
  143. package/src/server/request-context.ts +39 -2
  144. package/src/server/route-element-builder.ts +12 -1
  145. package/src/server/rsc-entry/action-dispatcher.ts +37 -34
  146. package/src/server/rsc-entry/error-renderer.ts +2 -1
  147. package/src/server/rsc-entry/rsc-stream.ts +20 -11
  148. package/src/server/rsc-entry/ssr-renderer.ts +14 -1
  149. package/src/server/ssr-bridge-types.ts +9 -0
  150. package/src/server/ssr-entry.ts +1 -0
  151. package/src/server/ssr-render.ts +5 -0
  152. package/dist/_chunks/actions-Rjk4htmA.js.map +0 -1
  153. package/dist/_chunks/als-registry-DaxkVjt5.js.map +0 -1
  154. package/dist/_chunks/chains-BoO51joc.js.map +0 -1
  155. package/dist/_chunks/poison-scan-vGV7Re0B.js.map +0 -1
  156. package/dist/server/form-flash.d.ts +0 -78
  157. package/dist/server/form-flash.d.ts.map +0 -1
  158. package/src/server/form-flash.ts +0 -89
@@ -0,0 +1,44 @@
1
+ /**
2
+ * client-dep-entries — seed the client dep optimizer's startup scan with
3
+ * the app's `'use client'` modules.
4
+ *
5
+ * Vite's dev optimizer discovers bare imports by crawling from its
6
+ * entries before the first request. With no `optimizeDeps.entries`, the
7
+ * client environment crawls its build input — timber's browser entry —
8
+ * and nothing more: every `'use client'` module is reached only through
9
+ * the RSC payload at runtime, never through a static import the crawl
10
+ * can follow. A package imported only from client components is then
11
+ * found on the first browser request, re-optimized mid-load, and the
12
+ * page full-reloads ("optimized dependencies changed. reloading"). That
13
+ * reload can leave react and react-dom from two optimizer runs in the
14
+ * browser (duplicate React → "Invalid hook call").
15
+ *
16
+ * Listing the `'use client'` files as entries lets the startup crawl see
17
+ * those imports. Setting `entries` replaces the build-input default, so
18
+ * the browser entry is listed too. Files that gain the directive after
19
+ * startup still fall back to Vite's late discovery.
20
+ *
21
+ * Design docs: 21-dev-server.md §"Client Dependency Pre-Bundling".
22
+ */
23
+ /**
24
+ * Every project source file under `root` whose directive prologue holds
25
+ * `'use client'`. Uses the same walker as `timber graph` (node_modules,
26
+ * root-level dot dirs and build outputs skipped) and the same AST
27
+ * directive check the RSC plugin applies. Files under `excludeDir` (the
28
+ * build output) are skipped.
29
+ */
30
+ export declare function findUseClientFiles(root: string, excludeDir?: string): Promise<string[]>;
31
+ /**
32
+ * Escape a path for use as an `optimizeDeps.entries` pattern. Vite globs
33
+ * entries, and route directories are full of glob syntax: `(group)`,
34
+ * `[slug]`, `[[...catchAll]]`, `@slot`. Slashes are normalized first, so
35
+ * the only backslashes left are literal (POSIX) ones, which are escaped
36
+ * too.
37
+ */
38
+ export declare function escapeGlobPath(path: string): string;
39
+ /**
40
+ * The client environment's `optimizeDeps.entries`: timber's browser
41
+ * entry plus every `'use client'` file in the project.
42
+ */
43
+ export declare function clientOptimizeDepsEntries(root: string, browserEntryFile: string, buildDir: string): Promise<string[]>;
44
+ //# sourceMappingURL=client-dep-entries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-dep-entries.d.ts","sourceRoot":"","sources":["../../src/plugins/client-dep-entries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAkB7F;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,EAAE,CAAC,CAGnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/plugins/content.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAoB1D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAoGxD"}
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/plugins/content.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAgB,MAAM,MAAM,CAAC;AAGjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAyC1D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAwGxD"}
@@ -12,6 +12,12 @@
12
12
  */
13
13
  import type { Plugin } from 'vite';
14
14
  import type { PluginContext } from '../plugin-context.ts';
15
+ /**
16
+ * The real file behind virtual:timber-browser-entry. The client dep
17
+ * optimizer scans it explicitly once timber sets optimizeDeps.entries
18
+ * (see plugins/client-dep-entries.ts).
19
+ */
20
+ export declare const BROWSER_ENTRY_FILE: string;
15
21
  /**
16
22
  * Detect a user convention file at both root and src/.
17
23
  *
@@ -1 +1 @@
1
- {"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../src/plugins/entries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAInC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAuK1D;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUlF;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAErE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAAC,mBAAmB,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAqBxF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CA+B3E;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAiFxD"}
1
+ {"version":3,"file":"entries.d.ts","sourceRoot":"","sources":["../../src/plugins/entries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAInC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAsC1D;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAA2C,CAAC;AAmI3E;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUlF;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAErE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAAC,mBAAmB,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAqBxF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CA+B3E;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAiFxD"}
@@ -1 +1 @@
1
- {"version":3,"file":"shims.d.ts","sourceRoot":"","sources":["../../src/plugins/shims.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAsB1D;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsBlD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EA6BhD,CAAC;AA2CF;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAoOvD"}
1
+ {"version":3,"file":"shims.d.ts","sourceRoot":"","sources":["../../src/plugins/shims.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAsB1D;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsBlD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EA2BhD,CAAC;AA2CF;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAoOvD"}
@@ -1,5 +1,5 @@
1
1
  import { a as INTERCEPTION_MARKERS, i as DEFAULT_PAGE_EXTENSIONS, n as classifyUrlSegment, t as classifySegment } from "../_chunks/segment-classify-C539Pa2O.js";
2
- import { d as collectInterceptionRewrites, n as scanRoutes } from "../_chunks/scanner-DmqdxzbW.js";
2
+ import { d as collectInterceptionRewrites, n as scanRoutes } from "../_chunks/scanner-CQt12vE2.js";
3
3
  import { t as generateRouteMap } from "../_chunks/codegen-Bps1sLKJ.js";
4
- import { n as collectDynamicSegmentsFromTree, r as validateSchemaAgainstRoutes, t as collectLeafRoutes } from "../_chunks/walkers-Czu2jXFq.js";
4
+ import { n as collectDynamicSegmentsFromTree, r as validateSchemaAgainstRoutes, t as collectLeafRoutes } from "../_chunks/walkers-DAT4avhZ.js";
5
5
  export { DEFAULT_PAGE_EXTENSIONS, INTERCEPTION_MARKERS, classifySegment, classifyUrlSegment, collectDynamicSegmentsFromTree, collectInterceptionRewrites, collectLeafRoutes, generateRouteMap, scanRoutes, validateSchemaAgainstRoutes };
@@ -10,5 +10,5 @@
10
10
  * Keep this as thin pass-through re-exports — the value is the single choke
11
11
  * point, not abstraction.
12
12
  */
13
- export { renderToReadableStream, loadServerAction, decodeReply, decodeAction, encryptActionBoundArgs, decryptActionBoundArgs, createFromReadableStream, } from '@vitejs/plugin-rsc/rsc';
13
+ export { renderToReadableStream, loadServerAction, decodeReply, decodeAction, decodeFormState, encryptActionBoundArgs, decryptActionBoundArgs, createFromReadableStream, } from '@vitejs/plugin-rsc/rsc';
14
14
  //# sourceMappingURL=rsc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rsc.d.ts","sourceRoot":"","sources":["../../src/rsc-runtime/rsc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,EAOtB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"rsc.d.ts","sourceRoot":"","sources":["../../src/rsc-runtime/rsc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,EACX,YAAY,EAGZ,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EAOtB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC"}
@@ -139,7 +139,8 @@ export interface ActionBuilderWithSchema<TCtx, TInput> {
139
139
  /**
140
140
  * The final action function. Callable three ways:
141
141
  * - Direct: action(input) → Promise<ActionResult<TData>>
142
- * - React useActionState: action(prevState, formData) → Promise<ActionResult<TData>>
142
+ * - React useActionState: action(prevState, payload) → Promise<ActionResult<TData>>,
143
+ * where payload is the submitted FormData or the value dispatch was called with
143
144
  * - React <form action={fn}>: action(formData) → void (return value ignored by React)
144
145
  *
145
146
  * The third overload exists purely for type compatibility with React's
@@ -169,16 +170,19 @@ export type ActionFn<TData = unknown, TInput = unknown> = {
169
170
  (formData: FormData): void;
170
171
  /** Direct call: action(input) — optional when TInput is undefined/unknown (no-schema actions). */
171
172
  (...args: undefined extends TInput ? [input?: TInput] : [input: TInput]): Promise<ActionResult<TData>>;
172
- /** React useActionState: action(prevState, formData) */
173
- (prevState: ActionResult<TData> | null, formData: FormData): Promise<ActionResult<TData>>;
173
+ /**
174
+ * React useActionState: action(prevState, payload). The payload is the
175
+ * submitted FormData, or whatever the hook's dispatch was called with.
176
+ */
177
+ (prevState: ActionResult<TData> | null, payload: TInput | FormData): Promise<ActionResult<TData>>;
174
178
  };
175
179
  import { type SensitiveFieldsOption } from './sensitive-fields.ts';
176
180
  /**
177
181
  * Wrap unexpected errors into a safe server error result.
178
182
  * ActionError → typed result. Other errors → INTERNAL_ERROR (no leak).
179
183
  *
180
- * Exported for use by action-handler.ts to catch errors from raw 'use server'
181
- * functions that don't use createActionClient.
184
+ * `createActionClient` actions only. A raw `'use server'` function that
185
+ * throws is rejected on the client instead (action-handler.ts).
182
186
  */
183
187
  export declare function handleActionError(error: unknown): ActionResult<never>;
184
188
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"action-client.d.ts","sourceRoot":"","sources":["../../src/server/action-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH;;;;;;;GAOG;AACH,qBAAa,WAAW,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,KAAK;IACnE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAEnD,YAAY,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAKtD;CACF;AAID;;;;;;;GAOG;AACH,UAAU,gBAAgB,CAAC,MAAM,GAAG,OAAO;IACzC,QAAQ,CAAC,WAAW,EAAE;QACpB,QAAQ,CAAC,QAAQ,EAAE,CACjB,KAAK,EAAE,OAAO,KACX,oBAAoB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC;KAC3E,CAAC;CACH;AAED,KAAK,oBAAoB,CAAC,MAAM,IAC5B;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,SAAS,CAAA;CAAE,GACrC;IAAE,KAAK,CAAC,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAA;CAAE,CAAC;AAEtE,UAAU,mBAAmB;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,aAAa,CAAC,WAAW,GAAG;QAAE,GAAG,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;CAC1D;AAcD;;;;;;;;;GASG;AACH,MAAM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C3B,MAAM,uBAAuB,CAAC;AA8C/B;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAAC,KAAK,CAAC,CAqBrE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC7D,MAAM,GAAE,kBAAkB,CAAC,IAAI,CAAM,GACpC,aAAa,CAAC,IAAI,CAAC,CA6HrB;AAID;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,KAAK,EACrC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,EAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,CAAC,GACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAIzB"}
@@ -8,7 +8,8 @@
8
8
  * 1. Detect action request (POST with `x-rsc-action` header or form action fields)
9
9
  * 2. CSRF validation
10
10
  * 3. Load and execute the server action
11
- * 4. Return RSC stream (with-JS) or 302 redirect (no-JS)
11
+ * 4. Return RSC stream (with-JS), or on the no-JS path a redirect, a page
12
+ * rerender carrying React's form state, or the error page
12
13
  *
13
14
  * See design/08-forms-and-actions.md
14
15
  */
@@ -16,7 +17,7 @@ import { type CsrfConfig } from './csrf.ts';
16
17
  import { type RevalidateRenderer } from './actions.ts';
17
18
  import { type BodyLimitsConfig } from './body-limits.ts';
18
19
  import { type SensitiveFieldsOption } from './sensitive-fields.ts';
19
- import type { FormFlashData } from './form-flash.ts';
20
+ import type { ReactFormState } from 'react-dom/client';
20
21
  /** Configuration for the action handler. */
21
22
  export interface ActionDispatchConfig {
22
23
  /** CSRF configuration. */
@@ -48,7 +49,18 @@ export interface ActionDispatchConfig {
48
49
  */
49
50
  export declare function isActionRequest(req: Request): boolean;
50
51
  /**
51
- * Signal from handleFormAction to re-render the page with flash data instead of redirecting.
52
+ * How a no-JS action that did not redirect is answered. The dispatcher
53
+ * (`rsc-entry/action-dispatcher.ts`) turns it into the response:
54
+ *
55
+ * - `rerender`: the action returned. The page is rendered again as a GET,
56
+ * with `formState` — React's `decodeFormState` of the result, present
57
+ * only when the submitted form used `useActionState` — handed to SSR
58
+ * and hydration, where React gives it to the hook that submitted.
59
+ * - `error`: the action threw. The page is rendered again with the error
60
+ * in place of the page component, so the route's nearest error page
61
+ * answers, with the
62
+ * status the pipeline gives any unhandled error. The JS path rejects
63
+ * the action for the same throw, so both reach an error boundary.
52
64
  *
53
65
  * Carries two cookie-related snapshots taken before the action's ALS scope
54
66
  * exits, so the rerender pipeline (which establishes its own fresh cookie
@@ -68,16 +80,23 @@ export declare function isActionRequest(req: Request): boolean;
68
80
  * previous `cookieHeader: string` shape carried — see
69
81
  * ONGOING_SECURITY.md H-3 (TIM-868) and TIM-837.
70
82
  */
71
- export interface FormRerender {
72
- rerender: FormFlashData;
83
+ export type FormActionOutcome = {
84
+ kind: 'rerender';
85
+ formState: ReactFormState | undefined;
73
86
  setCookieHeaders: string[];
74
87
  cookies: Map<string, string>;
75
- }
88
+ } | {
89
+ kind: 'error';
90
+ error: unknown;
91
+ errorId: string;
92
+ setCookieHeaders: string[];
93
+ cookies: Map<string, string>;
94
+ };
76
95
  /**
77
96
  * Handle a server action request.
78
97
  *
79
- * Returns a Response, a FormRerender signal (for no-JS validation failure re-render),
98
+ * Returns a Response, a FormActionOutcome (no-JS action that did not redirect),
80
99
  * or null if this isn't actually an action request (e.g., a regular form POST to an API route).
81
100
  */
82
- export declare function handleActionRequest(req: Request, config: ActionDispatchConfig): Promise<Response | FormRerender | null>;
101
+ export declare function handleActionRequest(req: Request, config: ActionDispatchConfig): Promise<Response | FormActionOutcome | null>;
83
102
  //# sourceMappingURL=action-handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"action-handler.d.ts","sourceRoot":"","sources":["../../src/server/action-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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EAAwC,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,EAKL,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAYvD,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;IACH,eAAe,CAAC,EAAE,qBAAqB,CAAC;CACzC;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAarD;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,MAAM,iBAAiB,GACzB;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,SAAS,EAAE,cAAc,GAAG,SAAS,CAAC;IACtC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B,CAAC;AAON;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,QAAQ,GAAG,iBAAiB,GAAG,IAAI,CAAC,CAoF9C"}
@@ -34,8 +34,14 @@ import '#server-only-guard';
34
34
  import type { CoercedParams } from '../shared/param-value.ts';
35
35
  import type { SlotParamsRecord } from '../shared/slot-params.ts';
36
36
  import { AsyncLocalStorage } from 'node:async_hooks';
37
+ import type { ReactFormState } from 'react-dom/client';
37
38
  /** @internal — import via request-context.ts public API */
38
39
  export declare const requestContextAls: AsyncLocalStorage<RequestContextStore>;
40
+ /** A no-JS action's thrown error, and the correlation ID it was logged with. */
41
+ export interface ActionErrorForRender {
42
+ error: unknown;
43
+ errorId: string;
44
+ }
39
45
  export interface RequestContextStore {
40
46
  /**
41
47
  * The request this context was opened for, or `null` in the build-time
@@ -105,6 +111,22 @@ export interface RequestContextStore {
105
111
  flushed: boolean;
106
112
  /** Whether the current context allows cookie mutation. */
107
113
  mutableContext: boolean;
114
+ /**
115
+ * The form state a no-JS action produced (`decodeFormState`), set only on
116
+ * the page render that answers it. Read once, by the SSR renderer, which
117
+ * hands it to Fizz and embeds it for `hydrateRoot`; no user-facing API
118
+ * reads it, because a server component cannot see an action's result on
119
+ * the JS path either (design/08 §"No-JS Result Round-Trip").
120
+ */
121
+ formState?: ReactFormState;
122
+ /**
123
+ * The error a no-JS action threw, set only on the page render that answers
124
+ * it. The route renders it where its page would be, so the nearest error
125
+ * page answers, as the nearest error boundary does with JS. Read by the
126
+ * route element builder and the Flight `onError`; no user-facing API reads
127
+ * it (design/08 §"The Basic Wire-Up").
128
+ */
129
+ actionError?: ActionErrorForRender;
108
130
  /**
109
131
  * Set by AccessGate or PageDenyBoundary when a DenySignal is caught
110
132
  * server-side (inside the React tree, before React Flight sees it).
@@ -187,8 +209,6 @@ export interface RevalidationState {
187
209
  }
188
210
  /** @internal — import via actions.ts public API */
189
211
  export declare const revalidationAls: AsyncLocalStorage<RevalidationState>;
190
- /** @internal — import via form-flash.ts public API */
191
- export declare const formFlashAls: AsyncLocalStorage<import("./form-flash.ts").FormFlashData>;
192
212
  /** Function that sends Link header values as a 103 Early Hints response. */
193
213
  export type EarlyHintsSenderFn = (links: string[]) => void;
194
214
  /** @internal — import via early-hints-sender.ts public API */
@@ -1 +1 @@
1
- {"version":3,"file":"als-registry.d.ts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,KAAK,IAAI,CAAC;AAE9D,4DAA4D;AAC5D,eAAO,MAAM,YAAY,gCAAmE,CAAC;AAM7F,2EAA2E;AAC3E,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAED,gEAAgE;AAChE,eAAO,MAAM,oBAAoB,yCAEhC,CAAC;AAOF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,GAAG,CAAC,MAAM,OAAO,EAAE,OAAO,CAAC,CAAC;AAE1D,8DAA8D;AAC9D,eAAO,MAAM,kBAAkB,oCAE9B,CAAC;AAMF;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,6EAA6E;IAC7E,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,6BAA6B,EAAE,YAAY,CAAC,CAAC;CACzE;AAED,uDAAuD;AACvD,eAAO,MAAM,kBAAkB,yCAE9B,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The message an unexpected server error shows the client: its own message
3
+ * in dev, a fixed one in production (design/13-security.md §"Errors don't
4
+ * leak"). One definition for every place an error crosses to the client —
5
+ * a Flight error row's digest, a rejected action, an error page's error.
6
+ *
7
+ * Uses isDevMode(), not isDebug(): the text reaches the browser, and
8
+ * TIMBER_DEBUG must never make it leak.
9
+ */
10
+ export declare const PRODUCTION_ERROR_MESSAGE = "An unexpected error occurred.";
11
+ export declare function clientErrorMessage(error: unknown): string;
12
+ //# sourceMappingURL=client-error-message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-error-message.d.ts","sourceRoot":"","sources":["../../src/server/client-error-message.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AAExE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAGzD"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The no-JS action form state a page render hands React (TIM-1570).
3
+ *
4
+ * Fizz renders the `useActionState` hook that submitted with the action's
5
+ * result, and the browser must hydrate with the same value, or the hook
6
+ * resets. The browser's copy is embedded as JSON, as Next.js embeds it
7
+ * (`self.__timber_form_state`, read by client/browser-entry/hydrate.ts).
8
+ *
9
+ * Both renders must get the same value, or the hook's state changes during
10
+ * hydration. JSON is lossy (a `Date` becomes a string, a `Map` `{}`, an
11
+ * `undefined` field — `{ data: undefined }` from every void action — is
12
+ * dropped), so Fizz gets the JSON round-trip of the state, not the original:
13
+ * exactly what the browser decodes. On the no-JS path a result is what JSON
14
+ * carries. A state JSON cannot encode at all (a `BigInt`, a cycle) must not
15
+ * turn the page into a 500 after the action's mutation committed, so it is
16
+ * dropped from both renders: the page renders with no result, as for a form
17
+ * without `useActionState`.
18
+ *
19
+ * With client JS disabled nothing is embedded and nothing hydrates, so Fizz
20
+ * gets the original.
21
+ *
22
+ * See design/08-forms-and-actions.md §"No-JS Result Round-Trip".
23
+ */
24
+ import type { ReactFormState } from 'react-dom/client';
25
+ export interface FormStateForRender {
26
+ /** For Fizz — the same value the embedded script hands `hydrateRoot`. */
27
+ formState: ReactFormState | undefined;
28
+ /** The `<script>` that embeds it for hydration, or `''`. */
29
+ script: string;
30
+ }
31
+ export declare function formStateForRender(formState: ReactFormState | null, clientJsDisabled: boolean, nonce: string | undefined): FormStateForRender;
32
+ //# sourceMappingURL=form-state-embed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-state-embed.d.ts","sourceRoot":"","sources":["../../src/server/form-state-embed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,MAAM,WAAW,kBAAkB;IACjC,yEAAyE;IACzE,SAAS,EAAE,cAAc,GAAG,SAAS,CAAC;IACtC,4DAA4D;IAC5D,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,cAAc,GAAG,IAAI,EAChC,gBAAgB,EAAE,OAAO,EACzB,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,kBAAkB,CAsBpB"}
@@ -10,8 +10,6 @@ export { deny, redirect, redirectExternal, RedirectType, waitUntil, type DenyOpt
10
10
  export { createActionClient, ActionError, validated } from './action-client.ts';
11
11
  export type { ActionResult, ActionFn, ActionBuilder, ActionBuilderWithSchema, ActionContext, ActionMiddleware, ActionSchema, ValidationErrors, } from './action-client.ts';
12
12
  export { coerce, parseFormData } from './form-data.ts';
13
- export { getFormFlash } from './form-flash.ts';
14
- export type { FormFlashData } from './form-flash.ts';
15
13
  export { revalidatePath, revalidateTag } from './actions.ts';
16
14
  export { getTraceId, getSpanId, withSpan, addSpanEvent } from './tracing.ts';
17
15
  export type { CoercedParamValue, CoercedParams } from '../shared/param-value.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAMA,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAK3F,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACpE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAI5D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,qBAAq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,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAG3F,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,KAAK,WAAW,EAChB,KAAK,eAAe,GACrB,MAAM,iBAAiB,CAAC;AAKzB,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAChF,YAAY,EACV,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,uBAAuB,EACvB,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAI7E,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1,7 +1,6 @@
1
- import { n as formFlashAls } from "../_chunks/als-registry-DaxkVjt5.js";
2
- import { A as getSpanId, C as isRedirectSignal, E as addSpanEvent, F as withSpan, S as isDenySignal, T as isDevMode, j as getTraceId, w as isDebug } from "../_chunks/logger-BP0LN6vP.js";
1
+ import { A as getSpanId, C as isRedirectSignal, E as addSpanEvent, F as withSpan, S as isDenySignal, T as isDevMode, j as getTraceId, w as isDebug } from "../_chunks/logger-CbLdcy-W.js";
3
2
  import { t as formatSize } from "../_chunks/format-BKclgVbk.js";
4
- import { _ as getHeaders, a as parseFormData, c as deny, d as waitUntil, i as coerce, l as redirect, n as revalidatePath, p as getCookieJar, r as revalidateTag, u as redirectExternal, y as getSegmentParams } from "../_chunks/actions-Rjk4htmA.js";
3
+ import { _ as getHeaders, a as parseFormData, c as deny, d as waitUntil, i as coerce, l as redirect, n as revalidatePath, p as getCookieJar, r as revalidateTag, u as redirectExternal, y as getSegmentParams } from "../_chunks/actions-CCdnVtWm.js";
5
4
  //#region src/shared/redirect-type.ts
6
5
  /**
7
6
  * Next.js redirect type discriminator.
@@ -253,8 +252,8 @@ function extractStandardSchemaErrors(issues) {
253
252
  * Wrap unexpected errors into a safe server error result.
254
253
  * ActionError → typed result. Other errors → INTERNAL_ERROR (no leak).
255
254
  *
256
- * Exported for use by action-handler.ts to catch errors from raw 'use server'
257
- * functions that don't use createActionClient.
255
+ * `createActionClient` actions only. A raw `'use server'` function that
256
+ * throws is rejected on the client instead (action-handler.ts).
258
257
  */
259
258
  function handleActionError(error) {
260
259
  if (error instanceof ActionError) return { serverError: {
@@ -291,10 +290,8 @@ function createActionClient(config = {}) {
291
290
  async function actionHandler(...args) {
292
291
  try {
293
292
  const ctx = await runActionMiddleware(config.middleware);
294
- let rawInput;
295
- if (args.length === 2 && args[1] instanceof FormData) rawInput = schema ? parseFormData(args[1]) : args[1];
296
- else if (args.length === 1 && args[0] instanceof FormData) rawInput = schema ? parseFormData(args[0]) : args[0];
297
- else rawInput = args[0];
293
+ const last = args.at(-1);
294
+ const rawInput = schema && last instanceof FormData ? parseFormData(last) : last;
298
295
  const sensitivePredicate = resolveSensitivePredicate(config.stripSensitiveFields, void 0);
299
296
  const buildSubmittedValues = () => {
300
297
  const withoutFiles = stripFiles(rawInput);
@@ -438,36 +435,6 @@ function stripFiles(value) {
438
435
  return result;
439
436
  }
440
437
  //#endregion
441
- //#region src/server/form-flash.ts
442
- /**
443
- * Read the form flash data for the current request.
444
- *
445
- * Returns `null` if no flash data is present (i.e., this is a normal page
446
- * render, not a re-render after a no-JS form submission).
447
- *
448
- * Pass the flash as the initial state to `useActionState` so the form
449
- * component has a single source of truth for both with-JS and no-JS paths:
450
- *
451
- * ```tsx
452
- * // app/contact/page.tsx (server component)
453
- * import { getFormFlash } from '@timber-js/app/server'
454
- *
455
- * export default function ContactPage() {
456
- * const flash = getFormFlash()
457
- * return <ContactForm flash={flash} />
458
- * }
459
- *
460
- * // app/contact/form.tsx (client component)
461
- * export function ContactForm({ flash }) {
462
- * const [result, action, isPending] = useActionState(submitContact, flash)
463
- * // result is the single source of truth — flash seeds it on no-JS
464
- * }
465
- * ```
466
- */
467
- function getFormFlash() {
468
- return formFlashAls.getStore() ?? null;
469
- }
470
- //#endregion
471
- export { ActionError, RedirectType, addSpanEvent, coerce, createActionClient, deny, getCookieJar, getFormFlash, getHeaders, getSegmentParams, getSpanId, getTraceId, parseFormData, redirect, redirectExternal, revalidatePath, revalidateTag, validated, waitUntil, withSpan };
438
+ export { ActionError, RedirectType, addSpanEvent, coerce, createActionClient, deny, getCookieJar, getHeaders, getSegmentParams, getSpanId, getTraceId, parseFormData, redirect, redirectExternal, revalidatePath, revalidateTag, validated, waitUntil, withSpan };
472
439
 
473
440
  //# sourceMappingURL=index.js.map