vinext 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/client-build-config.d.ts +11 -2
- package/dist/build/client-build-config.js +17 -6
- package/dist/build/prerender.d.ts +9 -1
- package/dist/build/prerender.js +42 -12
- package/dist/build/run-prerender.d.ts +10 -2
- package/dist/build/run-prerender.js +15 -1
- package/dist/client/app-nav-failure-handler.d.ts +8 -0
- package/dist/client/app-nav-failure-handler.js +44 -0
- package/dist/client/pages-router-link-navigation.d.ts +33 -7
- package/dist/client/pages-router-link-navigation.js +32 -2
- package/dist/client/vinext-next-data.d.ts +18 -1
- package/dist/client/vinext-next-data.js +2 -0
- package/dist/client/window-next.d.ts +2 -1
- package/dist/client/window-next.js +12 -1
- package/dist/cloudflare/src/cache/cdn-adapter.runtime.js +6 -1
- package/dist/config/config-matchers.d.ts +11 -1
- package/dist/config/config-matchers.js +87 -16
- package/dist/config/next-config.d.ts +46 -4
- package/dist/config/next-config.js +147 -48
- package/dist/config/tsconfig-paths.js +14 -1
- package/dist/deploy.d.ts +30 -11
- package/dist/deploy.js +200 -112
- package/dist/entries/app-browser-entry.d.ts +9 -3
- package/dist/entries/app-browser-entry.js +21 -3
- package/dist/entries/app-rsc-entry.d.ts +2 -0
- package/dist/entries/app-rsc-entry.js +65 -5
- package/dist/entries/app-rsc-manifest.js +2 -0
- package/dist/entries/app-ssr-entry.js +1 -1
- package/dist/entries/pages-client-entry.js +66 -20
- package/dist/entries/pages-server-entry.js +47 -31
- package/dist/index.js +417 -102
- package/dist/plugins/dynamic-preload-metadata.js +2 -4
- package/dist/plugins/extensionless-dynamic-import.d.ts +6 -0
- package/dist/plugins/extensionless-dynamic-import.js +152 -0
- package/dist/plugins/fonts.js +5 -4
- package/dist/plugins/optimize-imports.d.ts +2 -1
- package/dist/plugins/optimize-imports.js +11 -9
- package/dist/plugins/postcss.js +7 -7
- package/dist/plugins/strip-server-exports.d.ts +9 -7
- package/dist/plugins/strip-server-exports.js +493 -46
- package/dist/plugins/typeof-window.d.ts +14 -0
- package/dist/plugins/typeof-window.js +150 -0
- package/dist/routing/app-route-graph.d.ts +2 -1
- package/dist/routing/app-route-graph.js +46 -16
- package/dist/routing/file-matcher.d.ts +10 -1
- package/dist/routing/file-matcher.js +22 -1
- package/dist/routing/pages-router.js +3 -3
- package/dist/routing/utils.d.ts +35 -6
- package/dist/routing/utils.js +59 -7
- package/dist/server/api-handler.d.ts +6 -1
- package/dist/server/api-handler.js +21 -15
- package/dist/server/app-browser-action-result.d.ts +19 -6
- package/dist/server/app-browser-action-result.js +20 -11
- package/dist/server/app-browser-entry.js +175 -91
- package/dist/server/app-browser-error.d.ts +10 -6
- package/dist/server/app-browser-error.js +43 -8
- package/dist/server/app-browser-hydration.d.ts +2 -0
- package/dist/server/app-browser-hydration.js +1 -0
- package/dist/server/app-browser-navigation-controller.d.ts +5 -3
- package/dist/server/app-browser-navigation-controller.js +23 -2
- package/dist/server/app-browser-server-action-navigation.d.ts +6 -0
- package/dist/server/app-browser-server-action-navigation.js +9 -0
- package/dist/server/app-browser-state.d.ts +1 -1
- package/dist/server/app-browser-state.js +19 -11
- package/dist/server/app-browser-stream.js +86 -43
- package/dist/server/app-browser-visible-commit.d.ts +1 -1
- package/dist/server/app-elements-wire.d.ts +6 -1
- package/dist/server/app-elements-wire.js +14 -4
- package/dist/server/app-elements.d.ts +2 -2
- package/dist/server/app-elements.js +2 -2
- package/dist/server/app-fallback-renderer.d.ts +1 -0
- package/dist/server/app-fallback-renderer.js +3 -1
- package/dist/server/app-optimistic-routing.js +2 -2
- package/dist/server/app-page-boundary-render.d.ts +1 -0
- package/dist/server/app-page-boundary-render.js +27 -14
- package/dist/server/app-page-cache-render.d.ts +53 -0
- package/dist/server/app-page-cache-render.js +91 -0
- package/dist/server/app-page-cache.d.ts +16 -2
- package/dist/server/app-page-cache.js +62 -1
- package/dist/server/app-page-dispatch.d.ts +26 -0
- package/dist/server/app-page-dispatch.js +149 -92
- package/dist/server/app-page-element-builder.d.ts +1 -0
- package/dist/server/app-page-element-builder.js +5 -2
- package/dist/server/app-page-execution.d.ts +6 -1
- package/dist/server/app-page-execution.js +21 -1
- package/dist/server/app-page-probe.d.ts +1 -0
- package/dist/server/app-page-probe.js +4 -0
- package/dist/server/app-page-render-observation.d.ts +3 -1
- package/dist/server/app-page-render-observation.js +17 -1
- package/dist/server/app-page-render.d.ts +12 -1
- package/dist/server/app-page-render.js +42 -4
- package/dist/server/app-page-request.d.ts +2 -0
- package/dist/server/app-page-request.js +2 -1
- package/dist/server/app-page-route-wiring.d.ts +3 -1
- package/dist/server/app-page-route-wiring.js +14 -5
- package/dist/server/app-page-stream.d.ts +15 -3
- package/dist/server/app-page-stream.js +11 -5
- package/dist/server/app-pages-bridge.d.ts +23 -1
- package/dist/server/app-pages-bridge.js +26 -17
- package/dist/server/app-ppr-fallback-shell-render.d.ts +17 -0
- package/dist/server/app-ppr-fallback-shell-render.js +26 -0
- package/dist/server/app-ppr-fallback-shell.d.ts +13 -1
- package/dist/server/app-ppr-fallback-shell.js +8 -1
- package/dist/server/app-route-handler-dispatch.js +9 -2
- package/dist/server/app-route-handler-policy.d.ts +1 -0
- package/dist/server/app-router-entry.js +5 -0
- package/dist/server/app-rsc-cache-busting.js +2 -0
- package/dist/server/app-rsc-handler.d.ts +28 -0
- package/dist/server/app-rsc-handler.js +195 -59
- package/dist/server/app-rsc-route-matching.d.ts +3 -0
- package/dist/server/app-rsc-route-matching.js +8 -2
- package/dist/server/app-segment-config.d.ts +9 -1
- package/dist/server/app-segment-config.js +12 -3
- package/dist/server/app-server-action-execution.d.ts +1 -0
- package/dist/server/app-server-action-execution.js +47 -15
- package/dist/server/app-ssr-entry.d.ts +2 -0
- package/dist/server/app-ssr-entry.js +84 -39
- package/dist/server/before-interactive-head.d.ts +17 -0
- package/dist/server/before-interactive-head.js +35 -0
- package/dist/server/cache-control.js +4 -0
- package/dist/server/csp.js +1 -4
- package/dist/server/dev-server.d.ts +2 -2
- package/dist/server/dev-server.js +321 -83
- package/dist/server/hybrid-route-priority.d.ts +22 -0
- package/dist/server/hybrid-route-priority.js +33 -0
- package/dist/server/image-optimization.d.ts +18 -9
- package/dist/server/image-optimization.js +37 -23
- package/dist/server/implicit-tags.d.ts +2 -1
- package/dist/server/implicit-tags.js +4 -1
- package/dist/server/middleware-matcher.js +12 -3
- package/dist/server/middleware-runtime.d.ts +3 -4
- package/dist/server/middleware-runtime.js +2 -0
- package/dist/server/navigation-planner.d.ts +135 -41
- package/dist/server/navigation-planner.js +138 -0
- package/dist/server/navigation-trace.d.ts +9 -1
- package/dist/server/navigation-trace.js +9 -1
- package/dist/server/operation-token.d.ts +40 -0
- package/dist/server/operation-token.js +85 -0
- package/dist/server/pages-api-route.d.ts +6 -0
- package/dist/server/pages-api-route.js +13 -2
- package/dist/server/pages-asset-tags.d.ts +2 -1
- package/dist/server/pages-asset-tags.js +6 -2
- package/dist/server/pages-data-route.d.ts +9 -2
- package/dist/server/pages-data-route.js +18 -6
- package/dist/server/pages-dev-module-url.d.ts +4 -0
- package/dist/server/pages-dev-module-url.js +15 -0
- package/dist/server/pages-document-initial-props.d.ts +4 -15
- package/dist/server/pages-document-initial-props.js +27 -56
- package/dist/server/pages-get-initial-props.d.ts +54 -4
- package/dist/server/pages-get-initial-props.js +43 -1
- package/dist/server/pages-i18n.js +2 -2
- package/dist/server/pages-node-compat.js +2 -2
- package/dist/server/pages-page-data.d.ts +11 -2
- package/dist/server/pages-page-data.js +207 -34
- package/dist/server/pages-page-handler.d.ts +4 -2
- package/dist/server/pages-page-handler.js +62 -23
- package/dist/server/pages-page-response.d.ts +4 -1
- package/dist/server/pages-page-response.js +11 -8
- package/dist/server/pages-readiness.js +1 -1
- package/dist/server/pages-request-pipeline.d.ts +8 -7
- package/dist/server/pages-request-pipeline.js +126 -47
- package/dist/server/pregenerated-concrete-paths.d.ts +1 -17
- package/dist/server/pregenerated-concrete-paths.js +2 -19
- package/dist/server/prerender-manifest.d.ts +33 -0
- package/dist/server/prerender-manifest.js +54 -0
- package/dist/server/prerender-route-params.d.ts +1 -2
- package/dist/server/prod-server.d.ts +3 -1
- package/dist/server/prod-server.js +50 -13
- package/dist/server/request-pipeline.d.ts +3 -15
- package/dist/server/request-pipeline.js +58 -47
- package/dist/server/rsc-stream-hints.d.ts +5 -1
- package/dist/server/rsc-stream-hints.js +6 -1
- package/dist/server/seed-cache.js +10 -18
- package/dist/server/static-file-cache.js +16 -4
- package/dist/shims/app-router-scroll-state.d.ts +3 -1
- package/dist/shims/app-router-scroll-state.js +14 -2
- package/dist/shims/app-router-scroll.d.ts +3 -0
- package/dist/shims/app-router-scroll.js +28 -18
- package/dist/shims/before-interactive-context.d.ts +14 -3
- package/dist/shims/cache-runtime.js +3 -2
- package/dist/shims/cache.d.ts +1 -0
- package/dist/shims/cache.js +1 -1
- package/dist/shims/cdn-cache.d.ts +5 -5
- package/dist/shims/document.d.ts +15 -20
- package/dist/shims/document.js +5 -8
- package/dist/shims/dynamic-preload-chunks.js +6 -4
- package/dist/shims/error-boundary.d.ts +2 -0
- package/dist/shims/error-boundary.js +7 -0
- package/dist/shims/error.js +3 -2
- package/dist/shims/error.react-server.d.ts +9 -0
- package/dist/shims/error.react-server.js +6 -0
- package/dist/shims/fetch-cache.d.ts +3 -1
- package/dist/shims/fetch-cache.js +45 -20
- package/dist/shims/hash-scroll.js +6 -1
- package/dist/shims/headers.js +29 -4
- package/dist/shims/image.js +9 -2
- package/dist/shims/internal/als-registry.js +28 -1
- package/dist/shims/internal/app-route-detection.js +8 -17
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +31 -0
- package/dist/shims/internal/hybrid-client-route-owner.js +143 -0
- package/dist/shims/internal/navigation-untracked.d.ts +35 -0
- package/dist/shims/internal/navigation-untracked.js +55 -0
- package/dist/shims/internal/pages-data-fetch-dedup.d.ts +6 -7
- package/dist/shims/internal/pages-data-fetch-dedup.js +67 -14
- package/dist/shims/internal/pages-data-target.d.ts +7 -2
- package/dist/shims/internal/pages-data-target.js +17 -8
- package/dist/shims/internal/pages-router-accessor.d.ts +19 -0
- package/dist/shims/internal/pages-router-accessor.js +13 -0
- package/dist/shims/internal/router-context.d.ts +2 -1
- package/dist/shims/internal/router-context.js +3 -1
- package/dist/shims/link.js +47 -19
- package/dist/shims/metadata.js +4 -4
- package/dist/shims/navigation.d.ts +8 -2
- package/dist/shims/navigation.js +63 -31
- package/dist/shims/ppr-fallback-shell.d.ts +5 -1
- package/dist/shims/ppr-fallback-shell.js +28 -7
- package/dist/shims/router.d.ts +18 -3
- package/dist/shims/router.js +512 -142
- package/dist/shims/script.js +8 -4
- package/dist/shims/server.d.ts +16 -1
- package/dist/shims/server.js +44 -12
- package/dist/shims/unified-request-context.js +1 -0
- package/dist/utils/built-asset-url.d.ts +4 -0
- package/dist/utils/built-asset-url.js +11 -0
- package/dist/utils/commonjs-loader.d.ts +16 -0
- package/dist/utils/commonjs-loader.js +100 -0
- package/dist/utils/deployment-id.d.ts +8 -0
- package/dist/utils/deployment-id.js +22 -0
- package/dist/utils/has-trailing-comma.d.ts +24 -0
- package/dist/utils/has-trailing-comma.js +62 -0
- package/dist/utils/html-limited-bots.d.ts +18 -1
- package/dist/utils/html-limited-bots.js +23 -1
- package/dist/utils/parse-cookie.d.ts +13 -0
- package/dist/utils/parse-cookie.js +52 -0
- package/dist/utils/path.d.ts +7 -1
- package/dist/utils/path.js +9 -1
- package/dist/utils/text-stream.d.ts +1 -1
- package/dist/utils/text-stream.js +2 -2
- package/dist/utils/vite-version.d.ts +12 -1
- package/dist/utils/vite-version.js +9 -1
- package/package.json +2 -2
- package/dist/shims/internal/parse-cookie-header.d.ts +0 -14
- package/dist/shims/internal/parse-cookie-header.js +0 -30
|
@@ -42,6 +42,7 @@ const appRequestContextPath = resolveEntryPath("../server/app-request-context.js
|
|
|
42
42
|
const appRouteModuleLoaderPath = resolveEntryPath("../server/app-route-module-loader.js", import.meta.url);
|
|
43
43
|
const appPrerenderStaticParamsPath = resolveEntryPath("../server/app-prerender-static-params.js", import.meta.url);
|
|
44
44
|
const seedCachePath = resolveEntryPath("../server/seed-cache.js", import.meta.url);
|
|
45
|
+
const pregeneratedConcretePathsPath = resolveEntryPath("../server/pregenerated-concrete-paths.js", import.meta.url);
|
|
45
46
|
const appHookWarningSuppressionPath = resolveEntryPath("../server/app-hook-warning-suppression.js", import.meta.url);
|
|
46
47
|
const serverGlobalsPath = resolveEntryPath("../server/server-globals.js", import.meta.url);
|
|
47
48
|
const appPagesBridgePath = resolveEntryPath("../server/app-pages-bridge.js", import.meta.url);
|
|
@@ -72,6 +73,7 @@ function generateRscEntry(appDir, routes, middlewarePath, metadataRoutes, global
|
|
|
72
73
|
const reactMaxHeadersLength = config?.reactMaxHeadersLength ?? DEFAULT_REACT_MAX_HEADERS_LENGTH;
|
|
73
74
|
const cacheMaxMemorySize = config?.cacheMaxMemorySize;
|
|
74
75
|
const inlineCss = config?.inlineCss === true;
|
|
76
|
+
const cacheComponents = config?.cacheComponents === true;
|
|
75
77
|
const i18nConfig = config?.i18n ?? null;
|
|
76
78
|
const hasPagesDir = config?.hasPagesDir ?? false;
|
|
77
79
|
const publicFiles = config?.publicFiles ?? [];
|
|
@@ -98,9 +100,14 @@ import {
|
|
|
98
100
|
loadServerAction,
|
|
99
101
|
createTemporaryReferenceSet,
|
|
100
102
|
} from "@vitejs/plugin-rsc/rsc";
|
|
101
|
-
import {
|
|
103
|
+
import { createClientManifest as _createClientManifest } from "@vitejs/plugin-rsc/core/rsc";
|
|
104
|
+
import { prerender as _prerender } from "@vitejs/plugin-rsc/vendor/react-server-dom/static.edge";
|
|
105
|
+
import { createRscPrerenderer, createRscRenderer } from ${JSON.stringify(rscStreamHintsPath)};
|
|
102
106
|
|
|
103
107
|
const renderToReadableStream = createRscRenderer(_renderToReadableStream);
|
|
108
|
+
const prerenderToReadableStream = createRscPrerenderer(async (model, options) =>
|
|
109
|
+
_prerender(model, _createClientManifest(), options),
|
|
110
|
+
);
|
|
104
111
|
import { createElement } from "react";
|
|
105
112
|
import { getNavigationContext as _getNavigationContext } from "next/navigation";
|
|
106
113
|
import { configureMemoryCacheHandler as __configureMemoryCacheHandler } from "next/cache";
|
|
@@ -160,6 +167,7 @@ import {
|
|
|
160
167
|
import { makeThenableParams } from ${JSON.stringify(thenableParamsShimPath)};
|
|
161
168
|
import {
|
|
162
169
|
createAppRscRouteMatcher as __createAppRscRouteMatcher,
|
|
170
|
+
SIBLING_PAGE_INTERCEPT_SLOT_KEY as __SIBLING_PAGE_INTERCEPT_SLOT_KEY,
|
|
163
171
|
} from ${JSON.stringify(appRscRouteMatchingPath)};
|
|
164
172
|
import {
|
|
165
173
|
appIsrHtmlKey as __isrHtmlKey,
|
|
@@ -191,9 +199,15 @@ __configureMemoryCacheHandler({ cacheMaxMemorySize: ${JSON.stringify(cacheMaxMem
|
|
|
191
199
|
import { createAppPrerenderStaticParamsResolver as __createAppPrerenderStaticParamsResolver } from ${JSON.stringify(appPrerenderStaticParamsPath)};
|
|
192
200
|
import { ensureAppRouteModulesLoaded as __ensureRouteLoaded } from ${JSON.stringify(appRouteModuleLoaderPath)};
|
|
193
201
|
import { seedMemoryCacheFromPrerender as __seedMemoryCacheFromPrerender } from ${JSON.stringify(seedCachePath)};
|
|
202
|
+
import {
|
|
203
|
+
getRenderedConcreteUrlPathsForRoute as __getRenderedConcreteUrlPathsForRoute,
|
|
204
|
+
initPregeneratedPathsFromGlobals as __initPregeneratedPathsFromGlobals,
|
|
205
|
+
} from ${JSON.stringify(pregeneratedConcretePathsPath)};
|
|
194
206
|
|
|
195
207
|
const __draftModeSecret = ${JSON.stringify(draftModeSecret)};
|
|
196
208
|
|
|
209
|
+
__initPregeneratedPathsFromGlobals();
|
|
210
|
+
|
|
197
211
|
// Note: cache entries are written with \`headers: undefined\`. Next.js stores
|
|
198
212
|
// response headers (e.g. set-cookie from cookies().set() during render) in the
|
|
199
213
|
// cache entry so they can be replayed on HIT. We don't do this because:
|
|
@@ -228,6 +242,13 @@ function __resolveRouteFetchCacheMode(route) {
|
|
|
228
242
|
});
|
|
229
243
|
}
|
|
230
244
|
|
|
245
|
+
function __resolveRouteDynamicConfig(route) {
|
|
246
|
+
return __resolveAppPageSegmentConfig({
|
|
247
|
+
layouts: route.layouts,
|
|
248
|
+
page: route.page,
|
|
249
|
+
}).dynamicConfig ?? null;
|
|
250
|
+
}
|
|
251
|
+
|
|
231
252
|
function __resolveRouteRuntime(route) {
|
|
232
253
|
return __resolveAppPageSegmentConfig({
|
|
233
254
|
layouts: route.layouts,
|
|
@@ -371,6 +392,7 @@ const __i18nConfig = ${JSON.stringify(i18nConfig)};
|
|
|
371
392
|
const __configRedirects = ${JSON.stringify(redirects)};
|
|
372
393
|
const __configRewrites = ${JSON.stringify(rewrites)};
|
|
373
394
|
const __configHeaders = ${JSON.stringify(headers)};
|
|
395
|
+
const __imageConfig = ${JSON.stringify(config?.imageConfig)};
|
|
374
396
|
const __publicFiles = new Set(${JSON.stringify(publicFiles)});
|
|
375
397
|
const __allowedOrigins = ${JSON.stringify(allowedOrigins)};
|
|
376
398
|
const __expireTime = ${JSON.stringify(expireTime)};
|
|
@@ -383,6 +405,8 @@ const __reactMaxHeadersLength = ${JSON.stringify(reactMaxHeadersLength)};
|
|
|
383
405
|
export const __assetPrefix = ${JSON.stringify(assetPrefix)};
|
|
384
406
|
export const __inlineCss = ${JSON.stringify(inlineCss)};
|
|
385
407
|
export const __hasPagesDir = ${JSON.stringify(hasPagesDir)};
|
|
408
|
+
export const getRenderedConcreteUrlPathsForRoute = __getRenderedConcreteUrlPathsForRoute;
|
|
409
|
+
const __cacheComponents = ${JSON.stringify(cacheComponents)};
|
|
386
410
|
|
|
387
411
|
export function seedMemoryCacheFromPrerender(serverDir) {
|
|
388
412
|
return __seedMemoryCacheFromPrerender(serverDir, {
|
|
@@ -428,14 +452,18 @@ ${rootParamNameEntries.join("\n")}
|
|
|
428
452
|
|
|
429
453
|
export default __createAppRscHandler({
|
|
430
454
|
basePath: __basePath,
|
|
455
|
+
buildId: process.env.__VINEXT_BUILD_ID ?? null,
|
|
431
456
|
ensureRouteLoaded: __ensureRouteLoaded,
|
|
432
457
|
clearRequestContext() {
|
|
433
458
|
__clearRequestContext();
|
|
434
459
|
},
|
|
435
460
|
registerCacheAdapters: __registerConfiguredCacheAdapters,
|
|
436
461
|
configHeaders: __configHeaders,
|
|
462
|
+
cacheComponents: __cacheComponents,
|
|
437
463
|
configRedirects: __configRedirects,
|
|
438
464
|
configRewrites: __configRewrites,
|
|
465
|
+
imageConfig: __imageConfig,
|
|
466
|
+
isDev: process.env.NODE_ENV !== "production",
|
|
439
467
|
draftModeSecret: __draftModeSecret,
|
|
440
468
|
dispatchMatchedPage({
|
|
441
469
|
clientReuseManifest,
|
|
@@ -451,6 +479,10 @@ export default __createAppRscHandler({
|
|
|
451
479
|
middlewareContext,
|
|
452
480
|
mountedSlotsHeader,
|
|
453
481
|
params,
|
|
482
|
+
pprFallbackCacheShells,
|
|
483
|
+
pprFallbackShell,
|
|
484
|
+
renderedConcreteUrlPaths,
|
|
485
|
+
skipStaticParamsValidation,
|
|
454
486
|
staticParamsValidationParams,
|
|
455
487
|
rootParams,
|
|
456
488
|
request,
|
|
@@ -514,6 +546,7 @@ export default __createAppRscHandler({
|
|
|
514
546
|
getSourceRoute(sourceRouteIndex) {
|
|
515
547
|
return routes[sourceRouteIndex];
|
|
516
548
|
},
|
|
549
|
+
hasCustomGlobalError: ${globalErrorVar ? `Boolean(${globalErrorVar}?.default)` : "false"},
|
|
517
550
|
hasGenerateStaticParams: __generateStaticParams.length > 0,
|
|
518
551
|
hasPageDefaultExport: !!PageComponent,
|
|
519
552
|
hasPageModule: !!route.page,
|
|
@@ -538,6 +571,10 @@ export default __createAppRscHandler({
|
|
|
538
571
|
middlewareContext,
|
|
539
572
|
mountedSlotsHeader,
|
|
540
573
|
params,
|
|
574
|
+
pprFallbackCacheShells,
|
|
575
|
+
pprFallbackShell,
|
|
576
|
+
renderedConcreteUrlPaths,
|
|
577
|
+
skipStaticParamsValidation,
|
|
541
578
|
staticParamsValidationParams,
|
|
542
579
|
rootParams,
|
|
543
580
|
probeLayoutAt(li, layoutParamAccess) {
|
|
@@ -572,17 +609,33 @@ export default __createAppRscHandler({
|
|
|
572
609
|
}));
|
|
573
610
|
},
|
|
574
611
|
renderErrorBoundaryPage(renderErr) {
|
|
575
|
-
|
|
612
|
+
const __activeIntercept = findIntercept(cleanPathname, interceptionContext);
|
|
613
|
+
return __fallbackRenderer.renderErrorBoundary(route, renderErr, isRscRequest, request, params, scriptNonce, middlewareContext, {
|
|
614
|
+
isEdgeRuntime: __isEdgeRuntime(__segmentConfig.runtime),
|
|
615
|
+
sourcePageSegments: __activeIntercept?.slotKey === __SIBLING_PAGE_INTERCEPT_SLOT_KEY
|
|
616
|
+
? __activeIntercept.sourcePageSegments
|
|
617
|
+
: null,
|
|
618
|
+
});
|
|
576
619
|
},
|
|
577
620
|
renderHttpAccessFallbackPage(statusCode, opts, currentMiddlewareContext) {
|
|
578
|
-
|
|
621
|
+
const __activeIntercept = findIntercept(cleanPathname, interceptionContext);
|
|
622
|
+
return __fallbackRenderer.renderHttpAccessFallback(route, statusCode, isRscRequest, request, opts, scriptNonce, currentMiddlewareContext, {
|
|
623
|
+
isEdgeRuntime: __isEdgeRuntime(__segmentConfig.runtime),
|
|
624
|
+
sourcePageSegments: __activeIntercept?.slotKey === __SIBLING_PAGE_INTERCEPT_SLOT_KEY
|
|
625
|
+
? __activeIntercept.sourcePageSegments
|
|
626
|
+
: null,
|
|
627
|
+
});
|
|
579
628
|
},
|
|
580
629
|
renderToReadableStream,
|
|
630
|
+
prerenderToReadableStream,
|
|
581
631
|
request,
|
|
582
632
|
revalidateSeconds: __segmentConfig.revalidateSeconds,
|
|
583
633
|
resolveRouteFetchCacheMode(targetRoute) {
|
|
584
634
|
return __resolveRouteFetchCacheMode(targetRoute);
|
|
585
635
|
},
|
|
636
|
+
resolveRouteDynamicConfig(targetRoute) {
|
|
637
|
+
return __resolveRouteDynamicConfig(targetRoute);
|
|
638
|
+
},
|
|
586
639
|
rootForbiddenModule,
|
|
587
640
|
rootNotFoundModule,
|
|
588
641
|
rootUnauthorizedModule,
|
|
@@ -775,6 +828,12 @@ export default __createAppRscHandler({
|
|
|
775
828
|
readFormDataWithLimit: __readFormDataWithLimit,
|
|
776
829
|
renderToReadableStream,
|
|
777
830
|
reportRequestError: _reportRequestError,
|
|
831
|
+
resolveRouteFetchCacheMode(targetRoute) {
|
|
832
|
+
return __resolveRouteFetchCacheMode(targetRoute);
|
|
833
|
+
},
|
|
834
|
+
resolveRouteDynamicConfig(targetRoute) {
|
|
835
|
+
return __resolveRouteDynamicConfig(targetRoute);
|
|
836
|
+
},
|
|
778
837
|
resolveRouteRuntime: __resolveRouteRuntime,
|
|
779
838
|
request,
|
|
780
839
|
sanitizeErrorForClient(error) {
|
|
@@ -790,6 +849,7 @@ export default __createAppRscHandler({
|
|
|
790
849
|
interceptSlotId: intercept.slotId,
|
|
791
850
|
interceptSlotKey: intercept.slotKey,
|
|
792
851
|
interceptSourceMatchedUrl: interceptionContext,
|
|
852
|
+
interceptSourcePageSegments: intercept.sourcePageSegments,
|
|
793
853
|
interceptPage: intercept.page,
|
|
794
854
|
interceptParams: intercept.matchedParams,
|
|
795
855
|
};
|
|
@@ -808,9 +868,9 @@ export default __createAppRscHandler({
|
|
|
808
868
|
const __isEdge = route ? __isEdgeRuntime(__resolveAppPageSegmentConfig({ layouts: route.layouts, page: route.page }).runtime) : false;
|
|
809
869
|
return __fallbackRenderer.renderNotFound(route, isRscRequest, request, matchedParams, scriptNonce, middlewareContext, { isEdgeRuntime: __isEdge });
|
|
810
870
|
},
|
|
811
|
-
${hasPagesDir ? `async renderPagesFallback({ isRscRequest, middlewareContext, request, url }) {
|
|
871
|
+
${hasPagesDir ? `async renderPagesFallback({ allowRscDocumentFallback, appRouteMatch, isDataRequest, isRscRequest, matchKind, middlewareContext, pathname, pagesDataRequest, request, url }) {
|
|
812
872
|
return __renderPagesFallback(
|
|
813
|
-
{ isRscRequest, middlewareContext, request, url },
|
|
873
|
+
{ allowRscDocumentFallback, appRouteMatch, isDataRequest, isRscRequest, matchKind, middlewareContext, pathname, pagesDataRequest, request, url },
|
|
814
874
|
{
|
|
815
875
|
loadPagesEntry() {
|
|
816
876
|
return import.meta.viteRsc.loadModule("ssr", "index");
|
|
@@ -99,6 +99,7 @@ function buildRouteEntries(routes, imports) {
|
|
|
99
99
|
convention: ${JSON.stringify(ir.convention)},
|
|
100
100
|
targetPattern: ${JSON.stringify(ir.targetPattern)},
|
|
101
101
|
sourceMatchPattern: ${JSON.stringify(ir.sourceMatchPattern)},
|
|
102
|
+
sourcePageSegments: ${JSON.stringify(ir.sourcePageSegments)},
|
|
102
103
|
slotId: ${JSON.stringify(ir.slotId ?? null)},
|
|
103
104
|
interceptLayouts: [${ir.layoutPaths.map((l) => imports.getImportVar(l)).join(", ")}],
|
|
104
105
|
page: null,
|
|
@@ -110,6 +111,7 @@ function buildRouteEntries(routes, imports) {
|
|
|
110
111
|
convention: ${JSON.stringify(ir.convention)},
|
|
111
112
|
targetPattern: ${JSON.stringify(ir.targetPattern)},
|
|
112
113
|
sourceMatchPattern: ${JSON.stringify(ir.sourceMatchPattern)},
|
|
114
|
+
sourcePageSegments: ${JSON.stringify(ir.sourcePageSegments)},
|
|
113
115
|
interceptLayouts: [${ir.layoutPaths.map((layoutPath) => imports.getImportVar(layoutPath)).join(", ")}],
|
|
114
116
|
page: null,
|
|
115
117
|
__pageLoader: ${imports.getLazyLoaderVar(ir.pagePath)},
|
|
@@ -17,7 +17,7 @@ function generateSsrEntry(hasPagesDir = false) {
|
|
|
17
17
|
export * from ${JSON.stringify(entryPath)};
|
|
18
18
|
export { default } from ${JSON.stringify(entryPath)};
|
|
19
19
|
${hasPagesDir ? `
|
|
20
|
-
export { handleApiRoute, pageRoutes, renderPage } from "virtual:vinext-server-entry";
|
|
20
|
+
export { handleApiRoute, matchApiRoute, matchPageRoute, pageRoutes, renderPage } from "virtual:vinext-server-entry";
|
|
21
21
|
` : ""}`;
|
|
22
22
|
}
|
|
23
23
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalizePathSeparators } from "../utils/path.js";
|
|
2
2
|
import { findFileWithExts } from "../routing/file-matcher.js";
|
|
3
3
|
import { patternToNextFormat } from "../routing/route-validation.js";
|
|
4
|
-
import { pagesRouter } from "../routing/pages-router.js";
|
|
4
|
+
import { apiRouter, pagesRouter } from "../routing/pages-router.js";
|
|
5
5
|
//#region src/entries/pages-client-entry.ts
|
|
6
6
|
/**
|
|
7
7
|
* Pages Router client hydration entry generator.
|
|
@@ -14,11 +14,31 @@ import { pagesRouter } from "../routing/pages-router.js";
|
|
|
14
14
|
*
|
|
15
15
|
* Extracted from index.ts.
|
|
16
16
|
*/
|
|
17
|
+
/**
|
|
18
|
+
* Project a Pages `Route` down to the public `VinextPagesLinkPrefetchRoute`
|
|
19
|
+
* shape used for client-side hybrid ownership decisions. Mirrors
|
|
20
|
+
* `toLinkPrefetchRoute` in `app-browser-entry.ts`.
|
|
21
|
+
*
|
|
22
|
+
* Lives here (not in `routing/pages-router.ts`) so the routing module
|
|
23
|
+
* stays free of `vitext/client` type imports.
|
|
24
|
+
*/
|
|
25
|
+
function toPagesLinkPrefetchRoute(route) {
|
|
26
|
+
return {
|
|
27
|
+
canPrefetchLoadingShell: false,
|
|
28
|
+
isDynamic: route.isDynamic,
|
|
29
|
+
patternParts: [...route.patternParts]
|
|
30
|
+
};
|
|
31
|
+
}
|
|
17
32
|
async function generateClientEntry(pagesDir, nextConfig, fileMatcher, options = {}) {
|
|
18
33
|
const pageRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
34
|
+
const apiRoutes = await apiRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
19
35
|
const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
|
|
20
36
|
const hasApp = appFilePath !== null;
|
|
21
37
|
const appPrefetchRoutes = options.appPrefetchRoutes ?? [];
|
|
38
|
+
const pagesPrefetchRoutes = [...pageRoutes.map(toPagesLinkPrefetchRoute), ...apiRoutes.map((route) => ({
|
|
39
|
+
...toPagesLinkPrefetchRoute(route),
|
|
40
|
+
documentOnly: true
|
|
41
|
+
}))];
|
|
22
42
|
const instrumentationClientPath = options.instrumentationClientPath ?? null;
|
|
23
43
|
const loaderEntries = pageRoutes.map((r) => {
|
|
24
44
|
const absPath = normalizePathSeparators(r.filePath);
|
|
@@ -30,20 +50,10 @@ async function generateClientEntry(pagesDir, nextConfig, fileMatcher, options =
|
|
|
30
50
|
import "vinext/instrumentation-client";
|
|
31
51
|
import React from "react";
|
|
32
52
|
import { hydrateRoot } from "react-dom/client";
|
|
33
|
-
import {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// hydrate() resolves (see .nextjs-ref/packages/next/src/client/next.ts
|
|
38
|
-
// line 13, which also sets window.next as a top-level side effect),
|
|
39
|
-
// and (b) the popstate handler is registered before
|
|
40
|
-
// installPagesRouterRuntime() runs, removing the race window where a
|
|
41
|
-
// popstate event could fire between hydration and runtime install.
|
|
42
|
-
//
|
|
43
|
-
// Mirrors Next.js's bootstrap order: client/next.ts statically imports
|
|
44
|
-
// from './' before calling initialize/hydrate, so window.next is set up
|
|
45
|
-
// before any async work.
|
|
46
|
-
import { wrapWithRouterContext } from "next/router";
|
|
53
|
+
import Router, {
|
|
54
|
+
wrapWithRouterContext,
|
|
55
|
+
_initializePagesRouterReadyFromNextData,
|
|
56
|
+
} from "next/router";
|
|
47
57
|
|
|
48
58
|
const pageLoaders = {
|
|
49
59
|
${loaderEntries.join(",\n")}
|
|
@@ -64,7 +74,7 @@ const appLoader = undefined;
|
|
|
64
74
|
// Object.keys(pageLoaders), exposed separately so navigateClient() can iterate
|
|
65
75
|
// it without re-keying the map. Ordering is the insertion order of pageRoutes,
|
|
66
76
|
// which pagesRouter() has already sorted by specificity (static → dynamic →
|
|
67
|
-
// catch-all → optional catch-all) via
|
|
77
|
+
// catch-all → optional catch-all) via sortRoutes — so matchPagesPattern()
|
|
68
78
|
// can iterate in order and trust the first match.
|
|
69
79
|
window.__VINEXT_PAGE_LOADERS__ = pageLoaders;
|
|
70
80
|
window.__VINEXT_PAGE_PATTERNS__ = Object.keys(pageLoaders);
|
|
@@ -84,6 +94,20 @@ window.__VINEXT_APP_LOADER__ = appLoader;
|
|
|
84
94
|
// when the user lands on an App Router page (see app-browser-entry.ts) — the
|
|
85
95
|
// two writes do not race because only one entry executes per page load.
|
|
86
96
|
window.__VINEXT_LINK_PREFETCH_ROUTES__ = ${JSON.stringify(appPrefetchRoutes)};
|
|
97
|
+
// Pages route manifest, exposed so the App Router runtime can decide when
|
|
98
|
+
// a soft-navigated URL is actually owned by Pages (and must hard-navigate
|
|
99
|
+
// instead of issuing an RSC request). Set here AND in app-browser-entry.ts
|
|
100
|
+
// so whichever entry runs first emits the Pages manifest.
|
|
101
|
+
window.__VINEXT_PAGES_LINK_PREFETCH_ROUTES__ = ${JSON.stringify(pagesPrefetchRoutes)};
|
|
102
|
+
window.__VINEXT_CLIENT_REWRITES__ = ${JSON.stringify(nextConfig.rewrites)};
|
|
103
|
+
|
|
104
|
+
const nextDataElement = document.getElementById("__NEXT_DATA__");
|
|
105
|
+
if (nextDataElement?.textContent) {
|
|
106
|
+
window.__NEXT_DATA__ = JSON.parse(nextDataElement.textContent);
|
|
107
|
+
window.__VINEXT_LOCALE__ = window.__NEXT_DATA__.locale;
|
|
108
|
+
window.__VINEXT_LOCALES__ = window.__NEXT_DATA__.locales;
|
|
109
|
+
window.__VINEXT_DEFAULT_LOCALE__ = window.__NEXT_DATA__.defaultLocale;
|
|
110
|
+
}
|
|
87
111
|
|
|
88
112
|
async function hydrate() {
|
|
89
113
|
const nextData = window.__NEXT_DATA__;
|
|
@@ -92,6 +116,8 @@ async function hydrate() {
|
|
|
92
116
|
return;
|
|
93
117
|
}
|
|
94
118
|
|
|
119
|
+
_initializePagesRouterReadyFromNextData(nextData);
|
|
120
|
+
|
|
95
121
|
let hydrateRootOptions;
|
|
96
122
|
if (import.meta.env.DEV) {
|
|
97
123
|
const overlay = await import("vinext/dev-error-overlay");
|
|
@@ -104,7 +130,9 @@ async function hydrate() {
|
|
|
104
130
|
};
|
|
105
131
|
}
|
|
106
132
|
|
|
107
|
-
const
|
|
133
|
+
const props = nextData.props && typeof nextData.props === "object" ? nextData.props : {};
|
|
134
|
+
const rawPageProps = props.pageProps;
|
|
135
|
+
const pageProps = rawPageProps && typeof rawPageProps === "object" ? rawPageProps : {};
|
|
108
136
|
const loader = pageLoaders[nextData.page];
|
|
109
137
|
if (!loader) {
|
|
110
138
|
console.error("[vinext] No page loader for route:", nextData.page);
|
|
@@ -124,7 +152,12 @@ async function hydrate() {
|
|
|
124
152
|
const appModule = await appLoader();
|
|
125
153
|
const AppComponent = appModule.default;
|
|
126
154
|
window.__VINEXT_APP__ = AppComponent;
|
|
127
|
-
element = React.createElement(AppComponent, {
|
|
155
|
+
element = React.createElement(AppComponent, {
|
|
156
|
+
...props,
|
|
157
|
+
Component: PageComponent,
|
|
158
|
+
pageProps: rawPageProps,
|
|
159
|
+
router: Router,
|
|
160
|
+
});
|
|
128
161
|
} catch {
|
|
129
162
|
element = React.createElement(PageComponent, pageProps);
|
|
130
163
|
}
|
|
@@ -132,8 +165,13 @@ async function hydrate() {
|
|
|
132
165
|
element = React.createElement(PageComponent, pageProps);
|
|
133
166
|
`}
|
|
134
167
|
|
|
168
|
+
let resolveHydrationCommit;
|
|
169
|
+
const hydrationCommitted = new Promise((resolve) => {
|
|
170
|
+
resolveHydrationCommit = resolve;
|
|
171
|
+
});
|
|
172
|
+
|
|
135
173
|
// Wrap with RouterContext.Provider so next/router and next/compat/router work during hydration.
|
|
136
|
-
element = wrapWithRouterContext(element);
|
|
174
|
+
element = wrapWithRouterContext(element, resolveHydrationCommit);
|
|
137
175
|
|
|
138
176
|
const container = document.getElementById("__next");
|
|
139
177
|
if (!container) {
|
|
@@ -143,12 +181,20 @@ async function hydrate() {
|
|
|
143
181
|
|
|
144
182
|
const root = hydrateRoot(container, element, hydrateRootOptions);
|
|
145
183
|
window.__VINEXT_ROOT__ = root;
|
|
146
|
-
|
|
184
|
+
await hydrationCommitted;
|
|
147
185
|
const hydratedAt = performance.now();
|
|
148
186
|
window.__VINEXT_HYDRATED_AT = hydratedAt;
|
|
149
187
|
window.__NEXT_HYDRATED = true;
|
|
150
188
|
window.__NEXT_HYDRATED_AT = hydratedAt;
|
|
151
189
|
window.__NEXT_HYDRATED_CB?.();
|
|
190
|
+
|
|
191
|
+
if (nextData.isFallback) {
|
|
192
|
+
await Router.replace(
|
|
193
|
+
window.location.pathname + window.location.search + window.location.hash,
|
|
194
|
+
undefined,
|
|
195
|
+
{ _h: 1, scroll: false },
|
|
196
|
+
);
|
|
197
|
+
}
|
|
152
198
|
}
|
|
153
199
|
|
|
154
200
|
hydrate();
|
|
@@ -71,12 +71,14 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
|
|
|
71
71
|
headers: nextConfig?.headers ?? [],
|
|
72
72
|
expireTime: nextConfig?.expireTime,
|
|
73
73
|
cacheMaxMemorySize: nextConfig?.cacheMaxMemorySize,
|
|
74
|
+
htmlLimitedBots: nextConfig?.htmlLimitedBots,
|
|
74
75
|
i18n: nextConfig?.i18n ?? null,
|
|
75
76
|
disableOptimizedLoading: nextConfig?.disableOptimizedLoading === true,
|
|
76
77
|
clientTraceMetadata: nextConfig?.clientTraceMetadata,
|
|
77
78
|
images: {
|
|
78
79
|
deviceSizes: nextConfig?.images?.deviceSizes,
|
|
79
80
|
imageSizes: nextConfig?.images?.imageSizes,
|
|
81
|
+
qualities: nextConfig?.images?.qualities,
|
|
80
82
|
dangerouslyAllowSVG: nextConfig?.images?.dangerouslyAllowSVG,
|
|
81
83
|
dangerouslyAllowLocalIP: nextConfig?.images?.dangerouslyAllowLocalIP,
|
|
82
84
|
contentDispositionType: nextConfig?.images?.contentDispositionType,
|
|
@@ -98,42 +100,19 @@ if (typeof _instrumentation.onRequestError === "function") {
|
|
|
98
100
|
const middlewareImportCode = middlewarePath ? `import * as middlewareModule from ${JSON.stringify(normalizePathSeparators(middlewarePath))};` : "";
|
|
99
101
|
const middlewareExportCode = middlewarePath ? `
|
|
100
102
|
export async function runMiddleware(request, ctx, options) {
|
|
101
|
-
|
|
102
|
-
// worker entries don't need to know about the data endpoint protocol.
|
|
103
|
-
// Mismatched buildId → JSON 404 short-circuit. Matched → middleware sees
|
|
104
|
-
// the normalized page path via the request URL, and the worker sees the
|
|
105
|
-
// normalized URL via result.rewriteUrl (if middleware didn't already
|
|
106
|
-
// rewrite to something else).
|
|
107
|
-
const __dataNorm = __normalizePagesDataRequest(request, buildId);
|
|
108
|
-
if (__dataNorm.notFoundResponse) {
|
|
109
|
-
return { continue: false, response: __dataNorm.notFoundResponse };
|
|
110
|
-
}
|
|
111
|
-
const __result = await __runGeneratedMiddleware({
|
|
103
|
+
return __runGeneratedMiddleware({
|
|
112
104
|
basePath: vinextConfig.basePath,
|
|
113
105
|
ctx,
|
|
114
106
|
i18nConfig,
|
|
115
|
-
isDataRequest: options?.isDataRequest === true
|
|
107
|
+
isDataRequest: options?.isDataRequest === true,
|
|
116
108
|
isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},
|
|
117
109
|
module: middlewareModule,
|
|
118
|
-
request
|
|
110
|
+
request,
|
|
119
111
|
trailingSlash: vinextConfig.trailingSlash,
|
|
120
112
|
});
|
|
121
|
-
if (__dataNorm.isDataReq && __result.continue && !__result.rewriteUrl && !__result.redirectUrl) {
|
|
122
|
-
return { ...__result, rewriteUrl: __dataNorm.normalizedPathname + __dataNorm.search };
|
|
123
|
-
}
|
|
124
|
-
return __result;
|
|
125
113
|
}
|
|
126
114
|
` : `
|
|
127
115
|
export async function runMiddleware(request) {
|
|
128
|
-
// Even without user middleware, the data-endpoint URL must be normalized so
|
|
129
|
-
// the worker pipeline sees the page path. Mismatched buildId → JSON 404.
|
|
130
|
-
const __dataNorm = __normalizePagesDataRequest(request, buildId);
|
|
131
|
-
if (__dataNorm.notFoundResponse) {
|
|
132
|
-
return { continue: false, response: __dataNorm.notFoundResponse };
|
|
133
|
-
}
|
|
134
|
-
if (__dataNorm.isDataReq) {
|
|
135
|
-
return { continue: true, rewriteUrl: __dataNorm.normalizedPathname + __dataNorm.search };
|
|
136
|
-
}
|
|
137
116
|
return { continue: true };
|
|
138
117
|
}
|
|
139
118
|
`;
|
|
@@ -143,7 +122,7 @@ import React from "react";
|
|
|
143
122
|
import { renderToReadableStream } from "react-dom/server.edge";
|
|
144
123
|
import { resetSSRHead, getSSRHeadHTML, setDocumentInitialHead } from "next/head";
|
|
145
124
|
import { flushPreloads } from "next/dynamic";
|
|
146
|
-
import { setSSRContext, wrapWithRouterContext, getPagesNavigationIsReadyFromSerializedState } from "next/router";
|
|
125
|
+
import Router, { setSSRContext, wrapWithRouterContext, getPagesNavigationIsReadyFromSerializedState } from "next/router";
|
|
147
126
|
import { _runWithCacheState, configureMemoryCacheHandler as __configureMemoryCacheHandler } from "next/cache";
|
|
148
127
|
import { registerConfiguredCacheAdapters as __registerConfiguredCacheAdapters } from "virtual:vinext-cache-adapters";
|
|
149
128
|
import { runWithPrivateCache } from "vinext/cache-runtime";
|
|
@@ -179,6 +158,9 @@ const i18nConfig = ${i18nConfigJson};
|
|
|
179
158
|
// match _next/data requests against the embedded buildId without needing
|
|
180
159
|
// to load next.config.js at runtime.
|
|
181
160
|
export const buildId = ${buildIdJson};
|
|
161
|
+
export function normalizeDataRequest(request) {
|
|
162
|
+
return __normalizePagesDataRequest(request, buildId);
|
|
163
|
+
}
|
|
182
164
|
const __hasMiddleware = ${JSON.stringify(Boolean(middlewarePath))};
|
|
183
165
|
|
|
184
166
|
// Full resolved config for production server (embedded at build time)
|
|
@@ -267,6 +249,20 @@ export function matchPageRoute(url, request) {
|
|
|
267
249
|
return matchRoute(routeUrl, pageRoutes);
|
|
268
250
|
}
|
|
269
251
|
|
|
252
|
+
export function matchApiRoute(url, request) {
|
|
253
|
+
const routeUrl = i18nConfig && request
|
|
254
|
+
? resolvePagesI18nRequest(
|
|
255
|
+
url,
|
|
256
|
+
i18nConfig,
|
|
257
|
+
request.headers,
|
|
258
|
+
new URL(request.url).hostname,
|
|
259
|
+
vinextConfig.basePath,
|
|
260
|
+
vinextConfig.trailingSlash,
|
|
261
|
+
).url
|
|
262
|
+
: url;
|
|
263
|
+
return matchRoute(routeUrl, apiRoutes);
|
|
264
|
+
}
|
|
265
|
+
|
|
270
266
|
// ── Pages render orchestrator — delegates to server/pages-page-handler.ts ──
|
|
271
267
|
//
|
|
272
268
|
// All next/*-derived values are passed as closures so the handler module
|
|
@@ -282,6 +278,7 @@ const _renderPage = __createPagesPageHandler({
|
|
|
282
278
|
assetPrefix: vinextConfig.assetPrefix,
|
|
283
279
|
trailingSlash: vinextConfig.trailingSlash,
|
|
284
280
|
expireTime: vinextConfig.expireTime,
|
|
281
|
+
htmlLimitedBots: vinextConfig.htmlLimitedBots,
|
|
285
282
|
clientTraceMetadata: vinextConfig.clientTraceMetadata,
|
|
286
283
|
disableOptimizedLoading: vinextConfig.disableOptimizedLoading,
|
|
287
284
|
},
|
|
@@ -328,18 +325,36 @@ const _renderPage = __createPagesPageHandler({
|
|
|
328
325
|
renderIsrPassToStringAsync: _renderIsrPassToStringAsync,
|
|
329
326
|
safeJsonStringify,
|
|
330
327
|
sanitizeDestination: sanitizeDestinationLocal,
|
|
331
|
-
createPageElement(PageComponent, AppComponent,
|
|
328
|
+
createPageElement(PageComponent, AppComponent, props) {
|
|
329
|
+
const rawPageProps = props?.pageProps;
|
|
330
|
+
const pageProps = rawPageProps && typeof rawPageProps === "object"
|
|
331
|
+
? props.pageProps
|
|
332
|
+
: {};
|
|
332
333
|
return AppComponent
|
|
333
|
-
? React.createElement(AppComponent, {
|
|
334
|
+
? React.createElement(AppComponent, {
|
|
335
|
+
...props,
|
|
336
|
+
Component: PageComponent,
|
|
337
|
+
pageProps: rawPageProps,
|
|
338
|
+
router: Router,
|
|
339
|
+
})
|
|
334
340
|
: React.createElement(PageComponent, pageProps);
|
|
335
341
|
},
|
|
336
|
-
enhancePageElement(PageComponent, AppComponent,
|
|
342
|
+
enhancePageElement(PageComponent, AppComponent, props, opts) {
|
|
343
|
+
const rawPageProps = props?.pageProps;
|
|
344
|
+
const pageProps = rawPageProps && typeof rawPageProps === "object"
|
|
345
|
+
? props.pageProps
|
|
346
|
+
: {};
|
|
337
347
|
let FinalApp = AppComponent;
|
|
338
348
|
let FinalComp = PageComponent;
|
|
339
349
|
if (opts && typeof opts.enhanceApp === "function" && FinalApp) FinalApp = opts.enhanceApp(FinalApp);
|
|
340
350
|
if (opts && typeof opts.enhanceComponent === "function") FinalComp = opts.enhanceComponent(FinalComp);
|
|
341
351
|
return FinalApp
|
|
342
|
-
? React.createElement(FinalApp, {
|
|
352
|
+
? React.createElement(FinalApp, {
|
|
353
|
+
...props,
|
|
354
|
+
Component: FinalComp,
|
|
355
|
+
pageProps: rawPageProps,
|
|
356
|
+
router: Router,
|
|
357
|
+
})
|
|
343
358
|
: React.createElement(FinalComp, pageProps);
|
|
344
359
|
},
|
|
345
360
|
AppComponent,
|
|
@@ -360,6 +375,7 @@ export async function handleApiRoute(request, url, ctx) {
|
|
|
360
375
|
return __handlePagesApiRoute({
|
|
361
376
|
ctx,
|
|
362
377
|
match,
|
|
378
|
+
nextConfig: vinextConfig,
|
|
363
379
|
request,
|
|
364
380
|
url,
|
|
365
381
|
reportRequestError(error, routePattern) {
|