vinext 1.0.0-beta.0 → 1.0.0-beta.2
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 +21 -2
- package/dist/build/assets-ignore.js +1 -1
- package/dist/build/clean-output.js +1 -1
- package/dist/build/client-build-config.js +7 -4
- package/dist/build/css-url-assets.js +3 -3
- package/dist/build/google-fonts/fallback-metrics.js +1 -1
- package/dist/build/google-fonts/font-metadata.js +1 -1
- package/dist/build/inject-pregenerated-paths.js +1 -1
- package/dist/build/inline-css.js +2 -5
- package/dist/build/module-dependency-cache.d.ts +4 -0
- package/dist/build/module-dependency-cache.js +13 -0
- package/dist/build/next-client-runtime-manifests.js +1 -1
- package/dist/build/pages-client-assets-module.js +1 -1
- package/dist/build/precompress.js +7 -7
- package/dist/build/prerender-paths.d.ts +2 -2
- package/dist/build/prerender-paths.js +10 -15
- package/dist/build/prerender-server-pool.js +2 -2
- package/dist/build/prerender.js +1 -1
- package/dist/build/preview-credentials.d.ts +11 -0
- package/dist/build/preview-credentials.js +19 -0
- package/dist/build/report.d.ts +8 -4
- package/dist/build/report.js +14 -6
- package/dist/build/run-prerender.d.ts +2 -11
- package/dist/build/run-prerender.js +2 -10
- package/dist/build/server-manifest.js +1 -1
- package/dist/build/ssr-manifest.d.ts +4 -0
- package/dist/build/ssr-manifest.js +10 -6
- package/dist/build/standalone.js +37 -37
- package/dist/cache/cache-adapters-virtual.d.ts +1 -17
- package/dist/cache/cache-adapters-virtual.js +20 -11
- package/dist/check.d.ts +0 -16
- package/dist/check.js +27 -36
- package/dist/cli.js +61 -55
- package/dist/client/instrumentation-client-inject.js +1 -1
- package/dist/client/pages-router-link-navigation.js +1 -1
- package/dist/config/config-matchers.d.ts +13 -37
- package/dist/config/config-matchers.js +33 -123
- package/dist/config/dotenv.js +1 -1
- package/dist/config/next-config.d.ts +7 -3
- package/dist/config/next-config.js +84 -15
- package/dist/config/prerender.d.ts +2 -2
- package/dist/config/prerender.js +7 -15
- package/dist/config/request-context.d.ts +14 -0
- package/dist/config/request-context.js +26 -0
- package/dist/config/server-external-packages.js +1 -1
- package/dist/config/tsconfig-paths.js +2 -2
- package/dist/{node_modules/.pnpm/am-i-vibing@0.5.0/node_modules → deps/.pnpm/am-i-vibing@0.5.0/deps}/am-i-vibing/dist/detector-1yx2Hoe0.js +2 -2
- package/dist/deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js +50 -0
- package/dist/entries/app-rsc-entry.js +39 -14
- package/dist/entries/app-rsc-manifest.js +21 -4
- package/dist/entries/pages-client-entry.js +6 -5
- package/dist/entries/pages-server-entry.js +18 -28
- package/dist/entries/runtime-entry-module.js +2 -2
- package/dist/index.js +314 -230
- package/dist/init-cloudflare.js +1 -1
- package/dist/init-platform.js +1 -1
- package/dist/init.d.ts +6 -4
- package/dist/init.js +25 -27
- package/dist/plugins/ast-utils.js +1 -1
- package/dist/plugins/dynamic-preload-metadata.js +7 -7
- package/dist/plugins/extensionless-dynamic-import.js +1 -1
- package/dist/plugins/fonts.js +3 -3
- package/dist/plugins/ignore-dynamic-requests.js +13 -8
- package/dist/plugins/import-meta-url.js +16 -17
- package/dist/plugins/middleware-export-validation.js +1 -1
- package/dist/plugins/middleware-server-only.js +2 -2
- package/dist/plugins/og-asset-ownership.js +7 -6
- package/dist/plugins/og-assets.js +5 -6
- package/dist/plugins/optimize-imports.js +12 -13
- package/dist/plugins/postcss.js +1 -1
- package/dist/plugins/remove-console.js +1 -1
- package/dist/plugins/require-context.js +1 -1
- package/dist/plugins/sass.js +2 -2
- package/dist/plugins/server-externals-manifest.js +1 -1
- package/dist/plugins/strip-server-exports.js +1 -1
- package/dist/plugins/styled-jsx.js +3 -2
- package/dist/plugins/typeof-window.js +1 -1
- package/dist/routing/app-route-graph.d.ts +16 -15
- package/dist/routing/app-route-graph.js +86 -88
- package/dist/routing/app-router.d.ts +0 -5
- package/dist/routing/app-router.js +12 -11
- package/dist/routing/file-matcher.d.ts +13 -28
- package/dist/routing/file-matcher.js +31 -44
- package/dist/routing/pages-router.js +26 -32
- package/dist/routing/route-matching.d.ts +14 -1
- package/dist/routing/route-matching.js +13 -1
- package/dist/routing/route-pattern.d.ts +2 -1
- package/dist/routing/route-pattern.js +7 -4
- package/dist/routing/route-trie.d.ts +5 -1
- package/dist/routing/route-trie.js +5 -2
- package/dist/server/api-handler.js +41 -33
- package/dist/server/app-browser-entry.js +18 -11
- package/dist/server/app-browser-history-controller.d.ts +1 -1
- package/dist/server/app-browser-history-controller.js +3 -3
- package/dist/server/app-browser-navigation-controller.js +4 -2
- package/dist/server/app-browser-server-action-client.js +1 -1
- package/dist/server/app-elements-wire.d.ts +2 -1
- package/dist/server/app-fallback-renderer.d.ts +11 -0
- package/dist/server/app-fallback-renderer.js +16 -2
- package/dist/server/app-middleware.js +2 -1
- package/dist/server/app-page-boundary-render.d.ts +26 -2
- package/dist/server/app-page-boundary-render.js +190 -55
- package/dist/server/app-page-cache-finalizer.d.ts +1 -1
- package/dist/server/app-page-cache.d.ts +1 -1
- package/dist/server/app-page-dispatch.d.ts +12 -2
- package/dist/server/app-page-dispatch.js +37 -51
- package/dist/server/app-page-element-builder.d.ts +8 -2
- package/dist/server/app-page-element-builder.js +112 -27
- package/dist/server/app-page-execution.d.ts +3 -1
- package/dist/server/app-page-execution.js +31 -39
- package/dist/server/app-page-head.d.ts +54 -2
- package/dist/server/app-page-head.js +164 -78
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +29 -0
- package/dist/server/app-page-http-access-fallback-metadata.js +106 -0
- package/dist/server/app-page-render.d.ts +2 -2
- package/dist/server/app-page-render.js +1 -1
- package/dist/server/app-page-request.d.ts +12 -0
- package/dist/server/app-page-request.js +134 -14
- package/dist/server/app-page-route-wiring.d.ts +9 -0
- package/dist/server/app-page-route-wiring.js +44 -4
- package/dist/server/app-post-middleware-context.d.ts +1 -1
- package/dist/server/app-post-middleware-context.js +1 -1
- package/dist/server/app-route-handler-dispatch.js +31 -17
- package/dist/server/app-route-handler-execution.d.ts +6 -1
- package/dist/server/app-route-handler-execution.js +41 -15
- package/dist/server/app-route-handler-policy.d.ts +2 -0
- package/dist/server/app-route-handler-policy.js +3 -3
- package/dist/server/app-route-module-loader.d.ts +3 -1
- package/dist/server/app-route-module-loader.js +1 -0
- package/dist/server/app-route-tree-prefetch.js +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +1 -1
- package/dist/server/app-rsc-cache-busting.js +1 -1
- package/dist/server/app-rsc-errors.d.ts +1 -1
- package/dist/server/app-rsc-errors.js +12 -2
- package/dist/server/app-rsc-handler.d.ts +10 -5
- package/dist/server/app-rsc-handler.js +51 -23
- package/dist/server/app-rsc-redirect-flight.d.ts +66 -0
- package/dist/server/app-rsc-redirect-flight.js +71 -0
- package/dist/server/app-rsc-request-normalization.d.ts +3 -2
- package/dist/server/app-rsc-request-normalization.js +8 -2
- package/dist/server/app-rsc-response-finalizer.d.ts +2 -2
- package/dist/server/app-rsc-response-finalizer.js +5 -11
- package/dist/server/app-rsc-route-matching.d.ts +20 -0
- package/dist/server/app-rsc-route-matching.js +87 -11
- package/dist/server/app-segment-config.js +15 -5
- package/dist/server/app-server-action-execution.d.ts +3 -1
- package/dist/server/app-server-action-execution.js +8 -6
- package/dist/server/app-ssr-entry.js +4 -1
- package/dist/server/app-ssr-stream.d.ts +2 -7
- package/dist/server/app-ssr-stream.js +5 -10
- package/dist/server/cache-proof.js +1 -1
- package/dist/server/config-headers.d.ts +24 -0
- package/dist/server/config-headers.js +52 -0
- package/dist/server/default-global-error-module.d.ts +3 -1
- package/dist/server/default-not-found-module.d.ts +3 -1
- package/dist/server/dev-initial-server-error.d.ts +1 -1
- package/dist/server/dev-lockfile.js +2 -3
- package/dist/server/dev-route-files.js +1 -1
- package/dist/server/dev-server.js +281 -173
- package/dist/server/dev-stack-sourcemap.js +4 -3
- package/dist/server/headers.d.ts +3 -1
- package/dist/server/headers.js +3 -1
- package/dist/server/image-optimization.js +2 -2
- package/dist/server/implicit-tags.js +2 -1
- package/dist/server/instrumentation.js +2 -2
- package/dist/server/isr-cache.d.ts +1 -1
- package/dist/server/isr-cache.js +1 -1
- package/dist/server/metadata-routes.js +4 -4
- package/dist/server/middleware-matcher-pattern.d.ts +22 -0
- package/dist/server/middleware-matcher-pattern.js +219 -0
- package/dist/server/middleware-matcher.d.ts +2 -7
- package/dist/server/middleware-matcher.js +13 -60
- package/dist/server/middleware-path-to-regexp.d.ts +14 -0
- package/dist/server/middleware-path-to-regexp.js +228 -0
- package/dist/server/middleware-response-headers.js +1 -1
- package/dist/server/middleware-runtime.js +5 -4
- package/dist/server/middleware.d.ts +2 -1
- package/dist/server/middleware.js +3 -2
- package/dist/server/navigation-planner.d.ts +2 -0
- package/dist/server/navigation-planner.js +8 -2
- package/dist/server/next-error-digest.d.ts +9 -24
- package/dist/server/next-error-digest.js +23 -15
- package/dist/server/operation-token.js +1 -1
- package/dist/server/pages-body-parser-config.js +2 -1
- package/dist/server/pages-data-route.d.ts +11 -1
- package/dist/server/pages-data-route.js +16 -1
- package/dist/server/pages-dev-hydration.d.ts +14 -0
- package/dist/server/pages-dev-hydration.js +83 -0
- package/dist/server/pages-dev-module-url.js +2 -2
- package/dist/server/pages-get-initial-props.d.ts +15 -2
- package/dist/server/pages-get-initial-props.js +16 -6
- package/dist/server/pages-node-compat.d.ts +13 -6
- package/dist/server/pages-node-compat.js +44 -45
- package/dist/server/pages-page-data.d.ts +4 -2
- package/dist/server/pages-page-data.js +20 -10
- package/dist/server/pages-page-handler.d.ts +4 -2
- package/dist/server/pages-page-handler.js +74 -43
- package/dist/server/pages-page-response.d.ts +2 -2
- package/dist/server/pages-page-response.js +1 -1
- package/dist/server/pages-preview.d.ts +26 -0
- package/dist/server/pages-preview.js +165 -0
- package/dist/server/pages-readiness.d.ts +5 -4
- package/dist/server/pages-readiness.js +4 -2
- package/dist/server/pages-request-pipeline.d.ts +1 -0
- package/dist/server/pages-request-pipeline.js +25 -11
- package/dist/server/pages-router-entry.js +6 -0
- package/dist/server/prerender-route-params.js +2 -2
- package/dist/server/prod-server.d.ts +1 -4
- package/dist/server/prod-server.js +44 -30
- package/dist/server/request-pipeline.d.ts +15 -29
- package/dist/server/request-pipeline.js +25 -60
- package/dist/server/rsc-stream-hints.js +122 -18
- package/dist/server/seed-cache.js +1 -1
- package/dist/server/socket-error-backstop.js +1 -1
- package/dist/server/static-file-cache.js +7 -8
- package/dist/server/worker-utils.js +1 -1
- package/dist/shims/app.d.ts +1 -1
- package/dist/shims/cache-request-state.d.ts +27 -1
- package/dist/shims/cache-request-state.js +60 -1
- package/dist/shims/cache-runtime.d.ts +12 -1
- package/dist/shims/cache-runtime.js +22 -7
- package/dist/shims/cache.d.ts +5 -5
- package/dist/shims/cache.js +28 -11
- package/dist/shims/constants.js +1 -1
- package/dist/shims/document.d.ts +42 -83
- package/dist/shims/document.js +62 -53
- package/dist/shims/dynamic.d.ts +5 -25
- package/dist/shims/dynamic.js +29 -8
- package/dist/shims/error-boundary.d.ts +4 -4
- package/dist/shims/error.d.ts +22 -6
- package/dist/shims/error.js +53 -15
- package/dist/shims/fetch-cache.js +13 -4
- package/dist/shims/font-google-base.d.ts +11 -4
- package/dist/shims/font-local.d.ts +10 -3
- package/dist/shims/font-utils.js +1 -1
- package/dist/shims/form.d.ts +1 -1
- package/dist/shims/head.d.ts +13 -2
- package/dist/shims/head.js +6 -6
- package/dist/shims/headers.d.ts +28 -31
- package/dist/shims/headers.js +115 -53
- package/dist/shims/image.d.ts +27 -37
- package/dist/shims/image.js +21 -14
- package/dist/shims/internal/cookie-serialize.d.ts +3 -1
- package/dist/shims/internal/cookie-serialize.js +3 -1
- package/dist/shims/internal/hybrid-client-route-owner.js +3 -1
- package/dist/shims/internal/pages-data-fetch-dedup.js +5 -3
- package/dist/shims/internal/utils.d.ts +3 -3
- package/dist/shims/layout-segment-context.d.ts +1 -1
- package/dist/shims/legacy-image.d.ts +3 -37
- package/dist/shims/legacy-image.js +6 -16
- package/dist/shims/link.d.ts +16 -21
- package/dist/shims/link.js +25 -13
- package/dist/shims/navigation-context-state.d.ts +1 -1
- package/dist/shims/navigation-errors.d.ts +2 -1
- package/dist/shims/navigation-errors.js +9 -13
- package/dist/shims/navigation.d.ts +8 -4
- package/dist/shims/navigation.js +29 -18
- package/dist/shims/next-shims-augmentations.d.ts +1 -0
- package/dist/shims/next-shims-public.d.ts +1 -0
- package/dist/shims/public-shim-map.json.js +103 -0
- package/dist/shims/readonly-url-search-params.d.ts +3 -3
- package/dist/shims/readonly-url-search-params.js +3 -3
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/router-state.d.ts +1 -0
- package/dist/shims/router.d.ts +57 -22
- package/dist/shims/router.js +178 -46
- package/dist/shims/script.d.ts +6 -10
- package/dist/shims/script.js +7 -4
- package/dist/shims/server.d.ts +45 -22
- package/dist/shims/server.js +46 -7
- package/dist/shims/slot.d.ts +1 -1
- package/dist/shims/thenable-params.js +1 -1
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +2 -0
- package/dist/shims/url-safety.d.ts +1 -1
- package/dist/shims/url-safety.js +2 -2
- package/dist/typegen.d.ts +8 -2
- package/dist/typegen.js +84 -25
- package/dist/utils/client-build-manifest.js +2 -2
- package/dist/utils/client-entry-manifest.js +1 -1
- package/dist/utils/client-runtime-metadata.js +1 -1
- package/dist/utils/commonjs-loader.js +3 -3
- package/dist/utils/domain-locale.d.ts +2 -2
- package/dist/utils/external-url.d.ts +5 -0
- package/dist/utils/external-url.js +7 -0
- package/dist/utils/mdx-scan.js +1 -1
- package/dist/utils/path.d.ts +1 -13
- package/dist/utils/path.js +1 -15
- package/dist/utils/plugin-options.d.ts +4 -0
- package/dist/utils/plugin-options.js +8 -0
- package/dist/utils/project.d.ts +0 -6
- package/dist/utils/project.js +2 -8
- package/dist/utils/public-routes.js +2 -2
- package/dist/utils/react-version.js +1 -1
- package/dist/utils/redirect-digest.d.ts +9 -0
- package/dist/utils/redirect-digest.js +25 -0
- package/dist/utils/regex-safety.d.ts +8 -0
- package/dist/utils/regex-safety.js +737 -0
- package/dist/utils/vinext-root.js +1 -1
- package/dist/utils/vite-version.d.ts +5 -2
- package/dist/utils/vite-version.js +43 -17
- package/package.json +16 -4
- /package/dist/build/google-fonts/{fallback-metrics-data.js → fallback-metrics-data.json.js} +0 -0
- /package/dist/build/google-fonts/{font-data.js → font-data.json.js} +0 -0
- /package/dist/{node_modules/.pnpm/process-ancestry@0.1.0/node_modules → deps/.pnpm/process-ancestry@0.1.0/deps}/process-ancestry/dist/index.js +0 -0
package/dist/config/prerender.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isUnknownRecord } from "../utils/record.js";
|
|
2
|
+
import { flattenPluginOptions } from "../utils/plugin-options.js";
|
|
2
3
|
import { VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY, findVinextCacheConfigInPlugins, loadVinextCacheConfigFromViteConfig } from "../cache/cache-adapters-virtual.js";
|
|
3
4
|
//#region src/config/prerender.ts
|
|
4
5
|
const VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY = "__vinextPrerenderConfig";
|
|
@@ -10,16 +11,8 @@ function normalizeVinextPrerenderConfig(config) {
|
|
|
10
11
|
if (config.routes === "*") return { routes: "*" };
|
|
11
12
|
throw new Error("[vinext] Unsupported `prerender.routes` config. Currently only `routes: \"*\"` is supported.");
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
for (const item of value) flattenPluginOptions(item, target);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (value) target.push(value);
|
|
19
|
-
}
|
|
20
|
-
function findVinextPrerenderConfigInPlugins(plugins) {
|
|
21
|
-
const flattened = [];
|
|
22
|
-
flattenPluginOptions(plugins, flattened);
|
|
14
|
+
async function findVinextPrerenderConfigInPlugins(plugins) {
|
|
15
|
+
const flattened = await flattenPluginOptions(plugins);
|
|
23
16
|
for (const plugin of flattened) {
|
|
24
17
|
if (!isUnknownRecord(plugin)) continue;
|
|
25
18
|
const prerenderConfig = plugin[VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY];
|
|
@@ -27,9 +20,8 @@ function findVinextPrerenderConfigInPlugins(plugins) {
|
|
|
27
20
|
}
|
|
28
21
|
return null;
|
|
29
22
|
}
|
|
30
|
-
function findVinextRouteRootConfigInPlugins(plugins) {
|
|
31
|
-
const flattened =
|
|
32
|
-
flattenPluginOptions(plugins, flattened);
|
|
23
|
+
async function findVinextRouteRootConfigInPlugins(plugins) {
|
|
24
|
+
const flattened = await flattenPluginOptions(plugins);
|
|
33
25
|
for (const plugin of flattened) {
|
|
34
26
|
if (!isUnknownRecord(plugin)) continue;
|
|
35
27
|
const routeRootConfig = plugin[VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY];
|
|
@@ -38,13 +30,13 @@ function findVinextRouteRootConfigInPlugins(plugins) {
|
|
|
38
30
|
return null;
|
|
39
31
|
}
|
|
40
32
|
async function loadVinextPrerenderConfigFromViteConfig(vite, root) {
|
|
41
|
-
return findVinextPrerenderConfigInPlugins((await vite.loadConfigFromFile({
|
|
33
|
+
return await findVinextPrerenderConfigInPlugins((await vite.loadConfigFromFile({
|
|
42
34
|
command: "build",
|
|
43
35
|
mode: "production"
|
|
44
36
|
}, void 0, root))?.config.plugins);
|
|
45
37
|
}
|
|
46
38
|
async function loadVinextRouteRootConfigFromViteConfig(vite, root) {
|
|
47
|
-
return findVinextRouteRootConfigInPlugins((await vite.loadConfigFromFile({
|
|
39
|
+
return await findVinextRouteRootConfigInPlugins((await vite.loadConfigFromFile({
|
|
48
40
|
command: "build",
|
|
49
41
|
mode: "production"
|
|
50
42
|
}, void 0, root))?.config.plugins);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/config/request-context.d.ts
|
|
2
|
+
/** Request context needed for evaluating has/missing conditions. */
|
|
3
|
+
type RequestContext = {
|
|
4
|
+
readonly headers: Headers;
|
|
5
|
+
readonly cookies: Record<string, string>;
|
|
6
|
+
readonly query: URLSearchParams;
|
|
7
|
+
readonly host: string;
|
|
8
|
+
};
|
|
9
|
+
declare function parseCookies(cookieHeader: string | null): Record<string, string>;
|
|
10
|
+
declare function normalizeHost(hostHeader: string | null, fallbackHostname: string): string;
|
|
11
|
+
/** Build a lazily parsed request context from a Web Request. */
|
|
12
|
+
declare function requestContextFromRequest(request: Request): RequestContext;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { RequestContext, normalizeHost, parseCookies, requestContextFromRequest };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { parseCookieHeader } from "../utils/parse-cookie.js";
|
|
2
|
+
//#region src/config/request-context.ts
|
|
3
|
+
function parseCookies(cookieHeader) {
|
|
4
|
+
return parseCookieHeader(cookieHeader);
|
|
5
|
+
}
|
|
6
|
+
function normalizeHost(hostHeader, fallbackHostname) {
|
|
7
|
+
return (hostHeader ?? fallbackHostname).split(":", 1)[0].toLowerCase();
|
|
8
|
+
}
|
|
9
|
+
/** Build a lazily parsed request context from a Web Request. */
|
|
10
|
+
function requestContextFromRequest(request) {
|
|
11
|
+
const url = new URL(request.url);
|
|
12
|
+
let cookies;
|
|
13
|
+
let query;
|
|
14
|
+
return {
|
|
15
|
+
headers: request.headers,
|
|
16
|
+
get cookies() {
|
|
17
|
+
return cookies ??= parseCookies(request.headers.get("cookie"));
|
|
18
|
+
},
|
|
19
|
+
get query() {
|
|
20
|
+
return query ??= url.searchParams;
|
|
21
|
+
},
|
|
22
|
+
host: normalizeHost(request.headers.get("host"), url.hostname)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { normalizeHost, parseCookies, requestContextFromRequest };
|
|
@@ -85,7 +85,7 @@ function mergeServerExternalPackages(userPackages = [], transpilePackages = [])
|
|
|
85
85
|
const conflicts = userPackages.filter((name) => transpiled.has(name));
|
|
86
86
|
if (conflicts.length > 0) throw new Error(`The packages specified in the 'transpilePackages' conflict with the 'serverExternalPackages': ${conflicts.join(", ")}`);
|
|
87
87
|
const defaults = DEFAULT_SERVER_EXTERNAL_PACKAGES.filter((name) => !transpiled.has(name));
|
|
88
|
-
return [
|
|
88
|
+
return [.../* @__PURE__ */ new Set([...defaults, ...userPackages])];
|
|
89
89
|
}
|
|
90
90
|
//#endregion
|
|
91
91
|
export { mergeServerExternalPackages };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
1
2
|
import { isUnknownRecord } from "../utils/record.js";
|
|
2
3
|
import { parseStaticObjectLiteral } from "../plugins/fonts.js";
|
|
3
4
|
import { createRequire } from "node:module";
|
|
4
5
|
import fs from "node:fs";
|
|
5
|
-
import path from "node:path";
|
|
6
6
|
//#region src/config/tsconfig-paths.ts
|
|
7
7
|
/**
|
|
8
8
|
* tsconfig.json `compilerOptions.paths` loader.
|
|
@@ -61,7 +61,7 @@ function resolveTsconfigExtends(configPath, specifier) {
|
|
|
61
61
|
path.join(specifier, "tsconfig.json")
|
|
62
62
|
];
|
|
63
63
|
for (const item of candidates) try {
|
|
64
|
-
return requireFromConfig.resolve(item);
|
|
64
|
+
return toSlash(requireFromConfig.resolve(item));
|
|
65
65
|
} catch {}
|
|
66
66
|
return null;
|
|
67
67
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getProcessAncestry } from "../../../../process-ancestry@0.1.0/
|
|
1
|
+
import { getProcessAncestry } from "../../../../process-ancestry@0.1.0/deps/process-ancestry/dist/index.js";
|
|
2
2
|
//#region ../../node_modules/.pnpm/am-i-vibing@0.5.0/node_modules/am-i-vibing/dist/detector-1yx2Hoe0.mjs
|
|
3
3
|
/**
|
|
4
4
|
* Provider configurations for major AI coding tools
|
|
@@ -291,4 +291,4 @@ function isAgent(envOrOptions, legacyAncestry) {
|
|
|
291
291
|
return result.type === "agent" || result.type === "hybrid";
|
|
292
292
|
}
|
|
293
293
|
//#endregion
|
|
294
|
-
export { isAgent };
|
|
294
|
+
export { providers as c, isAgent as n, detectAgenticEnvironment as t };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import nodePath from "node:path";
|
|
2
|
+
//#region ../../node_modules/.pnpm/pathslash@0.1.0/node_modules/pathslash/dist/index.mjs
|
|
3
|
+
const BACKSLASH_RE = /\\/g;
|
|
4
|
+
const isWindows = process.platform === "win32";
|
|
5
|
+
/**
|
|
6
|
+
* Flip backslashes to forward slashes, used to slash-ify `node:path.win32`
|
|
7
|
+
* output. `\\?\` (extended-length) paths are left untouched: there a forward
|
|
8
|
+
* slash is a literal character, not a separator.
|
|
9
|
+
*/
|
|
10
|
+
const toForwardSlash = (path) => path.startsWith("\\\\?\\") ? path : path.replace(BACKSLASH_RE, "/");
|
|
11
|
+
/**
|
|
12
|
+
* Normalize separators to `/`, safely. On Windows it converts `\` to `/`. On
|
|
13
|
+
* POSIX it does nothing, because there a backslash is a legal filename character
|
|
14
|
+
* and rewriting it would corrupt the path.
|
|
15
|
+
*/
|
|
16
|
+
function toSlash(path) {
|
|
17
|
+
return isWindows ? toForwardSlash(path) : path;
|
|
18
|
+
}
|
|
19
|
+
const w = nodePath.win32;
|
|
20
|
+
function slashed(fn) {
|
|
21
|
+
return (...args) => toForwardSlash(fn(...args));
|
|
22
|
+
}
|
|
23
|
+
const win32 = {
|
|
24
|
+
resolve: slashed(w.resolve),
|
|
25
|
+
normalize: slashed(w.normalize),
|
|
26
|
+
join: slashed(w.join),
|
|
27
|
+
relative: slashed(w.relative),
|
|
28
|
+
dirname: slashed(w.dirname),
|
|
29
|
+
format: slashed(w.format),
|
|
30
|
+
parse: (path) => {
|
|
31
|
+
const parsed = w.parse(path);
|
|
32
|
+
parsed.root = toForwardSlash(parsed.root);
|
|
33
|
+
parsed.dir = toForwardSlash(parsed.dir);
|
|
34
|
+
return parsed;
|
|
35
|
+
},
|
|
36
|
+
basename: w.basename,
|
|
37
|
+
extname: w.extname,
|
|
38
|
+
isAbsolute: w.isAbsolute,
|
|
39
|
+
matchesGlob: w.matchesGlob,
|
|
40
|
+
toNamespacedPath: w.toNamespacedPath,
|
|
41
|
+
delimiter: w.delimiter,
|
|
42
|
+
sep: "/"
|
|
43
|
+
};
|
|
44
|
+
const posix = { ...nodePath.posix };
|
|
45
|
+
posix.posix = win32.posix = posix;
|
|
46
|
+
posix.win32 = win32.win32 = win32;
|
|
47
|
+
const path = isWindows ? win32 : posix;
|
|
48
|
+
const { basename, delimiter, dirname, extname, format, isAbsolute, join, matchesGlob, normalize, parse, relative, resolve, sep, toNamespacedPath } = path;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { path as default, posix, toSlash, win32 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
2
|
import { resolveEntryPath } from "./runtime-entry-module.js";
|
|
3
3
|
import { isProxyFile } from "../server/middleware.js";
|
|
4
4
|
import { DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES } from "../server/image-optimization.js";
|
|
@@ -127,9 +127,9 @@ import { getNavigationContext as _getNavigationContext } from "next/navigation";
|
|
|
127
127
|
import { configureMemoryCacheHandler as __configureMemoryCacheHandler } from "vinext/shims/cache-handler";
|
|
128
128
|
import { headersContextFromRequest, getDraftModeCookieHeader, getAndClearPendingCookies, consumeDynamicUsage, consumeInvalidDynamicUsageError, setHeadersAccessPhase } from "next/headers";
|
|
129
129
|
import { mergeMetadata, resolveModuleMetadata, mergeViewport, resolveModuleViewport } from "vinext/metadata";
|
|
130
|
-
${middlewarePath ? `import * as middlewareModule from ${JSON.stringify(
|
|
130
|
+
${middlewarePath ? `import * as middlewareModule from ${JSON.stringify(toSlash(middlewarePath))};
|
|
131
131
|
import { applyAppMiddleware as __applyAppMiddleware } from ${JSON.stringify(appMiddlewarePath)};` : ""}
|
|
132
|
-
${instrumentationPath ? `import * as _instrumentation from ${JSON.stringify(
|
|
132
|
+
${instrumentationPath ? `import * as _instrumentation from ${JSON.stringify(toSlash(instrumentationPath))};
|
|
133
133
|
import { ensureInstrumentationRegistered as __ensureInstrumentationRegistered } from ${JSON.stringify(instrumentationRuntimePath)};` : ""}
|
|
134
134
|
import { createAppRscHandler } from "vinext/server/app-rsc-handler";
|
|
135
135
|
import { registerConfiguredCacheAdapters as __registerConfiguredCacheAdapters } from "virtual:vinext-cache-adapters";
|
|
@@ -333,6 +333,11 @@ export const __basePath = ${JSON.stringify(bp)};
|
|
|
333
333
|
// thread the configured trailingSlash flag through canonical URL rendering.
|
|
334
334
|
const __trailingSlash = ${JSON.stringify(ts)};
|
|
335
335
|
|
|
336
|
+
// Hoisted above __createAppFallbackRenderer (which runs at module init) so the
|
|
337
|
+
// fallback renderer can decide streaming-vs-blocking metadata redirects per
|
|
338
|
+
// request user-agent. The later per-request references still read this const.
|
|
339
|
+
const __htmlLimitedBots = ${JSON.stringify(htmlLimitedBots)};
|
|
340
|
+
|
|
336
341
|
const rootNotFoundModule = ${rootNotFoundVar ? rootNotFoundVar : "null"};
|
|
337
342
|
const rootForbiddenModule = ${rootForbiddenVar ? rootForbiddenVar : "null"};
|
|
338
343
|
const rootUnauthorizedModule = ${rootUnauthorizedVar ? rootUnauthorizedVar : "null"};
|
|
@@ -358,6 +363,7 @@ const __fallbackRenderer = __createAppFallbackRenderer({
|
|
|
358
363
|
${(metadataRoutes?.length ?? 0) > 0 ? "applyFileBasedMetadata: __applyFileBasedMetadata," : ""}
|
|
359
364
|
basePath: __basePath,
|
|
360
365
|
trailingSlash: __trailingSlash,
|
|
366
|
+
htmlLimitedBots: __htmlLimitedBots,
|
|
361
367
|
rootBoundaries: {
|
|
362
368
|
rootForbiddenModule,
|
|
363
369
|
rootLayouts,
|
|
@@ -380,6 +386,7 @@ const __fallbackRenderer = __createAppFallbackRenderer({
|
|
|
380
386
|
makeThenableParams,
|
|
381
387
|
sanitizer: __sanitizeErrorForClient,
|
|
382
388
|
rscRenderer: renderToReadableStream,
|
|
389
|
+
getAndClearPendingCookies,
|
|
383
390
|
getNavigationContext: _getNavigationContext,
|
|
384
391
|
resolveChildSegments: __resolveAppPageChildSegments,
|
|
385
392
|
clearRequestContext() {
|
|
@@ -394,6 +401,10 @@ function matchRoute(url) {
|
|
|
394
401
|
return __routeMatcher.matchRoute(url);
|
|
395
402
|
}
|
|
396
403
|
|
|
404
|
+
function matchRequestRoute(url) {
|
|
405
|
+
return __routeMatcher.matchRequestRoute(url);
|
|
406
|
+
}
|
|
407
|
+
|
|
397
408
|
/**
|
|
398
409
|
* Check if a pathname matches any intercepting route.
|
|
399
410
|
* Returns the match info or null.
|
|
@@ -432,7 +443,6 @@ const __runtimeImageConfig = ${JSON.stringify(config?.imageConfig)};
|
|
|
432
443
|
const __publicFiles = new Set(${JSON.stringify(publicFiles)});
|
|
433
444
|
const __allowedOrigins = ${JSON.stringify(allowedOrigins)};
|
|
434
445
|
const __expireTime = ${JSON.stringify(expireTime)};
|
|
435
|
-
const __htmlLimitedBots = ${JSON.stringify(htmlLimitedBots)};
|
|
436
446
|
const __clientTraceMetadata = ${JSON.stringify(clientTraceMetadata)};
|
|
437
447
|
const __reactMaxHeadersLength = ${JSON.stringify(reactMaxHeadersLength)};
|
|
438
448
|
// Re-exported for the App Router prod-server to consume at startup —
|
|
@@ -517,6 +527,7 @@ export default createAppRscHandler({
|
|
|
517
527
|
actionFailed,
|
|
518
528
|
handlerStart,
|
|
519
529
|
interceptionContext,
|
|
530
|
+
interceptionPathname,
|
|
520
531
|
isProgressiveActionRender,
|
|
521
532
|
isRscRequest,
|
|
522
533
|
middlewareContext,
|
|
@@ -582,6 +593,8 @@ export default createAppRscHandler({
|
|
|
582
593
|
renderMode,
|
|
583
594
|
observeMetadataSearchParamsAccess: buildOptions?.observeMetadataSearchParamsAccess === true,
|
|
584
595
|
observePageSearchParamsAccess: buildOptions?.observePageSearchParamsAccess === true,
|
|
596
|
+
serveStreamingMetadata: buildOptions?.serveStreamingMetadata,
|
|
597
|
+
isProduction: process.env.NODE_ENV === "production",
|
|
585
598
|
}, layoutParamAccess, displayPathname);
|
|
586
599
|
},
|
|
587
600
|
clientReuseManifest,
|
|
@@ -601,7 +614,10 @@ export default createAppRscHandler({
|
|
|
601
614
|
fetchCache: __segmentConfig.fetchCache ?? null,
|
|
602
615
|
isEdgeRuntime: __isEdgeRuntime(__segmentConfig.runtime),
|
|
603
616
|
findIntercept(pathname) {
|
|
604
|
-
return findIntercept(
|
|
617
|
+
return findIntercept(
|
|
618
|
+
pathname === cleanPathname ? interceptionPathname : pathname,
|
|
619
|
+
interceptionContext,
|
|
620
|
+
);
|
|
605
621
|
},
|
|
606
622
|
generateStaticParams: __generateStaticParams,
|
|
607
623
|
getFontLinks: _getSSRFontLinks,
|
|
@@ -653,7 +669,7 @@ export default createAppRscHandler({
|
|
|
653
669
|
});
|
|
654
670
|
},
|
|
655
671
|
async probePage(probeSearchParams = searchParams) {
|
|
656
|
-
const __probeIntercept = findIntercept(
|
|
672
|
+
const __probeIntercept = findIntercept(interceptionPathname, interceptionContext);
|
|
657
673
|
// The intercepting-route page module is lazy (page: null + __pageLoader).
|
|
658
674
|
// Resolve it before probing so buildAppPageProbes inspects the real page
|
|
659
675
|
// component for dynamic bailout — matching the render path, which also
|
|
@@ -675,7 +691,7 @@ export default createAppRscHandler({
|
|
|
675
691
|
}));
|
|
676
692
|
},
|
|
677
693
|
renderErrorBoundaryPage(renderErr, errorOrigin) {
|
|
678
|
-
const __activeIntercept = findIntercept(
|
|
694
|
+
const __activeIntercept = findIntercept(interceptionPathname, interceptionContext);
|
|
679
695
|
return __fallbackRenderer.renderErrorBoundary(route, renderErr, isRscRequest, request, params, scriptNonce, middlewareContext, {
|
|
680
696
|
isEdgeRuntime: __isEdgeRuntime(__segmentConfig.runtime),
|
|
681
697
|
sourcePageSegments: __activeIntercept?.slotKey === __SIBLING_PAGE_INTERCEPT_SLOT_KEY
|
|
@@ -684,9 +700,10 @@ export default createAppRscHandler({
|
|
|
684
700
|
}, errorOrigin);
|
|
685
701
|
},
|
|
686
702
|
renderHttpAccessFallbackPage(statusCode, opts, currentMiddlewareContext) {
|
|
687
|
-
const __activeIntercept = findIntercept(
|
|
703
|
+
const __activeIntercept = findIntercept(interceptionPathname, interceptionContext);
|
|
688
704
|
return __fallbackRenderer.renderHttpAccessFallback(route, statusCode, isRscRequest, request, opts, scriptNonce, currentMiddlewareContext, {
|
|
689
705
|
isEdgeRuntime: __isEdgeRuntime(__segmentConfig.runtime),
|
|
706
|
+
routePathname: cleanPathname,
|
|
690
707
|
sourcePageSegments: __activeIntercept?.slotKey === __SIBLING_PAGE_INTERCEPT_SLOT_KEY
|
|
691
708
|
? __activeIntercept.sourcePageSegments
|
|
692
709
|
: null,
|
|
@@ -765,6 +782,7 @@ export default createAppRscHandler({
|
|
|
765
782
|
contentType,
|
|
766
783
|
middlewareContext,
|
|
767
784
|
request,
|
|
785
|
+
routeMatch,
|
|
768
786
|
}) {
|
|
769
787
|
const {
|
|
770
788
|
handleProgressiveServerActionRequest: __handleProgressiveServerActionRequest,
|
|
@@ -785,11 +803,10 @@ export default createAppRscHandler({
|
|
|
785
803
|
contentType,
|
|
786
804
|
actionId,
|
|
787
805
|
);
|
|
788
|
-
const __progressiveActionMatch = __isProgressiveAction ? matchRoute(cleanPathname) : null;
|
|
789
806
|
const __hasPageRoute = Boolean(
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
!
|
|
807
|
+
__isProgressiveAction &&
|
|
808
|
+
routeMatch?.route.__loadPage &&
|
|
809
|
+
!routeMatch.route.__loadRouteHandler,
|
|
793
810
|
);
|
|
794
811
|
return __handleProgressiveServerActionRequest({
|
|
795
812
|
actionId,
|
|
@@ -822,6 +839,8 @@ export default createAppRscHandler({
|
|
|
822
839
|
middlewareContext,
|
|
823
840
|
mountedSlotsHeader,
|
|
824
841
|
request,
|
|
842
|
+
routeMatch,
|
|
843
|
+
routePathname,
|
|
825
844
|
searchParams,
|
|
826
845
|
}) {
|
|
827
846
|
const {
|
|
@@ -829,7 +848,7 @@ export default createAppRscHandler({
|
|
|
829
848
|
readActionBodyWithLimit: __readBodyWithLimit,
|
|
830
849
|
readActionFormDataWithLimit: __readFormDataWithLimit,
|
|
831
850
|
} = await __loadAppServerActionExecution();
|
|
832
|
-
const __actionMatch =
|
|
851
|
+
const __actionMatch = routeMatch;
|
|
833
852
|
if (__actionMatch) await __ensureRouteLoaded(__actionMatch.route);
|
|
834
853
|
const __actionIsEdgeRuntime = __actionMatch
|
|
835
854
|
? __isEdgeRuntime(__resolveRouteRuntime(__actionMatch.route))
|
|
@@ -869,6 +888,8 @@ export default createAppRscHandler({
|
|
|
869
888
|
__clearRequestContext();
|
|
870
889
|
},
|
|
871
890
|
contentType,
|
|
891
|
+
currentRouteMatch: __actionMatch,
|
|
892
|
+
currentRoutePathname: routePathname,
|
|
872
893
|
createNotFoundElement(actionRouteId) {
|
|
873
894
|
return {
|
|
874
895
|
...__AppElementsWire.createMetadataEntries({
|
|
@@ -933,6 +954,9 @@ export default createAppRscHandler({
|
|
|
933
954
|
interceptLayouts: intercept.interceptLayouts,
|
|
934
955
|
interceptLayoutSegments: intercept.interceptLayoutSegments,
|
|
935
956
|
interceptBranchSegments: intercept.interceptBranchSegments,
|
|
957
|
+
interceptNotFoundBranchSegments: intercept.interceptNotFoundBranchSegments,
|
|
958
|
+
interceptNotFound: intercept.notFound,
|
|
959
|
+
interceptNotFoundTreePosition: intercept.notFoundTreePosition,
|
|
936
960
|
interceptSlotId: intercept.slotId,
|
|
937
961
|
interceptSlotKey: intercept.slotKey,
|
|
938
962
|
interceptSourceMatchedUrl: interceptionContext,
|
|
@@ -956,13 +980,14 @@ export default createAppRscHandler({
|
|
|
956
980
|
});
|
|
957
981
|
},` : ""}
|
|
958
982
|
matchRoute,
|
|
983
|
+
matchRequestRoute,
|
|
959
984
|
${middlewarePath ? `runMiddleware({ cleanPathname, context, hadBasePath, isDataRequest, request }) {
|
|
960
985
|
return __applyAppMiddleware({
|
|
961
986
|
basePath: __basePath,
|
|
962
987
|
cleanPathname,
|
|
963
988
|
context,
|
|
964
989
|
hadBasePath,
|
|
965
|
-
filePath: ${JSON.stringify(middlewarePath ?
|
|
990
|
+
filePath: ${JSON.stringify(middlewarePath ? toSlash(middlewarePath) : "")},
|
|
966
991
|
i18nConfig: __i18nConfig,
|
|
967
992
|
isDataRequest,
|
|
968
993
|
isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
2
|
import { computeAppRouteStaticSiblings, convertSegmentsToRouteParts } from "../routing/app-route-graph.js";
|
|
3
3
|
import "../routing/app-router.js";
|
|
4
4
|
import { createMetadataRouteEntriesSource } from "../server/metadata-route-build-data.js";
|
|
@@ -30,7 +30,7 @@ function createImportAllocator() {
|
|
|
30
30
|
const existing = importMap.get(filePath);
|
|
31
31
|
if (existing) return existing;
|
|
32
32
|
const varName = `mod_${importIdx++}`;
|
|
33
|
-
const absPath =
|
|
33
|
+
const absPath = toSlash(filePath);
|
|
34
34
|
imports.push(`import * as ${varName} from ${JSON.stringify(absPath)};`);
|
|
35
35
|
importMap.set(filePath, varName);
|
|
36
36
|
return varName;
|
|
@@ -39,7 +39,7 @@ function createImportAllocator() {
|
|
|
39
39
|
const existing = lazyMap.get(filePath);
|
|
40
40
|
if (existing) return existing;
|
|
41
41
|
const varName = `load_${lazyIdx++}`;
|
|
42
|
-
const absPath =
|
|
42
|
+
const absPath = toSlash(filePath);
|
|
43
43
|
imports.push(`const ${varName} = () => import(${JSON.stringify(absPath)});`);
|
|
44
44
|
lazyMap.set(filePath, varName);
|
|
45
45
|
return varName;
|
|
@@ -77,13 +77,16 @@ function registerRouteModules(routes, imports) {
|
|
|
77
77
|
for (const layoutPath of slot.configLayoutPaths ?? []) imports.getLazyLoaderVar(layoutPath);
|
|
78
78
|
if (slot.loadingPath) imports.getLazyLoaderVar(slot.loadingPath);
|
|
79
79
|
if (slot.errorPath) imports.getLazyLoaderVar(slot.errorPath);
|
|
80
|
+
if (slot.notFoundPath) imports.getLazyLoaderVar(slot.notFoundPath);
|
|
80
81
|
for (const ir of slot.interceptingRoutes) {
|
|
81
82
|
imports.getLazyLoaderVar(ir.pagePath);
|
|
83
|
+
if (ir.notFoundPath) imports.getLazyLoaderVar(ir.notFoundPath);
|
|
82
84
|
for (const layoutPath of ir.layoutPaths) imports.getLazyLoaderVar(layoutPath);
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
87
|
for (const ir of route.siblingIntercepts ?? []) {
|
|
86
88
|
imports.getLazyLoaderVar(ir.pagePath);
|
|
89
|
+
if (ir.notFoundPath) imports.getLazyLoaderVar(ir.notFoundPath);
|
|
87
90
|
for (const layoutPath of ir.layoutPaths) imports.getLazyLoaderVar(layoutPath);
|
|
88
91
|
}
|
|
89
92
|
}
|
|
@@ -115,8 +118,12 @@ function buildRouteEntries(routes, imports) {
|
|
|
115
118
|
__loadInterceptLayouts: ${lazyLoaderArray(ir.layoutPaths, imports)},
|
|
116
119
|
interceptLayoutSegments: ${JSON.stringify(ir.layoutSegments ?? [])},
|
|
117
120
|
interceptBranchSegments: ${JSON.stringify(ir.branchSegments ?? [])},
|
|
121
|
+
interceptNotFoundBranchSegments: ${JSON.stringify(ir.notFoundBranchSegments ?? ir.branchSegments ?? [])},
|
|
118
122
|
page: null,
|
|
119
123
|
__pageLoader: ${imports.getLazyLoaderVar(ir.pagePath)},
|
|
124
|
+
notFound: null,
|
|
125
|
+
__loadNotFound: ${ir.notFoundPath ? imports.getLazyLoaderVar(ir.notFoundPath) : "null"},
|
|
126
|
+
notFoundTreePosition: ${ir.notFoundTreePosition ?? "null"},
|
|
120
127
|
params: ${JSON.stringify(ir.params)},
|
|
121
128
|
}`);
|
|
122
129
|
const slotEntries = route.parallelSlots.map((slot) => {
|
|
@@ -129,8 +136,12 @@ function buildRouteEntries(routes, imports) {
|
|
|
129
136
|
__loadInterceptLayouts: ${lazyLoaderArray(ir.layoutPaths, imports)},
|
|
130
137
|
interceptLayoutSegments: ${JSON.stringify(ir.layoutSegments ?? [])},
|
|
131
138
|
interceptBranchSegments: ${JSON.stringify(ir.branchSegments ?? [])},
|
|
139
|
+
interceptNotFoundBranchSegments: ${JSON.stringify(ir.notFoundBranchSegments ?? ir.branchSegments ?? [])},
|
|
132
140
|
page: null,
|
|
133
141
|
__pageLoader: ${imports.getLazyLoaderVar(ir.pagePath)},
|
|
142
|
+
notFound: null,
|
|
143
|
+
__loadNotFound: ${ir.notFoundPath ? imports.getLazyLoaderVar(ir.notFoundPath) : "null"},
|
|
144
|
+
notFoundTreePosition: ${ir.notFoundTreePosition ?? "null"},
|
|
134
145
|
params: ${JSON.stringify(ir.params)},
|
|
135
146
|
}`);
|
|
136
147
|
return ` ${JSON.stringify(slot.key)}: {
|
|
@@ -149,6 +160,9 @@ function buildRouteEntries(routes, imports) {
|
|
|
149
160
|
__loadLoading: ${slot.loadingPath ? imports.getLazyLoaderVar(slot.loadingPath) : "null"},
|
|
150
161
|
error: null,
|
|
151
162
|
__loadError: ${slot.errorPath ? imports.getLazyLoaderVar(slot.errorPath) : "null"},
|
|
163
|
+
notFound: null,
|
|
164
|
+
__loadNotFound: ${slot.notFoundPath ? imports.getLazyLoaderVar(slot.notFoundPath) : "null"},
|
|
165
|
+
notFoundTreePosition: ${slot.notFoundTreePosition ?? "null"},
|
|
152
166
|
layoutIndex: ${slot.layoutIndex},
|
|
153
167
|
routeSegments: ${JSON.stringify(slot.routeSegments)},
|
|
154
168
|
slotPatternParts: ${slot.slotPatternParts ? JSON.stringify(slot.slotPatternParts) : "null"},
|
|
@@ -204,14 +218,17 @@ ${siblingInterceptEntries.join(",\n")}
|
|
|
204
218
|
__loadError: ${route.errorPath ? imports.getLazyLoaderVar(route.errorPath) : "null"},
|
|
205
219
|
notFound: null,
|
|
206
220
|
__loadNotFound: ${route.notFoundPath ? imports.getLazyLoaderVar(route.notFoundPath) : "null"},
|
|
221
|
+
notFoundTreePosition: ${route.notFoundTreePosition ?? "null"},
|
|
207
222
|
notFounds: ${moduleArray(notFoundPaths.length)},
|
|
208
223
|
__loadNotFounds: ${notFoundLoaders},
|
|
209
224
|
forbidden: null,
|
|
210
225
|
__loadForbidden: ${route.forbiddenPath ? imports.getLazyLoaderVar(route.forbiddenPath) : "null"},
|
|
226
|
+
forbiddenTreePosition: ${route.forbiddenTreePosition ?? "null"},
|
|
211
227
|
forbiddens: ${moduleArray(forbiddenPaths.length)},
|
|
212
228
|
__loadForbiddens: ${forbiddenLoaders},
|
|
213
229
|
unauthorized: null,
|
|
214
230
|
__loadUnauthorized: ${route.unauthorizedPath ? imports.getLazyLoaderVar(route.unauthorizedPath) : "null"},
|
|
231
|
+
unauthorizedTreePosition: ${route.unauthorizedTreePosition ?? "null"},
|
|
215
232
|
unauthorizeds: ${moduleArray(unauthorizedPaths.length)},
|
|
216
233
|
__loadUnauthorizeds: ${unauthorizedLoaders},
|
|
217
234
|
}`;
|
|
@@ -282,7 +299,7 @@ function buildAppRscManifestCode(options) {
|
|
|
282
299
|
const rootUnauthorizedVar = rootUnauthorizedPath ? imports.getImportVar(rootUnauthorizedPath) : null;
|
|
283
300
|
const rootLayoutVars = rootRouteLayoutPaths(rootRoute).map((layoutPath) => imports.getImportVar(layoutPath));
|
|
284
301
|
const globalErrorVar = options.globalErrorPath ? imports.getImportVar(options.globalErrorPath) : null;
|
|
285
|
-
const globalNotFoundImportSpecifier = options.globalNotFoundPath ? JSON.stringify(
|
|
302
|
+
const globalNotFoundImportSpecifier = options.globalNotFoundPath ? JSON.stringify(toSlash(options.globalNotFoundPath)) : null;
|
|
286
303
|
const dynamicMetadataRoutes = metadataRoutes.filter((r) => r.isDynamic);
|
|
287
304
|
for (const route of dynamicMetadataRoutes) imports.getImportVar(route.filePath);
|
|
288
305
|
const namesByPattern = buildRootParamNamesByPattern(options.routes);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
2
|
import { findFileWithExts } from "../routing/file-matcher.js";
|
|
3
3
|
import { patternToNextFormat } from "../routing/route-validation.js";
|
|
4
4
|
import { apiRouter, pagesRouter } from "../routing/pages-router.js";
|
|
5
|
-
import "./pages-entry-helpers.js";
|
|
6
5
|
import { hasExportedName } from "../build/report.js";
|
|
7
6
|
import { readFile } from "node:fs/promises";
|
|
8
7
|
//#region src/entries/pages-client-entry.ts
|
|
@@ -42,6 +41,7 @@ async function generateClientEntry(pagesDir, nextConfig, fileMatcher, options =
|
|
|
42
41
|
const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
43
42
|
const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
44
43
|
const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
|
|
44
|
+
const errorFilePath = findFileWithExts(pagesDir, "_error", fileMatcher);
|
|
45
45
|
const hasApp = appFilePath !== null;
|
|
46
46
|
const appPrefetchRoutes = options.appPrefetchRoutes ?? [];
|
|
47
47
|
const pagesPrefetchRoutes = [...pageRoutes.map(toPagesLinkPrefetchRoute), ...apiRoutes.map((route) => ({
|
|
@@ -52,12 +52,13 @@ async function generateClientEntry(pagesDir, nextConfig, fileMatcher, options =
|
|
|
52
52
|
const pagesSspPatterns = (await Promise.all(pageRoutes.map(async (route) => await hasGetServerSidePropsExport(route.filePath) ? patternToNextFormat(route.pattern) : null))).filter((pattern) => pattern !== null);
|
|
53
53
|
const instrumentationClientPath = options.instrumentationClientPath ?? null;
|
|
54
54
|
const loaderEntries = pageRoutes.map((r) => {
|
|
55
|
-
const absPath =
|
|
55
|
+
const absPath = r.filePath;
|
|
56
56
|
const nextFormatPattern = patternToNextFormat(r.pattern);
|
|
57
57
|
return ` ${JSON.stringify(nextFormatPattern)}: () => import(${JSON.stringify(absPath)})`;
|
|
58
58
|
});
|
|
59
|
-
|
|
60
|
-
const
|
|
59
|
+
loaderEntries.push(errorFilePath !== null ? ` "/_error": () => import(${JSON.stringify(errorFilePath)})` : " \"/_error\": () => import(\"next/error\")");
|
|
60
|
+
const appFileBase = appFilePath ?? void 0;
|
|
61
|
+
const userInstrumentationImport = instrumentationClientPath ? `import ${JSON.stringify(toSlash(instrumentationClientPath))};\n` : "";
|
|
61
62
|
const reactPreambleImport = options.reactPreamble === false ? "" : "import \"@vitejs/plugin-react/preamble\";\n";
|
|
62
63
|
const reactStrictModeEnabled = nextConfig.reactStrictMode === true;
|
|
63
64
|
return `${userInstrumentationImport}${reactPreambleImport}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { normalizePathSeparators } from "../utils/path.js";
|
|
2
1
|
import { findFileWithExts } from "../routing/file-matcher.js";
|
|
3
2
|
import { apiRouter, pagesRouter } from "../routing/pages-router.js";
|
|
4
3
|
import { resolveEntryPath } from "./runtime-entry-module.js";
|
|
5
4
|
import { isProxyFile } from "../server/middleware.js";
|
|
6
|
-
import "./pages-entry-helpers.js";
|
|
7
5
|
import { hasExportedName } from "../build/report.js";
|
|
8
6
|
import { readFile } from "node:fs/promises";
|
|
9
7
|
//#region src/entries/pages-server-entry.ts
|
|
@@ -39,18 +37,11 @@ async function getPagesDataKind(filePath) {
|
|
|
39
37
|
async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middlewarePath, instrumentationPath) {
|
|
40
38
|
const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
41
39
|
const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
42
|
-
const pageImports = pageRoutes.map((r, i) => {
|
|
43
|
-
|
|
44
|
-
return `import * as page_${i} from ${JSON.stringify(absPath)};`;
|
|
45
|
-
});
|
|
46
|
-
const apiImports = apiRoutes.map((r, i) => {
|
|
47
|
-
const absPath = normalizePathSeparators(r.filePath);
|
|
48
|
-
return `import * as api_${i} from ${JSON.stringify(absPath)};`;
|
|
49
|
-
});
|
|
40
|
+
const pageImports = pageRoutes.map((r, i) => `import * as page_${i} from ${JSON.stringify(r.filePath)};`);
|
|
41
|
+
const apiImports = apiRoutes.map((r, i) => `import * as api_${i} from ${JSON.stringify(r.filePath)};`);
|
|
50
42
|
const pageRouteEntries = await Promise.all(pageRoutes.map(async (r, i) => {
|
|
51
|
-
const absPath = normalizePathSeparators(r.filePath);
|
|
52
43
|
const dataKind = await getPagesDataKind(r.filePath);
|
|
53
|
-
return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: page_${i}, filePath: ${JSON.stringify(
|
|
44
|
+
return ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: page_${i}, filePath: ${JSON.stringify(r.filePath)}, dataKind: ${JSON.stringify(dataKind)} }`;
|
|
54
45
|
}));
|
|
55
46
|
const apiRouteEntries = apiRoutes.map((r, i) => ` { pattern: ${JSON.stringify(r.pattern)}, patternParts: ${JSON.stringify(r.patternParts)}, isDynamic: ${r.isDynamic}, params: ${JSON.stringify(r.params)}, module: api_${i} }`);
|
|
56
47
|
const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
|
|
@@ -60,7 +51,7 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
|
|
|
60
51
|
const appImportCode = appFilePath !== null ? `import { default as AppComponent } from ${JSON.stringify(appFilePath)};` : `const AppComponent = null;`;
|
|
61
52
|
const docImportCode = docFilePath !== null ? `import { default as DocumentComponent } from ${JSON.stringify(docFilePath)};` : `const DocumentComponent = null;`;
|
|
62
53
|
const errorAssetPathJson = errorFilePath !== null ? JSON.stringify(errorFilePath) : "null";
|
|
63
|
-
const errorImportCode = errorFilePath !== null ? `import * as ErrorPageModule from ${JSON.stringify(errorFilePath)};` : `
|
|
54
|
+
const errorImportCode = errorFilePath !== null ? `import * as ErrorPageModule from ${JSON.stringify(errorFilePath)};` : `import * as ErrorPageModule from "next/error";`;
|
|
64
55
|
const i18nConfigJson = nextConfig?.i18n ? JSON.stringify({
|
|
65
56
|
locales: nextConfig.i18n.locales,
|
|
66
57
|
defaultLocale: nextConfig.i18n.defaultLocale,
|
|
@@ -95,7 +86,7 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
|
|
|
95
86
|
contentSecurityPolicy: nextConfig?.images?.contentSecurityPolicy
|
|
96
87
|
}
|
|
97
88
|
});
|
|
98
|
-
const instrumentationImportCode = instrumentationPath ? `import * as _instrumentation from ${JSON.stringify(
|
|
89
|
+
const instrumentationImportCode = instrumentationPath ? `import * as _instrumentation from ${JSON.stringify(instrumentationPath)};` : "";
|
|
99
90
|
const instrumentationInitCode = instrumentationPath ? `// Run instrumentation register() once at module evaluation time — before any
|
|
100
91
|
// requests are handled. Matches Next.js semantics: register() is called once
|
|
101
92
|
// on startup in the process that handles requests.
|
|
@@ -107,13 +98,13 @@ if (typeof _instrumentation.register === "function") {
|
|
|
107
98
|
if (typeof _instrumentation.onRequestError === "function") {
|
|
108
99
|
globalThis.__VINEXT_onRequestErrorHandler__ = _instrumentation.onRequestError;
|
|
109
100
|
}` : "";
|
|
110
|
-
const middlewareImportCode = middlewarePath ? `import * as middlewareModule from ${JSON.stringify(
|
|
101
|
+
const middlewareImportCode = middlewarePath ? `import * as middlewareModule from ${JSON.stringify(middlewarePath)};` : "";
|
|
111
102
|
const middlewareExportCode = middlewarePath ? `
|
|
112
103
|
export async function runMiddleware(request, ctx, options) {
|
|
113
104
|
return __runGeneratedMiddleware({
|
|
114
105
|
basePath: vinextConfig.basePath,
|
|
115
106
|
ctx,
|
|
116
|
-
filePath: ${JSON.stringify(
|
|
107
|
+
filePath: ${JSON.stringify(middlewarePath)},
|
|
117
108
|
i18nConfig,
|
|
118
109
|
isDataRequest: options?.isDataRequest === true,
|
|
119
110
|
isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},
|
|
@@ -228,16 +219,14 @@ export const pageRoutes = [
|
|
|
228
219
|
${pageRouteEntries.join(",\n")}
|
|
229
220
|
];
|
|
230
221
|
const _pageRouteTrie = _buildRouteTrie(pageRoutes);
|
|
231
|
-
const _errorPageRoute =
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
: null;
|
|
222
|
+
const _errorPageRoute = {
|
|
223
|
+
pattern: "/_error",
|
|
224
|
+
patternParts: ["_error"],
|
|
225
|
+
isDynamic: false,
|
|
226
|
+
params: [],
|
|
227
|
+
module: ErrorPageModule,
|
|
228
|
+
filePath: ${errorAssetPathJson},
|
|
229
|
+
};
|
|
241
230
|
|
|
242
231
|
const apiRoutes = [
|
|
243
232
|
${apiRouteEntries.join(",\n")}
|
|
@@ -247,8 +236,8 @@ const _apiRouteTrie = _buildRouteTrie(apiRoutes);
|
|
|
247
236
|
function matchRoute(url, routes) {
|
|
248
237
|
const pathname = url.split("?")[0];
|
|
249
238
|
let normalizedUrl = pathname === "/" ? "/" : pathname.replace(/\\/$/, "");
|
|
250
|
-
//
|
|
251
|
-
//
|
|
239
|
+
// Static route selection uses raw encoded identity (/%61bout must not
|
|
240
|
+
// select /about). _trieMatch decodes dynamic captures exactly once.
|
|
252
241
|
const urlParts = normalizedUrl.split("/").filter(Boolean);
|
|
253
242
|
const trie = routes === pageRoutes ? _pageRouteTrie : _apiRouteTrie;
|
|
254
243
|
return _trieMatch(trie, urlParts);
|
|
@@ -318,6 +307,7 @@ const _renderPage = __createPagesPageHandler({
|
|
|
318
307
|
: null,
|
|
319
308
|
setI18nContext: typeof setI18nContext === "function" ? setI18nContext : null,
|
|
320
309
|
wrapWithRouterContext: typeof wrapWithRouterContext === "function" ? wrapWithRouterContext : null,
|
|
310
|
+
router: Router,
|
|
321
311
|
resetSSRHead: typeof resetSSRHead === "function" ? resetSSRHead : undefined,
|
|
322
312
|
getSSRHeadHTML: typeof getSSRHeadHTML === "function" ? getSSRHeadHTML : undefined,
|
|
323
313
|
setDocumentInitialHead: typeof setDocumentInitialHead === "function" ? setDocumentInitialHead : undefined,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
//#region src/entries/runtime-entry-module.ts
|
|
@@ -14,7 +14,7 @@ import { fileURLToPath } from "node:url";
|
|
|
14
14
|
* @param base - The caller's `import.meta.url`
|
|
15
15
|
*/
|
|
16
16
|
function resolveEntryPath(rel, base) {
|
|
17
|
-
return
|
|
17
|
+
return toSlash(fileURLToPath(new URL(rel, base)));
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Resolve a real runtime module for a virtual entry generator.
|