@krate/runtime 0.5.0-rc.1 → 0.5.0-rc.10
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/dist/action-context.js +1 -1
- package/dist/actions.d.ts +7 -0
- package/dist/actions.js +34 -10
- package/dist/after.d.ts +28 -0
- package/dist/after.js +48 -0
- package/dist/assets-static.d.ts +10 -1
- package/dist/assets-static.js +10 -2
- package/dist/base-path.d.ts +7 -0
- package/dist/base-path.js +20 -0
- package/dist/boundary.js +1 -1
- package/dist/builtin-tags.d.ts +12 -0
- package/dist/builtin-tags.js +42 -0
- package/dist/cache-adapter.js +1 -1
- package/dist/cache-scope.d.ts +8 -0
- package/dist/cache-scope.js +14 -1
- package/dist/cloudflare-workers.d.ts +2 -0
- package/dist/cloudflare-workers.js +27 -0
- package/dist/context.d.ts +5 -0
- package/dist/context.js +28 -17
- package/dist/dev-overlay.d.ts +54 -3
- package/dist/dev-overlay.js +470 -77
- package/dist/dom.js +18 -3
- package/dist/effects.js +2 -2
- package/dist/flight-props.d.ts +7 -0
- package/dist/flight-props.js +105 -0
- package/dist/handler-html.js +4 -4
- package/dist/handler-routing.d.ts +2 -23
- package/dist/handler-routing.js +9 -190
- package/dist/handler-segments.d.ts +6 -0
- package/dist/handler-segments.js +18 -4
- package/dist/head-tags.d.ts +9 -0
- package/dist/head-tags.js +93 -6
- package/dist/highlight-bind.js +1 -1
- package/dist/highlight.d.ts +3 -2
- package/dist/highlight.js +17 -12
- package/dist/hints.d.ts +25 -2
- package/dist/hints.js +147 -74
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/island-swap.d.ts +47 -0
- package/dist/island-swap.js +635 -0
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-types.d.ts +99 -3
- package/dist/krate-core.js +1 -1
- package/dist/krate-dev.js +385 -66
- package/dist/krate-f-actions.js +1 -1
- package/dist/krate-f-classes.js +1 -1
- package/dist/krate-f-highlight.js +1 -1
- package/dist/krate-f-list.js +1 -1
- package/dist/krate-f-navigation.js +1 -1
- package/dist/krate-f-router-lite.js +1 -1
- package/dist/krate-f-router.js +1 -1
- package/dist/krate-features.json +454 -0
- package/dist/krate-hydrate-lite.js +5 -5
- package/dist/krate-hydrate.js +5 -5
- package/dist/krate-island-swap.js +1 -0
- package/dist/krate-runtime.js +5 -5
- package/dist/list.d.ts +14 -4
- package/dist/list.js +4 -5
- package/dist/metadata.js +5 -2
- package/dist/navigation-react.d.ts +13 -0
- package/dist/navigation-react.js +86 -0
- package/dist/navigation.d.ts +19 -0
- package/dist/navigation.js +35 -0
- package/dist/node-server.js +3 -3
- package/dist/og.js +1 -1
- package/dist/platform.d.ts +52 -0
- package/dist/platform.js +57 -0
- package/dist/react-compat.d.ts +39 -0
- package/dist/react-compat.js +359 -0
- package/dist/react-server.d.ts +63 -0
- package/dist/react-server.js +125 -0
- package/dist/region-wire.d.ts +10 -0
- package/dist/region-wire.js +154 -0
- package/dist/request-context.js +1 -1
- package/dist/request-extras.d.ts +4 -0
- package/dist/request-extras.js +51 -0
- package/dist/resp.js +1 -1
- package/dist/route-source.d.ts +39 -0
- package/dist/route-source.js +532 -0
- package/dist/router-lite.js +3 -9
- package/dist/router.d.ts +1 -1
- package/dist/router.js +628 -98
- package/dist/server-handler.d.ts +69 -1
- package/dist/server-handler.js +515 -96
- package/dist/server-renderer.js +16 -7
- package/dist/server.d.ts +73 -16
- package/dist/server.js +619 -102
- package/dist/sha256.js +9 -9
- package/dist/signal.js +0 -6
- package/dist/site-config.d.ts +15 -0
- package/dist/site-config.js +28 -0
- package/dist/slot.d.ts +12 -0
- package/dist/slot.js +23 -0
- package/dist/ssr-core.d.ts +2 -0
- package/dist/ssr-core.js +12 -4
- package/dist/testing.d.ts +62 -0
- package/dist/testing.js +90 -0
- package/dist/use-id.js +1 -1
- package/package.json +28 -3
- package/dist/action-context.test.d.ts +0 -1
- package/dist/action-context.test.js +0 -72
- package/dist/actions.test.d.ts +0 -1
- package/dist/actions.test.js +0 -477
- package/dist/cache-adapter.test.d.ts +0 -1
- package/dist/cache-adapter.test.js +0 -244
- package/dist/cache.test.d.ts +0 -1
- package/dist/cache.test.js +0 -233
- package/dist/class-component.test.d.ts +0 -1
- package/dist/class-component.test.js +0 -462
- package/dist/class-helpers.test.d.ts +0 -1
- package/dist/class-helpers.test.js +0 -169
- package/dist/context.test.d.ts +0 -1
- package/dist/context.test.js +0 -57
- package/dist/derived.test.d.ts +0 -1
- package/dist/derived.test.js +0 -140
- package/dist/dev-overlay.test.d.ts +0 -1
- package/dist/dev-overlay.test.js +0 -165
- package/dist/discrete.test.d.ts +0 -1
- package/dist/discrete.test.js +0 -100
- package/dist/dom.test.d.ts +0 -1
- package/dist/dom.test.js +0 -39
- package/dist/effect-errors.test.d.ts +0 -1
- package/dist/effect-errors.test.js +0 -199
- package/dist/effects.test.d.ts +0 -1
- package/dist/effects.test.js +0 -485
- package/dist/events.test.d.ts +0 -1
- package/dist/events.test.js +0 -447
- package/dist/handler-html.test.d.ts +0 -1
- package/dist/handler-html.test.js +0 -256
- package/dist/handler-routing.test.d.ts +0 -1
- package/dist/handler-routing.test.js +0 -99
- package/dist/handler-segments.test.d.ts +0 -1
- package/dist/handler-segments.test.js +0 -217
- package/dist/head-tags.test.d.ts +0 -1
- package/dist/head-tags.test.js +0 -131
- package/dist/highlight-bind.test.d.ts +0 -1
- package/dist/highlight-bind.test.js +0 -124
- package/dist/highlight.test.d.ts +0 -1
- package/dist/highlight.test.js +0 -56
- package/dist/lanes.test.d.ts +0 -1
- package/dist/lanes.test.js +0 -59
- package/dist/list.test.d.ts +0 -1
- package/dist/list.test.js +0 -435
- package/dist/metadata.test.d.ts +0 -1
- package/dist/metadata.test.js +0 -167
- package/dist/navigation.test.d.ts +0 -1
- package/dist/navigation.test.js +0 -130
- package/dist/node-server.test.d.ts +0 -1
- package/dist/node-server.test.js +0 -492
- package/dist/optimistic-lanes.test.d.ts +0 -1
- package/dist/optimistic-lanes.test.js +0 -45
- package/dist/patterns.test.d.ts +0 -1
- package/dist/patterns.test.js +0 -125
- package/dist/portal.test.d.ts +0 -1
- package/dist/portal.test.js +0 -99
- package/dist/react-effects.test.d.ts +0 -1
- package/dist/react-effects.test.js +0 -133
- package/dist/react-suspense.test.d.ts +0 -1
- package/dist/react-suspense.test.js +0 -194
- package/dist/react.test.d.ts +0 -1
- package/dist/react.test.js +0 -60
- package/dist/react19.test.d.ts +0 -1
- package/dist/react19.test.js +0 -176
- package/dist/reactivity-core.test.d.ts +0 -1
- package/dist/reactivity-core.test.js +0 -152
- package/dist/reconcile.test.d.ts +0 -1
- package/dist/reconcile.test.js +0 -110
- package/dist/refs.test.d.ts +0 -1
- package/dist/refs.test.js +0 -257
- package/dist/router-layout.test.d.ts +0 -1
- package/dist/router-layout.test.js +0 -249
- package/dist/router-nav.test.d.ts +0 -1
- package/dist/router-nav.test.js +0 -559
- package/dist/router-slots.test.d.ts +0 -1
- package/dist/router-slots.test.js +0 -144
- package/dist/router-speculation.test.d.ts +0 -1
- package/dist/router-speculation.test.js +0 -25
- package/dist/router-styles.test.d.ts +0 -1
- package/dist/router-styles.test.js +0 -98
- package/dist/router.test.d.ts +0 -1
- package/dist/router.test.js +0 -36
- package/dist/server-async.test.d.ts +0 -1
- package/dist/server-async.test.js +0 -216
- package/dist/server-handler.test.d.ts +0 -1
- package/dist/server-handler.test.js +0 -535
- package/dist/server-highlight.test.d.ts +0 -1
- package/dist/server-highlight.test.js +0 -32
- package/dist/server-renderer.test.d.ts +0 -1
- package/dist/server-renderer.test.js +0 -266
- package/dist/server.test.d.ts +0 -1
- package/dist/server.test.js +0 -88
- package/dist/sha256.test.d.ts +0 -1
- package/dist/sha256.test.js +0 -13
- package/dist/signal-lanes.test.d.ts +0 -1
- package/dist/signal-lanes.test.js +0 -32
- package/dist/signal.test.d.ts +0 -1
- package/dist/signal.test.js +0 -68
- package/dist/slots.test.d.ts +0 -1
- package/dist/slots.test.js +0 -187
- package/dist/snapshots.test.d.ts +0 -1
- package/dist/snapshots.test.js +0 -208
- package/dist/ssr-core-behavior.test.d.ts +0 -1
- package/dist/ssr-core-behavior.test.js +0 -620
- package/dist/ssr-core.test.d.ts +0 -1
- package/dist/ssr-core.test.js +0 -324
- package/dist/static-memory.test.d.ts +0 -1
- package/dist/static-memory.test.js +0 -26
- package/dist/storage.test.d.ts +0 -1
- package/dist/storage.test.js +0 -46
- package/dist/suspense-actions.test.d.ts +0 -1
- package/dist/suspense-actions.test.js +0 -72
- package/dist/suspense.test.d.ts +0 -1
- package/dist/suspense.test.js +0 -556
package/dist/server-handler.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type IsrStore, type RegionMeta } from "./ssr-core.js";
|
|
2
2
|
import { isDynamicPattern } from "./handler-routing.js";
|
|
3
|
+
import { type RouteCondition } from "./route-source.js";
|
|
3
4
|
import { type SegmentEntry } from "./handler-segments.js";
|
|
4
5
|
import { type CacheAdapter, type CacheSpec } from "./cache-adapter.js";
|
|
5
6
|
export type DeployTarget = "node" | "vercel" | "netlify" | "cloudflare";
|
|
@@ -24,14 +25,25 @@ export interface HandlerConfig {
|
|
|
24
25
|
source: string;
|
|
25
26
|
destination: string;
|
|
26
27
|
permanent?: boolean;
|
|
28
|
+
statusCode?: number;
|
|
29
|
+
has?: RouteCondition[];
|
|
30
|
+
missing?: RouteCondition[];
|
|
31
|
+
basePath?: boolean;
|
|
27
32
|
}>;
|
|
28
33
|
rewrites: Array<{
|
|
29
34
|
source: string;
|
|
30
35
|
destination: string;
|
|
36
|
+
has?: RouteCondition[];
|
|
37
|
+
missing?: RouteCondition[];
|
|
31
38
|
}>;
|
|
32
39
|
headers: Array<{
|
|
33
40
|
source: string;
|
|
34
|
-
headers: Record<string, string
|
|
41
|
+
headers: Record<string, string> | Array<{
|
|
42
|
+
key: string;
|
|
43
|
+
value: string;
|
|
44
|
+
}>;
|
|
45
|
+
has?: RouteCondition[];
|
|
46
|
+
missing?: RouteCondition[];
|
|
35
47
|
}>;
|
|
36
48
|
/** Resolved security headers; an empty string means "do not send". */
|
|
37
49
|
security: {
|
|
@@ -56,6 +68,8 @@ export interface HandlerConfig {
|
|
|
56
68
|
ppr: boolean;
|
|
57
69
|
pprRevalidate: number;
|
|
58
70
|
};
|
|
71
|
+
/** Page URL form: "always" (default) redirects /x to /x/, "never" redirects /x/ to /x, "ignore" serves both. */
|
|
72
|
+
trailingSlash?: "always" | "never" | "ignore";
|
|
59
73
|
}
|
|
60
74
|
export interface HandlerPage {
|
|
61
75
|
route: string;
|
|
@@ -66,12 +80,29 @@ export interface HandlerPage {
|
|
|
66
80
|
serverComponents?: boolean;
|
|
67
81
|
/** Source directory relative to the pages root, route groups kept (segment page lookup). */
|
|
68
82
|
segDir?: string;
|
|
83
|
+
/** A segment page that renders per request: reached through its synthetic route, never a URL. */
|
|
84
|
+
segment?: boolean;
|
|
69
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* A per-request metadata route. `path` is an exact URL; `prefix` and `suffix`
|
|
88
|
+
* match /sitemap/<id>.xml, where `key` ends in "/[id]".
|
|
89
|
+
*/
|
|
90
|
+
export interface MetaRoute {
|
|
91
|
+
path?: string;
|
|
92
|
+
prefix?: string;
|
|
93
|
+
suffix?: string;
|
|
94
|
+
key: string;
|
|
95
|
+
}
|
|
96
|
+
/** The API route key serving URL path p, or "" when no metadata route does. */
|
|
97
|
+
export declare function matchMetaRoute(routes: MetaRoute[] | undefined, p: string): string;
|
|
70
98
|
export interface ActionEntry {
|
|
71
99
|
id: string;
|
|
72
100
|
export: string;
|
|
73
101
|
file: string;
|
|
74
102
|
source?: string;
|
|
103
|
+
/** A hoisted inline server action; `captures` names the sealed values it receives first. */
|
|
104
|
+
inline?: boolean;
|
|
105
|
+
captures?: string[];
|
|
75
106
|
}
|
|
76
107
|
/** Build data the compiler inlines into the server bundle. */
|
|
77
108
|
export interface KrateServerData {
|
|
@@ -105,6 +136,17 @@ export interface KrateServerData {
|
|
|
105
136
|
staticPages?: Record<string, string>;
|
|
106
137
|
/** API route keys: file path under the API dir without extension ("items/[id]"). */
|
|
107
138
|
apiRoutes: string[];
|
|
139
|
+
/**
|
|
140
|
+
* Per-route request budgets in seconds (`export const maxDuration`), keyed
|
|
141
|
+
* like apiRoutes. A handler still running at the deadline is aborted
|
|
142
|
+
* (request.signal) and the request answered 504.
|
|
143
|
+
*/
|
|
144
|
+
apiMaxDuration?: Record<string, number>;
|
|
145
|
+
/**
|
|
146
|
+
* Metadata routes (robots.ts, sitemap.ts, manifest.ts) that run per request:
|
|
147
|
+
* a public URL served by the API route `key`.
|
|
148
|
+
*/
|
|
149
|
+
metaRoutes?: MetaRoute[];
|
|
108
150
|
actions: ActionEntry[];
|
|
109
151
|
hasMiddleware: boolean;
|
|
110
152
|
}
|
|
@@ -132,6 +174,12 @@ export interface StaticLayer {
|
|
|
132
174
|
export interface HandlerContext {
|
|
133
175
|
/** Keeps the instance alive for work that outlives the response. */
|
|
134
176
|
waitUntil?(work: Promise<unknown>): void;
|
|
177
|
+
/** Cloudflare only: let the request fall through to the origin when the Worker throws. */
|
|
178
|
+
passThroughOnException?(): void;
|
|
179
|
+
/** The platform's bindings (the Worker `env` on cloudflare), reachable from page code through getPlatform(). */
|
|
180
|
+
env?: unknown;
|
|
181
|
+
/** Cloudflare's `request.cf` properties. */
|
|
182
|
+
cf?: Record<string, unknown>;
|
|
135
183
|
}
|
|
136
184
|
export interface HandlerOptions {
|
|
137
185
|
target: DeployTarget;
|
|
@@ -161,5 +209,25 @@ export interface HandlerOptions {
|
|
|
161
209
|
flashSecret?: string;
|
|
162
210
|
}
|
|
163
211
|
export type KrateHandler = (request: Request, ctx?: HandlerContext) => Promise<Response>;
|
|
212
|
+
/**
|
|
213
|
+
* Runs fn with the platform of a request (or of a Worker event such as a cron
|
|
214
|
+
* trigger) published to getPlatform() / getCloudflareContext(). The generated
|
|
215
|
+
* Cloudflare Worker wraps the exports of src/cloudflare.ts with it.
|
|
216
|
+
*/
|
|
217
|
+
export declare function runWithPlatform<R>(target: DeployTarget, ctx: HandlerContext, fn: () => R): R;
|
|
218
|
+
/**
|
|
219
|
+
* The name/value pairs of a headers rule: an object, or Next's array of
|
|
220
|
+
* { key, value } where a repeated name (any case) keeps its last value.
|
|
221
|
+
*/
|
|
222
|
+
export declare function ruleHeaderPairs(h: Record<string, string> | Array<{
|
|
223
|
+
key: string;
|
|
224
|
+
value: string;
|
|
225
|
+
}>): Array<[string, string]>;
|
|
226
|
+
/**
|
|
227
|
+
* Opens the closure token of an inline server action: AES-256-GCM over the
|
|
228
|
+
* JSON of the captured values, authenticated against the action id, with the
|
|
229
|
+
* key derived from the action secret (the format the server renderer seals).
|
|
230
|
+
*/
|
|
231
|
+
export declare function openInlineToken(token: unknown, entry: ActionEntry, secret: string): Promise<unknown[]>;
|
|
164
232
|
export declare function createKrateHandler(options: HandlerOptions): KrateHandler;
|
|
165
233
|
export { isDynamicPattern };
|