vinext 0.1.2 → 0.1.3
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/prerender.d.ts +9 -1
- package/dist/build/prerender.js +41 -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/vinext-next-data.d.ts +18 -1
- 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.js +73 -14
- package/dist/config/next-config.d.ts +46 -4
- package/dist/config/next-config.js +147 -48
- package/dist/deploy.d.ts +30 -11
- package/dist/deploy.js +180 -99
- 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 +64 -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 +53 -8
- package/dist/entries/pages-server-entry.js +41 -5
- package/dist/index.js +200 -62
- package/dist/plugins/extensionless-dynamic-import.d.ts +6 -0
- package/dist/plugins/extensionless-dynamic-import.js +152 -0
- 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/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 +44 -14
- 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 +19 -10
- package/dist/server/app-browser-entry.js +167 -90
- 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 +4 -2
- 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-stream.js +86 -43
- 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 +18 -0
- package/dist/server/app-pages-bridge.js +22 -5
- 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 +25 -0
- package/dist/server/app-rsc-handler.js +154 -54
- package/dist/server/app-rsc-route-matching.d.ts +3 -0
- package/dist/server/app-rsc-route-matching.js +2 -0
- 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 +42 -13
- package/dist/server/app-ssr-entry.d.ts +2 -0
- package/dist/server/app-ssr-entry.js +83 -10
- package/dist/server/cache-control.js +4 -0
- package/dist/server/dev-server.d.ts +2 -2
- package/dist/server/dev-server.js +244 -51
- 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/navigation-planner.d.ts +133 -30
- package/dist/server/navigation-planner.js +114 -0
- package/dist/server/navigation-trace.d.ts +8 -1
- package/dist/server/navigation-trace.js +8 -1
- 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 +8 -1
- package/dist/server/pages-data-route.js +11 -2
- 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-node-compat.js +2 -2
- package/dist/server/pages-page-data.d.ts +11 -2
- package/dist/server/pages-page-data.js +204 -33
- package/dist/server/pages-page-handler.d.ts +4 -2
- package/dist/server/pages-page-handler.js +59 -22
- package/dist/server/pages-page-response.d.ts +2 -1
- package/dist/server/pages-page-response.js +7 -4
- package/dist/server/pages-request-pipeline.d.ts +1 -0
- package/dist/server/pages-request-pipeline.js +73 -36
- 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.js +9 -3
- 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/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/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/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/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-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 +12 -5
- package/dist/shims/navigation.d.ts +8 -2
- package/dist/shims/navigation.js +61 -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 +13 -2
- package/dist/shims/router.js +419 -128
- 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/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/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, {
|
|
@@ -434,8 +458,11 @@ export default __createAppRscHandler({
|
|
|
434
458
|
},
|
|
435
459
|
registerCacheAdapters: __registerConfiguredCacheAdapters,
|
|
436
460
|
configHeaders: __configHeaders,
|
|
461
|
+
cacheComponents: __cacheComponents,
|
|
437
462
|
configRedirects: __configRedirects,
|
|
438
463
|
configRewrites: __configRewrites,
|
|
464
|
+
imageConfig: __imageConfig,
|
|
465
|
+
isDev: process.env.NODE_ENV !== "production",
|
|
439
466
|
draftModeSecret: __draftModeSecret,
|
|
440
467
|
dispatchMatchedPage({
|
|
441
468
|
clientReuseManifest,
|
|
@@ -451,6 +478,10 @@ export default __createAppRscHandler({
|
|
|
451
478
|
middlewareContext,
|
|
452
479
|
mountedSlotsHeader,
|
|
453
480
|
params,
|
|
481
|
+
pprFallbackCacheShells,
|
|
482
|
+
pprFallbackShell,
|
|
483
|
+
renderedConcreteUrlPaths,
|
|
484
|
+
skipStaticParamsValidation,
|
|
454
485
|
staticParamsValidationParams,
|
|
455
486
|
rootParams,
|
|
456
487
|
request,
|
|
@@ -514,6 +545,7 @@ export default __createAppRscHandler({
|
|
|
514
545
|
getSourceRoute(sourceRouteIndex) {
|
|
515
546
|
return routes[sourceRouteIndex];
|
|
516
547
|
},
|
|
548
|
+
hasCustomGlobalError: ${globalErrorVar ? `Boolean(${globalErrorVar}?.default)` : "false"},
|
|
517
549
|
hasGenerateStaticParams: __generateStaticParams.length > 0,
|
|
518
550
|
hasPageDefaultExport: !!PageComponent,
|
|
519
551
|
hasPageModule: !!route.page,
|
|
@@ -538,6 +570,10 @@ export default __createAppRscHandler({
|
|
|
538
570
|
middlewareContext,
|
|
539
571
|
mountedSlotsHeader,
|
|
540
572
|
params,
|
|
573
|
+
pprFallbackCacheShells,
|
|
574
|
+
pprFallbackShell,
|
|
575
|
+
renderedConcreteUrlPaths,
|
|
576
|
+
skipStaticParamsValidation,
|
|
541
577
|
staticParamsValidationParams,
|
|
542
578
|
rootParams,
|
|
543
579
|
probeLayoutAt(li, layoutParamAccess) {
|
|
@@ -572,17 +608,33 @@ export default __createAppRscHandler({
|
|
|
572
608
|
}));
|
|
573
609
|
},
|
|
574
610
|
renderErrorBoundaryPage(renderErr) {
|
|
575
|
-
|
|
611
|
+
const __activeIntercept = findIntercept(cleanPathname, interceptionContext);
|
|
612
|
+
return __fallbackRenderer.renderErrorBoundary(route, renderErr, isRscRequest, request, params, scriptNonce, middlewareContext, {
|
|
613
|
+
isEdgeRuntime: __isEdgeRuntime(__segmentConfig.runtime),
|
|
614
|
+
sourcePageSegments: __activeIntercept?.slotKey === __SIBLING_PAGE_INTERCEPT_SLOT_KEY
|
|
615
|
+
? __activeIntercept.sourcePageSegments
|
|
616
|
+
: null,
|
|
617
|
+
});
|
|
576
618
|
},
|
|
577
619
|
renderHttpAccessFallbackPage(statusCode, opts, currentMiddlewareContext) {
|
|
578
|
-
|
|
620
|
+
const __activeIntercept = findIntercept(cleanPathname, interceptionContext);
|
|
621
|
+
return __fallbackRenderer.renderHttpAccessFallback(route, statusCode, isRscRequest, request, opts, scriptNonce, currentMiddlewareContext, {
|
|
622
|
+
isEdgeRuntime: __isEdgeRuntime(__segmentConfig.runtime),
|
|
623
|
+
sourcePageSegments: __activeIntercept?.slotKey === __SIBLING_PAGE_INTERCEPT_SLOT_KEY
|
|
624
|
+
? __activeIntercept.sourcePageSegments
|
|
625
|
+
: null,
|
|
626
|
+
});
|
|
579
627
|
},
|
|
580
628
|
renderToReadableStream,
|
|
629
|
+
prerenderToReadableStream,
|
|
581
630
|
request,
|
|
582
631
|
revalidateSeconds: __segmentConfig.revalidateSeconds,
|
|
583
632
|
resolveRouteFetchCacheMode(targetRoute) {
|
|
584
633
|
return __resolveRouteFetchCacheMode(targetRoute);
|
|
585
634
|
},
|
|
635
|
+
resolveRouteDynamicConfig(targetRoute) {
|
|
636
|
+
return __resolveRouteDynamicConfig(targetRoute);
|
|
637
|
+
},
|
|
586
638
|
rootForbiddenModule,
|
|
587
639
|
rootNotFoundModule,
|
|
588
640
|
rootUnauthorizedModule,
|
|
@@ -775,6 +827,12 @@ export default __createAppRscHandler({
|
|
|
775
827
|
readFormDataWithLimit: __readFormDataWithLimit,
|
|
776
828
|
renderToReadableStream,
|
|
777
829
|
reportRequestError: _reportRequestError,
|
|
830
|
+
resolveRouteFetchCacheMode(targetRoute) {
|
|
831
|
+
return __resolveRouteFetchCacheMode(targetRoute);
|
|
832
|
+
},
|
|
833
|
+
resolveRouteDynamicConfig(targetRoute) {
|
|
834
|
+
return __resolveRouteDynamicConfig(targetRoute);
|
|
835
|
+
},
|
|
778
836
|
resolveRouteRuntime: __resolveRouteRuntime,
|
|
779
837
|
request,
|
|
780
838
|
sanitizeErrorForClient(error) {
|
|
@@ -790,6 +848,7 @@ export default __createAppRscHandler({
|
|
|
790
848
|
interceptSlotId: intercept.slotId,
|
|
791
849
|
interceptSlotKey: intercept.slotKey,
|
|
792
850
|
interceptSourceMatchedUrl: interceptionContext,
|
|
851
|
+
interceptSourcePageSegments: intercept.sourcePageSegments,
|
|
793
852
|
interceptPage: intercept.page,
|
|
794
853
|
interceptParams: intercept.matchedParams,
|
|
795
854
|
};
|
|
@@ -808,9 +867,9 @@ export default __createAppRscHandler({
|
|
|
808
867
|
const __isEdge = route ? __isEdgeRuntime(__resolveAppPageSegmentConfig({ layouts: route.layouts, page: route.page }).runtime) : false;
|
|
809
868
|
return __fallbackRenderer.renderNotFound(route, isRscRequest, request, matchedParams, scriptNonce, middlewareContext, { isEdgeRuntime: __isEdge });
|
|
810
869
|
},
|
|
811
|
-
${hasPagesDir ? `async renderPagesFallback({ isRscRequest, middlewareContext, request, url }) {
|
|
870
|
+
${hasPagesDir ? `async renderPagesFallback({ allowRscDocumentFallback, appRouteMatch, isRscRequest, matchKind, middlewareContext, pathname, request, url }) {
|
|
812
871
|
return __renderPagesFallback(
|
|
813
|
-
{ isRscRequest, middlewareContext, request, url },
|
|
872
|
+
{ allowRscDocumentFallback, appRouteMatch, isRscRequest, matchKind, middlewareContext, pathname, request, url },
|
|
814
873
|
{
|
|
815
874
|
loadPagesEntry() {
|
|
816
875
|
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,7 +50,6 @@ 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 { installPagesRouterRuntime } from "vinext/pages-router-runtime";
|
|
34
53
|
// Statically import next/router as the very first vinext shim so that
|
|
35
54
|
// (a) installWindowNext runs at top-level — \`window.next.router\` is
|
|
36
55
|
// available to test harnesses and third-party scripts BEFORE
|
|
@@ -43,7 +62,7 @@ import { installPagesRouterRuntime } from "vinext/pages-router-runtime";
|
|
|
43
62
|
// Mirrors Next.js's bootstrap order: client/next.ts statically imports
|
|
44
63
|
// from './' before calling initialize/hydrate, so window.next is set up
|
|
45
64
|
// before any async work.
|
|
46
|
-
import { wrapWithRouterContext } from "next/router";
|
|
65
|
+
import Router, { wrapWithRouterContext } from "next/router";
|
|
47
66
|
|
|
48
67
|
const pageLoaders = {
|
|
49
68
|
${loaderEntries.join(",\n")}
|
|
@@ -64,7 +83,7 @@ const appLoader = undefined;
|
|
|
64
83
|
// Object.keys(pageLoaders), exposed separately so navigateClient() can iterate
|
|
65
84
|
// it without re-keying the map. Ordering is the insertion order of pageRoutes,
|
|
66
85
|
// which pagesRouter() has already sorted by specificity (static → dynamic →
|
|
67
|
-
// catch-all → optional catch-all) via
|
|
86
|
+
// catch-all → optional catch-all) via sortRoutes — so matchPagesPattern()
|
|
68
87
|
// can iterate in order and trust the first match.
|
|
69
88
|
window.__VINEXT_PAGE_LOADERS__ = pageLoaders;
|
|
70
89
|
window.__VINEXT_PAGE_PATTERNS__ = Object.keys(pageLoaders);
|
|
@@ -84,6 +103,12 @@ window.__VINEXT_APP_LOADER__ = appLoader;
|
|
|
84
103
|
// when the user lands on an App Router page (see app-browser-entry.ts) — the
|
|
85
104
|
// two writes do not race because only one entry executes per page load.
|
|
86
105
|
window.__VINEXT_LINK_PREFETCH_ROUTES__ = ${JSON.stringify(appPrefetchRoutes)};
|
|
106
|
+
// Pages route manifest, exposed so the App Router runtime can decide when
|
|
107
|
+
// a soft-navigated URL is actually owned by Pages (and must hard-navigate
|
|
108
|
+
// instead of issuing an RSC request). Set here AND in app-browser-entry.ts
|
|
109
|
+
// so whichever entry runs first emits the Pages manifest.
|
|
110
|
+
window.__VINEXT_PAGES_LINK_PREFETCH_ROUTES__ = ${JSON.stringify(pagesPrefetchRoutes)};
|
|
111
|
+
window.__VINEXT_CLIENT_REWRITES__ = ${JSON.stringify(nextConfig.rewrites)};
|
|
87
112
|
|
|
88
113
|
async function hydrate() {
|
|
89
114
|
const nextData = window.__NEXT_DATA__;
|
|
@@ -104,7 +129,9 @@ async function hydrate() {
|
|
|
104
129
|
};
|
|
105
130
|
}
|
|
106
131
|
|
|
107
|
-
const
|
|
132
|
+
const props = nextData.props && typeof nextData.props === "object" ? nextData.props : {};
|
|
133
|
+
const rawPageProps = props.pageProps;
|
|
134
|
+
const pageProps = rawPageProps && typeof rawPageProps === "object" ? rawPageProps : {};
|
|
108
135
|
const loader = pageLoaders[nextData.page];
|
|
109
136
|
if (!loader) {
|
|
110
137
|
console.error("[vinext] No page loader for route:", nextData.page);
|
|
@@ -124,7 +151,12 @@ async function hydrate() {
|
|
|
124
151
|
const appModule = await appLoader();
|
|
125
152
|
const AppComponent = appModule.default;
|
|
126
153
|
window.__VINEXT_APP__ = AppComponent;
|
|
127
|
-
element = React.createElement(AppComponent, {
|
|
154
|
+
element = React.createElement(AppComponent, {
|
|
155
|
+
...props,
|
|
156
|
+
Component: PageComponent,
|
|
157
|
+
pageProps: rawPageProps,
|
|
158
|
+
router: Router,
|
|
159
|
+
});
|
|
128
160
|
} catch {
|
|
129
161
|
element = React.createElement(PageComponent, pageProps);
|
|
130
162
|
}
|
|
@@ -132,8 +164,13 @@ async function hydrate() {
|
|
|
132
164
|
element = React.createElement(PageComponent, pageProps);
|
|
133
165
|
`}
|
|
134
166
|
|
|
167
|
+
let resolveHydrationCommit;
|
|
168
|
+
const hydrationCommitted = new Promise((resolve) => {
|
|
169
|
+
resolveHydrationCommit = resolve;
|
|
170
|
+
});
|
|
171
|
+
|
|
135
172
|
// Wrap with RouterContext.Provider so next/router and next/compat/router work during hydration.
|
|
136
|
-
element = wrapWithRouterContext(element);
|
|
173
|
+
element = wrapWithRouterContext(element, resolveHydrationCommit);
|
|
137
174
|
|
|
138
175
|
const container = document.getElementById("__next");
|
|
139
176
|
if (!container) {
|
|
@@ -143,12 +180,20 @@ async function hydrate() {
|
|
|
143
180
|
|
|
144
181
|
const root = hydrateRoot(container, element, hydrateRootOptions);
|
|
145
182
|
window.__VINEXT_ROOT__ = root;
|
|
146
|
-
|
|
183
|
+
await hydrationCommitted;
|
|
147
184
|
const hydratedAt = performance.now();
|
|
148
185
|
window.__VINEXT_HYDRATED_AT = hydratedAt;
|
|
149
186
|
window.__NEXT_HYDRATED = true;
|
|
150
187
|
window.__NEXT_HYDRATED_AT = hydratedAt;
|
|
151
188
|
window.__NEXT_HYDRATED_CB?.();
|
|
189
|
+
|
|
190
|
+
if (nextData.isFallback) {
|
|
191
|
+
await Router.replace(
|
|
192
|
+
window.location.pathname + window.location.search + window.location.hash,
|
|
193
|
+
undefined,
|
|
194
|
+
{ _h: 1, scroll: false },
|
|
195
|
+
);
|
|
196
|
+
}
|
|
152
197
|
}
|
|
153
198
|
|
|
154
199
|
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,
|
|
@@ -143,7 +145,7 @@ import React from "react";
|
|
|
143
145
|
import { renderToReadableStream } from "react-dom/server.edge";
|
|
144
146
|
import { resetSSRHead, getSSRHeadHTML, setDocumentInitialHead } from "next/head";
|
|
145
147
|
import { flushPreloads } from "next/dynamic";
|
|
146
|
-
import { setSSRContext, wrapWithRouterContext, getPagesNavigationIsReadyFromSerializedState } from "next/router";
|
|
148
|
+
import Router, { setSSRContext, wrapWithRouterContext, getPagesNavigationIsReadyFromSerializedState } from "next/router";
|
|
147
149
|
import { _runWithCacheState, configureMemoryCacheHandler as __configureMemoryCacheHandler } from "next/cache";
|
|
148
150
|
import { registerConfiguredCacheAdapters as __registerConfiguredCacheAdapters } from "virtual:vinext-cache-adapters";
|
|
149
151
|
import { runWithPrivateCache } from "vinext/cache-runtime";
|
|
@@ -267,6 +269,20 @@ export function matchPageRoute(url, request) {
|
|
|
267
269
|
return matchRoute(routeUrl, pageRoutes);
|
|
268
270
|
}
|
|
269
271
|
|
|
272
|
+
export function matchApiRoute(url, request) {
|
|
273
|
+
const routeUrl = i18nConfig && request
|
|
274
|
+
? resolvePagesI18nRequest(
|
|
275
|
+
url,
|
|
276
|
+
i18nConfig,
|
|
277
|
+
request.headers,
|
|
278
|
+
new URL(request.url).hostname,
|
|
279
|
+
vinextConfig.basePath,
|
|
280
|
+
vinextConfig.trailingSlash,
|
|
281
|
+
).url
|
|
282
|
+
: url;
|
|
283
|
+
return matchRoute(routeUrl, apiRoutes);
|
|
284
|
+
}
|
|
285
|
+
|
|
270
286
|
// ── Pages render orchestrator — delegates to server/pages-page-handler.ts ──
|
|
271
287
|
//
|
|
272
288
|
// All next/*-derived values are passed as closures so the handler module
|
|
@@ -282,6 +298,7 @@ const _renderPage = __createPagesPageHandler({
|
|
|
282
298
|
assetPrefix: vinextConfig.assetPrefix,
|
|
283
299
|
trailingSlash: vinextConfig.trailingSlash,
|
|
284
300
|
expireTime: vinextConfig.expireTime,
|
|
301
|
+
htmlLimitedBots: vinextConfig.htmlLimitedBots,
|
|
285
302
|
clientTraceMetadata: vinextConfig.clientTraceMetadata,
|
|
286
303
|
disableOptimizedLoading: vinextConfig.disableOptimizedLoading,
|
|
287
304
|
},
|
|
@@ -328,18 +345,36 @@ const _renderPage = __createPagesPageHandler({
|
|
|
328
345
|
renderIsrPassToStringAsync: _renderIsrPassToStringAsync,
|
|
329
346
|
safeJsonStringify,
|
|
330
347
|
sanitizeDestination: sanitizeDestinationLocal,
|
|
331
|
-
createPageElement(PageComponent, AppComponent,
|
|
348
|
+
createPageElement(PageComponent, AppComponent, props) {
|
|
349
|
+
const rawPageProps = props?.pageProps;
|
|
350
|
+
const pageProps = rawPageProps && typeof rawPageProps === "object"
|
|
351
|
+
? props.pageProps
|
|
352
|
+
: {};
|
|
332
353
|
return AppComponent
|
|
333
|
-
? React.createElement(AppComponent, {
|
|
354
|
+
? React.createElement(AppComponent, {
|
|
355
|
+
...props,
|
|
356
|
+
Component: PageComponent,
|
|
357
|
+
pageProps: rawPageProps,
|
|
358
|
+
router: Router,
|
|
359
|
+
})
|
|
334
360
|
: React.createElement(PageComponent, pageProps);
|
|
335
361
|
},
|
|
336
|
-
enhancePageElement(PageComponent, AppComponent,
|
|
362
|
+
enhancePageElement(PageComponent, AppComponent, props, opts) {
|
|
363
|
+
const rawPageProps = props?.pageProps;
|
|
364
|
+
const pageProps = rawPageProps && typeof rawPageProps === "object"
|
|
365
|
+
? props.pageProps
|
|
366
|
+
: {};
|
|
337
367
|
let FinalApp = AppComponent;
|
|
338
368
|
let FinalComp = PageComponent;
|
|
339
369
|
if (opts && typeof opts.enhanceApp === "function" && FinalApp) FinalApp = opts.enhanceApp(FinalApp);
|
|
340
370
|
if (opts && typeof opts.enhanceComponent === "function") FinalComp = opts.enhanceComponent(FinalComp);
|
|
341
371
|
return FinalApp
|
|
342
|
-
? React.createElement(FinalApp, {
|
|
372
|
+
? React.createElement(FinalApp, {
|
|
373
|
+
...props,
|
|
374
|
+
Component: FinalComp,
|
|
375
|
+
pageProps: rawPageProps,
|
|
376
|
+
router: Router,
|
|
377
|
+
})
|
|
343
378
|
: React.createElement(FinalComp, pageProps);
|
|
344
379
|
},
|
|
345
380
|
AppComponent,
|
|
@@ -360,6 +395,7 @@ export async function handleApiRoute(request, url, ctx) {
|
|
|
360
395
|
return __handlePagesApiRoute({
|
|
361
396
|
ctx,
|
|
362
397
|
match,
|
|
398
|
+
nextConfig: vinextConfig,
|
|
363
399
|
request,
|
|
364
400
|
url,
|
|
365
401
|
reportRequestError(error, routePattern) {
|