@rangojs/router 0.24.3 → 0.25.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/README.md +1 -0
- package/dist/bin/rango.js +363 -39
- package/dist/testing/vitest.js +37 -4
- package/dist/types/browser/event-controller.d.ts +24 -5
- package/dist/types/browser/intercept-utils.d.ts +5 -2
- package/dist/types/browser/merge-segment-loaders.d.ts +0 -23
- package/dist/types/browser/navigation-transaction.d.ts +5 -5
- package/dist/types/browser/partial-update.d.ts +21 -13
- package/dist/types/browser/prefetch/cache.d.ts +8 -0
- package/dist/types/browser/rango-marker.d.ts +7 -0
- package/dist/types/browser/react/filter-segment-order.d.ts +10 -0
- package/dist/types/browser/react/use-handle.d.ts +20 -0
- package/dist/types/browser/react/use-href.d.ts +6 -0
- package/dist/types/browser/react/use-router.d.ts +6 -1
- package/dist/types/browser/response-adapter.d.ts +5 -3
- package/dist/types/browser/scroll-restoration.d.ts +9 -3
- package/dist/types/browser/segment-reconciler.d.ts +10 -13
- package/dist/types/browser/types.d.ts +38 -8
- package/dist/types/build/route-types/per-module-writer.d.ts +12 -0
- package/dist/types/cache/cf/cf-shell-frame.d.ts +2 -0
- package/dist/types/cache/types.d.ts +8 -0
- package/dist/types/client-urls/client-root.d.ts +4 -1
- package/dist/types/client-urls/client-urls.d.ts +28 -2
- package/dist/types/client-urls/navigation.d.ts +6 -8
- package/dist/types/client-urls/revalidate-registry.d.ts +1 -1
- package/dist/types/client-urls/server-projection.d.ts +20 -5
- package/dist/types/client-urls/types.d.ts +35 -17
- package/dist/types/client.d.ts +2 -2
- package/dist/types/client.rsc.d.ts +2 -2
- package/dist/types/decode-loader-results.d.ts +28 -7
- package/dist/types/href-client.d.ts +3 -1
- package/dist/types/index.rsc.d.ts +1 -1
- package/dist/types/loader-redirect.d.ts +2 -3
- package/dist/types/outlet-context.d.ts +7 -6
- package/dist/types/prefetch-markers.d.ts +14 -5
- package/dist/types/route-content-wrapper.d.ts +17 -14
- package/dist/types/route-definition/helpers-types.d.ts +7 -2
- package/dist/types/route-definition/resolve-handler-use.d.ts +6 -1
- package/dist/types/route-definition/rewrite.d.ts +48 -5
- package/dist/types/route-types.d.ts +2 -2
- package/dist/types/router/handler-context.d.ts +14 -2
- package/dist/types/router/intercept-resolution.d.ts +19 -46
- package/dist/types/router/lazy-includes.d.ts +7 -0
- package/dist/types/router/match-middleware/intercept-resolution.d.ts +2 -2
- package/dist/types/router/middleware.d.ts +0 -16
- package/dist/types/router/navigation-snapshot.d.ts +2 -0
- package/dist/types/router/prefetch-cache-ttl.d.ts +8 -11
- package/dist/types/router/revalidation.d.ts +8 -1
- package/dist/types/router/router-context.d.ts +4 -16
- package/dist/types/router/router-interfaces.d.ts +0 -6
- package/dist/types/router/router-options.d.ts +4 -7
- package/dist/types/router/segment-resolution/prefetch-deferral.d.ts +31 -8
- package/dist/types/router/segment-resolution/revalidation.d.ts +38 -4
- package/dist/types/router/segment-resolution.d.ts +1 -1
- package/dist/types/router/segment-wrappers.d.ts +3 -5
- package/dist/types/router/substitute-pattern-params.d.ts +19 -2
- package/dist/types/router/tracing.d.ts +2 -2
- package/dist/types/rsc/full-payload.d.ts +14 -2
- package/dist/types/rsc/helpers.d.ts +8 -0
- package/dist/types/rsc/manifest-init.d.ts +20 -0
- package/dist/types/rsc/prefetch-render-error.d.ts +22 -0
- package/dist/types/rsc/progressive-enhancement.d.ts +20 -0
- package/dist/types/rsc/rewrite-passes.d.ts +12 -2
- package/dist/types/rsc/server-action.d.ts +6 -0
- package/dist/types/rsc/shell-capture-constants.d.ts +10 -1
- package/dist/types/rsc/shell-capture.d.ts +7 -0
- package/dist/types/rsc/types.d.ts +5 -0
- package/dist/types/segment-system.d.ts +15 -0
- package/dist/types/server/context.d.ts +64 -4
- package/dist/types/server/request-context.d.ts +41 -4
- package/dist/types/server/request-headers.d.ts +12 -0
- package/dist/types/server/rewrite-trail.d.ts +8 -1
- package/dist/types/testing/e2e/index.d.ts +1 -1
- package/dist/types/testing/flight.entry.d.ts +1 -1
- package/dist/types/testing/index.d.ts +1 -1
- package/dist/types/testing/internal/client-urls-projection.d.ts +4 -3
- package/dist/types/testing/render-route.d.ts +21 -11
- package/dist/types/testing/run-loader.d.ts +7 -0
- package/dist/types/testing/run-middleware.d.ts +7 -0
- package/dist/types/testing/run-revalidate.d.ts +5 -4
- package/dist/types/testing/serve-shell-request.d.ts +41 -4
- package/dist/types/testing/shell-status.d.ts +17 -0
- package/dist/types/testing/vitest-stubs/version.d.ts +1 -0
- package/dist/types/testing/vitest.d.ts +10 -1
- package/dist/types/thenable-status.d.ts +0 -6
- package/dist/types/types/handler-context.d.ts +12 -1
- package/dist/types/types/loader-types.d.ts +4 -3
- package/dist/types/types/route-entry.d.ts +2 -1
- package/dist/types/urls/path-helper-types.d.ts +4 -2
- package/dist/types/urls/path-helper.d.ts +5 -0
- package/dist/types/vite/discovery/client-urls-projection.d.ts +55 -5
- package/dist/types/vite/discovery/state.d.ts +20 -0
- package/dist/types/vite/plugins/client-urls-revalidate-hoist.d.ts +28 -16
- package/dist/types/vite/plugins/hoist/source.d.ts +8 -7
- package/dist/types/vite/plugins/virtual-entries.d.ts +6 -0
- package/dist/types/vite/utils/prerender-utils.d.ts +7 -0
- package/dist/vite/index.js +6816 -6547
- package/package.json +1 -1
- package/skills/app-structure/SKILL.md +255 -0
- package/skills/app-structure/content-site.md +333 -0
- package/skills/app-structure/e-commerce.md +435 -0
- package/skills/app-structure/large-app.md +885 -0
- package/skills/app-structure/multi-app.md +280 -0
- package/skills/breadcrumbs/SKILL.md +6 -1
- package/skills/caching/SKILL.md +3 -1
- package/skills/catalog.json +12 -0
- package/skills/client-urls/SKILL.md +195 -32
- package/skills/composability/SKILL.md +10 -8
- package/skills/handler-use/SKILL.md +48 -9
- package/skills/hooks/handle-and-actions.md +104 -0
- package/skills/hooks/navigation.md +24 -10
- package/skills/hooks/urls.md +1 -1
- package/skills/i18n/SKILL.md +2 -1
- package/skills/intercept/SKILL.md +60 -29
- package/skills/layout/SKILL.md +6 -3
- package/skills/links/SKILL.md +151 -17
- package/skills/loader/SKILL.md +32 -10
- package/skills/middleware/SKILL.md +111 -15
- package/skills/observability/SKILL.md +11 -0
- package/skills/parallel/SKILL.md +5 -5
- package/skills/ppr/SKILL.md +43 -8
- package/skills/prerender/SKILL.md +1 -2
- package/skills/rango/SKILL.md +3 -0
- package/skills/response-routes/SKILL.md +4 -1
- package/skills/scripts/SKILL.md +12 -1
- package/skills/server-actions/SKILL.md +60 -20
- package/skills/testing/SKILL.md +1 -0
- package/skills/testing/client-components.md +13 -10
- package/skills/testing/loader.md +25 -24
- package/skills/testing/middleware.md +11 -11
- package/skills/testing/response-routes.md +4 -1
- package/skills/testing/serve-shell-request.md +85 -21
- package/skills/ux-architecture/SKILL.md +980 -0
- package/skills/view-transitions/SKILL.md +43 -10
- package/src/__augment-tests__/augmented.check.ts +28 -0
- package/src/browser/event-controller.ts +44 -18
- package/src/browser/intercept-utils.ts +3 -2
- package/src/browser/merge-segment-loaders.ts +0 -85
- package/src/browser/navigation-bridge.ts +119 -98
- package/src/browser/navigation-client.ts +20 -15
- package/src/browser/navigation-store.ts +4 -2
- package/src/browser/navigation-transaction.ts +9 -8
- package/src/browser/partial-update.ts +90 -32
- package/src/browser/prefetch/cache.ts +8 -0
- package/src/browser/prefetch/fetch.ts +13 -3
- package/src/browser/rango-marker.ts +13 -0
- package/src/browser/react/NavigationProvider.tsx +25 -7
- package/src/browser/react/filter-segment-order.ts +13 -0
- package/src/browser/react/use-action.ts +9 -15
- package/src/browser/react/use-handle.ts +63 -71
- package/src/browser/react/use-href.tsx +24 -5
- package/src/browser/react/use-link-status.ts +1 -1
- package/src/browser/react/use-navigation.ts +30 -40
- package/src/browser/react/use-reverse.ts +4 -17
- package/src/browser/react/use-router.ts +37 -6
- package/src/browser/react/use-segments.ts +8 -12
- package/src/browser/response-adapter.ts +11 -5
- package/src/browser/rsc-router.tsx +3 -1
- package/src/browser/scroll-restoration.ts +34 -20
- package/src/browser/segment-reconciler.ts +11 -29
- package/src/browser/server-action-bridge.ts +52 -16
- package/src/browser/types.ts +40 -8
- package/src/build/generate-manifest.ts +12 -1
- package/src/build/route-types/codegen.ts +6 -2
- package/src/build/route-types/per-module-writer.ts +94 -61
- package/src/cache/cache-runtime.ts +9 -0
- package/src/cache/cache-scope.ts +2 -1
- package/src/cache/cf/cf-cache-store.ts +2 -0
- package/src/cache/cf/cf-shell-frame.ts +3 -0
- package/src/cache/types.ts +8 -0
- package/src/cache/vercel/vercel-cache-store.ts +6 -1
- package/src/client-urls/client-root.tsx +10 -5
- package/src/client-urls/client-urls.ts +246 -166
- package/src/client-urls/navigation.ts +45 -38
- package/src/client-urls/revalidate-registry.ts +12 -3
- package/src/client-urls/server-projection.ts +286 -75
- package/src/client-urls/types.ts +40 -16
- package/src/client.rsc.tsx +11 -1
- package/src/client.tsx +9 -1
- package/src/decode-loader-results.ts +64 -31
- package/src/href-client.ts +3 -1
- package/src/index.rsc.ts +1 -0
- package/src/index.ts +12 -4
- package/src/loader-redirect.tsx +2 -3
- package/src/outlet-context.ts +7 -6
- package/src/prefetch-markers.ts +15 -5
- package/src/reverse.ts +3 -3
- package/src/route-content-wrapper.tsx +19 -17
- package/src/route-definition/dsl-helpers.ts +27 -7
- package/src/route-definition/helpers-types.ts +7 -2
- package/src/route-definition/resolve-handler-use.ts +23 -10
- package/src/route-definition/rewrite.ts +86 -19
- package/src/route-types.ts +1 -2
- package/src/router/find-match.ts +37 -1
- package/src/router/handler-context.ts +85 -40
- package/src/router/intercept-resolution.ts +161 -307
- package/src/router/lazy-includes.ts +43 -27
- package/src/router/loader-resolution.ts +21 -1
- package/src/router/manifest.ts +6 -8
- package/src/router/match-api.ts +11 -1
- package/src/router/match-middleware/background-revalidation.ts +2 -4
- package/src/router/match-middleware/cache-lookup.ts +16 -20
- package/src/router/match-middleware/intercept-resolution.ts +41 -60
- package/src/router/match-result.ts +31 -2
- package/src/router/middleware.ts +6 -147
- package/src/router/navigation-snapshot.ts +38 -2
- package/src/router/prefetch-cache-ttl.ts +10 -18
- package/src/router/prerender-match.ts +2 -1
- package/src/router/revalidation.ts +24 -3
- package/src/router/router-context.ts +5 -18
- package/src/router/router-interfaces.ts +0 -7
- package/src/router/router-options.ts +4 -7
- package/src/router/segment-resolution/fresh.ts +6 -2
- package/src/router/segment-resolution/helpers.ts +7 -1
- package/src/router/segment-resolution/prefetch-deferral.ts +62 -12
- package/src/router/segment-resolution/revalidation.ts +75 -35
- package/src/router/segment-resolution.ts +0 -1
- package/src/router/segment-wrappers.ts +8 -13
- package/src/router/substitute-pattern-params.ts +37 -2
- package/src/router/tracing.ts +2 -2
- package/src/router.ts +2 -9
- package/src/rsc/full-payload.ts +26 -4
- package/src/rsc/handler.ts +83 -41
- package/src/rsc/helpers.ts +13 -0
- package/src/rsc/manifest-init.ts +56 -3
- package/src/rsc/prefetch-render-error.ts +38 -0
- package/src/rsc/progressive-enhancement.ts +161 -211
- package/src/rsc/rewrite-passes.ts +56 -9
- package/src/rsc/rsc-rendering.ts +79 -23
- package/src/rsc/server-action.ts +25 -2
- package/src/rsc/shell-capture-constants.ts +22 -0
- package/src/rsc/shell-capture.ts +11 -0
- package/src/rsc/types.ts +5 -0
- package/src/segment-system.tsx +125 -119
- package/src/server/context.ts +96 -5
- package/src/server/handle-store.ts +3 -2
- package/src/server/request-context.ts +42 -3
- package/src/server/request-headers.ts +32 -0
- package/src/server/rewrite-trail.ts +55 -9
- package/src/ssr/ssr-root.tsx +6 -10
- package/src/testing/dispatch.ts +4 -5
- package/src/testing/e2e/index.ts +1 -0
- package/src/testing/flight.entry.ts +1 -0
- package/src/testing/index.ts +1 -0
- package/src/testing/internal/client-urls-projection.ts +31 -11
- package/src/testing/render-route.tsx +83 -40
- package/src/testing/run-loader.ts +26 -2
- package/src/testing/run-middleware.ts +10 -0
- package/src/testing/run-revalidate.ts +13 -6
- package/src/testing/serve-shell-request.ts +77 -4
- package/src/testing/shell-status.ts +40 -0
- package/src/testing/vitest-stubs/version.ts +1 -0
- package/src/testing/vitest.ts +74 -7
- package/src/thenable-status.ts +0 -11
- package/src/types/handler-context.ts +12 -1
- package/src/types/loader-types.ts +4 -3
- package/src/types/route-entry.ts +2 -1
- package/src/urls/include-helper.ts +38 -11
- package/src/urls/path-helper-types.ts +4 -2
- package/src/urls/path-helper.ts +16 -3
- package/src/vite/discovery/client-urls-projection.ts +205 -16
- package/src/vite/discovery/discover-routers.ts +2 -2
- package/src/vite/discovery/prerender-collection.ts +2 -6
- package/src/vite/discovery/state.ts +26 -0
- package/src/vite/plugins/client-urls-revalidate-hoist.ts +190 -77
- package/src/vite/plugins/expose-internal-ids.ts +46 -40
- package/src/vite/plugins/hoist/source.ts +8 -7
- package/src/vite/plugins/transition-when-hoist.ts +1 -0
- package/src/vite/plugins/version-plugin.ts +7 -0
- package/src/vite/plugins/version.d.ts +7 -0
- package/src/vite/plugins/virtual-entries.ts +20 -0
- package/src/vite/rango.ts +4 -1
- package/src/vite/router-discovery.ts +39 -7
- package/src/vite/utils/prerender-utils.ts +17 -0
|
@@ -17,17 +17,29 @@ export interface ClientUrlItem {
|
|
|
17
17
|
export type ClientUrlItemInput = ClientUrlItem | readonly ClientUrlItemInput[];
|
|
18
18
|
export type ClientUrlItems = readonly ClientUrlItemInput[];
|
|
19
19
|
export type ClientUrlUse = () => ClientUrlItems;
|
|
20
|
+
/**
|
|
21
|
+
* A component path(), layout() or intercept() mounts. Its optional `use`
|
|
22
|
+
* carries its own items, as a server handler's `.use` does, built with the
|
|
23
|
+
* helpers `@rangojs/router/client` exports: they come before the mount
|
|
24
|
+
* site's explicit items (an explicit loading() or transition() wins, loaders
|
|
25
|
+
* accumulate). A page component may carry loader(), loading() and
|
|
26
|
+
* transition(); a layout or intercept component loader() and loading().
|
|
27
|
+
*/
|
|
28
|
+
export type ClientUrlComponent = ComponentType & {
|
|
29
|
+
readonly use?: ClientUrlUse;
|
|
30
|
+
};
|
|
20
31
|
export type ClientPathOptions<TName extends string = string, TSearch extends SearchSchema = SearchSchema> = Pick<PathOptions<TName, TSearch>, "name" | "search" | "trailingSlash" | "ppr">;
|
|
21
|
-
export type ClientPathFn = <const TPattern extends string, const TName extends string = UnnamedRoute, const TSearch extends SearchSchema = {}>(pattern: TPattern, component:
|
|
22
|
-
export type ClientLayoutFn = <const TItems extends ClientUrlItems>(component:
|
|
32
|
+
export type ClientPathFn = <const TPattern extends string, const TName extends string = UnnamedRoute, const TSearch extends SearchSchema = {}>(pattern: TPattern, component: ClientUrlComponent, optionsOrUse?: ClientPathOptions<TName, TSearch> | ClientUrlUse, use?: ClientUrlUse) => ClientUrlItem & TypedRouteItem<TName, TPattern, unknown, TSearch>;
|
|
33
|
+
export type ClientLayoutFn = <const TItems extends ClientUrlItems>(component: ClientUrlComponent, children: () => TItems) => ClientUrlItem & TypedLayoutItem<ExtractRoutes<TItems>>;
|
|
23
34
|
export interface ClientUrlLoaderRecord {
|
|
24
35
|
readonly loader: LoaderDefinition<any, any>;
|
|
25
36
|
/**
|
|
26
37
|
* Per-loader revalidate() predicates, run on the server; empty = the
|
|
27
38
|
* router's defaults. Under the rango Vite plugin the browser and SSR copies
|
|
28
|
-
* hold the marker the build left in place of each hoisted predicate
|
|
39
|
+
* hold the marker the build left in place of each hoisted predicate; a
|
|
40
|
+
* boolean literal stays in place.
|
|
29
41
|
*/
|
|
30
|
-
readonly revalidate: readonly (ShouldRevalidateFn<any, DefaultEnv> | HoistedRevalidateRef)[];
|
|
42
|
+
readonly revalidate: readonly (ShouldRevalidateFn<any, DefaultEnv> | HoistedRevalidateRef | boolean)[];
|
|
31
43
|
/**
|
|
32
44
|
* loader(Def, { ssr: false }): document renders await this loader before
|
|
33
45
|
* first flush (see {@link LoaderOptions}). Projected into the server tree,
|
|
@@ -36,11 +48,10 @@ export interface ClientUrlLoaderRecord {
|
|
|
36
48
|
*/
|
|
37
49
|
readonly ssr?: false;
|
|
38
50
|
/**
|
|
39
|
-
* loader(Def, { prefetch: false }): a prefetch of the route
|
|
40
|
-
*
|
|
41
|
-
* {@link LoaderOptions}).
|
|
42
|
-
*
|
|
43
|
-
* urls().
|
|
51
|
+
* loader(Def, { prefetch: false }): a prefetch of the route, or of an
|
|
52
|
+
* intercept's target from its source, defers this loader and the click
|
|
53
|
+
* that adopts it runs it in its fill request (see {@link LoaderOptions}).
|
|
54
|
+
* Projected onto the materialized stub.
|
|
44
55
|
*/
|
|
45
56
|
readonly prefetch?: false;
|
|
46
57
|
}
|
|
@@ -78,7 +89,7 @@ export interface ClientUrlRouteRecord {
|
|
|
78
89
|
}
|
|
79
90
|
/**
|
|
80
91
|
* A restricted intercept declared inside clientUrls(). Compared to the server
|
|
81
|
-
* intercept() there is no `when` selector,
|
|
92
|
+
* intercept() there is no `when` selector, and the target must
|
|
82
93
|
* be a dot-local NAMED route in the same definition — every field is
|
|
83
94
|
* JSON-projectable, which is what makes the declaration legal in a
|
|
84
95
|
* "use client" module. `targetName` is stored bare (no leading dot).
|
|
@@ -111,8 +122,8 @@ export interface ClientUrlHelpers {
|
|
|
111
122
|
* the destination at once, commits the adopted prefetch with the other
|
|
112
123
|
* loaders' data, and runs only the flagged loaders in its one fill
|
|
113
124
|
* request. A `layout()` loader with the flag is flagged on every route
|
|
114
|
-
* below it. Inside intercept() the
|
|
115
|
-
* urls().
|
|
125
|
+
* below it. Inside intercept() it defers the loader in a prefetch of the
|
|
126
|
+
* intercept from its source, as in urls().
|
|
116
127
|
*/
|
|
117
128
|
readonly loader: <TData>(definition: LoaderDefinition<TData>, optionsOrUse?: Pick<LoaderOptions, "ssr" | "prefetch"> | ClientUrlUse, use?: ClientUrlUse) => ClientUrlItem;
|
|
118
129
|
readonly loading: (component: ReactNode) => ClientUrlItem;
|
|
@@ -123,22 +134,24 @@ export interface ClientUrlHelpers {
|
|
|
123
134
|
* names, ...): the build moves it out of this "use client" module. It may
|
|
124
135
|
* reference imports and globals only; a binding of this module, `this`,
|
|
125
136
|
* `import()`, a browser global, an `async` function or an import from a
|
|
126
|
-
* "use client" module fails the build with its file and line.
|
|
137
|
+
* "use client" module fails the build with its file and line. A boolean
|
|
138
|
+
* is shorthand for `() => true` / `() => false`.
|
|
127
139
|
*/
|
|
128
|
-
readonly revalidate: (fn: ShouldRevalidateFn<any, DefaultEnv>) => ClientUrlItem;
|
|
140
|
+
readonly revalidate: (fn: ShouldRevalidateFn<any, DefaultEnv> | boolean) => ClientUrlItem;
|
|
129
141
|
/**
|
|
130
142
|
* Declare an intercept for a named route in THIS definition. The target is
|
|
131
143
|
* dot-local (`.detail`); scoping is module-local — only navigations whose
|
|
132
144
|
* origin is inside this clientUrls() group render the intercept. `use` may
|
|
133
145
|
* contain loader() and loading() only.
|
|
134
146
|
*/
|
|
135
|
-
readonly intercept: (slotName: `@${string}`, targetName: `.${string}`, component:
|
|
147
|
+
readonly intercept: (slotName: `@${string}`, targetName: `.${string}`, component: ClientUrlComponent, use?: ClientUrlUse) => ClientUrlItem;
|
|
136
148
|
/**
|
|
137
149
|
* Opt THIS route into transition-driven navigation: the canonical commit
|
|
138
150
|
* holds previous content instead of re-streaming the loading() fallback,
|
|
139
151
|
* and on experimental React the config's ViewTransition classes apply.
|
|
140
152
|
* Data-only — no `when` gate (server-executed; declare it in the server
|
|
141
|
-
* tree). Valid inside a path() use callback
|
|
153
|
+
* tree). Valid inside a path() use callback, or a page component's
|
|
154
|
+
* `.use`.
|
|
142
155
|
*/
|
|
143
156
|
readonly transition: (config: ClientTransitionConfig) => ClientUrlItem;
|
|
144
157
|
}
|
|
@@ -149,6 +162,11 @@ export interface ClientUrlPatterns<TRoutes extends Record<string, any> = Record<
|
|
|
149
162
|
readonly intercepts: readonly ClientUrlInterceptRecord[];
|
|
150
163
|
readonly [CLIENT_URL_PATTERNS_BRAND]: void;
|
|
151
164
|
readonly _routes?: TRoutes;
|
|
152
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Match an absolute pathname against the routes joined to `mount`, the
|
|
167
|
+
* include() mount pattern (default "/"); params include the mount's. A
|
|
168
|
+
* `foreign` pattern that wins is a match whose routeKey is that pattern.
|
|
169
|
+
*/
|
|
170
|
+
match(pathname: string, mount?: string, foreign?: readonly string[]): TrieMatchResult | null;
|
|
153
171
|
}
|
|
154
172
|
export {};
|
package/dist/types/client.d.ts
CHANGED
|
@@ -95,8 +95,8 @@ export interface OutletState {
|
|
|
95
95
|
}
|
|
96
96
|
export declare function useOutlet(): OutletState;
|
|
97
97
|
export { useLoader, useFetchLoader, useRefreshLoaders, type LoadFunction, type UseLoaderResult, type UseFetchLoaderResult, type UseLoaderOptions, } from "./use-loader.js";
|
|
98
|
-
export { clientUrls } from "./client-urls/client-urls.js";
|
|
99
|
-
export type { ClientUrlPatterns, ClientUrlRouteRecord, } from "./client-urls/client-urls.js";
|
|
98
|
+
export { clientUrls, loader, loading, revalidate, transition, } from "./client-urls/client-urls.js";
|
|
99
|
+
export type { ClientUrlComponent, ClientUrlPatterns, ClientUrlRouteRecord, ClientUrlUse, } from "./client-urls/client-urls.js";
|
|
100
100
|
/**
|
|
101
101
|
* Props for the ErrorBoundary component
|
|
102
102
|
*/
|
|
@@ -12,8 +12,8 @@ import * as Html from "./html.js";
|
|
|
12
12
|
export { Outlet, ParallelOutlet, useOutlet, type OutletState, useLoader, ErrorBoundary, type ErrorBoundaryProps, } from "./client.js";
|
|
13
13
|
export { useFetchLoader, useRefreshLoaders, type LoadFunction, type UseLoaderResult, type UseFetchLoaderResult, type UseLoaderOptions, } from "./use-loader.js";
|
|
14
14
|
export { createLoader } from "./route-definition.js";
|
|
15
|
-
export { clientUrls } from "./client-urls/client-urls.js";
|
|
16
|
-
export type { ClientUrlPatterns, ClientUrlRouteRecord, } from "./client-urls/client-urls.js";
|
|
15
|
+
export { clientUrls, loader, loading, revalidate, transition, } from "./client-urls/client-urls.js";
|
|
16
|
+
export type { ClientUrlComponent, ClientUrlPatterns, ClientUrlRouteRecord, ClientUrlUse, } from "./client-urls/client-urls.js";
|
|
17
17
|
export { useRouter } from "./browser/react/use-router.js";
|
|
18
18
|
export { usePathname } from "./browser/react/use-pathname.js";
|
|
19
19
|
export { useSearchParams } from "./browser/react/use-search-params.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import { type ErrorInfo, type ResolvedSegment } from "./types.js";
|
|
2
3
|
/**
|
|
3
4
|
* Markers for loader-thrown AUTHORITY SIGNALS (notFound()/redirect()) on the
|
|
4
5
|
* reconstructed read-site error. Siblings of LOADER_ERROR_FALLBACK, routed
|
|
@@ -11,16 +12,36 @@ import type { ReactNode } from "react";
|
|
|
11
12
|
* Only decodeLoaderEntry (the read-site path — client components, so the
|
|
12
13
|
* throw lands in the router-owned boundary; during document SSR, Fizz emits
|
|
13
14
|
* the Suspense fallback and replays the throw at hydration) throws these.
|
|
14
|
-
* decodeLoaderResults runs during the
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
15
|
+
* decodeLoaderResults runs during the tree build on settled results, where a
|
|
16
|
+
* throw would collapse the whole payload — it routes signals through the
|
|
17
|
+
* errorFallback slot instead (same visual: the slot replaces the children
|
|
18
|
+
* under OutletProvider). The document lane's `{ ssr: false }` results take
|
|
19
|
+
* this route (segment-system buildLoaderStreams): they are settled before the
|
|
20
|
+
* tree is built, and the read-site throw would land in the Fizz shell with no
|
|
21
|
+
* boundary to absorb it.
|
|
21
22
|
*/
|
|
22
23
|
export declare const LOADER_NOT_FOUND_FALLBACK: unique symbol;
|
|
23
24
|
export declare const LOADER_REDIRECT: unique symbol;
|
|
25
|
+
/**
|
|
26
|
+
* A failed loader entry's error, rebuilt with the ErrorInfo identity
|
|
27
|
+
* (name/stack/code/cause) instead of a stripped generic Error.
|
|
28
|
+
*/
|
|
29
|
+
export declare function loaderResultError(result: {
|
|
30
|
+
error: ErrorInfo;
|
|
31
|
+
}): Error;
|
|
32
|
+
/** A loader that threw: not ok, and not a notFound()/redirect() signal. */
|
|
33
|
+
export declare function isLoaderError(result: unknown): result is {
|
|
34
|
+
error: ErrorInfo;
|
|
35
|
+
fallback: ReactNode | null;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* The error of the first loader that threw while it re-ran in an action's
|
|
39
|
+
* revalidation, for useAction()'s `revalidationError`. The loader itself
|
|
40
|
+
* throws at its read (segment-system buildLoaderStreams), and the action
|
|
41
|
+
* resolves. A stale revalidation rejects with it instead and commits nothing
|
|
42
|
+
* (partial-update.ts). A notFound()/redirect() is a signal, not an error.
|
|
43
|
+
*/
|
|
44
|
+
export declare function revalidationErrorOf(segments?: ResolvedSegment[]): Promise<Error | undefined>;
|
|
24
45
|
export declare function decodeLoaderResults(resolvedData: any[], loaderIds: string[]): {
|
|
25
46
|
loaderData: Record<string, any>;
|
|
26
47
|
errorFallback: ReactNode;
|
|
@@ -169,7 +169,9 @@ declare global {
|
|
|
169
169
|
* Type-safe href function for client-side use
|
|
170
170
|
*
|
|
171
171
|
* Without mount: identity function, validates absolute paths at compile time.
|
|
172
|
-
* With mount: prepends mount
|
|
172
|
+
* With mount: prepends the mount as given. `useMount()` under a parameterized
|
|
173
|
+
* include returns its pattern (`/:accountId`), which this does not fill: use
|
|
174
|
+
* `useHref()` there, which substitutes the mount params.
|
|
173
175
|
*
|
|
174
176
|
* @param path - A valid path matching one of the registered route patterns
|
|
175
177
|
* @param mount - Optional mount prefix from useMount() for include-scoped paths
|
|
@@ -14,7 +14,7 @@ export type { RangoOptions, SSRStreamMode, SSROptions, ResolveStreamingContext,
|
|
|
14
14
|
export type { OriginCheckConfig, OriginCheckContext, OriginCheckPhase, } from "./rsc/origin-guard.js";
|
|
15
15
|
export type { ShellCaptureDebug, ShellCaptureDebugEvent, } from "./rsc/shell-capture.js";
|
|
16
16
|
export { createLoader, redirect, type RouteHelpers, type RouteHandlers, layout, cache, middleware, revalidate, loader, loading, parallel, intercept, errorBoundary, notFoundBoundary, transition, } from "./route-definition.js";
|
|
17
|
-
export { rewrite, type Rewrite, type RewriteFunction, } from "./route-definition/rewrite.js";
|
|
17
|
+
export { rewrite, type Rewrite, type RewriteFunction, type RewriteShell, } from "./route-definition/rewrite.js";
|
|
18
18
|
export { RewriteLoopError } from "./errors.js";
|
|
19
19
|
export type { RouteUseItem, LayoutUseItem, AllUseItems, UseItems, HandlerUseItem, } from "./route-types.js";
|
|
20
20
|
export { createHandle, isHandle, type Handle } from "./handle.js";
|
|
@@ -9,9 +9,8 @@ import type { ReactNode } from "react";
|
|
|
9
9
|
*
|
|
10
10
|
* Own module (not route-content-wrapper.tsx) because BOTH consumers need it
|
|
11
11
|
* without a cycle: the StreamedLoaderErrorBoundary redirect branch (read-site
|
|
12
|
-
* throw path) and decodeLoaderResults (
|
|
13
|
-
*
|
|
14
|
-
* in the errorFallback slot instead).
|
|
12
|
+
* throw path) and decodeLoaderResults (the tree build's settled results, which
|
|
13
|
+
* cannot throw — it plants this element in the errorFallback slot instead).
|
|
15
14
|
*/
|
|
16
15
|
export declare function LoaderRedirect({ to, state, }: {
|
|
17
16
|
to: string;
|
|
@@ -12,18 +12,19 @@ export interface OutletContextValue {
|
|
|
12
12
|
* $$id. A value may be a pending Promise (loader still streaming) or an
|
|
13
13
|
* already-settled result entry. useLoader `use()`es a pending value at the
|
|
14
14
|
* read site — implicit suspension to the nearest consumer Suspense boundary —
|
|
15
|
-
* and decodes via decodeLoaderEntry. Populated instead of `loaderData`
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* and decodes via decodeLoaderEntry. Populated instead of `loaderData` for
|
|
16
|
+
* a route's or layout's loaders on every lane; forceAwait/action lanes hand
|
|
17
|
+
* settled entries. `loaderData` is a slot's decoded aggregate.
|
|
18
18
|
*/
|
|
19
19
|
loaderStreams?: Record<string, unknown>;
|
|
20
20
|
/**
|
|
21
21
|
* Loader $$ids on this segment that the render awaited before first flush
|
|
22
22
|
* (loader(Def, { ssr: false })). Dev-diagnostic input only: useLoader uses
|
|
23
23
|
* it to warn when a read still suspends during SSR on a render that awaited
|
|
24
|
-
* flagged loaders (ssr-suspension-warning.ts). Present only
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* flagged loaders (ssr-suspension-warning.ts). Present only where a
|
|
25
|
+
* segment carries flagged loaders (document and shell-capture renders, and
|
|
26
|
+
* a client lane that re-renders their segments); a settled read never
|
|
27
|
+
* suspends, so it never warns.
|
|
27
28
|
*/
|
|
28
29
|
awaitedLoaderIds?: readonly string[];
|
|
29
30
|
parent?: OutletContextValue | null;
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The wire markers of `prefetch: false`
|
|
3
|
-
* shared by the browser
|
|
4
|
-
* (router/segment-resolution/prefetch-deferral.ts requestKind
|
|
5
|
-
* free, like segment-fragments.ts:
|
|
6
|
-
*
|
|
2
|
+
* The wire markers of prefetches and of `prefetch: false`
|
|
3
|
+
* (docs/design/prefetch-false.md): shared by the browser and the server
|
|
4
|
+
* (router/segment-resolution/prefetch-deferral.ts requestKind,
|
|
5
|
+
* rsc/prefetch-render-error.ts). Dependency free, like segment-fragments.ts:
|
|
6
|
+
* the browser must not import the server modules that use them.
|
|
7
7
|
*/
|
|
8
8
|
/** Request header of a `<Link>` prefetch (browser/prefetch/fetch.ts). */
|
|
9
9
|
export declare const PREFETCH_HEADER = "X-Rango-Prefetch";
|
|
10
10
|
/** Query param of a fill request (browser/navigation-client.ts). */
|
|
11
11
|
export declare const FILL_PARAM = "_rsc_fill";
|
|
12
|
+
/**
|
|
13
|
+
* The last row of a prefetch whose render reported an error
|
|
14
|
+
* (rsc/prefetch-render-error.ts): a Flight hint with a code React does not
|
|
15
|
+
* dispatch, so the decoder skips it (pinned by
|
|
16
|
+
* src/__tests__/flight-unknown-hint.test.ts), and browser/response-adapter.ts
|
|
17
|
+
* reads the stream as not ended cleanly. Five bytes: teeWithCompletion keeps
|
|
18
|
+
* the last five.
|
|
19
|
+
*/
|
|
20
|
+
export declare const PREFETCH_FAILED_ROW = ":H_0\n";
|
|
@@ -23,34 +23,37 @@ import type { ResolvedSegment } from "./types.js";
|
|
|
23
23
|
*/
|
|
24
24
|
export declare class StreamedLoaderErrorBoundary extends Component<{
|
|
25
25
|
children: ReactNode;
|
|
26
|
-
|
|
26
|
+
reset: unknown[];
|
|
27
27
|
}, {
|
|
28
28
|
error: unknown;
|
|
29
|
-
|
|
29
|
+
reset: unknown[];
|
|
30
30
|
}> {
|
|
31
31
|
state: {
|
|
32
32
|
error: unknown;
|
|
33
|
-
|
|
33
|
+
reset: unknown[];
|
|
34
34
|
};
|
|
35
35
|
static getDerivedStateFromError(error: unknown): {
|
|
36
36
|
error: unknown;
|
|
37
37
|
};
|
|
38
38
|
/**
|
|
39
39
|
* A caught marker (redirect, notFound, error fallback) belongs to ONE route
|
|
40
|
-
* + params
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
40
|
+
* + params and ONE delivery of the segment's loader data. `reset` is the
|
|
41
|
+
* segment's id-params identity followed by each of its loaders' data; the
|
|
42
|
+
* error clears when any of them changes. Group-keyed segments
|
|
43
|
+
* (ResolvedSegment.clientGroup) keep this instance alive across in-group
|
|
44
|
+
* navigations, so a redirect caught for /legacy must not keep rendering
|
|
45
|
+
* LoaderRedirect for /state. A rerun hands a loader new data, a held loader
|
|
46
|
+
* keeps its own: a later action or navigation that re-ran the loader clears
|
|
47
|
+
* an error fallback left by an earlier failure, and a tree that re-ran
|
|
48
|
+
* nothing here keeps it.
|
|
45
49
|
*/
|
|
46
|
-
static getDerivedStateFromProps(
|
|
47
|
-
|
|
50
|
+
static getDerivedStateFromProps({ reset }: {
|
|
51
|
+
reset: unknown[];
|
|
48
52
|
}, state: {
|
|
49
|
-
|
|
50
|
-
resetKey?: string;
|
|
53
|
+
reset: unknown[];
|
|
51
54
|
}): {
|
|
52
|
-
error:
|
|
53
|
-
|
|
55
|
+
error: null;
|
|
56
|
+
reset: unknown[];
|
|
54
57
|
} | null;
|
|
55
58
|
render(): ReactNode;
|
|
56
59
|
}
|
|
@@ -105,7 +105,7 @@ export type RouteHelpers<T extends RouteDefinition, TEnv> = {
|
|
|
105
105
|
* // With loaders and revalidation (revalidate() goes on the loader;
|
|
106
106
|
* // an intercept-level revalidate() throws)
|
|
107
107
|
* intercept("@modal", "card", () => <CardModal />, () => [
|
|
108
|
-
* loader(CardModalLoader, () => [revalidate(
|
|
108
|
+
* loader(CardModalLoader, () => [revalidate(false)]),
|
|
109
109
|
* ])
|
|
110
110
|
*
|
|
111
111
|
* // Conditional activation via the config object's `when` selector
|
|
@@ -186,6 +186,9 @@ export type RouteHelpers<T extends RouteDefinition, TEnv> = {
|
|
|
186
186
|
* revalidate(({ defaultShouldRevalidate }) =>
|
|
187
187
|
* ({ defaultShouldRevalidate: true })
|
|
188
188
|
* )
|
|
189
|
+
*
|
|
190
|
+
* // Shorthand for a constant hard decision: revalidate(() => false)
|
|
191
|
+
* revalidate(false)
|
|
189
192
|
* ```
|
|
190
193
|
* Not valid directly inside intercept() use() (throws at definition time):
|
|
191
194
|
* intercepts only revalidate their loaders, so attach it there with
|
|
@@ -196,8 +199,10 @@ export type RouteHelpers<T extends RouteDefinition, TEnv> = {
|
|
|
196
199
|
* for downstream revalidators),
|
|
197
200
|
* - or nothing / `null` / `undefined` (defer — leaves the suggestion
|
|
198
201
|
* unchanged and continues to the next revalidator).
|
|
202
|
+
* Or `true` / `false`: shorthand for `() => true` / `() => false`. A
|
|
203
|
+
* defer has no shorthand; write the function.
|
|
199
204
|
*/
|
|
200
|
-
revalidate: (fn: ShouldRevalidateFn<any, TEnv>) => RevalidateItem;
|
|
205
|
+
revalidate: (fn: ShouldRevalidateFn<any, TEnv> | boolean) => RevalidateItem;
|
|
201
206
|
/**
|
|
202
207
|
* Attach a data loader to the current route/layout
|
|
203
208
|
* ```typescript
|
|
@@ -8,7 +8,7 @@ import type { AllUseItems } from "../route-types.js";
|
|
|
8
8
|
export declare function resolveHandlerUse(handler: unknown): (() => any[]) | undefined;
|
|
9
9
|
/**
|
|
10
10
|
* Validate every item an intercept's merged use() returned (explicit use()
|
|
11
|
-
* and handler.use) against MOUNT_SITE_ALLOWED_TYPES.intercept, plus
|
|
11
|
+
* and handler.use) against MOUNT_SITE_ALLOWED_TYPES.intercept, plus three
|
|
12
12
|
* structural rules:
|
|
13
13
|
* - a nested layout() is only the modal chrome (intercept() keeps its
|
|
14
14
|
* handler), so it may not carry use() items of its own;
|
|
@@ -16,10 +16,15 @@ export declare function resolveHandlerUse(handler: unknown): (() => any[]) | und
|
|
|
16
16
|
* it was not returned; its orphan form re-parents the following siblings
|
|
17
17
|
* onto that entry, so it is rejected the same way. Inside a path, cache()
|
|
18
18
|
* writes `sinks.cache` instead (dsl-helpers.ts cache()).
|
|
19
|
+
* - middleware on a `capturedLayouts` entry is rejected like `sinks.middleware`:
|
|
20
|
+
* it is an unreturned middleware(fn, () => [...]) or one called inside the
|
|
21
|
+
* chrome layout's use(), and nothing would run it.
|
|
19
22
|
*/
|
|
20
23
|
export declare function validateInterceptUseItems(items: AllUseItems[], capturedLayouts: readonly {
|
|
21
24
|
type: string;
|
|
25
|
+
middleware?: readonly unknown[];
|
|
22
26
|
}[], slotName: string, routeName: string, sinks: {
|
|
27
|
+
readonly middleware: readonly unknown[];
|
|
23
28
|
readonly revalidate: readonly unknown[];
|
|
24
29
|
readonly errorBoundary: readonly unknown[];
|
|
25
30
|
readonly notFoundBoundary: readonly unknown[];
|
|
@@ -16,6 +16,16 @@ export type RewriteTarget = {
|
|
|
16
16
|
readonly search?: Record<string, unknown>;
|
|
17
17
|
};
|
|
18
18
|
export declare function describeRewriteTarget(target: RewriteTarget): string;
|
|
19
|
+
/**
|
|
20
|
+
* Which PPR shell a rewritten request reads and captures
|
|
21
|
+
* (`rewrite(...).shell()`); without a call, none.
|
|
22
|
+
* - `"visitor"`: its own, keyed by the visitor's URL and the target, captured
|
|
23
|
+
* with the visitor's location and `ctx.rewrittenFrom`.
|
|
24
|
+
* - `"target"`: the target's shared shell. `usePathname()` reads the target's
|
|
25
|
+
* path on a HIT, and values set before the throw are baked in: for a page
|
|
26
|
+
* that renders neither (a lock or promo page).
|
|
27
|
+
*/
|
|
28
|
+
export type RewriteShell = "visitor" | "target";
|
|
19
29
|
/**
|
|
20
30
|
* The value `rewrite()` returns, thrown by middleware. An Error, so a throw
|
|
21
31
|
* where a rewrite is not supported fails loudly with the rule in its message.
|
|
@@ -23,7 +33,34 @@ export declare function describeRewriteTarget(target: RewriteTarget): string;
|
|
|
23
33
|
export declare class Rewrite extends Error {
|
|
24
34
|
name: "Rewrite";
|
|
25
35
|
readonly target: RewriteTarget;
|
|
26
|
-
|
|
36
|
+
/** The `shell()` choice; undefined: no shell. */
|
|
37
|
+
readonly shellAudience: RewriteShell | undefined;
|
|
38
|
+
/** `disallowMutations()`: a mutation is refused, not moved, before its action runs. */
|
|
39
|
+
readonly mutationsDisallowed: boolean;
|
|
40
|
+
constructor(target: RewriteTarget, shellAudience?: RewriteShell, mutationsDisallowed?: boolean);
|
|
41
|
+
/**
|
|
42
|
+
* A copy that picks the PPR shell of a `ppr` target ({@link RewriteShell}),
|
|
43
|
+
* so a rewrite kept in a module constant keeps its own choice:
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* throw rewrite("item", { id }).shell("visitor");
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
shell(audience: RewriteShell): Rewrite;
|
|
50
|
+
/**
|
|
51
|
+
* A copy for a lock: global middleware's rewrite of a mutation (a server
|
|
52
|
+
* action, a form post, any non-GET request) is an error before the action
|
|
53
|
+
* runs, instead of moving the mutation to the target. GET and HEAD rewrite
|
|
54
|
+
* as usual.
|
|
55
|
+
*
|
|
56
|
+
* ```ts
|
|
57
|
+
* throw rewrite("maintenance").disallowMutations();
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* Route middleware runs after the action, so there it cannot refuse it: the
|
|
61
|
+
* render moves to the target, dev warns, and production logs one error.
|
|
62
|
+
*/
|
|
63
|
+
disallowMutations(): Rewrite;
|
|
27
64
|
}
|
|
28
65
|
/** Whether `value` is a Rewrite thrown by `rewrite()` (ctx.isRewrite). */
|
|
29
66
|
export declare function isRewrite(value: unknown): value is Rewrite;
|
|
@@ -40,17 +77,23 @@ export type RewriteFunction<TRoutes = DefaultReverseRouteMap> = ((path: `/${stri
|
|
|
40
77
|
* ```ts
|
|
41
78
|
* router.use(async (ctx, next) => {
|
|
42
79
|
* if (!locked || ctx.pathname === "/maintenance") return next();
|
|
43
|
-
* throw rewrite("maintenance");
|
|
80
|
+
* throw rewrite("maintenance").disallowMutations();
|
|
44
81
|
* });
|
|
45
82
|
* ```
|
|
46
83
|
*
|
|
47
84
|
* The request runs again as the target (global middleware, route
|
|
48
85
|
* middleware, render) with the same request context: values set before the
|
|
49
86
|
* throw stay readable. `ctx.url` is the target; `ctx.rewrittenFrom` is the
|
|
50
|
-
* visitor's URL.
|
|
87
|
+
* visitor's URL. A mutation that global middleware rewrites moves to the
|
|
88
|
+
* target before its action runs, so the page's forms keep working; a lock
|
|
89
|
+
* refuses it with `.disallowMutations()`. A `ppr` target gets no shell unless
|
|
90
|
+
* `.shell()` picks one ({@link RewriteShell}). See the `/middleware` skill.
|
|
51
91
|
*/
|
|
52
92
|
export declare const rewrite: RewriteFunction;
|
|
53
|
-
/**
|
|
54
|
-
|
|
93
|
+
/**
|
|
94
|
+
* A dispatch site that cannot honor a rewrite. "mutation" is the refusal
|
|
95
|
+
* `.disallowMutations()` asked for, not a misuse.
|
|
96
|
+
*/
|
|
97
|
+
export type RewriteSite = "mutation" | "body-read" | "loader-fetch";
|
|
55
98
|
/** The error a rewrite becomes at a site that cannot honor it. */
|
|
56
99
|
export declare function rewriteNotSupported(rewrite: Rewrite, site: RewriteSite): Error;
|
|
@@ -134,7 +134,7 @@ export type IncludeItem = {
|
|
|
134
134
|
* include cannot collide with siblings declared outside it.
|
|
135
135
|
*/
|
|
136
136
|
includeScope?: string;
|
|
137
|
-
};
|
|
137
|
+
} & import("./server/context.js").IncludeScopePosition;
|
|
138
138
|
};
|
|
139
139
|
/**
|
|
140
140
|
* Typed include item that carries nested routes as phantom type
|
|
@@ -156,7 +156,7 @@ export type RouteUseItem = LayoutItem | ParallelItem | InterceptItem | Middlewar
|
|
|
156
156
|
/** Items that can be used inside a response route (path.json(), etc.) */
|
|
157
157
|
export type ResponseRouteUseItem = MiddlewareItem | CacheItem;
|
|
158
158
|
export type ParallelUseItem = RevalidateItem | LoaderItem | LoadingItem | ErrorBoundaryItem | NotFoundBoundaryItem | TransitionItem;
|
|
159
|
-
export type InterceptUseItem =
|
|
159
|
+
export type InterceptUseItem = LoaderItem | LoadingItem | LayoutItem | RouteItem | TransitionItem;
|
|
160
160
|
export type LoaderUseItem = RevalidateItem | CacheItem;
|
|
161
161
|
/**
|
|
162
162
|
* Allow composition factories in use() callbacks.
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Creates the handler context object passed to route handlers, middleware, and loaders.
|
|
5
5
|
*/
|
|
6
6
|
import type { InternalHandlerContext } from "../types";
|
|
7
|
+
import { type ReverseScope, type ScopableReverse } from "../server/context.js";
|
|
7
8
|
/**
|
|
8
9
|
* `headers` whose mutating methods run `assertWrite(method)` first. Shared by
|
|
9
10
|
* the handler ctx (createHandlerContext) and the middleware ctx
|
|
@@ -11,6 +12,16 @@ import type { InternalHandlerContext } from "../types";
|
|
|
11
12
|
*/
|
|
12
13
|
export declare function guardHeaderWrites(headers: Headers, assertWrite: (method: string | symbol) => void): Headers;
|
|
13
14
|
export { stripInternalParams } from "./internal-params.js";
|
|
15
|
+
/**
|
|
16
|
+
* The ctx a layout's or parallel slot's handler gets: a prototype child of
|
|
17
|
+
* the request's one handler ctx with its own `reverse` in the segment's
|
|
18
|
+
* ReverseScope, so `.name` resolves in the module that declared the segment.
|
|
19
|
+
* The scope rides the object, not the call frame: it holds after an `await`
|
|
20
|
+
* and in a component the ctx is handed to. Every other field reads through
|
|
21
|
+
* live (`_currentSegmentId` as resolution moves it, ctx.set values).
|
|
22
|
+
* `_reverseScope` keys a "use cache" call that takes this ctx (cache-runtime.ts).
|
|
23
|
+
*/
|
|
24
|
+
export declare function withReverseScope<C>(ctx: C, scope: ReverseScope | undefined): C;
|
|
14
25
|
/**
|
|
15
26
|
* Create a reverse function for URL generation from route names.
|
|
16
27
|
* Used by both HandlerContext and MiddlewareContext.
|
|
@@ -19,9 +30,10 @@ export { stripInternalParams } from "./internal-params.js";
|
|
|
19
30
|
* generation. This enables auto-filling mount params from include() prefixes:
|
|
20
31
|
* inner handlers can call ctx.reverse(".sibling") without explicitly passing
|
|
21
32
|
* params that are already known from the current URL match.
|
|
22
|
-
* Explicitly passed hrefParams take priority over currentParams.
|
|
33
|
+
* Explicitly passed hrefParams take priority over currentParams. A required
|
|
34
|
+
* param that neither supplies throws `Missing param`.
|
|
23
35
|
*/
|
|
24
|
-
export declare function createReverseFunction(routeMap: Record<string, string>, currentRoutePrefix?: string, currentParams?: Record<string, string>, rootScoped?: boolean):
|
|
36
|
+
export declare function createReverseFunction(routeMap: Record<string, string>, currentRoutePrefix?: string, currentParams?: Record<string, string>, rootScoped?: boolean): ScopableReverse;
|
|
25
37
|
/**
|
|
26
38
|
* Create HandlerContext with typed env/var/get/set
|
|
27
39
|
*/
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import type { EntryData, InterceptEntry, InterceptSelectorContext } from "../server/context";
|
|
8
8
|
import type { HandlerContext, ResolvedSegment } from "../types";
|
|
9
9
|
import type { SegmentResolutionDeps } from "./types.js";
|
|
10
|
+
import type { RevalidationContext } from "./router-context.js";
|
|
10
11
|
/**
|
|
11
12
|
* Check if an intercept's when conditions are satisfied.
|
|
12
13
|
* All when() functions must return true for the intercept to activate.
|
|
@@ -37,57 +38,29 @@ export declare function findInterceptForRoute(targetRouteKey: string, fromEntry:
|
|
|
37
38
|
intercept: InterceptEntry;
|
|
38
39
|
entry: EntryData;
|
|
39
40
|
} | null;
|
|
41
|
+
/** The segment id of `intercept`'s slot on `parentEntry`. */
|
|
42
|
+
export declare function interceptSlotId(parentEntry: EntryData, intercept: InterceptEntry): string;
|
|
40
43
|
/**
|
|
41
|
-
*
|
|
44
|
+
* Every segment id an intercept's slot owns, in order: the slot, then one
|
|
45
|
+
* loader segment per loader in declaration order, run or not. A request that
|
|
46
|
+
* resolves the intercept lists them in `matched` (match-result.ts).
|
|
42
47
|
*/
|
|
43
|
-
export declare function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
nextUrl: URL;
|
|
49
|
-
routeKey: string;
|
|
50
|
-
actionContext?: {
|
|
51
|
-
actionId?: string;
|
|
52
|
-
actionUrl?: URL;
|
|
53
|
-
actionResult?: any;
|
|
54
|
-
formData?: FormData;
|
|
55
|
-
};
|
|
56
|
-
stale?: boolean;
|
|
57
|
-
}, options?: {
|
|
48
|
+
export declare function interceptSegmentIds(parentEntry: EntryData, intercept: InterceptEntry): string[];
|
|
49
|
+
/**
|
|
50
|
+
* Resolve an intercept entry: its slot segment, then its loader segments.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveInterceptEntry<TEnv>(interceptEntry: InterceptEntry, parentEntry: EntryData, params: Record<string, string>, context: HandlerContext<any, TEnv>, belongsToRoute: boolean, deps: SegmentResolutionDeps<TEnv>, revalidationContext?: RevalidationContext, options?: {
|
|
58
53
|
/**
|
|
59
|
-
*
|
|
60
|
-
* background re-render paths (proactive caching, stale background
|
|
54
|
+
* Set ONLY by the post-response background re-render (stale background
|
|
61
55
|
* revalidation), whose sole purpose is to re-render the segment tree to
|
|
62
|
-
* populate the cache
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* which the background render reuses. Re-running middleware here would fire
|
|
66
|
-
* its side effects a SECOND time, and a middleware that short-circuits with
|
|
67
|
-
* a Response would `throw` and silently abort the cache write. Never set on
|
|
68
|
-
* the foreground path.
|
|
56
|
+
* populate the cache: a handler error rejects instead of rendering the
|
|
57
|
+
* error boundary, so a failure is never cached. Never set on the
|
|
58
|
+
* foreground path.
|
|
69
59
|
*/
|
|
70
|
-
|
|
60
|
+
background?: boolean;
|
|
71
61
|
}): Promise<ResolvedSegment[]>;
|
|
72
62
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
63
|
+
* The loader segments of a cached intercept slot, on a cache hit: the slot
|
|
64
|
+
* keeps its cached component and layout, its loaders are never cached.
|
|
75
65
|
*/
|
|
76
|
-
export declare function resolveInterceptLoadersOnly<TEnv>(interceptEntry: InterceptEntry, parentEntry: EntryData,
|
|
77
|
-
clientSegmentIds: Set<string>;
|
|
78
|
-
prevParams: Record<string, string>;
|
|
79
|
-
request: Request;
|
|
80
|
-
prevUrl: URL;
|
|
81
|
-
nextUrl: URL;
|
|
82
|
-
routeKey: string;
|
|
83
|
-
actionContext?: {
|
|
84
|
-
actionId?: string;
|
|
85
|
-
actionUrl?: URL;
|
|
86
|
-
actionResult?: any;
|
|
87
|
-
formData?: FormData;
|
|
88
|
-
};
|
|
89
|
-
stale?: boolean;
|
|
90
|
-
}): Promise<{
|
|
91
|
-
loaderDataPromise: Promise<any[]> | any[];
|
|
92
|
-
loaderIds: string[];
|
|
93
|
-
} | null>;
|
|
66
|
+
export declare function resolveInterceptLoadersOnly<TEnv>(interceptEntry: InterceptEntry, parentEntry: EntryData, context: HandlerContext<any, TEnv>, belongsToRoute: boolean, deps: SegmentResolutionDeps<TEnv>, revalidationContext: RevalidationContext): Promise<ResolvedSegment[]>;
|
|
@@ -24,3 +24,10 @@ export declare function findLazyIncludes<TEnv = any>(items: AllUseItems[]): Arra
|
|
|
24
24
|
* Also detects nested lazy includes and registers them as new entries
|
|
25
25
|
*/
|
|
26
26
|
export declare function evaluateLazyEntry<TEnv = any>(entry: RouteEntry<TEnv>, deps: LazyEvalDeps<TEnv>): void | Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Resolve an async include entry's provider once and cache the patterns on
|
|
29
|
+
* `entry.lazyPatterns`. Concurrent callers (match-time expansion and
|
|
30
|
+
* render-time loadManifest) share one in-flight import; it clears when it
|
|
31
|
+
* settles, so a rejected import is retried by the next request.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveEntryPatterns<TEnv = any>(entry: RouteEntry<TEnv>): Promise<UrlPatterns<TEnv>>;
|