@timber-js/app 0.1.0
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/bin/timber.mjs +5 -0
- package/dist/_chunks/error-boundary-dj-WO5uq.js +121 -0
- package/dist/_chunks/error-boundary-dj-WO5uq.js.map +1 -0
- package/dist/_chunks/format-DNt20Kt8.js +163 -0
- package/dist/_chunks/format-DNt20Kt8.js.map +1 -0
- package/dist/_chunks/interception-DIaZN1bF.js +669 -0
- package/dist/_chunks/interception-DIaZN1bF.js.map +1 -0
- package/dist/_chunks/metadata-routes-BDnswgRO.js +141 -0
- package/dist/_chunks/metadata-routes-BDnswgRO.js.map +1 -0
- package/dist/_chunks/registry-DUIpYD_x.js +20 -0
- package/dist/_chunks/registry-DUIpYD_x.js.map +1 -0
- package/dist/_chunks/request-context-D6XHINkR.js +330 -0
- package/dist/_chunks/request-context-D6XHINkR.js.map +1 -0
- package/dist/_chunks/tracing-BtOwb8O6.js +174 -0
- package/dist/_chunks/tracing-BtOwb8O6.js.map +1 -0
- package/dist/_chunks/use-cookie-8ZlA0rr3.js +125 -0
- package/dist/_chunks/use-cookie-8ZlA0rr3.js.map +1 -0
- package/dist/adapters/cloudflare.d.ts +92 -0
- package/dist/adapters/cloudflare.d.ts.map +1 -0
- package/dist/adapters/cloudflare.js +188 -0
- package/dist/adapters/cloudflare.js.map +1 -0
- package/dist/adapters/nitro.d.ts +72 -0
- package/dist/adapters/nitro.d.ts.map +1 -0
- package/dist/adapters/nitro.js +217 -0
- package/dist/adapters/nitro.js.map +1 -0
- package/dist/adapters/types.d.ts +53 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/cache/index.d.ts +52 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +283 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/redis-handler.d.ts +45 -0
- package/dist/cache/redis-handler.d.ts.map +1 -0
- package/dist/cache/register-cached-function.d.ts +17 -0
- package/dist/cache/register-cached-function.d.ts.map +1 -0
- package/dist/cache/singleflight.d.ts +11 -0
- package/dist/cache/singleflight.d.ts.map +1 -0
- package/dist/cache/stable-stringify.d.ts +7 -0
- package/dist/cache/stable-stringify.d.ts.map +1 -0
- package/dist/cache/timber-cache.d.ts +21 -0
- package/dist/cache/timber-cache.d.ts.map +1 -0
- package/dist/cli.d.ts +44 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +135 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/browser-entry.d.ts +22 -0
- package/dist/client/browser-entry.d.ts.map +1 -0
- package/dist/client/error-boundary.d.ts +42 -0
- package/dist/client/error-boundary.d.ts.map +1 -0
- package/dist/client/form.d.ts +115 -0
- package/dist/client/form.d.ts.map +1 -0
- package/dist/client/head.d.ts +16 -0
- package/dist/client/head.d.ts.map +1 -0
- package/dist/client/history.d.ts +29 -0
- package/dist/client/history.d.ts.map +1 -0
- package/dist/client/index.d.ts +32 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +1218 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/link-navigate-interceptor.d.ts +28 -0
- package/dist/client/link-navigate-interceptor.d.ts.map +1 -0
- package/dist/client/link-status-provider.d.ts +11 -0
- package/dist/client/link-status-provider.d.ts.map +1 -0
- package/dist/client/link.d.ts +119 -0
- package/dist/client/link.d.ts.map +1 -0
- package/dist/client/nuqs-adapter.d.ts +11 -0
- package/dist/client/nuqs-adapter.d.ts.map +1 -0
- package/dist/client/router-ref.d.ts +11 -0
- package/dist/client/router-ref.d.ts.map +1 -0
- package/dist/client/router.d.ts +85 -0
- package/dist/client/router.d.ts.map +1 -0
- package/dist/client/segment-cache.d.ts +88 -0
- package/dist/client/segment-cache.d.ts.map +1 -0
- package/dist/client/segment-context.d.ts +32 -0
- package/dist/client/segment-context.d.ts.map +1 -0
- package/dist/client/ssr-data.d.ts +64 -0
- package/dist/client/ssr-data.d.ts.map +1 -0
- package/dist/client/types.d.ts +5 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/unload-guard.d.ts +18 -0
- package/dist/client/unload-guard.d.ts.map +1 -0
- package/dist/client/use-cookie.d.ts +37 -0
- package/dist/client/use-cookie.d.ts.map +1 -0
- package/dist/client/use-link-status.d.ts +35 -0
- package/dist/client/use-link-status.d.ts.map +1 -0
- package/dist/client/use-navigation-pending.d.ts +26 -0
- package/dist/client/use-navigation-pending.d.ts.map +1 -0
- package/dist/client/use-params.d.ts +50 -0
- package/dist/client/use-params.d.ts.map +1 -0
- package/dist/client/use-pathname.d.ts +20 -0
- package/dist/client/use-pathname.d.ts.map +1 -0
- package/dist/client/use-query-states.d.ts +36 -0
- package/dist/client/use-query-states.d.ts.map +1 -0
- package/dist/client/use-router.d.ts +39 -0
- package/dist/client/use-router.d.ts.map +1 -0
- package/dist/client/use-search-params.d.ts +24 -0
- package/dist/client/use-search-params.d.ts.map +1 -0
- package/dist/client/use-selected-layout-segment.d.ts +68 -0
- package/dist/client/use-selected-layout-segment.d.ts.map +1 -0
- package/dist/content/index.d.ts +11 -0
- package/dist/content/index.d.ts.map +1 -0
- package/dist/content/index.js +2 -0
- package/dist/cookies/define-cookie.d.ts +61 -0
- package/dist/cookies/define-cookie.d.ts.map +1 -0
- package/dist/cookies/index.d.ts +3 -0
- package/dist/cookies/index.d.ts.map +1 -0
- package/dist/cookies/index.js +82 -0
- package/dist/cookies/index.js.map +1 -0
- package/dist/fonts/ast.d.ts +38 -0
- package/dist/fonts/ast.d.ts.map +1 -0
- package/dist/fonts/css.d.ts +43 -0
- package/dist/fonts/css.d.ts.map +1 -0
- package/dist/fonts/fallbacks.d.ts +36 -0
- package/dist/fonts/fallbacks.d.ts.map +1 -0
- package/dist/fonts/google.d.ts +122 -0
- package/dist/fonts/google.d.ts.map +1 -0
- package/dist/fonts/local.d.ts +76 -0
- package/dist/fonts/local.d.ts.map +1 -0
- package/dist/fonts/types.d.ts +85 -0
- package/dist/fonts/types.d.ts.map +1 -0
- package/dist/index.d.ts +150 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14701 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/adapter-build.d.ts +18 -0
- package/dist/plugins/adapter-build.d.ts.map +1 -0
- package/dist/plugins/build-manifest.d.ts +79 -0
- package/dist/plugins/build-manifest.d.ts.map +1 -0
- package/dist/plugins/build-report.d.ts +63 -0
- package/dist/plugins/build-report.d.ts.map +1 -0
- package/dist/plugins/cache-transform.d.ts +36 -0
- package/dist/plugins/cache-transform.d.ts.map +1 -0
- package/dist/plugins/chunks.d.ts +45 -0
- package/dist/plugins/chunks.d.ts.map +1 -0
- package/dist/plugins/content.d.ts +19 -0
- package/dist/plugins/content.d.ts.map +1 -0
- package/dist/plugins/dev-error-overlay.d.ts +60 -0
- package/dist/plugins/dev-error-overlay.d.ts.map +1 -0
- package/dist/plugins/dev-logs.d.ts +46 -0
- package/dist/plugins/dev-logs.d.ts.map +1 -0
- package/dist/plugins/dev-server.d.ts +22 -0
- package/dist/plugins/dev-server.d.ts.map +1 -0
- package/dist/plugins/dynamic-transform.d.ts +72 -0
- package/dist/plugins/dynamic-transform.d.ts.map +1 -0
- package/dist/plugins/entries.d.ts +21 -0
- package/dist/plugins/entries.d.ts.map +1 -0
- package/dist/plugins/fonts.d.ts +77 -0
- package/dist/plugins/fonts.d.ts.map +1 -0
- package/dist/plugins/mdx.d.ts +21 -0
- package/dist/plugins/mdx.d.ts.map +1 -0
- package/dist/plugins/react-prod.d.ts +18 -0
- package/dist/plugins/react-prod.d.ts.map +1 -0
- package/dist/plugins/routing.d.ts +13 -0
- package/dist/plugins/routing.d.ts.map +1 -0
- package/dist/plugins/server-action-exports.d.ts +26 -0
- package/dist/plugins/server-action-exports.d.ts.map +1 -0
- package/dist/plugins/server-bundle.d.ts +15 -0
- package/dist/plugins/server-bundle.d.ts.map +1 -0
- package/dist/plugins/shims.d.ts +18 -0
- package/dist/plugins/shims.d.ts.map +1 -0
- package/dist/plugins/static-build.d.ts +55 -0
- package/dist/plugins/static-build.d.ts.map +1 -0
- package/dist/routing/codegen.d.ts +29 -0
- package/dist/routing/codegen.d.ts.map +1 -0
- package/dist/routing/index.d.ts +8 -0
- package/dist/routing/index.d.ts.map +1 -0
- package/dist/routing/index.js +2 -0
- package/dist/routing/interception.d.ts +46 -0
- package/dist/routing/interception.d.ts.map +1 -0
- package/dist/routing/scanner.d.ts +28 -0
- package/dist/routing/scanner.d.ts.map +1 -0
- package/dist/routing/status-file-lint.d.ts +33 -0
- package/dist/routing/status-file-lint.d.ts.map +1 -0
- package/dist/routing/types.d.ts +81 -0
- package/dist/routing/types.d.ts.map +1 -0
- package/dist/search-params/analyze.d.ts +54 -0
- package/dist/search-params/analyze.d.ts.map +1 -0
- package/dist/search-params/codecs.d.ts +53 -0
- package/dist/search-params/codecs.d.ts.map +1 -0
- package/dist/search-params/create.d.ts +106 -0
- package/dist/search-params/create.d.ts.map +1 -0
- package/dist/search-params/index.d.ts +7 -0
- package/dist/search-params/index.d.ts.map +1 -0
- package/dist/search-params/index.js +300 -0
- package/dist/search-params/index.js.map +1 -0
- package/dist/search-params/registry.d.ts +20 -0
- package/dist/search-params/registry.d.ts.map +1 -0
- package/dist/server/access-gate.d.ts +42 -0
- package/dist/server/access-gate.d.ts.map +1 -0
- package/dist/server/action-client.d.ts +190 -0
- package/dist/server/action-client.d.ts.map +1 -0
- package/dist/server/action-handler.d.ts +48 -0
- package/dist/server/action-handler.d.ts.map +1 -0
- package/dist/server/actions.d.ts +108 -0
- package/dist/server/actions.d.ts.map +1 -0
- package/dist/server/asset-headers.d.ts +42 -0
- package/dist/server/asset-headers.d.ts.map +1 -0
- package/dist/server/body-limits.d.ts +30 -0
- package/dist/server/body-limits.d.ts.map +1 -0
- package/dist/server/build-manifest.d.ts +120 -0
- package/dist/server/build-manifest.d.ts.map +1 -0
- package/dist/server/canonicalize.d.ts +30 -0
- package/dist/server/canonicalize.d.ts.map +1 -0
- package/dist/server/client-module-map.d.ts +47 -0
- package/dist/server/client-module-map.d.ts.map +1 -0
- package/dist/server/csrf.d.ts +34 -0
- package/dist/server/csrf.d.ts.map +1 -0
- package/dist/server/deny-renderer.d.ts +49 -0
- package/dist/server/deny-renderer.d.ts.map +1 -0
- package/dist/server/dev-logger.d.ts +44 -0
- package/dist/server/dev-logger.d.ts.map +1 -0
- package/dist/server/dev-span-processor.d.ts +29 -0
- package/dist/server/dev-span-processor.d.ts.map +1 -0
- package/dist/server/dev-warnings.d.ts +129 -0
- package/dist/server/dev-warnings.d.ts.map +1 -0
- package/dist/server/early-hints-sender.d.ts +38 -0
- package/dist/server/early-hints-sender.d.ts.map +1 -0
- package/dist/server/early-hints.d.ts +83 -0
- package/dist/server/early-hints.d.ts.map +1 -0
- package/dist/server/error-boundary-wrapper.d.ts +17 -0
- package/dist/server/error-boundary-wrapper.d.ts.map +1 -0
- package/dist/server/error-formatter.d.ts +17 -0
- package/dist/server/error-formatter.d.ts.map +1 -0
- package/dist/server/flush.d.ts +74 -0
- package/dist/server/flush.d.ts.map +1 -0
- package/dist/server/form-data.d.ts +60 -0
- package/dist/server/form-data.d.ts.map +1 -0
- package/dist/server/form-flash.d.ts +78 -0
- package/dist/server/form-flash.d.ts.map +1 -0
- package/dist/server/html-injectors.d.ts +101 -0
- package/dist/server/html-injectors.d.ts.map +1 -0
- package/dist/server/index.d.ts +54 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +2925 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/instrumentation.d.ts +61 -0
- package/dist/server/instrumentation.d.ts.map +1 -0
- package/dist/server/logger.d.ts +83 -0
- package/dist/server/logger.d.ts.map +1 -0
- package/dist/server/manifest-status-resolver.d.ts +58 -0
- package/dist/server/manifest-status-resolver.d.ts.map +1 -0
- package/dist/server/metadata-render.d.ts +20 -0
- package/dist/server/metadata-render.d.ts.map +1 -0
- package/dist/server/metadata-routes.d.ts +67 -0
- package/dist/server/metadata-routes.d.ts.map +1 -0
- package/dist/server/metadata.d.ts +67 -0
- package/dist/server/metadata.d.ts.map +1 -0
- package/dist/server/middleware-runner.d.ts +21 -0
- package/dist/server/middleware-runner.d.ts.map +1 -0
- package/dist/server/nuqs-ssr-provider.d.ts +28 -0
- package/dist/server/nuqs-ssr-provider.d.ts.map +1 -0
- package/dist/server/pipeline.d.ts +81 -0
- package/dist/server/pipeline.d.ts.map +1 -0
- package/dist/server/prerender.d.ts +77 -0
- package/dist/server/prerender.d.ts.map +1 -0
- package/dist/server/primitives.d.ts +131 -0
- package/dist/server/primitives.d.ts.map +1 -0
- package/dist/server/proxy.d.ts +23 -0
- package/dist/server/proxy.d.ts.map +1 -0
- package/dist/server/request-context.d.ts +175 -0
- package/dist/server/request-context.d.ts.map +1 -0
- package/dist/server/route-element-builder.d.ts +66 -0
- package/dist/server/route-element-builder.d.ts.map +1 -0
- package/dist/server/route-handler.d.ts +35 -0
- package/dist/server/route-handler.d.ts.map +1 -0
- package/dist/server/route-matcher.d.ts +78 -0
- package/dist/server/route-matcher.d.ts.map +1 -0
- package/dist/server/rsc-entry/api-handler.d.ts +11 -0
- package/dist/server/rsc-entry/api-handler.d.ts.map +1 -0
- package/dist/server/rsc-entry/error-renderer.d.ts +30 -0
- package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -0
- package/dist/server/rsc-entry/helpers.d.ts +73 -0
- package/dist/server/rsc-entry/helpers.d.ts.map +1 -0
- package/dist/server/rsc-entry/index.d.ts +11 -0
- package/dist/server/rsc-entry/index.d.ts.map +1 -0
- package/dist/server/rsc-entry/ssr-bridge.d.ts +6 -0
- package/dist/server/rsc-entry/ssr-bridge.d.ts.map +1 -0
- package/dist/server/slot-resolver.d.ts +34 -0
- package/dist/server/slot-resolver.d.ts.map +1 -0
- package/dist/server/ssr-entry.d.ts +73 -0
- package/dist/server/ssr-entry.d.ts.map +1 -0
- package/dist/server/ssr-render.d.ts +67 -0
- package/dist/server/ssr-render.d.ts.map +1 -0
- package/dist/server/status-code-resolver.d.ts +77 -0
- package/dist/server/status-code-resolver.d.ts.map +1 -0
- package/dist/server/tracing.d.ts +99 -0
- package/dist/server/tracing.d.ts.map +1 -0
- package/dist/server/tree-builder.d.ts +116 -0
- package/dist/server/tree-builder.d.ts.map +1 -0
- package/dist/server/types.d.ts +231 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/shims/font-google.d.ts +41 -0
- package/dist/shims/font-google.d.ts.map +1 -0
- package/dist/shims/headers.d.ts +11 -0
- package/dist/shims/headers.d.ts.map +1 -0
- package/dist/shims/image.d.ts +328 -0
- package/dist/shims/image.d.ts.map +1 -0
- package/dist/shims/link.d.ts +9 -0
- package/dist/shims/link.d.ts.map +1 -0
- package/dist/shims/navigation-client.d.ts +25 -0
- package/dist/shims/navigation-client.d.ts.map +1 -0
- package/dist/shims/navigation.d.ts +25 -0
- package/dist/shims/navigation.d.ts.map +1 -0
- package/dist/utils/directive-parser.d.ts +70 -0
- package/dist/utils/directive-parser.d.ts.map +1 -0
- package/dist/utils/format.d.ts +6 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/startup-timer.d.ts +34 -0
- package/dist/utils/startup-timer.d.ts.map +1 -0
- package/package.json +140 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createActionClient — typed middleware and schema validation for server actions.
|
|
3
|
+
*
|
|
4
|
+
* Inspired by next-safe-action. Provides a builder API:
|
|
5
|
+
* createActionClient({ middleware }) → .schema(z.object(...)) → .action(fn)
|
|
6
|
+
*
|
|
7
|
+
* The resulting action function satisfies both:
|
|
8
|
+
* 1. Direct call: action(input) → Promise<ActionResult>
|
|
9
|
+
* 2. React useActionState: (prevState, formData) => Promise<ActionResult>
|
|
10
|
+
*
|
|
11
|
+
* See design/08-forms-and-actions.md §"Middleware for Server Actions"
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Typed error class for server actions. Carries a string code and optional data.
|
|
15
|
+
* When thrown from middleware or the action body, the action short-circuits and
|
|
16
|
+
* the client receives `result.serverError`.
|
|
17
|
+
*
|
|
18
|
+
* In production, unexpected errors (non-ActionError) return `{ code: 'INTERNAL_ERROR' }`
|
|
19
|
+
* with no message. In dev, `data.message` is included.
|
|
20
|
+
*/
|
|
21
|
+
export declare class ActionError<TCode extends string = string> extends Error {
|
|
22
|
+
readonly code: TCode;
|
|
23
|
+
readonly data: Record<string, unknown> | undefined;
|
|
24
|
+
constructor(code: TCode, data?: Record<string, unknown>);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Standard Schema v1 interface (subset).
|
|
28
|
+
* Zod ≥3.24, Valibot ≥1.0, and ArkType all implement this.
|
|
29
|
+
* See https://github.com/standard-schema/standard-schema
|
|
30
|
+
*
|
|
31
|
+
* We use permissive types here to accept all compliant libraries without
|
|
32
|
+
* requiring exact structural matches on issues/path shapes.
|
|
33
|
+
*/
|
|
34
|
+
interface StandardSchemaV1<Output = unknown> {
|
|
35
|
+
'~standard': {
|
|
36
|
+
validate(value: unknown): StandardSchemaResult<Output> | Promise<StandardSchemaResult<Output>>;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
type StandardSchemaResult<Output> = {
|
|
40
|
+
value: Output;
|
|
41
|
+
issues?: undefined;
|
|
42
|
+
} | {
|
|
43
|
+
value?: undefined;
|
|
44
|
+
issues: ReadonlyArray<StandardSchemaIssue>;
|
|
45
|
+
};
|
|
46
|
+
interface StandardSchemaIssue {
|
|
47
|
+
message: string;
|
|
48
|
+
path?: ReadonlyArray<PropertyKey | {
|
|
49
|
+
key: PropertyKey;
|
|
50
|
+
}>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Minimal schema interface — compatible with Zod, Valibot, ArkType, etc.
|
|
54
|
+
*
|
|
55
|
+
* Accepts either:
|
|
56
|
+
* - Standard Schema (preferred): any object with `~standard.validate()`
|
|
57
|
+
* - Legacy parse interface: objects with `.parse()` / `.safeParse()`
|
|
58
|
+
*
|
|
59
|
+
* At runtime, Standard Schema is detected via `~standard` property and
|
|
60
|
+
* takes priority over the legacy interface.
|
|
61
|
+
*/
|
|
62
|
+
export type ActionSchema<T = unknown> = StandardSchemaV1<T> | LegacyActionSchema<T>;
|
|
63
|
+
/** Legacy schema interface with .parse() / .safeParse(). */
|
|
64
|
+
interface LegacyActionSchema<T = unknown> {
|
|
65
|
+
'parse'(data: unknown): T;
|
|
66
|
+
'safeParse'?(data: unknown): {
|
|
67
|
+
success: true;
|
|
68
|
+
data: T;
|
|
69
|
+
} | {
|
|
70
|
+
success: false;
|
|
71
|
+
error: SchemaError;
|
|
72
|
+
};
|
|
73
|
+
'~standard'?: never;
|
|
74
|
+
}
|
|
75
|
+
/** Schema validation error shape (for legacy .safeParse()/.parse() interface). */
|
|
76
|
+
export interface SchemaError {
|
|
77
|
+
issues?: Array<{
|
|
78
|
+
path?: Array<string | number>;
|
|
79
|
+
message: string;
|
|
80
|
+
}>;
|
|
81
|
+
flatten?(): {
|
|
82
|
+
fieldErrors: Record<string, string[]>;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** Flattened validation errors keyed by field name. */
|
|
86
|
+
export type ValidationErrors = Record<string, string[]>;
|
|
87
|
+
/** Middleware function: returns context to merge into the action body's ctx. */
|
|
88
|
+
export type ActionMiddleware<TCtx = Record<string, unknown>> = () => Promise<TCtx> | TCtx;
|
|
89
|
+
/** The result type returned to the client. */
|
|
90
|
+
export type ActionResult<TData = unknown> = {
|
|
91
|
+
data: TData;
|
|
92
|
+
validationErrors?: never;
|
|
93
|
+
serverError?: never;
|
|
94
|
+
submittedValues?: never;
|
|
95
|
+
} | {
|
|
96
|
+
data?: never;
|
|
97
|
+
validationErrors: ValidationErrors;
|
|
98
|
+
serverError?: never;
|
|
99
|
+
/** Raw input values on validation failure — for repopulating form fields. */
|
|
100
|
+
submittedValues?: Record<string, unknown>;
|
|
101
|
+
} | {
|
|
102
|
+
data?: never;
|
|
103
|
+
validationErrors?: never;
|
|
104
|
+
serverError: {
|
|
105
|
+
code: string;
|
|
106
|
+
data?: Record<string, unknown>;
|
|
107
|
+
};
|
|
108
|
+
submittedValues?: never;
|
|
109
|
+
};
|
|
110
|
+
/** Context passed to the action body. */
|
|
111
|
+
export interface ActionContext<TCtx, TInput> {
|
|
112
|
+
ctx: TCtx;
|
|
113
|
+
input: TInput;
|
|
114
|
+
}
|
|
115
|
+
interface ActionClientConfig<TCtx> {
|
|
116
|
+
middleware?: ActionMiddleware<TCtx> | ActionMiddleware<Record<string, unknown>>[];
|
|
117
|
+
/** Max file size in bytes. Files exceeding this are rejected with validation errors. */
|
|
118
|
+
fileSizeLimit?: number;
|
|
119
|
+
}
|
|
120
|
+
/** Intermediate builder returned by createActionClient(). */
|
|
121
|
+
export interface ActionBuilder<TCtx> {
|
|
122
|
+
/** Declare the input schema. Validation errors are returned typed. */
|
|
123
|
+
schema<TInput>(schema: ActionSchema<TInput>): ActionBuilderWithSchema<TCtx, TInput>;
|
|
124
|
+
/** Define the action body without input validation. */
|
|
125
|
+
action<TData>(fn: (ctx: ActionContext<TCtx, undefined>) => Promise<TData>): ActionFn<TData>;
|
|
126
|
+
}
|
|
127
|
+
/** Builder after .schema() has been called. */
|
|
128
|
+
export interface ActionBuilderWithSchema<TCtx, TInput> {
|
|
129
|
+
/** Define the action body with validated input. */
|
|
130
|
+
action<TData>(fn: (ctx: ActionContext<TCtx, TInput>) => Promise<TData>): ActionFn<TData>;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The final action function. Callable two ways:
|
|
134
|
+
* - Direct: action(input) → Promise<ActionResult<TData>>
|
|
135
|
+
* - React useActionState: action(prevState, formData) → Promise<ActionResult<TData>>
|
|
136
|
+
*/
|
|
137
|
+
export type ActionFn<TData> = {
|
|
138
|
+
(input?: unknown): Promise<ActionResult<TData>>;
|
|
139
|
+
(prevState: ActionResult<TData> | null, formData: FormData): Promise<ActionResult<TData>>;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Wrap unexpected errors into a safe server error result.
|
|
143
|
+
* ActionError → typed result. Other errors → INTERNAL_ERROR (no leak).
|
|
144
|
+
*
|
|
145
|
+
* Exported for use by action-handler.ts to catch errors from raw 'use server'
|
|
146
|
+
* functions that don't use createActionClient.
|
|
147
|
+
*/
|
|
148
|
+
export declare function handleActionError(error: unknown): ActionResult<never>;
|
|
149
|
+
/**
|
|
150
|
+
* Create a typed action client with middleware and schema validation.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```ts
|
|
154
|
+
* const action = createActionClient({
|
|
155
|
+
* middleware: async () => {
|
|
156
|
+
* const user = await getUser()
|
|
157
|
+
* if (!user) throw new ActionError('UNAUTHORIZED')
|
|
158
|
+
* return { user }
|
|
159
|
+
* },
|
|
160
|
+
* })
|
|
161
|
+
*
|
|
162
|
+
* export const createTodo = action
|
|
163
|
+
* .schema(z.object({ title: z.string().min(1) }))
|
|
164
|
+
* .action(async ({ input, ctx }) => {
|
|
165
|
+
* await db.todos.create({ ...input, userId: ctx.user.id })
|
|
166
|
+
* })
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
export declare function createActionClient<TCtx = Record<string, never>>(config?: ActionClientConfig<TCtx>): ActionBuilder<TCtx>;
|
|
170
|
+
/**
|
|
171
|
+
* Convenience wrapper for the common case: validate input, run handler.
|
|
172
|
+
* No middleware needed.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* 'use server'
|
|
177
|
+
* import { validated } from '@timber/app/server'
|
|
178
|
+
* import { z } from 'zod'
|
|
179
|
+
*
|
|
180
|
+
* export const createTodo = validated(
|
|
181
|
+
* z.object({ title: z.string().min(1) }),
|
|
182
|
+
* async (input) => {
|
|
183
|
+
* await db.todos.create(input)
|
|
184
|
+
* }
|
|
185
|
+
* )
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
export declare function validated<TInput, TData>(schema: ActionSchema<TInput>, handler: (input: TInput) => Promise<TData>): ActionFn<TData>;
|
|
189
|
+
export {};
|
|
190
|
+
//# sourceMappingURL=action-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-client.d.ts","sourceRoot":"","sources":["../../src/server/action-client.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server Action Request Handler — dispatches incoming action POST requests.
|
|
3
|
+
*
|
|
4
|
+
* Handles both JS-enabled (RSC) and no-JS (HTML form POST) action submissions.
|
|
5
|
+
* Wired into the RSC entry to intercept action requests before the render pipeline.
|
|
6
|
+
*
|
|
7
|
+
* Flow:
|
|
8
|
+
* 1. Detect action request (POST with `x-rsc-action` header or form action fields)
|
|
9
|
+
* 2. CSRF validation
|
|
10
|
+
* 3. Load and execute the server action
|
|
11
|
+
* 4. Return RSC stream (with-JS) or 302 redirect (no-JS)
|
|
12
|
+
*
|
|
13
|
+
* See design/08-forms-and-actions.md
|
|
14
|
+
*/
|
|
15
|
+
import { type CsrfConfig } from './csrf.js';
|
|
16
|
+
import { type RevalidateRenderer } from './actions.js';
|
|
17
|
+
import { type BodyLimitsConfig } from './body-limits.js';
|
|
18
|
+
import type { FormFlashData } from './form-flash.js';
|
|
19
|
+
/** Configuration for the action handler. */
|
|
20
|
+
export interface ActionDispatchConfig {
|
|
21
|
+
/** CSRF configuration. */
|
|
22
|
+
csrf: CsrfConfig;
|
|
23
|
+
/** Renderer for revalidatePath — produces RSC flight payloads. */
|
|
24
|
+
revalidateRenderer?: RevalidateRenderer;
|
|
25
|
+
/** Body size limits (from timber.config.ts). */
|
|
26
|
+
bodyLimits?: BodyLimitsConfig;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Check if a request is a server action invocation.
|
|
30
|
+
*
|
|
31
|
+
* Two cases:
|
|
32
|
+
* - With JS: POST with `x-rsc-action` header (client callServer dispatch)
|
|
33
|
+
* - Without JS: POST with form data containing `$ACTION_REF` or `$ACTION_KEY`
|
|
34
|
+
* (React's progressive enhancement hidden fields)
|
|
35
|
+
*/
|
|
36
|
+
export declare function isActionRequest(req: Request): boolean;
|
|
37
|
+
/** Signal from handleFormAction to re-render the page with flash data instead of redirecting. */
|
|
38
|
+
export interface FormRerender {
|
|
39
|
+
rerender: FormFlashData;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Handle a server action request.
|
|
43
|
+
*
|
|
44
|
+
* Returns a Response, a FormRerender signal (for no-JS validation failure re-render),
|
|
45
|
+
* or null if this isn't actually an action request (e.g., a regular form POST to an API route).
|
|
46
|
+
*/
|
|
47
|
+
export declare function handleActionRequest(req: Request, config: ActionDispatchConfig): Promise<Response | FormRerender | null>;
|
|
48
|
+
//# sourceMappingURL=action-handler.d.ts.map
|
|
@@ -0,0 +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,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIrD,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;CAC/B;AAQD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAarD;AAID,iGAAiG;AACjG,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,aAAa,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,QAAQ,GAAG,YAAY,GAAG,IAAI,CAAC,CAwCzC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server action primitives: revalidatePath, revalidateTag, and the action handler.
|
|
3
|
+
*
|
|
4
|
+
* - revalidatePath(path) re-renders the route at that path and returns the RSC
|
|
5
|
+
* flight payload for inline reconciliation.
|
|
6
|
+
* - revalidateTag(tag) invalidates cached shells and 'use cache' entries by tag.
|
|
7
|
+
*
|
|
8
|
+
* Both are callable from anywhere on the server — actions, API routes, handlers.
|
|
9
|
+
*
|
|
10
|
+
* The action handler processes incoming action requests, validates CSRF,
|
|
11
|
+
* enforces body limits, executes the action, and returns the response
|
|
12
|
+
* (with piggybacked RSC payload if revalidatePath was called).
|
|
13
|
+
*
|
|
14
|
+
* See design/08-forms-and-actions.md
|
|
15
|
+
*/
|
|
16
|
+
import type { CacheHandler } from '#/cache/index';
|
|
17
|
+
/** Result of rendering a revalidation — element tree before RSC serialization. */
|
|
18
|
+
export interface RevalidationResult {
|
|
19
|
+
/** React element tree (pre-serialization — passed to renderToReadableStream). */
|
|
20
|
+
element: unknown;
|
|
21
|
+
/** Resolved head elements for metadata. */
|
|
22
|
+
headElements: unknown[];
|
|
23
|
+
}
|
|
24
|
+
/** Renderer function that builds a React element tree for a given path. */
|
|
25
|
+
export type RevalidateRenderer = (path: string) => Promise<RevalidationResult>;
|
|
26
|
+
/** Per-request revalidation state — tracks revalidatePath/Tag calls within an action. */
|
|
27
|
+
export interface RevalidationState {
|
|
28
|
+
/** Paths to re-render (populated by revalidatePath calls). */
|
|
29
|
+
paths: string[];
|
|
30
|
+
/** Tags to invalidate (populated by revalidateTag calls). */
|
|
31
|
+
tags: string[];
|
|
32
|
+
}
|
|
33
|
+
/** Options for creating the action handler. */
|
|
34
|
+
export interface ActionHandlerConfig {
|
|
35
|
+
/** Cache handler for tag invalidation. */
|
|
36
|
+
cacheHandler?: CacheHandler;
|
|
37
|
+
/** Renderer for producing RSC payloads during revalidation. */
|
|
38
|
+
renderer?: RevalidateRenderer;
|
|
39
|
+
}
|
|
40
|
+
/** Result of handling a server action request. */
|
|
41
|
+
export interface ActionHandlerResult {
|
|
42
|
+
/** The action's return value (serialized). */
|
|
43
|
+
actionResult: unknown;
|
|
44
|
+
/** Revalidation result if revalidatePath was called (element tree, not yet serialized). */
|
|
45
|
+
revalidation?: RevalidationResult;
|
|
46
|
+
/** Redirect location if a RedirectSignal was thrown during revalidation. */
|
|
47
|
+
redirectTo?: string;
|
|
48
|
+
/** Redirect status code. */
|
|
49
|
+
redirectStatus?: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Set the revalidation state for the current action execution.
|
|
53
|
+
* @internal — kept for test compatibility; prefer executeAction() which uses ALS.
|
|
54
|
+
*/
|
|
55
|
+
export declare function _setRevalidationState(state: RevalidationState): void;
|
|
56
|
+
/**
|
|
57
|
+
* Clear the revalidation state after action execution.
|
|
58
|
+
* @internal — kept for test compatibility.
|
|
59
|
+
*/
|
|
60
|
+
export declare function _clearRevalidationState(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Re-render the route at `path` and include the RSC flight payload in the
|
|
63
|
+
* action response. The client reconciles inline — no separate fetch needed.
|
|
64
|
+
*
|
|
65
|
+
* Can be called from server actions, API routes, or any server-side context.
|
|
66
|
+
*
|
|
67
|
+
* @param path - The path to re-render (e.g. '/dashboard', '/todos').
|
|
68
|
+
*/
|
|
69
|
+
export declare function revalidatePath(path: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Invalidate all pre-rendered shells and 'use cache' entries tagged with `tag`.
|
|
72
|
+
* Does not return a payload — the next request for an invalidated route re-renders fresh.
|
|
73
|
+
*
|
|
74
|
+
* @param tag - The cache tag to invalidate (e.g. 'products', 'user:123').
|
|
75
|
+
*/
|
|
76
|
+
export declare function revalidateTag(tag: string): void;
|
|
77
|
+
/**
|
|
78
|
+
* Execute a server action and process revalidation.
|
|
79
|
+
*
|
|
80
|
+
* 1. Sets up revalidation state
|
|
81
|
+
* 2. Calls the action function
|
|
82
|
+
* 3. Processes revalidateTag calls (invalidates cache entries)
|
|
83
|
+
* 4. Processes revalidatePath calls (re-renders and captures RSC payload)
|
|
84
|
+
* 5. Returns the action result + optional RSC payload
|
|
85
|
+
*
|
|
86
|
+
* @param actionFn - The server action function to execute.
|
|
87
|
+
* @param args - Arguments to pass to the action.
|
|
88
|
+
* @param config - Handler configuration (cache handler, renderer).
|
|
89
|
+
*/
|
|
90
|
+
export declare function executeAction(actionFn: (...args: unknown[]) => Promise<unknown>, args: unknown[], config?: ActionHandlerConfig, spanMeta?: {
|
|
91
|
+
actionFile?: string;
|
|
92
|
+
actionName?: string;
|
|
93
|
+
}): Promise<ActionHandlerResult>;
|
|
94
|
+
/**
|
|
95
|
+
* Build an HTTP Response for a no-JS form submission.
|
|
96
|
+
* Standard POST → 302 redirect pattern.
|
|
97
|
+
*
|
|
98
|
+
* @param redirectPath - Where to redirect after the action executes.
|
|
99
|
+
*/
|
|
100
|
+
export declare function buildNoJsResponse(redirectPath: string, status?: number): Response;
|
|
101
|
+
/**
|
|
102
|
+
* Detect whether the incoming request is an RSC action request (with JS)
|
|
103
|
+
* or a plain HTML form POST (no JS).
|
|
104
|
+
*
|
|
105
|
+
* RSC action requests use Accept: text/x-component or Content-Type: text/x-component.
|
|
106
|
+
*/
|
|
107
|
+
export declare function isRscActionRequest(req: Request): boolean;
|
|
108
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/server/actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAMlD,kFAAkF;AAClF,MAAM,WAAW,kBAAkB;IACjC,iFAAiF;IACjF,OAAO,EAAE,OAAO,CAAC;IACjB,2CAA2C;IAC3C,YAAY,EAAE,OAAO,EAAE,CAAC;CACzB;AAED,2EAA2E;AAC3E,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAE/E,yFAAyF;AACzF,MAAM,WAAW,iBAAiB;IAChC,8DAA8D;IAC9D,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IAClC,0CAA0C;IAC1C,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B;AAED,kDAAkD;AAClD,MAAM,WAAW,mBAAmB;IAClC,8CAA8C;IAC9C,YAAY,EAAE,OAAO,CAAC;IACtB,2FAA2F;IAC3F,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AASD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAIpE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C;AAmBD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAKjD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAK/C;AAID;;;;;;;;;;;;GAYG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,EAClD,IAAI,EAAE,OAAO,EAAE,EACf,MAAM,GAAE,mBAAwB,EAChC,QAAQ,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GACtD,OAAO,CAAC,mBAAmB,CAAC,CA0D9B;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,GAAE,MAAY,GAAG,QAAQ,CAKtF;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAIxD"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static asset cache header utilities.
|
|
3
|
+
*
|
|
4
|
+
* Hashed assets (e.g. /assets/layout-abc123.css) are immutable — the hash
|
|
5
|
+
* changes when content changes. These get long-lived cache headers:
|
|
6
|
+
* Cache-Control: public, max-age=31536000, immutable
|
|
7
|
+
*
|
|
8
|
+
* Unhashed assets (e.g. /favicon.ico) get a shorter cache with revalidation:
|
|
9
|
+
* Cache-Control: public, max-age=3600, must-revalidate
|
|
10
|
+
*
|
|
11
|
+
* This is applied automatically by the framework for static assets served
|
|
12
|
+
* from the build output. Page responses are NOT affected — those are
|
|
13
|
+
* controlled by the developer via middleware.ts or proxy.ts.
|
|
14
|
+
*
|
|
15
|
+
* Design docs: 18-build-system.md, 06-caching.md
|
|
16
|
+
*/
|
|
17
|
+
/** Cache-Control value for hashed (immutable) assets. */
|
|
18
|
+
export declare const IMMUTABLE_CACHE = "public, max-age=31536000, immutable";
|
|
19
|
+
/** Cache-Control value for unhashed static assets. */
|
|
20
|
+
export declare const STATIC_CACHE = "public, max-age=3600, must-revalidate";
|
|
21
|
+
/**
|
|
22
|
+
* Check if a URL path looks like a hashed asset.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isHashedAsset(pathname: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Get the appropriate Cache-Control header for a static asset path.
|
|
27
|
+
*
|
|
28
|
+
* Returns `immutable` for hashed assets, short-lived for unhashed.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getAssetCacheControl(pathname: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Generate a `_headers` file for static asset cache control.
|
|
33
|
+
*
|
|
34
|
+
* The `_headers` file is a platform convention supported by Cloudflare Workers
|
|
35
|
+
* Static Assets, Cloudflare Pages, and Netlify. It maps URL patterns to
|
|
36
|
+
* HTTP response headers.
|
|
37
|
+
*
|
|
38
|
+
* Vite places all hashed chunks under `/assets/` — these get immutable caching.
|
|
39
|
+
* Everything else (favicon.ico, robots.txt, etc.) gets a shorter cache.
|
|
40
|
+
*/
|
|
41
|
+
export declare function generateHeadersFile(): string;
|
|
42
|
+
//# sourceMappingURL=asset-headers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-headers.d.ts","sourceRoot":"","sources":["../../src/server/asset-headers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAuBH,yDAAyD;AACzD,eAAO,MAAM,eAAe,wCAA2C,CAAC;AAExE,sDAAsD;AACtD,eAAO,MAAM,YAAY,0CAAiD,CAAC;AAE3E;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAU5C"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request body size limits — returns 413 when exceeded.
|
|
3
|
+
* See design/08-forms-and-actions.md §"FormData Limits"
|
|
4
|
+
*/
|
|
5
|
+
export interface BodyLimitsConfig {
|
|
6
|
+
limits?: {
|
|
7
|
+
actionBodySize?: string;
|
|
8
|
+
uploadBodySize?: string;
|
|
9
|
+
maxFields?: number;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export type BodyLimitResult = {
|
|
13
|
+
ok: true;
|
|
14
|
+
} | {
|
|
15
|
+
ok: false;
|
|
16
|
+
status: 411 | 413;
|
|
17
|
+
};
|
|
18
|
+
export type BodyKind = 'action' | 'upload';
|
|
19
|
+
export declare const DEFAULT_LIMITS: {
|
|
20
|
+
readonly actionBodySize: number;
|
|
21
|
+
readonly uploadBodySize: number;
|
|
22
|
+
readonly maxFields: 100;
|
|
23
|
+
};
|
|
24
|
+
/** Parse a human-readable size string ("1mb", "512kb", "1024") into bytes. */
|
|
25
|
+
export declare function parseBodySize(size: string): number;
|
|
26
|
+
/** Check whether a request body exceeds the configured size limit (stateless, no ALS). */
|
|
27
|
+
export declare function enforceBodyLimits(req: Request, kind: BodyKind, config: BodyLimitsConfig): BodyLimitResult;
|
|
28
|
+
/** Check whether a FormData payload exceeds the configured field count limit. */
|
|
29
|
+
export declare function enforceFieldLimit(formData: FormData, config: BodyLimitsConfig): BodyLimitResult;
|
|
30
|
+
//# sourceMappingURL=body-limits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body-limits.d.ts","sourceRoot":"","sources":["../../src/server/body-limits.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE;QACP,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,MAAM,eAAe,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,GAAG,GAAG,GAAG,CAAA;CAAE,CAAC;AAE9E,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAM3C,eAAO,MAAM,cAAc;;;;CAIjB,CAAC;AAIX,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAuBlD;AAED,0FAA0F;AAC1F,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,gBAAgB,GACvB,eAAe,CAejB;AAED,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB,GAAG,eAAe,CAM/F"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build manifest types and utilities for CSS and JS asset tracking.
|
|
3
|
+
*
|
|
4
|
+
* The build manifest maps route segment file paths to their output
|
|
5
|
+
* chunks from Vite's client build. This enables:
|
|
6
|
+
* - <link rel="stylesheet"> injection in HTML <head>
|
|
7
|
+
* - <script type="module"> with hashed URLs in production
|
|
8
|
+
* - <link rel="modulepreload"> for client chunk dependencies
|
|
9
|
+
* - Link preload headers for Early Hints (103)
|
|
10
|
+
*
|
|
11
|
+
* In dev mode, Vite's HMR client handles CSS/JS injection, so the build
|
|
12
|
+
* manifest is empty. In production, it's populated from Vite's
|
|
13
|
+
* .vite/manifest.json after the client build.
|
|
14
|
+
*
|
|
15
|
+
* Design docs: 18-build-system.md §"Build Manifest", 02-rendering-pipeline.md §"Early Hints"
|
|
16
|
+
*/
|
|
17
|
+
/** A font asset entry in the build manifest. */
|
|
18
|
+
export interface ManifestFontEntry {
|
|
19
|
+
/** URL path to the font file (e.g. `/_timber/fonts/inter-latin-400-abc123.woff2`). */
|
|
20
|
+
href: string;
|
|
21
|
+
/** Font format (e.g. `woff2`). */
|
|
22
|
+
format: string;
|
|
23
|
+
/** Crossorigin attribute — always `anonymous` for fonts. */
|
|
24
|
+
crossOrigin: string;
|
|
25
|
+
}
|
|
26
|
+
/** Build manifest mapping input file paths to output asset URLs. */
|
|
27
|
+
export interface BuildManifest {
|
|
28
|
+
/** Map from input file path (relative to project root) to output CSS URLs. */
|
|
29
|
+
css: Record<string, string[]>;
|
|
30
|
+
/** Map from input file path to output JS chunk URL (hashed filename). */
|
|
31
|
+
js: Record<string, string>;
|
|
32
|
+
/** Map from input file path to transitive JS dependency URLs for modulepreload. */
|
|
33
|
+
modulepreload: Record<string, string[]>;
|
|
34
|
+
/** Map from input file path to font assets used by that module. */
|
|
35
|
+
fonts: Record<string, ManifestFontEntry[]>;
|
|
36
|
+
}
|
|
37
|
+
/** Empty build manifest used in dev mode. */
|
|
38
|
+
export declare const EMPTY_BUILD_MANIFEST: BuildManifest;
|
|
39
|
+
/** Segment shape expected by collectRouteCss (matches ManifestSegmentNode). */
|
|
40
|
+
interface SegmentWithFiles {
|
|
41
|
+
layout?: {
|
|
42
|
+
filePath: string;
|
|
43
|
+
};
|
|
44
|
+
page?: {
|
|
45
|
+
filePath: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Collect all CSS files needed for a matched route's segment chain.
|
|
50
|
+
*
|
|
51
|
+
* Walks segments root → leaf, collecting CSS for each layout and page.
|
|
52
|
+
* Deduplicates while preserving order (root layout CSS first).
|
|
53
|
+
*/
|
|
54
|
+
export declare function collectRouteCss(segments: SegmentWithFiles[], manifest: BuildManifest): string[];
|
|
55
|
+
/**
|
|
56
|
+
* Generate <link rel="stylesheet"> tags for CSS URLs.
|
|
57
|
+
*
|
|
58
|
+
* Returns an HTML string to prepend to headHtml for injection
|
|
59
|
+
* via injectHead() before </head>.
|
|
60
|
+
*/
|
|
61
|
+
export declare function buildCssLinkTags(cssUrls: string[]): string;
|
|
62
|
+
/**
|
|
63
|
+
* Generate a Link header value for CSS preload hints.
|
|
64
|
+
*
|
|
65
|
+
* Cloudflare CDN automatically converts Link headers with rel=preload
|
|
66
|
+
* into 103 Early Hints responses. This avoids platform-specific 103
|
|
67
|
+
* sending code.
|
|
68
|
+
*
|
|
69
|
+
* Example output: `</assets/root.css>; rel=preload; as=style, </assets/page.css>; rel=preload; as=style`
|
|
70
|
+
*/
|
|
71
|
+
export declare function buildLinkHeaders(cssUrls: string[]): string;
|
|
72
|
+
/**
|
|
73
|
+
* Collect all font entries needed for a matched route's segment chain.
|
|
74
|
+
*
|
|
75
|
+
* Walks segments root → leaf, collecting fonts for each layout and page.
|
|
76
|
+
* Deduplicates by href while preserving order.
|
|
77
|
+
*/
|
|
78
|
+
export declare function collectRouteFonts(segments: SegmentWithFiles[], manifest: BuildManifest): ManifestFontEntry[];
|
|
79
|
+
/**
|
|
80
|
+
* Generate <link rel="preload"> tags for font assets.
|
|
81
|
+
*
|
|
82
|
+
* Font preloads use `as=font` and always include `crossorigin` (required
|
|
83
|
+
* for font preloads even for same-origin resources per the spec).
|
|
84
|
+
*/
|
|
85
|
+
export declare function buildFontPreloadTags(fonts: ManifestFontEntry[]): string;
|
|
86
|
+
/**
|
|
87
|
+
* Generate Link header values for font preload hints.
|
|
88
|
+
*
|
|
89
|
+
* Cloudflare CDN converts Link headers with rel=preload into 103 Early Hints.
|
|
90
|
+
*
|
|
91
|
+
* Example: `</fonts/inter.woff2>; rel=preload; as=font; crossorigin`
|
|
92
|
+
*/
|
|
93
|
+
export declare function buildFontLinkHeaders(fonts: ManifestFontEntry[]): string;
|
|
94
|
+
/**
|
|
95
|
+
* Collect JS chunk URLs for a matched route's segment chain.
|
|
96
|
+
*
|
|
97
|
+
* Walks segments root → leaf, collecting the JS chunk for each layout
|
|
98
|
+
* and page. Deduplicates while preserving order.
|
|
99
|
+
*/
|
|
100
|
+
export declare function collectRouteJs(segments: SegmentWithFiles[], manifest: BuildManifest): string[];
|
|
101
|
+
/**
|
|
102
|
+
* Collect modulepreload URLs for a matched route's segment chain.
|
|
103
|
+
*
|
|
104
|
+
* Walks segments root → leaf, collecting transitive JS dependencies
|
|
105
|
+
* for each layout and page. Deduplicates across segments.
|
|
106
|
+
*/
|
|
107
|
+
export declare function collectRouteModulepreloads(segments: SegmentWithFiles[], manifest: BuildManifest): string[];
|
|
108
|
+
/**
|
|
109
|
+
* Generate <link rel="modulepreload"> tags for JS dependency URLs.
|
|
110
|
+
*
|
|
111
|
+
* Modulepreload hints tell the browser to fetch and parse JS modules
|
|
112
|
+
* before they're needed, reducing waterfall latency for dynamic imports.
|
|
113
|
+
*/
|
|
114
|
+
export declare function buildModulepreloadTags(urls: string[]): string;
|
|
115
|
+
/**
|
|
116
|
+
* Generate a <script type="module"> tag for a JS entry point.
|
|
117
|
+
*/
|
|
118
|
+
export declare function buildEntryScriptTag(url: string): string;
|
|
119
|
+
export {};
|
|
120
|
+
//# sourceMappingURL=build-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-manifest.d.ts","sourceRoot":"","sources":["../../src/server/build-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,gDAAgD;AAChD,MAAM,WAAW,iBAAiB;IAChC,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,oEAAoE;AACpE,MAAM,WAAW,aAAa;IAC5B,8EAA8E;IAC9E,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9B,yEAAyE;IACzE,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,mFAAmF;IACnF,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACxC,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC,CAAC;CAC5C;AAED,6CAA6C;AAC7C,eAAO,MAAM,oBAAoB,EAAE,aAKlC,CAAC;AAEF,+EAA+E;AAC/E,UAAU,gBAAgB;IACxB,MAAM,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9B,IAAI,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,gBAAgB,EAAE,EAAE,QAAQ,EAAE,aAAa,GAAG,MAAM,EAAE,CAmB/F;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAE1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAE1D;AAID;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,gBAAgB,EAAE,EAC5B,QAAQ,EAAE,aAAa,GACtB,iBAAiB,EAAE,CAmBrB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAOvE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAEvE;AAID;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,gBAAgB,EAAE,EAAE,QAAQ,EAAE,aAAa,GAAG,MAAM,EAAE,CAiB9F;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,gBAAgB,EAAE,EAC5B,QAAQ,EAAE,aAAa,GACtB,MAAM,EAAE,CAmBV;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAE7D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL canonicalization — runs once at the request boundary.
|
|
3
|
+
*
|
|
4
|
+
* Every layer (proxy.ts, middleware.ts, access.ts, components) sees the same
|
|
5
|
+
* canonical path. No re-decoding occurs at any later stage.
|
|
6
|
+
*
|
|
7
|
+
* See design/07-routing.md §"URL Canonicalization & Security"
|
|
8
|
+
*/
|
|
9
|
+
/** Result of canonicalization — either a clean path or a rejection. */
|
|
10
|
+
export type CanonicalizeResult = {
|
|
11
|
+
ok: true;
|
|
12
|
+
pathname: string;
|
|
13
|
+
} | {
|
|
14
|
+
ok: false;
|
|
15
|
+
status: 400;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Canonicalize a URL pathname.
|
|
19
|
+
*
|
|
20
|
+
* 1. Reject encoded separators (%2f, %5c) and null bytes (%00)
|
|
21
|
+
* 2. Single percent-decode
|
|
22
|
+
* 3. Collapse // → /
|
|
23
|
+
* 4. Resolve .. segments (reject if escaping root)
|
|
24
|
+
* 5. Strip trailing slash (except root "/")
|
|
25
|
+
*
|
|
26
|
+
* @param rawPathname - The raw pathname from the request URL (percent-encoded)
|
|
27
|
+
* @param stripTrailingSlash - Whether to strip trailing slashes. Default: true.
|
|
28
|
+
*/
|
|
29
|
+
export declare function canonicalize(rawPathname: string, stripTrailingSlash?: boolean): CanonicalizeResult;
|
|
30
|
+
//# sourceMappingURL=canonicalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonicalize.d.ts","sourceRoot":"","sources":["../../src/server/canonicalize.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,uEAAuE;AACvE,MAAM,MAAM,kBAAkB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,CAAC;AAW7F;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,UAAO,GAAG,kBAAkB,CAwD/F"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client module map — maps client reference IDs to their SSR module loaders.
|
|
3
|
+
*
|
|
4
|
+
* When the RSC stream contains a client component reference (from a
|
|
5
|
+
* "use client" module), the SSR environment needs to resolve it to the
|
|
6
|
+
* actual component module so it can render the component to HTML.
|
|
7
|
+
*
|
|
8
|
+
* The @vitejs/plugin-rsc SSR runtime handles this internally via its
|
|
9
|
+
* setRequireModule hook — it imports client reference modules from the
|
|
10
|
+
* SSR environment's module graph. This module provides the configuration
|
|
11
|
+
* bridge between timber's entry system and the RSC plugin's runtime.
|
|
12
|
+
*
|
|
13
|
+
* Design docs: 18-build-system.md §"Entry Files", 02-rendering-pipeline.md
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Client reference metadata used during SSR to resolve client components.
|
|
17
|
+
*
|
|
18
|
+
* The RSC plugin tracks these internally via `clientReferenceMetaMap`.
|
|
19
|
+
* At SSR time, when `createFromReadableStream` encounters a client
|
|
20
|
+
* reference in the RSC payload, it uses the module map to import the
|
|
21
|
+
* actual component for server-side HTML rendering.
|
|
22
|
+
*/
|
|
23
|
+
export interface ClientModuleEntry {
|
|
24
|
+
/** The module ID (Vite-resolved file path) */
|
|
25
|
+
id: string;
|
|
26
|
+
/** The export name (e.g., 'default', 'Counter') */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Async module loader */
|
|
29
|
+
load: () => Promise<Record<string, unknown>>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create a client module map for SSR resolution.
|
|
33
|
+
*
|
|
34
|
+
* In dev mode, the RSC plugin's SSR runtime (`@vitejs/plugin-rsc/ssr`)
|
|
35
|
+
* handles client reference resolution automatically via its initialize()
|
|
36
|
+
* function which sets up `setRequireModule` with dynamic imports through
|
|
37
|
+
* Vite's dev server. No explicit module map is needed.
|
|
38
|
+
*
|
|
39
|
+
* In production builds, the RSC plugin generates a `virtual:vite-rsc/client-references`
|
|
40
|
+
* module that maps client reference IDs to their chunk imports. The SSR
|
|
41
|
+
* runtime reads this at startup.
|
|
42
|
+
*
|
|
43
|
+
* This function returns an empty map as a placeholder — the actual
|
|
44
|
+
* resolution is handled by the RSC plugin's runtime internals.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createClientModuleMap(): Record<string, ClientModuleEntry>;
|
|
47
|
+
//# sourceMappingURL=client-module-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-module-map.d.ts","sourceRoot":"","sources":["../../src/server/client-module-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,8CAA8C;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC9C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAUzE"}
|