vinext 1.0.1 → 1.2.0
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 +93 -10
- package/dist/build/app-page-static-eligibility.d.ts +15 -0
- package/dist/build/app-page-static-eligibility.js +82 -0
- package/dist/build/client-build-config.d.ts +10 -0
- package/dist/build/client-build-config.js +18 -2
- 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 +8 -81
- package/dist/build/prerender.js +33 -8
- package/dist/build/run-prerender.js +1 -1
- package/dist/build/server-manifest.d.ts +7 -0
- package/dist/build/server-manifest.js +11 -1
- package/dist/build/ssr-manifest.d.ts +2 -0
- package/dist/build/ssr-manifest.js +6 -2
- package/dist/cache/cache-adapters-virtual.d.ts +7 -1
- package/dist/cache/cache-adapters-virtual.js +3 -3
- package/dist/check.js +7 -6
- package/dist/cli.js +2 -1
- 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/client/navigation-runtime.d.ts +11 -0
- package/dist/client/navigation-runtime.js +1 -1
- package/dist/config/config-matchers.d.ts +26 -11
- package/dist/config/config-matchers.js +81 -82
- package/dist/config/destination-params.d.ts +47 -0
- package/dist/config/destination-params.js +116 -0
- package/dist/config/next-config.d.ts +14 -0
- package/dist/config/next-config.js +21 -3
- package/dist/entries/app-rsc-entry.d.ts +6 -0
- package/dist/entries/app-rsc-entry.js +84 -49
- package/dist/entries/pages-client-entry.js +3 -1
- package/dist/entries/pages-server-entry.js +13 -37
- package/dist/index.d.ts +7 -2
- package/dist/index.js +193 -73
- 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 +1 -0
- package/dist/init.js +67 -3
- package/dist/plugins/ast-scope.d.ts +7 -0
- package/dist/plugins/ast-scope.js +59 -3
- package/dist/plugins/cache-flight-codec.d.ts +19 -0
- package/dist/plugins/cache-flight-codec.js +68 -0
- package/dist/plugins/commonjs-esm-facade.d.ts +35 -0
- package/dist/plugins/commonjs-esm-facade.js +80 -0
- package/dist/plugins/dynamic-preload-metadata.d.ts +1 -1
- package/dist/plugins/dynamic-preload-metadata.js +9 -8
- package/dist/plugins/fonts.d.ts +8 -11
- package/dist/plugins/fonts.js +71 -34
- package/dist/plugins/ignore-dynamic-requests.d.ts +1 -1
- package/dist/plugins/ignore-dynamic-requests.js +3 -4
- package/dist/plugins/middleware-server-only.d.ts +5 -4
- package/dist/plugins/middleware-server-only.js +8 -5
- package/dist/plugins/pages-node-externals.js +1 -1
- 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 +262 -98
- 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.js +8 -2
- 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 +129 -0
- package/dist/routing/file-matcher.d.ts +1 -0
- package/dist/routing/file-matcher.js +1 -1
- package/dist/server/api-handler.d.ts +1 -0
- package/dist/server/api-handler.js +19 -8
- 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 +11 -7
- package/dist/server/app-browser-history-controller.d.ts +2 -0
- package/dist/server/app-browser-history-controller.js +8 -0
- package/dist/server/app-browser-interception-context.js +26 -2
- package/dist/server/app-browser-navigation-controller.d.ts +7 -1
- package/dist/server/app-browser-navigation-controller.js +94 -11
- package/dist/server/app-browser-server-action-client.js +1 -1
- package/dist/server/app-fallback-renderer.d.ts +2 -0
- package/dist/server/app-fallback-renderer.js +1 -0
- package/dist/server/app-history-state.d.ts +3 -0
- package/dist/server/app-history-state.js +7 -0
- package/dist/server/app-middleware.d.ts +11 -0
- package/dist/server/app-middleware.js +19 -3
- package/dist/server/app-optimistic-routing.js +1 -1
- package/dist/server/app-page-boundary-render.d.ts +5 -0
- package/dist/server/app-page-boundary-render.js +6 -4
- package/dist/server/app-page-cache-finalizer.d.ts +11 -0
- package/dist/server/app-page-cache-finalizer.js +41 -7
- package/dist/server/app-page-cache-render.d.ts +18 -0
- package/dist/server/app-page-cache-render.js +63 -43
- package/dist/server/app-page-cache.d.ts +6 -1
- package/dist/server/app-page-cache.js +28 -8
- package/dist/server/app-page-dispatch.d.ts +12 -2
- package/dist/server/app-page-dispatch.js +51 -33
- package/dist/server/app-page-element-builder.d.ts +7 -0
- package/dist/server/app-page-element-builder.js +27 -42
- package/dist/server/app-page-execution.d.ts +15 -12
- package/dist/server/app-page-execution.js +30 -40
- package/dist/server/app-page-head.d.ts +5 -0
- package/dist/server/app-page-head.js +9 -3
- package/dist/server/app-page-ppr-runtime.js +1 -1
- package/dist/server/app-page-probe.d.ts +0 -109
- package/dist/server/app-page-probe.js +3 -136
- package/dist/server/app-page-render-identity.d.ts +0 -1
- package/dist/server/app-page-render-identity.js +1 -1
- package/dist/server/app-page-render-observation.js +3 -3
- package/dist/server/app-page-render.d.ts +13 -5
- package/dist/server/app-page-render.js +219 -119
- package/dist/server/app-page-request.d.ts +0 -1
- package/dist/server/app-page-request.js +54 -17
- package/dist/server/app-page-response.d.ts +4 -3
- package/dist/server/app-page-response.js +4 -3
- package/dist/server/app-page-route-wiring.d.ts +17 -5
- package/dist/server/app-page-route-wiring.js +57 -35
- package/dist/server/app-page-rsc-render-status.d.ts +48 -0
- package/dist/server/app-page-rsc-render-status.js +54 -0
- package/dist/server/app-page-stream.d.ts +15 -8
- package/dist/server/app-page-stream.js +6 -0
- package/dist/server/app-pages-bridge.d.ts +1 -1
- package/dist/server/app-pages-bridge.js +2 -3
- package/dist/server/app-prerender-endpoints.js +9 -6
- package/dist/server/app-request-stage-dispatch.js +7 -3
- package/dist/server/app-request-stage-independent-entry.js +29 -9
- package/dist/server/app-response-header-provenance.d.ts +2 -0
- package/dist/server/app-response-header-provenance.js +10 -4
- package/dist/server/app-response-stage-entry.js +10 -2
- 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 +6 -3
- 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 +45 -24
- package/dist/server/app-router-entry.js +27 -8
- package/dist/server/app-rsc-cache-busting.js +1 -1
- package/dist/server/app-rsc-errors.js +20 -16
- package/dist/server/app-rsc-handler.d.ts +11 -0
- package/dist/server/app-rsc-handler.js +291 -125
- package/dist/server/app-rsc-request-normalization.d.ts +3 -1
- package/dist/server/app-rsc-request-normalization.js +4 -2
- package/dist/server/app-rsc-response-stage.d.ts +1 -1
- package/dist/server/app-rsc-response-stage.js +10 -6
- package/dist/server/app-rsc-route-matching.d.ts +9 -1
- package/dist/server/app-rsc-route-matching.js +36 -19
- 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.d.ts +3 -2
- package/dist/server/app-ssr-entry.js +8 -5
- package/dist/server/app-ssr-stream.d.ts +6 -1
- package/dist/server/app-ssr-stream.js +34 -15
- package/dist/server/app-worker-stages.d.ts +7 -2
- package/dist/server/app-worker-stages.js +4 -4
- package/dist/server/cacheability-request.js +11 -7
- 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 +2 -0
- package/dist/server/dev-server.js +50 -29
- 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 +18 -1
- package/dist/server/headers.js +19 -2
- 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 +54 -0
- package/dist/server/image-optimization.js +118 -9
- package/dist/server/isr-cache.d.ts +10 -0
- package/dist/server/isr-cache.js +43 -8
- package/dist/server/metadata-route-response.js +9 -8
- package/dist/server/middleware-matcher-pattern.js +8 -4
- package/dist/server/middleware-matcher.d.ts +2 -0
- package/dist/server/middleware-matcher.js +23 -2
- package/dist/server/middleware-response-headers.js +2 -0
- package/dist/server/middleware-runtime.d.ts +13 -0
- package/dist/server/middleware-runtime.js +33 -20
- package/dist/server/middleware.d.ts +1 -1
- package/dist/server/middleware.js +3 -1
- package/dist/server/multi-stage.d.ts +19 -0
- package/dist/server/navigation-planner.js +1 -1
- package/dist/server/node-response-signal.d.ts +16 -0
- package/dist/server/node-response-signal.js +26 -0
- package/dist/server/normalize-path.d.ts +0 -13
- package/dist/server/normalize-path.js +1 -34
- package/dist/server/open-redirect.d.ts +47 -0
- package/dist/server/open-redirect.js +74 -1
- package/dist/server/pages-api-route.d.ts +3 -2
- package/dist/server/pages-api-route.js +4 -3
- 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 +19 -2
- 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 +50 -120
- package/dist/server/pages-page-handler.d.ts +0 -6
- package/dist/server/pages-page-handler.js +209 -130
- package/dist/server/pages-page-response.d.ts +12 -6
- package/dist/server/pages-page-response.js +41 -34
- package/dist/server/pages-request-pipeline.d.ts +10 -2
- package/dist/server/pages-request-pipeline.js +37 -18
- package/dist/server/pages-request-stage-entry.d.ts +6 -0
- package/dist/server/pages-request-stage-entry.js +79 -16
- package/dist/server/pages-response-stage-entry.js +4 -0
- package/dist/server/pages-revalidate.js +1 -1
- package/dist/server/pages-router-entry.js +4 -3
- 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 +20 -7
- package/dist/server/prod-server.js +343 -129
- package/dist/server/proper-error.d.ts +4 -0
- package/dist/server/proper-error.js +31 -0
- package/dist/server/request-pipeline.d.ts +24 -9
- package/dist/server/request-pipeline.js +24 -9
- package/dist/server/response-compression.d.ts +43 -0
- package/dist/server/response-compression.js +111 -0
- package/dist/server/revalidation-request.d.ts +1 -0
- package/dist/server/revalidation-request.js +1 -1
- package/dist/server/rsc-stream-hints.js +31 -2
- package/dist/server/seed-cache.d.ts +1 -0
- package/dist/server/seed-cache.js +15 -11
- 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 +23 -1
- package/dist/server/socket-error-backstop.js +69 -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 +86 -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-adapter-instantiate.d.ts +50 -0
- package/dist/shims/cache-adapter-instantiate.js +118 -0
- package/dist/shims/cache-callable-runtime.d.ts +6 -42
- package/dist/shims/cache-callable-runtime.js +65 -174
- package/dist/shims/cache-flight-arguments.d.ts +22 -0
- package/dist/shims/cache-flight-arguments.js +56 -0
- package/dist/shims/cache-handler.js +1 -9
- package/dist/shims/cache-request-state.d.ts +15 -0
- package/dist/shims/cache-request-state.js +31 -8
- package/dist/shims/cache-runtime.d.ts +12 -20
- package/dist/shims/cache-runtime.js +166 -225
- package/dist/shims/cache.d.ts +4 -4
- package/dist/shims/cache.js +44 -16
- package/dist/shims/cacheability-classification.d.ts +7 -0
- 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/error-boundary-navigation.d.ts +7 -0
- package/dist/shims/error-boundary-navigation.js +19 -1
- package/dist/shims/error-boundary.d.ts +10 -10
- package/dist/shims/error-boundary.js +26 -7
- 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 -61
- package/dist/shims/fetch-cache.js +161 -108
- package/dist/shims/form.js +1 -1
- package/dist/shims/head.d.ts +10 -6
- package/dist/shims/head.js +15 -13
- package/dist/shims/headers.d.ts +13 -0
- package/dist/shims/headers.js +47 -4
- package/dist/shims/image.js +2 -1
- package/dist/shims/internal/app-page-props-cache-key.d.ts +5 -2
- package/dist/shims/internal/app-page-props-cache-key.js +24 -15
- package/dist/shims/internal/headers-state.d.ts +0 -1
- package/dist/shims/internal/work-store-scope.d.ts +5 -0
- package/dist/shims/internal/work-store-scope.js +24 -0
- package/dist/shims/metadata.js +3 -3
- package/dist/shims/navigation-errors.d.ts +6 -0
- package/dist/shims/navigation-errors.js +11 -1
- package/dist/shims/navigation.d.ts +7 -0
- package/dist/shims/navigation.js +45 -9
- package/dist/shims/request-context.d.ts +11 -0
- package/dist/shims/request-state-types.d.ts +2 -1
- package/dist/shims/router.js +12 -20
- package/dist/shims/server.d.ts +16 -0
- package/dist/shims/server.js +24 -4
- package/dist/shims/thenable-params.d.ts +4 -0
- package/dist/shims/thenable-params.js +25 -3
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +1 -0
- package/dist/shims/url-utils.d.ts +2 -0
- package/dist/shims/url-utils.js +3 -1
- package/dist/utils/client-runtime-metadata.js +1 -1
- package/dist/utils/hash.d.ts +7 -0
- package/dist/utils/hash.js +11 -1
- package/dist/utils/mdx-scan.d.ts +5 -0
- package/dist/utils/mdx-scan.js +8 -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 +4 -0
- package/dist/utils/plugin-rsc-version.js +15 -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 +3 -0
- package/dist/utils/react-version.js +1 -1
- package/dist/utils/regex-safety.d.ts +10 -0
- package/dist/utils/regex-safety.js +70 -18
- package/package.json +9 -5
|
@@ -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
|
/**
|
|
@@ -106,7 +108,10 @@ export type VinextOptions = {
|
|
|
106
108
|
* Configure cache handlers declaratively, so you don't need a custom worker
|
|
107
109
|
* entry that calls `setDataCacheHandler()` / `setCdnCacheAdapter()`. Each slot
|
|
108
110
|
* is a `{ adapter, options }` descriptor pointing at an adapter module whose
|
|
109
|
-
* default export is a factory
|
|
111
|
+
* default export is a factory function or a class; either receives one
|
|
112
|
+
* `{ env, options }` argument (classes are invoked with `new`, other
|
|
113
|
+
* functions are called; see `CacheAdapterDescriptor.adapter` for how
|
|
114
|
+
* classes are recognised). The plugin registers them automatically on the
|
|
110
115
|
* first request, passing the host `env` (Worker bindings) so adapters that
|
|
111
116
|
* need a binding — e.g. a KV namespace — can read it.
|
|
112
117
|
*
|