@rangojs/router 0.20.0 → 0.22.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/dist/bin/rango.js +39 -15
- package/dist/types/browser/event-controller.d.ts +49 -0
- package/dist/types/browser/history-state.d.ts +16 -4
- package/dist/types/browser/navigation-store.d.ts +9 -0
- package/dist/types/browser/navigation-transaction.d.ts +7 -0
- package/dist/types/browser/partial-update.d.ts +2 -1
- package/dist/types/browser/prefetch/default-strategy.d.ts +16 -20
- package/dist/types/browser/rango-state.d.ts +3 -1
- package/dist/types/browser/react/NavigationProvider.d.ts +14 -1
- package/dist/types/browser/react/context.d.ts +25 -0
- package/dist/types/browser/react/location-state-shared.d.ts +84 -10
- package/dist/types/browser/react/location-state.d.ts +7 -2
- package/dist/types/browser/rsc-router.d.ts +13 -2
- package/dist/types/browser/types.d.ts +10 -0
- package/dist/types/build/generate-manifest.d.ts +2 -0
- package/dist/types/cache/background-task.d.ts +22 -0
- package/dist/types/cache/cache-key-utils.d.ts +50 -5
- package/dist/types/cache/cache-policy.d.ts +17 -0
- package/dist/types/cache/cache-scope.d.ts +5 -6
- package/dist/types/cache/cf/cf-cache-store.d.ts +34 -7
- package/dist/types/cache/cf/cf-cache-types.d.ts +12 -4
- package/dist/types/cache/document-cache.d.ts +8 -5
- package/dist/types/cache/handle-snapshot.d.ts +59 -50
- package/dist/types/cache/index.d.ts +3 -1
- package/dist/types/cache/invalidation-order.d.ts +14 -0
- package/dist/types/cache/memory-segment-store.d.ts +33 -1
- package/dist/types/cache/shell-snapshot.d.ts +29 -4
- package/dist/types/cache/store-scope.d.ts +22 -0
- package/dist/types/cache/tag-invalidation.d.ts +7 -6
- package/dist/types/cache/types.d.ts +84 -24
- package/dist/types/cache/vercel/vercel-cache-store.d.ts +35 -17
- package/dist/types/client-urls/navigation.d.ts +7 -1
- package/dist/types/client-urls/optimistic-location.d.ts +10 -4
- package/dist/types/errors.d.ts +6 -0
- package/dist/types/handles/deferred-resolution.d.ts +18 -1
- package/dist/types/internal-suspense-audit.d.ts +1 -0
- package/dist/types/loader-store.d.ts +4 -8
- package/dist/types/outlet-provider.d.ts +2 -1
- package/dist/types/prerender/build-shell-capture.d.ts +8 -6
- package/dist/types/prerender/cloudflare.d.ts +49 -0
- package/dist/types/prerender/create-prerender-trigger.d.ts +121 -0
- package/dist/types/prerender/index.d.ts +12 -0
- package/dist/types/prerender/memory-prerender-store.d.ts +29 -0
- package/dist/types/prerender/on-demand.d.ts +272 -0
- package/dist/types/prerender/producer-guard.d.ts +33 -0
- package/dist/types/prerender/shell-manifest-key.d.ts +1 -18
- package/dist/types/prerender/warm-request.d.ts +65 -0
- package/dist/types/prerender/warm.d.ts +65 -0
- package/dist/types/prerender/writable-store.d.ts +170 -0
- package/dist/types/prerender.d.ts +27 -0
- package/dist/types/reverse.d.ts +1 -1
- package/dist/types/route-content-wrapper.d.ts +3 -1
- package/dist/types/router/error-handling.d.ts +2 -0
- package/dist/types/router/handler-context.d.ts +1 -1
- package/dist/types/router/match-middleware/cache-lookup.d.ts +15 -1
- package/dist/types/router/navigation-snapshot.d.ts +8 -1
- package/dist/types/router/pattern-matching.d.ts +2 -0
- package/dist/types/router/prefetch-default.d.ts +4 -4
- package/dist/types/router/prerender-match.d.ts +23 -1
- package/dist/types/router/route-trie-builder.d.ts +8 -1
- package/dist/types/router/router-context.d.ts +1 -0
- package/dist/types/router/router-interfaces.d.ts +32 -1
- package/dist/types/router/router-options.d.ts +39 -5
- package/dist/types/router/segment-resolution/fresh.d.ts +7 -0
- package/dist/types/router/segment-resolution/loader-cache.d.ts +23 -10
- package/dist/types/router/segment-resolution/revalidation.d.ts +5 -1
- package/dist/types/router/segment-resolution/streamed-handler-boundary.d.ts +43 -0
- package/dist/types/router/trie-matching.d.ts +2 -0
- package/dist/types/router-versions.d.ts +39 -0
- package/dist/types/rsc/handler-context.d.ts +5 -0
- package/dist/types/rsc/shell-build-manifest.d.ts +9 -6
- package/dist/types/rsc/shell-capture-constants.d.ts +20 -5
- package/dist/types/rsc/shell-capture.d.ts +14 -1
- package/dist/types/rsc/shell-serve.d.ts +2 -2
- package/dist/types/rsc/ssr-module-loader.d.ts +15 -0
- package/dist/types/rsc/types.d.ts +12 -6
- package/dist/types/segment-boundary-content.d.ts +17 -0
- package/dist/types/segment-loader-promise.d.ts +2 -6
- package/dist/types/server/build-version-table.d.ts +53 -0
- package/dist/types/server/context.d.ts +12 -4
- package/dist/types/server/handle-store.d.ts +89 -46
- package/dist/types/server/request-context.d.ts +84 -9
- package/dist/types/suspense-audit-react.d.ts +26 -0
- package/dist/types/suspense-audit.d.ts +157 -0
- package/dist/types/testing/action-form.d.ts +34 -0
- package/dist/types/testing/build-versions.d.ts +32 -0
- package/dist/types/testing/dom.entry.d.ts +1 -1
- package/dist/types/testing/flight.entry.d.ts +3 -1
- package/dist/types/testing/index.d.ts +6 -0
- package/dist/types/testing/internal/seed-vars.d.ts +7 -2
- package/dist/types/testing/internal/server-modules.d.ts +8 -0
- package/dist/types/testing/location-state-key.d.ts +5 -1
- package/dist/types/testing/render-route.d.ts +77 -6
- package/dist/types/testing/serve-shell-request.d.ts +55 -4
- package/dist/types/testing/shell-status.d.ts +14 -6
- package/dist/types/testing/vitest-stubs/plugin-rsc.d.ts +9 -6
- package/dist/types/testing/vitest-stubs/version.d.ts +1 -0
- package/dist/types/thenable-status.d.ts +6 -0
- package/dist/types/types/handler-context.d.ts +15 -5
- package/dist/types/types/route-entry.d.ts +5 -0
- package/dist/types/urls/path-helper.d.ts +18 -0
- package/dist/types/vite/discovery/build-versions.d.ts +393 -0
- package/dist/types/vite/discovery/installed-packages.d.ts +26 -0
- package/dist/types/vite/discovery/router-versions-phase.d.ts +52 -0
- package/dist/types/vite/discovery/shell-prerender-phase.d.ts +7 -17
- package/dist/types/vite/discovery/state.d.ts +25 -0
- package/dist/types/vite/encryption-key.d.ts +18 -0
- package/dist/types/vite/inject-client-debug.d.ts +6 -25
- package/dist/types/vite/plugin-types.d.ts +27 -0
- package/dist/types/vite/plugins/{version-injector.d.ts → entry-bootstrap-injector.d.ts} +4 -6
- package/dist/types/vite/plugins/expose-ids/export-analysis.d.ts +1 -0
- package/dist/types/vite/plugins/expose-ids/router-transform.d.ts +14 -0
- package/dist/types/vite/plugins/stable-rsc-output.d.ts +51 -0
- package/dist/types/vite/plugins/version-plugin.d.ts +9 -11
- package/dist/types/vite/plugins/virtual-entries.d.ts +18 -1
- package/dist/types/vite/router-discovery.d.ts +6 -0
- package/dist/types/vite/utils/bundle-analysis.d.ts +6 -2
- package/dist/types/vite/utils/client-chunks.d.ts +2 -0
- package/dist/types/vite/utils/compare-strings.d.ts +7 -0
- package/dist/types/vite/utils/package-resolution.d.ts +8 -0
- package/dist/types/vite/utils/prerender-utils.d.ts +2 -0
- package/dist/vite/index.js +1707 -931
- package/package.json +12 -3
- package/skills/cache-guide/SKILL.md +102 -37
- package/skills/caching/SKILL.md +56 -9
- package/skills/catalog.json +1 -1
- package/skills/client-urls/SKILL.md +16 -0
- package/skills/cloudflare/SKILL.md +133 -1
- package/skills/comparison/references/framework-comparison.md +17 -13
- package/skills/deployment-caching/SKILL.md +33 -12
- package/skills/document-cache/SKILL.md +16 -14
- package/skills/hooks/SKILL.md +25 -0
- package/skills/hooks/handle-and-actions.md +5 -0
- package/skills/hooks/navigation.md +38 -0
- package/skills/hooks/state.md +213 -11
- package/skills/hooks/urls.md +40 -1
- package/skills/host-router/SKILL.md +31 -0
- package/skills/intercept/SKILL.md +6 -0
- package/skills/loader/SKILL.md +25 -5
- package/skills/middleware/SKILL.md +2 -0
- package/skills/migrate-nextjs/SKILL.md +82 -9
- package/skills/ppr/SKILL.md +150 -48
- package/skills/prerender/SKILL.md +651 -10
- package/skills/rango/SKILL.md +9 -7
- package/skills/response-routes/SKILL.md +5 -5
- package/skills/route/SKILL.md +29 -0
- package/skills/router-setup/SKILL.md +15 -1
- package/skills/testing/SKILL.md +32 -27
- package/skills/testing/cache-prerender.md +18 -17
- package/skills/testing/client-components.md +193 -8
- package/skills/testing/handles.md +2 -0
- package/skills/testing/loader.md +1 -1
- package/skills/testing/middleware.md +1 -1
- package/skills/testing/render-handler.md +18 -18
- package/skills/testing/serve-shell-request.md +167 -22
- package/skills/testing/server-actions.md +17 -17
- package/skills/testing/server-tree.md +1 -1
- package/skills/typesafety/generated-files-and-cli.md +1 -1
- package/skills/use-cache/SKILL.md +25 -10
- package/skills/vercel/SKILL.md +5 -3
- package/skills/view-transitions/SKILL.md +9 -4
- package/src/bin/rango.ts +1 -1
- package/src/browser/event-controller.ts +119 -2
- package/src/browser/history-state.ts +39 -17
- package/src/browser/link-interceptor.ts +2 -2
- package/src/browser/navigation-bridge.ts +104 -41
- package/src/browser/navigation-store.ts +26 -0
- package/src/browser/navigation-transaction.ts +24 -12
- package/src/browser/network-error-handler.ts +2 -0
- package/src/browser/partial-update.ts +58 -14
- package/src/browser/prefetch/default-strategy.ts +22 -42
- package/src/browser/rango-state.ts +3 -1
- package/src/browser/react/Link.tsx +37 -43
- package/src/browser/react/NavigationProvider.tsx +85 -1
- package/src/browser/react/context.ts +30 -0
- package/src/browser/react/location-state-shared.ts +200 -34
- package/src/browser/react/location-state.ts +28 -77
- package/src/browser/react/use-action.ts +4 -1
- package/src/browser/react/use-handle.ts +3 -0
- package/src/browser/react/use-link-status.ts +4 -3
- package/src/browser/react/use-navigation.ts +4 -1
- package/src/browser/react/use-params.ts +4 -1
- package/src/browser/react/use-pathname.ts +4 -1
- package/src/browser/react/use-search-params.ts +5 -3
- package/src/browser/react/use-segments.ts +36 -54
- package/src/browser/rsc-router.tsx +93 -31
- package/src/browser/segment-reconciler.ts +3 -3
- package/src/browser/server-action-bridge.ts +43 -7
- package/src/browser/types.ts +11 -0
- package/src/build/generate-manifest.ts +17 -0
- package/src/build/merge-full-manifests.ts +5 -0
- package/src/build/route-trie.ts +1 -0
- package/src/cache/background-task.ts +61 -0
- package/src/cache/cache-key-utils.ts +91 -12
- package/src/cache/cache-policy.ts +11 -2
- package/src/cache/cache-runtime.ts +23 -23
- package/src/cache/cache-scope.ts +48 -36
- package/src/cache/cf/cf-cache-store.ts +91 -66
- package/src/cache/cf/cf-cache-types.ts +12 -4
- package/src/cache/document-cache.ts +35 -14
- package/src/cache/handle-snapshot.ts +118 -86
- package/src/cache/index.ts +5 -0
- package/src/cache/invalidation-order.ts +53 -0
- package/src/cache/memory-segment-store.ts +52 -1
- package/src/cache/shell-snapshot.ts +52 -5
- package/src/cache/store-scope.ts +36 -0
- package/src/cache/tag-invalidation.ts +7 -5
- package/src/cache/types.ts +90 -24
- package/src/cache/vercel/vercel-cache-store.ts +68 -26
- package/src/client-urls/client-root.tsx +1 -0
- package/src/client-urls/navigation.ts +10 -0
- package/src/client-urls/optimistic-location.ts +10 -4
- package/src/client.tsx +40 -3
- package/src/errors.ts +13 -6
- package/src/handles/deferred-resolution.ts +36 -0
- package/src/internal-suspense-audit.ts +12 -0
- package/src/loader-store.ts +4 -9
- package/src/outlet-provider.tsx +25 -1
- package/src/prerender/build-shell-capture.ts +11 -9
- package/src/prerender/cloudflare.ts +130 -0
- package/src/prerender/create-prerender-trigger.ts +780 -0
- package/src/prerender/index.ts +39 -0
- package/src/prerender/memory-prerender-store.ts +115 -0
- package/src/prerender/on-demand.ts +339 -0
- package/src/prerender/producer-guard.ts +66 -0
- package/src/prerender/shell-manifest-key.ts +12 -17
- package/src/prerender/warm-request.ts +154 -0
- package/src/prerender/warm.ts +193 -0
- package/src/prerender/writable-store.ts +278 -0
- package/src/prerender.ts +29 -0
- package/src/reverse.ts +1 -1
- package/src/route-content-wrapper.tsx +107 -13
- package/src/router/error-handling.ts +12 -12
- package/src/router/find-match.ts +1 -0
- package/src/router/handler-context.ts +2 -0
- package/src/router/intercept-resolution.ts +15 -8
- package/src/router/loader-resolution.ts +2 -10
- package/src/router/manifest.ts +2 -0
- package/src/router/match-middleware/background-revalidation.ts +2 -0
- package/src/router/match-middleware/cache-lookup.ts +239 -54
- package/src/router/navigation-snapshot.ts +25 -6
- package/src/router/pattern-matching.ts +14 -0
- package/src/router/prefetch-default.ts +4 -4
- package/src/router/prerender-match.ts +460 -352
- package/src/router/request-classification.ts +15 -12
- package/src/router/route-trie-builder.ts +9 -0
- package/src/router/router-context.ts +1 -0
- package/src/router/router-interfaces.ts +35 -1
- package/src/router/router-options.ts +45 -5
- package/src/router/segment-resolution/fresh.ts +20 -19
- package/src/router/segment-resolution/loader-cache.ts +110 -77
- package/src/router/segment-resolution/revalidation.ts +34 -24
- package/src/router/segment-resolution/streamed-handler-boundary.ts +133 -0
- package/src/router/trie-matching.ts +3 -0
- package/src/router-versions.ts +60 -0
- package/src/router.ts +107 -1
- package/src/rsc/full-payload.ts +6 -2
- package/src/rsc/handler-context.ts +5 -0
- package/src/rsc/handler.ts +64 -7
- package/src/rsc/progressive-enhancement.ts +5 -1
- package/src/rsc/response-cache-serve.ts +10 -4
- package/src/rsc/rsc-rendering.ts +65 -12
- package/src/rsc/shell-build-manifest.ts +17 -12
- package/src/rsc/shell-capture-constants.ts +39 -7
- package/src/rsc/shell-capture.ts +144 -45
- package/src/rsc/shell-serve.ts +12 -6
- package/src/rsc/ssr-module-loader.ts +26 -0
- package/src/rsc/types.ts +12 -6
- package/src/segment-boundary-content.ts +25 -0
- package/src/segment-loader-promise.ts +28 -38
- package/src/segment-system.tsx +117 -57
- package/src/server/build-version-table.ts +130 -0
- package/src/server/context.ts +40 -17
- package/src/server/cookie-store.ts +5 -0
- package/src/server/handle-store.ts +357 -127
- package/src/server/request-context.ts +149 -12
- package/src/ssr/ssr-root.tsx +32 -13
- package/src/suspense-audit-react.tsx +98 -0
- package/src/suspense-audit.ts +1030 -0
- package/src/testing/action-form.ts +66 -0
- package/src/testing/build-versions.ts +64 -0
- package/src/testing/dispatch.ts +6 -0
- package/src/testing/dom.entry.ts +1 -0
- package/src/testing/flight-runtime.d.ts +27 -0
- package/src/testing/flight.entry.ts +4 -0
- package/src/testing/index.ts +22 -0
- package/src/testing/internal/context.ts +2 -1
- package/src/testing/internal/seed-vars.ts +14 -2
- package/src/testing/internal/server-modules.ts +32 -0
- package/src/testing/location-state-key.ts +18 -8
- package/src/testing/render-handler.ts +2 -1
- package/src/testing/render-route.tsx +293 -46
- package/src/testing/serve-shell-request.ts +262 -37
- package/src/testing/shell-status.ts +17 -6
- package/src/testing/vitest-stubs/plugin-rsc.ts +37 -11
- package/src/testing/vitest-stubs/version.ts +4 -1
- package/src/thenable-status.ts +10 -0
- package/src/types/handler-context.ts +15 -5
- package/src/types/route-entry.ts +6 -0
- package/src/urls/path-helper.ts +69 -9
- package/src/use-loader.tsx +57 -30
- package/src/vite/discovery/build-versions.ts +1281 -0
- package/src/vite/discovery/bundle-postprocess.ts +4 -0
- package/src/vite/discovery/discover-routers.ts +15 -0
- package/src/vite/discovery/installed-packages.ts +159 -0
- package/src/vite/discovery/prerender-collection.ts +38 -1
- package/src/vite/discovery/router-versions-phase.ts +336 -0
- package/src/vite/discovery/shell-prerender-phase.ts +33 -43
- package/src/vite/discovery/state.ts +36 -1
- package/src/vite/discovery/virtual-module-codegen.ts +7 -2
- package/src/vite/encryption-key.ts +101 -9
- package/src/vite/inject-client-debug.ts +42 -20
- package/src/vite/plugin-types.ts +28 -0
- package/src/vite/plugins/{version-injector.ts → entry-bootstrap-injector.ts} +7 -22
- package/src/vite/plugins/expose-ids/export-analysis.ts +1 -1
- package/src/vite/plugins/expose-ids/router-transform.ts +36 -15
- package/src/vite/plugins/expose-internal-ids.ts +12 -3
- package/src/vite/plugins/stable-rsc-output.ts +147 -0
- package/src/vite/plugins/version-plugin.ts +19 -24
- package/src/vite/plugins/version.d.ts +17 -2
- package/src/vite/plugins/virtual-entries.ts +39 -6
- package/src/vite/rango.ts +28 -3
- package/src/vite/router-discovery.ts +96 -13
- package/src/vite/utils/bundle-analysis.ts +39 -7
- package/src/vite/utils/client-chunks.ts +5 -1
- package/src/vite/utils/compare-strings.ts +9 -0
- package/src/vite/utils/package-resolution.ts +9 -0
- package/src/vite/utils/prerender-utils.ts +4 -1
- package/src/vite/utils/shared-utils.ts +1 -1
- package/dist/types/segment-content-promise.d.ts +0 -13
- package/src/segment-content-promise.ts +0 -67
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
2
|
/**
|
|
3
|
-
* Plugin that auto-injects
|
|
4
|
-
* custom entry.rsc
|
|
5
|
-
*
|
|
6
|
-
* automatically. It also ensures the routes-manifest and loader-manifest
|
|
7
|
-
* virtual modules are always imported.
|
|
3
|
+
* Plugin that auto-injects the routes-manifest and loader-manifest imports
|
|
4
|
+
* into a custom entry.rsc file (the Cloudflare preset, where the consumer owns
|
|
5
|
+
* the worker entry).
|
|
8
6
|
*
|
|
9
7
|
* The loader-manifest import is what makes fetchable loaders resolvable on a
|
|
10
8
|
* custom worker entry. The virtual RSC entry (getVirtualEntryRSC) imports the
|
|
@@ -18,4 +16,4 @@ import type { Plugin } from "vite";
|
|
|
18
16
|
* manifest, hence the production-only failure this fixes.
|
|
19
17
|
* @internal
|
|
20
18
|
*/
|
|
21
|
-
export declare function
|
|
19
|
+
export declare function createEntryBootstrapInjectorPlugin(rscEntryPath: string | undefined): Plugin;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CreateExportBinding } from "./types.js";
|
|
2
2
|
export declare function isExportOnlyFile(code: string, bindings: CreateExportBinding[]): boolean;
|
|
3
|
+
export declare function createCallPattern(fnNames: string[]): RegExp;
|
|
3
4
|
export declare function countCreateCallsForNames(code: string, fnNames: string[]): number;
|
|
4
5
|
export declare function offsetToLineColumn(code: string, index: number): {
|
|
5
6
|
line: number;
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
2
|
import MagicString from "magic-string";
|
|
3
|
+
/**
|
|
4
|
+
* A router's `$$id`: a hash of its root-relative file and of its position
|
|
5
|
+
* among the file's createRouter() calls.
|
|
6
|
+
*
|
|
7
|
+
* Not of the call's line. `code` is TS-transformed, and a dev server keeps
|
|
8
|
+
* comments there that a build drops, so a line of `code` gave build-time
|
|
9
|
+
* discovery and the bundle different ids for any router with a comment above
|
|
10
|
+
* it (e2e/test-app, tests/cloudflare-basic): the build registered the lazy
|
|
11
|
+
* route manifest under an id no running router had. And a line of the file as
|
|
12
|
+
* written changes with every blank line or comment added above the call,
|
|
13
|
+
* which renamed the state cookie, the route manifest chunk and the router's
|
|
14
|
+
* cache versions for an edit that changed nothing.
|
|
15
|
+
*/
|
|
16
|
+
export declare function routerId(filePath: string, callIndex: number): string;
|
|
3
17
|
export declare function transformRouter(code: string, filePath: string, routerFnNames: string[], absolutePath?: string, warn?: (message: string) => void): {
|
|
4
18
|
code: string;
|
|
5
19
|
map: ReturnType<MagicString["generateMap"]>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type Plugin } from "vite";
|
|
2
|
+
/** One property of an object literal, by its position in the source. */
|
|
3
|
+
export interface LiteralProperty {
|
|
4
|
+
readonly key: string;
|
|
5
|
+
/** Range of the whole property, key included. */
|
|
6
|
+
readonly start: number;
|
|
7
|
+
readonly end: number;
|
|
8
|
+
/** The value's AST node. */
|
|
9
|
+
readonly value: any;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The properties of an object-literal AST node, or undefined when it is not an
|
|
13
|
+
* object literal of plain keys (a spread, a computed key).
|
|
14
|
+
*/
|
|
15
|
+
export declare function literalProperties(object: any): LiteralProperty[] | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* The properties of a module's `export default { ... }`, or undefined when
|
|
18
|
+
* the module does not parse or is not that shape. plugin-rsc generates its
|
|
19
|
+
* registries (the server-reference map, the assets manifest) in this form.
|
|
20
|
+
*/
|
|
21
|
+
export declare function defaultExportProperties(code: string): LiteralProperty[] | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Return `code` with the properties of its default-exported object literal
|
|
24
|
+
* sorted by key, or undefined when there is nothing to reorder (or the module
|
|
25
|
+
* is not that shape).
|
|
26
|
+
*/
|
|
27
|
+
export declare function sortDefaultExportProperties(code: string): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Return `code` with its default import of plugin-rsc's assets manifest
|
|
30
|
+
* renamed to {@link ASSETS_MANIFEST_BINDING}, or undefined when there is
|
|
31
|
+
* nothing to rename (no such import under a generated name, or the module
|
|
32
|
+
* uses the canonical name for something else).
|
|
33
|
+
*/
|
|
34
|
+
export declare function canonicalAssetsManifestBinding(code: string): string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Removes two run-to-run differences from plugin-rsc 0.5.35's build output.
|
|
37
|
+
* The cache versions hash these bytes (discovery/build-versions.ts).
|
|
38
|
+
*
|
|
39
|
+
* 1. Property order of the server-reference map. plugin-rsc writes it in the
|
|
40
|
+
* order its transforms first saw each `"use server"` module
|
|
41
|
+
* (`ServerReferencesManager.claimMap`), which varies with the concurrent
|
|
42
|
+
* scan builds (e2e/test-app: 2 of 2 consecutive builds differed). Sorted
|
|
43
|
+
* here so a minified server build, where stripServerReferenceMap finds no
|
|
44
|
+
* region comments, still hashes the same bytes.
|
|
45
|
+
* 2. Local name of the assets-manifest import. plugin-rsc imports the manifest
|
|
46
|
+
* under three names; the bundler merges them into one import per chunk and
|
|
47
|
+
* keeps a different one from build to build (the cache-versions fixture:
|
|
48
|
+
* 1 of 10 concurrent builds). One name in, one name out.
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
export declare function stableRscOutput(): Plugin;
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { type Plugin } from "vite";
|
|
2
2
|
/**
|
|
3
|
-
* Plugin providing
|
|
4
|
-
* Exports VERSION that changes when RSC modules change (dev) or at build time (production).
|
|
3
|
+
* Plugin providing the `@rangojs/router:version` virtual module.
|
|
5
4
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Dev: exports a VERSION stamp used for both versions of every router. It
|
|
6
|
+
* updates when the server starts and when an RSC module changes via HMR (the
|
|
7
|
+
* version module is invalidated). Client-only HMR changes do not update it:
|
|
8
|
+
* they do not affect server-rendered content or cached RSC payloads.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* Client-only HMR changes don't update the version since they don't affect
|
|
15
|
-
* server-rendered content or cached RSC payloads.
|
|
10
|
+
* Build: exports a placeholder for the per-router versions table. The module
|
|
11
|
+
* holds nothing that varies between builds; the table is written into the
|
|
12
|
+
* built chunk after the server output is hashed (the buildApp post hook in
|
|
13
|
+
* router-discovery.ts). See docs/design/per-app-cache-version.md.
|
|
16
14
|
* @internal
|
|
17
15
|
*/
|
|
18
16
|
export declare function createVersionPlugin(): Plugin;
|
|
@@ -22,7 +22,7 @@ export declare function getVirtualEntrySSR(headScripts?: HeadScriptsOption, prog
|
|
|
22
22
|
* registered for the _rsc_loader endpoint and fail in production.
|
|
23
23
|
*
|
|
24
24
|
* Single source of truth: both the generated virtual RSC entry below and the
|
|
25
|
-
* custom-entry injector (
|
|
25
|
+
* custom-entry injector (entry-bootstrap-injector) consume this list, so a new
|
|
26
26
|
* bootstrap manifest cannot be added to one path and forgotten on the other.
|
|
27
27
|
* That exact drift (loader-manifest present here but missing from the injector)
|
|
28
28
|
* is what left fetchable loaders unresolved on custom worker entries.
|
|
@@ -36,4 +36,21 @@ export declare const VIRTUAL_IDS: {
|
|
|
36
36
|
readonly rsc: "virtual:rsc-router/entry.rsc.js";
|
|
37
37
|
readonly version: "@rangojs/router:version";
|
|
38
38
|
};
|
|
39
|
+
/** Dev: one stamp for both versions of every router, bumped on RSC edits. */
|
|
39
40
|
export declare function getVirtualVersionContent(version: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Free identifier the production version module ships in place of the table.
|
|
43
|
+
* The versions are hashes of the built server code, so they cannot be part of
|
|
44
|
+
* it: the buildApp post hook (router-discovery.ts) replaces this token in the
|
|
45
|
+
* written chunk once the hashes are final (runRouterVersionsPhase,
|
|
46
|
+
* discovery/router-versions-phase.ts). An unreplaced token throws a ReferenceError
|
|
47
|
+
* when the module evaluates, so a build that skipped the step cannot serve
|
|
48
|
+
* with a constant version.
|
|
49
|
+
*/
|
|
50
|
+
export declare const ROUTER_VERSIONS_PLACEHOLDER = "__RANGO_ROUTER_VERSIONS__";
|
|
51
|
+
/**
|
|
52
|
+
* Production: byte-identical in every build, so it never moves the hashes it
|
|
53
|
+
* is later filled with. VERSION is the whole-build document version (the
|
|
54
|
+
* table's "*" entry).
|
|
55
|
+
*/
|
|
56
|
+
export declare function getVirtualBuildVersionContent(): string;
|
|
@@ -35,6 +35,12 @@ export declare function createTempRscServer(state: DiscoveryState, options?: {
|
|
|
35
35
|
*/
|
|
36
36
|
realSsrEntry?: boolean;
|
|
37
37
|
}): Promise<ViteDevServer>;
|
|
38
|
+
import type { BuildEnvOption, BuildEnvFactoryContext, BuildEnvResult } from "./plugin-types.js";
|
|
39
|
+
/**
|
|
40
|
+
* Resolve the buildEnv option into a concrete { env, dispose? } result.
|
|
41
|
+
* Handles all four input shapes: false, "auto", factory, plain object.
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolveBuildEnv(option: BuildEnvOption | undefined, factoryCtx: BuildEnvFactoryContext): Promise<BuildEnvResult | null>;
|
|
38
44
|
/**
|
|
39
45
|
* Plugin that discovers router instances at dev/build time via the RSC environment.
|
|
40
46
|
*
|
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
export declare function findMatchingParenInBundle(code: string, openParenPos: number): number;
|
|
7
7
|
/**
|
|
8
8
|
* Scan a bundled chunk for handler exports and extract their names + $$id values.
|
|
9
|
-
* Optionally detects passthrough flag
|
|
9
|
+
* Optionally detects the passthrough flag by parsing the call body, and marks
|
|
10
|
+
* onDemand from the authoritative discovery-derived handlerId set.
|
|
11
|
+
* @internal Exported for testing only.
|
|
10
12
|
*/
|
|
11
|
-
export declare function extractHandlerExportsFromChunk(chunkCode: string, handlerModules: Map<string, string[]>, fnName: string, detectPassthrough: boolean): Array<{
|
|
13
|
+
export declare function extractHandlerExportsFromChunk(chunkCode: string, handlerModules: Map<string, string[]>, fnName: string, detectPassthrough: boolean, onDemandHandlerIds?: ReadonlyMap<string, string>): Array<{
|
|
12
14
|
name: string;
|
|
13
15
|
handlerId: string;
|
|
14
16
|
passthrough: boolean;
|
|
17
|
+
onDemand: boolean;
|
|
15
18
|
}>;
|
|
16
19
|
/**
|
|
17
20
|
* Evict handler code from a bundled chunk, replacing full call expressions with stubs.
|
|
@@ -22,6 +25,7 @@ export declare function evictHandlerCode(code: string, exports: Array<{
|
|
|
22
25
|
name: string;
|
|
23
26
|
handlerId: string;
|
|
24
27
|
passthrough?: boolean;
|
|
28
|
+
onDemand?: boolean;
|
|
25
29
|
}>, fnName: string, brand: string): {
|
|
26
30
|
code: string;
|
|
27
31
|
savedBytes: number;
|
|
@@ -58,6 +58,8 @@ export declare function directoryClientChunks(meta: ClientChunkMeta, ctx?: Clien
|
|
|
58
58
|
* fallback refinement does not apply — the consumer owns the grouping).
|
|
59
59
|
*/
|
|
60
60
|
export declare function resolveClientChunks(option: ClientChunks | undefined, ctx?: ClientChunkContext): RscClientChunksFn | undefined;
|
|
61
|
+
/** @vitejs/plugin-rsc's client-reference map; its group modules sit under it. */
|
|
62
|
+
export declare const CLIENT_REFERENCES_MODULE_ID = "\0virtual:vite-rsc/client-references";
|
|
61
63
|
/**
|
|
62
64
|
* Build-end group report under `DEBUG=rango:chunks`: one line per client
|
|
63
65
|
* reference group with its client-reference count and the size of the group's
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code-unit order, the same on every machine. Generated modules and the cache
|
|
3
|
+
* version inputs are sorted with it: `localeCompare` depends on the build
|
|
4
|
+
* machine's ICU data, and build output has to be byte-identical across machines
|
|
5
|
+
* (discovery/build-versions.ts hashes it).
|
|
6
|
+
*/
|
|
7
|
+
export declare function compareStrings(a: string, b: string): number;
|
|
@@ -3,4 +3,12 @@ export declare function isInstalledFromNpm(): boolean;
|
|
|
3
3
|
export declare function isWorkspaceDevelopment(): boolean;
|
|
4
4
|
export declare function getExcludeDeps(): string[];
|
|
5
5
|
export declare function getPackageAliases(): Record<string, string>;
|
|
6
|
+
/**
|
|
7
|
+
* @vitejs/plugin-rsc puts these vendor specifiers in `optimizeDeps.include`,
|
|
8
|
+
* and Vite resolves them from the app root, where pnpm's strict layout does
|
|
9
|
+
* not link the plugin unless the app lists it (#1050). Aliased to the copy
|
|
10
|
+
* the router resolves, which therefore also wins over an app's own
|
|
11
|
+
* @vitejs/plugin-rsc. Must hold every vendor entry the plugin includes:
|
|
12
|
+
* optimize-deps-vendor-resolution.test.ts checks the resolved config.
|
|
13
|
+
*/
|
|
6
14
|
export declare function getVendorAliases(): Record<string, string>;
|
|
@@ -18,6 +18,8 @@ export declare function notifyOnError(registry: Map<string, any>, error: unknown
|
|
|
18
18
|
* URL / handler name for the log line; `elapsed` is the per-entry duration string.
|
|
19
19
|
*/
|
|
20
20
|
export declare function resolvePrerenderError(registry: Map<string, any>, error: any, onError: "fail" | "warn", label: string, elapsed: string, phase: "prerender" | "static", routeKey?: string, pathname?: string): void;
|
|
21
|
+
/** Build scratch space, relative to the project root. Never shipped. */
|
|
22
|
+
export declare const RANGO_BUILD_DIR = "node_modules/.rangojs-router-build";
|
|
21
23
|
export declare function resetStagedBuildAssets(projectRoot: string): void;
|
|
22
24
|
/**
|
|
23
25
|
* Write one content-hashed `export default <value>;` asset module into `dir`
|