@rangojs/router 0.24.4 → 0.26.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-cache-store.d.ts +0 -2
- package/dist/types/cache/cf/cf-cache-types.d.ts +0 -16
- package/dist/types/cache/cf/cf-shell-frame.d.ts +2 -0
- package/dist/types/cache/handle-snapshot.d.ts +2 -2
- package/dist/types/cache/types.d.ts +16 -6
- package/dist/types/cache/vercel/vercel-cache-store.d.ts +1 -15
- package/dist/types/client-urls/client-urls.d.ts +6 -2
- package/dist/types/client-urls/revalidate-registry.d.ts +1 -1
- package/dist/types/client-urls/server-projection.d.ts +9 -5
- package/dist/types/client-urls/types.d.ts +29 -16
- 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/handles/deferred-resolution.d.ts +3 -2
- package/dist/types/handles/meta.d.ts +5 -0
- 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/prerender/build-shell-capture.d.ts +1 -2
- package/dist/types/prerender/writable-store.d.ts +2 -3
- 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 -11
- package/dist/types/router/router-options.d.ts +4 -27
- package/dist/types/router/segment-resolution/mask-nested.d.ts +5 -3
- 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 +3 -2
- package/dist/types/router/tracing.d.ts +2 -2
- package/dist/types/router-versions.d.ts +8 -6
- 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 +14 -4
- package/dist/types/rsc/shell-capture.d.ts +23 -2
- package/dist/types/rsc/types.d.ts +5 -8
- package/dist/types/segment-system.d.ts +15 -0
- package/dist/types/server/build-version-table.d.ts +10 -13
- package/dist/types/server/context.d.ts +90 -6
- package/dist/types/server/handle-store.d.ts +17 -6
- package/dist/types/server/request-context.d.ts +45 -7
- package/dist/types/server/request-headers.d.ts +12 -0
- package/dist/types/server/rewrite-trail.d.ts +8 -1
- package/dist/types/testing/build-versions.d.ts +0 -3
- 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/internal/seed-vars.d.ts +4 -4
- 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 +42 -5
- 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 +10 -4
- package/dist/types/types/route-entry.d.ts +2 -1
- package/dist/types/urls/path-helper-types.d.ts +4 -2
- 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 +6819 -6555
- 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/cache-guide/SKILL.md +4 -8
- package/skills/caching/SKILL.md +6 -6
- package/skills/catalog.json +12 -0
- package/skills/client-urls/SKILL.md +185 -32
- package/skills/comparison/references/framework-comparison.md +1 -1
- 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/host-router/SKILL.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 +42 -19
- 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 +103 -52
- package/skills/prerender/SKILL.md +4 -5
- package/skills/rango/SKILL.md +3 -0
- package/skills/response-routes/SKILL.md +4 -1
- package/skills/router-setup/SKILL.md +0 -2
- 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/render-handler.md +17 -17
- package/skills/testing/response-routes.md +4 -1
- package/skills/testing/serve-shell-request.md +86 -22
- package/skills/testing/server-actions.md +16 -16
- package/skills/ux-architecture/SKILL.md +980 -0
- package/skills/vercel/SKILL.md +1 -1
- 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 +112 -84
- 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-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 +6 -7
- package/src/cache/cf/cf-cache-types.ts +0 -17
- package/src/cache/cf/cf-shell-frame.ts +3 -0
- package/src/cache/handle-snapshot.ts +2 -2
- package/src/cache/types.ts +16 -6
- package/src/cache/vercel/vercel-cache-store.ts +8 -19
- package/src/client-urls/client-urls.ts +202 -153
- package/src/client-urls/revalidate-registry.ts +12 -3
- package/src/client-urls/server-projection.ts +137 -66
- package/src/client-urls/types.ts +30 -15
- package/src/client.rsc.tsx +11 -1
- package/src/client.tsx +9 -1
- package/src/decode-loader-results.ts +64 -31
- package/src/handles/deferred-resolution.ts +3 -2
- package/src/handles/meta.ts +5 -0
- 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/prerender/build-shell-capture.ts +1 -2
- package/src/prerender/writable-store.ts +2 -3
- package/src/reverse.ts +3 -3
- package/src/route-content-wrapper.tsx +19 -17
- package/src/route-definition/dsl-helpers.ts +41 -21
- 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 +15 -10
- 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 -13
- package/src/router/router-options.ts +4 -28
- package/src/router/segment-resolution/fresh.ts +6 -2
- package/src/router/segment-resolution/helpers.ts +7 -1
- package/src/router/segment-resolution/loader-cache.ts +4 -3
- package/src/router/segment-resolution/mask-nested.ts +5 -3
- 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 +3 -2
- package/src/router/tracing.ts +2 -2
- package/src/router-versions.ts +7 -7
- package/src/router.ts +5 -17
- package/src/rsc/full-payload.ts +26 -4
- package/src/rsc/handler.ts +86 -48
- 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 +26 -3
- package/src/rsc/shell-capture.ts +137 -51
- package/src/rsc/types.ts +5 -9
- package/src/segment-system.tsx +125 -119
- package/src/server/build-version-table.ts +12 -24
- package/src/server/context.ts +160 -7
- package/src/server/handle-store.ts +80 -12
- package/src/server/request-context.ts +46 -6
- 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/build-versions.ts +0 -3
- package/src/testing/dispatch.ts +5 -8
- 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/internal/seed-vars.ts +4 -4
- 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 +79 -9
- 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 +10 -4
- 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/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/shell-prerender-phase.ts +1 -5
- 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
|
@@ -422,6 +422,7 @@ function shellHeadToEntry(head: ShellFrameHead): ShellEntryHead {
|
|
|
422
422
|
reactVersion: head.rv,
|
|
423
423
|
buildVersion: head.bv,
|
|
424
424
|
initialTheme: head.i,
|
|
425
|
+
pathname: head.lp,
|
|
425
426
|
docKey: head.dk,
|
|
426
427
|
prunedRecords: head.pr,
|
|
427
428
|
navigationOnly: head.no,
|
|
@@ -499,8 +500,6 @@ export class CFCacheStore<TEnv = unknown> implements SegmentCacheStore<TEnv> {
|
|
|
499
500
|
private readonly namespace?: string;
|
|
500
501
|
private readonly explicitBaseUrl?: string;
|
|
501
502
|
private readonly waitUntil?: (fn: () => Promise<void>) => void;
|
|
502
|
-
/** The `version` option: used for every versioned family when set. */
|
|
503
|
-
private readonly explicitVersion?: string;
|
|
504
503
|
private readonly edgeLookupTimeoutMs: number;
|
|
505
504
|
private readonly edgeReadTimeoutMs: number;
|
|
506
505
|
private readonly kvReadTimeoutMs: number;
|
|
@@ -553,7 +552,6 @@ export class CFCacheStore<TEnv = unknown> implements SegmentCacheStore<TEnv> {
|
|
|
553
552
|
// the internal host. Only the explicit override can be captured eagerly.
|
|
554
553
|
this.explicitBaseUrl = options.baseUrl;
|
|
555
554
|
this.defaults = options.defaults;
|
|
556
|
-
this.explicitVersion = options.version;
|
|
557
555
|
// Coalesce only finite numbers to the override; a non-finite value (NaN from
|
|
558
556
|
// `Number(env.UNSET)`, or Infinity) would otherwise sail past `?? DEFAULT`
|
|
559
557
|
// (which only replaces null/undefined) into setTimeout, where NaN/Infinity
|
|
@@ -1627,8 +1625,8 @@ export class CFCacheStore<TEnv = unknown> implements SegmentCacheStore<TEnv> {
|
|
|
1627
1625
|
// stamp). Carried on doc L1 entries for the herd guard; never serve them.
|
|
1628
1626
|
headers.delete(CACHE_EXPIRES_AT_HEADER);
|
|
1629
1627
|
headers.delete(CACHE_REVALIDATING_AT_HEADER);
|
|
1630
|
-
// Finding #3 (read side): strip per-client signals a pre-fix
|
|
1631
|
-
//
|
|
1628
|
+
// Finding #3 (read side): strip per-client signals a pre-fix L1 entry
|
|
1629
|
+
// may carry. See the read-side note in the design doc.
|
|
1632
1630
|
stripPerClientSignals(headers);
|
|
1633
1631
|
return new Response(response.body, {
|
|
1634
1632
|
status: response.status,
|
|
@@ -2695,6 +2693,7 @@ export class CFCacheStore<TEnv = unknown> implements SegmentCacheStore<TEnv> {
|
|
|
2695
2693
|
t: tags,
|
|
2696
2694
|
ta: taggedAt,
|
|
2697
2695
|
i: entry.initialTheme,
|
|
2696
|
+
lp: entry.pathname,
|
|
2698
2697
|
dk: entry.docKey,
|
|
2699
2698
|
pr: entry.prunedRecords,
|
|
2700
2699
|
no: entry.navigationOnly,
|
|
@@ -2950,7 +2949,7 @@ export class CFCacheStore<TEnv = unknown> implements SegmentCacheStore<TEnv> {
|
|
|
2950
2949
|
private keyToRequest(key: string, family: KeyVersion): Request {
|
|
2951
2950
|
const encodedKey = encodeURIComponent(key);
|
|
2952
2951
|
return new Request(
|
|
2953
|
-
`${this.resolveBaseUrl()}${versionKeyPrefix(
|
|
2952
|
+
`${this.resolveBaseUrl()}${versionKeyPrefix(family)}${encodedKey}`,
|
|
2954
2953
|
{ method: "GET" },
|
|
2955
2954
|
);
|
|
2956
2955
|
}
|
|
@@ -2974,7 +2973,7 @@ export class CFCacheStore<TEnv = unknown> implements SegmentCacheStore<TEnv> {
|
|
|
2974
2973
|
* @internal
|
|
2975
2974
|
*/
|
|
2976
2975
|
private async toKVKey(key: string, family: KeyVersion): Promise<string> {
|
|
2977
|
-
const composed = `${versionKeyPrefix(
|
|
2976
|
+
const composed = `${versionKeyPrefix(family)}${key}`;
|
|
2978
2977
|
if (kvKeyByteLength(composed) <= KV_MAX_KEY_BYTES) return composed;
|
|
2979
2978
|
const prefix = truncateToBytes(composed, KV_KEY_PRESERVED_PREFIX_BYTES);
|
|
2980
2979
|
return `${prefix}~${await kvKeyDigest(composed)}`;
|
|
@@ -322,23 +322,6 @@ export interface CFCacheStoreOptions<TEnv = unknown> {
|
|
|
322
322
|
*/
|
|
323
323
|
tagCacheTtl?: number;
|
|
324
324
|
|
|
325
|
-
/**
|
|
326
|
-
* Cache version string override. When set, this exact value prefixes every
|
|
327
|
-
* versioned key the store writes (`v/{version}/...`), for cached data and
|
|
328
|
-
* stored HTML alike; changing it makes every earlier entry unreachable.
|
|
329
|
-
*
|
|
330
|
-
* Leave it unset for the default: the store keys with the versions of the
|
|
331
|
-
* router serving the request. Segment entries and `"use cache"` items use
|
|
332
|
-
* the router's data version; document responses and PPR shells use its
|
|
333
|
-
* document version (see `createRouter({ version })`). Those are computed
|
|
334
|
-
* from the router's built code, so a deploy that does not change the router
|
|
335
|
-
* keeps its entries.
|
|
336
|
-
*
|
|
337
|
-
* Tag invalidation markers are never versioned: an invalidation applies to
|
|
338
|
-
* the entries of every version, including one that comes back in a rollback.
|
|
339
|
-
*/
|
|
340
|
-
version?: string;
|
|
341
|
-
|
|
342
325
|
/**
|
|
343
326
|
* Latency budget (ms) for an L1 edge cache (CF Cache API) read. A `match`
|
|
344
327
|
* slower than this is abandoned and treated as a miss, so a degraded colo
|
|
@@ -47,6 +47,8 @@ export interface ShellFrameHead {
|
|
|
47
47
|
ta?: number;
|
|
48
48
|
/** ShellCacheEntry.initialTheme */
|
|
49
49
|
i?: string;
|
|
50
|
+
/** ShellCacheEntry.pathname (a visitor-keyed shell's rendered location). */
|
|
51
|
+
lp?: string;
|
|
50
52
|
/** ShellCacheEntry.docKey; navigation replay needs it after any round trip. */
|
|
51
53
|
dk?: string;
|
|
52
54
|
/** ShellCacheEntry.prunedRecords (diagnostic). */
|
|
@@ -79,6 +81,7 @@ function isShellFrameHead(value: unknown): value is ShellFrameHead {
|
|
|
79
81
|
head.t.every((tag) => typeof tag === "string"))) &&
|
|
80
82
|
(head.ta === undefined || isFiniteNumber(head.ta)) &&
|
|
81
83
|
(head.i === undefined || typeof head.i === "string") &&
|
|
84
|
+
(head.lp === undefined || typeof head.lp === "string") &&
|
|
82
85
|
(head.dk === undefined || typeof head.dk === "string") &&
|
|
83
86
|
(head.pr === undefined || typeof head.pr === "string") &&
|
|
84
87
|
(head.no === undefined || head.no === true) &&
|
|
@@ -177,8 +177,8 @@ export type OwnedPushDelivery = (loaderId: string) => RecordAuthority;
|
|
|
177
177
|
* says the record supplies that loader's value too ("pin", "copies"), and is
|
|
178
178
|
* a placeholder (pushPlaceholder) everywhere else: without `owned`, every
|
|
179
179
|
* owner. Neither claims its loader, so the loader's own cache() HIT still
|
|
180
|
-
* delivers (the
|
|
181
|
-
* pushes in a placeholder's place).
|
|
180
|
+
* delivers (the pushes holding a promise a restored copy lets through, or its
|
|
181
|
+
* entry's pushes in a placeholder's place).
|
|
182
182
|
*/
|
|
183
183
|
export function restoreHandles(
|
|
184
184
|
handles: Record<string, SegmentHandleData>,
|
package/src/cache/types.ts
CHANGED
|
@@ -445,7 +445,7 @@ export interface ShellCacheEntry {
|
|
|
445
445
|
/** React.version captured at prerender time; the read-time invalidation gate. */
|
|
446
446
|
reactVersion: string;
|
|
447
447
|
/**
|
|
448
|
-
* Build version captured at prerender time: the RSC handler's
|
|
448
|
+
* Build version captured at prerender time: the RSC handler's version,
|
|
449
449
|
* which is the router's DOCUMENT version (router-versions.ts) — a hash of
|
|
450
450
|
* its server code and the client asset names by default, a stamp bumped on
|
|
451
451
|
* dev RSC-module edits. The second read-time gate: a persistent shared
|
|
@@ -468,6 +468,14 @@ export interface ShellCacheEntry {
|
|
|
468
468
|
* ThemeProvider.
|
|
469
469
|
*/
|
|
470
470
|
initialTheme?: string;
|
|
471
|
+
/**
|
|
472
|
+
* The payload pathname of a shell keyed by the visitor's URL
|
|
473
|
+
* (`rewrite(...).shell("visitor")`, visitorShellKey); absent when the
|
|
474
|
+
* capture rendered its key's own URL. The serve tail replays it as it does
|
|
475
|
+
* `initialTheme`, and the serve gate serves the entry only to a request
|
|
476
|
+
* that renders this location.
|
|
477
|
+
*/
|
|
478
|
+
pathname?: string;
|
|
471
479
|
/**
|
|
472
480
|
* The CAPTURE DATA SNAPSHOT, in stored/serialized form: the doc segment
|
|
473
481
|
* record every HIT replays the handler layer from (`docKey`) and the
|
|
@@ -678,11 +686,13 @@ export interface ShellSnapshotLoaderValue {
|
|
|
678
686
|
*/
|
|
679
687
|
holes: 0 | 1;
|
|
680
688
|
/**
|
|
681
|
-
* 1 when the capture saw a loader push it could not record (
|
|
682
|
-
*
|
|
683
|
-
* body): a HIT then still runs the loader
|
|
684
|
-
* (pin-first) so those pushes reach the page.
|
|
685
|
-
*
|
|
689
|
+
* 1 when the capture saw a loader push it could not record (one whose
|
|
690
|
+
* settled value holds masked nested promises, one a live-lane loader made,
|
|
691
|
+
* or one made outside any loader body): a HIT then still runs the loader
|
|
692
|
+
* body in the background (pin-first) so those pushes reach the page. A
|
|
693
|
+
* pushed promise that settles thenable-free is recorded (#1182).
|
|
694
|
+
* 0: a hole-free record is served from the pin alone and its body does not
|
|
695
|
+
* run on a HIT.
|
|
686
696
|
*
|
|
687
697
|
* Both bits are always written. A record stored before they existed (v0.17)
|
|
688
698
|
* reads each missing bit as 1 (buildShellLoaderSeed): its snapshot lacks
|
|
@@ -271,6 +271,8 @@ interface VercelShellEnvelope {
|
|
|
271
271
|
t?: string[];
|
|
272
272
|
/** initialTheme the capture render was built with (resume theme fidelity). */
|
|
273
273
|
i?: string;
|
|
274
|
+
/** ShellCacheEntry.pathname (a visitor-keyed shell's rendered location). */
|
|
275
|
+
lp?: string;
|
|
274
276
|
/** Capture data snapshot (ShellCacheEntry.snapshot). */
|
|
275
277
|
sn: ShellSnapshotRecord[];
|
|
276
278
|
/**
|
|
@@ -328,7 +330,7 @@ export interface VercelCacheStoreOptions<TEnv = unknown> {
|
|
|
328
330
|
*
|
|
329
331
|
* Vercel does not reconcile entries between deployments; the store does it
|
|
330
332
|
* through its keys, which carry the serving router's cache versions (see
|
|
331
|
-
* `
|
|
333
|
+
* `getCacheVersions`). So a deploy that changes a router's code stops reading that
|
|
332
334
|
* router's old entries, and a deploy that does not keeps them. A namespace
|
|
333
335
|
* that changes per deployment (`getCache({ namespace: VERCEL_DEPLOYMENT_ID })`)
|
|
334
336
|
* still works and clears the cache on every deploy, which is what you want
|
|
@@ -361,19 +363,6 @@ export interface VercelCacheStoreOptions<TEnv = unknown> {
|
|
|
361
363
|
defaultKey: string,
|
|
362
364
|
) => string | Promise<string>;
|
|
363
365
|
|
|
364
|
-
/**
|
|
365
|
-
* Version override, folded into every versioned key as `v/{version}/...`.
|
|
366
|
-
* When set, this exact value is used for cached data and stored HTML alike;
|
|
367
|
-
* changing it makes everything this store wrote before unreachable.
|
|
368
|
-
*
|
|
369
|
-
* Leave it unset for the default: the store keys with the versions of the
|
|
370
|
-
* router serving the request, as CFCacheStore does. Segments and `"use
|
|
371
|
-
* cache"` items use the router's data version; responses and PPR shells use
|
|
372
|
-
* its document version (see `createRouter({ version })`). Tag markers are
|
|
373
|
-
* never versioned, so an invalidation applies to every version.
|
|
374
|
-
*/
|
|
375
|
-
version?: string;
|
|
376
|
-
|
|
377
366
|
/**
|
|
378
367
|
* Max serialized entry size in bytes before a write is skipped. Defaults to
|
|
379
368
|
* VERCEL_MAX_ITEM_BYTES (2 MB - the platform's hard cap).
|
|
@@ -535,8 +524,6 @@ export class VercelCacheStore<
|
|
|
535
524
|
|
|
536
525
|
private readonly cache: VercelRuntimeCache;
|
|
537
526
|
private readonly waitUntil?: (promise: Promise<unknown>) => void;
|
|
538
|
-
/** The `version` option: used for every versioned family when set. */
|
|
539
|
-
private readonly explicitVersion?: string;
|
|
540
527
|
private readonly maxItemBytes: number;
|
|
541
528
|
private readonly memo: ResolvedShellMemoOptions;
|
|
542
529
|
private readonly handleMemos: VercelHandleMemos;
|
|
@@ -561,7 +548,6 @@ export class VercelCacheStore<
|
|
|
561
548
|
this.waitUntil = options.waitUntil;
|
|
562
549
|
this.defaults = options.defaults;
|
|
563
550
|
this.keyGenerator = options.keyGenerator;
|
|
564
|
-
this.explicitVersion = options.version;
|
|
565
551
|
this.maxItemBytes = options.maxItemBytes ?? VERCEL_MAX_ITEM_BYTES;
|
|
566
552
|
this.maxShellEntryBytes = Math.floor((this.maxItemBytes * 3) / 4);
|
|
567
553
|
this.memo = resolveShellMemoOptions(options.memo, {
|
|
@@ -1158,6 +1144,7 @@ export class VercelCacheStore<
|
|
|
1158
1144
|
reactVersion: env.rv,
|
|
1159
1145
|
buildVersion: env.bv,
|
|
1160
1146
|
initialTheme: env.i,
|
|
1147
|
+
pathname: env.lp,
|
|
1161
1148
|
snapshot: env.sn,
|
|
1162
1149
|
docKey: env.dk,
|
|
1163
1150
|
prunedRecords: env.pr,
|
|
@@ -1326,6 +1313,7 @@ export class VercelCacheStore<
|
|
|
1326
1313
|
e: Math.min(expiresAt, now + retentionTtl * 1000),
|
|
1327
1314
|
t: safeTags.length > 0 ? safeTags : undefined,
|
|
1328
1315
|
i: entry.initialTheme,
|
|
1316
|
+
lp: entry.pathname,
|
|
1329
1317
|
sn: entry.snapshot,
|
|
1330
1318
|
dk: entry.docKey,
|
|
1331
1319
|
pr: entry.prunedRecords,
|
|
@@ -1512,7 +1500,7 @@ export class VercelCacheStore<
|
|
|
1512
1500
|
// cross-family one reads as corrupt. See the class doc for passing a wider
|
|
1513
1501
|
// hash (sha256) when many keys are live.
|
|
1514
1502
|
private toStoreKey(key: string, family: CacheFamily): string {
|
|
1515
|
-
return `${versionKeyPrefix(
|
|
1503
|
+
return `${versionKeyPrefix(FAMILY_VERSION[family])}rg:${family}:${key}`;
|
|
1516
1504
|
}
|
|
1517
1505
|
|
|
1518
1506
|
private async write(
|
|
@@ -1743,7 +1731,7 @@ export class VercelCacheStore<
|
|
|
1743
1731
|
|
|
1744
1732
|
private asShellEnvelope(raw: unknown): VercelShellEnvelope | null {
|
|
1745
1733
|
if (!isRecord(raw)) return null;
|
|
1746
|
-
const { p, po, rv, bv, c, s, e, t, i, sn, dk, pr, no } = raw;
|
|
1734
|
+
const { p, po, rv, bv, c, s, e, t, i, lp, sn, dk, pr, no } = raw;
|
|
1747
1735
|
if (typeof rv !== "string" || typeof bv !== "string") return null;
|
|
1748
1736
|
// Document half: required unless navigationOnly (`no`), which stores
|
|
1749
1737
|
// neither field. Tolerate a legacy navigationOnly envelope that still
|
|
@@ -1766,6 +1754,7 @@ export class VercelCacheStore<
|
|
|
1766
1754
|
e,
|
|
1767
1755
|
t: Array.isArray(t) ? (t as string[]) : undefined,
|
|
1768
1756
|
i: typeof i === "string" ? i : undefined,
|
|
1757
|
+
lp: typeof lp === "string" ? lp : undefined,
|
|
1769
1758
|
// A non-array field reads as no records.
|
|
1770
1759
|
sn: Array.isArray(sn) ? (sn as ShellSnapshotRecord[]) : [],
|
|
1771
1760
|
dk: typeof dk === "string" ? dk : undefined,
|