@rangojs/router 0.0.0-experimental.0f44aca1
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/AGENTS.md +5 -0
- package/README.md +899 -0
- package/dist/bin/rango.js +1601 -0
- package/dist/vite/index.js +5214 -0
- package/package.json +176 -0
- package/skills/breadcrumbs/SKILL.md +250 -0
- package/skills/cache-guide/SKILL.md +262 -0
- package/skills/caching/SKILL.md +220 -0
- package/skills/composability/SKILL.md +172 -0
- package/skills/debug-manifest/SKILL.md +112 -0
- package/skills/document-cache/SKILL.md +182 -0
- package/skills/fonts/SKILL.md +167 -0
- package/skills/hooks/SKILL.md +704 -0
- package/skills/host-router/SKILL.md +218 -0
- package/skills/intercept/SKILL.md +313 -0
- package/skills/layout/SKILL.md +310 -0
- package/skills/links/SKILL.md +239 -0
- package/skills/loader/SKILL.md +596 -0
- package/skills/middleware/SKILL.md +339 -0
- package/skills/mime-routes/SKILL.md +128 -0
- package/skills/parallel/SKILL.md +305 -0
- package/skills/prerender/SKILL.md +643 -0
- package/skills/rango/SKILL.md +118 -0
- package/skills/response-routes/SKILL.md +411 -0
- package/skills/route/SKILL.md +385 -0
- package/skills/router-setup/SKILL.md +439 -0
- package/skills/tailwind/SKILL.md +129 -0
- package/skills/theme/SKILL.md +79 -0
- package/skills/typesafety/SKILL.md +623 -0
- package/skills/use-cache/SKILL.md +324 -0
- package/src/__internal.ts +273 -0
- package/src/bin/rango.ts +321 -0
- package/src/browser/action-coordinator.ts +97 -0
- package/src/browser/action-response-classifier.ts +99 -0
- package/src/browser/event-controller.ts +899 -0
- package/src/browser/history-state.ts +80 -0
- package/src/browser/index.ts +18 -0
- package/src/browser/intercept-utils.ts +52 -0
- package/src/browser/link-interceptor.ts +141 -0
- package/src/browser/logging.ts +55 -0
- package/src/browser/merge-segment-loaders.ts +134 -0
- package/src/browser/navigation-bridge.ts +645 -0
- package/src/browser/navigation-client.ts +215 -0
- package/src/browser/navigation-store.ts +806 -0
- package/src/browser/navigation-transaction.ts +295 -0
- package/src/browser/network-error-handler.ts +61 -0
- package/src/browser/partial-update.ts +550 -0
- package/src/browser/prefetch/cache.ts +146 -0
- package/src/browser/prefetch/fetch.ts +135 -0
- package/src/browser/prefetch/observer.ts +65 -0
- package/src/browser/prefetch/policy.ts +42 -0
- package/src/browser/prefetch/queue.ts +88 -0
- package/src/browser/rango-state.ts +112 -0
- package/src/browser/react/Link.tsx +360 -0
- package/src/browser/react/NavigationProvider.tsx +386 -0
- package/src/browser/react/ScrollRestoration.tsx +94 -0
- package/src/browser/react/context.ts +59 -0
- package/src/browser/react/filter-segment-order.ts +11 -0
- package/src/browser/react/index.ts +52 -0
- package/src/browser/react/location-state-shared.ts +162 -0
- package/src/browser/react/location-state.ts +107 -0
- package/src/browser/react/mount-context.ts +37 -0
- package/src/browser/react/nonce-context.ts +23 -0
- package/src/browser/react/shallow-equal.ts +27 -0
- package/src/browser/react/use-action.ts +218 -0
- package/src/browser/react/use-client-cache.ts +58 -0
- package/src/browser/react/use-handle.ts +162 -0
- package/src/browser/react/use-href.tsx +40 -0
- package/src/browser/react/use-link-status.ts +135 -0
- package/src/browser/react/use-mount.ts +31 -0
- package/src/browser/react/use-navigation.ts +99 -0
- package/src/browser/react/use-params.ts +65 -0
- package/src/browser/react/use-pathname.ts +47 -0
- package/src/browser/react/use-router.ts +63 -0
- package/src/browser/react/use-search-params.ts +56 -0
- package/src/browser/react/use-segments.ts +171 -0
- package/src/browser/response-adapter.ts +73 -0
- package/src/browser/rsc-router.tsx +431 -0
- package/src/browser/scroll-restoration.ts +400 -0
- package/src/browser/segment-reconciler.ts +216 -0
- package/src/browser/segment-structure-assert.ts +83 -0
- package/src/browser/server-action-bridge.ts +667 -0
- package/src/browser/shallow.ts +40 -0
- package/src/browser/types.ts +538 -0
- package/src/browser/validate-redirect-origin.ts +29 -0
- package/src/build/generate-manifest.ts +438 -0
- package/src/build/generate-route-types.ts +36 -0
- package/src/build/index.ts +35 -0
- package/src/build/route-trie.ts +265 -0
- package/src/build/route-types/ast-helpers.ts +25 -0
- package/src/build/route-types/ast-route-extraction.ts +98 -0
- package/src/build/route-types/codegen.ts +102 -0
- package/src/build/route-types/include-resolution.ts +411 -0
- package/src/build/route-types/param-extraction.ts +48 -0
- package/src/build/route-types/per-module-writer.ts +128 -0
- package/src/build/route-types/router-processing.ts +469 -0
- package/src/build/route-types/scan-filter.ts +78 -0
- package/src/build/runtime-discovery.ts +231 -0
- package/src/cache/background-task.ts +34 -0
- package/src/cache/cache-key-utils.ts +44 -0
- package/src/cache/cache-policy.ts +125 -0
- package/src/cache/cache-runtime.ts +338 -0
- package/src/cache/cache-scope.ts +382 -0
- package/src/cache/cf/cf-cache-store.ts +540 -0
- package/src/cache/cf/index.ts +25 -0
- package/src/cache/document-cache.ts +369 -0
- package/src/cache/handle-capture.ts +81 -0
- package/src/cache/handle-snapshot.ts +41 -0
- package/src/cache/index.ts +43 -0
- package/src/cache/memory-segment-store.ts +328 -0
- package/src/cache/profile-registry.ts +73 -0
- package/src/cache/read-through-swr.ts +134 -0
- package/src/cache/segment-codec.ts +256 -0
- package/src/cache/taint.ts +98 -0
- package/src/cache/types.ts +342 -0
- package/src/client.rsc.tsx +85 -0
- package/src/client.tsx +601 -0
- package/src/component-utils.ts +76 -0
- package/src/components/DefaultDocument.tsx +27 -0
- package/src/context-var.ts +86 -0
- package/src/debug.ts +243 -0
- package/src/default-error-boundary.tsx +88 -0
- package/src/deps/browser.ts +8 -0
- package/src/deps/html-stream-client.ts +2 -0
- package/src/deps/html-stream-server.ts +2 -0
- package/src/deps/rsc.ts +10 -0
- package/src/deps/ssr.ts +2 -0
- package/src/errors.ts +365 -0
- package/src/handle.ts +135 -0
- package/src/handles/MetaTags.tsx +246 -0
- package/src/handles/breadcrumbs.ts +66 -0
- package/src/handles/index.ts +7 -0
- package/src/handles/meta.ts +264 -0
- package/src/host/cookie-handler.ts +165 -0
- package/src/host/errors.ts +97 -0
- package/src/host/index.ts +53 -0
- package/src/host/pattern-matcher.ts +214 -0
- package/src/host/router.ts +352 -0
- package/src/host/testing.ts +79 -0
- package/src/host/types.ts +146 -0
- package/src/host/utils.ts +25 -0
- package/src/href-client.ts +222 -0
- package/src/index.rsc.ts +233 -0
- package/src/index.ts +277 -0
- package/src/internal-debug.ts +11 -0
- package/src/loader.rsc.ts +89 -0
- package/src/loader.ts +64 -0
- package/src/network-error-thrower.tsx +23 -0
- package/src/outlet-context.ts +15 -0
- package/src/outlet-provider.tsx +45 -0
- package/src/prerender/param-hash.ts +37 -0
- package/src/prerender/store.ts +185 -0
- package/src/prerender.ts +463 -0
- package/src/reverse.ts +330 -0
- package/src/root-error-boundary.tsx +289 -0
- package/src/route-content-wrapper.tsx +196 -0
- package/src/route-definition/dsl-helpers.ts +934 -0
- package/src/route-definition/helper-factories.ts +200 -0
- package/src/route-definition/helpers-types.ts +430 -0
- package/src/route-definition/index.ts +52 -0
- package/src/route-definition/redirect.ts +93 -0
- package/src/route-definition.ts +1 -0
- package/src/route-map-builder.ts +275 -0
- package/src/route-name.ts +53 -0
- package/src/route-types.ts +259 -0
- package/src/router/content-negotiation.ts +116 -0
- package/src/router/debug-manifest.ts +72 -0
- package/src/router/error-handling.ts +287 -0
- package/src/router/find-match.ts +158 -0
- package/src/router/handler-context.ts +451 -0
- package/src/router/intercept-resolution.ts +395 -0
- package/src/router/lazy-includes.ts +234 -0
- package/src/router/loader-resolution.ts +420 -0
- package/src/router/logging.ts +248 -0
- package/src/router/manifest.ts +267 -0
- package/src/router/match-api.ts +620 -0
- package/src/router/match-context.ts +266 -0
- package/src/router/match-handlers.ts +440 -0
- package/src/router/match-middleware/background-revalidation.ts +223 -0
- package/src/router/match-middleware/cache-lookup.ts +634 -0
- package/src/router/match-middleware/cache-store.ts +295 -0
- package/src/router/match-middleware/index.ts +81 -0
- package/src/router/match-middleware/intercept-resolution.ts +306 -0
- package/src/router/match-middleware/segment-resolution.ts +192 -0
- package/src/router/match-pipelines.ts +179 -0
- package/src/router/match-result.ts +219 -0
- package/src/router/metrics.ts +282 -0
- package/src/router/middleware-cookies.ts +55 -0
- package/src/router/middleware-types.ts +222 -0
- package/src/router/middleware.ts +748 -0
- package/src/router/pattern-matching.ts +563 -0
- package/src/router/prerender-match.ts +402 -0
- package/src/router/preview-match.ts +170 -0
- package/src/router/revalidation.ts +289 -0
- package/src/router/router-context.ts +316 -0
- package/src/router/router-interfaces.ts +452 -0
- package/src/router/router-options.ts +592 -0
- package/src/router/router-registry.ts +24 -0
- package/src/router/segment-resolution/fresh.ts +570 -0
- package/src/router/segment-resolution/helpers.ts +263 -0
- package/src/router/segment-resolution/loader-cache.ts +198 -0
- package/src/router/segment-resolution/revalidation.ts +1239 -0
- package/src/router/segment-resolution/static-store.ts +67 -0
- package/src/router/segment-resolution.ts +21 -0
- package/src/router/segment-wrappers.ts +289 -0
- package/src/router/telemetry-otel.ts +299 -0
- package/src/router/telemetry.ts +300 -0
- package/src/router/timeout.ts +148 -0
- package/src/router/trie-matching.ts +239 -0
- package/src/router/types.ts +170 -0
- package/src/router.ts +1002 -0
- package/src/rsc/handler-context.ts +45 -0
- package/src/rsc/handler.ts +1089 -0
- package/src/rsc/helpers.ts +198 -0
- package/src/rsc/index.ts +36 -0
- package/src/rsc/loader-fetch.ts +209 -0
- package/src/rsc/manifest-init.ts +86 -0
- package/src/rsc/nonce.ts +32 -0
- package/src/rsc/origin-guard.ts +141 -0
- package/src/rsc/progressive-enhancement.ts +379 -0
- package/src/rsc/response-error.ts +37 -0
- package/src/rsc/response-route-handler.ts +347 -0
- package/src/rsc/rsc-rendering.ts +235 -0
- package/src/rsc/runtime-warnings.ts +42 -0
- package/src/rsc/server-action.ts +348 -0
- package/src/rsc/ssr-setup.ts +128 -0
- package/src/rsc/types.ts +263 -0
- package/src/search-params.ts +230 -0
- package/src/segment-system.tsx +454 -0
- package/src/server/context.ts +591 -0
- package/src/server/cookie-store.ts +190 -0
- package/src/server/fetchable-loader-store.ts +37 -0
- package/src/server/handle-store.ts +308 -0
- package/src/server/loader-registry.ts +133 -0
- package/src/server/request-context.ts +914 -0
- package/src/server/root-layout.tsx +10 -0
- package/src/server/tsconfig.json +14 -0
- package/src/server.ts +51 -0
- package/src/ssr/index.tsx +365 -0
- package/src/static-handler.ts +114 -0
- package/src/theme/ThemeProvider.tsx +297 -0
- package/src/theme/ThemeScript.tsx +61 -0
- package/src/theme/constants.ts +62 -0
- package/src/theme/index.ts +48 -0
- package/src/theme/theme-context.ts +44 -0
- package/src/theme/theme-script.ts +155 -0
- package/src/theme/types.ts +182 -0
- package/src/theme/use-theme.ts +44 -0
- package/src/types/boundaries.ts +158 -0
- package/src/types/cache-types.ts +198 -0
- package/src/types/error-types.ts +192 -0
- package/src/types/global-namespace.ts +100 -0
- package/src/types/handler-context.ts +687 -0
- package/src/types/index.ts +88 -0
- package/src/types/loader-types.ts +183 -0
- package/src/types/route-config.ts +170 -0
- package/src/types/route-entry.ts +102 -0
- package/src/types/segments.ts +148 -0
- package/src/types.ts +1 -0
- package/src/urls/include-helper.ts +197 -0
- package/src/urls/index.ts +53 -0
- package/src/urls/path-helper-types.ts +339 -0
- package/src/urls/path-helper.ts +329 -0
- package/src/urls/pattern-types.ts +95 -0
- package/src/urls/response-types.ts +106 -0
- package/src/urls/type-extraction.ts +372 -0
- package/src/urls/urls-function.ts +98 -0
- package/src/urls.ts +1 -0
- package/src/use-loader.tsx +354 -0
- package/src/vite/discovery/bundle-postprocess.ts +184 -0
- package/src/vite/discovery/discover-routers.ts +344 -0
- package/src/vite/discovery/prerender-collection.ts +385 -0
- package/src/vite/discovery/route-types-writer.ts +258 -0
- package/src/vite/discovery/self-gen-tracking.ts +47 -0
- package/src/vite/discovery/state.ts +110 -0
- package/src/vite/discovery/virtual-module-codegen.ts +203 -0
- package/src/vite/index.ts +16 -0
- package/src/vite/plugin-types.ts +131 -0
- package/src/vite/plugins/cjs-to-esm.ts +93 -0
- package/src/vite/plugins/client-ref-dedup.ts +115 -0
- package/src/vite/plugins/client-ref-hashing.ts +105 -0
- package/src/vite/plugins/expose-action-id.ts +365 -0
- package/src/vite/plugins/expose-id-utils.ts +287 -0
- package/src/vite/plugins/expose-ids/export-analysis.ts +296 -0
- package/src/vite/plugins/expose-ids/handler-transform.ts +179 -0
- package/src/vite/plugins/expose-ids/loader-transform.ts +74 -0
- package/src/vite/plugins/expose-ids/router-transform.ts +110 -0
- package/src/vite/plugins/expose-ids/types.ts +45 -0
- package/src/vite/plugins/expose-internal-ids.ts +569 -0
- package/src/vite/plugins/refresh-cmd.ts +65 -0
- package/src/vite/plugins/use-cache-transform.ts +323 -0
- package/src/vite/plugins/version-injector.ts +83 -0
- package/src/vite/plugins/version-plugin.ts +254 -0
- package/src/vite/plugins/version.d.ts +12 -0
- package/src/vite/plugins/virtual-entries.ts +123 -0
- package/src/vite/plugins/virtual-stub-plugin.ts +29 -0
- package/src/vite/rango.ts +510 -0
- package/src/vite/router-discovery.ts +785 -0
- package/src/vite/utils/ast-handler-extract.ts +517 -0
- package/src/vite/utils/banner.ts +36 -0
- package/src/vite/utils/bundle-analysis.ts +137 -0
- package/src/vite/utils/manifest-utils.ts +70 -0
- package/src/vite/utils/package-resolution.ts +121 -0
- package/src/vite/utils/prerender-utils.ts +189 -0
- package/src/vite/utils/shared-utils.ts +169 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { LocationStateEntry } from "../browser/react/location-state-shared.js";
|
|
2
|
+
import {
|
|
3
|
+
requireRequestContext,
|
|
4
|
+
getRequestContext,
|
|
5
|
+
} from "../server/request-context.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Create a soft redirect Response for middleware short-circuit
|
|
9
|
+
*
|
|
10
|
+
* Returns a Response that signals a client-side navigation to the target URL.
|
|
11
|
+
* Unlike Response.redirect() which causes a full page reload, this redirect
|
|
12
|
+
* is handled by the router for SPA-style navigation.
|
|
13
|
+
*
|
|
14
|
+
* Supports an optional state parameter to carry location state through the
|
|
15
|
+
* redirect. On the target page, state can be read via useLocationState()
|
|
16
|
+
* (use { flash: true } in createLocationState for read-once flash messages).
|
|
17
|
+
*
|
|
18
|
+
* @param url - The URL to redirect to
|
|
19
|
+
* @param statusOrOptions - HTTP status code (default: 302) or options object
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // Simple redirect
|
|
24
|
+
* middleware((ctx, next) => {
|
|
25
|
+
* if (!ctx.get('user')) {
|
|
26
|
+
* return redirect('/login');
|
|
27
|
+
* }
|
|
28
|
+
* next();
|
|
29
|
+
* })
|
|
30
|
+
*
|
|
31
|
+
* // Redirect with state
|
|
32
|
+
* return redirect('/dashboard', {
|
|
33
|
+
* state: [Flash({ text: "Item saved!" })],
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* // Redirect with custom status and state
|
|
37
|
+
* return redirect('/login', {
|
|
38
|
+
* status: 303,
|
|
39
|
+
* state: [Flash({ text: "Session expired" })],
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export function redirect(url: string, status?: number): Response;
|
|
44
|
+
export function redirect(
|
|
45
|
+
url: string,
|
|
46
|
+
options: {
|
|
47
|
+
status?: number;
|
|
48
|
+
state?: LocationStateEntry | LocationStateEntry[];
|
|
49
|
+
},
|
|
50
|
+
): Response;
|
|
51
|
+
export function redirect(
|
|
52
|
+
url: string,
|
|
53
|
+
statusOrOptions?:
|
|
54
|
+
| number
|
|
55
|
+
| { status?: number; state?: LocationStateEntry | LocationStateEntry[] },
|
|
56
|
+
): Response {
|
|
57
|
+
const status =
|
|
58
|
+
typeof statusOrOptions === "number"
|
|
59
|
+
? statusOrOptions
|
|
60
|
+
: (statusOrOptions?.status ?? 302);
|
|
61
|
+
const state =
|
|
62
|
+
typeof statusOrOptions === "object" ? statusOrOptions?.state : undefined;
|
|
63
|
+
|
|
64
|
+
if (state) {
|
|
65
|
+
const ctx = requireRequestContext();
|
|
66
|
+
ctx.setLocationState(state);
|
|
67
|
+
|
|
68
|
+
if (process.env.NODE_ENV !== "production") {
|
|
69
|
+
const reqCtx = getRequestContext();
|
|
70
|
+
// Warn only on true full-page SSR loads. SPA partial requests and server
|
|
71
|
+
// actions both deliver state through Flight payloads, so suppress for those.
|
|
72
|
+
if (
|
|
73
|
+
reqCtx &&
|
|
74
|
+
!reqCtx.url.searchParams.has("_rsc_partial") &&
|
|
75
|
+
!reqCtx.request.headers.has("rsc-action") &&
|
|
76
|
+
!reqCtx.url.searchParams.has("_rsc_action")
|
|
77
|
+
) {
|
|
78
|
+
console.warn(
|
|
79
|
+
`[Router] redirect() with state during a full-page (SSR) request to "${url}". ` +
|
|
80
|
+
"Location state is only delivered during SPA navigations and will be lost on this request.",
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return new Response(null, {
|
|
87
|
+
status,
|
|
88
|
+
headers: {
|
|
89
|
+
Location: url,
|
|
90
|
+
"X-RSC-Redirect": "soft",
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./route-definition/index.js";
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route manifest storage and retrieval.
|
|
3
|
+
*
|
|
4
|
+
* The route manifest maps route names to URL patterns. It is populated
|
|
5
|
+
* by the virtual module (which imports from .named-routes.gen.ts files)
|
|
6
|
+
* and consumed by reverse() and href() at runtime.
|
|
7
|
+
*
|
|
8
|
+
* See docs/manifests.md for the full data flow.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Singleton route map instance - populated incrementally as routes are encountered
|
|
12
|
+
let globalRouteMap: Record<string, string> = {};
|
|
13
|
+
|
|
14
|
+
// Cached complete manifest - includes all routes (including lazy includes)
|
|
15
|
+
// Set from runtime cache or build-time import
|
|
16
|
+
let cachedManifest: Record<string, string> | null = null;
|
|
17
|
+
|
|
18
|
+
// Pre-computed route entries from build-time prefix tree leaf nodes.
|
|
19
|
+
// Used by evaluateLazyEntry() to skip running the handler for route matching.
|
|
20
|
+
let cachedPrecomputedEntries: Array<{
|
|
21
|
+
staticPrefix: string;
|
|
22
|
+
routes: Record<string, string>;
|
|
23
|
+
}> | null = null;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Register routes into the global route map.
|
|
27
|
+
* Routes are merged with any existing registered routes.
|
|
28
|
+
* Called by createRouter() during module evaluation.
|
|
29
|
+
*/
|
|
30
|
+
export function registerRouteMap(map: Record<string, string>): void {
|
|
31
|
+
// Always merge with existing map (don't replace)
|
|
32
|
+
globalRouteMap = { ...globalRouteMap, ...map };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get the globally registered route map
|
|
37
|
+
*
|
|
38
|
+
* Used internally by reverse to resolve route names to URLs at runtime.
|
|
39
|
+
* Returns the cached manifest if available (complete with lazy includes),
|
|
40
|
+
* otherwise returns the runtime-accumulated route map.
|
|
41
|
+
*
|
|
42
|
+
* @returns The registered route map
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export function getGlobalRouteMap(): Record<string, string> {
|
|
46
|
+
// Cached manifest is complete (includes lazy routes), so prefer it
|
|
47
|
+
if (cachedManifest) {
|
|
48
|
+
return cachedManifest;
|
|
49
|
+
}
|
|
50
|
+
return globalRouteMap;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Set the cached manifest (for runtime cache integration)
|
|
55
|
+
*
|
|
56
|
+
* This sets the complete route manifest from a runtime cache.
|
|
57
|
+
* The cached manifest includes all routes (including lazy includes)
|
|
58
|
+
* and takes precedence over the incrementally-built globalRouteMap.
|
|
59
|
+
*
|
|
60
|
+
* @param manifest - The complete route manifest to cache
|
|
61
|
+
*/
|
|
62
|
+
export function setCachedManifest(manifest: Record<string, string>): void {
|
|
63
|
+
cachedManifest = manifest;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Check if a cached manifest is loaded
|
|
68
|
+
*
|
|
69
|
+
* @returns true if a complete manifest is available
|
|
70
|
+
*/
|
|
71
|
+
export function hasCachedManifest(): boolean {
|
|
72
|
+
return cachedManifest !== null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Clear the cached manifest (for testing)
|
|
77
|
+
*/
|
|
78
|
+
export function clearCachedManifest(): void {
|
|
79
|
+
cachedManifest = null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Set pre-computed route entries from build-time data.
|
|
84
|
+
*
|
|
85
|
+
* Each entry corresponds to a leaf node in the prefix tree (no nested includes).
|
|
86
|
+
* evaluateLazyEntry() checks these before running the handler, avoiding the
|
|
87
|
+
* 5-50ms cost of handler evaluation for route matching on the first request.
|
|
88
|
+
*
|
|
89
|
+
* @param entries - Array of { staticPrefix, routes } from build-time prefix tree leaves
|
|
90
|
+
*/
|
|
91
|
+
export function setPrecomputedEntries(
|
|
92
|
+
entries: Array<{
|
|
93
|
+
staticPrefix: string;
|
|
94
|
+
routes: Record<string, string>;
|
|
95
|
+
}> | null,
|
|
96
|
+
): void {
|
|
97
|
+
cachedPrecomputedEntries = entries;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get pre-computed route entries (if available)
|
|
102
|
+
*/
|
|
103
|
+
export function getPrecomputedEntries(): typeof cachedPrecomputedEntries {
|
|
104
|
+
return cachedPrecomputedEntries;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Route trie for O(path_length) matching at runtime.
|
|
108
|
+
// Built at build time from the route manifest and serialized into the virtual module.
|
|
109
|
+
let cachedRouteTrie: import("./build/route-trie.js").TrieNode | null = null;
|
|
110
|
+
|
|
111
|
+
export function setRouteTrie(trie: typeof cachedRouteTrie): void {
|
|
112
|
+
cachedRouteTrie = trie;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function getRouteTrie(): typeof cachedRouteTrie {
|
|
116
|
+
return cachedRouteTrie;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Per-router isolated data: each router gets its own manifest, trie, and
|
|
120
|
+
// precomputed entries so multi-router setups (e.g. site + admin via
|
|
121
|
+
// createHostRouter()) don't see each other's routes.
|
|
122
|
+
const perRouterManifestMap: Map<string, Record<string, string>> = new Map();
|
|
123
|
+
const perRouterTrieMap: Map<string, import("./build/route-trie.js").TrieNode> =
|
|
124
|
+
new Map();
|
|
125
|
+
const perRouterPrecomputedEntriesMap: Map<
|
|
126
|
+
string,
|
|
127
|
+
Array<{ staticPrefix: string; routes: Record<string, string> }>
|
|
128
|
+
> = new Map();
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Clear all cached route data (global and per-router).
|
|
132
|
+
* Called during HMR when route definitions change so the handler rebuilds
|
|
133
|
+
* the trie from the updated router.urlpatterns on the next request.
|
|
134
|
+
*
|
|
135
|
+
* The virtual module calls this before repopulating with fresh data,
|
|
136
|
+
* preventing stale entries from removed routes from accumulating.
|
|
137
|
+
*/
|
|
138
|
+
export function clearAllRouterData(): void {
|
|
139
|
+
globalRouteMap = {};
|
|
140
|
+
cachedManifest = null;
|
|
141
|
+
cachedPrecomputedEntries = null;
|
|
142
|
+
cachedRouteTrie = null;
|
|
143
|
+
rootScopeRoutes.clear();
|
|
144
|
+
globalSearchSchemas.clear();
|
|
145
|
+
perRouterManifestMap.clear();
|
|
146
|
+
perRouterTrieMap.clear();
|
|
147
|
+
perRouterPrecomputedEntriesMap.clear();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function setRouterManifest(
|
|
151
|
+
routerId: string,
|
|
152
|
+
manifest: Record<string, string>,
|
|
153
|
+
): void {
|
|
154
|
+
perRouterManifestMap.set(routerId, manifest);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** @internal */
|
|
158
|
+
export function getRouterManifest(
|
|
159
|
+
routerId: string,
|
|
160
|
+
): Record<string, string> | undefined {
|
|
161
|
+
return perRouterManifestMap.get(routerId);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function setRouterTrie(
|
|
165
|
+
routerId: string,
|
|
166
|
+
trie: import("./build/route-trie.js").TrieNode,
|
|
167
|
+
): void {
|
|
168
|
+
perRouterTrieMap.set(routerId, trie);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function getRouterTrie(
|
|
172
|
+
routerId: string,
|
|
173
|
+
): import("./build/route-trie.js").TrieNode | undefined {
|
|
174
|
+
return perRouterTrieMap.get(routerId);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export function setRouterPrecomputedEntries(
|
|
178
|
+
routerId: string,
|
|
179
|
+
entries: Array<{ staticPrefix: string; routes: Record<string, string> }>,
|
|
180
|
+
): void {
|
|
181
|
+
perRouterPrecomputedEntriesMap.set(routerId, entries);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function getRouterPrecomputedEntries(
|
|
185
|
+
routerId: string,
|
|
186
|
+
): Array<{ staticPrefix: string; routes: Record<string, string> }> | undefined {
|
|
187
|
+
return perRouterPrecomputedEntriesMap.get(routerId);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Lazy loader registry: per-router manifest modules are loaded on first request
|
|
191
|
+
// via import() to keep startup fast and allow Rollup to code-split per router.
|
|
192
|
+
const routerManifestLoaders: Map<string, () => Promise<any>> = new Map();
|
|
193
|
+
|
|
194
|
+
export function registerRouterManifestLoader(
|
|
195
|
+
routerId: string,
|
|
196
|
+
loader: () => Promise<any>,
|
|
197
|
+
): void {
|
|
198
|
+
routerManifestLoaders.set(routerId, loader);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export async function ensureRouterManifest(routerId: string): Promise<void> {
|
|
202
|
+
if (perRouterManifestMap.has(routerId)) return;
|
|
203
|
+
const loader = routerManifestLoaders.get(routerId);
|
|
204
|
+
if (loader) {
|
|
205
|
+
const mod = await loader();
|
|
206
|
+
if (mod.manifest) perRouterManifestMap.set(routerId, mod.manifest);
|
|
207
|
+
if (mod.trie) perRouterTrieMap.set(routerId, mod.trie);
|
|
208
|
+
if (mod.precomputedEntries)
|
|
209
|
+
perRouterPrecomputedEntriesMap.set(routerId, mod.precomputedEntries);
|
|
210
|
+
routerManifestLoaders.delete(routerId);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Dev-mode manifest readiness gate.
|
|
215
|
+
// The Vite discovery plugin calls setManifestReadyPromise() before starting
|
|
216
|
+
// discovery, and resolves it when discovery completes. The handler awaits
|
|
217
|
+
// waitForManifestReady() on first request if the manifest isn't yet available.
|
|
218
|
+
let manifestReadyPromise: Promise<void> | null = null;
|
|
219
|
+
|
|
220
|
+
export function setManifestReadyPromise(promise: Promise<void>): void {
|
|
221
|
+
manifestReadyPromise = promise;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export function waitForManifestReady(): Promise<void> | null {
|
|
225
|
+
return manifestReadyPromise;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// ============================================================================
|
|
229
|
+
// Route Scope Registry
|
|
230
|
+
// ============================================================================
|
|
231
|
+
|
|
232
|
+
// Tracks whether each route is at root scope (no named include boundary above).
|
|
233
|
+
// Used by dot-local reverse resolution to decide whether bare-name fallback
|
|
234
|
+
// is allowed after scoped lookups are exhausted.
|
|
235
|
+
const rootScopeRoutes: Map<string, boolean> = new Map();
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Register whether a route is at root scope.
|
|
239
|
+
* Called by path() during route evaluation.
|
|
240
|
+
*/
|
|
241
|
+
export function registerRouteRootScope(
|
|
242
|
+
routeName: string,
|
|
243
|
+
rootScoped: boolean,
|
|
244
|
+
): void {
|
|
245
|
+
rootScopeRoutes.set(routeName, rootScoped);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Check if a route is at root scope.
|
|
250
|
+
* Returns undefined if the route has not been registered (e.g. in unit tests).
|
|
251
|
+
*/
|
|
252
|
+
export function isRouteRootScoped(routeName: string): boolean | undefined {
|
|
253
|
+
return rootScopeRoutes.get(routeName);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// ============================================================================
|
|
257
|
+
// Search Schema Registry
|
|
258
|
+
// ============================================================================
|
|
259
|
+
|
|
260
|
+
import type { SearchSchema } from "./search-params.js";
|
|
261
|
+
|
|
262
|
+
// Global search schema map: route name -> search schema descriptor.
|
|
263
|
+
// Populated by path() when a search option is provided.
|
|
264
|
+
const globalSearchSchemas: Map<string, SearchSchema> = new Map();
|
|
265
|
+
|
|
266
|
+
export function registerSearchSchema(
|
|
267
|
+
routeName: string,
|
|
268
|
+
schema: SearchSchema,
|
|
269
|
+
): void {
|
|
270
|
+
globalSearchSchemas.set(routeName, schema);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export function getSearchSchema(routeName: string): SearchSchema | undefined {
|
|
274
|
+
return globalSearchSchemas.get(routeName);
|
|
275
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route name utilities for filtering internal route names.
|
|
3
|
+
*
|
|
4
|
+
* Internal names stay active in the runtime manifest for matching and local
|
|
5
|
+
* reverse() resolution, but they must not leak into public APIs or generated
|
|
6
|
+
* route maps.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const AUTO_GENERATED_ROUTE_PREFIX = "$path_";
|
|
10
|
+
export const INTERNAL_INCLUDE_SCOPE_PREFIX = "$prefix_";
|
|
11
|
+
|
|
12
|
+
const RESERVED_PREFIXES = [
|
|
13
|
+
AUTO_GENERATED_ROUTE_PREFIX,
|
|
14
|
+
INTERNAL_INCLUDE_SCOPE_PREFIX,
|
|
15
|
+
] as const;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Check if a route name is internal.
|
|
19
|
+
* Internal names include:
|
|
20
|
+
* - unnamed path() routes like "$path__health" or "docs.$path__health"
|
|
21
|
+
* - hidden include scopes like "$prefix_0.index" or "blog.$prefix_1.post"
|
|
22
|
+
*
|
|
23
|
+
* User-defined names containing "$" (e.g. "docs.$admin") are valid and must
|
|
24
|
+
* be preserved.
|
|
25
|
+
*/
|
|
26
|
+
export function isAutoGeneratedRouteName(name: string): boolean {
|
|
27
|
+
return name.split(".").some((segment) => {
|
|
28
|
+
return (
|
|
29
|
+
segment.startsWith(AUTO_GENERATED_ROUTE_PREFIX) ||
|
|
30
|
+
segment.startsWith(INTERNAL_INCLUDE_SCOPE_PREFIX)
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Validate that a user-provided route name does not collide with
|
|
37
|
+
* reserved internal prefixes. Checks every dot-separated segment,
|
|
38
|
+
* mirroring the same rule used by isAutoGeneratedRouteName().
|
|
39
|
+
*
|
|
40
|
+
* Throws with a clear message when a reserved prefix is detected.
|
|
41
|
+
*/
|
|
42
|
+
export function validateUserRouteName(name: string): void {
|
|
43
|
+
for (const segment of name.split(".")) {
|
|
44
|
+
for (const prefix of RESERVED_PREFIXES) {
|
|
45
|
+
if (segment.startsWith(prefix)) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`Route name "${name}" contains segment "${segment}" which uses reserved internal prefix "${prefix}". ` +
|
|
48
|
+
`Choose a different name to avoid collision with auto-generated route names.`,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for route system items
|
|
3
|
+
* These are extracted separately to avoid circular dependencies
|
|
4
|
+
* and to prevent bundling server-only code in client bundles
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Branded return types for route helpers
|
|
9
|
+
*/
|
|
10
|
+
export declare const LayoutBrand: unique symbol;
|
|
11
|
+
export declare const RouteBrand: unique symbol;
|
|
12
|
+
export declare const ParallelBrand: unique symbol;
|
|
13
|
+
export declare const InterceptBrand: unique symbol;
|
|
14
|
+
export declare const MiddlewareBrand: unique symbol;
|
|
15
|
+
export declare const RevalidateBrand: unique symbol;
|
|
16
|
+
export declare const LoaderBrand: unique symbol;
|
|
17
|
+
export declare const LoadingBrand: unique symbol;
|
|
18
|
+
export declare const ErrorBoundaryBrand: unique symbol;
|
|
19
|
+
export declare const NotFoundBoundaryBrand: unique symbol;
|
|
20
|
+
export declare const WhenBrand: unique symbol;
|
|
21
|
+
export declare const CacheBrand: unique symbol;
|
|
22
|
+
export declare const TransitionBrand: unique symbol;
|
|
23
|
+
export declare const IncludeBrand: unique symbol;
|
|
24
|
+
export declare const UrlPatternsBrand: unique symbol;
|
|
25
|
+
|
|
26
|
+
export type LayoutItem = {
|
|
27
|
+
name: string;
|
|
28
|
+
type: "layout";
|
|
29
|
+
uses?: AllUseItems[];
|
|
30
|
+
[LayoutBrand]: void;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Typed layout item that carries child routes as phantom type
|
|
35
|
+
* Used for type inference in urls() API
|
|
36
|
+
*/
|
|
37
|
+
export type TypedLayoutItem<
|
|
38
|
+
TChildRoutes extends Record<string, any> = Record<string, string>,
|
|
39
|
+
TChildResponses extends Record<string, unknown> = Record<string, unknown>,
|
|
40
|
+
> = LayoutItem & {
|
|
41
|
+
readonly __childRoutes?: TChildRoutes;
|
|
42
|
+
readonly __childResponses?: TChildResponses;
|
|
43
|
+
};
|
|
44
|
+
export type RouteItem = {
|
|
45
|
+
name: string;
|
|
46
|
+
type: "route";
|
|
47
|
+
uses?: AllUseItems[];
|
|
48
|
+
[RouteBrand]: void;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Typed route item that carries route name and pattern as phantom types
|
|
53
|
+
* Used for type inference in urls() API
|
|
54
|
+
*/
|
|
55
|
+
export type TypedRouteItem<
|
|
56
|
+
TName extends string = string,
|
|
57
|
+
TPattern extends string = string,
|
|
58
|
+
TData = unknown,
|
|
59
|
+
TSearch = {},
|
|
60
|
+
> = RouteItem & {
|
|
61
|
+
readonly __name?: TName;
|
|
62
|
+
readonly __pattern?: TPattern;
|
|
63
|
+
readonly __data?: TData;
|
|
64
|
+
readonly __search?: TSearch;
|
|
65
|
+
};
|
|
66
|
+
export type ParallelItem = {
|
|
67
|
+
name: string;
|
|
68
|
+
type: "parallel";
|
|
69
|
+
uses?: ParallelUseItem[];
|
|
70
|
+
[ParallelBrand]: void;
|
|
71
|
+
};
|
|
72
|
+
export type InterceptItem = {
|
|
73
|
+
name: string;
|
|
74
|
+
type: "intercept";
|
|
75
|
+
uses?: InterceptUseItem[];
|
|
76
|
+
[InterceptBrand]: void;
|
|
77
|
+
};
|
|
78
|
+
export type LoaderItem = {
|
|
79
|
+
name: string;
|
|
80
|
+
type: "loader";
|
|
81
|
+
uses?: LoaderUseItem[];
|
|
82
|
+
[LoaderBrand]: void;
|
|
83
|
+
};
|
|
84
|
+
export type MiddlewareItem = {
|
|
85
|
+
name: string;
|
|
86
|
+
type: "middleware";
|
|
87
|
+
uses?: AllUseItems[];
|
|
88
|
+
[MiddlewareBrand]: void;
|
|
89
|
+
};
|
|
90
|
+
export type RevalidateItem = {
|
|
91
|
+
name: string;
|
|
92
|
+
type: "revalidate";
|
|
93
|
+
uses?: AllUseItems[];
|
|
94
|
+
[RevalidateBrand]: void;
|
|
95
|
+
};
|
|
96
|
+
export type LoadingItem = {
|
|
97
|
+
name: string;
|
|
98
|
+
type: "loading";
|
|
99
|
+
[LoadingBrand]: void;
|
|
100
|
+
};
|
|
101
|
+
export type ErrorBoundaryItem = {
|
|
102
|
+
name: string;
|
|
103
|
+
type: "errorBoundary";
|
|
104
|
+
uses?: AllUseItems[];
|
|
105
|
+
[ErrorBoundaryBrand]: void;
|
|
106
|
+
};
|
|
107
|
+
export type NotFoundBoundaryItem = {
|
|
108
|
+
name: string;
|
|
109
|
+
type: "notFoundBoundary";
|
|
110
|
+
uses?: AllUseItems[];
|
|
111
|
+
[NotFoundBoundaryBrand]: void;
|
|
112
|
+
};
|
|
113
|
+
export type WhenItem = {
|
|
114
|
+
name: string;
|
|
115
|
+
type: "when";
|
|
116
|
+
[WhenBrand]: void;
|
|
117
|
+
};
|
|
118
|
+
export type CacheItem = {
|
|
119
|
+
name: string;
|
|
120
|
+
type: "cache";
|
|
121
|
+
uses?: AllUseItems[];
|
|
122
|
+
[CacheBrand]: void;
|
|
123
|
+
};
|
|
124
|
+
export type TransitionItem = {
|
|
125
|
+
name: string;
|
|
126
|
+
type: "transition";
|
|
127
|
+
[TransitionBrand]: void;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Typed transition item that carries child routes as phantom type
|
|
132
|
+
* Used for type inference when transition() wraps child routes
|
|
133
|
+
*/
|
|
134
|
+
export type TypedTransitionItem<
|
|
135
|
+
TChildRoutes extends Record<string, any> = Record<string, string>,
|
|
136
|
+
TChildResponses extends Record<string, unknown> = Record<string, unknown>,
|
|
137
|
+
> = TransitionItem & {
|
|
138
|
+
readonly __childRoutes?: TChildRoutes;
|
|
139
|
+
readonly __childResponses?: TChildResponses;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Typed cache item that carries child routes as phantom type
|
|
144
|
+
* Used for type inference in urls() API
|
|
145
|
+
*/
|
|
146
|
+
export type TypedCacheItem<
|
|
147
|
+
TChildRoutes extends Record<string, any> = Record<string, string>,
|
|
148
|
+
TChildResponses extends Record<string, unknown> = Record<string, unknown>,
|
|
149
|
+
> = CacheItem & {
|
|
150
|
+
readonly __childRoutes?: TChildRoutes;
|
|
151
|
+
readonly __childResponses?: TChildResponses;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Include item for URL pattern composition (used by urls() API)
|
|
156
|
+
*/
|
|
157
|
+
export type IncludeItem = {
|
|
158
|
+
type: "include";
|
|
159
|
+
name: string;
|
|
160
|
+
prefix: string;
|
|
161
|
+
patterns: unknown; // UrlPatterns - avoid circular ref
|
|
162
|
+
options?: { name?: string; lazy?: boolean };
|
|
163
|
+
/** Whether this include should be lazily evaluated on first request */
|
|
164
|
+
lazy?: boolean;
|
|
165
|
+
/** Captured context for deferred lazy evaluation */
|
|
166
|
+
_lazyContext?: {
|
|
167
|
+
urlPrefix: string;
|
|
168
|
+
namePrefix: string | undefined;
|
|
169
|
+
parent: unknown; // EntryData - avoid circular import
|
|
170
|
+
/** Counter snapshot from pattern extraction for consistent shortCode indices */
|
|
171
|
+
counters?: Record<string, number>;
|
|
172
|
+
/** Cache profiles for DSL-time cache("profileName") resolution */
|
|
173
|
+
cacheProfiles?: Record<
|
|
174
|
+
string,
|
|
175
|
+
import("./cache/profile-registry.js").CacheProfile
|
|
176
|
+
>;
|
|
177
|
+
/** Root scope flag for dot-local reverse resolution */
|
|
178
|
+
rootScoped?: boolean;
|
|
179
|
+
};
|
|
180
|
+
[IncludeBrand]: void;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Typed include item that carries nested routes as phantom type
|
|
185
|
+
* Used for type inference in urls() API
|
|
186
|
+
*/
|
|
187
|
+
export type TypedIncludeItem<
|
|
188
|
+
TRoutes extends Record<string, any> = Record<string, string>,
|
|
189
|
+
TNamePrefix extends string = string,
|
|
190
|
+
TUrlPrefix extends string = string,
|
|
191
|
+
TResponses extends Record<string, unknown> = Record<string, unknown>,
|
|
192
|
+
> = IncludeItem & {
|
|
193
|
+
readonly __routes?: TRoutes;
|
|
194
|
+
readonly __namePrefix?: TNamePrefix;
|
|
195
|
+
readonly __urlPrefix?: TUrlPrefix;
|
|
196
|
+
readonly __responses?: TResponses;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Union types for use() callbacks
|
|
201
|
+
*/
|
|
202
|
+
export type AllUseItems =
|
|
203
|
+
| LayoutItem
|
|
204
|
+
| RouteItem
|
|
205
|
+
| MiddlewareItem
|
|
206
|
+
| RevalidateItem
|
|
207
|
+
| ParallelItem
|
|
208
|
+
| InterceptItem
|
|
209
|
+
| LoaderItem
|
|
210
|
+
| LoadingItem
|
|
211
|
+
| ErrorBoundaryItem
|
|
212
|
+
| NotFoundBoundaryItem
|
|
213
|
+
| CacheItem
|
|
214
|
+
| TransitionItem
|
|
215
|
+
| IncludeItem;
|
|
216
|
+
|
|
217
|
+
/** Items that can be used inside a layout callback */
|
|
218
|
+
export type LayoutUseItem = AllUseItems;
|
|
219
|
+
export type RouteUseItem =
|
|
220
|
+
| LayoutItem
|
|
221
|
+
| ParallelItem
|
|
222
|
+
| InterceptItem
|
|
223
|
+
| MiddlewareItem
|
|
224
|
+
| RevalidateItem
|
|
225
|
+
| LoaderItem
|
|
226
|
+
| LoadingItem
|
|
227
|
+
| ErrorBoundaryItem
|
|
228
|
+
| NotFoundBoundaryItem
|
|
229
|
+
| CacheItem
|
|
230
|
+
| TransitionItem;
|
|
231
|
+
/** Items that can be used inside a response route (path.json(), etc.) */
|
|
232
|
+
export type ResponseRouteUseItem = MiddlewareItem | CacheItem;
|
|
233
|
+
export type ParallelUseItem =
|
|
234
|
+
| RevalidateItem
|
|
235
|
+
| LoaderItem
|
|
236
|
+
| LoadingItem
|
|
237
|
+
| ErrorBoundaryItem
|
|
238
|
+
| NotFoundBoundaryItem
|
|
239
|
+
| TransitionItem;
|
|
240
|
+
export type InterceptUseItem =
|
|
241
|
+
| MiddlewareItem
|
|
242
|
+
| RevalidateItem
|
|
243
|
+
| LoaderItem
|
|
244
|
+
| LoadingItem
|
|
245
|
+
| ErrorBoundaryItem
|
|
246
|
+
| NotFoundBoundaryItem
|
|
247
|
+
| LayoutItem
|
|
248
|
+
| RouteItem
|
|
249
|
+
| WhenItem
|
|
250
|
+
| TransitionItem;
|
|
251
|
+
export type LoaderUseItem = RevalidateItem | CacheItem;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Allow composition factories in use() callbacks.
|
|
255
|
+
* Factories return T[], which placed inside a use() callback array
|
|
256
|
+
* creates nested arrays like (T | T[])[]. These are flattened at
|
|
257
|
+
* runtime via .flat(3).
|
|
258
|
+
*/
|
|
259
|
+
export type UseItems<T> = (T | readonly T[])[];
|