vinext 0.2.1 → 1.0.0-beta.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 +67 -30
- package/dist/build/assets-ignore.js +1 -1
- package/dist/build/clean-output.js +1 -1
- package/dist/build/client-build-config.d.ts +13 -92
- package/dist/build/client-build-config.js +23 -99
- package/dist/build/css-url-assets.js +3 -3
- package/dist/build/google-fonts/fallback-metrics.js +1 -1
- package/dist/build/google-fonts/font-metadata.js +1 -1
- package/dist/build/inject-pregenerated-paths.js +1 -1
- package/dist/build/inline-css.js +2 -5
- package/dist/build/module-dependency-cache.d.ts +4 -0
- package/dist/build/module-dependency-cache.js +13 -0
- package/dist/build/next-client-runtime-manifests.js +1 -1
- package/dist/build/pages-client-assets-module.js +1 -1
- package/dist/build/precompress.js +7 -7
- package/dist/build/prerender-paths.d.ts +23 -0
- package/dist/build/prerender-paths.js +291 -0
- package/dist/build/prerender-server-pool.js +2 -2
- package/dist/build/prerender.d.ts +12 -1
- package/dist/build/prerender.js +2 -2
- package/dist/build/preview-credentials.d.ts +11 -0
- package/dist/build/preview-credentials.js +19 -0
- package/dist/build/report.d.ts +0 -3
- package/dist/build/report.js +2 -4
- package/dist/build/run-prerender.d.ts +2 -11
- package/dist/build/run-prerender.js +2 -10
- package/dist/build/server-manifest.js +1 -1
- package/dist/build/ssr-manifest.d.ts +4 -0
- package/dist/build/ssr-manifest.js +10 -6
- package/dist/build/standalone.js +37 -37
- package/dist/cache/cache-adapters-virtual.d.ts +7 -17
- package/dist/cache/cache-adapters-virtual.js +35 -2
- package/dist/check.d.ts +0 -16
- package/dist/check.js +17 -34
- package/dist/cli.js +86 -101
- package/dist/client/instrumentation-client-inject.js +1 -1
- package/dist/client/pages-router-link-navigation.js +1 -1
- package/dist/config/config-matchers.js +2 -2
- package/dist/config/dotenv.js +1 -1
- package/dist/config/next-config.d.ts +4 -1
- package/dist/config/next-config.js +82 -16
- package/dist/config/prerender.d.ts +12 -2
- package/dist/config/prerender.js +22 -12
- package/dist/config/server-external-packages.js +1 -1
- package/dist/config/tsconfig-paths.js +7 -3
- package/dist/{node_modules/.pnpm/am-i-vibing@0.5.0/node_modules → deps/.pnpm/am-i-vibing@0.5.0/deps}/am-i-vibing/dist/detector-1yx2Hoe0.js +2 -2
- package/dist/deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js +50 -0
- package/dist/entries/app-rsc-entry.js +12 -5
- package/dist/entries/app-rsc-manifest.js +4 -4
- package/dist/entries/pages-client-entry.js +6 -5
- package/dist/entries/pages-server-entry.js +15 -26
- package/dist/entries/runtime-entry-module.js +2 -2
- package/dist/image/image-adapters-virtual.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +500 -338
- package/dist/init-cloudflare.js +13 -4
- package/dist/init-platform.d.ts +10 -1
- package/dist/init-platform.js +79 -13
- package/dist/init.d.ts +11 -3
- package/dist/init.js +133 -35
- package/dist/plugins/ast-utils.js +1 -1
- package/dist/plugins/dynamic-preload-metadata.js +7 -7
- package/dist/plugins/extensionless-dynamic-import.js +1 -1
- package/dist/plugins/fonts.js +3 -3
- package/dist/plugins/ignore-dynamic-requests.js +13 -8
- package/dist/plugins/import-meta-url.js +16 -17
- package/dist/plugins/middleware-export-validation.js +1 -1
- package/dist/plugins/middleware-server-only.js +2 -2
- package/dist/plugins/og-asset-ownership.js +7 -6
- package/dist/plugins/og-assets.js +4 -5
- package/dist/plugins/optimize-imports.js +12 -13
- package/dist/plugins/postcss.js +1 -1
- package/dist/plugins/remove-console.js +1 -1
- package/dist/plugins/require-context.js +1 -1
- package/dist/plugins/sass.js +2 -2
- package/dist/plugins/server-externals-manifest.js +1 -1
- package/dist/plugins/strip-server-exports.js +1 -1
- package/dist/plugins/styled-jsx.js +3 -2
- package/dist/plugins/typeof-window.js +1 -1
- package/dist/routing/app-route-graph.d.ts +3 -10
- package/dist/routing/app-route-graph.js +28 -76
- package/dist/routing/app-router.d.ts +0 -5
- package/dist/routing/app-router.js +0 -5
- package/dist/routing/file-matcher.d.ts +2 -6
- package/dist/routing/file-matcher.js +10 -11
- package/dist/routing/pages-router.js +3 -3
- package/dist/server/api-handler.js +41 -33
- package/dist/server/app-browser-entry.js +15 -11
- package/dist/server/app-browser-navigation-controller.js +9 -4
- package/dist/server/app-browser-server-action-client.js +1 -1
- package/dist/server/app-elements-wire.d.ts +2 -1
- package/dist/server/app-fallback-renderer.d.ts +8 -0
- package/dist/server/app-fallback-renderer.js +13 -1
- package/dist/server/app-layout-param-observation.d.ts +1 -1
- package/dist/server/app-page-boundary-render.d.ts +14 -1
- package/dist/server/app-page-boundary-render.js +107 -54
- package/dist/server/app-page-cache-render.d.ts +1 -1
- package/dist/server/app-page-dispatch.d.ts +2 -1
- package/dist/server/app-page-dispatch.js +29 -40
- package/dist/server/app-page-element-builder.d.ts +2 -1
- package/dist/server/app-page-element-builder.js +3 -3
- package/dist/server/app-page-execution.d.ts +3 -1
- package/dist/server/app-page-execution.js +31 -39
- package/dist/server/app-page-render.d.ts +1 -1
- package/dist/server/app-page-request.js +1 -1
- package/dist/server/app-page-route-wiring.js +4 -4
- package/dist/server/app-route-handler-execution.d.ts +1 -1
- package/dist/server/app-route-tree-prefetch.js +1 -1
- package/dist/server/app-rsc-cache-busting.js +1 -2
- package/dist/server/app-rsc-handler.js +2 -2
- package/dist/server/app-rsc-redirect-flight.d.ts +66 -0
- package/dist/server/app-rsc-redirect-flight.js +71 -0
- package/dist/server/app-rsc-render-mode.d.ts +2 -5
- package/dist/server/app-rsc-render-mode.js +2 -12
- package/dist/server/app-segment-config.js +2 -2
- package/dist/server/app-server-action-execution.js +3 -3
- package/dist/server/app-ssr-entry.js +4 -1
- package/dist/server/app-ssr-stream.d.ts +2 -1
- package/dist/server/app-ssr-stream.js +4 -1
- package/dist/server/cache-proof.js +1 -1
- package/dist/server/default-global-error-module.d.ts +3 -1
- package/dist/server/default-not-found-module.d.ts +3 -1
- package/dist/server/dev-lockfile.js +2 -3
- package/dist/server/dev-module-runner.js +1 -1
- package/dist/server/dev-origin-check.d.ts +2 -2
- package/dist/server/dev-origin-check.js +2 -2
- package/dist/server/dev-route-files.js +1 -1
- package/dist/server/dev-server.js +256 -164
- package/dist/server/dev-stack-sourcemap.js +4 -3
- package/dist/server/headers.d.ts +3 -1
- package/dist/server/headers.js +3 -1
- package/dist/server/image-optimization.d.ts +12 -1
- package/dist/server/image-optimization.js +15 -3
- package/dist/server/implicit-tags.js +2 -1
- package/dist/server/instrumentation.js +2 -2
- package/dist/server/isr-cache.d.ts +12 -4
- package/dist/server/isr-cache.js +3 -3
- package/dist/server/metadata-routes.js +4 -4
- package/dist/server/middleware-response-headers.js +1 -1
- package/dist/server/middleware-runtime.js +1 -1
- package/dist/server/middleware.d.ts +1 -0
- package/dist/server/middleware.js +1 -1
- package/dist/server/navigation-planner.d.ts +2 -0
- package/dist/server/navigation-planner.js +8 -2
- package/dist/server/next-error-digest.d.ts +9 -24
- package/dist/server/next-error-digest.js +23 -15
- package/dist/server/operation-token.js +1 -1
- package/dist/server/pages-body-parser-config.js +2 -1
- package/dist/server/pages-dev-hydration.d.ts +14 -0
- package/dist/server/pages-dev-hydration.js +83 -0
- package/dist/server/pages-dev-module-url.js +2 -2
- package/dist/server/pages-node-compat.d.ts +13 -6
- package/dist/server/pages-node-compat.js +44 -45
- package/dist/server/pages-page-data.d.ts +1 -1
- package/dist/server/pages-page-data.js +5 -4
- package/dist/server/pages-page-handler.js +61 -29
- package/dist/server/pages-page-response.d.ts +2 -2
- package/dist/server/pages-page-response.js +2 -2
- package/dist/server/pages-preview.d.ts +26 -0
- package/dist/server/pages-preview.js +165 -0
- package/dist/server/pages-readiness.d.ts +2 -1
- package/dist/server/pages-readiness.js +4 -2
- package/dist/server/pages-request-pipeline.js +1 -1
- package/dist/server/prerender-manifest.d.ts +15 -1
- package/dist/server/prerender-manifest.js +29 -1
- package/dist/server/prod-server.d.ts +6 -5
- package/dist/server/prod-server.js +15 -15
- package/dist/server/request-pipeline.js +1 -1
- package/dist/server/seed-cache.js +1 -1
- package/dist/server/socket-error-backstop.js +1 -1
- package/dist/server/static-file-cache.js +8 -9
- package/dist/server/worker-utils.js +1 -1
- package/dist/shims/cache.d.ts +1 -1
- package/dist/shims/cache.js +2 -1
- package/dist/shims/cdn-cache.d.ts +2 -7
- package/dist/shims/cdn-cache.js +2 -14
- package/dist/shims/constants.js +1 -1
- package/dist/shims/error-boundary.d.ts +4 -4
- package/dist/shims/error.d.ts +21 -5
- package/dist/shims/error.js +52 -14
- package/dist/shims/fetch-cache.js +1 -1
- package/dist/shims/font-utils.js +1 -1
- package/dist/shims/form.d.ts +1 -1
- package/dist/shims/head.js +3 -3
- package/dist/shims/headers.js +6 -4
- package/dist/shims/internal/pages-data-fetch-dedup.js +5 -3
- package/dist/shims/layout-segment-context.d.ts +1 -1
- package/dist/shims/link.d.ts +3 -1
- package/dist/shims/link.js +6 -3
- package/dist/shims/navigation-errors.d.ts +2 -1
- package/dist/shims/navigation-errors.js +9 -13
- package/dist/shims/navigation.d.ts +1 -1
- package/dist/shims/navigation.js +5 -5
- package/dist/shims/request-state-types.d.ts +2 -2
- package/dist/shims/router-state.d.ts +1 -0
- package/dist/shims/router.d.ts +2 -1
- package/dist/shims/router.js +18 -11
- package/dist/shims/script.js +1 -1
- package/dist/shims/server.js +2 -2
- package/dist/shims/slot.d.ts +1 -1
- package/dist/shims/thenable-params.js +1 -1
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/typegen.js +9 -11
- package/dist/utils/client-build-manifest.js +2 -2
- package/dist/utils/client-entry-manifest.js +1 -1
- package/dist/utils/client-runtime-metadata.js +1 -1
- package/dist/utils/commonjs-loader.js +3 -3
- package/dist/utils/mdx-scan.js +1 -1
- package/dist/utils/path.d.ts +1 -13
- package/dist/utils/path.js +1 -15
- package/dist/utils/plugin-options.d.ts +4 -0
- package/dist/utils/plugin-options.js +8 -0
- package/dist/utils/project.d.ts +1 -7
- package/dist/utils/project.js +2 -8
- package/dist/utils/public-routes.js +2 -2
- package/dist/utils/react-version.js +1 -1
- package/dist/utils/redirect-digest.d.ts +9 -0
- package/dist/utils/redirect-digest.js +25 -0
- package/dist/utils/vinext-root.js +1 -1
- package/dist/utils/vite-version.d.ts +6 -13
- package/dist/utils/vite-version.js +68 -34
- package/package.json +33 -14
- package/dist/cloudflare/index.d.ts +0 -3
- package/dist/cloudflare/index.js +0 -3
- package/dist/packages/cloudflare/src/cache/cdn-adapter.runtime.js +0 -102
- package/dist/packages/cloudflare/src/cache/kv-data-adapter.runtime.d.ts +0 -126
- package/dist/packages/cloudflare/src/cache/kv-data-adapter.runtime.js +0 -442
- package/dist/packages/cloudflare/src/deploy-config.js +0 -150
- package/dist/packages/cloudflare/src/deploy-help.js +0 -55
- package/dist/packages/cloudflare/src/deploy.js +0 -272
- package/dist/packages/cloudflare/src/tpr.d.ts +0 -45
- package/dist/packages/cloudflare/src/tpr.js +0 -582
- package/dist/packages/cloudflare/src/utils/cache-control-metadata.js +0 -20
- /package/dist/build/google-fonts/{fallback-metrics-data.js → fallback-metrics-data.json.js} +0 -0
- /package/dist/build/google-fonts/{font-data.js → font-data.json.js} +0 -0
- /package/dist/{node_modules/.pnpm/process-ancestry@0.1.0/node_modules → deps/.pnpm/process-ancestry@0.1.0/deps}/process-ancestry/dist/index.js +0 -0
|
@@ -18,7 +18,7 @@ import { PagesPageModule } from "./pages-page-data.js";
|
|
|
18
18
|
* The field names/types are projected from the canonical `VinextNextData` so
|
|
19
19
|
* this stays in lockstep with the `__NEXT_DATA__` shape it feeds into.
|
|
20
20
|
*/
|
|
21
|
-
type PagesReadinessNextData = Pick<VinextNextData, "gssp" | "gsp" | "gip" | "appGip" | "autoExport"> & {
|
|
21
|
+
type PagesReadinessNextData = Pick<VinextNextData, "gssp" | "gsp" | "gip" | "appGip" | "autoExport" | "nextExport"> & {
|
|
22
22
|
__vinext: Pick<NonNullable<VinextNextData["__vinext"]>, "hasRewrites">;
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
@@ -29,6 +29,7 @@ declare function buildPagesReadinessNextData(options: {
|
|
|
29
29
|
pageModule: PagesPageModule;
|
|
30
30
|
appComponent: {
|
|
31
31
|
getInitialProps?: unknown;
|
|
32
|
+
origGetInitialProps?: unknown;
|
|
32
33
|
} | null | undefined;
|
|
33
34
|
hasRewrites: boolean;
|
|
34
35
|
}): PagesReadinessNextData;
|
|
@@ -7,13 +7,15 @@ function buildPagesReadinessNextData(options) {
|
|
|
7
7
|
const hasPageGssp = typeof options.pageModule.getServerSideProps === "function";
|
|
8
8
|
const hasPageGsp = typeof options.pageModule.getStaticProps === "function";
|
|
9
9
|
const hasPageGip = typeof options.pageModule.default?.getInitialProps === "function";
|
|
10
|
-
const hasAppGip = typeof options.appComponent?.getInitialProps === "function";
|
|
10
|
+
const hasAppGip = typeof options.appComponent?.getInitialProps === "function" && options.appComponent.getInitialProps !== options.appComponent.origGetInitialProps;
|
|
11
|
+
const autoExport = !hasPageGssp && !hasPageGsp && !hasPageGip && !hasAppGip;
|
|
11
12
|
return {
|
|
12
13
|
gssp: hasPageGssp,
|
|
13
14
|
gsp: hasPageGsp ? true : void 0,
|
|
14
15
|
gip: hasPageGip,
|
|
15
16
|
appGip: hasAppGip,
|
|
16
|
-
autoExport
|
|
17
|
+
autoExport,
|
|
18
|
+
nextExport: autoExport ? true : void 0,
|
|
17
19
|
__vinext: { hasRewrites: options.hasRewrites }
|
|
18
20
|
};
|
|
19
21
|
}
|
|
@@ -320,7 +320,7 @@ async function runPagesRequest(request, deps) {
|
|
|
320
320
|
return {
|
|
321
321
|
type: "response",
|
|
322
322
|
response: merged,
|
|
323
|
-
defaultContentType: "text/html"
|
|
323
|
+
defaultContentType: "text/html; charset=utf-8"
|
|
324
324
|
};
|
|
325
325
|
}
|
|
326
326
|
let devPageMatch = isOutsideBasePathUnclaimed() ? null : resolvedPathnameChanged ? deps.matchPageRoute ? deps.matchPageRoute(resolvedPathname, request) : null : pageMatch;
|
|
@@ -15,6 +15,10 @@ type PrerenderManifest = {
|
|
|
15
15
|
routes?: PrerenderManifestRoute[];
|
|
16
16
|
pregeneratedConcretePaths?: Array<[string, string[]]>;
|
|
17
17
|
};
|
|
18
|
+
type PrerenderedPathSelectionOptions = {
|
|
19
|
+
includeFallbackShells?: boolean;
|
|
20
|
+
includeErrorDocuments?: boolean;
|
|
21
|
+
};
|
|
18
22
|
declare function readPrerenderManifest(manifestPath: string): PrerenderManifest | null;
|
|
19
23
|
declare function getRenderedAppRoutes(routes: PrerenderManifestRoute[]): PrerenderManifestRoute[];
|
|
20
24
|
/**
|
|
@@ -31,5 +35,15 @@ declare function isFallbackShellArtifactPath(pathname: string, route?: Prerender
|
|
|
31
35
|
* rendered App routes or all routes are fallback-shell artifacts.
|
|
32
36
|
*/
|
|
33
37
|
declare function buildPregeneratedConcretePathTable(manifest: PrerenderManifest): Array<[string, string[]]>;
|
|
38
|
+
/**
|
|
39
|
+
* Select concrete URL paths that were rendered by the prerender engine.
|
|
40
|
+
*
|
|
41
|
+
* This intentionally includes both App Router and Pages Router entries because
|
|
42
|
+
* deploy-time cache warmup should exercise the same URLs the prerender phase
|
|
43
|
+
* proved are statically renderable. PPR fallback-shell placeholder artifacts
|
|
44
|
+
* and known error documents are excluded by default so warmup does not request
|
|
45
|
+
* synthetic bracket paths or treat a healthy 404 response as a failed warmup.
|
|
46
|
+
*/
|
|
47
|
+
declare function getPrerenderedConcretePaths(manifest: PrerenderManifest, options?: PrerenderedPathSelectionOptions): string[];
|
|
34
48
|
//#endregion
|
|
35
|
-
export { PrerenderManifest, buildPregeneratedConcretePathTable, getRenderedAppRoutes, isFallbackShellArtifactPath, readPrerenderManifest };
|
|
49
|
+
export { PrerenderManifest, PrerenderManifestRoute, PrerenderedPathSelectionOptions, buildPregeneratedConcretePathTable, getPrerenderedConcretePaths, getRenderedAppRoutes, isFallbackShellArtifactPath, readPrerenderManifest };
|
|
@@ -22,6 +22,9 @@ function groupRoutesByPattern(routes) {
|
|
|
22
22
|
}
|
|
23
23
|
return byPattern;
|
|
24
24
|
}
|
|
25
|
+
function isErrorDocumentRoute(pathname, route) {
|
|
26
|
+
return pathname === "/404" || pathname === "/500" || pathname === "/_error" || route.route === "/404" || route.route === "/500" || route.route === "/_error";
|
|
27
|
+
}
|
|
25
28
|
/**
|
|
26
29
|
* Returns true when `pathname` contains bracket-delimited route params,
|
|
27
30
|
* indicating it is a fallback-shell placeholder (e.g. `/en/blog/[slug]`)
|
|
@@ -50,5 +53,30 @@ function buildPregeneratedConcretePathTable(manifest) {
|
|
|
50
53
|
});
|
|
51
54
|
return Array.from(groupRoutesByPattern(concreteRoutes).entries());
|
|
52
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Select concrete URL paths that were rendered by the prerender engine.
|
|
58
|
+
*
|
|
59
|
+
* This intentionally includes both App Router and Pages Router entries because
|
|
60
|
+
* deploy-time cache warmup should exercise the same URLs the prerender phase
|
|
61
|
+
* proved are statically renderable. PPR fallback-shell placeholder artifacts
|
|
62
|
+
* and known error documents are excluded by default so warmup does not request
|
|
63
|
+
* synthetic bracket paths or treat a healthy 404 response as a failed warmup.
|
|
64
|
+
*/
|
|
65
|
+
function getPrerenderedConcretePaths(manifest, options) {
|
|
66
|
+
const routes = manifest.routes;
|
|
67
|
+
if (!routes?.length) return [];
|
|
68
|
+
const paths = [];
|
|
69
|
+
const seen = /* @__PURE__ */ new Set();
|
|
70
|
+
for (const route of routes) {
|
|
71
|
+
if (route.status !== "rendered") continue;
|
|
72
|
+
const pathname = route.path ?? route.route;
|
|
73
|
+
if (!options?.includeFallbackShells && isFallbackShellArtifactPath(pathname, route)) continue;
|
|
74
|
+
if (!options?.includeErrorDocuments && isErrorDocumentRoute(pathname, route)) continue;
|
|
75
|
+
if (seen.has(pathname)) continue;
|
|
76
|
+
seen.add(pathname);
|
|
77
|
+
paths.push(pathname);
|
|
78
|
+
}
|
|
79
|
+
return paths;
|
|
80
|
+
}
|
|
53
81
|
//#endregion
|
|
54
|
-
export { buildPregeneratedConcretePathTable, getRenderedAppRoutes, isFallbackShellArtifactPath, readPrerenderManifest };
|
|
82
|
+
export { buildPregeneratedConcretePathTable, getPrerenderedConcretePaths, getRenderedAppRoutes, isFallbackShellArtifactPath, readPrerenderManifest };
|
|
@@ -10,10 +10,9 @@ import { IncomingMessage, ServerResponse } from "node:http";
|
|
|
10
10
|
*
|
|
11
11
|
* The first import of a given path uses the plain file:// URL with NO query
|
|
12
12
|
* string. This is load-bearing: code-split builds emit lazy chunks that
|
|
13
|
-
* import the entry back by bare specifier (default Vite builds
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* entry chunk, which the chunks then import as e.g. "../../index.js").
|
|
13
|
+
* import the entry back by bare specifier (default Vite/Rolldown builds hoist
|
|
14
|
+
* modules shared between the entry's static graph and lazy route chunks into
|
|
15
|
+
* the entry chunk, which the chunks then import as e.g. "../../index.js").
|
|
17
16
|
* Node keys its ESM cache on the full URL including the query string, so if
|
|
18
17
|
* the server imported the entry as `index.js?t=<mtime>`, a chunk's bare
|
|
19
18
|
* back-import would evaluate the entire server bundle a second time and
|
|
@@ -48,7 +47,9 @@ declare function readNodeStream(req: IncomingMessage): ReadableStream<Uint8Array
|
|
|
48
47
|
type ProdServerOptions = {
|
|
49
48
|
/** Port to listen on */port?: number; /** Host to bind to */
|
|
50
49
|
host?: string; /** Path to the build output directory */
|
|
51
|
-
outDir?: string; /**
|
|
50
|
+
outDir?: string; /** Explicit App Router RSC entry path. Defaults to `<outDir>/server/index.js`. */
|
|
51
|
+
rscEntryPath?: string; /** Explicit Pages Router server entry path. Defaults to `<outDir>/server/entry.js`. */
|
|
52
|
+
serverEntryPath?: string; /** Disable compression (default: false) */
|
|
52
53
|
noCompression?: boolean;
|
|
53
54
|
/**
|
|
54
55
|
* Narrow startup context for callers that need a more precise log line.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
1
2
|
import { normalizePathnameForRouteMatchStrict } from "../routing/utils.js";
|
|
2
3
|
import { hasBasePath, stripBasePath } from "../utils/base-path.js";
|
|
3
4
|
import { VINEXT_PRERENDER_ROUTE_PARAMS_HEADER, VINEXT_PRERENDER_SECRET_HEADER, VINEXT_PRERENDER_SPECULATIVE_HEADER } from "../utils/protocol-headers.js";
|
|
@@ -23,8 +24,7 @@ import { readPrerenderSecret } from "../build/server-manifest.js";
|
|
|
23
24
|
import { seedMemoryCacheFromPrerender } from "./seed-cache.js";
|
|
24
25
|
import { negotiateEncoding, parseAcceptedEncodings, selectContentEncoding } from "./accept-encoding.js";
|
|
25
26
|
import fs from "node:fs";
|
|
26
|
-
import
|
|
27
|
-
import fs$1 from "node:fs/promises";
|
|
27
|
+
import fsp from "node:fs/promises";
|
|
28
28
|
import { pathToFileURL } from "node:url";
|
|
29
29
|
import { Readable, pipeline } from "node:stream";
|
|
30
30
|
import zlib from "node:zlib";
|
|
@@ -74,10 +74,9 @@ function resolveCanonicalServerEntry(entryPath) {
|
|
|
74
74
|
*
|
|
75
75
|
* The first import of a given path uses the plain file:// URL with NO query
|
|
76
76
|
* string. This is load-bearing: code-split builds emit lazy chunks that
|
|
77
|
-
* import the entry back by bare specifier (default Vite builds
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* entry chunk, which the chunks then import as e.g. "../../index.js").
|
|
77
|
+
* import the entry back by bare specifier (default Vite/Rolldown builds hoist
|
|
78
|
+
* modules shared between the entry's static graph and lazy route chunks into
|
|
79
|
+
* the entry chunk, which the chunks then import as e.g. "../../index.js").
|
|
81
80
|
* Node keys its ESM cache on the full URL including the query string, so if
|
|
82
81
|
* the server imported the entry as `index.js?t=<mtime>`, a chunk's bare
|
|
83
82
|
* back-import would evaluate the entire server bundle a second time and
|
|
@@ -160,7 +159,7 @@ function readNodeStream(req) {
|
|
|
160
159
|
});
|
|
161
160
|
}
|
|
162
161
|
/** Content types that benefit from compression. */
|
|
163
|
-
const COMPRESSIBLE_TYPES = new Set([
|
|
162
|
+
const COMPRESSIBLE_TYPES = /* @__PURE__ */ new Set([
|
|
164
163
|
"text/html",
|
|
165
164
|
"text/css",
|
|
166
165
|
"text/plain",
|
|
@@ -238,13 +237,13 @@ function nodeHeadersToWebHeaders(headersRecord) {
|
|
|
238
237
|
for (const [key, value] of Object.entries(headersRecord)) appendWebHeader(headers, key, value);
|
|
239
238
|
return headers;
|
|
240
239
|
}
|
|
241
|
-
const NO_BODY_RESPONSE_STATUSES = new Set([
|
|
240
|
+
const NO_BODY_RESPONSE_STATUSES = /* @__PURE__ */ new Set([
|
|
242
241
|
204,
|
|
243
242
|
205,
|
|
244
243
|
304
|
|
245
244
|
]);
|
|
246
|
-
const OMIT_BODY_HEADERS = new Set(["content-length", "content-type"]);
|
|
247
|
-
const OMIT_STATIC_RESPONSE_HEADERS = new Set([
|
|
245
|
+
const OMIT_BODY_HEADERS = /* @__PURE__ */ new Set(["content-length", "content-type"]);
|
|
246
|
+
const OMIT_STATIC_RESPONSE_HEADERS = /* @__PURE__ */ new Set([
|
|
248
247
|
VINEXT_STATIC_FILE_HEADER,
|
|
249
248
|
"content-encoding",
|
|
250
249
|
"content-length",
|
|
@@ -543,7 +542,7 @@ async function resolveStaticFile(staticFile) {
|
|
|
543
542
|
}
|
|
544
543
|
async function statIfFile(filePath) {
|
|
545
544
|
try {
|
|
546
|
-
const stat = await
|
|
545
|
+
const stat = await fsp.stat(filePath);
|
|
547
546
|
return stat.isFile() ? {
|
|
548
547
|
size: stat.size,
|
|
549
548
|
mtimeMs: stat.mtimeMs
|
|
@@ -633,12 +632,12 @@ async function sendWebResponse(webResponse, req, res, compress) {
|
|
|
633
632
|
*/
|
|
634
633
|
async function startProdServer(options = {}) {
|
|
635
634
|
installSocketErrorBackstop();
|
|
636
|
-
const { port = process.env.PORT ? parseInt(process.env.PORT) : 3e3, host = "0.0.0.0", outDir = path.resolve("dist"), noCompression = false, purpose, silent = false } = options;
|
|
635
|
+
const { port = process.env.PORT ? parseInt(process.env.PORT) : 3e3, host = "0.0.0.0", outDir = path.resolve("dist"), rscEntryPath: explicitRscEntryPath, serverEntryPath: explicitServerEntryPath, noCompression = false, purpose, silent = false } = options;
|
|
637
636
|
const compress = !noCompression;
|
|
638
637
|
const resolvedOutDir = path.resolve(outDir);
|
|
639
638
|
const clientDir = path.join(resolvedOutDir, "client");
|
|
640
|
-
const rscEntryPath = path.join(resolvedOutDir, "server", "index.js");
|
|
641
|
-
const serverEntryPath = path.join(resolvedOutDir, "server", "entry.js");
|
|
639
|
+
const rscEntryPath = explicitRscEntryPath ? path.resolve(explicitRscEntryPath) : path.join(resolvedOutDir, "server", "index.js");
|
|
640
|
+
const serverEntryPath = explicitServerEntryPath ? path.resolve(explicitServerEntryPath) : path.join(resolvedOutDir, "server", "entry.js");
|
|
642
641
|
const isAppRouter = fs.existsSync(rscEntryPath);
|
|
643
642
|
if (!isAppRouter && !fs.existsSync(serverEntryPath)) {
|
|
644
643
|
console.error(`[vinext] No build output found in ${outDir}`);
|
|
@@ -875,7 +874,8 @@ async function startAppRouterServer(options) {
|
|
|
875
874
|
}
|
|
876
875
|
try {
|
|
877
876
|
const qs = rawUrl.includes("?") ? rawUrl.slice(rawUrl.indexOf("?")) : "";
|
|
878
|
-
const
|
|
877
|
+
const request = nodeToWebRequest(req, pathname + qs, prerenderSecret);
|
|
878
|
+
const response = await rscHandler(request);
|
|
879
879
|
const staticFileSignal = response.headers.get(VINEXT_STATIC_FILE_HEADER);
|
|
880
880
|
if (staticFileSignal) {
|
|
881
881
|
let staticFilePath = "/";
|
|
@@ -341,7 +341,7 @@ function processMiddlewareHeaders(headers) {
|
|
|
341
341
|
for (const key of headers.keys()) if (key.startsWith("x-middleware-") && key !== "x-middleware-cache") keysToDelete.push(key);
|
|
342
342
|
for (const key of keysToDelete) headers.delete(key);
|
|
343
343
|
}
|
|
344
|
-
const STRIPPED_INTERNAL_HEADERS = new Set([...INTERNAL_HEADERS, ...VINEXT_INTERNAL_HEADERS]);
|
|
344
|
+
const STRIPPED_INTERNAL_HEADERS = /* @__PURE__ */ new Set([...INTERNAL_HEADERS, ...VINEXT_INTERNAL_HEADERS]);
|
|
345
345
|
/**
|
|
346
346
|
* Strip internal headers from an inbound request so they cannot be forged by
|
|
347
347
|
* an external attacker to influence routing or impersonate internal state.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
1
2
|
import { isrCacheKey, isrSetPrerenderedAppPage } from "./isr-cache.js";
|
|
2
3
|
import { getRenderedAppRoutes, isFallbackShellArtifactPath, readPrerenderManifest } from "./prerender-manifest.js";
|
|
3
4
|
import { buildAppPageCacheTags } from "./app-page-cache.js";
|
|
4
5
|
import { getOutputPath, getRscOutputPath } from "../utils/prerender-output-paths.js";
|
|
5
6
|
import { addPregeneratedConcretePath, clearPregeneratedConcretePaths, normalizePregeneratedPathname } from "./pregenerated-concrete-paths.js";
|
|
6
7
|
import fs from "node:fs";
|
|
7
|
-
import path from "node:path";
|
|
8
8
|
//#region src/server/seed-cache.ts
|
|
9
9
|
/**
|
|
10
10
|
* Seed the memory cache from pre-rendered build output.
|
|
@@ -90,7 +90,7 @@ function peerDisconnectCode(err) {
|
|
|
90
90
|
const code = err?.code;
|
|
91
91
|
return code === "ECONNRESET" || code === "EPIPE" || code === "ECONNABORTED" ? code : void 0;
|
|
92
92
|
}
|
|
93
|
-
const STATIC_ASSET_IMPORT_EXTENSIONS = new Set([
|
|
93
|
+
const STATIC_ASSET_IMPORT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
94
94
|
".css",
|
|
95
95
|
".scss",
|
|
96
96
|
".sass",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
2
|
import { ASSET_PREFIX_URL_DIR } from "../utils/asset-prefix.js";
|
|
3
|
-
import
|
|
4
|
-
import fs from "node:fs/promises";
|
|
3
|
+
import fsp from "node:fs/promises";
|
|
5
4
|
//#region src/server/static-file-cache.ts
|
|
6
5
|
/**
|
|
7
6
|
* Startup metadata cache for static file serving.
|
|
@@ -21,7 +20,7 @@ const CONTENT_TYPES = {
|
|
|
21
20
|
".js": "application/javascript",
|
|
22
21
|
".mjs": "application/javascript",
|
|
23
22
|
".css": "text/css",
|
|
24
|
-
".html": "text/html",
|
|
23
|
+
".html": "text/html; charset=utf-8",
|
|
25
24
|
".json": "application/json",
|
|
26
25
|
".txt": "text/plain; charset=utf-8",
|
|
27
26
|
".png": "image/png",
|
|
@@ -137,7 +136,7 @@ var StaticFileCache = class StaticFileCache {
|
|
|
137
136
|
}
|
|
138
137
|
}
|
|
139
138
|
for (let i = 0; i < toBuffer.length; i += 64) await Promise.all(toBuffer.slice(i, i + 64).map(async (v) => {
|
|
140
|
-
v.buffer = await
|
|
139
|
+
v.buffer = await fsp.readFile(v.path);
|
|
141
140
|
}));
|
|
142
141
|
return new StaticFileCache(entries);
|
|
143
142
|
}
|
|
@@ -170,7 +169,7 @@ function etagFromFilenameHash(relativePath, ext) {
|
|
|
170
169
|
const suffix = basename.slice(lastDash + 1);
|
|
171
170
|
if (suffix.length >= 6 && suffix.length <= 12 && /^[A-Za-z0-9_-]+$/.test(suffix)) return `W/"${suffix}"`;
|
|
172
171
|
}
|
|
173
|
-
const normalizedPath =
|
|
172
|
+
const normalizedPath = toSlash(relativePath);
|
|
174
173
|
const managedMediaSegment = `${ASSET_PREFIX_URL_DIR}/media/`;
|
|
175
174
|
if (normalizedPath.startsWith(managedMediaSegment) || normalizedPath.includes(`/${managedMediaSegment}`)) {
|
|
176
175
|
const lastDot = basename.lastIndexOf(".");
|
|
@@ -204,7 +203,7 @@ const STAT_BATCH_SIZE = 64;
|
|
|
204
203
|
async function* walkFilesWithStats(dir, base = dir) {
|
|
205
204
|
let entries;
|
|
206
205
|
try {
|
|
207
|
-
entries = await
|
|
206
|
+
entries = await fsp.readdir(dir, { withFileTypes: true });
|
|
208
207
|
} catch {
|
|
209
208
|
return;
|
|
210
209
|
}
|
|
@@ -216,9 +215,9 @@ async function* walkFilesWithStats(dir, base = dir) {
|
|
|
216
215
|
}
|
|
217
216
|
for (let i = 0; i < files.length; i += STAT_BATCH_SIZE) {
|
|
218
217
|
const batch = files.slice(i, i + STAT_BATCH_SIZE);
|
|
219
|
-
const stats = await Promise.all(batch.map((f) =>
|
|
218
|
+
const stats = await Promise.all(batch.map((f) => fsp.stat(f)));
|
|
220
219
|
for (let j = 0; j < batch.length; j++) yield {
|
|
221
|
-
relativePath:
|
|
220
|
+
relativePath: path.relative(base, batch[j]),
|
|
222
221
|
fullPath: batch[j],
|
|
223
222
|
stat: {
|
|
224
223
|
size: stats[j].size,
|
|
@@ -14,7 +14,7 @@ import { notFoundStaticAssetResponse } from "./http-error-responses.js";
|
|
|
14
14
|
* are preserved). Uses getSetCookie() to preserve multiple Set-Cookie values.
|
|
15
15
|
* Keep this in sync with prod-server.ts.
|
|
16
16
|
*/
|
|
17
|
-
const NO_BODY_RESPONSE_STATUSES = new Set([
|
|
17
|
+
const NO_BODY_RESPONSE_STATUSES = /* @__PURE__ */ new Set([
|
|
18
18
|
204,
|
|
19
19
|
205,
|
|
20
20
|
304
|
package/dist/shims/cache.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, ActionRevalidationKind, CacheLifeConfig, CacheState, UnstableCacheObservation, UnstableCacheRevalidationMode, _consumeRequestScopedCacheLife, _initRequestScopedCacheState, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLifeProfiles, getAndClearActionRevalidationKind, getRegisteredCacheContext, markActionRevalidation, recordUnstableCacheObservation, shouldServeStaleUnstableCacheEntry } from "./cache-request-state.js";
|
|
2
|
-
import { CacheControlMetadata, CacheHandler, CacheHandlerContext, CacheHandlerValue, CachedAppPageValue, CachedFetchValue, CachedImageValue, CachedPagesValue, CachedRedirectValue, CachedRouteValue, IncrementalCacheValue, MemoryCacheHandler, NoOpCacheHandler, configureMemoryCacheHandler, getCacheHandler, getDataCacheHandler, setCacheHandler, setDataCacheHandler } from "./cache-handler.js";
|
|
3
2
|
import { ExecutionContextLike, getRequestExecutionContext, runWithExecutionContext } from "./request-context.js";
|
|
3
|
+
import { CacheControlMetadata, CacheHandler, CacheHandlerContext, CacheHandlerValue, CachedAppPageValue, CachedFetchValue, CachedImageValue, CachedPagesValue, CachedRedirectValue, CachedRouteValue, IncrementalCacheValue, MemoryCacheHandler, NoOpCacheHandler, configureMemoryCacheHandler, getCacheHandler, getDataCacheHandler, setCacheHandler, setDataCacheHandler } from "./cache-handler.js";
|
|
4
4
|
|
|
5
5
|
//#region src/shims/cache.d.ts
|
|
6
6
|
/**
|
package/dist/shims/cache.js
CHANGED
|
@@ -374,7 +374,8 @@ function unstable_cache(fn, keyParts, options) {
|
|
|
374
374
|
const tags = encodeCacheTags(options?.tags ?? []);
|
|
375
375
|
const revalidateSeconds = options?.revalidate;
|
|
376
376
|
const cachedFn = async (...args) => {
|
|
377
|
-
const
|
|
377
|
+
const argsKey = JSON.stringify(args);
|
|
378
|
+
const cacheKey = `unstable_cache:${baseKey}:${argsKey}`;
|
|
378
379
|
addCollectedRequestTags(tags);
|
|
379
380
|
recordUnstableCacheObservation({
|
|
380
381
|
kind: "unstable_cache",
|
|
@@ -112,13 +112,8 @@ declare class DefaultCdnCacheAdapter implements CdnCacheAdapter {
|
|
|
112
112
|
*/
|
|
113
113
|
declare function setCdnCacheAdapter(adapter: CdnCacheAdapter): void;
|
|
114
114
|
/**
|
|
115
|
-
* Get the active CDN cache adapter.
|
|
116
|
-
*
|
|
117
|
-
* {@link DefaultCdnCacheAdapter}.
|
|
118
|
-
*
|
|
119
|
-
* Auto-detection of the Cloudflare Workers Cache (`ctx.cache`) only runs when
|
|
120
|
-
* `VINEXT_CDN_CACHE_AUTO_DETECT === "1"`; otherwise the default adapter is used
|
|
121
|
-
* unless an adapter was set explicitly.
|
|
115
|
+
* Get the active CDN cache adapter. An explicitly configured adapter wins;
|
|
116
|
+
* otherwise the origin-managed {@link DefaultCdnCacheAdapter} is used.
|
|
122
117
|
*/
|
|
123
118
|
declare function getCdnCacheAdapter(): CdnCacheAdapter;
|
|
124
119
|
//#endregion
|
package/dist/shims/cdn-cache.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { getRequestExecutionContext } from "./request-context.js";
|
|
2
1
|
import { getDataCacheHandler } from "./cache-handler.js";
|
|
3
|
-
import { CloudflareCdnCacheAdapter } from "../packages/cloudflare/src/cache/cdn-adapter.runtime.js";
|
|
4
2
|
//#region src/shims/cdn-cache.ts
|
|
5
3
|
/**
|
|
6
4
|
* CDN cache adapter — owns the *page-level ISR serving strategy*.
|
|
@@ -78,22 +76,12 @@ function setCdnCacheAdapter(adapter) {
|
|
|
78
76
|
_gCdn[_CDN_KEY] = adapter;
|
|
79
77
|
}
|
|
80
78
|
/**
|
|
81
|
-
* Get the active CDN cache adapter.
|
|
82
|
-
*
|
|
83
|
-
* {@link DefaultCdnCacheAdapter}.
|
|
84
|
-
*
|
|
85
|
-
* Auto-detection of the Cloudflare Workers Cache (`ctx.cache`) only runs when
|
|
86
|
-
* `VINEXT_CDN_CACHE_AUTO_DETECT === "1"`; otherwise the default adapter is used
|
|
87
|
-
* unless an adapter was set explicitly.
|
|
79
|
+
* Get the active CDN cache adapter. An explicitly configured adapter wins;
|
|
80
|
+
* otherwise the origin-managed {@link DefaultCdnCacheAdapter} is used.
|
|
88
81
|
*/
|
|
89
82
|
function getCdnCacheAdapter() {
|
|
90
83
|
const active = _gCdn[_CDN_KEY];
|
|
91
84
|
if (active) return active;
|
|
92
|
-
if (process.env.VINEXT_CDN_CACHE_AUTO_DETECT === "1" && getRequestExecutionContext()?.cache) {
|
|
93
|
-
const edge = new CloudflareCdnCacheAdapter();
|
|
94
|
-
_gCdn[_CDN_KEY] = edge;
|
|
95
|
-
return edge;
|
|
96
|
-
}
|
|
97
85
|
return _defaultAdapter ??= new DefaultCdnCacheAdapter();
|
|
98
86
|
}
|
|
99
87
|
//#endregion
|
package/dist/shims/constants.js
CHANGED
|
@@ -158,7 +158,7 @@ const EDGE_UNSUPPORTED_NODE_APIS = [
|
|
|
158
158
|
"TransformStreamDefaultController",
|
|
159
159
|
"WritableStreamDefaultController"
|
|
160
160
|
];
|
|
161
|
-
const SYSTEM_ENTRYPOINTS = new Set([
|
|
161
|
+
const SYSTEM_ENTRYPOINTS = /* @__PURE__ */ new Set([
|
|
162
162
|
CLIENT_STATIC_FILES_RUNTIME_MAIN,
|
|
163
163
|
CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH,
|
|
164
164
|
CLIENT_STATIC_FILES_RUNTIME_MAIN_APP
|
|
@@ -50,7 +50,7 @@ declare class RedirectErrorBoundary extends React.Component<{
|
|
|
50
50
|
children?: React.ReactNode;
|
|
51
51
|
});
|
|
52
52
|
static getDerivedStateFromError(error: unknown): RedirectBoundaryState;
|
|
53
|
-
render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.
|
|
53
|
+
render(): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | Iterable<React.ReactNode> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | React.ReactPortal | null | undefined> | null | undefined;
|
|
54
54
|
}
|
|
55
55
|
declare function RedirectBoundary({
|
|
56
56
|
children
|
|
@@ -70,7 +70,7 @@ declare class ErrorBoundaryInner extends React.Component<ErrorBoundaryInnerProps
|
|
|
70
70
|
componentDidMount(): void;
|
|
71
71
|
componentWillUnmount(): void;
|
|
72
72
|
reset: () => void;
|
|
73
|
-
render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.
|
|
73
|
+
render(): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | Iterable<React.ReactNode> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | React.ReactPortal | null | undefined> | null | undefined;
|
|
74
74
|
}
|
|
75
75
|
declare function ErrorBoundary({
|
|
76
76
|
fallback,
|
|
@@ -118,7 +118,7 @@ declare class ForbiddenBoundaryInner extends React.Component<ForbiddenBoundaryIn
|
|
|
118
118
|
constructor(props: ForbiddenBoundaryInnerProps);
|
|
119
119
|
static getDerivedStateFromProps(props: ForbiddenBoundaryInnerProps, state: ForbiddenBoundaryState): ForbiddenBoundaryState | null;
|
|
120
120
|
static getDerivedStateFromError(error: unknown): Partial<ForbiddenBoundaryState>;
|
|
121
|
-
render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.
|
|
121
|
+
render(): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | Iterable<React.ReactNode> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | React.ReactPortal | null | undefined> | null | undefined;
|
|
122
122
|
}
|
|
123
123
|
declare function ForbiddenBoundary({
|
|
124
124
|
fallback,
|
|
@@ -142,7 +142,7 @@ declare class UnauthorizedBoundaryInner extends React.Component<UnauthorizedBoun
|
|
|
142
142
|
constructor(props: UnauthorizedBoundaryInnerProps);
|
|
143
143
|
static getDerivedStateFromProps(props: UnauthorizedBoundaryInnerProps, state: UnauthorizedBoundaryState): UnauthorizedBoundaryState | null;
|
|
144
144
|
static getDerivedStateFromError(error: unknown): Partial<UnauthorizedBoundaryState>;
|
|
145
|
-
render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.
|
|
145
|
+
render(): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | Iterable<React.ReactNode> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | React.ReactPortal | null | undefined> | null | undefined;
|
|
146
146
|
}
|
|
147
147
|
declare function UnauthorizedBoundary({
|
|
148
148
|
fallback,
|
package/dist/shims/error.d.ts
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { IncomingMessage, ServerResponse } from "node:http";
|
|
2
3
|
|
|
3
4
|
//#region src/shims/error.d.ts
|
|
4
5
|
type ErrorProps = {
|
|
5
6
|
statusCode: number;
|
|
7
|
+
hostname?: string;
|
|
6
8
|
title?: string;
|
|
7
9
|
withDarkMode?: boolean;
|
|
8
10
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
11
|
+
type ErrorPageContext = {
|
|
12
|
+
err?: (Error & {
|
|
13
|
+
statusCode?: number;
|
|
14
|
+
}) | null;
|
|
15
|
+
req?: IncomingMessage;
|
|
16
|
+
res?: ServerResponse;
|
|
17
|
+
};
|
|
18
|
+
declare function getErrorInitialProps({
|
|
19
|
+
err,
|
|
20
|
+
req,
|
|
21
|
+
res
|
|
22
|
+
}: ErrorPageContext): ErrorProps;
|
|
23
|
+
declare class ErrorComponent<P = {}> extends React.Component<P & ErrorProps> {
|
|
24
|
+
static displayName: string;
|
|
25
|
+
static getInitialProps: typeof getErrorInitialProps;
|
|
26
|
+
static origGetInitialProps: typeof getErrorInitialProps;
|
|
27
|
+
render(): React.ReactElement;
|
|
28
|
+
}
|
|
13
29
|
type ErrorInfo = {
|
|
14
30
|
error: unknown;
|
|
15
31
|
reset: () => void;
|
|
@@ -28,4 +44,4 @@ declare function unstable_catchError<P extends _UserProps>(fallback: (props: P,
|
|
|
28
44
|
children?: React.ReactNode;
|
|
29
45
|
}>;
|
|
30
46
|
//#endregion
|
|
31
|
-
export { ErrorInfo, ErrorComponent as default, unstable_catchError };
|
|
47
|
+
export { ErrorInfo, ErrorProps, ErrorComponent as default, unstable_catchError };
|
package/dist/shims/error.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AppRouterContext } from "./internal/app-router-context.js";
|
|
2
2
|
import { RouterContext } from "./internal/router-context.js";
|
|
3
|
+
import Head from "./head.js";
|
|
3
4
|
import { isNextRouterError } from "./navigation-errors.js";
|
|
4
5
|
import "./navigation.js";
|
|
5
6
|
import { useUntrackedPathname } from "./internal/navigation-untracked.js";
|
|
@@ -16,32 +17,69 @@ import React from "react";
|
|
|
16
17
|
* (`unstable_catchError`) and its `ErrorInfo` type, mirroring
|
|
17
18
|
* `next/error`'s public surface.
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const statusCodes = {
|
|
21
|
+
400: "Bad Request",
|
|
22
|
+
404: "This page could not be found",
|
|
23
|
+
405: "Method Not Allowed",
|
|
24
|
+
500: "Internal Server Error"
|
|
25
|
+
};
|
|
26
|
+
function getErrorInitialProps({ err, req, res }) {
|
|
27
|
+
const statusCode = res?.statusCode ? res.statusCode : err ? err.statusCode : 404;
|
|
28
|
+
let hostname;
|
|
29
|
+
if (typeof window !== "undefined") hostname = window.location.hostname;
|
|
30
|
+
else if (req) {
|
|
31
|
+
if (req.url) try {
|
|
32
|
+
hostname = new URL(req.url).hostname;
|
|
33
|
+
} catch {}
|
|
34
|
+
if (!hostname) {
|
|
35
|
+
const host = Array.isArray(req.headers?.host) ? req.headers.host[0] : req.headers?.host;
|
|
36
|
+
if (host) hostname = new URL(`http://${host}`).hostname;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
statusCode,
|
|
41
|
+
hostname
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const styles = {
|
|
45
|
+
error: {
|
|
46
|
+
fontFamily: "system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"",
|
|
23
47
|
height: "100vh",
|
|
24
48
|
textAlign: "center",
|
|
25
49
|
display: "flex",
|
|
26
50
|
flexDirection: "column",
|
|
27
51
|
alignItems: "center",
|
|
28
52
|
justifyContent: "center"
|
|
29
|
-
}
|
|
53
|
+
},
|
|
54
|
+
desc: { lineHeight: "48px" },
|
|
55
|
+
h1: {
|
|
30
56
|
display: "inline-block",
|
|
31
57
|
margin: "0 20px 0 0",
|
|
32
|
-
|
|
58
|
+
paddingRight: 23,
|
|
33
59
|
fontSize: 24,
|
|
34
60
|
fontWeight: 500,
|
|
35
|
-
verticalAlign: "top"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
} }, statusCode), React.createElement("div", { style: { display: "inline-block" } }, React.createElement("h2", { style: {
|
|
61
|
+
verticalAlign: "top"
|
|
62
|
+
},
|
|
63
|
+
h2: {
|
|
39
64
|
fontSize: 14,
|
|
40
65
|
fontWeight: 400,
|
|
41
|
-
lineHeight: "
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
66
|
+
lineHeight: "28px"
|
|
67
|
+
},
|
|
68
|
+
wrap: { display: "inline-block" }
|
|
69
|
+
};
|
|
70
|
+
var ErrorComponent = class extends React.Component {
|
|
71
|
+
static displayName = "ErrorPage";
|
|
72
|
+
static getInitialProps = getErrorInitialProps;
|
|
73
|
+
static origGetInitialProps = getErrorInitialProps;
|
|
74
|
+
render() {
|
|
75
|
+
const { statusCode, hostname, title: customTitle, withDarkMode = true } = this.props;
|
|
76
|
+
const title = customTitle || statusCodes[statusCode] || "An unexpected error has occurred";
|
|
77
|
+
return React.createElement("div", { style: styles.error }, React.createElement(Head, null, React.createElement("title", null, statusCode ? `${statusCode}: ${title}` : "Application error: a client-side exception has occurred")), React.createElement("div", { style: styles.desc }, React.createElement("style", { dangerouslySetInnerHTML: { __html: `body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}${withDarkMode ? "@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}" : ""}` } }), statusCode ? React.createElement("h1", {
|
|
78
|
+
className: "next-error-h1",
|
|
79
|
+
style: styles.h1
|
|
80
|
+
}, statusCode) : null, React.createElement("div", { style: styles.wrap }, React.createElement("h2", { style: styles.h2 }, customTitle || statusCode ? `${title}.` : `Application error: a client-side exception has occurred${hostname ? ` while loading ${hostname}` : ""} (see the browser console for more information).`))));
|
|
81
|
+
}
|
|
82
|
+
};
|
|
45
83
|
const _CatchErrorAppRouterContext = AppRouterContext ?? React.createContext(null);
|
|
46
84
|
var _CatchError = class extends React.Component {
|
|
47
85
|
static contextType = _CatchErrorAppRouterContext;
|
|
@@ -371,7 +371,7 @@ async function writeFetchCacheResponse(handler, cacheKey, response, tags, revali
|
|
|
371
371
|
}
|
|
372
372
|
async function lowerFetchCacheRevalidateIfNeeded(handler, cacheKey, cachedValue, tags, revalidateSeconds) {
|
|
373
373
|
if (!Number.isFinite(revalidateSeconds) || revalidateSeconds <= 0 || typeof cachedValue.revalidate !== "number" || cachedValue.revalidate <= revalidateSeconds) return;
|
|
374
|
-
const mergedTags = Array.from(new Set([...cachedValue.tags ?? [], ...tags]));
|
|
374
|
+
const mergedTags = Array.from(/* @__PURE__ */ new Set([...cachedValue.tags ?? [], ...tags]));
|
|
375
375
|
const updatedValue = {
|
|
376
376
|
...cachedValue,
|
|
377
377
|
tags: mergedTags,
|
package/dist/shims/font-utils.js
CHANGED
|
@@ -30,7 +30,7 @@ function sanitizeCSSVarName(name) {
|
|
|
30
30
|
* crafted fallback values like `); } body { color: red; } .x {`.
|
|
31
31
|
*/
|
|
32
32
|
function sanitizeFallback(name) {
|
|
33
|
-
const generics = new Set([
|
|
33
|
+
const generics = /* @__PURE__ */ new Set([
|
|
34
34
|
"serif",
|
|
35
35
|
"sans-serif",
|
|
36
36
|
"monospace",
|
package/dist/shims/form.d.ts
CHANGED
|
@@ -16,6 +16,6 @@ declare const Form: import("react").ForwardRefExoticComponent<{
|
|
|
16
16
|
* In pages dir, prefetch is not supported and the prop has no effect.
|
|
17
17
|
*/
|
|
18
18
|
prefetch?: false | null;
|
|
19
|
-
} & Omit<FormHTMLAttributes<HTMLFormElement>, "
|
|
19
|
+
} & Omit<FormHTMLAttributes<HTMLFormElement>, "encType" | "method" | "target"> & import("react").RefAttributes<HTMLFormElement>>;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { createFormSubmitDestinationUrl, Form as default, useActionState };
|