vinext 0.1.1 → 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/README.md +2 -5
- package/dist/build/client-build-config.d.ts +7 -1
- package/dist/build/client-build-config.js +9 -1
- 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/check.js +4 -3
- package/dist/client/app-nav-failure-handler.d.ts +8 -0
- package/dist/client/app-nav-failure-handler.js +44 -0
- package/dist/client/navigation-runtime.d.ts +3 -2
- package/dist/client/vinext-next-data.d.ts +18 -1
- package/dist/client/window-next.d.ts +8 -5
- 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 -4
- package/dist/config/config-matchers.js +88 -16
- package/dist/config/next-config.d.ts +59 -4
- package/dist/config/next-config.js +149 -48
- package/dist/deploy.d.ts +30 -11
- package/dist/deploy.js +189 -101
- 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 +71 -6
- 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 +54 -9
- package/dist/entries/pages-server-entry.js +48 -11
- package/dist/index.d.ts +0 -2
- package/dist/index.js +285 -139
- package/dist/plugins/dynamic-preload-metadata.d.ts +13 -0
- package/dist/plugins/dynamic-preload-metadata.js +415 -0
- package/dist/plugins/extensionless-dynamic-import.d.ts +6 -0
- package/dist/plugins/extensionless-dynamic-import.js +152 -0
- package/dist/plugins/og-assets.js +2 -2
- package/dist/plugins/optimize-imports.d.ts +10 -5
- package/dist/plugins/optimize-imports.js +27 -21
- package/dist/plugins/postcss.js +7 -7
- package/dist/plugins/sass.d.ts +53 -24
- package/dist/plugins/sass.js +249 -1
- package/dist/plugins/typeof-window.d.ts +14 -0
- package/dist/plugins/typeof-window.js +150 -0
- package/dist/plugins/wasm-module-import.d.ts +15 -0
- package/dist/plugins/wasm-module-import.js +50 -0
- package/dist/routing/app-route-graph.d.ts +25 -2
- package/dist/routing/app-route-graph.js +91 -22
- package/dist/routing/file-matcher.d.ts +10 -1
- package/dist/routing/file-matcher.js +23 -2
- 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 +269 -297
- package/dist/server/app-browser-error.d.ts +10 -3
- package/dist/server/app-browser-error.js +47 -6
- package/dist/server/app-browser-history-controller.d.ts +104 -0
- package/dist/server/app-browser-history-controller.js +210 -0
- 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 +7 -4
- package/dist/server/app-browser-navigation-controller.js +33 -9
- package/dist/server/app-browser-rsc-redirect.d.ts +11 -2
- package/dist/server/app-browser-rsc-redirect.js +30 -8
- 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.js +4 -7
- package/dist/server/app-browser-stream.js +86 -43
- package/dist/server/app-browser-visible-commit.js +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 +3 -1
- package/dist/server/app-fallback-renderer.js +6 -2
- package/dist/server/app-middleware.js +1 -0
- package/dist/server/app-optimistic-routing.js +24 -3
- package/dist/server/app-page-boundary-render.d.ts +3 -1
- package/dist/server/app-page-boundary-render.js +31 -16
- 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 +71 -8
- package/dist/server/app-page-dispatch.d.ts +34 -0
- package/dist/server/app-page-dispatch.js +167 -97
- package/dist/server/app-page-element-builder.d.ts +23 -2
- package/dist/server/app-page-element-builder.js +42 -10
- package/dist/server/app-page-execution.d.ts +7 -2
- package/dist/server/app-page-execution.js +53 -18
- 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 +13 -2
- package/dist/server/app-page-render.js +48 -17
- package/dist/server/app-page-request.d.ts +3 -0
- package/dist/server/app-page-request.js +5 -3
- package/dist/server/app-page-response.js +1 -1
- package/dist/server/app-page-route-wiring.d.ts +5 -1
- package/dist/server/app-page-route-wiring.js +21 -11
- package/dist/server/app-page-stream.d.ts +16 -9
- package/dist/server/app-page-stream.js +12 -9
- 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-route-handler-response.js +11 -10
- package/dist/server/app-route-handler-runtime.js +12 -1
- 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 +153 -53
- package/dist/server/app-rsc-response-finalizer.js +1 -1
- 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 +12 -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 +81 -8
- package/dist/server/app-ssr-stream.js +9 -1
- package/dist/server/cache-control.js +4 -0
- package/dist/server/dev-lockfile.js +2 -1
- package/dist/server/dev-server.d.ts +2 -2
- package/dist/server/dev-server.js +287 -63
- package/dist/server/headers.d.ts +8 -1
- package/dist/server/headers.js +8 -1
- 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/instrumentation-runtime.d.ts +6 -0
- package/dist/server/instrumentation-runtime.js +8 -0
- package/dist/server/isr-decision.d.ts +79 -0
- package/dist/server/isr-decision.js +70 -0
- package/dist/server/metadata-route-response.js +5 -3
- package/dist/server/middleware-runtime.d.ts +13 -0
- package/dist/server/middleware-runtime.js +11 -7
- package/dist/server/middleware.js +1 -0
- package/dist/server/navigation-planner.d.ts +186 -22
- package/dist/server/navigation-planner.js +302 -0
- package/dist/server/navigation-trace.d.ts +18 -1
- package/dist/server/navigation-trace.js +18 -1
- package/dist/server/normalize-path.d.ts +0 -8
- package/dist/server/normalize-path.js +3 -1
- package/dist/server/otel-tracer-extension.d.ts +45 -0
- package/dist/server/otel-tracer-extension.js +89 -0
- package/dist/server/pages-api-route.d.ts +20 -3
- package/dist/server/pages-api-route.js +19 -3
- package/dist/server/pages-asset-tags.d.ts +16 -4
- package/dist/server/pages-asset-tags.js +22 -12
- package/dist/server/pages-data-route.d.ts +8 -1
- package/dist/server/pages-data-route.js +16 -3
- 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.d.ts +3 -11
- package/dist/server/pages-node-compat.js +175 -122
- package/dist/server/pages-page-data.d.ts +39 -2
- package/dist/server/pages-page-data.js +261 -46
- package/dist/server/pages-page-handler.d.ts +5 -2
- package/dist/server/pages-page-handler.js +78 -25
- package/dist/server/pages-page-response.d.ts +47 -2
- package/dist/server/pages-page-response.js +73 -9
- package/dist/server/pages-readiness.d.ts +1 -1
- package/dist/server/pages-request-pipeline.d.ts +16 -1
- package/dist/server/pages-request-pipeline.js +96 -38
- 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 +39 -1
- package/dist/server/prod-server.js +107 -37
- 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 +12 -4
- 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.d.ts +8 -0
- package/dist/shims/dynamic-preload-chunks.js +79 -0
- package/dist/shims/dynamic.d.ts +4 -0
- package/dist/shims/dynamic.js +4 -2
- package/dist/shims/error-boundary.d.ts +6 -4
- package/dist/shims/error-boundary.js +7 -0
- package/dist/shims/error.js +38 -11
- 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 +11 -1
- package/dist/shims/fetch-cache.js +55 -20
- package/dist/shims/hash-scroll.js +6 -1
- package/dist/shims/head.js +6 -1
- package/dist/shims/headers.d.ts +16 -2
- package/dist/shims/headers.js +66 -5
- package/dist/shims/image-config.js +7 -1
- package/dist/shims/internal/als-registry.js +28 -1
- package/dist/shims/internal/app-route-detection.d.ts +6 -3
- package/dist/shims/internal/app-route-detection.js +18 -23
- package/dist/shims/internal/app-router-context.d.ts +5 -0
- 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/metadata.d.ts +6 -2
- package/dist/shims/metadata.js +32 -14
- package/dist/shims/navigation.d.ts +14 -17
- package/dist/shims/navigation.js +93 -46
- 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 +434 -116
- package/dist/shims/script-nonce-context.d.ts +1 -1
- package/dist/shims/script-nonce-context.js +11 -3
- package/dist/shims/server.d.ts +33 -2
- package/dist/shims/server.js +75 -18
- package/dist/shims/slot.js +1 -1
- package/dist/shims/unified-request-context.js +2 -0
- package/dist/typegen.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/client-build-manifest.js +15 -5
- package/dist/utils/client-runtime-metadata.d.ts +45 -0
- package/dist/utils/client-runtime-metadata.js +63 -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/hash.d.ts +17 -1
- package/dist/utils/hash.js +36 -1
- package/dist/utils/html-limited-bots.d.ts +18 -1
- package/dist/utils/html-limited-bots.js +23 -1
- package/dist/utils/lazy-chunks.d.ts +27 -1
- package/dist/utils/lazy-chunks.js +65 -1
- package/dist/utils/manifest-paths.d.ts +20 -2
- package/dist/utils/manifest-paths.js +38 -3
- package/dist/utils/parse-cookie.d.ts +13 -0
- package/dist/utils/parse-cookie.js +52 -0
- package/dist/utils/path.d.ts +8 -1
- package/dist/utils/path.js +13 -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,
|
|
@@ -275,6 +296,10 @@ ${metaRouteEntries.join(",\n")}
|
|
|
275
296
|
// recognising /_next/static/* paths (parity with __assetPrefix below).
|
|
276
297
|
export const __basePath = ${JSON.stringify(bp)};
|
|
277
298
|
|
|
299
|
+
// Hoisted alongside __basePath so __fallbackRenderer / buildPageElements can
|
|
300
|
+
// thread the configured trailingSlash flag through canonical URL rendering.
|
|
301
|
+
const __trailingSlash = ${JSON.stringify(ts)};
|
|
302
|
+
|
|
278
303
|
const rootNotFoundModule = ${rootNotFoundVar ? rootNotFoundVar : "null"};
|
|
279
304
|
const rootForbiddenModule = ${rootForbiddenVar ? rootForbiddenVar : "null"};
|
|
280
305
|
const rootUnauthorizedModule = ${rootUnauthorizedVar ? rootUnauthorizedVar : "null"};
|
|
@@ -298,6 +323,7 @@ const createRscOnErrorHandler = (request, pathname, routePath) =>
|
|
|
298
323
|
|
|
299
324
|
const __fallbackRenderer = __createAppFallbackRenderer({
|
|
300
325
|
basePath: __basePath,
|
|
326
|
+
trailingSlash: __trailingSlash,
|
|
301
327
|
rootBoundaries: {
|
|
302
328
|
rootForbiddenModule,
|
|
303
329
|
rootLayouts,
|
|
@@ -357,15 +383,16 @@ async function buildPageElements(route, params, routePath, pageRequest, layoutPa
|
|
|
357
383
|
metadataRoutes,
|
|
358
384
|
layoutParamAccess,
|
|
359
385
|
basePath: __basePath,
|
|
386
|
+
trailingSlash: __trailingSlash,
|
|
360
387
|
htmlLimitedBots: __htmlLimitedBots,
|
|
361
388
|
});
|
|
362
389
|
}
|
|
363
390
|
|
|
364
|
-
const __trailingSlash = ${JSON.stringify(ts)};
|
|
365
391
|
const __i18nConfig = ${JSON.stringify(i18nConfig)};
|
|
366
392
|
const __configRedirects = ${JSON.stringify(redirects)};
|
|
367
393
|
const __configRewrites = ${JSON.stringify(rewrites)};
|
|
368
394
|
const __configHeaders = ${JSON.stringify(headers)};
|
|
395
|
+
const __imageConfig = ${JSON.stringify(config?.imageConfig)};
|
|
369
396
|
const __publicFiles = new Set(${JSON.stringify(publicFiles)});
|
|
370
397
|
const __allowedOrigins = ${JSON.stringify(allowedOrigins)};
|
|
371
398
|
const __expireTime = ${JSON.stringify(expireTime)};
|
|
@@ -378,6 +405,8 @@ const __reactMaxHeadersLength = ${JSON.stringify(reactMaxHeadersLength)};
|
|
|
378
405
|
export const __assetPrefix = ${JSON.stringify(assetPrefix)};
|
|
379
406
|
export const __inlineCss = ${JSON.stringify(inlineCss)};
|
|
380
407
|
export const __hasPagesDir = ${JSON.stringify(hasPagesDir)};
|
|
408
|
+
export const getRenderedConcreteUrlPathsForRoute = __getRenderedConcreteUrlPathsForRoute;
|
|
409
|
+
const __cacheComponents = ${JSON.stringify(cacheComponents)};
|
|
381
410
|
|
|
382
411
|
export function seedMemoryCacheFromPrerender(serverDir) {
|
|
383
412
|
return __seedMemoryCacheFromPrerender(serverDir, {
|
|
@@ -429,8 +458,11 @@ export default __createAppRscHandler({
|
|
|
429
458
|
},
|
|
430
459
|
registerCacheAdapters: __registerConfiguredCacheAdapters,
|
|
431
460
|
configHeaders: __configHeaders,
|
|
461
|
+
cacheComponents: __cacheComponents,
|
|
432
462
|
configRedirects: __configRedirects,
|
|
433
463
|
configRewrites: __configRewrites,
|
|
464
|
+
imageConfig: __imageConfig,
|
|
465
|
+
isDev: process.env.NODE_ENV !== "production",
|
|
434
466
|
draftModeSecret: __draftModeSecret,
|
|
435
467
|
dispatchMatchedPage({
|
|
436
468
|
clientReuseManifest,
|
|
@@ -446,6 +478,10 @@ export default __createAppRscHandler({
|
|
|
446
478
|
middlewareContext,
|
|
447
479
|
mountedSlotsHeader,
|
|
448
480
|
params,
|
|
481
|
+
pprFallbackCacheShells,
|
|
482
|
+
pprFallbackShell,
|
|
483
|
+
renderedConcreteUrlPaths,
|
|
484
|
+
skipStaticParamsValidation,
|
|
449
485
|
staticParamsValidationParams,
|
|
450
486
|
rootParams,
|
|
451
487
|
request,
|
|
@@ -484,6 +520,7 @@ export default __createAppRscHandler({
|
|
|
484
520
|
},
|
|
485
521
|
clientReuseManifest,
|
|
486
522
|
cleanPathname,
|
|
523
|
+
displayPathname,
|
|
487
524
|
clearRequestContext() {
|
|
488
525
|
__clearRequestContext();
|
|
489
526
|
},
|
|
@@ -508,6 +545,7 @@ export default __createAppRscHandler({
|
|
|
508
545
|
getSourceRoute(sourceRouteIndex) {
|
|
509
546
|
return routes[sourceRouteIndex];
|
|
510
547
|
},
|
|
548
|
+
hasCustomGlobalError: ${globalErrorVar ? `Boolean(${globalErrorVar}?.default)` : "false"},
|
|
511
549
|
hasGenerateStaticParams: __generateStaticParams.length > 0,
|
|
512
550
|
hasPageDefaultExport: !!PageComponent,
|
|
513
551
|
hasPageModule: !!route.page,
|
|
@@ -532,6 +570,10 @@ export default __createAppRscHandler({
|
|
|
532
570
|
middlewareContext,
|
|
533
571
|
mountedSlotsHeader,
|
|
534
572
|
params,
|
|
573
|
+
pprFallbackCacheShells,
|
|
574
|
+
pprFallbackShell,
|
|
575
|
+
renderedConcreteUrlPaths,
|
|
576
|
+
skipStaticParamsValidation,
|
|
535
577
|
staticParamsValidationParams,
|
|
536
578
|
rootParams,
|
|
537
579
|
probeLayoutAt(li, layoutParamAccess) {
|
|
@@ -566,17 +608,33 @@ export default __createAppRscHandler({
|
|
|
566
608
|
}));
|
|
567
609
|
},
|
|
568
610
|
renderErrorBoundaryPage(renderErr) {
|
|
569
|
-
|
|
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
|
+
});
|
|
570
618
|
},
|
|
571
619
|
renderHttpAccessFallbackPage(statusCode, opts, currentMiddlewareContext) {
|
|
572
|
-
|
|
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
|
+
});
|
|
573
627
|
},
|
|
574
628
|
renderToReadableStream,
|
|
629
|
+
prerenderToReadableStream,
|
|
575
630
|
request,
|
|
576
631
|
revalidateSeconds: __segmentConfig.revalidateSeconds,
|
|
577
632
|
resolveRouteFetchCacheMode(targetRoute) {
|
|
578
633
|
return __resolveRouteFetchCacheMode(targetRoute);
|
|
579
634
|
},
|
|
635
|
+
resolveRouteDynamicConfig(targetRoute) {
|
|
636
|
+
return __resolveRouteDynamicConfig(targetRoute);
|
|
637
|
+
},
|
|
580
638
|
rootForbiddenModule,
|
|
581
639
|
rootNotFoundModule,
|
|
582
640
|
rootUnauthorizedModule,
|
|
@@ -769,6 +827,12 @@ export default __createAppRscHandler({
|
|
|
769
827
|
readFormDataWithLimit: __readFormDataWithLimit,
|
|
770
828
|
renderToReadableStream,
|
|
771
829
|
reportRequestError: _reportRequestError,
|
|
830
|
+
resolveRouteFetchCacheMode(targetRoute) {
|
|
831
|
+
return __resolveRouteFetchCacheMode(targetRoute);
|
|
832
|
+
},
|
|
833
|
+
resolveRouteDynamicConfig(targetRoute) {
|
|
834
|
+
return __resolveRouteDynamicConfig(targetRoute);
|
|
835
|
+
},
|
|
772
836
|
resolveRouteRuntime: __resolveRouteRuntime,
|
|
773
837
|
request,
|
|
774
838
|
sanitizeErrorForClient(error) {
|
|
@@ -784,6 +848,7 @@ export default __createAppRscHandler({
|
|
|
784
848
|
interceptSlotId: intercept.slotId,
|
|
785
849
|
interceptSlotKey: intercept.slotKey,
|
|
786
850
|
interceptSourceMatchedUrl: interceptionContext,
|
|
851
|
+
interceptSourcePageSegments: intercept.sourcePageSegments,
|
|
787
852
|
interceptPage: intercept.page,
|
|
788
853
|
interceptParams: intercept.matchedParams,
|
|
789
854
|
};
|
|
@@ -802,9 +867,9 @@ export default __createAppRscHandler({
|
|
|
802
867
|
const __isEdge = route ? __isEdgeRuntime(__resolveAppPageSegmentConfig({ layouts: route.layouts, page: route.page }).runtime) : false;
|
|
803
868
|
return __fallbackRenderer.renderNotFound(route, isRscRequest, request, matchedParams, scriptNonce, middlewareContext, { isEdgeRuntime: __isEdge });
|
|
804
869
|
},
|
|
805
|
-
${hasPagesDir ? `async renderPagesFallback({ isRscRequest, middlewareContext, request, url }) {
|
|
870
|
+
${hasPagesDir ? `async renderPagesFallback({ allowRscDocumentFallback, appRouteMatch, isRscRequest, matchKind, middlewareContext, pathname, request, url }) {
|
|
806
871
|
return __renderPagesFallback(
|
|
807
|
-
{ isRscRequest, middlewareContext, request, url },
|
|
872
|
+
{ allowRscDocumentFallback, appRouteMatch, isRscRequest, matchKind, middlewareContext, pathname, request, url },
|
|
808
873
|
{
|
|
809
874
|
loadPagesEntry() {
|
|
810
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
|
+
import { normalizePathSeparators } from "../utils/path.js";
|
|
1
2
|
import { findFileWithExts } from "../routing/file-matcher.js";
|
|
2
3
|
import { patternToNextFormat } from "../routing/route-validation.js";
|
|
3
|
-
import { pagesRouter } from "../routing/pages-router.js";
|
|
4
|
-
import { normalizePathSeparators } from "../utils/path.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 { normalizePathSeparators } from "../utils/path.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();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { normalizePathSeparators } from "../utils/path.js";
|
|
1
2
|
import { findFileWithExts } from "../routing/file-matcher.js";
|
|
2
3
|
import { apiRouter, pagesRouter } from "../routing/pages-router.js";
|
|
3
|
-
import { normalizePathSeparators } from "../utils/path.js";
|
|
4
4
|
import { resolveEntryPath } from "./runtime-entry-module.js";
|
|
5
5
|
import { isProxyFile } from "../server/middleware.js";
|
|
6
6
|
//#region src/entries/pages-server-entry.ts
|
|
@@ -46,11 +46,11 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
|
|
|
46
46
|
const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
|
|
47
47
|
const docFilePath = findFileWithExts(pagesDir, "_document", fileMatcher);
|
|
48
48
|
const errorFilePath = findFileWithExts(pagesDir, "_error", fileMatcher);
|
|
49
|
-
const appAssetPathJson = appFilePath !== null ? JSON.stringify(
|
|
50
|
-
const appImportCode = appFilePath !== null ? `import { default as AppComponent } from ${JSON.stringify(
|
|
51
|
-
const docImportCode = docFilePath !== null ? `import { default as DocumentComponent } from ${JSON.stringify(
|
|
52
|
-
const errorAssetPathJson = errorFilePath !== null ? JSON.stringify(
|
|
53
|
-
const errorImportCode = errorFilePath !== null ? `import * as ErrorPageModule from ${JSON.stringify(
|
|
49
|
+
const appAssetPathJson = appFilePath !== null ? JSON.stringify(appFilePath) : "null";
|
|
50
|
+
const appImportCode = appFilePath !== null ? `import { default as AppComponent } from ${JSON.stringify(appFilePath)};` : `const AppComponent = null;`;
|
|
51
|
+
const docImportCode = docFilePath !== null ? `import { default as DocumentComponent } from ${JSON.stringify(docFilePath)};` : `const DocumentComponent = null;`;
|
|
52
|
+
const errorAssetPathJson = errorFilePath !== null ? JSON.stringify(errorFilePath) : "null";
|
|
53
|
+
const errorImportCode = errorFilePath !== null ? `import * as ErrorPageModule from ${JSON.stringify(errorFilePath)};` : `const ErrorPageModule = null;`;
|
|
54
54
|
const i18nConfigJson = nextConfig?.i18n ? JSON.stringify({
|
|
55
55
|
locales: nextConfig.i18n.locales,
|
|
56
56
|
defaultLocale: nextConfig.i18n.defaultLocale,
|
|
@@ -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
|
|
@@ -279,8 +295,10 @@ const _renderPage = __createPagesPageHandler({
|
|
|
279
295
|
i18nConfig,
|
|
280
296
|
vinextConfig: {
|
|
281
297
|
basePath: vinextConfig.basePath,
|
|
298
|
+
assetPrefix: vinextConfig.assetPrefix,
|
|
282
299
|
trailingSlash: vinextConfig.trailingSlash,
|
|
283
300
|
expireTime: vinextConfig.expireTime,
|
|
301
|
+
htmlLimitedBots: vinextConfig.htmlLimitedBots,
|
|
284
302
|
clientTraceMetadata: vinextConfig.clientTraceMetadata,
|
|
285
303
|
disableOptimizedLoading: vinextConfig.disableOptimizedLoading,
|
|
286
304
|
},
|
|
@@ -327,18 +345,36 @@ const _renderPage = __createPagesPageHandler({
|
|
|
327
345
|
renderIsrPassToStringAsync: _renderIsrPassToStringAsync,
|
|
328
346
|
safeJsonStringify,
|
|
329
347
|
sanitizeDestination: sanitizeDestinationLocal,
|
|
330
|
-
createPageElement(PageComponent, AppComponent,
|
|
348
|
+
createPageElement(PageComponent, AppComponent, props) {
|
|
349
|
+
const rawPageProps = props?.pageProps;
|
|
350
|
+
const pageProps = rawPageProps && typeof rawPageProps === "object"
|
|
351
|
+
? props.pageProps
|
|
352
|
+
: {};
|
|
331
353
|
return AppComponent
|
|
332
|
-
? React.createElement(AppComponent, {
|
|
354
|
+
? React.createElement(AppComponent, {
|
|
355
|
+
...props,
|
|
356
|
+
Component: PageComponent,
|
|
357
|
+
pageProps: rawPageProps,
|
|
358
|
+
router: Router,
|
|
359
|
+
})
|
|
333
360
|
: React.createElement(PageComponent, pageProps);
|
|
334
361
|
},
|
|
335
|
-
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
|
+
: {};
|
|
336
367
|
let FinalApp = AppComponent;
|
|
337
368
|
let FinalComp = PageComponent;
|
|
338
369
|
if (opts && typeof opts.enhanceApp === "function" && FinalApp) FinalApp = opts.enhanceApp(FinalApp);
|
|
339
370
|
if (opts && typeof opts.enhanceComponent === "function") FinalComp = opts.enhanceComponent(FinalComp);
|
|
340
371
|
return FinalApp
|
|
341
|
-
? React.createElement(FinalApp, {
|
|
372
|
+
? React.createElement(FinalApp, {
|
|
373
|
+
...props,
|
|
374
|
+
Component: FinalComp,
|
|
375
|
+
pageProps: rawPageProps,
|
|
376
|
+
router: Router,
|
|
377
|
+
})
|
|
342
378
|
: React.createElement(FinalComp, pageProps);
|
|
343
379
|
},
|
|
344
380
|
AppComponent,
|
|
@@ -359,6 +395,7 @@ export async function handleApiRoute(request, url, ctx) {
|
|
|
359
395
|
return __handlePagesApiRoute({
|
|
360
396
|
ctx,
|
|
361
397
|
match,
|
|
398
|
+
nextConfig: vinextConfig,
|
|
362
399
|
request,
|
|
363
400
|
url,
|
|
364
401
|
reportRequestError(error, routePattern) {
|
package/dist/index.d.ts
CHANGED
|
@@ -88,12 +88,10 @@ type VinextOptions = {
|
|
|
88
88
|
* need a binding — e.g. a KV namespace — can read it.
|
|
89
89
|
*
|
|
90
90
|
* @example
|
|
91
|
-
* import { cdnAdapter } from "@vinext/cloudflare/cache/cdn-adapter";
|
|
92
91
|
* import { kvDataAdapter } from "@vinext/cloudflare/cache/kv-data-adapter";
|
|
93
92
|
*
|
|
94
93
|
* vinext({
|
|
95
94
|
* cache: {
|
|
96
|
-
* cdn: cdnAdapter(),
|
|
97
95
|
* data: kvDataAdapter({ binding: "MY_KV" }),
|
|
98
96
|
* },
|
|
99
97
|
* })
|