vinext 1.0.0-beta.6 → 1.0.0-beta.8
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 +47 -3
- package/dist/build/action-owner-manifest.d.ts +42 -0
- package/dist/build/action-owner-manifest.js +110 -0
- package/dist/build/clean-output.js +1 -4
- package/dist/build/client-build-config.js +10 -11
- package/dist/build/prerender.d.ts +1 -1
- package/dist/build/prerender.js +12 -6
- package/dist/build/report.d.ts +1 -1
- package/dist/build/route-classification-manifest.d.ts +1 -1
- package/dist/build/static-export.d.ts +1 -1
- package/dist/client/app-nav-failure-handler.js +1 -0
- package/dist/client/navigation-runtime.d.ts +5 -3
- package/dist/client/navigation-runtime.js +4 -8
- package/dist/entries/app-browser-entry.d.ts +1 -1
- package/dist/entries/app-rsc-entry.d.ts +2 -1
- package/dist/entries/app-rsc-entry.js +111 -8
- package/dist/entries/pages-client-entry.d.ts +1 -1
- package/dist/entries/pages-server-entry.d.ts +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +119 -26
- package/dist/plugins/action-owner-manifest.d.ts +14 -0
- package/dist/plugins/action-owner-manifest.js +84 -0
- package/dist/plugins/ast-utils.d.ts +30 -1
- package/dist/plugins/ast-utils.js +76 -1
- package/dist/plugins/css-module-imports.d.ts +2 -2
- package/dist/plugins/css-module-imports.js +5 -13
- package/dist/plugins/dynamic-preload-metadata.js +13 -34
- package/dist/plugins/environment.d.ts +11 -0
- package/dist/plugins/environment.js +7 -0
- package/dist/plugins/extensionless-dynamic-import.js +11 -35
- package/dist/plugins/fonts.js +8 -12
- package/dist/plugins/ignore-dynamic-requests.d.ts +2 -4
- package/dist/plugins/ignore-dynamic-requests.js +29 -59
- package/dist/plugins/import-meta-url.d.ts +15 -9
- package/dist/plugins/import-meta-url.js +310 -85
- package/dist/plugins/instrumentation-client.js +4 -5
- package/dist/plugins/middleware-export-validation.js +5 -17
- package/dist/plugins/middleware-server-only.js +2 -2
- package/dist/plugins/og-asset-ownership.js +18 -26
- package/dist/plugins/og-assets.js +2 -4
- package/dist/plugins/optimize-imports.js +2 -4
- package/dist/plugins/pages-node-externals.js +13 -40
- package/dist/plugins/remove-console.js +2 -4
- package/dist/plugins/require-condition-resolution.d.ts +16 -0
- package/dist/plugins/require-condition-resolution.js +167 -0
- package/dist/plugins/require-context.js +11 -46
- package/dist/plugins/sass.js +1 -1
- package/dist/plugins/server-externals-manifest.js +1 -23
- package/dist/plugins/strip-server-exports.js +13 -19
- package/dist/plugins/styled-jsx.js +17 -19
- package/dist/plugins/transform-result.d.ts +10 -0
- package/dist/plugins/transform-result.js +10 -0
- package/dist/plugins/transitive-externals.js +7 -21
- package/dist/plugins/typeof-window.d.ts +3 -8
- package/dist/plugins/typeof-window.js +5 -15
- package/dist/plugins/use-cache-callable.js +12 -22
- package/dist/plugins/wasm-module-import.js +1 -1
- package/dist/plugins/worker-image-imports.d.ts +12 -0
- package/dist/plugins/worker-image-imports.js +136 -0
- package/dist/routing/app-route-graph.d.ts +3 -2
- package/dist/routing/app-route-graph.js +1 -1
- package/dist/routing/route-pattern.d.ts +8 -1
- package/dist/routing/route-pattern.js +28 -1
- package/dist/routing/route-validation.js +7 -1
- package/dist/server/accept-encoding.d.ts +1 -2
- package/dist/server/accept-encoding.js +1 -4
- package/dist/server/app-action-forwarding.d.ts +18 -0
- package/dist/server/app-action-forwarding.js +140 -0
- package/dist/server/app-browser-entry.js +231 -50
- package/dist/server/app-browser-error.d.ts +1 -2
- package/dist/server/app-browser-error.js +1 -5
- package/dist/server/app-browser-history-controller.d.ts +16 -1
- package/dist/server/app-browser-history-controller.js +135 -18
- package/dist/server/app-browser-navigation-abort.d.ts +16 -0
- package/dist/server/app-browser-navigation-abort.js +29 -0
- package/dist/server/app-browser-navigation-controller.d.ts +4 -0
- package/dist/server/app-browser-navigation-controller.js +22 -6
- package/dist/server/app-browser-navigation-response.d.ts +11 -0
- package/dist/server/app-browser-navigation-response.js +8 -0
- package/dist/server/app-browser-popstate.d.ts +6 -1
- package/dist/server/app-browser-popstate.js +6 -2
- package/dist/server/app-browser-server-action-client.js +1 -1
- package/dist/server/app-browser-state.d.ts +2 -2
- package/dist/server/app-browser-state.js +3 -3
- package/dist/server/app-browser-stream.d.ts +0 -2
- package/dist/server/app-browser-supplemental-refresh.d.ts +49 -0
- package/dist/server/app-browser-supplemental-refresh.js +190 -0
- package/dist/server/app-browser-visible-commit.js +23 -12
- package/dist/server/app-elements-wire.d.ts +2 -0
- package/dist/server/app-elements-wire.js +7 -0
- package/dist/server/app-history-state.d.ts +22 -1
- package/dist/server/app-history-state.js +93 -9
- package/dist/server/app-optimistic-routing.d.ts +22 -1
- package/dist/server/app-optimistic-routing.js +137 -12
- package/dist/server/app-page-cache-finalizer.d.ts +3 -1
- package/dist/server/app-page-cache-finalizer.js +6 -6
- package/dist/server/app-page-cache.d.ts +2 -1
- package/dist/server/app-page-cache.js +2 -2
- package/dist/server/app-page-dispatch.d.ts +4 -1
- package/dist/server/app-page-dispatch.js +10 -1
- package/dist/server/app-page-element-builder.d.ts +1 -0
- package/dist/server/app-page-element-builder.js +1 -0
- package/dist/server/app-page-ppr-runtime.js +3 -2
- package/dist/server/app-page-render.d.ts +2 -1
- package/dist/server/app-page-render.js +6 -3
- package/dist/server/app-page-request.d.ts +2 -33
- package/dist/server/app-page-request.js +1 -27
- package/dist/server/app-page-route-wiring.d.ts +1 -0
- package/dist/server/app-page-route-wiring.js +4 -0
- package/dist/server/app-page-segment-state.d.ts +2 -2
- package/dist/server/app-page-segment-state.js +14 -8
- package/dist/server/app-ppr-fallback-shell.d.ts +2 -2
- package/dist/server/app-ppr-fallback-shell.js +3 -6
- package/dist/server/app-route-handler-dispatch.js +4 -1
- package/dist/server/app-route-handler-execution.js +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +2 -1
- package/dist/server/app-rsc-cache-busting.js +34 -8
- package/dist/server/app-rsc-handler.d.ts +4 -2
- package/dist/server/app-rsc-handler.js +57 -9
- package/dist/server/app-rsc-request-normalization.d.ts +2 -0
- package/dist/server/app-rsc-request-normalization.js +5 -1
- package/dist/server/app-rsc-route-matching.d.ts +4 -3
- package/dist/server/app-rsc-route-matching.js +14 -42
- package/dist/server/app-server-action-execution.d.ts +3 -0
- package/dist/server/app-server-action-execution.js +77 -2
- package/dist/server/app-ssr-entry.js +6 -6
- package/dist/server/app-ssr-stream.d.ts +1 -1
- package/dist/server/app-ssr-stream.js +2 -2
- package/dist/server/app-visited-response-cache.d.ts +6 -1
- package/dist/server/app-visited-response-cache.js +18 -2
- package/dist/server/dev-route-files.js +2 -5
- package/dist/server/dev-server.d.ts +5 -13
- package/dist/server/dev-server.js +22 -22
- package/dist/server/dev-stack-sourcemap.d.ts +1 -2
- package/dist/server/dev-stack-sourcemap.js +1 -4
- package/dist/server/headers.d.ts +5 -1
- package/dist/server/headers.js +5 -1
- package/dist/server/isr-cache.d.ts +6 -14
- package/dist/server/isr-cache.js +6 -27
- package/dist/server/middleware.d.ts +3 -16
- package/dist/server/middleware.js +2 -19
- package/dist/server/navigation-planner.d.ts +1 -0
- package/dist/server/navigation-planner.js +57 -9
- package/dist/server/navigation-trace.d.ts +1 -0
- package/dist/server/navigation-trace.js +1 -0
- package/dist/server/pages-data-route.d.ts +1 -10
- package/dist/server/pages-data-route.js +1 -12
- package/dist/server/pages-node-compat.d.ts +1 -4
- package/dist/server/pages-node-compat.js +1 -7
- package/dist/server/pages-readiness.js +4 -4
- package/dist/server/prerender-route-params.d.ts +1 -2
- package/dist/server/prerender-route-params.js +1 -4
- package/dist/server/prod-server.js +3 -1
- package/dist/shims/cache-runtime.js +39 -22
- package/dist/shims/cache.d.ts +1 -1
- package/dist/shims/dynamic.d.ts +3 -3
- package/dist/shims/dynamic.js +4 -6
- package/dist/shims/error.js +1 -1
- package/dist/shims/fetch-cache.d.ts +3 -1
- package/dist/shims/fetch-cache.js +23 -4
- package/dist/shims/internal/app-route-prefetch-policy.d.ts +6 -7
- package/dist/shims/internal/app-route-prefetch-policy.js +5 -4
- package/dist/shims/link.js +1 -1
- package/dist/shims/navigation.d.ts +12 -3
- package/dist/shims/navigation.js +46 -11
- package/dist/shims/navigation.react-server.js +1 -1
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/router.js +75 -4
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +1 -0
- package/dist/utils/built-asset-url.d.ts +1 -1
- package/dist/utils/built-asset-url.js +4 -2
- package/dist/utils/package-name.d.ts +11 -0
- package/dist/utils/package-name.js +18 -0
- package/dist/utils/path.d.ts +8 -1
- package/dist/utils/path.js +21 -1
- package/dist/utils/react-compiler-support.d.ts +20 -0
- package/dist/utils/react-compiler-support.js +29 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Run Next.js applications on Vite, with Cloudflare Workers as the primary deployment target.
|
|
4
4
|
|
|
5
|
+
**Website:** [vinext.dev](https://vinext.dev)
|
|
6
|
+
|
|
5
7
|
> **Read the announcement:** [How we rebuilt Next.js with AI in one week](https://blog.cloudflare.com/vinext/)
|
|
6
8
|
|
|
7
9
|
> **Under active development.** vinext supports substantial Next.js applications today, but it is not yet a drop-in replacement for every application or production workload. Expect compatibility gaps, especially in newer App Router features, and evaluate it against your own application before adopting it.
|
|
@@ -516,12 +518,12 @@ These are deployed to Cloudflare Workers and updated on every push to `main`:
|
|
|
516
518
|
| App Router (minimal) | Minimal App Router on Workers | [app-router-cloudflare.vinext.workers.dev](https://app-router-cloudflare.vinext.workers.dev) |
|
|
517
519
|
| Pages Router (minimal) | Minimal Pages Router on Workers | [pages-router-cloudflare.vinext.workers.dev](https://pages-router-cloudflare.vinext.workers.dev) |
|
|
518
520
|
| RealWorld API | REST API routes example | [realworld-api-rest.vinext.workers.dev](https://realworld-api-rest.vinext.workers.dev) |
|
|
519
|
-
| Benchmarks Dashboard | Build performance tracking over time (D1-backed) | [vinext
|
|
521
|
+
| Benchmarks Dashboard | Build performance tracking over time (D1-backed) | [vinext.dev/benchmarks](https://vinext.dev/benchmarks) |
|
|
520
522
|
| App Router + Nitro | App Router deployed via Nitro (multi-platform) | [examples/app-router-nitro](examples/app-router-nitro) |
|
|
521
523
|
|
|
522
524
|
## API coverage
|
|
523
525
|
|
|
524
|
-
~94% of the Next.js 16 API surface has full or partial support. The remaining gaps are intentional stubs for deprecated features
|
|
526
|
+
~94% of the Next.js 16 API surface has full or partial support. The remaining gaps are intentional stubs for deprecated features, plus Partial Prerendering and Cache Components. Next.js 16 reworked PPR into `"use cache"`; vinext implements that directive for file-level and function-level caching, but full `cacheComponents` behavior is still incomplete — see [Known gaps we're working on](#known-gaps-were-working-on).
|
|
525
527
|
|
|
526
528
|
> ✅ = full implementation | 🟡 = partial (runtime behavior correct, some build-time optimizations missing) | ⬜ = intentional stub/no-op
|
|
527
529
|
|
|
@@ -604,6 +606,33 @@ Every `next/*` import is shimmed to a Vite-compatible implementation.
|
|
|
604
606
|
| `images` config | 🟡 | Parsed but not used for optimization |
|
|
605
607
|
| `experimental.optimizePackageImports` | ✅ | Rewrites barrel imports to direct sub-module imports in RSC/SSR environments. A default set (lucide-react, date-fns, radix-ui, antd, MUI, and others) are always optimized. Add package names here to extend the list. |
|
|
606
608
|
| `vinext({ nextConfig })` | ✅ | Inline Next-style config from `vite.config.*`. Supports object-form and function-form config. When provided, this overrides root `next.config.*`. |
|
|
609
|
+
| `vinext({ react: { compiler: true } })` | ✅ | React Compiler auto memoization. Needs `@vitejs/plugin-react` 6.1+ and the optional `oxc-transform-react` package. |
|
|
610
|
+
|
|
611
|
+
### React Compiler
|
|
612
|
+
|
|
613
|
+
vinext auto-registers `@vitejs/plugin-react`, so the React Compiler is enabled through the same `react` option:
|
|
614
|
+
|
|
615
|
+
```ts
|
|
616
|
+
import { defineConfig } from "vite";
|
|
617
|
+
import vinext from "vinext";
|
|
618
|
+
|
|
619
|
+
export default defineConfig({
|
|
620
|
+
plugins: [vinext({ react: { compiler: true } })],
|
|
621
|
+
});
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
The transform itself ships separately, so install it alongside:
|
|
625
|
+
|
|
626
|
+
```bash
|
|
627
|
+
npm install -D oxc-transform-react
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
This requires `@vitejs/plugin-react` 6.1.0 or newer. Older versions accept the option and drop it, so vinext fails with an actionable error instead of leaving the compiler silently disabled. The compiler runs on the client environment only.
|
|
631
|
+
|
|
632
|
+
One caveat: modules whose JSX is lowered earlier in the pipeline are not memoized. Those build and behave correctly, they just miss auto memoization:
|
|
633
|
+
|
|
634
|
+
- JSX in plain `.js` files, which `vinext:jsx-in-js` compiles first so the compiler can parse them at all. Rename to `.jsx` or `.tsx` to get memoization.
|
|
635
|
+
- Components using `<style jsx>`, which `vinext:styled-jsx` compiles through the Next.js SWC transform before the compiler runs.
|
|
607
636
|
|
|
608
637
|
### Environment variable loading (`.env*`)
|
|
609
638
|
|
|
@@ -643,16 +672,21 @@ The cache is pluggable. The default `MemoryCacheHandler` works out of the box. S
|
|
|
643
672
|
Instead of wiring up cache handlers imperatively from a worker entry, you can declare them in the `vinext()` plugin config. The `@vinext/cloudflare` package ships Cloudflare adapters for this:
|
|
644
673
|
|
|
645
674
|
- **`kvDataAdapter()`** (`@vinext/cloudflare/cache/kv-data-adapter`) — backs the `"use cache"` data cache with a Workers KV namespace.
|
|
675
|
+
- **`cdnAdapter()`** (`@vinext/cloudflare/cache/cdn-adapter`) — serves page-level ISR from the Cloudflare Workers Cache (`ctx.cache`) instead of from the origin.
|
|
676
|
+
|
|
677
|
+
The two fill different slots and can be used together:
|
|
646
678
|
|
|
647
679
|
```ts
|
|
648
680
|
import { defineConfig } from "vite";
|
|
649
681
|
import vinext from "vinext";
|
|
682
|
+
import { cdnAdapter } from "@vinext/cloudflare/cache/cdn-adapter";
|
|
650
683
|
import { kvDataAdapter } from "@vinext/cloudflare/cache/kv-data-adapter";
|
|
651
684
|
|
|
652
685
|
export default defineConfig({
|
|
653
686
|
plugins: [
|
|
654
687
|
vinext({
|
|
655
688
|
cache: {
|
|
689
|
+
cdn: cdnAdapter(),
|
|
656
690
|
data: kvDataAdapter(),
|
|
657
691
|
},
|
|
658
692
|
}),
|
|
@@ -670,6 +704,16 @@ The KV data adapter reads `env[binding]` at runtime, so add the matching KV name
|
|
|
670
704
|
|
|
671
705
|
`binding` defaults to `VINEXT_KV_CACHE`, so `kvDataAdapter()` with no options works as long as that's your binding name. Other options: `appPrefix` (namespace cache keys to isolate multiple apps in one KV namespace), `ttlSeconds` (default KV `expirationTtl`, default 30 days), and `tagCacheTtlMs` (in-memory tag-invalidation cache TTL, default 5s).
|
|
672
706
|
|
|
707
|
+
`cdnAdapter()` takes no options, but the Workers Cache only exposes `ctx.cache` when `cache.enabled` is set in `wrangler.jsonc`:
|
|
708
|
+
|
|
709
|
+
```jsonc
|
|
710
|
+
{
|
|
711
|
+
"cache": { "enabled": true },
|
|
712
|
+
}
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
While the data adapter can store entries and serve HIT/STALE itself, the CDN adapter delegates serving to Cloudflare's edge: the origin renders fresh responses and tags them with `Cache-Tag`, and `revalidateTag()` / `revalidatePath()` purge the edge through `ctx.cache.purge({ tags })`. See [examples/workers-cache](examples/workers-cache) for both adapters wired up together.
|
|
716
|
+
|
|
673
717
|
Each builder returns a plain, serializable `{ adapter, options }` descriptor — **it never touches the Workers runtime**, so nothing throws at build or dev time when bindings aren't available. The actual adapter (and its `env` binding lookup) is instantiated lazily on the first request.
|
|
674
718
|
|
|
675
719
|
Registration is wired into **every router and runtime** — App Router and Pages Router, on Cloudflare Workers as well as the Node.js server (`vinext start`) and dev. It self-guards (instantiated once per isolate) and is resilient: if an adapter can't initialize on a given runtime (e.g. a KV binding doesn't exist on the Node server), vinext logs a warning and falls back to the default handler instead of failing requests.
|
|
@@ -713,7 +757,7 @@ We measure three things:
|
|
|
713
757
|
- **Client bundle size** — gzipped output of each build.
|
|
714
758
|
- **Dev server cold start** — 10 runs, randomized execution order. Vite's dependency optimizer cache is cleared before each run.
|
|
715
759
|
|
|
716
|
-
Benchmarks run on GitHub CI runners (2-core Ubuntu) on every merge to `main`. See the launch numbers in the [announcement blog post](https://blog.cloudflare.com/vinext/) and the latest results at **[vinext
|
|
760
|
+
Benchmarks run on GitHub CI runners (2-core Ubuntu) on every merge to `main`. See the launch numbers in the [announcement blog post](https://blog.cloudflare.com/vinext/) and the latest results at **[vinext.dev/benchmarks](https://vinext.dev/benchmarks)**.
|
|
717
761
|
|
|
718
762
|
<details>
|
|
719
763
|
<summary>Why the bundle size difference?</summary>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AppRoute } from "../routing/app-route-graph.js";
|
|
2
|
+
import { Rollup } from "vite";
|
|
3
|
+
import { RscPluginManager } from "@vitejs/plugin-rsc";
|
|
4
|
+
//#region src/build/action-owner-manifest.d.ts
|
|
5
|
+
type ActionOwnerRoute = Pick<AppRoute, "errorPath" | "errorPaths" | "forbiddenPath" | "forbiddenPaths" | "layoutErrorPaths" | "layouts" | "loadingPath" | "loadingPaths" | "notFoundPath" | "notFoundPaths" | "pagePath" | "parallelSlots" | "pattern" | "siblingIntercepts" | "templates" | "unauthorizedPath" | "unauthorizedPaths">;
|
|
6
|
+
type ActionOwnerRouteReachability = Map<string, {
|
|
7
|
+
clientReferenceImportIds: Set<string>;
|
|
8
|
+
serverReferenceIds: Set<string>;
|
|
9
|
+
}>;
|
|
10
|
+
type ActionOwnerModuleInfo = Pick<Rollup.ModuleInfo, "dynamicallyImportedIds" | "importedIds">;
|
|
11
|
+
type ActionOwnerReferenceMaps = {
|
|
12
|
+
clientReferenceMetaMap: RscPluginManager["clientReferenceMetaMap"];
|
|
13
|
+
serverReferenceMetaMap: RscPluginManager["serverReferences"]["metaMap"];
|
|
14
|
+
};
|
|
15
|
+
declare function actionOwnerRouteEntryIds(route: ActionOwnerRoute): string[];
|
|
16
|
+
declare function collectReachableActionReferences(options: {
|
|
17
|
+
canonicalizeModuleId?: (id: string) => string;
|
|
18
|
+
getModuleInfo: (id: string) => ActionOwnerModuleInfo | null;
|
|
19
|
+
roots: readonly string[];
|
|
20
|
+
} & ActionOwnerReferenceMaps): {
|
|
21
|
+
clientReferenceImportIds: Set<string>;
|
|
22
|
+
serverReferenceIds: Set<string>;
|
|
23
|
+
};
|
|
24
|
+
declare function collectRscActionReachability(options: {
|
|
25
|
+
canonicalizeModuleId?: (id: string) => string;
|
|
26
|
+
getModuleInfo: (id: string) => ActionOwnerModuleInfo | null;
|
|
27
|
+
routes: readonly ActionOwnerRoute[];
|
|
28
|
+
sharedRoots?: readonly string[];
|
|
29
|
+
} & ActionOwnerReferenceMaps): ActionOwnerRouteReachability;
|
|
30
|
+
declare function resolveClientReferenceImportIds(options: {
|
|
31
|
+
canonicalizeModuleId?: (id: string) => string;
|
|
32
|
+
resolveId: (id: string) => Promise<string | null>;
|
|
33
|
+
routeReachability: ActionOwnerRouteReachability;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
declare function addClientActionReachability(options: {
|
|
36
|
+
canonicalizeModuleId?: (id: string) => string;
|
|
37
|
+
getModuleInfo: (id: string) => ActionOwnerModuleInfo | null;
|
|
38
|
+
routeReachability: ActionOwnerRouteReachability;
|
|
39
|
+
} & ActionOwnerReferenceMaps): void;
|
|
40
|
+
declare function buildActionOwnerManifest(routeReachability: ActionOwnerRouteReachability): Record<string, string[]>;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { ActionOwnerRouteReachability, actionOwnerRouteEntryIds, addClientActionReachability, buildActionOwnerManifest, collectReachableActionReferences, collectRscActionReachability, resolveClientReferenceImportIds };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
//#region src/build/action-owner-manifest.ts
|
|
2
|
+
function actionOwnerRouteEntryIds(route) {
|
|
3
|
+
return [
|
|
4
|
+
route.pagePath,
|
|
5
|
+
...route.layouts,
|
|
6
|
+
...route.templates,
|
|
7
|
+
route.loadingPath,
|
|
8
|
+
...route.loadingPaths ?? [],
|
|
9
|
+
route.errorPath,
|
|
10
|
+
...route.layoutErrorPaths ?? [],
|
|
11
|
+
...route.errorPaths ?? [],
|
|
12
|
+
route.notFoundPath,
|
|
13
|
+
...route.notFoundPaths ?? [],
|
|
14
|
+
route.forbiddenPath,
|
|
15
|
+
...route.forbiddenPaths ?? [],
|
|
16
|
+
route.unauthorizedPath,
|
|
17
|
+
...route.unauthorizedPaths ?? [],
|
|
18
|
+
...route.parallelSlots.flatMap((slot) => [
|
|
19
|
+
slot.pagePath,
|
|
20
|
+
slot.defaultPath,
|
|
21
|
+
slot.layoutPath,
|
|
22
|
+
...slot.configLayoutPaths ?? [],
|
|
23
|
+
slot.loadingPath,
|
|
24
|
+
...slot.loadingPaths ?? [],
|
|
25
|
+
slot.errorPath,
|
|
26
|
+
slot.notFoundPath,
|
|
27
|
+
...slot.interceptingRoutes.flatMap((intercept) => [
|
|
28
|
+
intercept.pagePath,
|
|
29
|
+
...intercept.layoutPaths,
|
|
30
|
+
...intercept.loadingPaths ?? [],
|
|
31
|
+
intercept.notFoundPath
|
|
32
|
+
])
|
|
33
|
+
]),
|
|
34
|
+
...route.siblingIntercepts.flatMap((intercept) => [
|
|
35
|
+
intercept.pagePath,
|
|
36
|
+
...intercept.layoutPaths,
|
|
37
|
+
...intercept.loadingPaths ?? [],
|
|
38
|
+
intercept.notFoundPath
|
|
39
|
+
])
|
|
40
|
+
].filter((value) => typeof value === "string");
|
|
41
|
+
}
|
|
42
|
+
function collectReachableActionReferences(options) {
|
|
43
|
+
const canonicalizeModuleId = options.canonicalizeModuleId ?? ((id) => id);
|
|
44
|
+
const clientReferenceImportIds = /* @__PURE__ */ new Set();
|
|
45
|
+
const serverReferenceIds = /* @__PURE__ */ new Set();
|
|
46
|
+
const visited = /* @__PURE__ */ new Set();
|
|
47
|
+
const queue = options.roots.map(canonicalizeModuleId);
|
|
48
|
+
for (let index = 0; index < queue.length; index++) {
|
|
49
|
+
const id = queue[index];
|
|
50
|
+
if (visited.has(id)) continue;
|
|
51
|
+
visited.add(id);
|
|
52
|
+
const clientReference = options.clientReferenceMetaMap[id];
|
|
53
|
+
if (clientReference) clientReferenceImportIds.add(clientReference.importId);
|
|
54
|
+
const serverReference = options.serverReferenceMetaMap.get(id);
|
|
55
|
+
if (serverReference) for (const exportName of serverReference.exportNames) serverReferenceIds.add(`${serverReference.referenceKey}#${exportName}`);
|
|
56
|
+
const info = options.getModuleInfo(id);
|
|
57
|
+
for (const importedId of [...info?.importedIds ?? [], ...info?.dynamicallyImportedIds ?? []]) if (!visited.has(importedId)) queue.push(importedId);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
clientReferenceImportIds,
|
|
61
|
+
serverReferenceIds
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function collectRscActionReachability(options) {
|
|
65
|
+
const routeReachability = new Map(options.routes.map((route) => [route.pattern, collectReachableActionReferences({
|
|
66
|
+
canonicalizeModuleId: options.canonicalizeModuleId,
|
|
67
|
+
clientReferenceMetaMap: options.clientReferenceMetaMap,
|
|
68
|
+
getModuleInfo: options.getModuleInfo,
|
|
69
|
+
roots: actionOwnerRouteEntryIds(route),
|
|
70
|
+
serverReferenceMetaMap: options.serverReferenceMetaMap
|
|
71
|
+
})]));
|
|
72
|
+
if (options.sharedRoots?.length) routeReachability.set("*", collectReachableActionReferences({
|
|
73
|
+
canonicalizeModuleId: options.canonicalizeModuleId,
|
|
74
|
+
clientReferenceMetaMap: options.clientReferenceMetaMap,
|
|
75
|
+
getModuleInfo: options.getModuleInfo,
|
|
76
|
+
roots: options.sharedRoots,
|
|
77
|
+
serverReferenceMetaMap: options.serverReferenceMetaMap
|
|
78
|
+
}));
|
|
79
|
+
return routeReachability;
|
|
80
|
+
}
|
|
81
|
+
async function resolveClientReferenceImportIds(options) {
|
|
82
|
+
const canonicalizeModuleId = options.canonicalizeModuleId ?? ((id) => id);
|
|
83
|
+
for (const reachability of options.routeReachability.values()) {
|
|
84
|
+
const resolvedImportIds = /* @__PURE__ */ new Set();
|
|
85
|
+
for (const importId of reachability.clientReferenceImportIds) {
|
|
86
|
+
const resolvedId = await options.resolveId(importId) ?? importId;
|
|
87
|
+
resolvedImportIds.add(canonicalizeModuleId(resolvedId));
|
|
88
|
+
}
|
|
89
|
+
reachability.clientReferenceImportIds = resolvedImportIds;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function addClientActionReachability(options) {
|
|
93
|
+
for (const reachability of options.routeReachability.values()) {
|
|
94
|
+
const clientReachability = collectReachableActionReferences({
|
|
95
|
+
canonicalizeModuleId: options.canonicalizeModuleId,
|
|
96
|
+
clientReferenceMetaMap: options.clientReferenceMetaMap,
|
|
97
|
+
getModuleInfo: options.getModuleInfo,
|
|
98
|
+
roots: [...reachability.clientReferenceImportIds],
|
|
99
|
+
serverReferenceMetaMap: options.serverReferenceMetaMap
|
|
100
|
+
});
|
|
101
|
+
for (const actionId of clientReachability.serverReferenceIds) reachability.serverReferenceIds.add(actionId);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function buildActionOwnerManifest(routeReachability) {
|
|
105
|
+
const manifest = {};
|
|
106
|
+
for (const [pattern, reachability] of routeReachability) for (const actionId of reachability.serverReferenceIds) (manifest[actionId] ??= []).push(pattern);
|
|
107
|
+
return manifest;
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
export { actionOwnerRouteEntryIds, addClientActionReachability, buildActionOwnerManifest, collectReachableActionReferences, collectRscActionReachability, resolveClientReferenceImportIds };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
|
+
import { isPathInsideOrEqual } from "../utils/path.js";
|
|
2
3
|
import fs from "node:fs";
|
|
3
4
|
//#region src/build/clean-output.ts
|
|
4
5
|
function resolveOutDir(root, outDir) {
|
|
@@ -6,10 +7,6 @@ function resolveOutDir(root, outDir) {
|
|
|
6
7
|
if (!outDir) return path.join(resolvedRoot, "dist");
|
|
7
8
|
return path.isAbsolute(outDir) ? outDir : path.resolve(resolvedRoot, outDir);
|
|
8
9
|
}
|
|
9
|
-
function isPathInsideOrEqual(parent, child) {
|
|
10
|
-
const relative = path.relative(parent, child);
|
|
11
|
-
return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
12
|
-
}
|
|
13
10
|
function shouldCleanBuildOutput(options) {
|
|
14
11
|
if (options.emptyOutDir === false) return false;
|
|
15
12
|
if (options.emptyOutDir === true) return true;
|
|
@@ -86,11 +86,20 @@ function getPackageName(id) {
|
|
|
86
86
|
*/
|
|
87
87
|
function createClientManualChunks(shimsDir, preserveRouteBoundaries = false) {
|
|
88
88
|
return function clientManualChunks(id) {
|
|
89
|
+
const slashedId = toSlash(id);
|
|
90
|
+
if (slashedId.startsWith(shimsDir)) {
|
|
91
|
+
if (preserveRouteBoundaries) {
|
|
92
|
+
const relativeId = slashedId.slice(shimsDir.length).split("?", 1)[0] ?? "";
|
|
93
|
+
const extensionIndex = relativeId.lastIndexOf(".");
|
|
94
|
+
const shimName = extensionIndex === -1 ? relativeId : relativeId.slice(0, extensionIndex);
|
|
95
|
+
if (ROUTE_OWNED_CLIENT_SHIMS.has(shimName)) return void 0;
|
|
96
|
+
}
|
|
97
|
+
return "vinext";
|
|
98
|
+
}
|
|
89
99
|
if (id.includes("node_modules")) {
|
|
90
100
|
const pkg = getPackageName(id);
|
|
91
101
|
if (!pkg) return void 0;
|
|
92
102
|
if (pkg === "react-dom") {
|
|
93
|
-
const slashedId = toSlash(id);
|
|
94
103
|
const sub = slashedId.slice(slashedId.lastIndexOf("react-dom/") + 10);
|
|
95
104
|
if (sub.startsWith("server.") || sub.startsWith("static.") || sub.startsWith("cjs/react-dom-server")) return "react-dom-server";
|
|
96
105
|
return "framework";
|
|
@@ -98,16 +107,6 @@ function createClientManualChunks(shimsDir, preserveRouteBoundaries = false) {
|
|
|
98
107
|
if (pkg === "react" || pkg === "scheduler") return "framework";
|
|
99
108
|
return;
|
|
100
109
|
}
|
|
101
|
-
const slashedId = toSlash(id);
|
|
102
|
-
if (slashedId.startsWith(shimsDir)) {
|
|
103
|
-
if (preserveRouteBoundaries) {
|
|
104
|
-
const relativeId = slashedId.slice(shimsDir.length).split("?", 1)[0] ?? "";
|
|
105
|
-
const extensionIndex = relativeId.lastIndexOf(".");
|
|
106
|
-
const shimName = extensionIndex === -1 ? relativeId : relativeId.slice(0, extensionIndex);
|
|
107
|
-
if (ROUTE_OWNED_CLIENT_SHIMS.has(shimName)) return void 0;
|
|
108
|
-
}
|
|
109
|
-
return "vinext";
|
|
110
|
-
}
|
|
111
110
|
};
|
|
112
111
|
}
|
|
113
112
|
function createClientFileNameConfig(assetsDir) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { AppRoute } from "../routing/app-route-graph.js";
|
|
1
2
|
import { ResolvedNextConfig } from "../config/next-config.js";
|
|
2
3
|
import { Route } from "../routing/pages-router.js";
|
|
3
|
-
import { AppRoute } from "../routing/app-route-graph.js";
|
|
4
4
|
import { MetadataFileRoute } from "../server/metadata-routes.js";
|
|
5
5
|
import { readPrerenderSecret } from "./server-manifest.js";
|
|
6
6
|
import { Server } from "node:http";
|
package/dist/build/prerender.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
2
|
import { createValidFileMatcher, findFileWithExtensions } from "../routing/file-matcher.js";
|
|
3
3
|
import { VINEXT_PRERENDER_ROUTE_PARAMS_HEADER, VINEXT_PRERENDER_SECRET_HEADER, VINEXT_PRERENDER_SPECULATIVE_HEADER } from "../utils/protocol-headers.js";
|
|
4
|
-
import { NEXT_CACHE_TAGS_HEADER, VINEXT_METADATA_ROUTE_CACHE_HEADER, VINEXT_PRERENDER_CACHE_LIFE_HEADER, VINEXT_PRERENDER_METADATA_ROUTES_PATH } from "../server/headers.js";
|
|
4
|
+
import { NEXT_CACHE_TAGS_HEADER, VINEXT_METADATA_ROUTE_CACHE_HEADER, VINEXT_PRERENDER_CACHE_LIFE_HEADER, VINEXT_PRERENDER_METADATA_ROUTES_PATH, VINEXT_PRERENDER_RENDER_ERROR_HEADER } from "../server/headers.js";
|
|
5
5
|
import { classifyAppRoute, classifyPagesRoute, getAppRouteRenderEntryPath } from "./report.js";
|
|
6
6
|
import { resolveClientStaleTimeSeconds } from "../utils/cache-control-metadata.js";
|
|
7
7
|
import { NoOpCacheHandler, getCacheHandler, setCacheHandler } from "../shims/cache-handler.js";
|
|
@@ -781,11 +781,13 @@ async function prerenderApp({ routes, metadataRoutes = [], outDir, config, mode,
|
|
|
781
781
|
const request = new Request(`http://localhost${config.basePath ?? ""}${urlPath}`);
|
|
782
782
|
const response = await runWithHeadersContext(headersContextFromRequest(request), () => rscHandler(request));
|
|
783
783
|
if (!response.ok) {
|
|
784
|
+
const fatal = response.headers.get(VINEXT_PRERENDER_RENDER_ERROR_HEADER) === "1";
|
|
784
785
|
await response.body?.cancel();
|
|
785
786
|
return {
|
|
786
787
|
route: routePattern,
|
|
787
788
|
status: "error",
|
|
788
|
-
error: `Metadata route returned ${response.status}
|
|
789
|
+
error: `Metadata route returned ${response.status}`,
|
|
790
|
+
...fatal ? { fatal: true } : {}
|
|
789
791
|
};
|
|
790
792
|
}
|
|
791
793
|
const cacheControl = response.headers.get("cache-control") ?? "";
|
|
@@ -834,6 +836,7 @@ async function prerenderApp({ routes, metadataRoutes = [], outDir, config, mode,
|
|
|
834
836
|
const linkHeader = response.headers.get("link");
|
|
835
837
|
const responseCacheLife = readPrerenderCacheLifeHeader(response.headers);
|
|
836
838
|
const cacheTags = readPrerenderCacheTagsHeader(response.headers);
|
|
839
|
+
const fatal = response.headers.get(VINEXT_PRERENDER_RENDER_ERROR_HEADER) === "1";
|
|
837
840
|
if (!response.ok || cacheControl.includes("no-store")) {
|
|
838
841
|
await response.body?.cancel();
|
|
839
842
|
return {
|
|
@@ -843,7 +846,8 @@ async function prerenderApp({ routes, metadataRoutes = [], outDir, config, mode,
|
|
|
843
846
|
ok: response.ok,
|
|
844
847
|
requestCacheLife: null,
|
|
845
848
|
tags: [],
|
|
846
|
-
status: response.status
|
|
849
|
+
status: response.status,
|
|
850
|
+
fatal
|
|
847
851
|
};
|
|
848
852
|
}
|
|
849
853
|
const html = await response.text();
|
|
@@ -855,12 +859,13 @@ async function prerenderApp({ routes, metadataRoutes = [], outDir, config, mode,
|
|
|
855
859
|
ok: true,
|
|
856
860
|
requestCacheLife: responseCacheLife ?? processCacheLife,
|
|
857
861
|
status: response.status,
|
|
858
|
-
tags: cacheTags
|
|
862
|
+
tags: cacheTags,
|
|
863
|
+
fatal: false
|
|
859
864
|
};
|
|
860
865
|
});
|
|
861
866
|
const htmlCacheControl = htmlRender.cacheControl;
|
|
862
867
|
if (!htmlRender.ok) {
|
|
863
|
-
if (isSpeculative) return {
|
|
868
|
+
if (isSpeculative && !htmlRender.fatal) return {
|
|
864
869
|
route: routePattern,
|
|
865
870
|
status: "skipped",
|
|
866
871
|
reason: "dynamic"
|
|
@@ -868,7 +873,8 @@ async function prerenderApp({ routes, metadataRoutes = [], outDir, config, mode,
|
|
|
868
873
|
return {
|
|
869
874
|
route: routePattern,
|
|
870
875
|
status: "error",
|
|
871
|
-
error: `RSC handler returned ${htmlRender.status}
|
|
876
|
+
error: `RSC handler returned ${htmlRender.status}`,
|
|
877
|
+
...htmlRender.fatal ? { fatal: true } : {}
|
|
872
878
|
};
|
|
873
879
|
}
|
|
874
880
|
if (htmlCacheControl.includes("no-store")) return {
|
package/dist/build/report.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { AppRoute } from "../routing/app-route-graph.js";
|
|
1
2
|
import { LayoutBuildClassification } from "./layout-classification-types.js";
|
|
2
3
|
import { Route } from "../routing/pages-router.js";
|
|
3
|
-
import { AppRoute } from "../routing/app-route-graph.js";
|
|
4
4
|
import { PrerenderResult } from "./prerender.js";
|
|
5
5
|
//#region src/build/report.d.ts
|
|
6
6
|
type RouteType = "static" | "isr" | "ssr" | "unknown" | "api";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ClassificationReason, ModuleGraphStaticReason } from "./layout-classification-types.js";
|
|
2
1
|
import { AppRoute } from "../routing/app-route-graph.js";
|
|
2
|
+
import { ClassificationReason, ModuleGraphStaticReason } from "./layout-classification-types.js";
|
|
3
3
|
//#region src/build/route-classification-manifest.d.ts
|
|
4
4
|
type Layer1Class = "static" | "dynamic";
|
|
5
5
|
type RouteManifestEntry = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { AppRoute } from "../routing/app-route-graph.js";
|
|
1
2
|
import { ResolvedNextConfig } from "../config/next-config.js";
|
|
2
3
|
import { Route } from "../routing/pages-router.js";
|
|
3
|
-
import { AppRoute } from "../routing/app-route-graph.js";
|
|
4
4
|
//#region src/build/static-export.d.ts
|
|
5
5
|
type StaticExportOptions = {
|
|
6
6
|
/**
|
|
@@ -22,6 +22,7 @@ function clearAppNavigationFailureTarget(target) {
|
|
|
22
22
|
}
|
|
23
23
|
function handleAppNavigationFailure(error) {
|
|
24
24
|
if (!process.env.__NEXT_APP_NAV_FAIL_HANDLING || typeof window === "undefined") return false;
|
|
25
|
+
if (error !== null && typeof error === "object" && "handled" in error && error.handled === true) return false;
|
|
25
26
|
const pendingUrl = getPendingUrl();
|
|
26
27
|
if (pendingUrl === null || pendingUrl.href === window.location.href) return false;
|
|
27
28
|
console.error("Error occurred during navigation, falling back to hard navigation", error);
|
|
@@ -10,6 +10,7 @@ type NavigationRuntimeRscBootstrap = {
|
|
|
10
10
|
done?: boolean;
|
|
11
11
|
dynamicStaleTimeSeconds?: number;
|
|
12
12
|
initialCacheKind?: "dynamic" | "static";
|
|
13
|
+
searchParamsFromBrowser?: boolean;
|
|
13
14
|
nav?: NavigationRuntimeSnapshot;
|
|
14
15
|
params?: Record<string, string | string[]>;
|
|
15
16
|
rsc: NavigationRuntimeRscChunk[];
|
|
@@ -32,7 +33,7 @@ type NavigationRuntimeTraversalIntent = {
|
|
|
32
33
|
historyState: unknown;
|
|
33
34
|
targetHistoryIndex: number | null;
|
|
34
35
|
};
|
|
35
|
-
type NavigationRuntimeNavigate = (href: string, redirectDepth?: number, navigationKind?: NavigationRuntimeKind, historyUpdateMode?: NavigationRuntimeHistoryUpdateMode, previousNextUrlOverride?: string | null, programmaticTransition?: boolean, traversalIntent?: NavigationRuntimeTraversalIntent, scrollIntent?: AppRouterScrollIntent | null, visibleCommitMode?: NavigationRuntimeVisibleCommitMode) => Promise<void>;
|
|
36
|
+
type NavigationRuntimeNavigate = (href: string, redirectDepth?: number, navigationKind?: NavigationRuntimeKind, historyUpdateMode?: NavigationRuntimeHistoryUpdateMode, previousNextUrlOverride?: string | null, programmaticTransition?: boolean, traversalIntent?: NavigationRuntimeTraversalIntent, scrollIntent?: AppRouterScrollIntent | null, visibleCommitMode?: NavigationRuntimeVisibleCommitMode, bypassNavigationCache?: boolean) => Promise<void>;
|
|
36
37
|
type NavigationRuntimeFunctions = {
|
|
37
38
|
clearNavigationCaches?: () => void;
|
|
38
39
|
commitHashNavigation?: (href: string, historyUpdateMode: NavigationRuntimeHistoryUpdateMode, scroll: boolean) => void;
|
|
@@ -49,6 +50,8 @@ type NavigationRuntimeFunctions = {
|
|
|
49
50
|
notifyLinkNavigationStart?: () => void;
|
|
50
51
|
pingVisibleLinks?: () => void;
|
|
51
52
|
preparePrefetchResponse?: (response: Response) => Promise<unknown>;
|
|
53
|
+
claimCurrentHistoryTreeSnapshot?: (historyUpdateMode: NavigationRuntimeHistoryUpdateMode, previousHistoryState: unknown) => void;
|
|
54
|
+
commitAppOwnedHistoryStateWrite?: (historyUpdateMode: NavigationRuntimeHistoryUpdateMode, previousHistoryState: unknown) => void;
|
|
52
55
|
};
|
|
53
56
|
type NavigationRuntimeBootstrap = {
|
|
54
57
|
routeManifest: RouteManifest | null;
|
|
@@ -64,7 +67,6 @@ declare function getNavigationRuntime(): NavigationRuntime | null;
|
|
|
64
67
|
declare function registerNavigationRuntimeBootstrap(bootstrap: Partial<NavigationRuntimeBootstrap>): NavigationRuntime;
|
|
65
68
|
declare function registerNavigationRuntimeFunctions(functions: Partial<NavigationRuntimeFunctions>): NavigationRuntime;
|
|
66
69
|
declare function ensureNavigationRuntimeRscBootstrap(): NavigationRuntimeRscBootstrap;
|
|
67
|
-
declare function subscribeNavigationRuntimeRscChunk(chunk: NavigationRuntimeRscChunk): NavigationRuntime;
|
|
68
70
|
declare function hasAppNavigationRuntime(): boolean;
|
|
69
71
|
/**
|
|
70
72
|
* True when the App Router has installed its runtime bootstrap on `window`,
|
|
@@ -80,4 +82,4 @@ declare function hasAppNavigationRuntime(): boolean;
|
|
|
80
82
|
*/
|
|
81
83
|
declare function hasAppNavigationRuntimeBootstrap(): boolean;
|
|
82
84
|
//#endregion
|
|
83
|
-
export { NAVIGATION_RUNTIME_KEY, NAVIGATION_RUNTIME_SYMBOL_DESCRIPTION, NavigationRuntime, NavigationRuntimeBootstrap, NavigationRuntimeFunctions, NavigationRuntimeNavigate, NavigationRuntimeRscBootstrap, NavigationRuntimeRscChunk,
|
|
85
|
+
export { NAVIGATION_RUNTIME_KEY, NAVIGATION_RUNTIME_SYMBOL_DESCRIPTION, NavigationRuntime, NavigationRuntimeBootstrap, NavigationRuntimeFunctions, NavigationRuntimeNavigate, NavigationRuntimeRscBootstrap, NavigationRuntimeRscChunk, NavigationRuntimeVisibleCommitMode, ensureNavigationRuntimeRscBootstrap, getNavigationRuntime, hasAppNavigationRuntime, hasAppNavigationRuntimeBootstrap, registerNavigationRuntimeBootstrap, registerNavigationRuntimeFunctions };
|
|
@@ -31,7 +31,7 @@ function readRuntimeWindow() {
|
|
|
31
31
|
}
|
|
32
32
|
function isNavigationRuntimeFunctions(value) {
|
|
33
33
|
if (!isUnknownRecord(value)) return false;
|
|
34
|
-
return isOptionalRuntimeFunction(Reflect.get(value, "clearNavigationCaches")) && isOptionalRuntimeFunction(Reflect.get(value, "commitHashNavigation")) && isOptionalRuntimeFunction(Reflect.get(value, "navigateExternal")) && isOptionalRuntimeFunction(Reflect.get(value, "navigate")) && isOptionalRuntimeFunction(Reflect.get(value, "getPrefetchRouterState")) && isOptionalRuntimeFunction(Reflect.get(value, "notifyLinkNavigationStart")) && isOptionalRuntimeFunction(Reflect.get(value, "pingVisibleLinks")) && isOptionalRuntimeFunction(Reflect.get(value, "preparePrefetchResponse"));
|
|
34
|
+
return isOptionalRuntimeFunction(Reflect.get(value, "clearNavigationCaches")) && isOptionalRuntimeFunction(Reflect.get(value, "commitHashNavigation")) && isOptionalRuntimeFunction(Reflect.get(value, "navigateExternal")) && isOptionalRuntimeFunction(Reflect.get(value, "navigate")) && isOptionalRuntimeFunction(Reflect.get(value, "getPrefetchRouterState")) && isOptionalRuntimeFunction(Reflect.get(value, "notifyLinkNavigationStart")) && isOptionalRuntimeFunction(Reflect.get(value, "pingVisibleLinks")) && isOptionalRuntimeFunction(Reflect.get(value, "preparePrefetchResponse")) && isOptionalRuntimeFunction(Reflect.get(value, "claimCurrentHistoryTreeSnapshot")) && isOptionalRuntimeFunction(Reflect.get(value, "commitAppOwnedHistoryStateWrite"));
|
|
35
35
|
}
|
|
36
36
|
function isNavigationRuntimeRscChunk(value) {
|
|
37
37
|
if (typeof value === "string") return true;
|
|
@@ -52,11 +52,12 @@ function isNavigationRuntimeRscBootstrap(value) {
|
|
|
52
52
|
const done = Reflect.get(value, "done");
|
|
53
53
|
const dynamicStaleTimeSeconds = Reflect.get(value, "dynamicStaleTimeSeconds");
|
|
54
54
|
const initialCacheKind = Reflect.get(value, "initialCacheKind");
|
|
55
|
+
const searchParamsFromBrowser = Reflect.get(value, "searchParamsFromBrowser");
|
|
55
56
|
const nav = Reflect.get(value, "nav");
|
|
56
57
|
const params = Reflect.get(value, "params");
|
|
57
58
|
const rsc = Reflect.get(value, "rsc");
|
|
58
59
|
const staleTimeSeconds = Reflect.get(value, "staleTimeSeconds");
|
|
59
|
-
return (done === void 0 || typeof done === "boolean") && isOptionalStaleTimeSeconds(dynamicStaleTimeSeconds) && (initialCacheKind === void 0 || initialCacheKind === "dynamic" || initialCacheKind === "static") && (nav === void 0 || isNavigationRuntimeSnapshot(nav)) && (params === void 0 || isNavigationRuntimeParams(params)) && Array.isArray(rsc) && rsc.every(isNavigationRuntimeRscChunk) && isOptionalStaleTimeSeconds(staleTimeSeconds);
|
|
60
|
+
return (done === void 0 || typeof done === "boolean") && isOptionalStaleTimeSeconds(dynamicStaleTimeSeconds) && (initialCacheKind === void 0 || initialCacheKind === "dynamic" || initialCacheKind === "static") && (searchParamsFromBrowser === void 0 || typeof searchParamsFromBrowser === "boolean") && (nav === void 0 || isNavigationRuntimeSnapshot(nav)) && (params === void 0 || isNavigationRuntimeParams(params)) && Array.isArray(rsc) && rsc.every(isNavigationRuntimeRscChunk) && isOptionalStaleTimeSeconds(staleTimeSeconds);
|
|
60
61
|
}
|
|
61
62
|
function isOptionalStaleTimeSeconds(value) {
|
|
62
63
|
return value === void 0 || typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
@@ -148,11 +149,6 @@ function ensureNavigationRuntimeRscBootstrapForRuntime(runtime) {
|
|
|
148
149
|
}
|
|
149
150
|
return rscBootstrap;
|
|
150
151
|
}
|
|
151
|
-
function subscribeNavigationRuntimeRscChunk(chunk) {
|
|
152
|
-
const runtime = ensureNavigationRuntime();
|
|
153
|
-
ensureNavigationRuntimeRscBootstrapForRuntime(runtime).rsc.push(chunk);
|
|
154
|
-
return runtime;
|
|
155
|
-
}
|
|
156
152
|
function hasAppNavigationRuntime() {
|
|
157
153
|
return typeof getNavigationRuntime()?.functions.navigate === "function";
|
|
158
154
|
}
|
|
@@ -172,4 +168,4 @@ function hasAppNavigationRuntimeBootstrap() {
|
|
|
172
168
|
return getNavigationRuntime() !== null;
|
|
173
169
|
}
|
|
174
170
|
//#endregion
|
|
175
|
-
export { NAVIGATION_RUNTIME_KEY, NAVIGATION_RUNTIME_SYMBOL_DESCRIPTION, ensureNavigationRuntimeRscBootstrap, getNavigationRuntime, hasAppNavigationRuntime, hasAppNavigationRuntimeBootstrap, registerNavigationRuntimeBootstrap, registerNavigationRuntimeFunctions
|
|
171
|
+
export { NAVIGATION_RUNTIME_KEY, NAVIGATION_RUNTIME_SYMBOL_DESCRIPTION, ensureNavigationRuntimeRscBootstrap, getNavigationRuntime, hasAppNavigationRuntime, hasAppNavigationRuntimeBootstrap, registerNavigationRuntimeBootstrap, registerNavigationRuntimeFunctions };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NextRewrite } from "../config/next-config.js";
|
|
2
1
|
import { AppRoute, RouteManifest } from "../routing/app-route-graph.js";
|
|
2
|
+
import { NextRewrite } from "../config/next-config.js";
|
|
3
3
|
import { VinextLinkPrefetchRoute, VinextPagesLinkPrefetchRoute } from "../client/vinext-next-data.js";
|
|
4
4
|
//#region src/entries/app-browser-entry.d.ts
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NextHeader, NextI18nConfig, NextRedirect, NextRewrite, PrefetchInliningConfig } from "../config/next-config.js";
|
|
2
1
|
import { AppRoute } from "../routing/app-route-graph.js";
|
|
2
|
+
import { NextHeader, NextI18nConfig, NextRedirect, NextRewrite, PrefetchInliningConfig } from "../config/next-config.js";
|
|
3
3
|
import { MetadataFileRoute } from "../server/metadata-routes.js";
|
|
4
4
|
import { ImageConfig } from "../server/image-optimization.js";
|
|
5
5
|
//#region src/entries/app-rsc-entry.d.ts
|
|
@@ -8,6 +8,7 @@ import { ImageConfig } from "../server/image-optimization.js";
|
|
|
8
8
|
* Passed from the Vite plugin where the full next.config.js is loaded.
|
|
9
9
|
*/
|
|
10
10
|
type AppRouterConfig = {
|
|
11
|
+
actionOwners?: Record<string, string[]> | null;
|
|
11
12
|
redirects?: NextRedirect[];
|
|
12
13
|
rewrites?: {
|
|
13
14
|
beforeFiles: NextRewrite[];
|