@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.
- package/agent-skill.md +10 -5
- package/dist/_chunks/{actions-Rjk4htmA.js → actions-CEootpB1.js} +49 -12
- package/dist/_chunks/actions-CEootpB1.js.map +1 -0
- package/dist/_chunks/{als-registry-DaxkVjt5.js → als-registry-BZqHCtq-.js} +2 -4
- package/dist/_chunks/als-registry-BZqHCtq-.js.map +1 -0
- package/dist/_chunks/{cache-api-DGdYfNJn.js → cache-api-LA3sBpUS.js} +5 -5
- package/dist/_chunks/{cache-api-DGdYfNJn.js.map → cache-api-LA3sBpUS.js.map} +1 -1
- package/dist/_chunks/{chains-DGX9zmg9.js → chains-BfoPFraI.js} +2 -2
- package/dist/_chunks/{chains-DGX9zmg9.js.map → chains-BfoPFraI.js.map} +1 -1
- package/dist/_chunks/{classify-QwG5rxKI.js → classify-BT66U83D.js} +2 -2
- package/dist/_chunks/{classify-QwG5rxKI.js.map → classify-BT66U83D.js.map} +1 -1
- package/dist/_chunks/{cli-check-ajNY3B2e.js → cli-check-BfQ54-UJ.js} +3 -3
- package/dist/_chunks/{cli-check-ajNY3B2e.js.map → cli-check-BfQ54-UJ.js.map} +1 -1
- package/dist/_chunks/{cli-schema-sync-D2eI8jEg.js → cli-schema-sync-czh2dsLs.js} +2 -2
- package/dist/_chunks/{cli-schema-sync-D2eI8jEg.js.map → cli-schema-sync-czh2dsLs.js.map} +1 -1
- package/dist/_chunks/{client-dep-entries-2HCF09no.js → client-dep-entries-CQwpb8dI.js} +2 -2
- package/dist/_chunks/{client-dep-entries-2HCF09no.js.map → client-dep-entries-CQwpb8dI.js.map} +1 -1
- package/dist/_chunks/{convention-lint-DLmhGsRS.js → convention-lint-BEVW4EID.js} +3 -3
- package/dist/_chunks/{convention-lint-DLmhGsRS.js.map → convention-lint-BEVW4EID.js.map} +1 -1
- package/dist/_chunks/{dev-server-TFpEwm3H.js → dev-server-FKxptbnI.js} +2 -2
- package/dist/_chunks/{dev-server-TFpEwm3H.js.map → dev-server-FKxptbnI.js.map} +1 -1
- package/dist/_chunks/{error-boundary-DsNScGRM.js → error-boundary-9g_Lb2na.js} +3 -3
- package/dist/_chunks/{error-boundary-DsNScGRM.js.map → error-boundary-9g_Lb2na.js.map} +1 -1
- package/dist/_chunks/{json-lossy-check-CVuRs2hG.js → json-lossy-check-C8zBY2uZ.js} +2 -2
- package/dist/_chunks/{json-lossy-check-CVuRs2hG.js.map → json-lossy-check-C8zBY2uZ.js.map} +1 -1
- package/dist/_chunks/{live-graph-cNuWMYQI.js → live-graph-C_4v-fHv.js} +4 -4
- package/dist/_chunks/{live-graph-cNuWMYQI.js.map → live-graph-C_4v-fHv.js.map} +1 -1
- package/dist/_chunks/{logger-BP0LN6vP.js → logger-CbLdcy-W.js} +2 -2
- package/dist/_chunks/{logger-BP0LN6vP.js.map → logger-CbLdcy-W.js.map} +1 -1
- package/dist/_chunks/{poison-scan-CfQ3unZR.js → poison-scan-C92liMAr.js} +2 -2
- package/dist/_chunks/{poison-scan-CfQ3unZR.js.map → poison-scan-C92liMAr.js.map} +1 -1
- package/dist/_chunks/{scanner-DmqdxzbW.js → scanner-CQt12vE2.js} +2 -2
- package/dist/_chunks/{scanner-DmqdxzbW.js.map → scanner-CQt12vE2.js.map} +1 -1
- package/dist/_chunks/{sizeof-BM1409x2.js → sizeof-QPE5nd3u.js} +2 -2
- package/dist/_chunks/{sizeof-BM1409x2.js.map → sizeof-QPE5nd3u.js.map} +1 -1
- package/dist/_chunks/{walkers-Czu2jXFq.js → walkers-DAT4avhZ.js} +3 -3
- package/dist/_chunks/{walkers-Czu2jXFq.js.map → walkers-DAT4avhZ.js.map} +1 -1
- package/dist/adapters/cloudflare-kv-cache.js +1 -1
- package/dist/analyze/crawl-entry.js +3 -3
- package/dist/analyze/graph-command.js +2 -2
- package/dist/cache/index.js +2 -2
- package/dist/cache/stores/memory.js +1 -1
- package/dist/cdn/workers-cache-purge.js +1 -1
- package/dist/cli.js +3 -3
- package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -1
- package/dist/client/browser-entry/action-queue.d.ts +1 -0
- package/dist/client/browser-entry/action-queue.d.ts.map +1 -1
- package/dist/client/browser-entry/form-state.d.ts +22 -0
- package/dist/client/browser-entry/form-state.d.ts.map +1 -0
- package/dist/client/browser-entry/hydrate.d.ts +9 -1
- package/dist/client/browser-entry/hydrate.d.ts.map +1 -1
- package/dist/client/browser-entry/index.d.ts +2 -0
- package/dist/client/browser-entry/index.d.ts.map +1 -1
- package/dist/client/browser-entry/router-init.d.ts.map +1 -1
- package/dist/client/error-boundary.js +1 -1
- package/dist/client/form.d.ts +17 -64
- package/dist/client/form.d.ts.map +1 -1
- package/dist/client/index.d.ts +3 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +111 -51
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.js +33 -32
- package/dist/client/internal.js.map +1 -1
- package/dist/client/navigation-api.d.ts +25 -63
- package/dist/client/navigation-api.d.ts.map +1 -1
- package/dist/client/navigation-transition.d.ts +11 -2
- package/dist/client/navigation-transition.d.ts.map +1 -1
- package/dist/client/router-effects.d.ts +7 -3
- package/dist/client/router-effects.d.ts.map +1 -1
- package/dist/client/router-lifecycle.d.ts +17 -11
- package/dist/client/router-lifecycle.d.ts.map +1 -1
- package/dist/client/router-pipeline.d.ts +3 -2
- package/dist/client/router-pipeline.d.ts.map +1 -1
- package/dist/client/router-types.d.ts +24 -44
- package/dist/client/router-types.d.ts.map +1 -1
- package/dist/client/router.d.ts.map +1 -1
- package/dist/client/use-form-field.d.ts +39 -0
- package/dist/client/use-form-field.d.ts.map +1 -0
- package/dist/config-types.d.ts +2 -1
- package/dist/config-types.d.ts.map +1 -1
- package/dist/index.js +6 -7
- package/dist/index.js.map +1 -1
- package/dist/plugins/shims.d.ts.map +1 -1
- package/dist/routing/index.js +2 -2
- package/dist/rsc-runtime/rsc.d.ts +1 -1
- package/dist/rsc-runtime/rsc.d.ts.map +1 -1
- package/dist/server/action-client.d.ts +20 -7
- package/dist/server/action-client.d.ts.map +1 -1
- package/dist/server/action-handler.d.ts +27 -8
- package/dist/server/action-handler.d.ts.map +1 -1
- package/dist/server/als-registry.d.ts +22 -2
- package/dist/server/als-registry.d.ts.map +1 -1
- package/dist/server/client-error-message.d.ts +12 -0
- package/dist/server/client-error-message.d.ts.map +1 -0
- package/dist/server/flight-scripts.d.ts +9 -0
- package/dist/server/flight-scripts.d.ts.map +1 -1
- package/dist/server/form-data.d.ts +13 -4
- package/dist/server/form-data.d.ts.map +1 -1
- package/dist/server/form-state-flight.d.ts +32 -0
- package/dist/server/form-state-flight.d.ts.map +1 -0
- package/dist/server/index.d.ts +0 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +41 -60
- package/dist/server/index.js.map +1 -1
- package/dist/server/internal.js +10 -6
- package/dist/server/internal.js.map +1 -1
- package/dist/server/logger.d.ts +1 -0
- package/dist/server/logger.d.ts.map +1 -1
- package/dist/server/pipeline.d.ts +20 -6
- package/dist/server/pipeline.d.ts.map +1 -1
- package/dist/server/request-context.d.ts +27 -2
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/rsc-entry/action-dispatcher.d.ts +6 -5
- package/dist/server/rsc-entry/action-dispatcher.d.ts.map +1 -1
- package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/render-route.d.ts +2 -0
- package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- package/dist/server/rsc-entry/ssr-renderer.d.ts +6 -0
- package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
- package/dist/server/ssr-bridge-types.d.ts +10 -0
- package/dist/server/ssr-bridge-types.d.ts.map +1 -1
- package/dist/server/ssr-entry.d.ts.map +1 -1
- package/dist/server/ssr-form-state.d.ts +30 -0
- package/dist/server/ssr-form-state.d.ts.map +1 -0
- package/dist/server/ssr-render.d.ts +3 -0
- package/dist/server/ssr-render.d.ts.map +1 -1
- package/dist/shared/form-state-flight.d.ts +36 -0
- package/dist/shared/form-state-flight.d.ts.map +1 -0
- package/docs/api/31-api-client.mdx +31 -3
- package/docs/api/34-api-config.mdx +1 -1
- package/docs/learn/08-forms-and-actions.mdx +116 -36
- package/package.json +1 -1
- package/src/client/browser-entry/action-dispatch.ts +104 -24
- package/src/client/browser-entry/action-queue.ts +1 -1
- package/src/client/browser-entry/form-state.ts +48 -0
- package/src/client/browser-entry/hydrate.ts +10 -1
- package/src/client/browser-entry/index.ts +25 -7
- package/src/client/browser-entry/router-init.ts +7 -20
- package/src/client/form.tsx +33 -98
- package/src/client/index.ts +3 -2
- package/src/client/navigation-api.ts +47 -173
- package/src/client/navigation-transition.ts +15 -4
- package/src/client/router-effects.ts +8 -4
- package/src/client/router-lifecycle.ts +40 -20
- package/src/client/router-pipeline.ts +10 -12
- package/src/client/router-types.ts +24 -48
- package/src/client/router.ts +49 -56
- package/src/client/use-form-field.ts +132 -0
- package/src/config-types.ts +2 -1
- package/src/plugins/shims.ts +0 -2
- package/src/rsc-runtime/rsc.ts +3 -0
- package/src/rsc-runtime/vendor-types.d.ts +14 -0
- package/src/server/action-client.ts +77 -64
- package/src/server/action-handler.ts +133 -95
- package/src/server/als-registry.ts +23 -9
- package/src/server/client-error-message.ts +18 -0
- package/src/server/flight-scripts.ts +13 -0
- package/src/server/form-data.ts +62 -10
- package/src/server/form-state-flight.ts +67 -0
- package/src/server/index.ts +0 -4
- package/src/server/logger.ts +6 -1
- package/src/server/pipeline.ts +27 -8
- package/src/server/request-context.ts +39 -2
- package/src/server/route-element-builder.ts +12 -1
- package/src/server/rsc-entry/action-dispatcher.ts +40 -34
- package/src/server/rsc-entry/error-renderer.ts +2 -1
- package/src/server/rsc-entry/index.ts +1 -0
- package/src/server/rsc-entry/render-route.ts +16 -0
- package/src/server/rsc-entry/rsc-stream.ts +20 -11
- package/src/server/rsc-entry/ssr-renderer.ts +11 -0
- package/src/server/ssr-bridge-types.ts +10 -0
- package/src/server/ssr-entry.ts +16 -2
- package/src/server/ssr-form-state.ts +58 -0
- package/src/server/ssr-render.ts +5 -0
- package/src/shared/form-state-flight.ts +74 -0
- package/dist/_chunks/actions-Rjk4htmA.js.map +0 -1
- package/dist/_chunks/als-registry-DaxkVjt5.js.map +0 -1
- package/dist/server/form-flash.d.ts +0 -78
- package/dist/server/form-flash.d.ts.map +0 -1
- 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"}
|
package/src/server/form-flash.ts
DELETED
|
@@ -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
|
-
}
|