@rangojs/router 0.32.0 → 0.33.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 +3 -2
- package/dist/bin/browser-7KIJ5HSV.js +15 -0
- package/dist/bin/chunk-3B7CKBRO.js +463 -0
- package/dist/bin/chunk-524VACCG.js +71 -0
- package/dist/bin/chunk-LD7UBHT4.js +196 -0
- package/dist/bin/chunk-TO6CRWLN.js +1429 -0
- package/dist/bin/chunk-TTXC2U3G.js +2477 -0
- package/dist/bin/client-urls-projection-DQLWPDAT.js +28 -0
- package/dist/bin/forward-user-plugins-URBZKJP4.js +62 -0
- package/dist/bin/rango.js +42 -10173
- package/dist/bin/runtime-EPUDEHO4.js +596 -0
- package/dist/bin/runtime-discovery-CZ2QHT4Q.js +352 -0
- package/dist/bin/state-ACD2MGKJ.js +16 -0
- package/dist/bin/temp-rsc-server-QRR6HD6T.js +3190 -0
- package/dist/types/bin/rango.d.ts +1 -0
- package/dist/types/browser/action-fence.d.ts +20 -0
- package/dist/types/browser/cookie-name.d.ts +51 -10
- package/dist/types/browser/invalidate-client-cache.d.ts +8 -6
- package/dist/types/browser/navigation-bridge.d.ts +36 -1
- package/dist/types/browser/navigation-client.d.ts +19 -0
- package/dist/types/browser/navigation-store-handle.d.ts +37 -4
- package/dist/types/browser/navigation-store.d.ts +2 -2
- package/dist/types/browser/navigation-transaction.d.ts +0 -1
- package/dist/types/browser/partial-update.d.ts +13 -0
- package/dist/types/browser/prefetch/cache.d.ts +96 -8
- package/dist/types/browser/prefetch/fetch.d.ts +26 -2
- package/dist/types/browser/prefetch/queue.d.ts +3 -2
- package/dist/types/browser/rango-state.d.ts +34 -5
- package/dist/types/browser/react/Link.d.ts +15 -6
- package/dist/types/browser/types.d.ts +25 -0
- package/dist/types/build/generate-route-types.d.ts +1 -1
- package/dist/types/build/route-types/include-resolution.d.ts +9 -1
- package/dist/types/build/route-types/router-processing.d.ts +3 -1
- package/dist/types/cache/cache-key-utils.d.ts +12 -8
- package/dist/types/cache/cache-scope.d.ts +4 -2
- package/dist/types/cache/cf/cf-cache-types.d.ts +9 -5
- package/dist/types/cache/document-cache-policy.d.ts +9 -1
- package/dist/types/cache/memory-segment-store.d.ts +3 -2
- package/dist/types/cache/segment-codec.d.ts +2 -2
- package/dist/types/cache/shell-snapshot.d.ts +1 -1
- package/dist/types/cache/types.d.ts +12 -7
- package/dist/types/cache/vercel/vercel-cache-store.d.ts +2 -1
- package/dist/types/client-urls/types.d.ts +7 -5
- package/dist/types/prefetch-markers.d.ts +9 -0
- package/dist/types/prefetch-source-scope.d.ts +66 -0
- package/dist/types/route-definition/helpers-types.d.ts +8 -5
- package/dist/types/router/intercept-resolution.d.ts +25 -11
- package/dist/types/router/match-context.d.ts +1 -0
- package/dist/types/router/match-handlers.d.ts +1 -1
- package/dist/types/router/prefetch-cache-ttl.d.ts +11 -3
- package/dist/types/router/router-context.d.ts +1 -1
- package/dist/types/router/router-options.d.ts +6 -3
- package/dist/types/router/segment-resolution/loader-cache.d.ts +8 -0
- package/dist/types/router/segment-resolution/prefetch-deferral.d.ts +23 -7
- package/dist/types/router/segment-resolution/revalidation.d.ts +19 -0
- package/dist/types/router/source-reads.d.ts +53 -0
- package/dist/types/router/types.d.ts +1 -1
- package/dist/types/rsc/helpers.d.ts +5 -2
- package/dist/types/rsc/prefetch-render-error.d.ts +7 -2
- package/dist/types/rsc/request-stages.d.ts +2 -0
- package/dist/types/rsc/shell-serve.d.ts +6 -1
- package/dist/types/server/context.d.ts +23 -6
- package/dist/types/server/cookie-store.d.ts +15 -1
- package/dist/types/server/document-location-state.d.ts +5 -2
- package/dist/types/server/handle-store.d.ts +2 -0
- package/dist/types/server/request-context.d.ts +43 -7
- package/dist/types/testing/e2e/server.d.ts +16 -1
- package/dist/types/testing/render-route.d.ts +66 -2
- package/dist/types/testing/serve-shell-request.d.ts +6 -3
- package/dist/types/types/handler-context.d.ts +7 -5
- package/dist/types/types/loader-types.d.ts +7 -4
- package/dist/types/types/segments.d.ts +15 -4
- package/dist/types/urls/path-helper-types.d.ts +7 -5
- package/dist/types/vite/temp-rsc-server.d.ts +2 -2
- package/dist/vite/index.js +449 -189
- package/package.json +2 -2
- package/skills/app-structure/SKILL.md +74 -0
- package/skills/app-structure/e-commerce.md +10 -9
- package/skills/app-structure/large-app.md +15 -2
- package/skills/caching/SKILL.md +10 -5
- package/skills/client-urls/SKILL.md +18 -11
- package/skills/comparison/references/framework-comparison.md +13 -8
- package/skills/document-cache/SKILL.md +8 -0
- package/skills/hooks/navigation.md +8 -8
- package/skills/hooks/state.md +24 -8
- package/skills/intercept/SKILL.md +33 -12
- package/skills/layout/SKILL.md +11 -0
- package/skills/links/SKILL.md +101 -4
- package/skills/loader/SKILL.md +49 -22
- package/skills/migrate-nextjs/SKILL.md +8 -2
- package/skills/migrate-react-router/data-and-actions.md +5 -0
- package/skills/ppr/SKILL.md +26 -5
- package/skills/prerender/SKILL.md +4 -1
- package/skills/route/SKILL.md +6 -6
- package/skills/router-setup/SKILL.md +2 -1
- package/skills/server-actions/SKILL.md +41 -8
- package/skills/testing/client-components.md +29 -13
- package/skills/testing/serve-shell-request.md +7 -7
- package/skills/testing/server-actions.md +8 -0
- package/skills/ux-architecture/SKILL.md +67 -18
- package/src/bin/rango.ts +39 -13
- package/src/browser/action-fence.ts +72 -0
- package/src/browser/cookie-name.ts +82 -14
- package/src/browser/invalidate-client-cache.ts +9 -7
- package/src/browser/navigation-bridge.ts +164 -32
- package/src/browser/navigation-client.ts +95 -20
- package/src/browser/navigation-store-handle.ts +67 -5
- package/src/browser/navigation-store.ts +86 -17
- package/src/browser/navigation-transaction.ts +0 -6
- package/src/browser/partial-update.ts +31 -12
- package/src/browser/prefetch/cache.ts +188 -11
- package/src/browser/prefetch/fetch.ts +211 -51
- package/src/browser/prefetch/queue.ts +3 -2
- package/src/browser/rango-state.ts +50 -8
- package/src/browser/react/Link.tsx +20 -9
- package/src/browser/react/use-navigation.ts +1 -1
- package/src/browser/rsc-router.tsx +8 -1
- package/src/browser/server-action-bridge.ts +3 -3
- package/src/browser/types.ts +25 -0
- package/src/build/generate-route-types.ts +1 -0
- package/src/build/route-types/include-resolution.ts +40 -3
- package/src/build/route-types/router-processing.ts +170 -25
- package/src/build/route-types/scan-filter.ts +1 -0
- package/src/cache/cache-key-utils.ts +12 -8
- package/src/cache/cache-runtime.ts +5 -1
- package/src/cache/cache-scope.ts +28 -7
- package/src/cache/cf/cf-cache-types.ts +9 -5
- package/src/cache/document-cache-policy.ts +27 -0
- package/src/cache/document-cache.ts +5 -0
- package/src/cache/memory-segment-store.ts +3 -2
- package/src/cache/segment-codec.ts +2 -2
- package/src/cache/shell-snapshot.ts +1 -1
- package/src/cache/types.ts +12 -7
- package/src/cache/vercel/vercel-cache-store.ts +2 -1
- package/src/client-urls/types.ts +7 -5
- package/src/prefetch-markers.ts +10 -0
- package/src/prefetch-source-scope.ts +137 -0
- package/src/route-definition/helpers-types.ts +8 -5
- package/src/router/intercept-resolution.ts +94 -50
- package/src/router/loader-resolution.ts +8 -6
- package/src/router/match-api.ts +33 -29
- package/src/router/match-context.ts +5 -0
- package/src/router/match-handlers.ts +2 -1
- package/src/router/match-middleware/cache-lookup.ts +21 -13
- package/src/router/match-result.ts +39 -87
- package/src/router/navigation-snapshot.ts +18 -3
- package/src/router/prefetch-cache-ttl.ts +15 -3
- package/src/router/revalidation.ts +53 -23
- package/src/router/router-context.ts +2 -1
- package/src/router/router-options.ts +6 -3
- package/src/router/segment-resolution/loader-cache.ts +21 -3
- package/src/router/segment-resolution/prefetch-deferral.ts +38 -31
- package/src/router/segment-resolution/revalidation.ts +40 -12
- package/src/router/source-reads.ts +122 -0
- package/src/router/types.ts +2 -1
- package/src/router.ts +11 -12
- package/src/rsc/helpers.ts +8 -3
- package/src/rsc/prefetch-render-error.ts +7 -2
- package/src/rsc/progressive-enhancement.ts +3 -2
- package/src/rsc/request-stages.ts +59 -0
- package/src/rsc/rsc-rendering.ts +49 -33
- package/src/rsc/server-action.ts +2 -1
- package/src/rsc/shell-capture.ts +4 -5
- package/src/rsc/shell-serve.ts +12 -1
- package/src/segment-system.tsx +1 -1
- package/src/server/context.ts +37 -6
- package/src/server/cookie-store.ts +22 -1
- package/src/server/document-location-state.ts +23 -2
- package/src/server/handle-store.ts +2 -0
- package/src/server/request-context.ts +113 -28
- package/src/testing/dispatch.ts +3 -0
- package/src/testing/e2e/fixture.ts +4 -12
- package/src/testing/e2e/server.ts +91 -4
- package/src/testing/render-route.tsx +269 -4
- package/src/testing/serve-shell-request.ts +6 -3
- package/src/types/handler-context.ts +7 -5
- package/src/types/loader-types.ts +7 -4
- package/src/types/segments.ts +15 -4
- package/src/urls/path-helper-types.ts +7 -5
- package/src/vite/temp-rsc-server.ts +2 -2
|
@@ -182,10 +182,13 @@ export type LoaderFn<T, TParams = Record<string, string | undefined>, TEnv = Def
|
|
|
182
182
|
export type LoaderOptions = {
|
|
183
183
|
ssr?: boolean;
|
|
184
184
|
/**
|
|
185
|
-
* `prefetch: false` keeps this loader out of prefetches. A
|
|
186
|
-
* prefetch (a partial request with
|
|
187
|
-
*
|
|
188
|
-
*
|
|
185
|
+
* `prefetch: false` keeps this loader out of speculative prefetches. A
|
|
186
|
+
* viewport or render `<Link>` prefetch (a partial request with
|
|
187
|
+
* `X-Rango-Prefetch: 1`) does not execute it; the payload marks it
|
|
188
|
+
* deferred. A hover prefetch and `useRouter().prefetch()`
|
|
189
|
+
* (`X-Rango-Prefetch: intent`) count as intent to click and run it, so a
|
|
190
|
+
* click after a hover needs no follow-up request. A document request and a
|
|
191
|
+
* navigation with no prefetch to adopt run it as usual.
|
|
189
192
|
*
|
|
190
193
|
* A deferred loader never blocks the navigation that adopts the prefetch:
|
|
191
194
|
* it behaves like a loader that is still streaming. Its own `<Suspense>`
|
|
@@ -147,7 +147,6 @@ export interface ResolvedSegment {
|
|
|
147
147
|
layoutName?: string;
|
|
148
148
|
parallelName?: string;
|
|
149
149
|
loaderId?: string;
|
|
150
|
-
_inherited?: boolean;
|
|
151
150
|
loaderData?: any;
|
|
152
151
|
/**
|
|
153
152
|
* True when this loader was awaited before first flush
|
|
@@ -276,10 +275,22 @@ export interface MatchResult {
|
|
|
276
275
|
interceptTargeted?: true;
|
|
277
276
|
/**
|
|
278
277
|
* Set on a partial match when a revalidate() predicate read the source page
|
|
279
|
-
* and kept a held segment: the diff is
|
|
280
|
-
* scopes its prefetch entry to
|
|
278
|
+
* and kept a held segment: the diff is right for the pages with equal values
|
|
279
|
+
* of what it read. The RSC handler scopes its prefetch entry to that group,
|
|
280
|
+
* or to the source page when the predicate read `currentUrl` (#1331).
|
|
281
281
|
*/
|
|
282
|
-
sourceHeld?:
|
|
282
|
+
sourceHeld?: import("../router/source-reads.js").SourceHeld;
|
|
283
|
+
/**
|
|
284
|
+
* Set on a partial match whose answer has nothing live in it: the cache
|
|
285
|
+
* lookup served it (a cache() record, a Prerender entry, a shell replay's
|
|
286
|
+
* record, not a stale cache() record or stale overlay entry), it sends a
|
|
287
|
+
* segment, every segment it
|
|
288
|
+
* sends is one that lookup decoded, and no loader ran. A stored segment
|
|
289
|
+
* cannot fail after the headers left, since every writer refuses a failed
|
|
290
|
+
* render; a live segment or a loader can. The RSC handler marks the request
|
|
291
|
+
* `_servedFromStorage` from it.
|
|
292
|
+
*/
|
|
293
|
+
fromStorage?: true;
|
|
283
294
|
/**
|
|
284
295
|
* Redirect URL for trailing slash normalization.
|
|
285
296
|
* When set, the RSC handler should return a 308 redirect to this URL
|
|
@@ -161,9 +161,10 @@ export type PathHelpers<TEnv> = {
|
|
|
161
161
|
* freezes into the shell (nested promises stay live holes) — the pre-flush
|
|
162
162
|
* promise applied to the prelude.
|
|
163
163
|
*
|
|
164
|
-
* Pass `{ prefetch: false }` to keep the loader out of
|
|
165
|
-
* prefetch skips it and the click
|
|
166
|
-
* one follow-up request
|
|
164
|
+
* Pass `{ prefetch: false }` to keep the loader out of speculative
|
|
165
|
+
* prefetches (viewport, render): such a prefetch skips it and the click
|
|
166
|
+
* that adopts it fetches it in one follow-up request; a hover prefetch runs
|
|
167
|
+
* it (see {@link LoaderOptions}). Only on a segment the
|
|
167
168
|
* client does not have yet: a loader the client already holds runs in the
|
|
168
169
|
* prefetch when it revalidates.
|
|
169
170
|
*/
|
|
@@ -172,8 +173,9 @@ export type PathHelpers<TEnv> = {
|
|
|
172
173
|
* Attach a loading component to the current route/layout.
|
|
173
174
|
*
|
|
174
175
|
* `{ ssr: false }` skips the fallback on document requests. `{ prefetch:
|
|
175
|
-
* false }` keeps what the fallback covers out of
|
|
176
|
-
*
|
|
176
|
+
* false }` keeps what the fallback covers out of viewport and render
|
|
177
|
+
* prefetches (a hover prefetch runs it), when this entry's segment is new
|
|
178
|
+
* to the client: the entry's handler, its loaders,
|
|
177
179
|
* its orphan layouts and parallel slots and, for a layout, every deeper
|
|
178
180
|
* entry. The click that adopts the prefetch shows the fallback and fetches
|
|
179
181
|
* them in one follow-up request, which reads cache() and "use cache" as
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Sits in src/vite/, not src/vite/discovery/: the loader hook URL below
|
|
9
9
|
* resolves against this module's import.meta.url, and the published bundles
|
|
10
|
-
* (dist/vite/index.js, dist/bin/
|
|
11
|
-
* path.
|
|
10
|
+
* (dist/vite/index.js, and the CLI's code-split chunks in dist/bin/) ship the
|
|
11
|
+
* hook at the same relative path.
|
|
12
12
|
*/
|
|
13
13
|
import type { ViteDevServer } from "vite";
|
|
14
14
|
import type { DiscoveryState } from "./discovery/state.js";
|