vinext 1.1.0 → 1.2.1
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 +22 -10
- package/dist/build/client-build-config.d.ts +10 -0
- package/dist/build/client-build-config.js +18 -2
- package/dist/build/output-root-externals.d.ts +21 -0
- package/dist/build/output-root-externals.js +40 -0
- package/dist/build/pages-client-assets-module.d.ts +8 -0
- package/dist/build/pages-client-assets-module.js +21 -1
- package/dist/build/prerender-paths.js +6 -4
- package/dist/build/prerender.js +1 -1
- package/dist/build/run-prerender.js +1 -1
- package/dist/build/ssr-manifest.d.ts +2 -0
- package/dist/build/ssr-manifest.js +6 -2
- package/dist/check.js +12 -12
- package/dist/cli-dev-config.js +3 -3
- package/dist/cli.js +3 -2
- package/dist/client/client-redirect-matcher.d.ts +14 -0
- package/dist/client/client-redirect-matcher.js +37 -0
- package/dist/client/client-redirects.d.ts +27 -0
- package/dist/client/client-redirects.js +28 -0
- package/dist/client/client-rewrites.d.ts +2 -1
- package/dist/client/client-rewrites.js +1 -1
- package/dist/config/config-matchers.d.ts +26 -11
- package/dist/config/config-matchers.js +90 -88
- package/dist/config/destination-params.d.ts +47 -0
- package/dist/config/destination-params.js +116 -0
- package/dist/config/next-config.d.ts +7 -0
- package/dist/config/next-config.js +3 -0
- package/dist/entries/app-rsc-entry.d.ts +4 -0
- package/dist/entries/app-rsc-entry.js +20 -6
- package/dist/entries/pages-client-entry.js +3 -1
- package/dist/entries/pages-server-entry.js +13 -37
- package/dist/index.d.ts +3 -1
- package/dist/index.js +246 -136
- package/dist/init-cloudflare.d.ts +9 -0
- package/dist/init-cloudflare.js +107 -31
- package/dist/init-platform.d.ts +4 -0
- package/dist/init-platform.js +27 -2
- package/dist/init.d.ts +2 -1
- package/dist/init.js +153 -9
- package/dist/plugins/ast-scope.d.ts +7 -0
- package/dist/plugins/ast-scope.js +59 -3
- package/dist/plugins/ast-utils.d.ts +53 -2
- package/dist/plugins/ast-utils.js +90 -2
- package/dist/plugins/cloudflare-dev-module-urls.d.ts +41 -0
- package/dist/plugins/cloudflare-dev-module-urls.js +271 -0
- package/dist/plugins/commonjs-esm-facade.js +2 -2
- package/dist/plugins/css-module-imports.js +13 -20
- package/dist/plugins/dynamic-preload-metadata.d.ts +1 -1
- package/dist/plugins/dynamic-preload-metadata.js +11 -11
- package/dist/plugins/extensionless-dynamic-import.js +2 -3
- package/dist/plugins/fonts.d.ts +1 -1
- package/dist/plugins/fonts.js +3 -3
- package/dist/plugins/ignore-dynamic-requests.d.ts +1 -1
- package/dist/plugins/ignore-dynamic-requests.js +5 -7
- package/dist/plugins/import-meta-url.js +3 -4
- package/dist/plugins/instrumentation-client.js +3 -2
- package/dist/plugins/middleware-export-validation.js +2 -3
- package/dist/plugins/middleware-server-only.d.ts +5 -4
- package/dist/plugins/middleware-server-only.js +8 -5
- package/dist/plugins/og-harfbuzz.js +2 -3
- package/dist/plugins/optimize-imports.js +3 -4
- package/dist/plugins/pages-node-externals.js +3 -4
- package/dist/plugins/remove-console.js +2 -18
- package/dist/plugins/require-condition-resolution.js +3 -3
- package/dist/plugins/require-context.js +2 -3
- package/dist/plugins/rsc-scan-glob-imports.d.ts +19 -0
- package/dist/plugins/rsc-scan-glob-imports.js +50 -0
- package/dist/plugins/strip-server-exports.js +265 -102
- package/dist/plugins/styled-jsx.js +2 -3
- package/dist/plugins/transform-result.d.ts +9 -5
- package/dist/plugins/transitive-externals.js +1 -1
- package/dist/plugins/typeof-window.d.ts +2 -2
- package/dist/plugins/use-cache-callable.d.ts +21 -2
- package/dist/plugins/use-cache-callable.js +84 -35
- package/dist/plugins/worker-image-imports.js +30 -33
- package/dist/plugins/worker-server-only-imports.d.ts +20 -0
- package/dist/plugins/worker-server-only-imports.js +31 -0
- package/dist/plugins/worker-use-server.d.ts +25 -0
- package/dist/plugins/worker-use-server.js +153 -0
- package/dist/server/api-handler.d.ts +1 -0
- package/dist/server/api-handler.js +3 -2
- package/dist/server/app-action-forwarding.js +2 -2
- package/dist/server/app-browser-action-result.d.ts +1 -1
- package/dist/server/app-browser-action-result.js +9 -2
- package/dist/server/app-browser-entry.js +3 -3
- package/dist/server/app-browser-interception-context.js +1 -1
- package/dist/server/app-browser-navigation-controller.js +1 -1
- package/dist/server/app-browser-prefetch-response.js +2 -2
- package/dist/server/app-browser-server-action-client.js +1 -1
- package/dist/server/app-browser-state.js +1 -1
- package/dist/server/app-browser-supplemental-refresh.js +1 -1
- package/dist/server/app-middleware.d.ts +11 -0
- package/dist/server/app-middleware.js +17 -2
- package/dist/server/app-optimistic-routing.js +1 -1
- package/dist/server/app-page-cache.d.ts +1 -1
- package/dist/server/app-page-cache.js +1 -1
- package/dist/server/app-page-dispatch.d.ts +3 -1
- package/dist/server/app-page-dispatch.js +5 -4
- package/dist/server/app-page-ppr-runtime.js +1 -1
- package/dist/server/app-page-render-observation.js +1 -1
- package/dist/server/app-page-render.js +1 -1
- package/dist/server/app-page-request.js +53 -15
- package/dist/server/app-page-route-wiring.js +2 -2
- package/dist/server/app-pages-bridge.d.ts +1 -1
- package/dist/server/app-pages-bridge.js +3 -4
- package/dist/server/app-prerender-endpoints.js +9 -6
- package/dist/server/app-render-abort-error.d.ts +19 -0
- package/dist/server/app-render-abort-error.js +31 -1
- package/dist/server/app-request-stage-dispatch.js +6 -2
- package/dist/server/app-request-stage-independent-entry.js +29 -9
- package/dist/server/app-response-stage-entry.js +11 -3
- package/dist/server/app-route-handler-cache.d.ts +1 -0
- package/dist/server/app-route-handler-cache.js +1 -0
- package/dist/server/app-route-handler-dispatch.d.ts +1 -0
- package/dist/server/app-route-handler-dispatch.js +5 -2
- package/dist/server/app-route-handler-execution.d.ts +1 -0
- package/dist/server/app-route-handler-execution.js +1 -0
- package/dist/server/app-route-handler-runtime.d.ts +4 -1
- package/dist/server/app-route-handler-runtime.js +46 -25
- package/dist/server/app-router-entry.js +29 -10
- package/dist/server/app-rsc-cache-busting.d.ts +16 -0
- package/dist/server/app-rsc-cache-busting.js +30 -13
- package/dist/server/app-rsc-errors.js +20 -16
- package/dist/server/app-rsc-handler.d.ts +7 -0
- package/dist/server/app-rsc-handler.js +89 -39
- package/dist/server/app-rsc-request-normalization.js +3 -3
- package/dist/server/app-rsc-response-stage.js +5 -3
- package/dist/server/app-segment-config.d.ts +2 -1
- package/dist/server/app-server-action-execution.d.ts +2 -1
- package/dist/server/app-server-action-execution.js +62 -23
- package/dist/server/app-ssr-entry.js +7 -5
- package/dist/server/app-visited-response-cache.js +2 -2
- package/dist/server/app-worker-stages.d.ts +5 -0
- package/dist/server/app-worker-stages.js +1 -1
- package/dist/server/cacheability-request.js +2 -2
- package/dist/server/client-build-files.d.ts +16 -0
- package/dist/server/client-build-files.js +36 -0
- package/dist/server/client-reuse-manifest.js +1 -1
- package/dist/server/config-headers.js +1 -1
- package/dist/server/defer-until-stream-consumed.d.ts +2 -1
- package/dist/server/defer-until-stream-consumed.js +3 -1
- package/dist/server/dev-server.js +39 -28
- package/dist/server/dev-stack-sourcemap.js +18 -23
- package/dist/server/document-initial-head.d.ts +0 -11
- package/dist/server/document-initial-head.js +1 -1
- package/dist/server/forwarded-middleware-context.d.ts +5 -0
- package/dist/server/forwarded-middleware-context.js +22 -0
- package/dist/server/headers.d.ts +4 -1
- package/dist/server/headers.js +4 -1
- package/dist/server/http-conditional.d.ts +11 -0
- package/dist/server/http-conditional.js +10 -1
- package/dist/server/http-error-responses.d.ts +1 -1
- package/dist/server/image-optimization.d.ts +38 -0
- package/dist/server/image-optimization.js +94 -4
- package/dist/server/isr-cache.d.ts +10 -0
- package/dist/server/isr-cache.js +41 -6
- package/dist/server/metadata-route-response.js +11 -10
- package/dist/server/middleware-matcher.d.ts +2 -0
- package/dist/server/middleware-matcher.js +23 -2
- package/dist/server/middleware-path-to-regexp.js +1 -1
- package/dist/server/middleware-runtime.d.ts +13 -0
- package/dist/server/middleware-runtime.js +38 -25
- package/dist/server/middleware.d.ts +1 -1
- package/dist/server/middleware.js +3 -1
- package/dist/server/multi-stage.d.ts +11 -0
- package/dist/server/navigation-planner.js +1 -1
- package/dist/server/normalize-path.d.ts +0 -13
- package/dist/server/normalize-path.js +1 -34
- package/dist/server/open-redirect.d.ts +11 -4
- package/dist/server/open-redirect.js +11 -4
- package/dist/server/pages-api-route.d.ts +3 -2
- package/dist/server/pages-api-route.js +6 -5
- package/dist/server/pages-cache-tag.d.ts +12 -0
- package/dist/server/pages-cache-tag.js +19 -0
- package/dist/server/pages-client-assets.d.ts +2 -0
- package/dist/server/pages-data-route.d.ts +10 -0
- package/dist/server/pages-data-route.js +21 -3
- package/dist/server/pages-document-asset-props.d.ts +5 -1
- package/dist/server/pages-document-asset-props.js +13 -5
- package/dist/server/pages-document-splice.d.ts +19 -0
- package/dist/server/pages-document-splice.js +55 -0
- package/dist/server/pages-i18n.d.ts +12 -1
- package/dist/server/pages-i18n.js +18 -4
- package/dist/server/pages-node-compat.d.ts +16 -5
- package/dist/server/pages-node-compat.js +20 -12
- package/dist/server/pages-page-data.d.ts +32 -24
- package/dist/server/pages-page-data.js +51 -121
- package/dist/server/pages-page-handler.d.ts +0 -6
- package/dist/server/pages-page-handler.js +189 -127
- package/dist/server/pages-page-response.d.ts +12 -6
- package/dist/server/pages-page-response.js +42 -35
- package/dist/server/pages-request-pipeline.d.ts +10 -2
- package/dist/server/pages-request-pipeline.js +41 -22
- package/dist/server/pages-request-stage-entry.d.ts +6 -0
- package/dist/server/pages-request-stage-entry.js +75 -16
- package/dist/server/pages-response-stage-entry.js +4 -0
- package/dist/server/pages-revalidate.js +3 -3
- package/dist/server/pages-router-entry.js +5 -4
- package/dist/server/prerender-manifest.d.ts +3 -3
- package/dist/server/prerender-manifest.js +4 -3
- package/dist/server/prerender-work-unit-setup.js +4 -0
- package/dist/server/prod-server.d.ts +12 -0
- package/dist/server/prod-server.js +204 -74
- package/dist/server/proper-error.d.ts +4 -0
- package/dist/server/proper-error.js +31 -0
- package/dist/server/request-pipeline.d.ts +4 -1
- package/dist/server/request-pipeline.js +3 -2
- package/dist/server/revalidation-request.d.ts +1 -0
- package/dist/server/revalidation-request.js +1 -1
- package/dist/server/rsc-stream-hints.d.ts +1 -1
- package/dist/server/rsc-stream-hints.js +52 -5
- package/dist/server/seed-cache.d.ts +1 -0
- package/dist/server/seed-cache.js +5 -4
- package/dist/server/server-reference-loader.d.ts +4 -0
- package/dist/server/server-reference-loader.js +29 -0
- package/dist/server/socket-error-backstop.d.ts +9 -1
- package/dist/server/socket-error-backstop.js +46 -17
- package/dist/server/static-file-signal.d.ts +15 -4
- package/dist/server/static-file-signal.js +46 -12
- package/dist/server/worker-image-optimization.d.ts +34 -0
- package/dist/server/worker-image-optimization.js +99 -0
- package/dist/server/worker-stages.d.ts +1 -1
- package/dist/server/worker-stages.js +2 -2
- package/dist/server/worker-utils.d.ts +8 -3
- package/dist/server/worker-utils.js +12 -7
- package/dist/shims/app-router-scroll.js +4 -1
- package/dist/shims/app-router-tree-context.d.ts +5 -0
- package/dist/shims/app-router-tree-context.js +27 -0
- package/dist/shims/cache-callable-runtime.d.ts +4 -2
- package/dist/shims/cache-callable-runtime.js +21 -12
- package/dist/shims/cache-handler.js +1 -9
- package/dist/shims/cache-runtime.d.ts +6 -1
- package/dist/shims/cache-runtime.js +2 -1
- package/dist/shims/cache.d.ts +2 -2
- package/dist/shims/cache.js +40 -13
- package/dist/shims/cdn-cache.d.ts +8 -0
- package/dist/shims/cdn-cache.js +17 -1
- package/dist/shims/disable-smooth-scroll.d.ts +3 -0
- package/dist/shims/disable-smooth-scroll.js +36 -0
- package/dist/shims/document-placeholders.d.ts +19 -0
- package/dist/shims/document-placeholders.js +45 -0
- package/dist/shims/document.js +21 -5
- package/dist/shims/dynamic-preload-chunks.d.ts +1 -0
- package/dist/shims/dynamic-preload-chunks.js +13 -9
- package/dist/shims/dynamic.d.ts +1 -1
- package/dist/shims/dynamic.js +60 -8
- package/dist/shims/fetch-cache-state.d.ts +66 -0
- package/dist/shims/fetch-cache-state.js +92 -0
- package/dist/shims/fetch-cache.d.ts +3 -67
- package/dist/shims/fetch-cache.js +160 -125
- package/dist/shims/head.d.ts +10 -6
- package/dist/shims/head.js +16 -14
- package/dist/shims/headers.js +2 -2
- package/dist/shims/image.js +2 -1
- package/dist/shims/internal/hybrid-client-route-owner-direct.js +1 -1
- package/dist/shims/internal/hybrid-client-route-owner.js +1 -0
- package/dist/shims/internal/work-store-scope.d.ts +5 -0
- package/dist/shims/internal/work-store-scope.js +24 -0
- package/dist/shims/link-prefetch.js +5 -4
- package/dist/shims/link.js +2 -2
- package/dist/shims/navigation.js +34 -9
- package/dist/shims/request-context.d.ts +2 -0
- package/dist/shims/request-state-types.d.ts +2 -1
- package/dist/shims/router.js +21 -32
- package/dist/shims/server.d.ts +27 -4
- package/dist/shims/server.js +65 -9
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/url-utils.d.ts +9 -0
- package/dist/shims/url-utils.js +15 -4
- package/dist/utils/client-runtime-metadata.js +1 -1
- package/dist/utils/domain-locale.js +1 -1
- package/dist/utils/hash.d.ts +7 -0
- package/dist/utils/hash.js +11 -1
- package/dist/utils/package-name.d.ts +6 -0
- package/dist/utils/package-name.js +12 -1
- package/dist/utils/plugin-rsc-version.d.ts +6 -0
- package/dist/utils/plugin-rsc-version.js +41 -0
- package/dist/utils/prerender-output-paths.js +15 -4
- package/dist/utils/public-file-path.d.ts +10 -2
- package/dist/utils/public-file-path.js +13 -9
- package/dist/utils/public-routes.js +2 -2
- package/dist/utils/react-version.d.ts +10 -0
- package/dist/utils/react-version.js +39 -16
- package/package.json +11 -7
- package/dist/build/nitro-route-rules.d.ts +0 -47
- package/dist/build/nitro-route-rules.js +0 -79
- package/dist/plugins/cache-flight-codec.d.ts +0 -19
- package/dist/plugins/cache-flight-codec.js +0 -68
|
@@ -25,12 +25,12 @@ import { randomUUID } from "node:crypto";
|
|
|
25
25
|
const DEFAULT_EXPIRE_TIME = 31536e3;
|
|
26
26
|
const DEFAULT_REACT_MAX_HEADERS_LENGTH = 6e3;
|
|
27
27
|
const middlewareRequestHeadersPath = resolveEntryPath("../utils/middleware-request-headers.js", import.meta.url);
|
|
28
|
-
const normalizePathModulePath = resolveEntryPath("../server/normalize-path.js", import.meta.url);
|
|
29
28
|
const appRouteHandlerDispatchPath = resolveEntryPath("../server/app-route-handler-dispatch.js", import.meta.url);
|
|
30
29
|
const appRouteRequestBuiltInsPath = resolveEntryPath("../server/app-route-request-built-ins.js", import.meta.url);
|
|
31
30
|
const appRouteHandlerResponsePath = resolveEntryPath("../server/app-route-handler-response.js", import.meta.url);
|
|
32
31
|
const appRouteHandlerMiddlewareContextPath = resolveEntryPath("../server/app-route-handler-middleware-context.js", import.meta.url);
|
|
33
32
|
const appServerActionExecutionPath = resolveEntryPath("../server/app-server-action-execution.js", import.meta.url);
|
|
33
|
+
const serverReferenceLoaderPath = resolveEntryPath("../server/server-reference-loader.js", import.meta.url);
|
|
34
34
|
const appActionForwardingPath = resolveEntryPath("../server/app-action-forwarding.js", import.meta.url);
|
|
35
35
|
const appMiddlewarePath = resolveEntryPath("../server/app-middleware.js", import.meta.url);
|
|
36
36
|
const metadataRouteResponsePath = resolveEntryPath("../server/metadata-route-response.js", import.meta.url);
|
|
@@ -200,6 +200,7 @@ import { dispatchAppRequestStage as __dispatchAppRequestStage } from ${JSON.stri
|
|
|
200
200
|
import { registerConfiguredCacheAdapters as __registerConfiguredCacheAdapters } from "virtual:vinext-cdn-cache-adapter";
|
|
201
201
|
import { clearAppRequestStageContext as __clearRequestContext, setAppRequestStageNavigationContext as setNavigationContext } from ${JSON.stringify(appRequestStageContextPath)};
|
|
202
202
|
import { matchRoutePattern as __matchRoutePattern } from ${JSON.stringify(routePatternPath)};
|
|
203
|
+
import __pagesClientAssets from "virtual:vinext-pages-client-assets";
|
|
203
204
|
${middlewarePath ? `import { applyAppMiddleware as __applyAppMiddleware } from ${JSON.stringify(appMiddlewarePath)};` : ""}
|
|
204
205
|
${instrumentationPath ? `import * as _instrumentation from ${JSON.stringify(toSlash(instrumentationPath))};
|
|
205
206
|
import { ensureInstrumentationRegistered as __ensureInstrumentationRegistered } from ${JSON.stringify(instrumentationRuntimePath)};
|
|
@@ -216,7 +217,6 @@ ${hasPagesDir ? `import { getDraftModeCookieHeader } from "next/headers";
|
|
|
216
217
|
import * as __pagesRequestEntry from "virtual:vinext-pages-request-entry";
|
|
217
218
|
import { renderPagesFallback as __renderPagesFallback } from ${JSON.stringify(appPagesBridgePath)};
|
|
218
219
|
import { buildRequestHeadersFromMiddlewareResponse as __buildRequestHeadersFromMiddlewareResponse } from ${JSON.stringify(middlewareRequestHeadersPath)};
|
|
219
|
-
import { decodePathParams as __decodePathParams } from ${JSON.stringify(normalizePathModulePath)};
|
|
220
220
|
import { applyRouteHandlerMiddlewareContext as __applyRouteHandlerMiddlewareContext } from ${JSON.stringify(appRouteHandlerMiddlewareContextPath)};` : ""}
|
|
221
221
|
|
|
222
222
|
${hasPagesDir ? `export function __ensureHybridPagesApplication() {
|
|
@@ -238,6 +238,7 @@ export const __imageConfig = ${JSON.stringify({
|
|
|
238
238
|
contentDispositionType: config?.imageConfig?.contentDispositionType,
|
|
239
239
|
contentSecurityPolicy: config?.imageConfig?.contentSecurityPolicy
|
|
240
240
|
})};
|
|
241
|
+
export const __clientBuildFiles = __pagesClientAssets.clientBuildFiles ?? [];
|
|
241
242
|
const __routes = ${JSON.stringify(requestRoutes)};
|
|
242
243
|
const __routeMatcher = __createAppRscRouteMatcher(__routes, ${JSON.stringify(buildAppDecodedPathnamePatterns(routes, config))});
|
|
243
244
|
const __metadataRouteMatchers = ${JSON.stringify(metadataRouteMatchers)};
|
|
@@ -291,6 +292,7 @@ const __requestHandler = createAppRscRequestHandler({
|
|
|
291
292
|
fallback: []
|
|
292
293
|
})},
|
|
293
294
|
draftModeSecret: __draftModeSecret,
|
|
295
|
+
devForwardedMiddlewareContextKey: ${JSON.stringify(config?.devForwardedMiddlewareContextKey ?? null)},
|
|
294
296
|
dispatchMatchedPage() { throw new Error("App request stage attempted to render a page inline"); },
|
|
295
297
|
dispatchMatchedRouteHandler() { throw new Error("App request stage attempted to render a route handler inline"); },
|
|
296
298
|
${instrumentationPath ? "ensureInstrumentation() { return __ensureInstrumentation(); }," : ""}
|
|
@@ -333,6 +335,7 @@ const __requestHandler = createAppRscRequestHandler({
|
|
|
333
335
|
middlewareRequest,
|
|
334
336
|
module: middlewareModule,
|
|
335
337
|
request,
|
|
338
|
+
skipTrailingSlashRedirect: ${JSON.stringify(config?.skipTrailingSlashRedirect ?? false)},
|
|
336
339
|
trailingSlash: __trailingSlash,
|
|
337
340
|
validateExternalRewriteRequest,
|
|
338
341
|
});
|
|
@@ -358,7 +361,6 @@ const __requestHandler = createAppRscRequestHandler({
|
|
|
358
361
|
};
|
|
359
362
|
},
|
|
360
363
|
buildRequestHeaders: __buildRequestHeadersFromMiddlewareResponse,
|
|
361
|
-
decodePathParams: __decodePathParams,
|
|
362
364
|
applyRouteHandlerMiddlewareContext: __applyRouteHandlerMiddlewareContext,
|
|
363
365
|
getDraftModeCookieHeader,
|
|
364
366
|
}
|
|
@@ -366,6 +368,7 @@ const __requestHandler = createAppRscRequestHandler({
|
|
|
366
368
|
},` : ""}
|
|
367
369
|
rootParamNamesByPattern: {},
|
|
368
370
|
setNavigationContext,
|
|
371
|
+
skipTrailingSlashRedirect: ${JSON.stringify(config?.skipTrailingSlashRedirect ?? false)},
|
|
369
372
|
staticParamsMap: {},
|
|
370
373
|
trailingSlash: __trailingSlash,
|
|
371
374
|
validateDevRequestOrigin: __validateDevRequestOrigin,
|
|
@@ -520,14 +523,15 @@ import { registerConfiguredCacheAdapters as __registerConfiguredCacheAdapters }
|
|
|
520
523
|
import __pagesClientAssets from "virtual:vinext-pages-client-assets";
|
|
521
524
|
${actionOwners === void 0 ? `import __vinextActionOwners from ${JSON.stringify(ACTION_OWNER_MANIFEST_ID)};` : ""}
|
|
522
525
|
import { setPagesClientAssets as __setPagesClientAssets } from "vinext/server/pages-client-assets";
|
|
523
|
-
import { decodePathParams as __decodePathParams } from ${JSON.stringify(normalizePathModulePath)};
|
|
524
526
|
import { buildRequestHeadersFromMiddlewareResponse as __buildRequestHeadersFromMiddlewareResponse } from ${JSON.stringify(middlewareRequestHeadersPath)};
|
|
525
527
|
${hasPagesDir ? `import {
|
|
526
528
|
applyRouteHandlerMiddlewareContext as __applyRouteHandlerMiddlewareContext,
|
|
527
529
|
} from ${JSON.stringify(appRouteHandlerResponsePath)};` : ""}
|
|
528
530
|
const __loadAppRouteHandlerDispatch = () => import(${JSON.stringify(appRouteHandlerDispatchPath)});
|
|
529
531
|
${hasServerActions ? `const __loadAppServerActionExecution = () => import(${JSON.stringify(appServerActionExecutionPath)});
|
|
530
|
-
const __loadAppActionForwarding = () => import(${JSON.stringify(appActionForwardingPath)})
|
|
532
|
+
const __loadAppActionForwarding = () => import(${JSON.stringify(appActionForwardingPath)});
|
|
533
|
+
import { isolateServerReferenceLoads as __isolateServerReferenceLoads } from ${JSON.stringify(serverReferenceLoaderPath)};
|
|
534
|
+
__isolateServerReferenceLoads();` : ""}
|
|
531
535
|
${(metadataRoutes?.length ?? 0) > 0 ? `const __loadMetadataRouteResponse = () => import(${JSON.stringify(metadataRouteResponsePath)});` : ""}
|
|
532
536
|
${(metadataRoutes?.length ?? 0) > 0 ? `const __loadFileBasedMetadata = () => import(${JSON.stringify(fileBasedMetadataPath)});
|
|
533
537
|
async function __applyFileBasedMetadata(...args) {
|
|
@@ -578,6 +582,8 @@ import {
|
|
|
578
582
|
SIBLING_PAGE_INTERCEPT_SLOT_KEY as __SIBLING_PAGE_INTERCEPT_SLOT_KEY,
|
|
579
583
|
} from ${JSON.stringify(appRscRouteMatchingPath)};
|
|
580
584
|
import {
|
|
585
|
+
appIsrFallbackShellHtmlKey as __isrFallbackShellHtmlKey,
|
|
586
|
+
appIsrFallbackShellKey as __isrFallbackShellKey,
|
|
581
587
|
appIsrHtmlKey as __isrHtmlKey,
|
|
582
588
|
appIsrRscKey as __isrRscKey,
|
|
583
589
|
appIsrRouteKey as __isrRouteKey,
|
|
@@ -949,6 +955,9 @@ export async function seedMemoryCacheFromPrerender(serverDir) {
|
|
|
949
955
|
buildAppPageHtmlKey(pathname) {
|
|
950
956
|
return __isrHtmlKey(pathname);
|
|
951
957
|
},
|
|
958
|
+
buildAppPageFallbackShellKey(pathname, suffix) {
|
|
959
|
+
return __isrFallbackShellKey(pathname, suffix);
|
|
960
|
+
},
|
|
952
961
|
buildAppPageRscKey(pathname) {
|
|
953
962
|
return __isrRscKey(pathname);
|
|
954
963
|
},
|
|
@@ -993,6 +1002,7 @@ ${rootParamNameEntries.join("\n")}
|
|
|
993
1002
|
};
|
|
994
1003
|
|
|
995
1004
|
__setPagesClientAssets(__pagesClientAssets);
|
|
1005
|
+
export const __clientBuildFiles = __pagesClientAssets.clientBuildFiles ?? [];
|
|
996
1006
|
function __VINEXT_ACTION_OWNERS() { return ${actionOwners === void 0 ? "__vinextActionOwners" : safeJsonStringify(actionOwners)}; }
|
|
997
1007
|
${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandler = createAppRscHandler({"}
|
|
998
1008
|
assetPrefix: __assetPrefix,
|
|
@@ -1013,6 +1023,7 @@ ${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandle
|
|
|
1013
1023
|
imageConfig: __runtimeImageConfig,
|
|
1014
1024
|
isDev: process.env.NODE_ENV !== "production",
|
|
1015
1025
|
draftModeSecret: __draftModeSecret,
|
|
1026
|
+
devForwardedMiddlewareContextKey: ${JSON.stringify(config?.devForwardedMiddlewareContextKey ?? null)},
|
|
1016
1027
|
dispatchMatchedPage({
|
|
1017
1028
|
bypassInterceptionContextCache,
|
|
1018
1029
|
cachePathname,
|
|
@@ -1136,6 +1147,7 @@ ${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandle
|
|
|
1136
1147
|
isRscRequest,
|
|
1137
1148
|
isrDebug: __isrDebug,
|
|
1138
1149
|
isrGet: __isrGet,
|
|
1150
|
+
isrFallbackShellHtmlKey: __isrFallbackShellHtmlKey,
|
|
1139
1151
|
isrHtmlKey(pathname) {
|
|
1140
1152
|
return __isrHtmlKey(pathname === cleanPathname ? cachePathname : pathname);
|
|
1141
1153
|
},
|
|
@@ -1254,6 +1266,7 @@ ${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandle
|
|
|
1254
1266
|
draftModeSecret: __draftModeSecret,
|
|
1255
1267
|
i18n: __i18nConfig,
|
|
1256
1268
|
trailingSlash: __trailingSlash,
|
|
1269
|
+
skipTrailingSlashRedirect: ${JSON.stringify(config?.skipTrailingSlashRedirect ?? false)},
|
|
1257
1270
|
isrDebug: __isrDebug,
|
|
1258
1271
|
isrGet: __isrGet,
|
|
1259
1272
|
isrRouteKey(pathname) {
|
|
@@ -1617,6 +1630,7 @@ ${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandle
|
|
|
1617
1630
|
middlewareRequest,
|
|
1618
1631
|
module: middlewareModule,
|
|
1619
1632
|
request,
|
|
1633
|
+
skipTrailingSlashRedirect: ${JSON.stringify(config?.skipTrailingSlashRedirect ?? false)},
|
|
1620
1634
|
trailingSlash: __trailingSlash,
|
|
1621
1635
|
validateExternalRewriteRequest,
|
|
1622
1636
|
});
|
|
@@ -1655,7 +1669,6 @@ ${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandle
|
|
|
1655
1669
|
};
|
|
1656
1670
|
},
|
|
1657
1671
|
buildRequestHeaders: __buildRequestHeadersFromMiddlewareResponse,
|
|
1658
|
-
decodePathParams: __decodePathParams,
|
|
1659
1672
|
applyRouteHandlerMiddlewareContext: __applyRouteHandlerMiddlewareContext,
|
|
1660
1673
|
getDraftModeCookieHeader,
|
|
1661
1674
|
}
|
|
@@ -1663,6 +1676,7 @@ ${responseStageOnly ? "const __responseStageOptions = {" : "const __appRscHandle
|
|
|
1663
1676
|
},` : ""}
|
|
1664
1677
|
rootParamNamesByPattern: rootParamNamesMap,
|
|
1665
1678
|
setNavigationContext,
|
|
1679
|
+
skipTrailingSlashRedirect: ${JSON.stringify(config?.skipTrailingSlashRedirect ?? false)},
|
|
1666
1680
|
staticParamsMap: generateStaticParamsMap,
|
|
1667
1681
|
trailingSlash: __trailingSlash,
|
|
1668
1682
|
validateDevRequestOrigin: __validateDevRequestOrigin,
|
|
@@ -6,6 +6,7 @@ import { resolveClientRuntimeModule } from "./runtime-entry-module.js";
|
|
|
6
6
|
import { compileMiddlewareMatcherPattern } from "../server/middleware-matcher-pattern.js";
|
|
7
7
|
import { hasExportedName } from "../build/report.js";
|
|
8
8
|
import { toClientRewrites } from "../client/client-rewrites.js";
|
|
9
|
+
import { toClientRedirects } from "../client/client-redirects.js";
|
|
9
10
|
import { readFile } from "node:fs/promises";
|
|
10
11
|
//#region src/entries/pages-client-entry.ts
|
|
11
12
|
/**
|
|
@@ -67,6 +68,7 @@ async function generateClientEntry(pagesDir, nextConfig, fileMatcher, options =
|
|
|
67
68
|
const pagesSsgPatterns = (await Promise.all(pageRoutes.map(async (route) => await hasGetStaticPropsExport(route.filePath) ? patternToNextFormat(route.pattern) : null))).filter((pattern) => pattern !== null);
|
|
68
69
|
const pagesSspPatterns = (await Promise.all(pageRoutes.map(async (route) => await hasGetServerSidePropsExport(route.filePath) ? patternToNextFormat(route.pattern) : null))).filter((pattern) => pattern !== null);
|
|
69
70
|
const instrumentationClientPath = options.instrumentationClientPath ?? null;
|
|
71
|
+
const clientRedirects = toClientRedirects(nextConfig.redirects);
|
|
70
72
|
const clientRewrites = toClientRewrites(nextConfig.rewrites);
|
|
71
73
|
const clientMiddlewareMatchers = compileClientMiddlewareMatchers(options.middlewareMatcher);
|
|
72
74
|
const reactInstanceBootstrapPath = resolveClientRuntimeModule("react-instance-bootstrap");
|
|
@@ -140,7 +142,7 @@ window.__VINEXT_LINK_PREFETCH_ROUTES__ = ${JSON.stringify(appPrefetchRoutes)};
|
|
|
140
142
|
// instead of issuing an RSC request). Set here AND in app-browser-entry.ts
|
|
141
143
|
// so whichever entry runs first emits the Pages manifest.
|
|
142
144
|
window.__VINEXT_PAGES_LINK_PREFETCH_ROUTES__ = ${JSON.stringify(pagesPrefetchRoutes)};
|
|
143
|
-
window.__VINEXT_CLIENT_REDIRECTS__ = ${JSON.stringify(
|
|
145
|
+
window.__VINEXT_CLIENT_REDIRECTS__ = ${JSON.stringify(clientRedirects)};
|
|
144
146
|
window.__VINEXT_CLIENT_REWRITES__ = ${JSON.stringify(clientRewrites)};
|
|
145
147
|
|
|
146
148
|
const nextDataElement = document.getElementById("__NEXT_DATA__");
|
|
@@ -57,6 +57,7 @@ async function generatePagesRequestEntry(pagesDir, nextConfig, fileMatcher, midd
|
|
|
57
57
|
basePath: nextConfig?.basePath ?? "",
|
|
58
58
|
assetPrefix: nextConfig?.assetPrefix ?? "",
|
|
59
59
|
trailingSlash: nextConfig?.trailingSlash ?? false,
|
|
60
|
+
skipTrailingSlashRedirect: nextConfig?.skipTrailingSlashRedirect ?? false,
|
|
60
61
|
skipProxyUrlNormalize: nextConfig?.skipProxyUrlNormalize ?? false,
|
|
61
62
|
redirects: nextConfig?.redirects ?? [],
|
|
62
63
|
rewrites: nextConfig?.rewrites ?? {
|
|
@@ -102,9 +103,11 @@ export function __ensureInstrumentation() {
|
|
|
102
103
|
filePath: ${JSON.stringify(middlewarePath)},
|
|
103
104
|
i18nConfig,
|
|
104
105
|
isDataRequest: options?.isDataRequest === true,
|
|
106
|
+
isStaleDataRequest: options?.isStaleDataRequest === true,
|
|
105
107
|
isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},
|
|
106
108
|
module: middlewareModule,
|
|
107
109
|
request,
|
|
110
|
+
skipTrailingSlashRedirect: vinextConfig.skipTrailingSlashRedirect,
|
|
108
111
|
trailingSlash: vinextConfig.trailingSlash,
|
|
109
112
|
});
|
|
110
113
|
}` : `export async function runMiddleware() {
|
|
@@ -118,6 +121,7 @@ import { buildRouteTrie as _buildRouteTrie, trieMatch as _trieMatch } from ${JSO
|
|
|
118
121
|
import { resolvePagesI18nRequest } from ${JSON.stringify(_pagesI18nPath)};
|
|
119
122
|
import { normalizePagesDataRequest as __normalizePagesDataRequest, shouldAddTrailingSlashToPagesDataPath as __shouldAddTrailingSlashToPagesDataPath } from ${JSON.stringify(_pagesDataRoutePath)};
|
|
120
123
|
import { isOnDemandRevalidateRequest as __isOnDemandRevalidateRequest } from ${JSON.stringify(_revalidationRequestPath)};
|
|
124
|
+
import __pagesClientAssets from "virtual:vinext-pages-client-assets";
|
|
121
125
|
${instrumentationImportCode}
|
|
122
126
|
|
|
123
127
|
${instrumentationInitCode}
|
|
@@ -131,6 +135,7 @@ export const hasMiddleware = ${JSON.stringify(Boolean(middlewarePath))};
|
|
|
131
135
|
export const hasRequestAwareDocument = ${JSON.stringify(hasRequestAwareDocument)};
|
|
132
136
|
export const vinextConfig = ${vinextConfigJson};
|
|
133
137
|
export const publicFiles = new Set(${JSON.stringify(publicFiles)});
|
|
138
|
+
export const clientBuildFiles = new Set(__pagesClientAssets.clientBuildFiles ?? []);
|
|
134
139
|
|
|
135
140
|
export function normalizeDataRequest(request) {
|
|
136
141
|
return __normalizePagesDataRequest(
|
|
@@ -227,6 +232,7 @@ async function generateServerEntry(pagesDir, nextConfig, fileMatcher, middleware
|
|
|
227
232
|
basePath: nextConfig?.basePath ?? "",
|
|
228
233
|
assetPrefix: nextConfig?.assetPrefix ?? "",
|
|
229
234
|
trailingSlash: nextConfig?.trailingSlash ?? false,
|
|
235
|
+
skipTrailingSlashRedirect: nextConfig?.skipTrailingSlashRedirect ?? false,
|
|
230
236
|
skipProxyUrlNormalize: nextConfig?.skipProxyUrlNormalize ?? false,
|
|
231
237
|
redirects: nextConfig?.redirects ?? [],
|
|
232
238
|
rewrites: nextConfig?.rewrites ?? {
|
|
@@ -292,9 +298,11 @@ export async function runMiddleware(request, ctx, options) {
|
|
|
292
298
|
filePath: ${JSON.stringify(middlewarePath)},
|
|
293
299
|
i18nConfig,
|
|
294
300
|
isDataRequest: options?.isDataRequest === true,
|
|
301
|
+
isStaleDataRequest: options?.isStaleDataRequest === true,
|
|
295
302
|
isProxy: ${JSON.stringify(isProxyFile(middlewarePath))},
|
|
296
303
|
module: middlewareModule,
|
|
297
304
|
request,
|
|
305
|
+
skipTrailingSlashRedirect: vinextConfig.skipTrailingSlashRedirect,
|
|
298
306
|
trailingSlash: vinextConfig.trailingSlash,
|
|
299
307
|
});
|
|
300
308
|
}
|
|
@@ -311,16 +319,16 @@ import { renderToReadableStream } from "react-dom/server.edge";
|
|
|
311
319
|
import { resetSSRHead, getSSRHeadHTML, setDocumentInitialHead } from "next/head";
|
|
312
320
|
import { flushPreloads } from "next/dynamic";
|
|
313
321
|
import Router, { setSSRContext, wrapWithRouterContext, getPagesNavigationIsReadyFromSerializedState } from "next/router";
|
|
314
|
-
import
|
|
322
|
+
import "vinext/shims/cache-request-state";
|
|
315
323
|
import { configureMemoryCacheHandler as __configureMemoryCacheHandler } from "vinext/shims/cache-handler";
|
|
316
324
|
import { registerConfiguredCacheAdapters as __registerConfiguredCacheAdapters } from "virtual:vinext-cache-adapters";
|
|
317
325
|
import __pagesClientAssets from "virtual:vinext-pages-client-assets";
|
|
318
326
|
import { setPagesClientAssets as __setPagesClientAssets } from "vinext/server/pages-client-assets";
|
|
319
|
-
import
|
|
320
|
-
import { ensureFetchPatch
|
|
327
|
+
import "vinext/cache-runtime";
|
|
328
|
+
import { ensureFetchPatch } from "vinext/fetch-cache";
|
|
321
329
|
import "vinext/router-state";
|
|
322
|
-
import
|
|
323
|
-
import
|
|
330
|
+
import "vinext/navigation-state";
|
|
331
|
+
import "vinext/head-state";
|
|
324
332
|
import "vinext/i18n-state";
|
|
325
333
|
import { setI18nContext } from "vinext/i18n-context";
|
|
326
334
|
import { safeJsonStringify } from "vinext/html";
|
|
@@ -388,37 +396,6 @@ __configureMemoryCacheHandler({ cacheMaxMemorySize: vinextConfig.cacheMaxMemoryS
|
|
|
388
396
|
// by _app are included in every page's <link rel="stylesheet"> set.
|
|
389
397
|
const _appAssetPath = ${appAssetPathJson};
|
|
390
398
|
|
|
391
|
-
async function _renderToStringAsync(element) {
|
|
392
|
-
const stream = await renderToReadableStream(element);
|
|
393
|
-
await stream.allReady;
|
|
394
|
-
return new Response(stream).text();
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
async function _renderIsrPassToStringAsync(element, onHeadReady) {
|
|
398
|
-
// The cache-fill render is a second render pass for the same request.
|
|
399
|
-
// Reset render-scoped state so it cannot leak from the streamed response
|
|
400
|
-
// render or affect async work that is still draining from that stream.
|
|
401
|
-
// Keep request identity state (pathname/query/locale/executionContext)
|
|
402
|
-
// intact: this second pass still belongs to the same request.
|
|
403
|
-
return await runWithServerInsertedHTMLState(() =>
|
|
404
|
-
runWithHeadState(() =>
|
|
405
|
-
_runWithCacheState(() =>
|
|
406
|
-
runWithPrivateCache(() =>
|
|
407
|
-
runWithFetchCache(async () => {
|
|
408
|
-
const html = await _renderToStringAsync(element);
|
|
409
|
-
// next/head tags are collected as a side effect of the render
|
|
410
|
-
// above and live in this ALS scope only, so a caller that wants
|
|
411
|
-
// the regenerated head has to read it here — after the render,
|
|
412
|
-
// before the scope unwinds.
|
|
413
|
-
await onHeadReady?.();
|
|
414
|
-
return html;
|
|
415
|
-
}),
|
|
416
|
-
),
|
|
417
|
-
),
|
|
418
|
-
),
|
|
419
|
-
);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
399
|
${pageImports.join("\n")}
|
|
423
400
|
${apiImports.join("\n")}
|
|
424
401
|
|
|
@@ -552,7 +529,6 @@ function __createRenderPage() {
|
|
|
552
529
|
} catch { return []; }
|
|
553
530
|
},
|
|
554
531
|
renderToReadableStream,
|
|
555
|
-
renderIsrPassToStringAsync: _renderIsrPassToStringAsync,
|
|
556
532
|
safeJsonStringify,
|
|
557
533
|
sanitizeDestination: sanitizeDestinationLocal,
|
|
558
534
|
createPageElement(PageComponent, AppComponent, props) {
|
package/dist/index.d.ts
CHANGED
|
@@ -39,7 +39,9 @@ export type VinextOptions = {
|
|
|
39
39
|
ssrOutDir?: string;
|
|
40
40
|
/**
|
|
41
41
|
* Override the output directory for the client bundle.
|
|
42
|
-
* Defaults to
|
|
42
|
+
* Defaults to "dist/client". Like rscOutDir and ssrOutDir, it is not
|
|
43
|
+
* supported by `vinext start` or `output: "standalone"`, which expect the
|
|
44
|
+
* default dist/ layout.
|
|
43
45
|
*/
|
|
44
46
|
clientOutDir?: string;
|
|
45
47
|
/**
|