@timber-js/app 0.2.0-alpha.211 → 0.2.0-alpha.213

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 (183) hide show
  1. package/agent-skill.md +10 -5
  2. package/dist/_chunks/{actions-Rjk4htmA.js → actions-CEootpB1.js} +49 -12
  3. package/dist/_chunks/actions-CEootpB1.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-DGX9zmg9.js → chains-BfoPFraI.js} +2 -2
  9. package/dist/_chunks/{chains-DGX9zmg9.js.map → chains-BfoPFraI.js.map} +1 -1
  10. package/dist/_chunks/{classify-QwG5rxKI.js → classify-BT66U83D.js} +2 -2
  11. package/dist/_chunks/{classify-QwG5rxKI.js.map → classify-BT66U83D.js.map} +1 -1
  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-2HCF09no.js → client-dep-entries-CQwpb8dI.js} +2 -2
  17. package/dist/_chunks/{client-dep-entries-2HCF09no.js.map → client-dep-entries-CQwpb8dI.js.map} +1 -1
  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-TFpEwm3H.js → dev-server-FKxptbnI.js} +2 -2
  21. package/dist/_chunks/{dev-server-TFpEwm3H.js.map → dev-server-FKxptbnI.js.map} +1 -1
  22. package/dist/_chunks/{error-boundary-DsNScGRM.js → error-boundary-9g_Lb2na.js} +3 -3
  23. package/dist/_chunks/{error-boundary-DsNScGRM.js.map → error-boundary-9g_Lb2na.js.map} +1 -1
  24. package/dist/_chunks/{json-lossy-check-CVuRs2hG.js → json-lossy-check-C8zBY2uZ.js} +2 -2
  25. package/dist/_chunks/{json-lossy-check-CVuRs2hG.js.map → json-lossy-check-C8zBY2uZ.js.map} +1 -1
  26. package/dist/_chunks/{live-graph-cNuWMYQI.js → live-graph-C_4v-fHv.js} +4 -4
  27. package/dist/_chunks/{live-graph-cNuWMYQI.js.map → live-graph-C_4v-fHv.js.map} +1 -1
  28. package/dist/_chunks/{logger-BP0LN6vP.js → logger-CbLdcy-W.js} +2 -2
  29. package/dist/_chunks/{logger-BP0LN6vP.js.map → logger-CbLdcy-W.js.map} +1 -1
  30. package/dist/_chunks/{poison-scan-CfQ3unZR.js → poison-scan-C92liMAr.js} +2 -2
  31. package/dist/_chunks/{poison-scan-CfQ3unZR.js.map → poison-scan-C92liMAr.js.map} +1 -1
  32. package/dist/_chunks/{scanner-DmqdxzbW.js → scanner-CQt12vE2.js} +2 -2
  33. package/dist/_chunks/{scanner-DmqdxzbW.js.map → scanner-CQt12vE2.js.map} +1 -1
  34. package/dist/_chunks/{sizeof-BM1409x2.js → sizeof-QPE5nd3u.js} +2 -2
  35. package/dist/_chunks/{sizeof-BM1409x2.js.map → sizeof-QPE5nd3u.js.map} +1 -1
  36. package/dist/_chunks/{walkers-Czu2jXFq.js → walkers-DAT4avhZ.js} +3 -3
  37. package/dist/_chunks/{walkers-Czu2jXFq.js.map → walkers-DAT4avhZ.js.map} +1 -1
  38. package/dist/adapters/cloudflare-kv-cache.js +1 -1
  39. package/dist/analyze/crawl-entry.js +3 -3
  40. package/dist/analyze/graph-command.js +2 -2
  41. package/dist/cache/index.js +2 -2
  42. package/dist/cache/stores/memory.js +1 -1
  43. package/dist/cdn/workers-cache-purge.js +1 -1
  44. package/dist/cli.js +3 -3
  45. package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -1
  46. package/dist/client/browser-entry/action-queue.d.ts +1 -0
  47. package/dist/client/browser-entry/action-queue.d.ts.map +1 -1
  48. package/dist/client/browser-entry/form-state.d.ts +22 -0
  49. package/dist/client/browser-entry/form-state.d.ts.map +1 -0
  50. package/dist/client/browser-entry/hydrate.d.ts +9 -1
  51. package/dist/client/browser-entry/hydrate.d.ts.map +1 -1
  52. package/dist/client/browser-entry/index.d.ts +2 -0
  53. package/dist/client/browser-entry/index.d.ts.map +1 -1
  54. package/dist/client/browser-entry/router-init.d.ts.map +1 -1
  55. package/dist/client/error-boundary.js +1 -1
  56. package/dist/client/form.d.ts +17 -64
  57. package/dist/client/form.d.ts.map +1 -1
  58. package/dist/client/index.d.ts +3 -2
  59. package/dist/client/index.d.ts.map +1 -1
  60. package/dist/client/index.js +111 -51
  61. package/dist/client/index.js.map +1 -1
  62. package/dist/client/internal.js +33 -32
  63. package/dist/client/internal.js.map +1 -1
  64. package/dist/client/navigation-api.d.ts +25 -63
  65. package/dist/client/navigation-api.d.ts.map +1 -1
  66. package/dist/client/navigation-transition.d.ts +11 -2
  67. package/dist/client/navigation-transition.d.ts.map +1 -1
  68. package/dist/client/router-effects.d.ts +7 -3
  69. package/dist/client/router-effects.d.ts.map +1 -1
  70. package/dist/client/router-lifecycle.d.ts +17 -11
  71. package/dist/client/router-lifecycle.d.ts.map +1 -1
  72. package/dist/client/router-pipeline.d.ts +3 -2
  73. package/dist/client/router-pipeline.d.ts.map +1 -1
  74. package/dist/client/router-types.d.ts +24 -44
  75. package/dist/client/router-types.d.ts.map +1 -1
  76. package/dist/client/router.d.ts.map +1 -1
  77. package/dist/client/use-form-field.d.ts +39 -0
  78. package/dist/client/use-form-field.d.ts.map +1 -0
  79. package/dist/config-types.d.ts +2 -1
  80. package/dist/config-types.d.ts.map +1 -1
  81. package/dist/index.js +6 -7
  82. package/dist/index.js.map +1 -1
  83. package/dist/plugins/shims.d.ts.map +1 -1
  84. package/dist/routing/index.js +2 -2
  85. package/dist/rsc-runtime/rsc.d.ts +1 -1
  86. package/dist/rsc-runtime/rsc.d.ts.map +1 -1
  87. package/dist/server/action-client.d.ts +20 -7
  88. package/dist/server/action-client.d.ts.map +1 -1
  89. package/dist/server/action-handler.d.ts +27 -8
  90. package/dist/server/action-handler.d.ts.map +1 -1
  91. package/dist/server/als-registry.d.ts +22 -2
  92. package/dist/server/als-registry.d.ts.map +1 -1
  93. package/dist/server/client-error-message.d.ts +12 -0
  94. package/dist/server/client-error-message.d.ts.map +1 -0
  95. package/dist/server/flight-scripts.d.ts +9 -0
  96. package/dist/server/flight-scripts.d.ts.map +1 -1
  97. package/dist/server/form-data.d.ts +13 -4
  98. package/dist/server/form-data.d.ts.map +1 -1
  99. package/dist/server/form-state-flight.d.ts +32 -0
  100. package/dist/server/form-state-flight.d.ts.map +1 -0
  101. package/dist/server/index.d.ts +0 -2
  102. package/dist/server/index.d.ts.map +1 -1
  103. package/dist/server/index.js +41 -60
  104. package/dist/server/index.js.map +1 -1
  105. package/dist/server/internal.js +10 -6
  106. package/dist/server/internal.js.map +1 -1
  107. package/dist/server/logger.d.ts +1 -0
  108. package/dist/server/logger.d.ts.map +1 -1
  109. package/dist/server/pipeline.d.ts +20 -6
  110. package/dist/server/pipeline.d.ts.map +1 -1
  111. package/dist/server/request-context.d.ts +27 -2
  112. package/dist/server/request-context.d.ts.map +1 -1
  113. package/dist/server/route-element-builder.d.ts.map +1 -1
  114. package/dist/server/rsc-entry/action-dispatcher.d.ts +6 -5
  115. package/dist/server/rsc-entry/action-dispatcher.d.ts.map +1 -1
  116. package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
  117. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  118. package/dist/server/rsc-entry/render-route.d.ts +2 -0
  119. package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
  120. package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
  121. package/dist/server/rsc-entry/ssr-renderer.d.ts +6 -0
  122. package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
  123. package/dist/server/ssr-bridge-types.d.ts +10 -0
  124. package/dist/server/ssr-bridge-types.d.ts.map +1 -1
  125. package/dist/server/ssr-entry.d.ts.map +1 -1
  126. package/dist/server/ssr-form-state.d.ts +30 -0
  127. package/dist/server/ssr-form-state.d.ts.map +1 -0
  128. package/dist/server/ssr-render.d.ts +3 -0
  129. package/dist/server/ssr-render.d.ts.map +1 -1
  130. package/dist/shared/form-state-flight.d.ts +36 -0
  131. package/dist/shared/form-state-flight.d.ts.map +1 -0
  132. package/docs/api/31-api-client.mdx +31 -3
  133. package/docs/api/34-api-config.mdx +1 -1
  134. package/docs/learn/08-forms-and-actions.mdx +116 -36
  135. package/package.json +1 -1
  136. package/src/client/browser-entry/action-dispatch.ts +104 -24
  137. package/src/client/browser-entry/action-queue.ts +1 -1
  138. package/src/client/browser-entry/form-state.ts +48 -0
  139. package/src/client/browser-entry/hydrate.ts +10 -1
  140. package/src/client/browser-entry/index.ts +25 -7
  141. package/src/client/browser-entry/router-init.ts +7 -20
  142. package/src/client/form.tsx +33 -98
  143. package/src/client/index.ts +3 -2
  144. package/src/client/navigation-api.ts +47 -173
  145. package/src/client/navigation-transition.ts +15 -4
  146. package/src/client/router-effects.ts +8 -4
  147. package/src/client/router-lifecycle.ts +40 -20
  148. package/src/client/router-pipeline.ts +10 -12
  149. package/src/client/router-types.ts +24 -48
  150. package/src/client/router.ts +49 -56
  151. package/src/client/use-form-field.ts +132 -0
  152. package/src/config-types.ts +2 -1
  153. package/src/plugins/shims.ts +0 -2
  154. package/src/rsc-runtime/rsc.ts +3 -0
  155. package/src/rsc-runtime/vendor-types.d.ts +14 -0
  156. package/src/server/action-client.ts +77 -64
  157. package/src/server/action-handler.ts +133 -95
  158. package/src/server/als-registry.ts +23 -9
  159. package/src/server/client-error-message.ts +18 -0
  160. package/src/server/flight-scripts.ts +13 -0
  161. package/src/server/form-data.ts +62 -10
  162. package/src/server/form-state-flight.ts +67 -0
  163. package/src/server/index.ts +0 -4
  164. package/src/server/logger.ts +6 -1
  165. package/src/server/pipeline.ts +27 -8
  166. package/src/server/request-context.ts +39 -2
  167. package/src/server/route-element-builder.ts +12 -1
  168. package/src/server/rsc-entry/action-dispatcher.ts +40 -34
  169. package/src/server/rsc-entry/error-renderer.ts +2 -1
  170. package/src/server/rsc-entry/index.ts +1 -0
  171. package/src/server/rsc-entry/render-route.ts +16 -0
  172. package/src/server/rsc-entry/rsc-stream.ts +20 -11
  173. package/src/server/rsc-entry/ssr-renderer.ts +11 -0
  174. package/src/server/ssr-bridge-types.ts +10 -0
  175. package/src/server/ssr-entry.ts +16 -2
  176. package/src/server/ssr-form-state.ts +58 -0
  177. package/src/server/ssr-render.ts +5 -0
  178. package/src/shared/form-state-flight.ts +74 -0
  179. package/dist/_chunks/actions-Rjk4htmA.js.map +0 -1
  180. package/dist/_chunks/als-registry-DaxkVjt5.js.map +0 -1
  181. package/dist/server/form-flash.d.ts +0 -78
  182. package/dist/server/form-flash.d.ts.map +0 -1
  183. package/src/server/form-flash.ts +0 -89
@@ -1,78 +0,0 @@
1
- /**
2
- * Form Flash — ALS-based store for no-JS form action results.
3
- *
4
- * When a no-JS form action completes, the server re-renders the page with
5
- * the action result injected via AsyncLocalStorage instead of redirecting
6
- * (which would discard the result). Server components read the flash and
7
- * pass it to client form components as the initial `useActionState` value.
8
- *
9
- * This follows the Remix/Rails pattern — the form component becomes the
10
- * single source of truth for both with-JS (React state) and no-JS (flash).
11
- *
12
- * The flash data is server-side only — never serialized to cookies or headers.
13
- *
14
- * See design/08-forms-and-actions.md §"No-JS Result Round-Trip"
15
- */
16
- import type { ValidationErrors } from './action-client.ts';
17
- /**
18
- * Flash data injected into the re-render after a no-JS form submission.
19
- *
20
- * This is the action result from the server action, stored in ALS so server
21
- * components can read it and pass it to client form components as the initial
22
- * state for `useActionState`. This makes the form component a single source
23
- * of truth for both with-JS and no-JS paths.
24
- *
25
- * The shape matches `ActionResult<unknown>` — it's one of:
26
- * - `{ data: ... }` — success
27
- * - `{ validationErrors, submittedValues }` — validation failure
28
- * - `{ serverError }` — server error
29
- */
30
- export interface FormFlashData {
31
- /** Success data from the action. */
32
- data?: unknown;
33
- /** Validation errors keyed by field name. `_root` for form-level errors. */
34
- validationErrors?: ValidationErrors;
35
- /** Raw submitted values for repopulating form fields. File objects are excluded. */
36
- submittedValues?: Record<string, unknown>;
37
- /** Server error if the action threw an ActionError. */
38
- serverError?: {
39
- code: string;
40
- data?: Record<string, unknown>;
41
- };
42
- }
43
- /**
44
- * Read the form flash data for the current request.
45
- *
46
- * Returns `null` if no flash data is present (i.e., this is a normal page
47
- * render, not a re-render after a no-JS form submission).
48
- *
49
- * Pass the flash as the initial state to `useActionState` so the form
50
- * component has a single source of truth for both with-JS and no-JS paths:
51
- *
52
- * ```tsx
53
- * // app/contact/page.tsx (server component)
54
- * import { getFormFlash } from '@timber-js/app/server'
55
- *
56
- * export default function ContactPage() {
57
- * const flash = getFormFlash()
58
- * return <ContactForm flash={flash} />
59
- * }
60
- *
61
- * // app/contact/form.tsx (client component)
62
- * export function ContactForm({ flash }) {
63
- * const [result, action, isPending] = useActionState(submitContact, flash)
64
- * // result is the single source of truth — flash seeds it on no-JS
65
- * }
66
- * ```
67
- */
68
- export declare function getFormFlash(): FormFlashData | null;
69
- /**
70
- * Run a callback with form flash data in scope.
71
- *
72
- * Used by the action handler to re-render the page with validation errors
73
- * available via `getFormFlash()`. Not part of the public API.
74
- *
75
- * @internal
76
- */
77
- export declare function runWithFormFlash<T>(data: FormFlashData, fn: () => T): T;
78
- //# sourceMappingURL=form-flash.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"form-flash.d.ts","sourceRoot":"","sources":["../../src/server/form-flash.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAK3D;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC5B,oCAAoC;IACpC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,oFAAoF;IACpF,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,uDAAuD;IACvD,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;CAChE;AAID;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,IAAI,aAAa,GAAG,IAAI,CAEnD;AAID;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEvE"}
@@ -1,89 +0,0 @@
1
- /**
2
- * Form Flash — ALS-based store for no-JS form action results.
3
- *
4
- * When a no-JS form action completes, the server re-renders the page with
5
- * the action result injected via AsyncLocalStorage instead of redirecting
6
- * (which would discard the result). Server components read the flash and
7
- * pass it to client form components as the initial `useActionState` value.
8
- *
9
- * This follows the Remix/Rails pattern — the form component becomes the
10
- * single source of truth for both with-JS (React state) and no-JS (flash).
11
- *
12
- * The flash data is server-side only — never serialized to cookies or headers.
13
- *
14
- * See design/08-forms-and-actions.md §"No-JS Result Round-Trip"
15
- */
16
-
17
- import type { ValidationErrors } from './action-client.ts';
18
- import { formFlashAls } from './als-registry.ts';
19
-
20
- // ─── Types ───────────────────────────────────────────────────────────────
21
-
22
- /**
23
- * Flash data injected into the re-render after a no-JS form submission.
24
- *
25
- * This is the action result from the server action, stored in ALS so server
26
- * components can read it and pass it to client form components as the initial
27
- * state for `useActionState`. This makes the form component a single source
28
- * of truth for both with-JS and no-JS paths.
29
- *
30
- * The shape matches `ActionResult<unknown>` — it's one of:
31
- * - `{ data: ... }` — success
32
- * - `{ validationErrors, submittedValues }` — validation failure
33
- * - `{ serverError }` — server error
34
- */
35
- export interface FormFlashData {
36
- /** Success data from the action. */
37
- data?: unknown;
38
- /** Validation errors keyed by field name. `_root` for form-level errors. */
39
- validationErrors?: ValidationErrors;
40
- /** Raw submitted values for repopulating form fields. File objects are excluded. */
41
- submittedValues?: Record<string, unknown>;
42
- /** Server error if the action threw an ActionError. */
43
- serverError?: { code: string; data?: Record<string, unknown> };
44
- }
45
-
46
- // ─── Public API ──────────────────────────────────────────────────────────
47
-
48
- /**
49
- * Read the form flash data for the current request.
50
- *
51
- * Returns `null` if no flash data is present (i.e., this is a normal page
52
- * render, not a re-render after a no-JS form submission).
53
- *
54
- * Pass the flash as the initial state to `useActionState` so the form
55
- * component has a single source of truth for both with-JS and no-JS paths:
56
- *
57
- * ```tsx
58
- * // app/contact/page.tsx (server component)
59
- * import { getFormFlash } from '@timber-js/app/server'
60
- *
61
- * export default function ContactPage() {
62
- * const flash = getFormFlash()
63
- * return <ContactForm flash={flash} />
64
- * }
65
- *
66
- * // app/contact/form.tsx (client component)
67
- * export function ContactForm({ flash }) {
68
- * const [result, action, isPending] = useActionState(submitContact, flash)
69
- * // result is the single source of truth — flash seeds it on no-JS
70
- * }
71
- * ```
72
- */
73
- export function getFormFlash(): FormFlashData | null {
74
- return formFlashAls.getStore() ?? null;
75
- }
76
-
77
- // ─── Framework-Internal ──────────────────────────────────────────────────
78
-
79
- /**
80
- * Run a callback with form flash data in scope.
81
- *
82
- * Used by the action handler to re-render the page with validation errors
83
- * available via `getFormFlash()`. Not part of the public API.
84
- *
85
- * @internal
86
- */
87
- export function runWithFormFlash<T>(data: FormFlashData, fn: () => T): T {
88
- return formFlashAls.run(data, fn);
89
- }