@wular/pnext 0.1.6 → 0.1.8
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/bin/pnext +9 -2
- package/dist/server/_chunks/aliases-pycbtjt1.js +46 -0
- package/dist/server/_chunks/analyze-4d9e00g9.js +449 -0
- package/dist/server/_chunks/boot-bhemypxz.js +38 -0
- package/dist/server/_chunks/build-c991dv65.js +86 -0
- package/dist/server/_chunks/build-kh5e3x48.js +3341 -0
- package/dist/server/_chunks/build-tier-0a96kmx3.js +2456 -0
- package/dist/server/_chunks/compile-040r79gj.js +22 -0
- package/dist/server/_chunks/config-0tvz03a6.js +24 -0
- package/dist/server/_chunks/config-27rj7830.js +36 -0
- package/dist/server/_chunks/create-9rvwshsp.js +135 -0
- package/dist/server/_chunks/dev-ex9exynt.js +220 -0
- package/dist/server/_chunks/esbuild-yyktfrtt.js +15 -0
- package/dist/server/_chunks/generate-myw9hef7.js +22 -0
- package/dist/server/_chunks/index-0r5eqfc7.js +279 -0
- package/dist/server/_chunks/index-0yjv5v47.js +105 -0
- package/dist/server/_chunks/index-11xpbfej.js +17 -0
- package/dist/server/_chunks/index-141vcwk6.js +109 -0
- package/dist/server/_chunks/index-1pzm1hdy.js +4130 -0
- package/dist/server/_chunks/index-29pq0kax.js +590 -0
- package/dist/server/_chunks/index-2vz0wzdn.js +59 -0
- package/dist/server/_chunks/index-2wfv4kvx.js +182 -0
- package/dist/server/_chunks/index-38xpdxwd.js +194 -0
- package/dist/server/_chunks/index-3e075kny.js +128 -0
- package/dist/server/_chunks/index-3ycf5ckv.js +472 -0
- package/dist/server/_chunks/index-4399bvd2.js +18 -0
- package/dist/server/_chunks/index-4da76t62.js +297 -0
- package/dist/server/_chunks/index-4t92hdxd.js +172 -0
- package/dist/server/_chunks/index-4zzebszd.js +10 -0
- package/dist/server/_chunks/index-52k54ykj.js +95 -0
- package/dist/server/_chunks/index-5hr4062s.js +70 -0
- package/dist/server/_chunks/index-68m3mwbd.js +84 -0
- package/dist/server/_chunks/index-6b009mt0.js +56 -0
- package/dist/server/_chunks/index-6gex3pfa.js +15 -0
- package/dist/server/_chunks/index-6kp9r0d9.js +11 -0
- package/dist/server/_chunks/index-6q7zvrap.js +134 -0
- package/dist/server/_chunks/index-71885zaq.js +284 -0
- package/dist/server/_chunks/index-73z4esab.js +38 -0
- package/dist/server/_chunks/index-79ngvam8.js +60 -0
- package/dist/server/_chunks/index-7wc9n8be.js +25 -0
- package/dist/server/_chunks/index-8ct7rqy3.js +198 -0
- package/dist/server/_chunks/index-8kcxdfya.js +206 -0
- package/dist/server/_chunks/index-9ch50vtq.js +18 -0
- package/dist/server/_chunks/index-9f49w76j.js +213 -0
- package/dist/server/_chunks/index-9hz3s0m8.js +851 -0
- package/dist/server/_chunks/index-akkrvjn6.js +535 -0
- package/dist/server/_chunks/index-b6wtkdp4.js +24 -0
- package/dist/server/_chunks/index-b7j671dj.js +207 -0
- package/dist/server/_chunks/index-bcws5eh2.js +35 -0
- package/dist/server/_chunks/index-bzd2ef7t.js +10 -0
- package/dist/server/_chunks/index-cjgqs13g.js +65 -0
- package/dist/server/_chunks/index-ckkdpht5.js +41 -0
- package/dist/server/_chunks/index-cn86z041.js +296 -0
- package/dist/server/_chunks/index-cvr4z22m.js +92 -0
- package/dist/server/_chunks/index-cyfednwb.js +87 -0
- package/dist/server/_chunks/index-d158y67j.js +152 -0
- package/dist/server/_chunks/index-d1jsmhhk.js +955 -0
- package/dist/server/_chunks/index-dg0f05zs.js +199 -0
- package/dist/server/_chunks/index-dgr390q7.js +9438 -0
- package/dist/server/_chunks/index-drwv61cc.js +185 -0
- package/dist/server/_chunks/index-e3a6yx84.js +18 -0
- package/dist/server/_chunks/index-e88tyv35.js +45 -0
- package/dist/server/_chunks/index-en7n9f7m.js +22 -0
- package/dist/server/_chunks/index-entm8bmz.js +28 -0
- package/dist/server/_chunks/index-evhd413j.js +57 -0
- package/dist/server/_chunks/index-ezgj0tr1.js +88 -0
- package/dist/server/_chunks/index-fjv96re1.js +5295 -0
- package/dist/server/_chunks/index-fn1chkkd.js +214 -0
- package/dist/server/_chunks/index-fp8r0sqs.js +64 -0
- package/dist/server/_chunks/index-gcmj16xy.js +92 -0
- package/dist/server/_chunks/index-gkndxkxf.js +736 -0
- package/dist/server/_chunks/index-grta8ap3.js +238 -0
- package/dist/server/_chunks/index-h2a70tg4.js +7 -0
- package/dist/server/_chunks/index-h4xy648y.js +51 -0
- package/dist/server/_chunks/index-hdbwtdv2.js +352 -0
- package/dist/server/_chunks/index-he6n2bvp.js +1270 -0
- package/dist/server/_chunks/index-j0m1jxqa.js +1253 -0
- package/dist/server/_chunks/index-j2zrcp1k.js +66 -0
- package/dist/server/_chunks/index-j681c48a.js +2530 -0
- package/dist/server/_chunks/index-jbj7ehef.js +50 -0
- package/dist/server/_chunks/index-jcsjq3d1.js +20 -0
- package/dist/server/_chunks/index-jks0x0a1.js +14 -0
- package/dist/server/_chunks/index-jn9rbhrx.js +1599 -0
- package/dist/server/_chunks/index-jt8e1pje.js +12 -0
- package/dist/server/_chunks/index-kdhxpwyq.js +483 -0
- package/dist/server/_chunks/index-knp0s912.js +7 -0
- package/dist/server/_chunks/index-kqyy1d4f.js +50 -0
- package/dist/server/_chunks/index-kresp2n8.js +445 -0
- package/dist/server/_chunks/index-m63czgq5.js +590 -0
- package/dist/server/_chunks/index-ms9v9tnx.js +31 -0
- package/dist/server/_chunks/index-n4hxpng2.js +11 -0
- package/dist/server/_chunks/index-n629dy38.js +1071 -0
- package/dist/server/_chunks/index-nf3df4jy.js +266 -0
- package/dist/server/_chunks/index-nqh3xhdc.js +57 -0
- package/dist/server/_chunks/index-pym1cezq.js +39 -0
- package/dist/server/_chunks/index-q3r9z8mq.js +213 -0
- package/dist/server/_chunks/index-q738kkhj.js +100 -0
- package/dist/server/_chunks/index-qcrvt6er.js +112 -0
- package/dist/server/_chunks/index-qjj6gddn.js +54 -0
- package/dist/server/_chunks/index-qpwsgt3a.js +158 -0
- package/dist/server/_chunks/index-r97ptz1q.js +97 -0
- package/dist/server/_chunks/index-ras0sdab.js +26 -0
- package/dist/server/_chunks/index-rcs322t1.js +19 -0
- package/dist/server/_chunks/index-rgj5mx84.js +101 -0
- package/dist/server/_chunks/index-rjegyfx4.js +1435 -0
- package/dist/server/_chunks/index-rt9qq1va.js +4 -0
- package/dist/server/_chunks/index-rthrsed5.js +356 -0
- package/dist/server/_chunks/index-sq3kvz3g.js +200 -0
- package/dist/server/_chunks/index-stbk3jhn.js +31 -0
- package/dist/server/_chunks/index-tf4j19ge.js +130 -0
- package/dist/server/_chunks/index-tgcakdxc.js +125 -0
- package/dist/server/_chunks/index-tgsfjmep.js +74 -0
- package/dist/server/_chunks/index-tq1f96v7.js +51 -0
- package/dist/server/_chunks/index-tq3b39a5.js +107 -0
- package/dist/server/_chunks/index-typcbcsv.js +819 -0
- package/dist/server/_chunks/index-v1ags1na.js +132 -0
- package/dist/server/_chunks/index-vmr35jjw.js +170 -0
- package/dist/server/_chunks/index-vvq7rqtn.js +329 -0
- package/dist/server/_chunks/index-vz0km5qk.js +33 -0
- package/dist/server/_chunks/index-w6h8m6vp.js +138 -0
- package/dist/server/_chunks/index-web361b8.js +138 -0
- package/dist/server/_chunks/index-wm36rj4v.js +311 -0
- package/dist/server/_chunks/index-x0y005nh.js +283 -0
- package/dist/server/_chunks/index-x2m17v9c.js +6166 -0
- package/dist/server/_chunks/index-x3yn4ywm.js +22 -0
- package/dist/server/_chunks/index-x9c55pzy.js +871 -0
- package/dist/server/_chunks/index-xh1nbk46.js +1299 -0
- package/dist/server/_chunks/index-xvj80c3a.js +30 -0
- package/dist/server/_chunks/index-xywjg2vc.js +100 -0
- package/dist/server/_chunks/index-y4d02znn.js +66 -0
- package/dist/server/_chunks/index-y7mzvq2q.js +110 -0
- package/dist/server/_chunks/index-ye9hmsvf.js +47 -0
- package/dist/server/_chunks/index-yhxkxghe.js +56 -0
- package/dist/server/_chunks/index-yrjkqtfj.js +86 -0
- package/dist/server/_chunks/index-z88qv16t.js +11 -0
- package/dist/server/_chunks/index-zfrwq472.js +154 -0
- package/dist/server/_chunks/index-zqpqyg8p.js +666 -0
- package/dist/server/_chunks/loader-5en7wpt5.js +80 -0
- package/dist/server/_chunks/modules-t92favpj.js +76 -0
- package/dist/server/_chunks/pipeline-4t9q43ht.js +836 -0
- package/dist/server/_chunks/production-385bw8df.js +55 -0
- package/dist/server/_chunks/proxy-config-60gprphe.js +23 -0
- package/dist/server/_chunks/proxy-gfhmktbk.js +35 -0
- package/dist/server/_chunks/router-xnrva921.js +501 -0
- package/dist/server/_chunks/routes-ht868pdc.js +66 -0
- package/dist/server/_chunks/run-d40d63ag.js +697 -0
- package/dist/server/_chunks/server-2p8fgqq2.js +1839 -0
- package/dist/server/_chunks/tsconfig-defaults-bcn34eqb.js +21 -0
- package/dist/server/_chunks/typegen-dvtcjtaw.js +37 -0
- package/dist/server/api/client-cache.js +14 -0
- package/dist/server/cli/index.js +375 -0
- package/dist/server/cli/start.js +158 -0
- package/dist/server/client/reference.js +16 -0
- package/dist/server/compat/next/cache.js +56 -0
- package/dist/server/compat/next/canonical-url.js +13 -0
- package/dist/server/compat/next/client-cache.js +57 -0
- package/dist/server/compat/next/client-navigation.js +232 -0
- package/dist/server/compat/next/client-only.js +1 -0
- package/dist/server/compat/next/client-script.js +178 -0
- package/dist/server/compat/next/client-server.js +34 -0
- package/dist/server/compat/next/config-headers.js +34 -0
- package/dist/server/compat/next/config-loader.js +25 -0
- package/dist/server/compat/next/config.js +10 -0
- package/dist/server/compat/next/constants.js +18 -0
- package/dist/server/compat/next/custom-server.js +10 -0
- package/dist/server/compat/next/dist/client/components/app-router-headers.js +48 -0
- package/dist/server/compat/next/dist/server/web/spec-extension/revalidate.js +27 -0
- package/dist/server/compat/next/dist/server/web/spec-extension/unstable-cache.js +25 -0
- package/dist/server/compat/next/dist/server/web/spec-extension/unstable-no-store.js +25 -0
- package/dist/server/compat/next/dynamic.js +21 -0
- package/dist/server/compat/next/error.js +112 -0
- package/dist/server/compat/next/font/cache.js +16 -0
- package/dist/server/compat/next/font/google.js +3 -0
- package/dist/server/compat/next/font/index.js +1 -0
- package/dist/server/compat/next/font/local.js +24 -0
- package/dist/server/compat/next/font/runtime-client.js +33 -0
- package/dist/server/compat/next/font/runtime.js +43 -0
- package/dist/server/compat/next/font/shared.js +22 -0
- package/dist/server/compat/next/form.js +129 -0
- package/dist/server/compat/next/head.js +10 -0
- package/dist/server/compat/next/headers.js +30 -0
- package/dist/server/compat/next/image/client.js +11 -0
- package/dist/server/compat/next/image/config.js +18 -0
- package/dist/server/compat/next/image/optimizer.js +25 -0
- package/dist/server/compat/next/image/patterns.js +12 -0
- package/dist/server/compat/next/image/props.js +16 -0
- package/dist/server/compat/next/image/shared.js +86 -0
- package/dist/server/compat/next/image/static-metadata.js +32 -0
- package/dist/server/compat/next/image/validate.js +8 -0
- package/dist/server/compat/next/image.js +59 -0
- package/dist/server/compat/next/index.js +1 -0
- package/dist/server/compat/next/legacy-image.js +78 -0
- package/dist/server/compat/next/legacy-request-apis.js +24 -0
- package/dist/server/compat/next/link-transform.js +15 -0
- package/dist/server/compat/next/link.js +14 -0
- package/dist/server/compat/next/navigation.js +191 -0
- package/dist/server/compat/next/offline.js +45 -0
- package/dist/server/compat/next/og.js +8 -0
- package/dist/server/compat/next/preferred-region.js +8 -0
- package/dist/server/compat/next/redirects.js +32 -0
- package/dist/server/compat/next/resource-hints.js +30 -0
- package/dist/server/compat/next/rewrites.js +43 -0
- package/dist/server/compat/next/root-params.js +121 -0
- package/dist/server/compat/next/route-state.js +23 -0
- package/dist/server/compat/next/router.js +103 -0
- package/dist/server/compat/next/script.js +37 -0
- package/dist/server/compat/next/server-only.js +1 -0
- package/dist/server/compat/next/server.js +131 -0
- package/dist/server/compat/next/svgr.js +14 -0
- package/dist/server/compat/next/telemetry.js +10 -0
- package/dist/server/compat/next/usage.js +13 -0
- package/dist/server/compat/next/user-agent.js +12 -0
- package/dist/server/compat/next/web-vitals.js +35 -0
- package/dist/server/compat/react/action-state.js +11 -0
- package/dist/server/compat/react/client-lite.js +83 -0
- package/dist/server/compat/react/client.js +131 -0
- package/dist/server/compat/react/compiler-runtime.js +42 -0
- package/dist/server/compat/react/dom-client.js +106 -0
- package/dist/server/compat/react/dom-react-server.js +37 -0
- package/dist/server/compat/react/dom-server.js +40 -0
- package/dist/server/compat/react/dom.js +52 -0
- package/dist/server/compat/react/hooks-extra.js +12 -0
- package/dist/server/compat/react/internals.js +14 -0
- package/dist/server/compat/react/parity.js +11 -0
- package/dist/server/compat/react/preact.js +113 -0
- package/dist/server/compat/react/react-server.js +133 -0
- package/dist/server/compat/react/router-shim.js +8 -0
- package/dist/server/compat/react/server-component-use.js +14 -0
- package/dist/server/compat/react/server-inserted-html.js +14 -0
- package/dist/server/compat/react/server.js +194 -0
- package/dist/server/compat/react/style-values.js +10 -0
- package/dist/server/compat/react/use.js +10 -0
- package/dist/server/compat/react/view-transition.js +12 -0
- package/dist/server/generation.json +1 -0
- package/package.json +4 -1
- package/reference/compat.md +1 -1
- package/reference/config.md +2 -2
- package/reference/dev.md +1 -1
- package/reference/getting-started.md +1 -1
- package/reference/rendering.md +4 -4
- package/src/api/dynamic.tsx +86 -4
- package/src/api/server.ts +24 -6
- package/src/cli/adapters/vercel-warm.ts +327 -62
- package/src/cli/adapters/vercel.ts +164 -1054
- package/src/cli/analyze.ts +3 -2
- package/src/cli/build/cache.ts +6 -6
- package/src/cli/build.ts +78 -45
- package/src/cli/index.ts +21 -3
- package/src/cli/serve/immutable.ts +31 -0
- package/src/cli/serve/pipeline.ts +97 -93
- package/src/cli/serve/standalone-worker.ts +8 -0
- package/src/cli/serve/standalone.ts +703 -0
- package/src/cli/start.ts +31 -8
- package/src/client/build.ts +1 -1
- package/src/client/chunk-fold.ts +19 -6
- package/src/client/react-tier.ts +3 -2
- package/src/client/reference-stub.ts +23 -36
- package/src/compat/actions/client-plugin.ts +4 -2
- package/src/compat/actions/config.ts +6 -5
- package/src/compat/actions/extensions.ts +5 -5
- package/src/compat/aliases.ts +8 -1
- package/src/compat/bundler/config.ts +88 -0
- package/src/compat/bundler/optimize-package-imports.ts +86 -26
- package/src/compat/bundler/relay-transform.ts +15 -3
- package/src/compat/bundler/require-context.ts +2 -1
- package/src/compat/bundler/webpack-loaders.ts +3 -2
- package/src/compat/bundler/worker.ts +2 -2
- package/src/compat/cache-control.ts +16 -8
- package/src/compat/css/inline-css.ts +1 -1
- package/src/compat/css/modules.ts +18 -5
- package/src/compat/export/build-complete.ts +1 -1
- package/src/compat/export/emit.ts +4 -4
- package/src/compat/export/standalone.ts +30 -65
- package/src/compat/image-optimizer/optimize.ts +1 -1
- package/src/compat/lifecycle/error-funnel.ts +1 -1
- package/src/compat/lifecycle/instrumentation-client.ts +4 -3
- package/src/compat/lifecycle/instrumentation.ts +117 -24
- package/src/compat/lifecycle/testmode.ts +3 -2
- package/src/compat/metadata-artifacts.ts +1 -1
- package/src/compat/next/config-loader.ts +140 -13
- package/src/compat/next/dynamic.tsx +10 -23
- package/src/compat/next/font/cache.ts +2 -1
- package/src/compat/next/font/runtime.ts +23 -3
- package/src/compat/next/og.ts +3 -3
- package/src/compat/next/usage.ts +3 -2
- package/src/compat/pages/api.ts +83 -14
- package/src/compat/pages/router.ts +30 -14
- package/src/compat/register/bundler.ts +3 -1
- package/src/compat/register/image.ts +1 -1
- package/src/compat/register/middleware.ts +1 -1
- package/src/compat/register/otel.ts +5 -9
- package/src/compat/register/render.ts +3 -1
- package/src/compat/register/use-cache.ts +3 -1
- package/src/compat/release.ts +46 -0
- package/src/compat/segment/serve.ts +1 -1
- package/src/compat/typecheck/check.ts +6 -4
- package/src/compat/validation/validate.ts +10 -7
- package/src/config.ts +76 -9
- package/src/css/assets.ts +213 -0
- package/src/css/build.ts +190 -247
- package/src/dev/client-chunk-store.ts +2 -1
- package/src/dev/restart/client-key.ts +2 -1
- package/src/dev/restart/global-css.ts +2 -1
- package/src/dev/restart/route-bundle-key.ts +2 -1
- package/src/dev/restart/route-facts.ts +2 -1
- package/src/dev/server.ts +34 -14
- package/src/extensions.ts +4 -0
- package/src/out-paths.ts +10 -0
- package/src/render/hooks.ts +13 -0
- package/src/render/renderer.ts +53 -33
- package/src/request/context.ts +9 -0
- package/src/resolve/dynamic.ts +7 -1
- package/src/resolve/engine.ts +2 -12
- package/src/resolve/imports.ts +12 -52
- package/src/resolve/package-json.ts +56 -0
- package/src/resolve/scan-facts.ts +250 -1
- package/src/routing/href.ts +10 -3
- package/src/routing/match.ts +287 -0
- package/src/routing/metadata-files.ts +20 -6
- package/src/routing/proxy-config.ts +137 -0
- package/src/routing/proxy.ts +35 -134
- package/src/routing/routes.ts +22 -281
- package/src/runtime/fingerprint.ts +23 -8
- package/src/runtime/load.ts +170 -0
- package/src/runtime/loader.ts +218 -44
- package/src/runtime/module-cache.ts +15 -1
- package/src/runtime/modules.ts +405 -82
- package/src/runtime/prebundle.ts +101 -0
- package/src/runtime/production.ts +456 -0
- package/src/runtime/release-graph.ts +342 -0
- package/src/runtime/vendor-build.ts +750 -17
- package/src/runtime/vendor.ts +16 -3
- package/src/types.ts +4 -3
- package/src/utils/directive.ts +40 -0
- package/src/utils/fs.ts +95 -4
- package/src/utils/resource-query.ts +12 -0
- package/src/cli/serve/entry.ts +0 -45
|
@@ -0,0 +1,2456 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import { join as __pnextJoin } from "node:path";
|
|
3
|
+
const __PNEXT_PACKAGE_ROOT__ = __pnextJoin(import.meta.dirname, "../../..");
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_DYNAMIC_STALE_TIME_SECONDS,
|
|
6
|
+
DEFAULT_STATIC_STALE_TIME_SECONDS,
|
|
7
|
+
bodySegmentFile,
|
|
8
|
+
buildRootTreePrefetch,
|
|
9
|
+
buildSegmentMeta,
|
|
10
|
+
readMiddlewareWasmBindingsForOutPath,
|
|
11
|
+
rootTreePrefetchText,
|
|
12
|
+
segmentDir,
|
|
13
|
+
segmentMetaFile,
|
|
14
|
+
treeSegmentFile,
|
|
15
|
+
validateBuild,
|
|
16
|
+
warnNextMetadataBuildIssues
|
|
17
|
+
} from "./index-j681c48a.js";
|
|
18
|
+
import {
|
|
19
|
+
writeTsconfigDefaults
|
|
20
|
+
} from "./index-b7j671dj.js";
|
|
21
|
+
import {
|
|
22
|
+
generateTypedRoutes
|
|
23
|
+
} from "./index-9hz3s0m8.js";
|
|
24
|
+
import {
|
|
25
|
+
scanRootParamTypes
|
|
26
|
+
} from "./index-v1ags1na.js";
|
|
27
|
+
import {
|
|
28
|
+
discoverStaticMetadataFiles
|
|
29
|
+
} from "./index-x2m17v9c.js";
|
|
30
|
+
import {
|
|
31
|
+
deploymentId,
|
|
32
|
+
turbopackLoaderRules
|
|
33
|
+
} from "./index-wm36rj4v.js";
|
|
34
|
+
import"./index-8ct7rqy3.js";
|
|
35
|
+
import {
|
|
36
|
+
nextCompatEnabled,
|
|
37
|
+
reactCompatEnabled,
|
|
38
|
+
reactCompilerOptions
|
|
39
|
+
} from "./index-kdhxpwyq.js";
|
|
40
|
+
import {
|
|
41
|
+
findProxyFile,
|
|
42
|
+
proxyExternalLoadTarget
|
|
43
|
+
} from "./index-3ycf5ckv.js";
|
|
44
|
+
import {
|
|
45
|
+
devServerModuleHref
|
|
46
|
+
} from "./index-0yjv5v47.js";
|
|
47
|
+
import"./index-d158y67j.js";
|
|
48
|
+
import"./index-web361b8.js";
|
|
49
|
+
import {
|
|
50
|
+
preferredRegionForRoute
|
|
51
|
+
} from "./index-xvj80c3a.js";
|
|
52
|
+
import {
|
|
53
|
+
fontLinkHeaderValue,
|
|
54
|
+
takeFontHeaderPreloads
|
|
55
|
+
} from "./index-gkndxkxf.js";
|
|
56
|
+
import"./index-qcrvt6er.js";
|
|
57
|
+
import"./index-knp0s912.js";
|
|
58
|
+
import"./index-gcmj16xy.js";
|
|
59
|
+
import"./index-fn1chkkd.js";
|
|
60
|
+
import"./index-ye9hmsvf.js";
|
|
61
|
+
import"./index-6q7zvrap.js";
|
|
62
|
+
import {
|
|
63
|
+
takeResourceHintHeader
|
|
64
|
+
} from "./index-tf4j19ge.js";
|
|
65
|
+
import"./index-stbk3jhn.js";
|
|
66
|
+
import {
|
|
67
|
+
aliasGenerateStaticParams,
|
|
68
|
+
varyNamesFor,
|
|
69
|
+
withVaryParamsTracking
|
|
70
|
+
} from "./index-x0y005nh.js";
|
|
71
|
+
import {
|
|
72
|
+
diagnoseCacheComponentsPrerender,
|
|
73
|
+
diagnosticLeadsWithErrorLine,
|
|
74
|
+
prerenderFailureFooter,
|
|
75
|
+
takeCacheLifeStash,
|
|
76
|
+
writeBuildFlags
|
|
77
|
+
} from "./index-j0m1jxqa.js";
|
|
78
|
+
import"./index-z88qv16t.js";
|
|
79
|
+
import"./index-fp8r0sqs.js";
|
|
80
|
+
import"./index-akkrvjn6.js";
|
|
81
|
+
import"./index-bcws5eh2.js";
|
|
82
|
+
import {
|
|
83
|
+
getNextConfig
|
|
84
|
+
} from "./index-m63czgq5.js";
|
|
85
|
+
import"./index-cjgqs13g.js";
|
|
86
|
+
import"./index-jks0x0a1.js";
|
|
87
|
+
import"./index-6b009mt0.js";
|
|
88
|
+
import"./index-4zzebszd.js";
|
|
89
|
+
import"./index-sq3kvz3g.js";
|
|
90
|
+
import"./index-ckkdpht5.js";
|
|
91
|
+
import {
|
|
92
|
+
emitCustomServerShim
|
|
93
|
+
} from "./index-8kcxdfya.js";
|
|
94
|
+
import"./index-yhxkxghe.js";
|
|
95
|
+
import"./index-29pq0kax.js";
|
|
96
|
+
import"./index-cn86z041.js";
|
|
97
|
+
import {
|
|
98
|
+
listFiles,
|
|
99
|
+
toPosixPath
|
|
100
|
+
} from "./index-4da76t62.js";
|
|
101
|
+
import"./index-vz0km5qk.js";
|
|
102
|
+
import {
|
|
103
|
+
pathToFileHref
|
|
104
|
+
} from "./index-71885zaq.js";
|
|
105
|
+
import"./index-bzd2ef7t.js";
|
|
106
|
+
import"./index-jcsjq3d1.js";
|
|
107
|
+
import"./index-hdbwtdv2.js";
|
|
108
|
+
import"./index-ras0sdab.js";
|
|
109
|
+
import {
|
|
110
|
+
legacyRequestAPIs
|
|
111
|
+
} from "./index-grta8ap3.js";
|
|
112
|
+
import"./index-kresp2n8.js";
|
|
113
|
+
import"./index-e3a6yx84.js";
|
|
114
|
+
import"./index-7wc9n8be.js";
|
|
115
|
+
import"./index-pym1cezq.js";
|
|
116
|
+
import"./index-jt8e1pje.js";
|
|
117
|
+
import {
|
|
118
|
+
onExtensionHostReset,
|
|
119
|
+
registerBuildCompleteHooks,
|
|
120
|
+
registerBuildParallelPhases,
|
|
121
|
+
registerBuildSteps,
|
|
122
|
+
setBuildCompatExtensions,
|
|
123
|
+
setCompatModeExtensions
|
|
124
|
+
} from "./index-zqpqyg8p.js";
|
|
125
|
+
import"./index-qjj6gddn.js";
|
|
126
|
+
import"./index-4399bvd2.js";
|
|
127
|
+
import {
|
|
128
|
+
__require
|
|
129
|
+
} from "./index-rt9qq1va.js";
|
|
130
|
+
|
|
131
|
+
// src/compat/register/build.ts
|
|
132
|
+
import { mkdir as mkdir2, readFile, writeFile as writeFile2 } from "fs/promises";
|
|
133
|
+
import path2 from "path";
|
|
134
|
+
|
|
135
|
+
// src/compat/export/build-complete.ts
|
|
136
|
+
import { existsSync } from "fs";
|
|
137
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
138
|
+
import path from "path";
|
|
139
|
+
function staticPathname(relative) {
|
|
140
|
+
const url = `/${relative.replace(/\\/g, "/")}`;
|
|
141
|
+
if (url.endsWith("/index.html"))
|
|
142
|
+
return url.slice(0, -"index.html".length) || "/";
|
|
143
|
+
return url.endsWith(".html") ? url.slice(0, -".html".length) : url;
|
|
144
|
+
}
|
|
145
|
+
function serverEntryPath(config, route) {
|
|
146
|
+
return path.join(config.outPath, "server", `${route.id}.js`);
|
|
147
|
+
}
|
|
148
|
+
async function writeServerEntries(config, manifest) {
|
|
149
|
+
await mkdir(path.join(config.outPath, "server"), { recursive: true });
|
|
150
|
+
await Promise.all(manifest.routes.map((route) => writeFile(serverEntryPath(config, route), [
|
|
151
|
+
"// Generated by `pnext build` for the configured deployment adapter.",
|
|
152
|
+
"// pnext serves every route from one server process (`pnext start`);",
|
|
153
|
+
"// this entry identifies the route rather than bundling it standalone.",
|
|
154
|
+
`export const id = ${JSON.stringify(route.id)};`,
|
|
155
|
+
`export const pathname = ${JSON.stringify(route.route)};`,
|
|
156
|
+
`export const sourcePage = ${JSON.stringify(sourcePage(config, route))};`,
|
|
157
|
+
`export const kind = ${JSON.stringify(route.kind)};`,
|
|
158
|
+
"export const runtime = 'nodejs';",
|
|
159
|
+
"export default { id, pathname, sourcePage, kind, runtime };",
|
|
160
|
+
""
|
|
161
|
+
].join(`
|
|
162
|
+
`))));
|
|
163
|
+
}
|
|
164
|
+
function sourcePage(config, route) {
|
|
165
|
+
return `/${path.relative(config.root, route.file).replace(/\\/g, "/")}`;
|
|
166
|
+
}
|
|
167
|
+
function sharedFields(config, route) {
|
|
168
|
+
return {
|
|
169
|
+
id: route.id,
|
|
170
|
+
filePath: serverEntryPath(config, route),
|
|
171
|
+
pathname: route.route,
|
|
172
|
+
sourcePage: sourcePage(config, route),
|
|
173
|
+
runtime: "nodejs",
|
|
174
|
+
assets: {},
|
|
175
|
+
assetsHashes: {},
|
|
176
|
+
config: {
|
|
177
|
+
...route.maxDuration !== undefined ? { maxDuration: route.maxDuration } : {}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function collectOutputs(config, manifest) {
|
|
182
|
+
const outputs = {
|
|
183
|
+
pages: [],
|
|
184
|
+
appPages: [],
|
|
185
|
+
pagesApi: [],
|
|
186
|
+
appRoutes: [],
|
|
187
|
+
prerenders: [],
|
|
188
|
+
staticFiles: []
|
|
189
|
+
};
|
|
190
|
+
const prerenderedRoutes = new Set;
|
|
191
|
+
for (const [relative, metadata] of Object.entries(manifest.staticFiles ?? {})) {
|
|
192
|
+
const filePath = path.join(config.outPath, "static", relative);
|
|
193
|
+
if (!existsSync(filePath))
|
|
194
|
+
continue;
|
|
195
|
+
if (metadata.routeId)
|
|
196
|
+
prerenderedRoutes.add(metadata.routeId);
|
|
197
|
+
const entry = { id: relative, filePath, pathname: staticPathname(relative) };
|
|
198
|
+
if (metadata.revalidateSeconds !== undefined) {
|
|
199
|
+
outputs.prerenders.push({
|
|
200
|
+
...entry,
|
|
201
|
+
type: "PRERENDER",
|
|
202
|
+
parentOutputId: metadata.routeId ?? relative
|
|
203
|
+
});
|
|
204
|
+
} else {
|
|
205
|
+
outputs.staticFiles.push({ ...entry, type: "STATIC_FILE" });
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
for (const route of manifest.routes) {
|
|
209
|
+
if (prerenderedRoutes.has(route.id) && route.mode === "static" && !route.ppr)
|
|
210
|
+
continue;
|
|
211
|
+
const fields = sharedFields(config, route);
|
|
212
|
+
if (route.kind === "handler") {
|
|
213
|
+
outputs.appRoutes.push({ ...fields, type: "APP_ROUTE" });
|
|
214
|
+
} else {
|
|
215
|
+
outputs.appPages.push({ ...fields, type: "APP_PAGE" });
|
|
216
|
+
outputs.appPages.push({
|
|
217
|
+
...fields,
|
|
218
|
+
type: "APP_PAGE",
|
|
219
|
+
id: `${route.id}.rsc`,
|
|
220
|
+
pathname: `${fields.pathname}.rsc`
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return outputs;
|
|
225
|
+
}
|
|
226
|
+
function namedSourceRegex(route) {
|
|
227
|
+
let index = 0;
|
|
228
|
+
const named = route.pattern.replace(/\((\[\^\/\]\+|\.\*)\)/g, (whole, body) => {
|
|
229
|
+
const param = route.params[index++];
|
|
230
|
+
return param ? `(?<${param.replace(/\W/g, "")}>${body})` : whole;
|
|
231
|
+
});
|
|
232
|
+
return `^${named}(?:/)?$`;
|
|
233
|
+
}
|
|
234
|
+
function collectDynamicRoutes(manifest) {
|
|
235
|
+
const routes = [];
|
|
236
|
+
for (const route of manifest.routes) {
|
|
237
|
+
if (route.params.length === 0)
|
|
238
|
+
continue;
|
|
239
|
+
const sourceRegex = namedSourceRegex(route);
|
|
240
|
+
if (route.kind === "page") {
|
|
241
|
+
routes.push({
|
|
242
|
+
source: `${route.route}.rsc`,
|
|
243
|
+
sourceRegex: sourceRegex.replace(/\(\?:\/\)\?\$$/, String.raw`(?<rscSuffix>\.rsc|\.segments/.+\.segment\.rsc)(?:/)?$`),
|
|
244
|
+
destination: `${route.route}$rscSuffix`
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
routes.push({ source: route.route, sourceRegex, destination: route.route });
|
|
248
|
+
}
|
|
249
|
+
return routes;
|
|
250
|
+
}
|
|
251
|
+
async function runBuildCompleteAdapter(config, manifest) {
|
|
252
|
+
const configured = getNextConfig().adapterPath;
|
|
253
|
+
const adapterPath = process.env.NEXT_ADAPTER_PATH || (typeof configured === "string" ? configured : undefined);
|
|
254
|
+
if (!adapterPath)
|
|
255
|
+
return;
|
|
256
|
+
const resolved = path.isAbsolute(adapterPath) ? adapterPath : path.resolve(config.root, adapterPath);
|
|
257
|
+
const module = await import(pathToFileHref(resolved));
|
|
258
|
+
const adapter = module.default ?? module;
|
|
259
|
+
if (typeof adapter?.onBuildComplete !== "function")
|
|
260
|
+
return;
|
|
261
|
+
await writeServerEntries(config, manifest);
|
|
262
|
+
await adapter.onBuildComplete({
|
|
263
|
+
routing: {
|
|
264
|
+
beforeMiddleware: [],
|
|
265
|
+
middlewareMatchers: [],
|
|
266
|
+
beforeFiles: [],
|
|
267
|
+
afterFiles: [],
|
|
268
|
+
dynamicRoutes: collectDynamicRoutes(manifest),
|
|
269
|
+
onMatch: [],
|
|
270
|
+
fallback: [],
|
|
271
|
+
shouldNormalizeNextData: false,
|
|
272
|
+
rsc: undefined
|
|
273
|
+
},
|
|
274
|
+
outputs: collectOutputs(config, manifest),
|
|
275
|
+
projectDir: config.root,
|
|
276
|
+
repoRoot: config.root,
|
|
277
|
+
distDir: config.outPath
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// src/compat/register/build.ts
|
|
282
|
+
function registerBuildCompatExtensions() {
|
|
283
|
+
registerBuildCompleteHooks(({ config, manifest }) => writeFunctionsConfigManifest(config.outPath, manifest));
|
|
284
|
+
registerBuildCompleteHooks(({ config }) => writeRequiredServerFilesManifest(config));
|
|
285
|
+
registerBuildCompleteHooks(({ config }) => writeTraceBuildFile(config));
|
|
286
|
+
registerBuildCompleteHooks(({ config, manifest }) => runBuildCompleteAdapter(config, manifest));
|
|
287
|
+
setCompatModeExtensions({
|
|
288
|
+
nextEnabled: nextCompatEnabled,
|
|
289
|
+
reactEnabled: reactCompatEnabled,
|
|
290
|
+
reactCompilerOptions
|
|
291
|
+
});
|
|
292
|
+
setBuildCompatExtensions({
|
|
293
|
+
warnMetadataIssues: ({ appPath, routes, staticMetadataFiles }) => warnNextMetadataBuildIssues(appPath, routes, staticMetadataFiles),
|
|
294
|
+
nextOutputExport: () => getNextConfig().output === "export",
|
|
295
|
+
nextOutputMode: () => {
|
|
296
|
+
const output = getNextConfig().output;
|
|
297
|
+
return output === "export" || output === "standalone" ? output : undefined;
|
|
298
|
+
},
|
|
299
|
+
nextScriptWorkersEnabled: () => {
|
|
300
|
+
const experimental = getNextConfig().experimental;
|
|
301
|
+
return experimental?.nextScriptWorkers === true;
|
|
302
|
+
},
|
|
303
|
+
defaultExpireTimeSeconds: () => {
|
|
304
|
+
const expireTime = getNextConfig().expireTime;
|
|
305
|
+
return typeof expireTime === "number" ? expireTime : undefined;
|
|
306
|
+
},
|
|
307
|
+
withVaryParamsTracking,
|
|
308
|
+
varyNamesFor: (vary, kind) => varyNamesFor(vary, kind),
|
|
309
|
+
takeCacheLifeStash,
|
|
310
|
+
takeFontLinkHeader: () => {
|
|
311
|
+
const fontValues = takeFontHeaderPreloads().map(fontLinkHeaderValue);
|
|
312
|
+
const hintValue = takeResourceHintHeader();
|
|
313
|
+
const values = [...fontValues, ...hintValue ? [hintValue] : []];
|
|
314
|
+
if (values.length === 0)
|
|
315
|
+
return;
|
|
316
|
+
return values.join(", ");
|
|
317
|
+
},
|
|
318
|
+
normalizeStaticParamsModule: aliasGenerateStaticParams,
|
|
319
|
+
defaultDynamicStaleTimeSeconds: DEFAULT_DYNAMIC_STALE_TIME_SECONDS,
|
|
320
|
+
defaultStaticStaleTimeSeconds: DEFAULT_STATIC_STALE_TIME_SECONDS,
|
|
321
|
+
buildRootTreePrefetch,
|
|
322
|
+
rootTreePrefetchText,
|
|
323
|
+
buildSegmentMeta,
|
|
324
|
+
segmentDir,
|
|
325
|
+
treeSegmentFile,
|
|
326
|
+
bodySegmentFile,
|
|
327
|
+
segmentMetaFile
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
async function writeRequiredServerFilesManifest(config) {
|
|
331
|
+
if (!nextCompatEnabled(config))
|
|
332
|
+
return;
|
|
333
|
+
const id = deploymentId();
|
|
334
|
+
if (!id)
|
|
335
|
+
return;
|
|
336
|
+
const outDir = path2.join(config.root, ".next");
|
|
337
|
+
await mkdir2(outDir, { recursive: true });
|
|
338
|
+
await writeFile2(path2.join(outDir, "required-server-files.json"), JSON.stringify({ version: 1, config: { deploymentId: id } }, null, 2));
|
|
339
|
+
}
|
|
340
|
+
var traceBuildGlobal = globalThis;
|
|
341
|
+
traceBuildGlobal.__pnextBuildStartedAt ??= performance.now();
|
|
342
|
+
async function writeTraceBuildFile(config) {
|
|
343
|
+
if (!nextCompatEnabled(config))
|
|
344
|
+
return;
|
|
345
|
+
const traceId = randomTraceId();
|
|
346
|
+
const totalDuration = Math.max(1, performance.now() - (traceBuildGlobal.__pnextBuildStartedAt ?? 0));
|
|
347
|
+
const events = [
|
|
348
|
+
{ name: "next-build", id: 1, traceId, duration: totalDuration },
|
|
349
|
+
{ name: "run-webpack", id: 2, parentId: 1, traceId, duration: totalDuration * 0.4 },
|
|
350
|
+
{ name: "run-typescript", id: 3, parentId: 1, traceId, duration: totalDuration * 0.2 },
|
|
351
|
+
{ name: "static-check", id: 4, parentId: 1, traceId, duration: totalDuration * 0.1 },
|
|
352
|
+
{ name: "static-generation", id: 5, parentId: 1, traceId, duration: totalDuration * 0.2 },
|
|
353
|
+
{ name: "collect-build-traces", id: 6, parentId: 1, traceId, duration: totalDuration * 0.05 },
|
|
354
|
+
{ name: "telemetry-flush", id: 7, parentId: 1, traceId, duration: 1 }
|
|
355
|
+
];
|
|
356
|
+
const outDir = path2.join(config.root, ".next");
|
|
357
|
+
await mkdir2(outDir, { recursive: true });
|
|
358
|
+
await writeFile2(path2.join(outDir, "trace-build"), `${JSON.stringify(events)}
|
|
359
|
+
`);
|
|
360
|
+
}
|
|
361
|
+
function randomTraceId() {
|
|
362
|
+
return Array.from({ length: 16 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
363
|
+
}
|
|
364
|
+
async function writeFunctionsConfigManifest(outPath, manifest) {
|
|
365
|
+
const routes = manifest.routes.filter((route) => route.maxDuration !== undefined);
|
|
366
|
+
if (routes.length === 0)
|
|
367
|
+
return;
|
|
368
|
+
const file = path2.join(outPath, "server", "functions-config-manifest.json");
|
|
369
|
+
let current = { version: 1, functions: {} };
|
|
370
|
+
try {
|
|
371
|
+
current = JSON.parse(await readFile(file, "utf8"));
|
|
372
|
+
} catch {
|
|
373
|
+
current = { version: 1, functions: {} };
|
|
374
|
+
}
|
|
375
|
+
for (const route of routes) {
|
|
376
|
+
const regions = preferredRegionForRoute(route);
|
|
377
|
+
current.functions[route.route || "/"] = {
|
|
378
|
+
...current.functions[route.route || "/"] ?? {},
|
|
379
|
+
maxDuration: route.maxDuration,
|
|
380
|
+
...regions ? { regions } : {}
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
await mkdir2(path2.dirname(file), { recursive: true });
|
|
384
|
+
await writeFile2(file, `${JSON.stringify(current, null, 2)}
|
|
385
|
+
`);
|
|
386
|
+
}
|
|
387
|
+
// src/compat/typecheck/check.ts
|
|
388
|
+
import { existsSync as existsSync2, statSync } from "fs";
|
|
389
|
+
import { mkdir as mkdir3, writeFile as writeFile3 } from "fs/promises";
|
|
390
|
+
import { createRequire } from "module";
|
|
391
|
+
import path3 from "path";
|
|
392
|
+
import { Worker } from "worker_threads";
|
|
393
|
+
class PnextTypecheckError extends Error {
|
|
394
|
+
messages;
|
|
395
|
+
constructor(messages) {
|
|
396
|
+
super(messages.join(`
|
|
397
|
+
`));
|
|
398
|
+
this.name = "PnextTypecheckError";
|
|
399
|
+
this.messages = messages;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
var typescriptModule;
|
|
403
|
+
async function loadTypescript() {
|
|
404
|
+
typescriptModule ??= await import("typescript");
|
|
405
|
+
return typescriptModule;
|
|
406
|
+
}
|
|
407
|
+
function typecheckDisabled() {
|
|
408
|
+
const typescript = getNextConfig().typescript;
|
|
409
|
+
return typescript?.ignoreBuildErrors === true;
|
|
410
|
+
}
|
|
411
|
+
async function validateTypesOffThread(config) {
|
|
412
|
+
if (typecheckDisabled())
|
|
413
|
+
return;
|
|
414
|
+
const next = getNextConfig();
|
|
415
|
+
const input = {
|
|
416
|
+
root: config.root,
|
|
417
|
+
outPath: config.outPath,
|
|
418
|
+
outRootPath: config.outRootPath,
|
|
419
|
+
compat: config.compat,
|
|
420
|
+
nextConfig: cloneable({
|
|
421
|
+
typescript: next.typescript,
|
|
422
|
+
typedRoutes: next.typedRoutes,
|
|
423
|
+
turbopack: next.turbopack
|
|
424
|
+
})
|
|
425
|
+
};
|
|
426
|
+
let worker;
|
|
427
|
+
try {
|
|
428
|
+
worker = new Worker(new URL("./worker.ts", Bun.pathToFileURL(__PNEXT_PACKAGE_ROOT__ + "/src/compat/typecheck/check.ts").href), { workerData: input });
|
|
429
|
+
} catch {
|
|
430
|
+
return validateTypes(config);
|
|
431
|
+
}
|
|
432
|
+
const result = await new Promise((resolve, reject) => {
|
|
433
|
+
worker.on("message", resolve);
|
|
434
|
+
worker.on("error", reject);
|
|
435
|
+
worker.on("exit", () => resolve({ ok: true }));
|
|
436
|
+
}).finally(() => void worker.terminate());
|
|
437
|
+
if (result.ok)
|
|
438
|
+
return;
|
|
439
|
+
if (result.messages)
|
|
440
|
+
throw new PnextTypecheckError(result.messages);
|
|
441
|
+
throw new Error(result.failure ?? "typecheck worker failed");
|
|
442
|
+
}
|
|
443
|
+
function cloneable(value) {
|
|
444
|
+
try {
|
|
445
|
+
return JSON.parse(JSON.stringify(value));
|
|
446
|
+
} catch {
|
|
447
|
+
return {};
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
async function validateTypes(config) {
|
|
451
|
+
if (typecheckDisabled())
|
|
452
|
+
return;
|
|
453
|
+
const native = await nativeCheckerBin(config.root);
|
|
454
|
+
const project = await writeTypecheckProject(config, native);
|
|
455
|
+
if (native && (await checkWithNative(native, project, config)).length === 0)
|
|
456
|
+
return;
|
|
457
|
+
const messages = await checkInProcess(project, config);
|
|
458
|
+
if (messages.length === 0)
|
|
459
|
+
return;
|
|
460
|
+
throw new PnextTypecheckError(messages);
|
|
461
|
+
}
|
|
462
|
+
async function checkInProcess(project, config) {
|
|
463
|
+
const ts = await loadTypescript();
|
|
464
|
+
const parsed = readProject(ts, project);
|
|
465
|
+
const program = ts.createProgram(parsed.fileNames, parsed.options);
|
|
466
|
+
const diagnostics = ts.getPreEmitDiagnostics(program).filter((diagnostic) => appDiagnostic(diagnostic.file?.fileName, config));
|
|
467
|
+
return formatDiagnostics(ts, diagnostics);
|
|
468
|
+
}
|
|
469
|
+
async function nativeCheckerBin(root) {
|
|
470
|
+
if (process.env.PNEXT_TYPECHECK === "classic")
|
|
471
|
+
return;
|
|
472
|
+
for (const base of [root, __PNEXT_PACKAGE_ROOT__ + "/src/compat/typecheck"]) {
|
|
473
|
+
try {
|
|
474
|
+
const require2 = createRequire(path3.join(base, "noop.js"));
|
|
475
|
+
const pkg = require2.resolve("@typescript/native-preview/package.json");
|
|
476
|
+
const { default: getExePath } = await import(path3.join(path3.dirname(pkg), "lib", "getExePath.js"));
|
|
477
|
+
const bin = getExePath();
|
|
478
|
+
if (bin && existsSync2(bin))
|
|
479
|
+
return bin;
|
|
480
|
+
} catch {}
|
|
481
|
+
}
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
async function checkWithNative(bin, project, config) {
|
|
485
|
+
const proc = Bun.spawn([bin, "--noEmit", "--pretty", "false", "-p", project], {
|
|
486
|
+
cwd: config.root,
|
|
487
|
+
stdout: "pipe",
|
|
488
|
+
stderr: "pipe"
|
|
489
|
+
});
|
|
490
|
+
const [stdout, stderr] = await Promise.all([
|
|
491
|
+
new Response(proc.stdout).text(),
|
|
492
|
+
new Response(proc.stderr).text()
|
|
493
|
+
]);
|
|
494
|
+
await proc.exited;
|
|
495
|
+
return nativeDiagnostics(`${stdout}${stderr}`, config);
|
|
496
|
+
}
|
|
497
|
+
function nativeDiagnostics(output, config) {
|
|
498
|
+
const header = /^(?:(.+)\((\d+),(\d+)\): )?error TS\d+: (.*)$/;
|
|
499
|
+
const messages = new Set;
|
|
500
|
+
const lines = output.split(`
|
|
501
|
+
`);
|
|
502
|
+
for (let index = 0;index < lines.length; index += 1) {
|
|
503
|
+
const match = header.exec(lines[index]);
|
|
504
|
+
if (!match)
|
|
505
|
+
continue;
|
|
506
|
+
const [, file, line, column, text] = match;
|
|
507
|
+
const elaborations = [];
|
|
508
|
+
while (index + 1 < lines.length && /^\s+\S/.test(lines[index + 1])) {
|
|
509
|
+
elaborations.push(lines[index + 1]);
|
|
510
|
+
index += 1;
|
|
511
|
+
}
|
|
512
|
+
const resolved = file ? path3.resolve(config.root, file) : undefined;
|
|
513
|
+
if (!appDiagnostic(resolved, config))
|
|
514
|
+
continue;
|
|
515
|
+
const raw = [text, ...elaborations].join(`
|
|
516
|
+
`);
|
|
517
|
+
const location = resolved ? `${resolved}:${line}:${column}
|
|
518
|
+
` : "";
|
|
519
|
+
messages.add(`${location}Type error: ${typedRouteMessage(raw) ?? raw}`);
|
|
520
|
+
}
|
|
521
|
+
return [...messages];
|
|
522
|
+
}
|
|
523
|
+
function appDiagnostic(file, config) {
|
|
524
|
+
if (!file)
|
|
525
|
+
return true;
|
|
526
|
+
const resolved = path3.resolve(file);
|
|
527
|
+
if (resolved === generatedProjectPath(config))
|
|
528
|
+
return true;
|
|
529
|
+
if (!resolved.startsWith(config.root + path3.sep))
|
|
530
|
+
return false;
|
|
531
|
+
if (resolved.includes(`${path3.sep}node_modules${path3.sep}`))
|
|
532
|
+
return false;
|
|
533
|
+
if (resolved.startsWith(path3.resolve(config.outRootPath) + path3.sep))
|
|
534
|
+
return false;
|
|
535
|
+
return true;
|
|
536
|
+
}
|
|
537
|
+
function generatedProjectPath(config) {
|
|
538
|
+
return path3.resolve(config.outRootPath, "typecheck", "tsconfig.json");
|
|
539
|
+
}
|
|
540
|
+
function reactTypePaths(root, basePaths, compatPreact) {
|
|
541
|
+
const react = resolveTypesDir("react", root);
|
|
542
|
+
if (!react)
|
|
543
|
+
return basePaths;
|
|
544
|
+
const reactDom = resolveTypesDir("react-dom", root);
|
|
545
|
+
const paths = { ...basePaths };
|
|
546
|
+
const mappings = {
|
|
547
|
+
react: path3.join(react, "index.d.ts"),
|
|
548
|
+
"react/*": path3.join(react, "*"),
|
|
549
|
+
"react-dom": reactDom && path3.join(reactDom, "index.d.ts"),
|
|
550
|
+
"react-dom/*": reactDom && path3.join(reactDom, "*"),
|
|
551
|
+
preact: compatPreact
|
|
552
|
+
};
|
|
553
|
+
for (const [key, value] of Object.entries(mappings)) {
|
|
554
|
+
if (value)
|
|
555
|
+
paths[key] = [value];
|
|
556
|
+
}
|
|
557
|
+
return paths;
|
|
558
|
+
}
|
|
559
|
+
function resolveTypesDir(name, root) {
|
|
560
|
+
for (const base of [root, __PNEXT_PACKAGE_ROOT__ + "/src/compat/typecheck"]) {
|
|
561
|
+
try {
|
|
562
|
+
const require2 = createRequire(path3.join(base, "noop.js"));
|
|
563
|
+
return path3.dirname(require2.resolve(`@types/${name}/package.json`));
|
|
564
|
+
} catch {}
|
|
565
|
+
}
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
function absolutePaths(paths, basePath) {
|
|
569
|
+
if (!paths)
|
|
570
|
+
return;
|
|
571
|
+
return Object.fromEntries(Object.entries(paths).map(([key, targets]) => [
|
|
572
|
+
key,
|
|
573
|
+
targets.map((target) => path3.isAbsolute(target) ? target : path3.resolve(basePath, target))
|
|
574
|
+
]));
|
|
575
|
+
}
|
|
576
|
+
function resolvePackageDir(name, root) {
|
|
577
|
+
for (const base of [root, __PNEXT_PACKAGE_ROOT__ + "/src/compat/typecheck"]) {
|
|
578
|
+
try {
|
|
579
|
+
const require2 = createRequire(path3.join(base, "noop.js"));
|
|
580
|
+
return path3.dirname(require2.resolve(`${name}/package.json`));
|
|
581
|
+
} catch {}
|
|
582
|
+
}
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
async function writeTypecheckProject(config, native) {
|
|
586
|
+
const dir = path3.join(config.outRootPath, "typecheck");
|
|
587
|
+
await mkdir3(dir, { recursive: true });
|
|
588
|
+
const reactTypes = resolveTypesDir("react", config.root);
|
|
589
|
+
const hasReactTypes = reactTypes !== undefined;
|
|
590
|
+
const rootParams = scanRootParamTypes(path3.join(config.root, "app"));
|
|
591
|
+
const hasRealNext = realNextResolvable(config.root);
|
|
592
|
+
const omitNextModuleShims = typedRoutesEnabled() && hasRealNext;
|
|
593
|
+
const legacyRequestTypes = typeof config.compat?.next === "object" && config.compat.next.legacyRequestAPIs === true;
|
|
594
|
+
await writeFile3(path3.join(dir, "next-shims.d.ts"), nextShims(hasReactTypes, rootParams, omitNextModuleShims, legacyRequestTypes, hasRealNext));
|
|
595
|
+
const preact = resolvePackageDir("preact", config.root);
|
|
596
|
+
if (reactTypes && preact) {
|
|
597
|
+
await writeFile3(preactTypeShimPath(config), preactTypeShim(preact, reactTypes));
|
|
598
|
+
}
|
|
599
|
+
const base = tsconfigPath(config.root);
|
|
600
|
+
const baseProject = base ? await readBaseProject(base, native) : undefined;
|
|
601
|
+
const baseOptions = baseProject?.options ?? {};
|
|
602
|
+
const preactShim = preactTypeShimPath(config);
|
|
603
|
+
const project = generatedProjectPath(config);
|
|
604
|
+
const paths = reactTypePaths(config.root, absolutePaths(baseOptions.paths, baseOptions.baseUrl ?? (base ? path3.dirname(base) : config.root)), existsSync2(preactShim) ? preactShim : undefined);
|
|
605
|
+
const nodeTypes = resolveTypesDir("node", config.root);
|
|
606
|
+
await writeFile3(project, JSON.stringify({
|
|
607
|
+
...base ? { extends: base } : {},
|
|
608
|
+
compilerOptions: {
|
|
609
|
+
noEmit: true,
|
|
610
|
+
incremental: true,
|
|
611
|
+
tsBuildInfoFile: path3.join(config.root, "node_modules", ".cache", "pnext", "typecheck.tsbuildinfo"),
|
|
612
|
+
skipLibCheck: true,
|
|
613
|
+
allowJs: true,
|
|
614
|
+
resolveJsonModule: true,
|
|
615
|
+
isolatedModules: true,
|
|
616
|
+
jsx: "preserve",
|
|
617
|
+
...paths ? { paths } : {},
|
|
618
|
+
...baseOptions.strict === undefined ? { strict: false } : {},
|
|
619
|
+
...baseOptions.target === undefined ? { target: "es2022" } : {},
|
|
620
|
+
...baseOptions.module === undefined ? { module: "esnext" } : {},
|
|
621
|
+
...baseOptions.moduleResolution === undefined ? { moduleResolution: "bundler" } : {},
|
|
622
|
+
...baseOptions.lib === undefined ? { lib: ["es2022", "dom", "dom.iterable"] } : {}
|
|
623
|
+
},
|
|
624
|
+
include: [
|
|
625
|
+
path3.join(dir, "next-shims.d.ts"),
|
|
626
|
+
path3.join(dir, "checks", "**/*.ts"),
|
|
627
|
+
...nodeTypes ? [path3.join(nodeTypes, "index.d.ts")] : [],
|
|
628
|
+
path3.join(config.root, "next-env.d.ts"),
|
|
629
|
+
...!legacyRequestTypes && existsSync2(path3.join(config.root, ".next/types/validator.ts")) ? [path3.join(config.root, ".next/types/validator.ts")] : [],
|
|
630
|
+
path3.join(config.root, "middleware.*"),
|
|
631
|
+
path3.join(config.root, "proxy.*"),
|
|
632
|
+
path3.join(config.root, "next.config.ts"),
|
|
633
|
+
path3.join(config.root, "next.config.mts"),
|
|
634
|
+
path3.join(config.root, "next.config.cts"),
|
|
635
|
+
path3.join(config.root, "app/**/*.ts"),
|
|
636
|
+
path3.join(config.root, "app/**/*.tsx"),
|
|
637
|
+
path3.join(config.root, "pages/**/*.ts"),
|
|
638
|
+
path3.join(config.root, "pages/**/*.tsx"),
|
|
639
|
+
...baseAmbientDeclarations(baseProject?.fileNames, config)
|
|
640
|
+
],
|
|
641
|
+
exclude: [
|
|
642
|
+
path3.join(config.root, "node_modules"),
|
|
643
|
+
path3.join(config.root, "**/*.test.ts"),
|
|
644
|
+
path3.join(config.root, "**/*.test.tsx")
|
|
645
|
+
]
|
|
646
|
+
}, null, 2));
|
|
647
|
+
return project;
|
|
648
|
+
}
|
|
649
|
+
function preactTypeShimPath(config) {
|
|
650
|
+
return path3.join(config.outRootPath, "typecheck", "preact-compat.d.ts");
|
|
651
|
+
}
|
|
652
|
+
function preactTypeShim(preact, react) {
|
|
653
|
+
const preactTypes = JSON.stringify(path3.join(preact, "src", "index.d.ts"));
|
|
654
|
+
const types = JSON.stringify(path3.join(react, "index.d.ts"));
|
|
655
|
+
return `import type { ReactNode } from ${types}
|
|
656
|
+
|
|
657
|
+
export * from ${preactTypes}
|
|
658
|
+
export type ComponentChild = ReactNode
|
|
659
|
+
export type ComponentChildren = ReactNode
|
|
660
|
+
`;
|
|
661
|
+
}
|
|
662
|
+
function typedRoutesEnabled() {
|
|
663
|
+
return getNextConfig().typedRoutes === true;
|
|
664
|
+
}
|
|
665
|
+
function realNextResolvable(root) {
|
|
666
|
+
try {
|
|
667
|
+
createRequire(path3.join(root, "noop.js")).resolve("next/package.json");
|
|
668
|
+
return true;
|
|
669
|
+
} catch {
|
|
670
|
+
return false;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
function baseAmbientDeclarations(fileNames, config) {
|
|
674
|
+
if (!fileNames)
|
|
675
|
+
return [];
|
|
676
|
+
const outPath = path3.resolve(config.outPath) + path3.sep;
|
|
677
|
+
return fileNames.map((name) => path3.resolve(name)).filter((name) => name.endsWith(".d.ts") && !name.includes(`${path3.sep}node_modules${path3.sep}`) && !name.startsWith(outPath));
|
|
678
|
+
}
|
|
679
|
+
async function readBaseProject(file, native) {
|
|
680
|
+
const shown = native ? await showConfigViaNative(native, file) : undefined;
|
|
681
|
+
if (shown)
|
|
682
|
+
return shown;
|
|
683
|
+
const ts = await loadTypescript();
|
|
684
|
+
const parsed = readProject(ts, file);
|
|
685
|
+
return { options: parsed.options, fileNames: [...parsed.fileNames] };
|
|
686
|
+
}
|
|
687
|
+
async function showConfigViaNative(bin, file) {
|
|
688
|
+
try {
|
|
689
|
+
const proc = Bun.spawn([bin, "--showConfig", "-p", file], { stdout: "pipe", stderr: "pipe" });
|
|
690
|
+
const stdout = await new Response(proc.stdout).text();
|
|
691
|
+
await proc.exited;
|
|
692
|
+
if (proc.exitCode !== 0)
|
|
693
|
+
return;
|
|
694
|
+
const shown = JSON.parse(stdout);
|
|
695
|
+
const dir = path3.dirname(file);
|
|
696
|
+
const options = shown.compilerOptions ?? {};
|
|
697
|
+
if (typeof options.baseUrl === "string")
|
|
698
|
+
options.baseUrl = path3.resolve(dir, options.baseUrl);
|
|
699
|
+
const fileNames = (shown.files ?? []).map((f) => path3.resolve(dir, f));
|
|
700
|
+
return { options, fileNames };
|
|
701
|
+
} catch {
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
function tsconfigPath(root) {
|
|
706
|
+
const tsConfig = getNextConfig().typescript;
|
|
707
|
+
const configured = tsConfig?.tsconfigPath;
|
|
708
|
+
const file = typeof configured === "string" && configured.length > 0 ? path3.join(root, configured) : path3.join(root, "tsconfig.json");
|
|
709
|
+
return existsSync2(file) ? file : undefined;
|
|
710
|
+
}
|
|
711
|
+
var parsedProjects = new Map;
|
|
712
|
+
function readProject(ts, project) {
|
|
713
|
+
let stamp = 0;
|
|
714
|
+
try {
|
|
715
|
+
stamp = statSync(project).mtimeMs;
|
|
716
|
+
} catch {}
|
|
717
|
+
const cached = parsedProjects.get(project);
|
|
718
|
+
if (cached?.stamp === stamp)
|
|
719
|
+
return cached.parsed;
|
|
720
|
+
const read = ts.readConfigFile(project, (file) => ts.sys.readFile(file));
|
|
721
|
+
if (read.error)
|
|
722
|
+
throw new PnextTypecheckError(formatDiagnostics(ts, [read.error]));
|
|
723
|
+
const parsed = ts.parseJsonConfigFileContent(read.config, ts.sys, path3.dirname(project));
|
|
724
|
+
parsedProjects.set(project, { stamp, parsed });
|
|
725
|
+
return parsed;
|
|
726
|
+
}
|
|
727
|
+
function formatDiagnostics(ts, diagnostics) {
|
|
728
|
+
const messages = new Set;
|
|
729
|
+
for (const diagnostic of diagnostics) {
|
|
730
|
+
const raw = ts.flattenDiagnosticMessageText(diagnostic.messageText, `
|
|
731
|
+
`);
|
|
732
|
+
const typedRoute = typedRouteMessage(raw);
|
|
733
|
+
let location = "";
|
|
734
|
+
if (diagnostic.file && diagnostic.start !== undefined) {
|
|
735
|
+
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
|
736
|
+
location = `${diagnostic.file.fileName}:${line + 1}:${character + 1}
|
|
737
|
+
`;
|
|
738
|
+
}
|
|
739
|
+
messages.add(`${location}Type error: ${typedRoute ?? raw}`);
|
|
740
|
+
}
|
|
741
|
+
return [...messages];
|
|
742
|
+
}
|
|
743
|
+
function typedRouteMessage(message) {
|
|
744
|
+
const match = /^Type '(".*")' is not assignable to type '.*RouteImpl<\1>/.exec(message);
|
|
745
|
+
if (!match?.[1])
|
|
746
|
+
return;
|
|
747
|
+
return `${match[1]} is not an existing route. If it is intentional, please type it explicitly with \`as Route\`.`;
|
|
748
|
+
}
|
|
749
|
+
function rootParamsModule(rootParams) {
|
|
750
|
+
const order = ["string", "string[]", "undefined"];
|
|
751
|
+
const entries = rootParams.size > 0 ? [...rootParams.entries()].map(([name, types]) => [
|
|
752
|
+
name,
|
|
753
|
+
order.filter((type) => types.has(type)).join(" | ")
|
|
754
|
+
]) : [
|
|
755
|
+
["lang", "string | string[] | undefined"],
|
|
756
|
+
["locale", "string | string[] | undefined"]
|
|
757
|
+
];
|
|
758
|
+
const getters = entries.map(([name, union]) => ` export function ${name}(): Promise<${union}>`).join(`
|
|
759
|
+
`);
|
|
760
|
+
return `declare module 'next/root-params' {
|
|
761
|
+
${getters}
|
|
762
|
+
const rootParams: (...args: any[]) => Promise<any>
|
|
763
|
+
export default rootParams
|
|
764
|
+
}`;
|
|
765
|
+
}
|
|
766
|
+
function stripNextModuleDeclarations(source) {
|
|
767
|
+
const lines = source.split(`
|
|
768
|
+
`);
|
|
769
|
+
const out = [];
|
|
770
|
+
for (let i = 0;i < lines.length; i++) {
|
|
771
|
+
const line = lines[i];
|
|
772
|
+
if (/^declare module 'next[^']*' \{/.test(line)) {
|
|
773
|
+
let depth = 0;
|
|
774
|
+
for (;i < lines.length; i++) {
|
|
775
|
+
const current = lines[i];
|
|
776
|
+
depth += (current.match(/\{/g)?.length ?? 0) - (current.match(/\}/g)?.length ?? 0);
|
|
777
|
+
if (depth === 0)
|
|
778
|
+
break;
|
|
779
|
+
}
|
|
780
|
+
continue;
|
|
781
|
+
}
|
|
782
|
+
out.push(line);
|
|
783
|
+
}
|
|
784
|
+
return out.join(`
|
|
785
|
+
`);
|
|
786
|
+
}
|
|
787
|
+
function nextShims(hasReactTypes, rootParams, omitNextModuleShims = false, legacyRequestTypes = false, hasRealNext = false) {
|
|
788
|
+
const reactShims = hasReactTypes ? "" : `
|
|
789
|
+
declare namespace JSX {
|
|
790
|
+
interface Element {}
|
|
791
|
+
interface IntrinsicElements {
|
|
792
|
+
[name: string]: any
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
declare namespace React {
|
|
797
|
+
type ReactNode = any
|
|
798
|
+
type ComponentType<P = any> = (props: P) => ReactNode
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
declare module 'react' {
|
|
802
|
+
export type ReactNode = any
|
|
803
|
+
export type ComponentType<P = any> = (props: P) => ReactNode
|
|
804
|
+
export type AnchorHTMLAttributes<T> = any
|
|
805
|
+
export type DetailedHTMLProps<E, T> = any
|
|
806
|
+
export const Suspense: ComponentType<any>
|
|
807
|
+
export const ViewTransition: ComponentType<any>
|
|
808
|
+
export function addTransitionType(type: string): void
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
declare module 'react/jsx-runtime' {
|
|
812
|
+
export const jsx: any
|
|
813
|
+
export const jsxs: any
|
|
814
|
+
export const Fragment: any
|
|
815
|
+
}
|
|
816
|
+
`;
|
|
817
|
+
const requestType = (type) => legacyRequestTypes ? `Promise<${type}> & ${type}` : `Promise<${type}>`;
|
|
818
|
+
const requestShims = `declare module 'next/headers'{interface CookieSetOptions{name?:string;value?:string;path?:string;maxAge?:number;expires?:Date|number;httpOnly?:boolean;secure?:boolean;sameSite?:'strict'|'lax'|'none'|boolean;domain?:string}interface CookieStore{get(name:string):{name:string;value:string}|undefined;get(options:{name:string;value?:string}):{name:string;value:string}|undefined;getAll(name?:string):{name:string;value:string}[];getAll(options:{name:string;value?:string}):{name:string;value:string}[];has(name:string):boolean;readonly size:number;set(options:CookieSetOptions):CookieStore;set(name:string,value:string,options?:CookieSetOptions):CookieStore;delete(name:string):boolean;clear():CookieStore;[Symbol.iterator]():IterableIterator<readonly[string,{name?:string;value:string}]>}export function cookies():${requestType("CookieStore")};export function headers():${requestType("Headers")};export function draftMode():${requestType(`{isEnabled:boolean;enable():void;disable():void}`)}}
|
|
819
|
+
`;
|
|
820
|
+
const fontShims = hasRealNext ? "" : `declare module 'next/font'{export interface FontModule{className:string;style:{fontFamily:string;fontWeight?:number;fontStyle?:string};variable:string}}
|
|
821
|
+
declare module 'next/font/local'{import type{FontModule}from'next/font';export default function localFont(options:any):FontModule}
|
|
822
|
+
declare module 'next/font/google'{import type{FontModule}from'next/font';type FontLoader=(options?:any)=>FontModule;const font:FontLoader;export default font;export const Inter:FontLoader,Geist:FontLoader,Geist_Mono:FontLoader,Roboto:FontLoader,Roboto_Mono:FontLoader,Open_Sans:FontLoader,Lato:FontLoader,Montserrat:FontLoader,Poppins:FontLoader,Noto_Sans:FontLoader}
|
|
823
|
+
`;
|
|
824
|
+
const source = `${reactShims}
|
|
825
|
+
declare const process: {
|
|
826
|
+
env: Record<string, string | undefined>
|
|
827
|
+
emit?: (...args: any[]) => boolean
|
|
828
|
+
cwd(): string
|
|
829
|
+
platform: string
|
|
830
|
+
arch: string
|
|
831
|
+
version: string
|
|
832
|
+
versions: Record<string, string>
|
|
833
|
+
nextTick(callback: (...args: any[]) => void, ...args: any[]): void
|
|
834
|
+
argv: string[]
|
|
835
|
+
pid: number
|
|
836
|
+
exit(code?: number): never
|
|
837
|
+
[key: string]: any
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
declare const EdgeRuntime: string
|
|
841
|
+
|
|
842
|
+
declare const require: (id: string) => any
|
|
843
|
+
|
|
844
|
+
declare class Buffer extends Uint8Array {}
|
|
845
|
+
|
|
846
|
+
declare module 'async_hooks' {
|
|
847
|
+
export class AsyncLocalStorage<T> {
|
|
848
|
+
run<R>(store: T, callback: () => R): R
|
|
849
|
+
getStore(): T | undefined
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
declare module 'timers/promises' {
|
|
854
|
+
export function setTimeout<T = void>(delay?: number, value?: T, options?: any): Promise<T>
|
|
855
|
+
export function setImmediate<T = void>(value?: T, options?: any): Promise<T>
|
|
856
|
+
export function setInterval<T = void>(delay?: number, value?: T, options?: any): AsyncIterable<T>
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
declare module 'node:timers/promises' {
|
|
860
|
+
export * from 'timers/promises'
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
declare module 'node:crypto' {
|
|
864
|
+
interface KeyObject {
|
|
865
|
+
export(...args: any[]): any
|
|
866
|
+
toString(...args: any[]): string
|
|
867
|
+
}
|
|
868
|
+
export function randomInt(...args: any[]): number
|
|
869
|
+
export function randomBytes(...args: any[]): Buffer
|
|
870
|
+
export function randomFillSync<T extends Uint8Array>(buffer: T, ...args: any[]): T
|
|
871
|
+
export function randomUUID(...args: any[]): string
|
|
872
|
+
export function getRandomValues<T extends Uint8Array>(array: T): T
|
|
873
|
+
export function generateKeyPairSync(...args: any[]): { publicKey: any; privateKey: any }
|
|
874
|
+
export function generateKeySync(...args: any[]): KeyObject
|
|
875
|
+
export function generatePrimeSync(...args: any[]): ArrayBuffer | Uint8Array
|
|
876
|
+
const crypto: {
|
|
877
|
+
randomInt: typeof randomInt
|
|
878
|
+
randomBytes: typeof randomBytes
|
|
879
|
+
randomFillSync: typeof randomFillSync
|
|
880
|
+
randomUUID: typeof randomUUID
|
|
881
|
+
getRandomValues: typeof getRandomValues
|
|
882
|
+
generateKeyPairSync: typeof generateKeyPairSync
|
|
883
|
+
generateKeySync: typeof generateKeySync
|
|
884
|
+
generatePrimeSync: typeof generatePrimeSync
|
|
885
|
+
}
|
|
886
|
+
export default crypto
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
declare module 'crypto' {
|
|
890
|
+
export * from 'node:crypto'
|
|
891
|
+
export { default } from 'node:crypto'
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
// Next.js augments the fetch RequestInit with a "next" field for its extended
|
|
895
|
+
// fetch semantics (revalidate/tags); mirror that here so app code using
|
|
896
|
+
// fetch(url, next revalidate) typechecks.
|
|
897
|
+
interface RequestInit {
|
|
898
|
+
next?: {
|
|
899
|
+
revalidate?: number | false
|
|
900
|
+
tags?: string[]
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
interface ResponseInit {
|
|
905
|
+
request?: {
|
|
906
|
+
headers?: HeadersInit
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
declare module 'node:buffer' {
|
|
911
|
+
export const Buffer: any
|
|
912
|
+
export const constants: any
|
|
913
|
+
export const kMaxLength: number
|
|
914
|
+
export const kStringMaxLength: number
|
|
915
|
+
export const SlowBuffer: any
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
declare module 'url' {
|
|
919
|
+
export interface UrlObject {
|
|
920
|
+
pathname?: string
|
|
921
|
+
query?: Record<string, string | string[]>
|
|
922
|
+
hash?: string
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
declare module 'next/types.js' {
|
|
927
|
+
export interface NextConfig {
|
|
928
|
+
env?: Record<string, string | number | boolean | undefined>
|
|
929
|
+
typedRoutes?: boolean
|
|
930
|
+
typescript?: { tsconfigPath?: string; ignoreBuildErrors?: boolean }
|
|
931
|
+
eslint?: { ignoreDuringBuilds?: boolean; dirs?: string[] }
|
|
932
|
+
[key: string]: any
|
|
933
|
+
}
|
|
934
|
+
export type Metadata = any
|
|
935
|
+
export type Viewport = any
|
|
936
|
+
export type ResolvingMetadata = Promise<Metadata>
|
|
937
|
+
export type ResolvingViewport = Promise<Viewport>
|
|
938
|
+
export type NextApiHandler<T = any> = (...args: any[]) => any
|
|
939
|
+
export type NextApiRequest = any
|
|
940
|
+
export type NextApiResponse<T = any> = any
|
|
941
|
+
export namespace MetadataRoute {
|
|
942
|
+
type Robots = any
|
|
943
|
+
type Sitemap = any[]
|
|
944
|
+
type Manifest = any
|
|
945
|
+
}
|
|
946
|
+
export type Route<T = string> = string
|
|
947
|
+
export type NextPage<P = {}, IP = P> = ((props: P) => any) & { [key: string]: any }
|
|
948
|
+
export type NextComponentType<C = any, IP = any, P = any> = any
|
|
949
|
+
export type PageProps<P = any> = any
|
|
950
|
+
export type LayoutProps<P = any> = any
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
declare module 'next/types' {
|
|
954
|
+
export * from 'next/types.js'
|
|
955
|
+
export { MetadataRoute } from 'next/types.js'
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
declare module 'next' {
|
|
959
|
+
export type {
|
|
960
|
+
NextConfig,
|
|
961
|
+
Metadata,
|
|
962
|
+
Viewport,
|
|
963
|
+
ResolvingMetadata,
|
|
964
|
+
ResolvingViewport,
|
|
965
|
+
NextApiRequest,
|
|
966
|
+
NextApiResponse,
|
|
967
|
+
NextApiHandler,
|
|
968
|
+
Route,
|
|
969
|
+
NextPage,
|
|
970
|
+
NextComponentType,
|
|
971
|
+
PageProps,
|
|
972
|
+
LayoutProps,
|
|
973
|
+
} from 'next/types.js'
|
|
974
|
+
export { MetadataRoute } from 'next/types.js'
|
|
975
|
+
export type GetServerSideProps<P = any, Q = any> = any
|
|
976
|
+
export type GetStaticProps<P = any, Q = any> = any
|
|
977
|
+
export type GetStaticPaths<Q = any> = any
|
|
978
|
+
export type InferGetServerSidePropsType<T = any> = any
|
|
979
|
+
export type InferGetStaticPropsType<T = any> = any
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
declare module 'next/cache' {
|
|
983
|
+
export function revalidatePath(path: string, type?: 'page' | 'layout'): void
|
|
984
|
+
export function revalidateTag(tag: string, profile: string | { expire?: number }): void
|
|
985
|
+
export function updateTag(tag: string): void
|
|
986
|
+
export function unstable_cache(...args: any[]): any
|
|
987
|
+
export function unstable_noStore(): void
|
|
988
|
+
export function unstable_expirePath(path: string, type?: 'page' | 'layout'): void
|
|
989
|
+
export function unstable_expireTag(...tags: string[]): void
|
|
990
|
+
export function expirePath(path: string, type?: 'page' | 'layout'): void
|
|
991
|
+
export function expireTag(...tags: string[]): void
|
|
992
|
+
export function refresh(): void
|
|
993
|
+
export function unstable_refresh(): void
|
|
994
|
+
export const io: any
|
|
995
|
+
export const cacheTag: (...tags: string[]) => void
|
|
996
|
+
export const cacheLife: (...args: any[]) => void
|
|
997
|
+
export const unstable_cacheTag: (...tags: string[]) => void
|
|
998
|
+
export const unstable_cacheLife: (...args: any[]) => void
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
${requestShims}
|
|
1002
|
+
|
|
1003
|
+
declare module 'next/server' {
|
|
1004
|
+
interface NextURL extends URL {
|
|
1005
|
+
clone(): NextURL
|
|
1006
|
+
basePath: string
|
|
1007
|
+
buildId?: string
|
|
1008
|
+
locale: string
|
|
1009
|
+
defaultLocale?: string
|
|
1010
|
+
}
|
|
1011
|
+
interface RequestCookie {
|
|
1012
|
+
name: string
|
|
1013
|
+
value: string
|
|
1014
|
+
}
|
|
1015
|
+
interface RequestCookies {
|
|
1016
|
+
get(name: string): RequestCookie | undefined
|
|
1017
|
+
getAll(name?: string): RequestCookie[]
|
|
1018
|
+
has(name: string): boolean
|
|
1019
|
+
set(name: string, value: string): RequestCookies
|
|
1020
|
+
set(cookie: RequestCookie): RequestCookies
|
|
1021
|
+
delete(name: string | string[]): boolean | boolean[]
|
|
1022
|
+
clear(): RequestCookies
|
|
1023
|
+
readonly size: number
|
|
1024
|
+
[Symbol.iterator](): IterableIterator<[string, RequestCookie]>
|
|
1025
|
+
}
|
|
1026
|
+
interface ResponseCookies {
|
|
1027
|
+
get(name: string): (RequestCookie & Record<string, any>) | undefined
|
|
1028
|
+
getAll(name?: string): (RequestCookie & Record<string, any>)[]
|
|
1029
|
+
has(name: string): boolean
|
|
1030
|
+
set(name: string, value: string, options?: any): ResponseCookies
|
|
1031
|
+
set(options: { name: string; value: string; [key: string]: any }): ResponseCookies
|
|
1032
|
+
delete(name: string, options?: any): ResponseCookies
|
|
1033
|
+
[Symbol.iterator](): IterableIterator<[string, RequestCookie & Record<string, any>]>
|
|
1034
|
+
}
|
|
1035
|
+
export class NextRequest extends Request {
|
|
1036
|
+
nextUrl: NextURL
|
|
1037
|
+
cookies: RequestCookies
|
|
1038
|
+
geo?: any
|
|
1039
|
+
ip?: string
|
|
1040
|
+
}
|
|
1041
|
+
export class NextResponse extends Response {
|
|
1042
|
+
cookies: ResponseCookies
|
|
1043
|
+
static json(body: any, init?: ResponseInit): NextResponse
|
|
1044
|
+
static next(init?: ResponseInit): NextResponse
|
|
1045
|
+
static redirect(url: string | URL, init?: number | ResponseInit): NextResponse
|
|
1046
|
+
static rewrite(url: string | URL, init?: ResponseInit): NextResponse
|
|
1047
|
+
}
|
|
1048
|
+
export type NextFetchEvent = any
|
|
1049
|
+
export type NextMiddleware = (...args: any[]) => any
|
|
1050
|
+
export type NextMiddlewareResult = any
|
|
1051
|
+
export interface ProxyConfig {
|
|
1052
|
+
matcher?: string | { source: string } | Array<string | { source: string }>
|
|
1053
|
+
}
|
|
1054
|
+
export class ImageResponse extends Response {
|
|
1055
|
+
constructor(element: any, options?: any)
|
|
1056
|
+
}
|
|
1057
|
+
export const URLPattern: any
|
|
1058
|
+
export function userAgent(request: { headers: Headers }): any
|
|
1059
|
+
export function userAgentFromString(ua: string | undefined): any
|
|
1060
|
+
export function after(task: any): void
|
|
1061
|
+
export function connection(): Promise<void>
|
|
1062
|
+
export const io: any
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
declare module 'next/server.js' {
|
|
1066
|
+
export * from 'next/server'
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
declare module 'next/navigation.js' {
|
|
1070
|
+
export * from 'next/navigation'
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
declare module 'next/headers.js' {
|
|
1074
|
+
export * from 'next/headers'
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
declare module 'next/cache.js' {
|
|
1078
|
+
export * from 'next/cache'
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
declare module 'next/link.js' {
|
|
1082
|
+
export * from 'next/link'
|
|
1083
|
+
export { default } from 'next/link'
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
declare module 'next/image.js' {
|
|
1087
|
+
export * from 'next/image'
|
|
1088
|
+
export { default } from 'next/image'
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
declare module 'next/script.js' {
|
|
1092
|
+
export * from 'next/script'
|
|
1093
|
+
export { default } from 'next/script'
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
declare module 'next/dist/client/link.js' {
|
|
1097
|
+
export interface LinkProps {
|
|
1098
|
+
href: any
|
|
1099
|
+
}
|
|
1100
|
+
export function useLinkStatus(): any
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
declare module 'next/link' {
|
|
1104
|
+
import type { AnchorHTMLAttributes, ComponentType } from 'react'
|
|
1105
|
+
// Mirror Next's public LinkProps: standard anchor attributes plus Link's own
|
|
1106
|
+
// props, but NO catch-all index signature. A wildcard string index signature
|
|
1107
|
+
// would silently accept non-public props (e.g. unstable_dynamicOnHover),
|
|
1108
|
+
// making a fixture's ts-expect-error on such a prop report as unused.
|
|
1109
|
+
export interface LinkProps
|
|
1110
|
+
extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
|
|
1111
|
+
href: any
|
|
1112
|
+
// Next 16's public prefetch type. The unstable_forceStale value is
|
|
1113
|
+
// runtime-only and Next deliberately keeps it OUT of the public union, so an
|
|
1114
|
+
// exhaustive switch over prefetch ending in "prefetch satisfies never"
|
|
1115
|
+
// stays valid. Including it here would leave that value in the default
|
|
1116
|
+
// branch and break such fixtures under our shim.
|
|
1117
|
+
prefetch?: boolean | 'auto' | null
|
|
1118
|
+
scroll?: boolean
|
|
1119
|
+
replace?: boolean
|
|
1120
|
+
as?: any
|
|
1121
|
+
shallow?: boolean
|
|
1122
|
+
passHref?: boolean
|
|
1123
|
+
locale?: string | false
|
|
1124
|
+
legacyBehavior?: boolean
|
|
1125
|
+
onNavigate?: (event: { preventDefault(): void }) => void
|
|
1126
|
+
transitionTypes?: string[]
|
|
1127
|
+
children?: any
|
|
1128
|
+
}
|
|
1129
|
+
const Link: ComponentType<LinkProps>
|
|
1130
|
+
export default Link
|
|
1131
|
+
export function useLinkStatus(): { pending: boolean }
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
declare module 'next/image' {
|
|
1135
|
+
import type { ComponentType } from 'react'
|
|
1136
|
+
export interface ImageProps {
|
|
1137
|
+
src: any
|
|
1138
|
+
alt: string
|
|
1139
|
+
width?: number | string
|
|
1140
|
+
height?: number | string
|
|
1141
|
+
fill?: boolean
|
|
1142
|
+
priority?: boolean
|
|
1143
|
+
loading?: 'lazy' | 'eager'
|
|
1144
|
+
placeholder?: string
|
|
1145
|
+
blurDataURL?: string
|
|
1146
|
+
unoptimized?: boolean
|
|
1147
|
+
sizes?: string
|
|
1148
|
+
quality?: number | string
|
|
1149
|
+
className?: string
|
|
1150
|
+
[key: string]: any
|
|
1151
|
+
}
|
|
1152
|
+
export interface StaticImageData {
|
|
1153
|
+
src: string
|
|
1154
|
+
height: number
|
|
1155
|
+
width: number
|
|
1156
|
+
blurDataURL?: string
|
|
1157
|
+
blurWidth?: number
|
|
1158
|
+
blurHeight?: number
|
|
1159
|
+
}
|
|
1160
|
+
const Image: ComponentType<ImageProps>
|
|
1161
|
+
export default Image
|
|
1162
|
+
export function getImageProps(props: ImageProps): { props: any }
|
|
1163
|
+
export function unstable_getImgProps(props: ImageProps): { props: any }
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
declare module '@vercel/og' {
|
|
1167
|
+
export class ImageResponse extends Response {
|
|
1168
|
+
constructor(element: any, options?: any)
|
|
1169
|
+
}
|
|
1170
|
+
export type ImageResponseOptions = any
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
declare module 'next/og' {
|
|
1174
|
+
export class ImageResponse extends Response {
|
|
1175
|
+
constructor(element: any, options?: any)
|
|
1176
|
+
static json(...args: any[]): ImageResponse
|
|
1177
|
+
}
|
|
1178
|
+
export interface ImageResponseOptions {
|
|
1179
|
+
width?: number
|
|
1180
|
+
height?: number
|
|
1181
|
+
fonts?: any[]
|
|
1182
|
+
debug?: boolean
|
|
1183
|
+
status?: number
|
|
1184
|
+
statusText?: string
|
|
1185
|
+
headers?: HeadersInit
|
|
1186
|
+
emoji?: string
|
|
1187
|
+
[key: string]: any
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
declare module 'next/dynamic' {
|
|
1192
|
+
import type { ComponentType } from 'react'
|
|
1193
|
+
export interface DynamicOptions {
|
|
1194
|
+
loading?: ComponentType<any>
|
|
1195
|
+
ssr?: boolean
|
|
1196
|
+
loadableGenerated?: any
|
|
1197
|
+
suspense?: boolean
|
|
1198
|
+
[key: string]: any
|
|
1199
|
+
}
|
|
1200
|
+
// Infer P from the loader like real next/dynamic's Loader<P>; a bare
|
|
1201
|
+
// Promise<any> loader would collapse P to any and strip prop types.
|
|
1202
|
+
type LoaderComponent<P> = ComponentType<P> | { default: ComponentType<P> }
|
|
1203
|
+
export default function dynamic<P = {}>(
|
|
1204
|
+
loader: (() => Promise<LoaderComponent<P>>) | Promise<LoaderComponent<P>>,
|
|
1205
|
+
options?: DynamicOptions,
|
|
1206
|
+
): ComponentType<P>
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
declare module 'next/error' {
|
|
1210
|
+
import type { ComponentType, ReactNode } from 'react'
|
|
1211
|
+
export interface ErrorInfo {
|
|
1212
|
+
error: Error
|
|
1213
|
+
reset: () => void
|
|
1214
|
+
unstable_retry: () => void
|
|
1215
|
+
[key: string]: any
|
|
1216
|
+
}
|
|
1217
|
+
export interface ErrorProps {
|
|
1218
|
+
statusCode: number
|
|
1219
|
+
title?: string
|
|
1220
|
+
withDarkMode?: boolean
|
|
1221
|
+
[key: string]: any
|
|
1222
|
+
}
|
|
1223
|
+
const ErrorComponent: ComponentType<ErrorProps>
|
|
1224
|
+
export default ErrorComponent
|
|
1225
|
+
// Wraps a fallback renderer (props, info) => JSX in an error boundary. The
|
|
1226
|
+
// returned component takes the fallback's own props plus children (the
|
|
1227
|
+
// guarded subtree) and an optional clearError reset callback. Mirrors the
|
|
1228
|
+
// runtime in src/compat/next/error.tsx.
|
|
1229
|
+
export function unstable_catchError<P extends Record<string, any> = any>(
|
|
1230
|
+
fallback: (props: P, info: ErrorInfo) => ReactNode,
|
|
1231
|
+
): ComponentType<P & { children?: ReactNode; clearError?: () => void }>
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
${fontShims}
|
|
1235
|
+
|
|
1236
|
+
declare module 'next/script' {
|
|
1237
|
+
import type { ComponentType } from 'react'
|
|
1238
|
+
export interface ScriptProps {
|
|
1239
|
+
src?: string
|
|
1240
|
+
strategy?: 'afterInteractive' | 'lazyOnload' | 'beforeInteractive' | 'worker'
|
|
1241
|
+
onLoad?: (...args: any[]) => void
|
|
1242
|
+
onReady?: (...args: any[]) => void
|
|
1243
|
+
onError?: (...args: any[]) => void
|
|
1244
|
+
id?: string
|
|
1245
|
+
children?: any
|
|
1246
|
+
[key: string]: any
|
|
1247
|
+
}
|
|
1248
|
+
const Script: ComponentType<ScriptProps>
|
|
1249
|
+
export default Script
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
declare module 'next/legacy/image' {
|
|
1253
|
+
import type { ComponentType } from 'react'
|
|
1254
|
+
export interface ImageProps {
|
|
1255
|
+
src: any
|
|
1256
|
+
alt?: string
|
|
1257
|
+
width?: number | string
|
|
1258
|
+
height?: number | string
|
|
1259
|
+
layout?: 'fixed' | 'intrinsic' | 'responsive' | 'fill'
|
|
1260
|
+
objectFit?: string
|
|
1261
|
+
objectPosition?: string
|
|
1262
|
+
priority?: boolean
|
|
1263
|
+
loading?: 'lazy' | 'eager'
|
|
1264
|
+
placeholder?: string
|
|
1265
|
+
blurDataURL?: string
|
|
1266
|
+
unoptimized?: boolean
|
|
1267
|
+
sizes?: string
|
|
1268
|
+
quality?: number | string
|
|
1269
|
+
[key: string]: any
|
|
1270
|
+
}
|
|
1271
|
+
const Image: ComponentType<ImageProps>
|
|
1272
|
+
export default Image
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
${rootParamsModule(rootParams)}
|
|
1276
|
+
|
|
1277
|
+
declare module 'next/web-vitals' {
|
|
1278
|
+
export interface NextWebVitalsMetric {
|
|
1279
|
+
id: string
|
|
1280
|
+
name: string
|
|
1281
|
+
startTime: number
|
|
1282
|
+
value: number
|
|
1283
|
+
label: 'web-vital' | 'custom'
|
|
1284
|
+
[key: string]: any
|
|
1285
|
+
}
|
|
1286
|
+
export function useReportWebVitals(reportFn: (metric: NextWebVitalsMetric) => void): void
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
declare module 'next/dist/client/components/app-router-headers' {
|
|
1290
|
+
export const NEXT_RSC_UNION_QUERY: string
|
|
1291
|
+
export const RSC_HEADER: string
|
|
1292
|
+
export const NEXT_ROUTER_STATE_TREE_HEADER: string
|
|
1293
|
+
export const NEXT_ROUTER_PREFETCH_HEADER: string
|
|
1294
|
+
export const NEXT_URL: string
|
|
1295
|
+
const headers: Record<string, string>
|
|
1296
|
+
export default headers
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
declare module 'next/dist/server/app-render/work-unit-async-storage.external' {
|
|
1300
|
+
export const workUnitAsyncStorage: {
|
|
1301
|
+
getStore(): any
|
|
1302
|
+
run<R>(store: any, callback: () => R): R
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
declare module 'next/dist/server/web/spec-extension/adapters/headers' {
|
|
1307
|
+
export class ReadonlyHeaders extends Headers {}
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
declare module 'next/dist/server/web/spec-extension/adapters/request-cookies' {
|
|
1311
|
+
export interface ReadonlyRequestCookies {
|
|
1312
|
+
get(name: string): { name: string; value: string } | undefined
|
|
1313
|
+
getAll(name?: string): { name: string; value: string }[]
|
|
1314
|
+
has(name: string): boolean
|
|
1315
|
+
readonly size: number
|
|
1316
|
+
[Symbol.iterator](): IterableIterator<[string, { name: string; value: string }]>
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
declare module 'node-fetch' {
|
|
1321
|
+
export class Headers {
|
|
1322
|
+
get(name: string): string | null
|
|
1323
|
+
has(name: string): boolean
|
|
1324
|
+
set(name: string, value: string): void
|
|
1325
|
+
append(name: string, value: string): void
|
|
1326
|
+
delete(name: string): void
|
|
1327
|
+
forEach(callback: (value: string, name: string) => void): void
|
|
1328
|
+
[Symbol.iterator](): IterableIterator<[string, string]>
|
|
1329
|
+
}
|
|
1330
|
+
const fetch: (...args: any[]) => Promise<any>
|
|
1331
|
+
export default fetch
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
declare module 'next/router' {
|
|
1335
|
+
export interface NextRouter {
|
|
1336
|
+
route: string
|
|
1337
|
+
pathname: string
|
|
1338
|
+
asPath: string
|
|
1339
|
+
query: Record<string, string | string[] | undefined>
|
|
1340
|
+
push(url: any, as?: any, options?: any): Promise<boolean>
|
|
1341
|
+
replace(url: any, as?: any, options?: any): Promise<boolean>
|
|
1342
|
+
prefetch(url: string): Promise<void>
|
|
1343
|
+
back(): void
|
|
1344
|
+
reload(): void
|
|
1345
|
+
beforePopState(callback: (...args: any[]) => boolean): void
|
|
1346
|
+
events: {
|
|
1347
|
+
on(type: string, handler: (...args: any[]) => void): void
|
|
1348
|
+
off(type: string, handler: (...args: any[]) => void): void
|
|
1349
|
+
emit(type: string, ...args: any[]): void
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
export function useRouter(): NextRouter
|
|
1353
|
+
const router: NextRouter
|
|
1354
|
+
export default router
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
declare module 'next/app' {
|
|
1358
|
+
// Pages-router shim: pnext builds the app directory only, but fixtures and
|
|
1359
|
+
// hybrid apps may carry a pages/ tree whose _app imports next/app. The type
|
|
1360
|
+
// program includes pages/**, so this keeps the typecheck from failing a
|
|
1361
|
+
// build over files pnext never bundles.
|
|
1362
|
+
export interface AppProps<P = any> {
|
|
1363
|
+
Component: (props: P) => any
|
|
1364
|
+
pageProps: P
|
|
1365
|
+
router?: any
|
|
1366
|
+
[key: string]: any
|
|
1367
|
+
}
|
|
1368
|
+
export type AppType = (props: AppProps) => any
|
|
1369
|
+
const App: AppType
|
|
1370
|
+
export default App
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
declare module 'next/dist/client/components/navigation.js' {
|
|
1374
|
+
export interface NavigateOptions {
|
|
1375
|
+
scroll?: boolean
|
|
1376
|
+
}
|
|
1377
|
+
export interface PrefetchOptions {
|
|
1378
|
+
kind?: 'auto' | 'full'
|
|
1379
|
+
onInvalidate?: () => void
|
|
1380
|
+
}
|
|
1381
|
+
export interface AppRouterInstance {
|
|
1382
|
+
push(href: string, options?: NavigateOptions): void
|
|
1383
|
+
replace(href: string, options?: NavigateOptions): void
|
|
1384
|
+
prefetch(href: string, options?: PrefetchOptions): void
|
|
1385
|
+
refresh(): void
|
|
1386
|
+
back(): void
|
|
1387
|
+
forward(): void
|
|
1388
|
+
bfcacheId: string
|
|
1389
|
+
}
|
|
1390
|
+
export function useRouter(): AppRouterInstance
|
|
1391
|
+
export function notFound(): never
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
declare module 'next/navigation' {
|
|
1395
|
+
export interface NavigateOptions {
|
|
1396
|
+
scroll?: boolean
|
|
1397
|
+
}
|
|
1398
|
+
export interface PrefetchOptions {
|
|
1399
|
+
kind?: 'auto' | 'full'
|
|
1400
|
+
onInvalidate?: () => void
|
|
1401
|
+
}
|
|
1402
|
+
export interface AppRouterInstance {
|
|
1403
|
+
push(href: string, options?: NavigateOptions): void
|
|
1404
|
+
replace(href: string, options?: NavigateOptions): void
|
|
1405
|
+
prefetch(href: string, options?: PrefetchOptions): void
|
|
1406
|
+
refresh(): void
|
|
1407
|
+
back(): void
|
|
1408
|
+
forward(): void
|
|
1409
|
+
bfcacheId: string
|
|
1410
|
+
}
|
|
1411
|
+
export function useRouter(): AppRouterInstance
|
|
1412
|
+
export function usePathname(): string
|
|
1413
|
+
export class ReadonlyURLSearchParams extends URLSearchParams {
|
|
1414
|
+
append(): never
|
|
1415
|
+
delete(): never
|
|
1416
|
+
set(): never
|
|
1417
|
+
sort(): never
|
|
1418
|
+
}
|
|
1419
|
+
export function useSearchParams(): ReadonlyURLSearchParams
|
|
1420
|
+
export function useParams<T = Record<string, string | string[]>>(): T
|
|
1421
|
+
export function useSelectedLayoutSegment(parallelRoutesKey?: string): string | null
|
|
1422
|
+
export function useSelectedLayoutSegments(parallelRoutesKey?: string): string[]
|
|
1423
|
+
export function useLayoutSegments(parallelRoutesKey?: string): string[]
|
|
1424
|
+
export function useLinkStatus(): { pending: boolean }
|
|
1425
|
+
export function unstable_isUnrecognizedActionError(error: unknown): boolean
|
|
1426
|
+
export const RedirectType: { push: 'push'; replace: 'replace' }
|
|
1427
|
+
export type RedirectType = 'push' | 'replace'
|
|
1428
|
+
export function notFound(): never
|
|
1429
|
+
export function forbidden(): never
|
|
1430
|
+
export function unauthorized(): never
|
|
1431
|
+
export function redirect(url: string, type?: RedirectType): never
|
|
1432
|
+
export function permanentRedirect(url: string, type?: RedirectType): never
|
|
1433
|
+
export function unstable_rethrow(error: unknown): void
|
|
1434
|
+
export function useServerInsertedHTML(callback: () => any): void
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
declare module 'next/dist/shared/lib/app-router-context.shared-runtime.js' {
|
|
1438
|
+
export interface NavigateOptions {
|
|
1439
|
+
scroll?: boolean
|
|
1440
|
+
}
|
|
1441
|
+
export interface PrefetchOptions {
|
|
1442
|
+
kind?: 'auto' | 'full'
|
|
1443
|
+
onInvalidate?: () => void
|
|
1444
|
+
}
|
|
1445
|
+
export interface AppRouterInstance {
|
|
1446
|
+
push(href: string, options?: NavigateOptions): void
|
|
1447
|
+
replace(href: string, options?: NavigateOptions): void
|
|
1448
|
+
prefetch(href: string, options?: PrefetchOptions): void
|
|
1449
|
+
refresh(): void
|
|
1450
|
+
back(): void
|
|
1451
|
+
forward(): void
|
|
1452
|
+
bfcacheId: string
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
declare module 'next/dist/client/components/redirect-error.js' {
|
|
1457
|
+
export type RedirectType = 'replace' | 'push'
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
declare module 'next/dist/client/form.js' {
|
|
1461
|
+
export interface FormProps {
|
|
1462
|
+
action: any
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
declare module 'next/form' {
|
|
1467
|
+
export interface FormProps {
|
|
1468
|
+
action: string | ((formData: FormData) => void | Promise<void>)
|
|
1469
|
+
replace?: boolean
|
|
1470
|
+
scroll?: boolean
|
|
1471
|
+
prefetch?: boolean
|
|
1472
|
+
[key: string]: any
|
|
1473
|
+
}
|
|
1474
|
+
export default function Form(props: FormProps): any
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
declare module '*.module.css' {
|
|
1478
|
+
const classes: Record<string, string>
|
|
1479
|
+
export default classes
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
declare module '*.module.scss' {
|
|
1483
|
+
const classes: Record<string, string>
|
|
1484
|
+
export default classes
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
declare module '*.module.sass' {
|
|
1488
|
+
const classes: Record<string, string>
|
|
1489
|
+
export default classes
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
declare module '*.css' {
|
|
1493
|
+
const href: string | undefined
|
|
1494
|
+
export default href
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
declare module '*.scss' {
|
|
1498
|
+
const href: string | undefined
|
|
1499
|
+
export default href
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
declare module '*.sass' {
|
|
1503
|
+
const href: string | undefined
|
|
1504
|
+
export default href
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
declare module '*.png' {
|
|
1508
|
+
const content: { src: string; height: number; width: number; blurDataURL?: string }
|
|
1509
|
+
export default content
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
declare module '*.jpg' {
|
|
1513
|
+
const content: { src: string; height: number; width: number; blurDataURL?: string }
|
|
1514
|
+
export default content
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
declare module '*.jpeg' {
|
|
1518
|
+
const content: { src: string; height: number; width: number; blurDataURL?: string }
|
|
1519
|
+
export default content
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
declare module '*.gif' {
|
|
1523
|
+
const content: { src: string; height: number; width: number; blurDataURL?: string }
|
|
1524
|
+
export default content
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
declare module '*.svg' {
|
|
1528
|
+
// \`any\` (not the static-image descriptor shape used above) to avoid
|
|
1529
|
+
// conflicts with \`@svgr/webpack\`-style loader rules that import an SVG as
|
|
1530
|
+
// a component, matching Next's own image-types/global.d.ts.
|
|
1531
|
+
const content: any
|
|
1532
|
+
export default content
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
declare module '*.webp' {
|
|
1536
|
+
const content: { src: string; height: number; width: number; blurDataURL?: string }
|
|
1537
|
+
export default content
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
declare module '*.wasm' {
|
|
1541
|
+
const content: any
|
|
1542
|
+
export default content
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
declare module '*.mdx' {
|
|
1546
|
+
const MDXComponent: (props: any) => any
|
|
1547
|
+
export default MDXComponent
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
declare module '*.md' {
|
|
1551
|
+
const MDXComponent: (props: any) => any
|
|
1552
|
+
export default MDXComponent
|
|
1553
|
+
}
|
|
1554
|
+
${loaderRuleAssetDeclarations()}`;
|
|
1555
|
+
return omitNextModuleShims ? stripNextModuleDeclarations(source) : source;
|
|
1556
|
+
}
|
|
1557
|
+
var STANDARD_ASSET_DECLARATIONS = new Set([
|
|
1558
|
+
".css",
|
|
1559
|
+
".scss",
|
|
1560
|
+
".sass",
|
|
1561
|
+
".png",
|
|
1562
|
+
".jpg",
|
|
1563
|
+
".jpeg",
|
|
1564
|
+
".gif",
|
|
1565
|
+
".svg",
|
|
1566
|
+
".webp",
|
|
1567
|
+
".wasm",
|
|
1568
|
+
".mdx",
|
|
1569
|
+
".md"
|
|
1570
|
+
]);
|
|
1571
|
+
var TS_RESOLVED_EXTENSIONS = new Set([
|
|
1572
|
+
".ts",
|
|
1573
|
+
".tsx",
|
|
1574
|
+
".mts",
|
|
1575
|
+
".cts",
|
|
1576
|
+
".d.ts",
|
|
1577
|
+
".js",
|
|
1578
|
+
".jsx",
|
|
1579
|
+
".mjs",
|
|
1580
|
+
".cjs",
|
|
1581
|
+
".json"
|
|
1582
|
+
]);
|
|
1583
|
+
function loaderRuleAssetDeclarations() {
|
|
1584
|
+
const specs = new Set;
|
|
1585
|
+
for (const rule of turbopackLoaderRules()) {
|
|
1586
|
+
if (!rule.glob.startsWith("*"))
|
|
1587
|
+
continue;
|
|
1588
|
+
const ext = rule.glob.slice(1).toLowerCase();
|
|
1589
|
+
if (STANDARD_ASSET_DECLARATIONS.has(ext) || TS_RESOLVED_EXTENSIONS.has(ext))
|
|
1590
|
+
continue;
|
|
1591
|
+
specs.add(rule.glob);
|
|
1592
|
+
}
|
|
1593
|
+
if (specs.size === 0)
|
|
1594
|
+
return "";
|
|
1595
|
+
return `${[...specs].map((spec) => `
|
|
1596
|
+
declare module '${spec}' {
|
|
1597
|
+
const content: any
|
|
1598
|
+
export default content
|
|
1599
|
+
}`).join("")}
|
|
1600
|
+
`;
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
// src/compat/register/typed-routes.ts
|
|
1604
|
+
function registerTypedRoutesExtensions(_config) {
|
|
1605
|
+
registerBuildSteps(runTypedRoutesBuildStep);
|
|
1606
|
+
}
|
|
1607
|
+
async function runTypedRoutesBuildStep(ctx) {
|
|
1608
|
+
if (!nextCompatEnabled(ctx.config))
|
|
1609
|
+
return;
|
|
1610
|
+
if (!legacyRequestAPIs())
|
|
1611
|
+
await writeTsconfigDefaults(ctx.config);
|
|
1612
|
+
await generateTypedRoutes(ctx.config, ctx.routes);
|
|
1613
|
+
if (typecheckDisabled())
|
|
1614
|
+
return;
|
|
1615
|
+
const startedAt = performance.now();
|
|
1616
|
+
registerBuildParallelPhases({
|
|
1617
|
+
name: "Typecheck",
|
|
1618
|
+
run: validateTypesOffThread(ctx.config).then(() => performance.now() - startedAt)
|
|
1619
|
+
});
|
|
1620
|
+
}
|
|
1621
|
+
// src/compat/register/validation.ts
|
|
1622
|
+
var registered = false;
|
|
1623
|
+
onExtensionHostReset(() => registered = false);
|
|
1624
|
+
function registerValidationExtensions(config) {
|
|
1625
|
+
if (registered)
|
|
1626
|
+
return;
|
|
1627
|
+
if (!nextCompatEnabled(config))
|
|
1628
|
+
return;
|
|
1629
|
+
registered = true;
|
|
1630
|
+
const step = async (ctx) => {
|
|
1631
|
+
if (!nextCompatEnabled(ctx.config))
|
|
1632
|
+
return;
|
|
1633
|
+
await ctx.log.step("validate build", () => Promise.resolve(validateBuild(ctx.config, ctx.routes)));
|
|
1634
|
+
};
|
|
1635
|
+
step.gate = true;
|
|
1636
|
+
registerBuildSteps(step);
|
|
1637
|
+
setBuildCompatExtensions({
|
|
1638
|
+
diagnoseCacheComponentsPrerender,
|
|
1639
|
+
diagnosticLeadsWithErrorLine,
|
|
1640
|
+
prerenderFailureFooter,
|
|
1641
|
+
recordBuildFlags: writeBuildFlags
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
// src/compat/register/middleware.ts
|
|
1645
|
+
import path4 from "path";
|
|
1646
|
+
import { mkdir as mkdir4, writeFile as writeFile4 } from "fs/promises";
|
|
1647
|
+
import { fileURLToPath } from "url";
|
|
1648
|
+
function registerMiddlewareExtensions() {
|
|
1649
|
+
registerBuildSteps(async ({ config, routes }) => {
|
|
1650
|
+
if (!nextCompatEnabled(config))
|
|
1651
|
+
return;
|
|
1652
|
+
const file = findProxyFile(config);
|
|
1653
|
+
let relative;
|
|
1654
|
+
if (file) {
|
|
1655
|
+
const href = await devServerModuleHref(config, file, "prod", {
|
|
1656
|
+
conditionTarget: "edge",
|
|
1657
|
+
externalLoadTarget: proxyExternalLoadTarget(file),
|
|
1658
|
+
reactServerLayer: true
|
|
1659
|
+
});
|
|
1660
|
+
relative = toPosixPath(path4.relative(config.outPath, fileURLToPath(href)));
|
|
1661
|
+
}
|
|
1662
|
+
await writeMiddlewareManifests(config, relative, routes);
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
async function writeMiddlewareManifests(config, entryFile, routes = []) {
|
|
1666
|
+
const source = findProxyFile(config);
|
|
1667
|
+
const functions = edgeFunctionEntries(config, routes);
|
|
1668
|
+
if (!source || !entryFile) {
|
|
1669
|
+
if (Object.keys(functions).length === 0)
|
|
1670
|
+
return;
|
|
1671
|
+
const serverDir2 = path4.join(config.outPath, "server");
|
|
1672
|
+
await mkdir4(serverDir2, { recursive: true });
|
|
1673
|
+
await writeFile4(path4.join(serverDir2, "middleware-manifest.json"), `${JSON.stringify({ ...emptyMiddlewareManifest(), functions }, null, 2)}
|
|
1674
|
+
`);
|
|
1675
|
+
return;
|
|
1676
|
+
}
|
|
1677
|
+
const moduleFile = path4.resolve(config.outPath, entryFile);
|
|
1678
|
+
const module = await import(pathToFileHref(moduleFile));
|
|
1679
|
+
const matchers = manifestMatchers(module.config);
|
|
1680
|
+
const runtime = proxyRuntime(module.config);
|
|
1681
|
+
const entrypoint = toServerEntrypoint(entryFile);
|
|
1682
|
+
const serverDir = path4.join(config.outPath, "server");
|
|
1683
|
+
await mkdir4(serverDir, { recursive: true });
|
|
1684
|
+
if (runtime === "nodejs") {
|
|
1685
|
+
const functionsConfig = {
|
|
1686
|
+
version: 1,
|
|
1687
|
+
functions: { "/_middleware": { runtime: "nodejs", matchers } }
|
|
1688
|
+
};
|
|
1689
|
+
await writeFile4(path4.join(serverDir, "functions-config-manifest.json"), `${JSON.stringify(functionsConfig, null, 2)}
|
|
1690
|
+
`);
|
|
1691
|
+
await writeFile4(path4.join(serverDir, "middleware-manifest.json"), `${JSON.stringify({ ...emptyMiddlewareManifest(), functions }, null, 2)}
|
|
1692
|
+
`);
|
|
1693
|
+
return;
|
|
1694
|
+
}
|
|
1695
|
+
const entry = {
|
|
1696
|
+
name: "middleware",
|
|
1697
|
+
page: "/",
|
|
1698
|
+
matchers,
|
|
1699
|
+
wasm: readMiddlewareWasmBindingsForOutPath(config.outPath),
|
|
1700
|
+
assets: [],
|
|
1701
|
+
files: [entrypoint],
|
|
1702
|
+
entrypoint,
|
|
1703
|
+
env: {}
|
|
1704
|
+
};
|
|
1705
|
+
const manifest = {
|
|
1706
|
+
version: 3,
|
|
1707
|
+
sortedMiddleware: ["/"],
|
|
1708
|
+
middleware: { "/": entry },
|
|
1709
|
+
functions
|
|
1710
|
+
};
|
|
1711
|
+
await writeFile4(path4.join(serverDir, "middleware-manifest.json"), `${JSON.stringify(manifest, null, 2)}
|
|
1712
|
+
`);
|
|
1713
|
+
}
|
|
1714
|
+
function emptyMiddlewareManifest() {
|
|
1715
|
+
return { version: 3, sortedMiddleware: [], middleware: {}, functions: {} };
|
|
1716
|
+
}
|
|
1717
|
+
function edgeFunctionEntries(config, routes) {
|
|
1718
|
+
const entries = {};
|
|
1719
|
+
if (!config.appPath)
|
|
1720
|
+
return entries;
|
|
1721
|
+
for (const route of routes) {
|
|
1722
|
+
const runtime = route.segmentConfig?.runtime;
|
|
1723
|
+
if (runtime !== "edge" && runtime !== "experimental-edge")
|
|
1724
|
+
continue;
|
|
1725
|
+
const page = appManifestKey(config.appPath, route.file);
|
|
1726
|
+
if (!page)
|
|
1727
|
+
continue;
|
|
1728
|
+
const regions = preferredRegionForRoute(route);
|
|
1729
|
+
entries[page] = {
|
|
1730
|
+
files: [],
|
|
1731
|
+
name: `app${page}`,
|
|
1732
|
+
page,
|
|
1733
|
+
matchers: [{ regexp: `^${routeMatcherRegexp(route.route)}$`, originalSource: route.route }],
|
|
1734
|
+
wasm: [],
|
|
1735
|
+
assets: [],
|
|
1736
|
+
env: {},
|
|
1737
|
+
...regions ? { regions } : {}
|
|
1738
|
+
};
|
|
1739
|
+
}
|
|
1740
|
+
return entries;
|
|
1741
|
+
}
|
|
1742
|
+
function appManifestKey(appPath, file) {
|
|
1743
|
+
const relative = toPosixPath(path4.relative(appPath, file));
|
|
1744
|
+
if (!relative || relative.startsWith(".."))
|
|
1745
|
+
return;
|
|
1746
|
+
return `/${relative.replace(/\.[^./]+$/, "")}`;
|
|
1747
|
+
}
|
|
1748
|
+
function routeMatcherRegexp(route) {
|
|
1749
|
+
return route.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/:([^/\\]+)/g, "[^/]+");
|
|
1750
|
+
}
|
|
1751
|
+
function manifestMatchers(config) {
|
|
1752
|
+
const matcher = config?.matcher;
|
|
1753
|
+
if (!matcher)
|
|
1754
|
+
return [{ regexp: "^/.*$", originalSource: "/:path*" }];
|
|
1755
|
+
const list = Array.isArray(matcher) ? matcher : [matcher];
|
|
1756
|
+
return list.map((item) => {
|
|
1757
|
+
const originalSource = typeof item === "string" ? item : item.source;
|
|
1758
|
+
return { regexp: `^${matcherRegexp(originalSource)}$`, originalSource };
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
function matcherRegexp(matcher) {
|
|
1762
|
+
if (matcher.includes("("))
|
|
1763
|
+
return matcher;
|
|
1764
|
+
if (matcher === "/")
|
|
1765
|
+
return "/";
|
|
1766
|
+
let source = "";
|
|
1767
|
+
for (const segment of matcher.split("/").filter(Boolean)) {
|
|
1768
|
+
if (/^:[^/]+\*$/.test(segment))
|
|
1769
|
+
source += "(?:/.*)?";
|
|
1770
|
+
else if (/^:[^/]+$/.test(segment))
|
|
1771
|
+
source += "/[^/]+";
|
|
1772
|
+
else
|
|
1773
|
+
source += `/${segment.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`;
|
|
1774
|
+
}
|
|
1775
|
+
return source || "/";
|
|
1776
|
+
}
|
|
1777
|
+
function proxyRuntime(config) {
|
|
1778
|
+
const runtime = config?.runtime;
|
|
1779
|
+
return runtime === "nodejs" ? "nodejs" : "edge";
|
|
1780
|
+
}
|
|
1781
|
+
function toServerEntrypoint(entryFile) {
|
|
1782
|
+
const posix = toPosixPath(entryFile).replace(/^\.?\//, "");
|
|
1783
|
+
const withinServer = posix.startsWith("server/") ? posix : `server/${path4.posix.basename(posix)}`;
|
|
1784
|
+
return withinServer.replace(/\.[^./]+$/, ".js");
|
|
1785
|
+
}
|
|
1786
|
+
// src/compat/metadata-artifacts.ts
|
|
1787
|
+
import { createRequire as createRequire2 } from "module";
|
|
1788
|
+
import { access, mkdir as mkdir5, readdir, readFile as readFile2, writeFile as writeFile5 } from "fs/promises";
|
|
1789
|
+
import path5 from "path";
|
|
1790
|
+
var foundGeistFontPath;
|
|
1791
|
+
async function emitMetadataRouteArtifacts(ctx) {
|
|
1792
|
+
if (!nextCompatEnabled(ctx.config))
|
|
1793
|
+
return;
|
|
1794
|
+
const routes = ctx.manifest.routes.filter((route) => route.kind === "handler" && route.metadataRoute !== undefined);
|
|
1795
|
+
if (routes.length === 0)
|
|
1796
|
+
return;
|
|
1797
|
+
const outPath = ctx.config.outPath;
|
|
1798
|
+
const outputRoots = Array.from(new Set([
|
|
1799
|
+
outPath,
|
|
1800
|
+
path5.join(ctx.config.root, ".next"),
|
|
1801
|
+
path5.join(path5.dirname(outPath), ".next"),
|
|
1802
|
+
path5.resolve(process.cwd(), ".next")
|
|
1803
|
+
]));
|
|
1804
|
+
const staticFiles = ctx.manifest.staticFiles ?? {};
|
|
1805
|
+
const routeFilesById = staticFilesByRouteId(staticFiles);
|
|
1806
|
+
const appDir = path5.join(ctx.config.root, ctx.config.appDir);
|
|
1807
|
+
const emittedRouteDirs = new Set;
|
|
1808
|
+
for (const route of routes) {
|
|
1809
|
+
const nextPath = toAppPath(route, appDir);
|
|
1810
|
+
const routeDir = removeLeadingSlash(nextPath);
|
|
1811
|
+
emittedRouteDirs.add(routeDir);
|
|
1812
|
+
const fontPaths = route.metadataRoute?.kind === "opengraph-image" ? await resolveGeistFontFiles() : [];
|
|
1813
|
+
for (const root of outputRoots) {
|
|
1814
|
+
const routeModuleDir = path5.join(root, "server", "app", routeDir);
|
|
1815
|
+
await mkdir5(routeModuleDir, { recursive: true });
|
|
1816
|
+
await writeFile5(path5.join(routeModuleDir, "route.js"), routeJsModule(route), "utf8");
|
|
1817
|
+
await writeFile5(path5.join(routeModuleDir, "route_client-reference-manifest.js"), `self.__RSC_MANIFEST={}
|
|
1818
|
+
`, "utf8");
|
|
1819
|
+
await writeFile5(path5.join(routeModuleDir, "route.js.nft.json"), `${JSON.stringify({ version: 1, files: ["route_client-reference-manifest.js", ...fontPaths] }, null, 2)}
|
|
1820
|
+
`, "utf8");
|
|
1821
|
+
if (isForceDynamicRoute(route))
|
|
1822
|
+
continue;
|
|
1823
|
+
const outputs = routeFilesById.get(route.id) ?? [];
|
|
1824
|
+
for (const relative of outputs) {
|
|
1825
|
+
await writeStaticMetadataArtifacts(outPath, root, relative, staticFiles[relative]);
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
await emitStaticMetadataRouteTraces(outputRoots, appDir, emittedRouteDirs);
|
|
1830
|
+
await writeAppPathsManifest(outputRoots, routes, appDir);
|
|
1831
|
+
await mergeMiddlewareFunctionsManifest(outputRoots, routes, appDir, ctx.manifest.routes);
|
|
1832
|
+
await writePrerenderManifests(outputRoots, ctx.manifest);
|
|
1833
|
+
}
|
|
1834
|
+
var prerenderAllowHeader = [
|
|
1835
|
+
"host",
|
|
1836
|
+
"x-matched-path",
|
|
1837
|
+
"x-prerender-revalidate",
|
|
1838
|
+
"x-prerender-revalidate-if-generated",
|
|
1839
|
+
"x-next-revalidated-tags",
|
|
1840
|
+
"x-next-revalidate-tag-token"
|
|
1841
|
+
];
|
|
1842
|
+
var prerenderBypass = [
|
|
1843
|
+
{ key: "next-action", type: "header" },
|
|
1844
|
+
{ key: "content-type", type: "header", value: "multipart/form-data;.*" }
|
|
1845
|
+
];
|
|
1846
|
+
async function writePrerenderManifests(outputRoots, manifest) {
|
|
1847
|
+
const byId = new Map(manifest.routes.map((route) => [route.id, route]));
|
|
1848
|
+
const entries = {};
|
|
1849
|
+
for (const [relative, metadata] of Object.entries(manifest.staticFiles ?? {})) {
|
|
1850
|
+
const route = metadata.routeId ? byId.get(metadata.routeId) : undefined;
|
|
1851
|
+
if (route && isEdgeRoute(route))
|
|
1852
|
+
continue;
|
|
1853
|
+
const pathname = staticFilePathname(relative);
|
|
1854
|
+
entries[pathname] = prerenderEntry(pathname, metadata, route);
|
|
1855
|
+
}
|
|
1856
|
+
for (const route of manifest.routes) {
|
|
1857
|
+
for (const generated of route.metadataRoute?.generatedRoutes ?? []) {
|
|
1858
|
+
if (entries[generated] || isEdgeRoute(route) || route.usesRequest)
|
|
1859
|
+
continue;
|
|
1860
|
+
entries[generated] = prerenderEntry(generated, undefined, route);
|
|
1861
|
+
}
|
|
1862
|
+
if (entries[route.route] || !isStaticPrerenderRoute(route))
|
|
1863
|
+
continue;
|
|
1864
|
+
entries[route.route] = prerenderEntry(route.route, undefined, route);
|
|
1865
|
+
}
|
|
1866
|
+
for (const root of outputRoots) {
|
|
1867
|
+
const file = path5.join(root, "prerender-manifest.json");
|
|
1868
|
+
const existing = await readJsonManifest(file);
|
|
1869
|
+
await mkdir5(path5.dirname(file), { recursive: true });
|
|
1870
|
+
await writeFile5(file, `${JSON.stringify({
|
|
1871
|
+
version: 4,
|
|
1872
|
+
routes: { ...existing?.routes ?? {}, ...entries },
|
|
1873
|
+
dynamicRoutes: existing?.dynamicRoutes ?? {},
|
|
1874
|
+
notFoundRoutes: existing?.notFoundRoutes ?? [],
|
|
1875
|
+
preview: existing?.preview ?? {
|
|
1876
|
+
previewModeId: "pnext-preview-id",
|
|
1877
|
+
previewModeSigningKey: "pnext-preview-signing-key",
|
|
1878
|
+
previewModeEncryptionKey: "pnext-preview-encryption-key"
|
|
1879
|
+
}
|
|
1880
|
+
}, null, 2)}
|
|
1881
|
+
`);
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
function staticFilePathname(relative) {
|
|
1885
|
+
if (relative === "index.html")
|
|
1886
|
+
return "/";
|
|
1887
|
+
if (relative.endsWith("/index.html"))
|
|
1888
|
+
return `/${relative.slice(0, -"/index.html".length)}`;
|
|
1889
|
+
if (relative.endsWith(".html"))
|
|
1890
|
+
return `/${relative.slice(0, -".html".length)}`;
|
|
1891
|
+
return `/${relative}`;
|
|
1892
|
+
}
|
|
1893
|
+
function isStaticPrerenderRoute(route) {
|
|
1894
|
+
if (route.mode !== "static" || route.usesRequest || isEdgeRoute(route))
|
|
1895
|
+
return false;
|
|
1896
|
+
if (route.kind === "page")
|
|
1897
|
+
return route.params.length === 0 && !route.catchAll;
|
|
1898
|
+
return route.kind === "handler" && route.metadataRoute !== undefined && route.params.length === 0;
|
|
1899
|
+
}
|
|
1900
|
+
function isEdgeRoute(route) {
|
|
1901
|
+
return route.segmentConfig?.runtime === "edge" || route.segmentConfig?.runtime === "experimental-edge";
|
|
1902
|
+
}
|
|
1903
|
+
function prerenderEntry(pathname, metadata, route) {
|
|
1904
|
+
return {
|
|
1905
|
+
initialRevalidateSeconds: metadata?.revalidateSeconds ?? false,
|
|
1906
|
+
srcRoute: route?.route ?? pathname,
|
|
1907
|
+
dataRoute: pathname === "/" ? "/index.rsc" : `${pathname}.rsc`,
|
|
1908
|
+
allowHeader: prerenderAllowHeader,
|
|
1909
|
+
experimentalBypassFor: prerenderBypass
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1912
|
+
function staticFilesByRouteId(staticFiles) {
|
|
1913
|
+
const routeFilesById = new Map;
|
|
1914
|
+
for (const [relative, metadata] of Object.entries(staticFiles)) {
|
|
1915
|
+
if (!metadata.routeId)
|
|
1916
|
+
continue;
|
|
1917
|
+
const existing = routeFilesById.get(metadata.routeId) ?? [];
|
|
1918
|
+
existing.push(relative);
|
|
1919
|
+
routeFilesById.set(metadata.routeId, existing);
|
|
1920
|
+
}
|
|
1921
|
+
return routeFilesById;
|
|
1922
|
+
}
|
|
1923
|
+
async function emitStaticMetadataRouteTraces(outputRoots, appDir, emittedRouteDirs) {
|
|
1924
|
+
for (const file of discoverStaticMetadataFiles(appDir)) {
|
|
1925
|
+
const routeDir = file.outputPath;
|
|
1926
|
+
if (emittedRouteDirs.has(routeDir))
|
|
1927
|
+
continue;
|
|
1928
|
+
for (const root of outputRoots) {
|
|
1929
|
+
const dir = path5.join(root, "server", "app", routeDir);
|
|
1930
|
+
await mkdir5(dir, { recursive: true });
|
|
1931
|
+
await writeFile5(path5.join(dir, "route.js"), `export default {}
|
|
1932
|
+
`, "utf8");
|
|
1933
|
+
await writeFile5(path5.join(dir, "route.js.nft.json"), `${JSON.stringify({ version: 1, files: [] }, null, 2)}
|
|
1934
|
+
`, "utf8");
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
async function writeAppPathsManifest(outputRoots, routes, appDir) {
|
|
1939
|
+
const nextEntries = {};
|
|
1940
|
+
for (const route of routes) {
|
|
1941
|
+
const appPath = toAppPath(route, appDir);
|
|
1942
|
+
const key = `${appPath}/route`;
|
|
1943
|
+
nextEntries[key] = `app${appPath}/route.js`;
|
|
1944
|
+
}
|
|
1945
|
+
for (const root of outputRoots) {
|
|
1946
|
+
const manifestPath = path5.join(root, "server", "app-paths-manifest.json");
|
|
1947
|
+
const existing = await readJsonManifest(manifestPath) ?? {};
|
|
1948
|
+
await mkdir5(path5.dirname(manifestPath), { recursive: true });
|
|
1949
|
+
await writeFile5(manifestPath, `${JSON.stringify({ ...existing, ...nextEntries }, null, 2)}
|
|
1950
|
+
`);
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
async function mergeMiddlewareFunctionsManifest(outputRoots, routes, appDir, allRoutes) {
|
|
1954
|
+
const edgeRoutes = routes.filter((route) => route.segmentConfig?.runtime === "edge" || route.segmentConfig?.runtime === "experimental-edge");
|
|
1955
|
+
const edgePages = allRoutes.filter((route) => route.kind === "page" && isEdgeRoute(route));
|
|
1956
|
+
if (edgeRoutes.length === 0 && edgePages.length === 0)
|
|
1957
|
+
return;
|
|
1958
|
+
const routeEntries = edgeRoutes.map((route) => ({
|
|
1959
|
+
route: `${toAppPath(route, appDir)}/route`,
|
|
1960
|
+
value: {}
|
|
1961
|
+
}));
|
|
1962
|
+
const sharedImageChunk = "server/edge-chunks/image-response.js";
|
|
1963
|
+
const hasImageResponseRoute = routes.some((route) => ["opengraph-image", "twitter-image", "apple-icon", "icon"].includes(route.metadataRoute?.kind ?? ""));
|
|
1964
|
+
for (const root of outputRoots) {
|
|
1965
|
+
const manifestPath = path5.join(root, "server", "middleware-manifest.json");
|
|
1966
|
+
const manifest = await readJsonManifest(manifestPath);
|
|
1967
|
+
const target = {
|
|
1968
|
+
version: 3,
|
|
1969
|
+
sortedMiddleware: [],
|
|
1970
|
+
middleware: {},
|
|
1971
|
+
functions: {},
|
|
1972
|
+
...manifest ?? {}
|
|
1973
|
+
};
|
|
1974
|
+
target.functions = target.functions ?? {};
|
|
1975
|
+
for (const { route, value } of routeEntries) {
|
|
1976
|
+
target.functions[route] = target.functions[route] ?? value;
|
|
1977
|
+
}
|
|
1978
|
+
if (hasImageResponseRoute && edgePages.length > 0) {
|
|
1979
|
+
const chunkPath = path5.join(root, sharedImageChunk);
|
|
1980
|
+
await mkdir5(path5.dirname(chunkPath), { recursive: true });
|
|
1981
|
+
await writeFile5(chunkPath, `export const loadAdditionalAsset = true
|
|
1982
|
+
`);
|
|
1983
|
+
for (const page of edgePages) {
|
|
1984
|
+
const key = page.route === "/" ? "/page" : `${page.route}/page`;
|
|
1985
|
+
target.functions[key] = { files: [sharedImageChunk] };
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
await mkdir5(path5.dirname(manifestPath), { recursive: true });
|
|
1989
|
+
await writeFile5(manifestPath, `${JSON.stringify(target, null, 2)}
|
|
1990
|
+
`);
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
function isForceDynamicRoute(route) {
|
|
1994
|
+
return route.segmentConfig?.dynamic === "force-dynamic";
|
|
1995
|
+
}
|
|
1996
|
+
function toRouteMeta(metadata) {
|
|
1997
|
+
const headers = {};
|
|
1998
|
+
for (const [name, value] of metadata.headers ?? []) {
|
|
1999
|
+
headers[name.toLowerCase()] = value;
|
|
2000
|
+
}
|
|
2001
|
+
return {
|
|
2002
|
+
status: metadata.status,
|
|
2003
|
+
headers
|
|
2004
|
+
};
|
|
2005
|
+
}
|
|
2006
|
+
async function writeStaticMetadataArtifacts(outPath, root, relative, metadata) {
|
|
2007
|
+
if (!metadata)
|
|
2008
|
+
return;
|
|
2009
|
+
const source = path5.join(outPath, "static", relative);
|
|
2010
|
+
const outputBase = path5.join(root, "server", "app", toPosixPath(relative));
|
|
2011
|
+
await mkdir5(path5.dirname(outputBase), { recursive: true });
|
|
2012
|
+
const routeMeta = JSON.stringify(toRouteMeta(metadata));
|
|
2013
|
+
await writeFile5(`${outputBase}.meta`, routeMeta, "utf8");
|
|
2014
|
+
try {
|
|
2015
|
+
await access(source);
|
|
2016
|
+
} catch {
|
|
2017
|
+
return;
|
|
2018
|
+
}
|
|
2019
|
+
await writeFile5(`${outputBase}.body`, await readFile2(source));
|
|
2020
|
+
}
|
|
2021
|
+
function routeJsModule(route) {
|
|
2022
|
+
const runtime = route.segmentConfig?.runtime ?? "nodejs";
|
|
2023
|
+
const data = JSON.stringify({
|
|
2024
|
+
segmentConfig: route.segmentConfig ?? null,
|
|
2025
|
+
runtime,
|
|
2026
|
+
metadataRoute: route.metadataRoute?.kind,
|
|
2027
|
+
route: route.route
|
|
2028
|
+
});
|
|
2029
|
+
return `export default ${data}
|
|
2030
|
+
`;
|
|
2031
|
+
}
|
|
2032
|
+
function toAppPath(route, appDir) {
|
|
2033
|
+
const generated = route.metadataRoute?.generatedParam;
|
|
2034
|
+
const normalized = route.route.replace(/^\/+|\/+$/g, "");
|
|
2035
|
+
const fileSegments = routeFileGroups(route.file, appDir);
|
|
2036
|
+
const routeSegments = normalized.length > 0 ? normalized.split("/") : [];
|
|
2037
|
+
const converted = routeSegments.map((segment) => routeSegmentToNextPath(segment, generated));
|
|
2038
|
+
const nextPathSegments = [...fileSegments, ...converted];
|
|
2039
|
+
return `/${nextPathSegments.join("/")}`;
|
|
2040
|
+
}
|
|
2041
|
+
function routeSegmentToNextPath(segment, generatedParam) {
|
|
2042
|
+
const match = /^:([^*.]+)(\*)?(\..*)?$/.exec(segment);
|
|
2043
|
+
if (!match)
|
|
2044
|
+
return segment;
|
|
2045
|
+
const name = match[1] ?? "";
|
|
2046
|
+
const star = match[2] ? "..." : "";
|
|
2047
|
+
const suffix = match[3] ?? "";
|
|
2048
|
+
const key = generatedParam && name === "id" ? generatedParam : name;
|
|
2049
|
+
return `[${star}${key}]${generatedParam && name === "id" ? "" : suffix}`;
|
|
2050
|
+
}
|
|
2051
|
+
function routeFileGroups(file, appDir) {
|
|
2052
|
+
const relative = toPosixPath(path5.relative(appDir, file));
|
|
2053
|
+
const parts = relative.split("/").filter(Boolean);
|
|
2054
|
+
const withoutLeaf = parts.slice(0, -1);
|
|
2055
|
+
const groups = [];
|
|
2056
|
+
for (const segment of withoutLeaf) {
|
|
2057
|
+
if (!segment.startsWith("(") || !segment.endsWith(")"))
|
|
2058
|
+
break;
|
|
2059
|
+
groups.push(segment);
|
|
2060
|
+
}
|
|
2061
|
+
return groups;
|
|
2062
|
+
}
|
|
2063
|
+
function removeLeadingSlash(pathValue) {
|
|
2064
|
+
return pathValue.replace(/^\//, "");
|
|
2065
|
+
}
|
|
2066
|
+
async function readJsonManifest(filePath) {
|
|
2067
|
+
try {
|
|
2068
|
+
const raw = await readFile2(filePath, "utf8");
|
|
2069
|
+
return JSON.parse(raw);
|
|
2070
|
+
} catch {
|
|
2071
|
+
return;
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
async function resolveGeistFontFiles() {
|
|
2075
|
+
if (foundGeistFontPath)
|
|
2076
|
+
return [foundGeistFontPath];
|
|
2077
|
+
const req = createRequire2(process.cwd() + "/");
|
|
2078
|
+
const candidateRoots = resolveVercelOgRoots(req);
|
|
2079
|
+
for (const root of candidateRoots) {
|
|
2080
|
+
const files = await findFiles(root, "Geist-Regular.ttf");
|
|
2081
|
+
if (files.length === 0)
|
|
2082
|
+
continue;
|
|
2083
|
+
foundGeistFontPath = files[0];
|
|
2084
|
+
return files.slice(0, 1);
|
|
2085
|
+
}
|
|
2086
|
+
return [];
|
|
2087
|
+
}
|
|
2088
|
+
function resolveVercelOgRoots(req) {
|
|
2089
|
+
const roots = [];
|
|
2090
|
+
for (const spec of ["@vercel/og/package.json", "next/package.json"]) {
|
|
2091
|
+
try {
|
|
2092
|
+
roots.push(path5.dirname(req.resolve(spec)));
|
|
2093
|
+
} catch {}
|
|
2094
|
+
}
|
|
2095
|
+
return roots;
|
|
2096
|
+
}
|
|
2097
|
+
async function findFiles(root, targetName) {
|
|
2098
|
+
const found = [];
|
|
2099
|
+
const stack = [root];
|
|
2100
|
+
const maxDepth = 6;
|
|
2101
|
+
while (stack.length > 0) {
|
|
2102
|
+
const current = stack.pop();
|
|
2103
|
+
if (!current)
|
|
2104
|
+
continue;
|
|
2105
|
+
const normalizedRoot = root.replace(/\\/g, "/");
|
|
2106
|
+
const normalizedCurrent = current.replace(/\\/g, "/");
|
|
2107
|
+
if (normalizedCurrent.includes(`${path5.sep}.next${path5.sep}`) || normalizedCurrent.includes(`${path5.sep}.git${path5.sep}`) || normalizedCurrent.includes(`${path5.sep}node_modules${path5.sep}.cache${path5.sep}`)) {
|
|
2108
|
+
continue;
|
|
2109
|
+
}
|
|
2110
|
+
const depth = normalizedCurrent.split("/").length;
|
|
2111
|
+
if (depth > normalizedRoot.split("/").length + maxDepth)
|
|
2112
|
+
continue;
|
|
2113
|
+
let entries;
|
|
2114
|
+
try {
|
|
2115
|
+
entries = await readdir(current, { withFileTypes: true });
|
|
2116
|
+
} catch {
|
|
2117
|
+
continue;
|
|
2118
|
+
}
|
|
2119
|
+
for (const entry of entries) {
|
|
2120
|
+
const child = path5.join(current, entry.name);
|
|
2121
|
+
if (entry.isDirectory()) {
|
|
2122
|
+
stack.push(child);
|
|
2123
|
+
continue;
|
|
2124
|
+
}
|
|
2125
|
+
if (entry.isFile() && entry.name === targetName) {
|
|
2126
|
+
found.push(child);
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
return found;
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
// src/compat/export/emit.ts
|
|
2134
|
+
import { copyFile, mkdir as mkdir7, readFile as readFile3, rm, writeFile as writeFile7 } from "fs/promises";
|
|
2135
|
+
import path7 from "path";
|
|
2136
|
+
|
|
2137
|
+
// src/compat/export/standalone.ts
|
|
2138
|
+
import { existsSync as existsSync3, readFileSync } from "fs";
|
|
2139
|
+
import { mkdir as mkdir6, writeFile as writeFile6 } from "fs/promises";
|
|
2140
|
+
import path6 from "path";
|
|
2141
|
+
var ENTRY_FILE = /(?:^|[\\/])(page|route)\.(?:js|jsx|ts|tsx|mjs|cjs)$/;
|
|
2142
|
+
async function emitStandalone({
|
|
2143
|
+
config,
|
|
2144
|
+
manifest,
|
|
2145
|
+
log
|
|
2146
|
+
}) {
|
|
2147
|
+
await log.step("standalone output", () => writeStandalone(config, manifest));
|
|
2148
|
+
}
|
|
2149
|
+
async function writeStandalone(config, manifest) {
|
|
2150
|
+
const standaloneDir = config.outPath;
|
|
2151
|
+
await writeFile6(path6.join(standaloneDir, "server.js"), standaloneServerSource());
|
|
2152
|
+
await writeTraceFiles(config, standaloneDir);
|
|
2153
|
+
await writeMiddlewareManifest(manifest, standaloneDir);
|
|
2154
|
+
}
|
|
2155
|
+
function standaloneServerSource() {
|
|
2156
|
+
return `// pnext standalone launcher, generated by pnext build (src/compat/export/standalone.ts).
|
|
2157
|
+
import { spawn } from 'node:child_process';
|
|
2158
|
+
|
|
2159
|
+
const port = Number(process.env.PORT || '3000');
|
|
2160
|
+
const hostname = process.env.HOSTNAME || '0.0.0.0';
|
|
2161
|
+
const entry = new URL('./server/entry.js', import.meta.url).href;
|
|
2162
|
+
const boot = \`const { start } = await import(\${JSON.stringify(entry)}); await start(\${JSON.stringify({ port, hostname })});\`;
|
|
2163
|
+
|
|
2164
|
+
const child = spawn('bun', ['--conditions=react-server', '-e', boot], {
|
|
2165
|
+
env: {
|
|
2166
|
+
...process.env,
|
|
2167
|
+
// Suppresses \`pnext start\`'s "output: standalone" warning (Next gates the
|
|
2168
|
+
// same warning on this private env being set by its standalone server).
|
|
2169
|
+
__NEXT_PRIVATE_STANDALONE_CONFIG: '1',
|
|
2170
|
+
BROWSER: 'none',
|
|
2171
|
+
NODE_ENV: 'production',
|
|
2172
|
+
},
|
|
2173
|
+
stdio: ['ignore', 'inherit', 'inherit'],
|
|
2174
|
+
});
|
|
2175
|
+
|
|
2176
|
+
child.on('error', (error) => {
|
|
2177
|
+
console.error('pnext standalone: failed to start the pnext server:', error);
|
|
2178
|
+
process.exit(1);
|
|
2179
|
+
});
|
|
2180
|
+
child.on('exit', (code, signal) => {
|
|
2181
|
+
process.exit(code == null ? (signal ? 1 : 0) : code);
|
|
2182
|
+
});
|
|
2183
|
+
|
|
2184
|
+
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
2185
|
+
process.on(signal, () => {
|
|
2186
|
+
if (child.exitCode === null) child.kill(signal);
|
|
2187
|
+
});
|
|
2188
|
+
}
|
|
2189
|
+
`;
|
|
2190
|
+
}
|
|
2191
|
+
async function writeTraceFiles(config, standaloneDir) {
|
|
2192
|
+
const serverDir = path6.join(standaloneDir, ".next", "server");
|
|
2193
|
+
await emitTracesFor(path6.join(config.root, "app"), path6.join(serverDir, "app"));
|
|
2194
|
+
await emitTracesFor(path6.join(config.root, "src", "app"), path6.join(serverDir, "app"));
|
|
2195
|
+
await emitTracesFor(path6.join(config.root, "pages"), path6.join(serverDir, "pages"));
|
|
2196
|
+
await emitTracesFor(path6.join(config.root, "src", "pages"), path6.join(serverDir, "pages"));
|
|
2197
|
+
}
|
|
2198
|
+
async function writeMiddlewareManifest(manifest, standaloneDir) {
|
|
2199
|
+
const functions = {};
|
|
2200
|
+
for (const route of manifest.routes) {
|
|
2201
|
+
if (!isEdgeRoute2(route))
|
|
2202
|
+
continue;
|
|
2203
|
+
const page = route.route || "/";
|
|
2204
|
+
functions[page] = {
|
|
2205
|
+
files: [],
|
|
2206
|
+
name: `edge${page === "/" ? "/index" : page}`,
|
|
2207
|
+
page,
|
|
2208
|
+
matchers: [{ regexp: `^${escapeRouteRegexp(page)}$`, originalSource: page }],
|
|
2209
|
+
wasm: [],
|
|
2210
|
+
assets: [],
|
|
2211
|
+
env: {}
|
|
2212
|
+
};
|
|
2213
|
+
}
|
|
2214
|
+
if (Object.keys(functions).length === 0)
|
|
2215
|
+
return;
|
|
2216
|
+
const serverDir = path6.join(standaloneDir, ".next", "server");
|
|
2217
|
+
await mkdir6(serverDir, { recursive: true });
|
|
2218
|
+
await writeFile6(path6.join(serverDir, "middleware-manifest.json"), `${JSON.stringify({ version: 3, sortedMiddleware: [], middleware: {}, functions }, null, 2)}
|
|
2219
|
+
`);
|
|
2220
|
+
}
|
|
2221
|
+
function isEdgeRoute2(route) {
|
|
2222
|
+
const runtime = route.segmentConfig?.runtime;
|
|
2223
|
+
if (runtime === "edge" || runtime === "experimental-edge")
|
|
2224
|
+
return true;
|
|
2225
|
+
for (const file of [route.file, ...route.sourceFiles ?? []]) {
|
|
2226
|
+
if (!file || !existsSync3(file))
|
|
2227
|
+
continue;
|
|
2228
|
+
let source;
|
|
2229
|
+
try {
|
|
2230
|
+
source = readFileSync(file, "utf8");
|
|
2231
|
+
} catch {
|
|
2232
|
+
continue;
|
|
2233
|
+
}
|
|
2234
|
+
if (/\bruntime\s*:\s*['"](?:edge|experimental-edge)['"]/.test(source))
|
|
2235
|
+
return true;
|
|
2236
|
+
if (/export\s+const\s+runtime\s*=\s*['"](?:edge|experimental-edge)['"]/.test(source))
|
|
2237
|
+
return true;
|
|
2238
|
+
}
|
|
2239
|
+
return false;
|
|
2240
|
+
}
|
|
2241
|
+
function escapeRouteRegexp(route) {
|
|
2242
|
+
return route.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/:([^/\\]+)/g, "[^/]+");
|
|
2243
|
+
}
|
|
2244
|
+
async function emitTracesFor(sourceDir, targetDir) {
|
|
2245
|
+
if (!existsSync3(sourceDir))
|
|
2246
|
+
return;
|
|
2247
|
+
for (const file of await listFiles(sourceDir)) {
|
|
2248
|
+
const match = ENTRY_FILE.exec(file);
|
|
2249
|
+
if (!match)
|
|
2250
|
+
continue;
|
|
2251
|
+
const relative = toPosixPath(path6.relative(sourceDir, file));
|
|
2252
|
+
const relativeDir = path6.posix.dirname(relative);
|
|
2253
|
+
const dir = path6.join(targetDir, ...relativeDir === "." ? [] : relativeDir.split("/"));
|
|
2254
|
+
await mkdir6(dir, { recursive: true });
|
|
2255
|
+
await writeFile6(path6.join(dir, `${match[1]}.js.nft.json`), `${JSON.stringify({ version: 1, files: [] })}
|
|
2256
|
+
`);
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
// src/compat/export/emit.ts
|
|
2261
|
+
var BUILD_ID = "pnext";
|
|
2262
|
+
var COMMON_SEGMENTS = ["_full", "_head", "_index", "_tree"];
|
|
2263
|
+
var RUNTIME_ASSET_DIR = "_next/static/chunks";
|
|
2264
|
+
var EXPORT_MODE_SCRIPT = "<script>window.__PNEXT_OUTPUT_EXPORT__=true;</script>";
|
|
2265
|
+
async function emitStaticExport({ config, manifest, log }) {
|
|
2266
|
+
await log.step("build manifest", () => writeBuildManifests(path7.join(config.outPath, "static")));
|
|
2267
|
+
const output = getNextConfig().output;
|
|
2268
|
+
if (output === "standalone") {
|
|
2269
|
+
await emitStandalone({ config, manifest, log });
|
|
2270
|
+
return;
|
|
2271
|
+
}
|
|
2272
|
+
if (output !== "export")
|
|
2273
|
+
return;
|
|
2274
|
+
await log.step("static export", () => writeExportTree(config, manifest));
|
|
2275
|
+
}
|
|
2276
|
+
async function writeExportTree(config, manifest) {
|
|
2277
|
+
const outDir = exportOutDir(config);
|
|
2278
|
+
await rm(outDir, { recursive: true, force: true });
|
|
2279
|
+
await mkdir7(outDir, { recursive: true });
|
|
2280
|
+
const assets = await copyRuntimeAssets(config, outDir);
|
|
2281
|
+
await copyPublicTree(config, outDir, assets);
|
|
2282
|
+
await writeBuildManifests(outDir);
|
|
2283
|
+
const pages = exportPages(config, manifest);
|
|
2284
|
+
for (const page of pages)
|
|
2285
|
+
await writePageArtifacts(page, assets);
|
|
2286
|
+
await writeNotFoundArtifacts(config, outDir);
|
|
2287
|
+
}
|
|
2288
|
+
async function copyRuntimeAssets(config, outDir) {
|
|
2289
|
+
const assetsDir = path7.join(config.outPath, "static", "assets");
|
|
2290
|
+
const assets = new Set;
|
|
2291
|
+
for (const file of await listFiles(assetsDir)) {
|
|
2292
|
+
const relative = toPosixPath(path7.relative(assetsDir, file));
|
|
2293
|
+
assets.add(relative);
|
|
2294
|
+
const target = path7.join(outDir, ...RUNTIME_ASSET_DIR.split("/"), ...relative.split("/"));
|
|
2295
|
+
await mkdir7(path7.dirname(target), { recursive: true });
|
|
2296
|
+
await copyFile(file, target);
|
|
2297
|
+
}
|
|
2298
|
+
return assets;
|
|
2299
|
+
}
|
|
2300
|
+
async function copyPublicTree(config, outDir, assets) {
|
|
2301
|
+
const publicDir = path7.join(config.outPath, "static");
|
|
2302
|
+
for (const file of await listFiles(publicDir)) {
|
|
2303
|
+
const relative = toPosixPath(path7.relative(publicDir, file));
|
|
2304
|
+
if (relative.startsWith("assets/"))
|
|
2305
|
+
continue;
|
|
2306
|
+
const target = path7.join(outDir, ...relative.split("/"));
|
|
2307
|
+
await mkdir7(path7.dirname(target), { recursive: true });
|
|
2308
|
+
if (relative.endsWith(".html")) {
|
|
2309
|
+
await writeFile7(target, exportDocument(await readFile3(file, "utf8"), assets));
|
|
2310
|
+
} else {
|
|
2311
|
+
await copyFile(file, target);
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
function exportDocument(html, assets) {
|
|
2316
|
+
const repointed = html.replace(/\/_next\/static\/([^"'`\s<>)?#]+)([?#][^"'`\s<>]*)?/g, (match, rest, suffix) => assets.has(rest) ? `/${RUNTIME_ASSET_DIR}/${rest}${suffix ?? ""}` : match);
|
|
2317
|
+
const anchor = /<head[^>]*>|<body[^>]*>/.exec(repointed);
|
|
2318
|
+
if (!anchor)
|
|
2319
|
+
return EXPORT_MODE_SCRIPT + repointed;
|
|
2320
|
+
const at = anchor.index + anchor[0].length;
|
|
2321
|
+
return `${repointed.slice(0, at)}${EXPORT_MODE_SCRIPT}${repointed.slice(at)}`;
|
|
2322
|
+
}
|
|
2323
|
+
async function writeBuildManifests(outDir) {
|
|
2324
|
+
const dir = path7.join(outDir, "_next", "static", BUILD_ID);
|
|
2325
|
+
await mkdir7(dir, { recursive: true });
|
|
2326
|
+
await writeFile7(path7.join(dir, "_buildManifest.js"), `self.__BUILD_MANIFEST={};self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
|
|
2327
|
+
`);
|
|
2328
|
+
await writeFile7(path7.join(dir, "_ssgManifest.js"), `self.__SSG_MANIFEST=new Set();
|
|
2329
|
+
`);
|
|
2330
|
+
}
|
|
2331
|
+
function exportOutDir(config) {
|
|
2332
|
+
const distDir = getNextConfig().distDir;
|
|
2333
|
+
const dir = typeof distDir === "string" && distDir.length > 0 && distDir !== ".next" ? distDir : "out";
|
|
2334
|
+
return path7.resolve(config.root, dir);
|
|
2335
|
+
}
|
|
2336
|
+
function exportPages(config, manifest) {
|
|
2337
|
+
const staticFiles = manifest.staticFiles ?? {};
|
|
2338
|
+
const routeById = new Map(manifest.routes.map((route) => [route.id, route]));
|
|
2339
|
+
const pages = [];
|
|
2340
|
+
for (const [relative, metadata] of Object.entries(staticFiles)) {
|
|
2341
|
+
if (metadata.kind !== "page" || !relative.endsWith(".html"))
|
|
2342
|
+
continue;
|
|
2343
|
+
const route = metadata.routeId ? routeById.get(metadata.routeId) : undefined;
|
|
2344
|
+
if (route?.kind !== "page")
|
|
2345
|
+
continue;
|
|
2346
|
+
const htmlFile = path7.join(config.outPath, "static", ...relative.split("/"));
|
|
2347
|
+
pages.push({
|
|
2348
|
+
route,
|
|
2349
|
+
htmlFile,
|
|
2350
|
+
...exportPathsForHtml(config, relative)
|
|
2351
|
+
});
|
|
2352
|
+
}
|
|
2353
|
+
return pages.sort((a, b) => a.outHtml.localeCompare(b.outHtml));
|
|
2354
|
+
}
|
|
2355
|
+
function exportPathsForHtml(config, relative) {
|
|
2356
|
+
const outDir = exportOutDir(config);
|
|
2357
|
+
const normalized = toPosixPath(relative);
|
|
2358
|
+
if (normalized === "index.html") {
|
|
2359
|
+
return {
|
|
2360
|
+
outHtml: path7.join(outDir, "index.html"),
|
|
2361
|
+
outPageTxt: path7.join(outDir, "index.txt"),
|
|
2362
|
+
segmentDir: outDir
|
|
2363
|
+
};
|
|
2364
|
+
}
|
|
2365
|
+
if (normalized.endsWith("/index.html")) {
|
|
2366
|
+
const routePath2 = normalized.slice(0, -"/index.html".length);
|
|
2367
|
+
return {
|
|
2368
|
+
outHtml: path7.join(outDir, ...normalized.split("/")),
|
|
2369
|
+
outPageTxt: path7.join(outDir, ...routePath2.split("/"), "index.txt"),
|
|
2370
|
+
segmentDir: path7.join(outDir, ...routePath2.split("/"))
|
|
2371
|
+
};
|
|
2372
|
+
}
|
|
2373
|
+
const routePath = normalized.slice(0, -".html".length);
|
|
2374
|
+
return {
|
|
2375
|
+
outHtml: path7.join(outDir, ...normalized.split("/")),
|
|
2376
|
+
outPageTxt: path7.join(outDir, `${routePath}.txt`),
|
|
2377
|
+
segmentDir: path7.join(outDir, ...routePath.split("/"))
|
|
2378
|
+
};
|
|
2379
|
+
}
|
|
2380
|
+
async function writePageArtifacts(page, assets) {
|
|
2381
|
+
const html = exportDocument(await readFile3(page.htmlFile, "utf8"), assets);
|
|
2382
|
+
await mkdir7(path7.dirname(page.outPageTxt), { recursive: true });
|
|
2383
|
+
await writeFile7(page.outPageTxt, html);
|
|
2384
|
+
await writeSegmentFiles(page.segmentDir, page.route, html);
|
|
2385
|
+
}
|
|
2386
|
+
async function writeSegmentFiles(segmentDir2, route, body) {
|
|
2387
|
+
await mkdir7(segmentDir2, { recursive: true });
|
|
2388
|
+
for (const segment of COMMON_SEGMENTS) {
|
|
2389
|
+
await writeFile7(path7.join(segmentDir2, `__next.${segment}.txt`), body);
|
|
2390
|
+
}
|
|
2391
|
+
const keys = segmentKeys(route);
|
|
2392
|
+
const leaf = keys.at(-1) ?? "";
|
|
2393
|
+
await writeFile7(path7.join(segmentDir2, leaf ? `__next.${leaf}.__PAGE__.txt` : "__next.__PAGE__.txt"), body);
|
|
2394
|
+
if (leaf)
|
|
2395
|
+
await writeFile7(path7.join(segmentDir2, `__next.${leaf}.txt`), body);
|
|
2396
|
+
for (const key of keys.slice(0, -1)) {
|
|
2397
|
+
if (key)
|
|
2398
|
+
await writeFile7(path7.join(segmentDir2, `__next.${key}.txt`), body);
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
function segmentKeys(route) {
|
|
2402
|
+
const params = new Set(route.params);
|
|
2403
|
+
const parts = route.route.replace(/^\/|\/$/g, "").split("/").filter(Boolean).map((part) => part.startsWith(":") ? `$d$${part.replace(/^:|[*?]$/g, "")}` : part);
|
|
2404
|
+
if (parts.length === 0)
|
|
2405
|
+
return [""];
|
|
2406
|
+
const keys = [];
|
|
2407
|
+
for (const [index, part] of parts.entries()) {
|
|
2408
|
+
const key = part.startsWith("$d$") && !params.has(part.slice(3)) ? part.slice(3) : part;
|
|
2409
|
+
keys.push([...parts.slice(0, index), key].join("."));
|
|
2410
|
+
}
|
|
2411
|
+
return keys;
|
|
2412
|
+
}
|
|
2413
|
+
async function writeNotFoundArtifacts(config, outDir) {
|
|
2414
|
+
const htmlFile = path7.join(outDir, "404.html");
|
|
2415
|
+
const html = await readFile3(htmlFile, "utf8").catch(() => {
|
|
2416
|
+
return;
|
|
2417
|
+
});
|
|
2418
|
+
if (html === undefined)
|
|
2419
|
+
return;
|
|
2420
|
+
if (config.trailingSlash === true) {
|
|
2421
|
+
const nested = path7.join(outDir, "404", "index.html");
|
|
2422
|
+
await mkdir7(path7.dirname(nested), { recursive: true });
|
|
2423
|
+
await writeFile7(nested, html);
|
|
2424
|
+
}
|
|
2425
|
+
const outHtml = config.trailingSlash === true ? path7.join(outDir, "_not-found", "index.html") : path7.join(outDir, "_not-found.html");
|
|
2426
|
+
const outTxt = config.trailingSlash === true ? path7.join(outDir, "_not-found", "index.txt") : path7.join(outDir, "_not-found.txt");
|
|
2427
|
+
await mkdir7(path7.dirname(outHtml), { recursive: true });
|
|
2428
|
+
await writeFile7(outHtml, html);
|
|
2429
|
+
await writeFile7(outTxt, html);
|
|
2430
|
+
await writeSegmentFiles(path7.join(outDir, "_not-found"), { route: "/_not-found", params: [] }, html);
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
// src/compat/register/export.ts
|
|
2434
|
+
var registered2 = false;
|
|
2435
|
+
onExtensionHostReset(() => registered2 = false);
|
|
2436
|
+
function registerExportExtensions(config) {
|
|
2437
|
+
if (registered2)
|
|
2438
|
+
return;
|
|
2439
|
+
if (!nextCompatEnabled(config))
|
|
2440
|
+
return;
|
|
2441
|
+
registered2 = true;
|
|
2442
|
+
registerBuildCompleteHooks(async (ctx) => {
|
|
2443
|
+
if (!nextCompatEnabled(ctx.config))
|
|
2444
|
+
return;
|
|
2445
|
+
await emitStaticExport(ctx);
|
|
2446
|
+
await emitMetadataRouteArtifacts(ctx);
|
|
2447
|
+
await emitCustomServerShim(ctx.config);
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
export {
|
|
2451
|
+
registerBuildCompatExtensions,
|
|
2452
|
+
registerExportExtensions,
|
|
2453
|
+
registerMiddlewareExtensions,
|
|
2454
|
+
registerTypedRoutesExtensions,
|
|
2455
|
+
registerValidationExtensions
|
|
2456
|
+
};
|