@wular/pnext 0.1.5 → 0.1.7
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-j47a10ce.js +44 -0
- package/dist/server/_chunks/analyze-arswqe6s.js +445 -0
- package/dist/server/_chunks/boot-af0mv3dy.js +36 -0
- package/dist/server/_chunks/build-spy3dxp4.js +84 -0
- package/dist/server/_chunks/build-t9h0hec3.js +3550 -0
- package/dist/server/_chunks/build-tier-m7yvqz61.js +2472 -0
- package/dist/server/_chunks/compile-53j02j27.js +22 -0
- package/dist/server/_chunks/config-1yzwexq6.js +27 -0
- package/dist/server/_chunks/config-n2z7yxps.js +22 -0
- package/dist/server/_chunks/create-meec9hs6.js +134 -0
- package/dist/server/_chunks/dev-fjmqg6en.js +220 -0
- package/dist/server/_chunks/esbuild-yyktfrtt.js +15 -0
- package/dist/server/_chunks/generate-n9sh6hzt.js +21 -0
- package/dist/server/_chunks/index-0374j2b9.js +66 -0
- package/dist/server/_chunks/index-06nyqntx.js +213 -0
- package/dist/server/_chunks/index-1011cscr.js +5263 -0
- package/dist/server/_chunks/index-11sfk4hb.js +170 -0
- package/dist/server/_chunks/index-20ppawv7.js +297 -0
- package/dist/server/_chunks/index-2dv4y4wd.js +1065 -0
- package/dist/server/_chunks/index-2vz0wzdn.js +59 -0
- package/dist/server/_chunks/index-2wfv4kvx.js +182 -0
- package/dist/server/_chunks/index-357na4a8.js +109 -0
- package/dist/server/_chunks/index-3b3at80h.js +109 -0
- package/dist/server/_chunks/index-3tf1xjsp.js +6166 -0
- package/dist/server/_chunks/index-3xbr4eyv.js +105 -0
- package/dist/server/_chunks/index-4399bvd2.js +18 -0
- package/dist/server/_chunks/index-4hgjrqh7.js +851 -0
- package/dist/server/_chunks/index-4q2gbfwk.js +2530 -0
- package/dist/server/_chunks/index-4t92hdxd.js +172 -0
- package/dist/server/_chunks/index-4zzebszd.js +10 -0
- package/dist/server/_chunks/index-5gyr4emz.js +107 -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-6e4fqv30.js +588 -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-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-8k7pfejn.js +1599 -0
- package/dist/server/_chunks/index-8kcxdfya.js +206 -0
- package/dist/server/_chunks/index-91x12ykq.js +274 -0
- package/dist/server/_chunks/index-9ch50vtq.js +18 -0
- package/dist/server/_chunks/index-9hx2641q.js +28 -0
- package/dist/server/_chunks/index-9n2914ww.js +535 -0
- package/dist/server/_chunks/index-9ych9ma8.js +207 -0
- package/dist/server/_chunks/index-b6wtkdp4.js +24 -0
- package/dist/server/_chunks/index-bcws5eh2.js +35 -0
- package/dist/server/_chunks/index-c0g2wf3z.js +92 -0
- package/dist/server/_chunks/index-cf4rvxv6.js +95 -0
- package/dist/server/_chunks/index-cjgqs13g.js +65 -0
- package/dist/server/_chunks/index-ckkdpht5.js +41 -0
- package/dist/server/_chunks/index-cyfednwb.js +87 -0
- package/dist/server/_chunks/index-danncfhy.js +311 -0
- package/dist/server/_chunks/index-dg0f05zs.js +199 -0
- package/dist/server/_chunks/index-e3a6yx84.js +18 -0
- package/dist/server/_chunks/index-e88tyv35.js +45 -0
- package/dist/server/_chunks/index-eajaspjk.js +1253 -0
- package/dist/server/_chunks/index-eeaanp2e.js +483 -0
- package/dist/server/_chunks/index-egykcqg3.js +101 -0
- package/dist/server/_chunks/index-en7n9f7m.js +22 -0
- package/dist/server/_chunks/index-ezgj0tr1.js +88 -0
- package/dist/server/_chunks/index-fkp000p1.js +590 -0
- package/dist/server/_chunks/index-fn1chkkd.js +214 -0
- package/dist/server/_chunks/index-fp8r0sqs.js +64 -0
- package/dist/server/_chunks/index-ggk2j965.js +9432 -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-hkdfj58q.js +92 -0
- package/dist/server/_chunks/index-j2zrcp1k.js +66 -0
- package/dist/server/_chunks/index-jcsjq3d1.js +20 -0
- package/dist/server/_chunks/index-jepjvcrf.js +198 -0
- package/dist/server/_chunks/index-jks0x0a1.js +14 -0
- package/dist/server/_chunks/index-jx7bqvw1.js +57 -0
- package/dist/server/_chunks/index-k1g3epw0.js +1299 -0
- package/dist/server/_chunks/index-knp0s912.js +7 -0
- package/dist/server/_chunks/index-kq8kpzye.js +472 -0
- package/dist/server/_chunks/index-kqyy1d4f.js +50 -0
- package/dist/server/_chunks/index-kresp2n8.js +445 -0
- package/dist/server/_chunks/index-ms9v9tnx.js +31 -0
- package/dist/server/_chunks/index-n4hxpng2.js +11 -0
- package/dist/server/_chunks/index-ncnes8c6.js +17 -0
- package/dist/server/_chunks/index-nqh3xhdc.js +57 -0
- package/dist/server/_chunks/index-nyrba2kr.js +4130 -0
- package/dist/server/_chunks/index-p77b4kcx.js +296 -0
- package/dist/server/_chunks/index-pym1cezq.js +39 -0
- package/dist/server/_chunks/index-q738kkhj.js +100 -0
- package/dist/server/_chunks/index-qjj6gddn.js +54 -0
- package/dist/server/_chunks/index-qm6kmhqs.js +110 -0
- package/dist/server/_chunks/index-qn4z5s3c.js +819 -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-rn8dyr1f.js +126 -0
- package/dist/server/_chunks/index-rt9qq1va.js +4 -0
- package/dist/server/_chunks/index-rthrsed5.js +356 -0
- package/dist/server/_chunks/index-sctcgyvv.js +185 -0
- package/dist/server/_chunks/index-sjpckxqn.js +213 -0
- package/dist/server/_chunks/index-sq3kvz3g.js +200 -0
- package/dist/server/_chunks/index-stbk3jhn.js +31 -0
- package/dist/server/_chunks/index-sv8m6789.js +266 -0
- package/dist/server/_chunks/index-tgcakdxc.js +125 -0
- package/dist/server/_chunks/index-tgsfjmep.js +74 -0
- package/dist/server/_chunks/index-tq0pc7eg.js +154 -0
- package/dist/server/_chunks/index-tq1f96v7.js +51 -0
- package/dist/server/_chunks/index-tqn2qnnn.js +241 -0
- package/dist/server/_chunks/index-tvqkq6e6.js +128 -0
- package/dist/server/_chunks/index-v1ags1na.js +132 -0
- package/dist/server/_chunks/index-vvmmknm1.js +1431 -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-wpfhfbs4.js +194 -0
- package/dist/server/_chunks/index-x0y005nh.js +283 -0
- package/dist/server/_chunks/index-x3yn4ywm.js +22 -0
- package/dist/server/_chunks/index-x93hv0sc.js +271 -0
- package/dist/server/_chunks/index-xvj80c3a.js +30 -0
- package/dist/server/_chunks/index-xywjg2vc.js +100 -0
- package/dist/server/_chunks/index-y2jr2n72.js +152 -0
- package/dist/server/_chunks/index-y36a0ybw.js +57 -0
- package/dist/server/_chunks/index-ye9hmsvf.js +47 -0
- package/dist/server/_chunks/index-yhxkxghe.js +56 -0
- package/dist/server/_chunks/index-ym67zqxp.js +130 -0
- package/dist/server/_chunks/index-ytjvpbm2.js +736 -0
- package/dist/server/_chunks/index-yz54pxrh.js +960 -0
- package/dist/server/_chunks/index-z4z9zv3b.js +733 -0
- package/dist/server/_chunks/index-z84ab1w0.js +1270 -0
- package/dist/server/_chunks/index-z88qv16t.js +11 -0
- package/dist/server/_chunks/index-zqpqyg8p.js +666 -0
- package/dist/server/_chunks/loader-7yw0j98z.js +78 -0
- package/dist/server/_chunks/modules-jn8bmbn8.js +74 -0
- package/dist/server/_chunks/pipeline-yy9jhydf.js +832 -0
- package/dist/server/_chunks/production-jar9ztm3.js +44 -0
- package/dist/server/_chunks/proxy-config-j84dgksn.js +21 -0
- package/dist/server/_chunks/proxy-w1d0wmsn.js +33 -0
- package/dist/server/_chunks/router-k1reahfn.js +498 -0
- package/dist/server/_chunks/routes-2s277fc6.js +64 -0
- package/dist/server/_chunks/run-pvd8bs1t.js +696 -0
- package/dist/server/_chunks/server-mt4a994c.js +1835 -0
- package/dist/server/_chunks/tsconfig-defaults-1nb3308g.js +20 -0
- package/dist/server/_chunks/typegen-0qr0459b.js +35 -0
- package/dist/server/api/client-cache.js +14 -0
- package/dist/server/cli/index.js +378 -0
- package/dist/server/cli/start.js +137 -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 +32 -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 +32 -0
- package/dist/server/compat/next/error.js +112 -0
- package/dist/server/compat/next/font/cache.js +14 -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 +22 -0
- package/dist/server/compat/next/font/runtime-client.js +33 -0
- package/dist/server/compat/next/font/runtime.js +41 -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 +14 -0
- package/dist/server/compat/next/link.js +14 -0
- package/dist/server/compat/next/navigation.js +190 -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 +30 -0
- package/dist/server/compat/next/resource-hints.js +30 -0
- package/dist/server/compat/next/rewrites.js +41 -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/src/api/dynamic.tsx +2 -0
- package/src/api/server.ts +24 -6
- package/src/cli/adapters/vercel-warm.ts +315 -61
- package/src/cli/adapters/vercel.ts +348 -71
- package/src/cli/build.ts +58 -33
- package/src/cli/index.ts +23 -10
- package/src/cli/serve/entry.ts +21 -159
- package/src/cli/serve/immutable.ts +31 -0
- package/src/cli/serve/pipeline.ts +82 -84
- package/src/cli/start.ts +3 -1
- package/src/client/chunk-fold.ts +19 -6
- package/src/client/react-tier.ts +3 -2
- package/src/client/reference-stub.ts +21 -2
- package/src/compat/actions/client-plugin.ts +4 -2
- package/src/compat/actions/config.ts +6 -5
- package/src/compat/actions/extensions.ts +2 -3
- 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/cache-control.ts +16 -8
- package/src/compat/css/modules.ts +18 -5
- package/src/compat/lifecycle/error-funnel.ts +1 -1
- package/src/compat/lifecycle/instrumentation.ts +117 -24
- package/src/compat/lifecycle/testmode.ts +3 -2
- package/src/compat/next/config-loader.ts +137 -13
- package/src/compat/next/font/runtime.ts +22 -2
- 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/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/validation/validate.ts +10 -7
- package/src/config.ts +51 -7
- package/src/css/assets.ts +213 -0
- package/src/css/build.ts +174 -238
- package/src/dev/server.ts +27 -8
- package/src/extensions.ts +4 -0
- package/src/render/hooks.ts +13 -0
- package/src/render/renderer.ts +52 -32
- package/src/request/context.ts +9 -0
- package/src/resolve/dynamic.ts +3 -1
- package/src/resolve/imports.ts +12 -52
- package/src/resolve/package-json.ts +56 -0
- package/src/resolve/scan-facts.ts +65 -0
- package/src/routing/href.ts +10 -3
- package/src/routing/match.ts +287 -0
- package/src/routing/metadata-files.ts +19 -5
- 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 +215 -43
- package/src/runtime/module-cache.ts +13 -0
- package/src/runtime/modules.ts +370 -81
- package/src/runtime/prebundle.ts +81 -0
- package/src/runtime/production.ts +391 -0
- package/src/runtime/release-graph.ts +334 -0
- package/src/runtime/vendor-build.ts +724 -13
- package/src/runtime/vendor.ts +16 -3
- package/src/types.ts +2 -0
- package/src/utils/fs.ts +89 -3
|
@@ -0,0 +1,1299 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
activateTestProxy,
|
|
4
|
+
installTestProxyFetch
|
|
5
|
+
} from "./index-2wfv4kvx.js";
|
|
6
|
+
import {
|
|
7
|
+
transpilePackages
|
|
8
|
+
} from "./index-danncfhy.js";
|
|
9
|
+
import {
|
|
10
|
+
selectRouteForRequest
|
|
11
|
+
} from "./index-jepjvcrf.js";
|
|
12
|
+
import {
|
|
13
|
+
compatAliases,
|
|
14
|
+
missingCompatImportError,
|
|
15
|
+
nextCompatAliases,
|
|
16
|
+
nextCompatEnabled,
|
|
17
|
+
reactCompatEnabled,
|
|
18
|
+
reactCompilerOptions,
|
|
19
|
+
reactServerLayerAliases
|
|
20
|
+
} from "./index-eeaanp2e.js";
|
|
21
|
+
import {
|
|
22
|
+
findProxyFiles
|
|
23
|
+
} from "./index-kq8kpzye.js";
|
|
24
|
+
import {
|
|
25
|
+
getRequestRuntime
|
|
26
|
+
} from "./index-z88qv16t.js";
|
|
27
|
+
import {
|
|
28
|
+
recordRequestPath
|
|
29
|
+
} from "./index-2vz0wzdn.js";
|
|
30
|
+
import {
|
|
31
|
+
getNextConfig
|
|
32
|
+
} from "./index-6e4fqv30.js";
|
|
33
|
+
import {
|
|
34
|
+
build
|
|
35
|
+
} from "./index-cjgqs13g.js";
|
|
36
|
+
import {
|
|
37
|
+
cssModuleScopePath
|
|
38
|
+
} from "./index-20ppawv7.js";
|
|
39
|
+
import {
|
|
40
|
+
markErrorLogged
|
|
41
|
+
} from "./index-jcsjq3d1.js";
|
|
42
|
+
import {
|
|
43
|
+
productionRelease
|
|
44
|
+
} from "./index-tqn2qnnn.js";
|
|
45
|
+
import {
|
|
46
|
+
getWorkUnit
|
|
47
|
+
} from "./index-grta8ap3.js";
|
|
48
|
+
import {
|
|
49
|
+
isPostpone
|
|
50
|
+
} from "./index-e3a6yx84.js";
|
|
51
|
+
import {
|
|
52
|
+
packageNameOfSpecifier,
|
|
53
|
+
resolveExternalLoadTarget,
|
|
54
|
+
resolveImport,
|
|
55
|
+
resolvePackageSpecifier,
|
|
56
|
+
setModuleAliases
|
|
57
|
+
} from "./index-yz54pxrh.js";
|
|
58
|
+
import {
|
|
59
|
+
loadNative
|
|
60
|
+
} from "./index-7wc9n8be.js";
|
|
61
|
+
import {
|
|
62
|
+
getProxyExtensions,
|
|
63
|
+
onExtensionHostReset,
|
|
64
|
+
registerAlwaysClientEntryReason,
|
|
65
|
+
registerClientEntryDetectors,
|
|
66
|
+
registerInitHooks,
|
|
67
|
+
registerLoadableExtensions,
|
|
68
|
+
registerPageExtensions,
|
|
69
|
+
registerRequestInterceptors,
|
|
70
|
+
registerRouteConventions,
|
|
71
|
+
registerRouteDependencyClassifiers,
|
|
72
|
+
registerUsageDetectors,
|
|
73
|
+
setBundlerExtensions,
|
|
74
|
+
setCompatModeExtensions,
|
|
75
|
+
setCssExtensions,
|
|
76
|
+
setImportAliasExtensions,
|
|
77
|
+
setProxyExtensions,
|
|
78
|
+
setRequestExtensions
|
|
79
|
+
} from "./index-zqpqyg8p.js";
|
|
80
|
+
import {
|
|
81
|
+
escapeRegex
|
|
82
|
+
} from "./index-qjj6gddn.js";
|
|
83
|
+
import {
|
|
84
|
+
__require
|
|
85
|
+
} from "./index-rt9qq1va.js";
|
|
86
|
+
|
|
87
|
+
// src/compat/css/modules.ts
|
|
88
|
+
import { existsSync, lstatSync, readdirSync, readFileSync, symlinkSync } from "fs";
|
|
89
|
+
import { createRequire as createRequire2 } from "module";
|
|
90
|
+
import path2 from "path";
|
|
91
|
+
|
|
92
|
+
// src/compat/css/lightningcss.ts
|
|
93
|
+
import { createRequire } from "module";
|
|
94
|
+
import path from "path";
|
|
95
|
+
var moduleCache = new Map;
|
|
96
|
+
function loadLightningcss(root) {
|
|
97
|
+
const cached = moduleCache.get(root);
|
|
98
|
+
if (cached !== undefined)
|
|
99
|
+
return cached;
|
|
100
|
+
let loaded = null;
|
|
101
|
+
try {
|
|
102
|
+
const require2 = createRequire(path.join(root, "package.json"));
|
|
103
|
+
loaded = loadNative(() => require2("lightningcss"));
|
|
104
|
+
} catch {
|
|
105
|
+
loaded = null;
|
|
106
|
+
}
|
|
107
|
+
moduleCache.set(root, loaded);
|
|
108
|
+
return loaded;
|
|
109
|
+
}
|
|
110
|
+
function featureKey(name) {
|
|
111
|
+
return name.replace(/(?:^|-)([a-z0-9])/g, (_match, char) => char.toUpperCase());
|
|
112
|
+
}
|
|
113
|
+
function featureMask(features, names) {
|
|
114
|
+
let mask = 0;
|
|
115
|
+
for (const name of names ?? [])
|
|
116
|
+
mask |= features[featureKey(name)] ?? 0;
|
|
117
|
+
return mask;
|
|
118
|
+
}
|
|
119
|
+
function maybeLightningcssTransform(css, file, root) {
|
|
120
|
+
const experimental = getNextConfig().experimental;
|
|
121
|
+
if (experimental?.useLightningcss !== true)
|
|
122
|
+
return css;
|
|
123
|
+
const lightning = loadLightningcss(root);
|
|
124
|
+
if (!lightning)
|
|
125
|
+
return css;
|
|
126
|
+
const features = experimental.lightningCssFeatures;
|
|
127
|
+
const userInclude = featureMask(lightning.Features, features?.include);
|
|
128
|
+
const userExclude = featureMask(lightning.Features, features?.exclude);
|
|
129
|
+
const include = ((lightning.Features.Nesting ?? 1) | userInclude) & ~userExclude;
|
|
130
|
+
try {
|
|
131
|
+
const result = lightning.transform({
|
|
132
|
+
filename: file,
|
|
133
|
+
code: new TextEncoder().encode(css),
|
|
134
|
+
include,
|
|
135
|
+
exclude: userExclude,
|
|
136
|
+
errorRecovery: true
|
|
137
|
+
});
|
|
138
|
+
return new TextDecoder().decode(result.code);
|
|
139
|
+
} catch {
|
|
140
|
+
return css;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/compat/css/modules.ts
|
|
145
|
+
var pagesCompatIgnoredSourceEntries = new Set([".next", ".pnext", "app", "node_modules", "pages"]);
|
|
146
|
+
function materializeNextCssSources(config) {
|
|
147
|
+
if (productionRelease(config))
|
|
148
|
+
return;
|
|
149
|
+
const generatedRoot = path2.dirname(config.appPath);
|
|
150
|
+
if (path2.basename(path2.dirname(generatedRoot)) !== "pnext-pages-compat")
|
|
151
|
+
return;
|
|
152
|
+
const outTop = path2.relative(config.root, config.outRootPath).split(path2.sep)[0];
|
|
153
|
+
const inApp = !path2.relative(config.root, generatedRoot).startsWith("..");
|
|
154
|
+
for (const entry of readdirSync(config.root)) {
|
|
155
|
+
if (pagesCompatIgnoredSourceEntries.has(entry) || entry === outTop)
|
|
156
|
+
continue;
|
|
157
|
+
const source = path2.join(config.root, entry);
|
|
158
|
+
const target = path2.join(generatedRoot, entry);
|
|
159
|
+
if (existsSync(target))
|
|
160
|
+
continue;
|
|
161
|
+
try {
|
|
162
|
+
symlinkSync(inApp ? path2.relative(generatedRoot, source) : source, target, lstatSync(source).isDirectory() ? "dir" : "file");
|
|
163
|
+
} catch {}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
var cssBuild;
|
|
167
|
+
function nextCssModuleChunkPlugin(config) {
|
|
168
|
+
return {
|
|
169
|
+
name: "pnext-compat-css-modules",
|
|
170
|
+
setup(build2) {
|
|
171
|
+
build2.onLoad({ filter: /\.css$/ }, async ({ path: file }) => {
|
|
172
|
+
const source = nextCssSource(file, config.root);
|
|
173
|
+
const raw = (await (cssBuild ??= import("./build-spy3dxp4.js"))).hoistCssImports(readFileSync(source, "utf8"));
|
|
174
|
+
const contents = file.endsWith(".module.css") ? transformCssModule(raw, source, config.root) : rewriteTransparentBodyChildren(raw);
|
|
175
|
+
return {
|
|
176
|
+
contents: maybeLightningcssTransform(contents, source, config.root),
|
|
177
|
+
loader: "css",
|
|
178
|
+
resolveDir: path2.dirname(source)
|
|
179
|
+
};
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function nextCssResolveModule(config) {
|
|
185
|
+
return (file) => isCssModuleFile(file) ? cssModuleMapping(file, config.root) : undefined;
|
|
186
|
+
}
|
|
187
|
+
function nextCssLoadModuleForClient(config) {
|
|
188
|
+
return (file) => isCssModuleFile(file) ? `export default ${JSON.stringify(cssModuleMapping(file, config.root))};` : undefined;
|
|
189
|
+
}
|
|
190
|
+
function nextCssResolveDependency(config) {
|
|
191
|
+
const requires = new Map;
|
|
192
|
+
return (_root, fromFile, specifier) => {
|
|
193
|
+
if (specifier.startsWith(".") || path2.isAbsolute(specifier))
|
|
194
|
+
return;
|
|
195
|
+
const source = nextCssSource(fromFile, config.root);
|
|
196
|
+
let require2 = requires.get(source);
|
|
197
|
+
if (!require2) {
|
|
198
|
+
require2 = createRequire2(source);
|
|
199
|
+
requires.set(source, require2);
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
const resolved = require2.resolve(specifier);
|
|
203
|
+
return isCssDependency(resolved) ? resolved : undefined;
|
|
204
|
+
} catch {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
function isCssModuleFile(file) {
|
|
210
|
+
return file.endsWith(".module.css");
|
|
211
|
+
}
|
|
212
|
+
function isCssDependency(file) {
|
|
213
|
+
return /\.(?:css|scss|sass)$/.test(file);
|
|
214
|
+
}
|
|
215
|
+
function cssModuleMapping(file, root) {
|
|
216
|
+
file = nextCssSource(file, root);
|
|
217
|
+
const cache = new Map;
|
|
218
|
+
const info = moduleInfo(file, root, cache);
|
|
219
|
+
return Object.fromEntries([...info.classes].map((className) => [
|
|
220
|
+
className,
|
|
221
|
+
classValue(file, className, root, cache, new Set)
|
|
222
|
+
]));
|
|
223
|
+
}
|
|
224
|
+
function nextCssSource(file, root) {
|
|
225
|
+
const resolved = path2.resolve(file);
|
|
226
|
+
const parts = resolved.split(path2.sep);
|
|
227
|
+
const buildClientIndex = parts.findIndex((_, index) => parts.slice(index, index + 3).join("/") === "cache/server/build-client");
|
|
228
|
+
if (buildClientIndex !== -1) {
|
|
229
|
+
const source = path2.join(root, ...parts.slice(buildClientIndex + 3));
|
|
230
|
+
if (existsSync(source))
|
|
231
|
+
return source;
|
|
232
|
+
}
|
|
233
|
+
const generatedIndex = parts.lastIndexOf("pnext-pages-compat");
|
|
234
|
+
const relative = generatedIndex === -1 ? undefined : parts.slice(generatedIndex + 2);
|
|
235
|
+
if (relative?.length) {
|
|
236
|
+
const source = path2.join(root, ...relative[0] === "source-app" ? ["app", ...relative.slice(1)] : relative[0] === "source-pages" ? ["pages", ...relative.slice(1)] : relative);
|
|
237
|
+
if (existsSync(source))
|
|
238
|
+
return source;
|
|
239
|
+
}
|
|
240
|
+
return resolved;
|
|
241
|
+
}
|
|
242
|
+
function rewriteTransparentBodyChildren(source) {
|
|
243
|
+
return source.replace(/body\s*>\s*(-?[_a-zA-Z][\w-]*)/g, (_, element) => `:is(body>${element},body :where(pnext-layout,#pnext-page)>${element})`);
|
|
244
|
+
}
|
|
245
|
+
function transformCssModule(source, file, root) {
|
|
246
|
+
const info = moduleInfoFromSource(source, file, root);
|
|
247
|
+
const imports = info.dependencies.map((dep) => `@import ${JSON.stringify(dep)};`).join(`
|
|
248
|
+
`);
|
|
249
|
+
const css = scopeKeyframes(rewriteModuleSelectors(stripComposes(source), file), file);
|
|
250
|
+
return [imports, css].filter(Boolean).join(`
|
|
251
|
+
`);
|
|
252
|
+
}
|
|
253
|
+
function moduleInfo(file, root, cache) {
|
|
254
|
+
const key = path2.resolve(file);
|
|
255
|
+
const cached = cache.get(key);
|
|
256
|
+
if (cached)
|
|
257
|
+
return cached;
|
|
258
|
+
const info = moduleInfoFromSource(readFileSync(key, "utf8"), key, root);
|
|
259
|
+
cache.set(key, info);
|
|
260
|
+
return info;
|
|
261
|
+
}
|
|
262
|
+
function moduleInfoFromSource(source, file, root) {
|
|
263
|
+
const classes = cssClassNames(source);
|
|
264
|
+
const composes = new Map;
|
|
265
|
+
const dependencies = [];
|
|
266
|
+
const seenDependencies = new Set;
|
|
267
|
+
const rulePattern = /(^|})([^{}]+)\{([^{}]*)\}/g;
|
|
268
|
+
let match;
|
|
269
|
+
while (match = rulePattern.exec(source)) {
|
|
270
|
+
const [, , selector, body] = match;
|
|
271
|
+
if (!selector || !body)
|
|
272
|
+
continue;
|
|
273
|
+
const localClasses = selectorClassNames(selector).filter((className) => classes.has(className));
|
|
274
|
+
if (localClasses.length === 0)
|
|
275
|
+
continue;
|
|
276
|
+
for (const ref of composeRefs(body)) {
|
|
277
|
+
for (const localClass of localClasses) {
|
|
278
|
+
const refs = composes.get(localClass) ?? [];
|
|
279
|
+
refs.push(ref);
|
|
280
|
+
composes.set(localClass, refs);
|
|
281
|
+
}
|
|
282
|
+
if (!ref.from || ref.from === "global")
|
|
283
|
+
continue;
|
|
284
|
+
const dependency = resolveCssModuleImport(root, file, ref.from);
|
|
285
|
+
if (!dependency || seenDependencies.has(dependency))
|
|
286
|
+
continue;
|
|
287
|
+
dependencies.push(dependency);
|
|
288
|
+
seenDependencies.add(dependency);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return { classes, composes, dependencies };
|
|
292
|
+
}
|
|
293
|
+
function classValue(file, className, root, cache, stack) {
|
|
294
|
+
const key = `${path2.resolve(file)}\x00${className}`;
|
|
295
|
+
if (stack.has(key))
|
|
296
|
+
return cssModuleClassName(file, className);
|
|
297
|
+
stack.add(key);
|
|
298
|
+
const info = moduleInfo(file, root, cache);
|
|
299
|
+
const parts = [cssModuleClassName(file, className)];
|
|
300
|
+
for (const ref of info.composes.get(className) ?? []) {
|
|
301
|
+
if (ref.from === "global") {
|
|
302
|
+
parts.push(...ref.names);
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
const refFile = ref.from ? resolveCssModuleImport(root, file, ref.from) : file;
|
|
306
|
+
if (!refFile)
|
|
307
|
+
continue;
|
|
308
|
+
const refInfo = moduleInfo(refFile, root, cache);
|
|
309
|
+
for (const name of ref.names) {
|
|
310
|
+
if (!refInfo.classes.has(name))
|
|
311
|
+
continue;
|
|
312
|
+
parts.push(...classValue(refFile, name, root, cache, stack).split(/\s+/));
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
stack.delete(key);
|
|
316
|
+
return [...new Set(parts)].join(" ");
|
|
317
|
+
}
|
|
318
|
+
function composeRefs(body) {
|
|
319
|
+
const refs = [];
|
|
320
|
+
const pattern = /\bcomposes\s*:\s*([^;]+);/g;
|
|
321
|
+
let match;
|
|
322
|
+
while (match = pattern.exec(body)) {
|
|
323
|
+
const value = match[1]?.trim();
|
|
324
|
+
if (!value)
|
|
325
|
+
continue;
|
|
326
|
+
const fromMatch = /^(.+?)\s+from\s+(['"]?)([^'"]+)\2$/.exec(value);
|
|
327
|
+
const names = (fromMatch?.[1] ?? value).split(/\s+/).filter(Boolean);
|
|
328
|
+
if (names.length === 0)
|
|
329
|
+
continue;
|
|
330
|
+
refs.push({ names, ...fromMatch?.[3] ? { from: fromMatch[3] } : {} });
|
|
331
|
+
}
|
|
332
|
+
return refs;
|
|
333
|
+
}
|
|
334
|
+
function resolveCssModuleImport(root, fromFile, specifier) {
|
|
335
|
+
const resolved = resolveImport(root, fromFile, specifier);
|
|
336
|
+
if (resolved && isCssModuleFile(resolved))
|
|
337
|
+
return path2.resolve(resolved);
|
|
338
|
+
if (specifier.startsWith(".") || path2.isAbsolute(specifier))
|
|
339
|
+
return;
|
|
340
|
+
const sibling = path2.resolve(path2.dirname(fromFile), specifier);
|
|
341
|
+
return existsSync(sibling) && isCssModuleFile(sibling) ? sibling : undefined;
|
|
342
|
+
}
|
|
343
|
+
function stripComposes(source) {
|
|
344
|
+
return source.replace(/\s*composes\s*:[^;{}]+;/g, "");
|
|
345
|
+
}
|
|
346
|
+
function cssClassNames(source) {
|
|
347
|
+
return new Set(selectorClassNames(source.replace(/\{[^{}]*\}/g, "{")));
|
|
348
|
+
}
|
|
349
|
+
function selectorClassNames(selector) {
|
|
350
|
+
const classes = [];
|
|
351
|
+
const pattern = /(^|[\s,>+~])\.(-?[_a-zA-Z][\w-]*)/g;
|
|
352
|
+
let match;
|
|
353
|
+
while (match = pattern.exec(selector)) {
|
|
354
|
+
if (match[2])
|
|
355
|
+
classes.push(match[2]);
|
|
356
|
+
}
|
|
357
|
+
return classes;
|
|
358
|
+
}
|
|
359
|
+
function rewriteModuleSelectors(css, file) {
|
|
360
|
+
let out = "";
|
|
361
|
+
let runStart = 0;
|
|
362
|
+
for (let index = 0;index < css.length; index++) {
|
|
363
|
+
const char = css[index];
|
|
364
|
+
if (char === "{") {
|
|
365
|
+
out += `${rewriteSelectorRun(css.slice(runStart, index), file)}{`;
|
|
366
|
+
runStart = index + 1;
|
|
367
|
+
} else if (char === "}" || char === ";") {
|
|
368
|
+
out += css.slice(runStart, index + 1);
|
|
369
|
+
runStart = index + 1;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return out + css.slice(runStart);
|
|
373
|
+
}
|
|
374
|
+
function rewriteSelectorRun(selector, file) {
|
|
375
|
+
if (selector.trimStart().startsWith("@"))
|
|
376
|
+
return selector;
|
|
377
|
+
let out = selector;
|
|
378
|
+
for (const className of selectorClassNames(selector)) {
|
|
379
|
+
out = rewriteClassSelector(out, cssModuleClassName(file, className), className);
|
|
380
|
+
}
|
|
381
|
+
return out.replace(/:global\(((?:[^()]|\([^()]*\))*)\)/g, "$1");
|
|
382
|
+
}
|
|
383
|
+
function scopeKeyframes(css, file) {
|
|
384
|
+
let out = css;
|
|
385
|
+
for (const name of keyframeNames(css)) {
|
|
386
|
+
const scoped = cssModuleClassName(file, name);
|
|
387
|
+
out = out.replace(new RegExp(`(@(?:-webkit-)?keyframes\\s+)${escapeRegex(name)}(?![-_a-zA-Z0-9])`, "g"), `$1${scoped}`);
|
|
388
|
+
out = out.replace(new RegExp(`(animation-name\\s*:\\s*)${escapeRegex(name)}(?![-_a-zA-Z0-9])`, "g"), `$1${scoped}`);
|
|
389
|
+
out = out.replace(new RegExp(`(animation\\s*:[^;{}]*?(?<![-_a-zA-Z0-9]))${escapeRegex(name)}(?![-_a-zA-Z0-9])`, "g"), `$1${scoped}`);
|
|
390
|
+
}
|
|
391
|
+
return out;
|
|
392
|
+
}
|
|
393
|
+
function keyframeNames(css) {
|
|
394
|
+
const names = new Set;
|
|
395
|
+
const pattern = /@(?:-webkit-)?keyframes\s+(-?[_a-zA-Z][\w-]*)/g;
|
|
396
|
+
let match;
|
|
397
|
+
while (match = pattern.exec(css)) {
|
|
398
|
+
if (match[1])
|
|
399
|
+
names.add(match[1]);
|
|
400
|
+
}
|
|
401
|
+
return names;
|
|
402
|
+
}
|
|
403
|
+
function cssModuleClassName(file, className) {
|
|
404
|
+
const base = path2.basename(file).replace(/\.module\.css$/, "").replace(/[^_a-zA-Z0-9]/g, "_");
|
|
405
|
+
const hash = pathHash(cssModuleScopePath(file));
|
|
406
|
+
return `${base}_${className}_${hash}`;
|
|
407
|
+
}
|
|
408
|
+
function rewriteClassSelector(css, scopedClassName, originalClassName) {
|
|
409
|
+
const pattern = new RegExp(`\\.${escapeRegex(originalClassName)}(?![-_a-zA-Z0-9])`, "g");
|
|
410
|
+
return css.replace(pattern, `.${scopedClassName}`);
|
|
411
|
+
}
|
|
412
|
+
function pathHash(file) {
|
|
413
|
+
let hash = 5381;
|
|
414
|
+
for (const char of file)
|
|
415
|
+
hash = (hash << 5) + hash ^ char.charCodeAt(0);
|
|
416
|
+
return (hash >>> 0).toString(36).slice(0, 5);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// src/compat/lifecycle/instrumentation.ts
|
|
420
|
+
import {
|
|
421
|
+
existsSync as existsSync2,
|
|
422
|
+
mkdirSync,
|
|
423
|
+
readFileSync as readFileSync2,
|
|
424
|
+
readdirSync as readdirSync2,
|
|
425
|
+
rmSync,
|
|
426
|
+
statSync,
|
|
427
|
+
writeFileSync
|
|
428
|
+
} from "fs";
|
|
429
|
+
import path3 from "path";
|
|
430
|
+
import { pathToFileURL } from "url";
|
|
431
|
+
import { createRequire as createRequire3 } from "module";
|
|
432
|
+
var INSTRUMENTATION_BASENAMES = [
|
|
433
|
+
"instrumentation.ts",
|
|
434
|
+
"instrumentation.mts",
|
|
435
|
+
"instrumentation.js",
|
|
436
|
+
"instrumentation.mjs",
|
|
437
|
+
"instrumentation.tsx"
|
|
438
|
+
];
|
|
439
|
+
function instrumentationAliases(config) {
|
|
440
|
+
return { ...compatAliases(config, "server"), ...reactServerLayerAliases(config) };
|
|
441
|
+
}
|
|
442
|
+
function instrumentationPlugin(root, config) {
|
|
443
|
+
const appRequire = createRequire3(path3.join(root, "package.json"));
|
|
444
|
+
const aliases = config ? instrumentationAliases(config) : {};
|
|
445
|
+
return {
|
|
446
|
+
name: "pnext-instrumentation",
|
|
447
|
+
setup(builder) {
|
|
448
|
+
builder.onResolve({ filter: /^[^./]/ }, (args) => {
|
|
449
|
+
const alias = aliases[args.path];
|
|
450
|
+
if (!alias)
|
|
451
|
+
return;
|
|
452
|
+
return {
|
|
453
|
+
path: path3.isAbsolute(alias) ? pathToFileURL(alias).href : alias,
|
|
454
|
+
external: true
|
|
455
|
+
};
|
|
456
|
+
});
|
|
457
|
+
builder.onResolve({ filter: /^server-only$/ }, () => ({
|
|
458
|
+
path: "server-only",
|
|
459
|
+
namespace: "pnext"
|
|
460
|
+
}));
|
|
461
|
+
builder.onLoad({ filter: /^server-only$/, namespace: "pnext" }, () => ({ contents: "" }));
|
|
462
|
+
builder.onResolve({ filter: /^@vercel\/otel$/ }, () => {
|
|
463
|
+
try {
|
|
464
|
+
appRequire.resolve("@vercel/otel");
|
|
465
|
+
return;
|
|
466
|
+
} catch {
|
|
467
|
+
return { path: "@vercel/otel", namespace: "pnext" };
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
builder.onLoad({ filter: /^@vercel\/otel$/, namespace: "pnext" }, () => ({
|
|
471
|
+
contents: "export function registerOTel() {}"
|
|
472
|
+
}));
|
|
473
|
+
builder.onResolve({ filter: /^[^./]/ }, (args) => {
|
|
474
|
+
const target = resolveExternalLoadTarget({
|
|
475
|
+
root,
|
|
476
|
+
fromFile: args.importer || path3.join(root, "instrumentation.ts"),
|
|
477
|
+
specifier: args.path,
|
|
478
|
+
target: "server"
|
|
479
|
+
});
|
|
480
|
+
return target ? { path: target } : undefined;
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
var loaded;
|
|
486
|
+
var readyGate;
|
|
487
|
+
function getUserOnRequestError() {
|
|
488
|
+
return loaded?.onRequestError;
|
|
489
|
+
}
|
|
490
|
+
function instrumentationReady() {
|
|
491
|
+
return readyGate ?? Promise.resolve();
|
|
492
|
+
}
|
|
493
|
+
function findInstrumentation(config) {
|
|
494
|
+
for (const root of instrumentationLookupRoots(config)) {
|
|
495
|
+
for (const name of INSTRUMENTATION_BASENAMES) {
|
|
496
|
+
const candidate = path3.join(root, name);
|
|
497
|
+
if (existsSync2(candidate))
|
|
498
|
+
return candidate;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
function instrumentationLookupRoots(config) {
|
|
504
|
+
const src = path3.join(config.root, "src");
|
|
505
|
+
const usesSrc = existsSync2(path3.join(src, "app")) || existsSync2(path3.join(src, "pages"));
|
|
506
|
+
return usesSrc ? [src] : [config.root];
|
|
507
|
+
}
|
|
508
|
+
async function importInstrumentation(file, config, suffix = "") {
|
|
509
|
+
const outDir = path3.join(config.outPath, "instrumentation");
|
|
510
|
+
mkdirSync(outDir, { recursive: true });
|
|
511
|
+
const outfile = path3.join(outDir, `instrumentation.${Date.now()}${suffix}.mjs`);
|
|
512
|
+
try {
|
|
513
|
+
await bundleInstrumentation(file, config, outfile);
|
|
514
|
+
return await import(pathToFileURL(outfile).href);
|
|
515
|
+
} finally {
|
|
516
|
+
rmSync(outfile, { force: true });
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
async function bundleInstrumentation(file, config, outfile, releaseDir) {
|
|
520
|
+
const root = config.root;
|
|
521
|
+
const tsconfig = path3.join(root, "tsconfig.json");
|
|
522
|
+
const sourceUrl = releaseDir ? `new URL(${JSON.stringify(path3.relative(releaseDir, file).split(path3.sep).join("/"))}, import.meta.url).href` : JSON.stringify(pathToFileURL(file).href);
|
|
523
|
+
await build({
|
|
524
|
+
entryPoints: [file],
|
|
525
|
+
outfile,
|
|
526
|
+
bundle: true,
|
|
527
|
+
platform: "node",
|
|
528
|
+
format: "esm",
|
|
529
|
+
target: "esnext",
|
|
530
|
+
packages: "external",
|
|
531
|
+
plugins: [instrumentationPlugin(root, config)],
|
|
532
|
+
...existsSync2(tsconfig) ? { tsconfig } : {},
|
|
533
|
+
banner: {
|
|
534
|
+
js: `import { fileURLToPath as __pnextFileURLToPath } from "node:url";
|
|
535
|
+
import { dirname as __pnextDirname } from "node:path";
|
|
536
|
+
const __pnextSourceUrl = ${sourceUrl};
|
|
537
|
+
const __pnextSourceFile = __pnextFileURLToPath(__pnextSourceUrl);
|
|
538
|
+
const __pnextSourceDir = __pnextDirname(__pnextSourceFile);`
|
|
539
|
+
},
|
|
540
|
+
define: {
|
|
541
|
+
__dirname: "__pnextSourceDir",
|
|
542
|
+
__filename: "__pnextSourceFile",
|
|
543
|
+
"import.meta.url": "__pnextSourceUrl"
|
|
544
|
+
},
|
|
545
|
+
logLevel: "silent",
|
|
546
|
+
sourcemap: false
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
function loadInstrumentation(config) {
|
|
550
|
+
if (readyGate)
|
|
551
|
+
return;
|
|
552
|
+
const released = productionRelease(config);
|
|
553
|
+
if (released) {
|
|
554
|
+
readyGate = registerReleased(released.instrumentation);
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
const file = findInstrumentation(config);
|
|
558
|
+
if (!file) {
|
|
559
|
+
readyGate = Promise.resolve();
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
readyGate = (async () => {
|
|
563
|
+
try {
|
|
564
|
+
if (!process.env.NEXT_RUNTIME)
|
|
565
|
+
process.env.NEXT_RUNTIME = "nodejs";
|
|
566
|
+
loaded = await importInstrumentation(file, config);
|
|
567
|
+
await loaded.register?.();
|
|
568
|
+
if (appHasEdgeEntities(config))
|
|
569
|
+
await runEdgeRegisterPass(file, config);
|
|
570
|
+
} catch (error) {
|
|
571
|
+
console.error("instrumentation register() failed:", error);
|
|
572
|
+
}
|
|
573
|
+
})();
|
|
574
|
+
}
|
|
575
|
+
async function registerReleased(instrumentation) {
|
|
576
|
+
if (!instrumentation?.file)
|
|
577
|
+
return;
|
|
578
|
+
try {
|
|
579
|
+
if (!process.env.NEXT_RUNTIME)
|
|
580
|
+
process.env.NEXT_RUNTIME = "nodejs";
|
|
581
|
+
loaded = await import(pathToFileURL(instrumentation.file).href);
|
|
582
|
+
await loaded.register?.();
|
|
583
|
+
if (instrumentation.edge) {
|
|
584
|
+
await withEdgeRuntime(async () => {
|
|
585
|
+
const edgeInstance = await import(pathToFileURL(instrumentation.edge).href);
|
|
586
|
+
await edgeInstance.register?.();
|
|
587
|
+
}, "instrumentation register() (edge pass) failed:");
|
|
588
|
+
}
|
|
589
|
+
} catch (error) {
|
|
590
|
+
console.error("instrumentation register() failed:", error);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
async function runEdgeRegisterPass(file, config) {
|
|
594
|
+
await withEdgeRuntime(async () => {
|
|
595
|
+
const edgeInstance = await importInstrumentation(file, config, ".edge");
|
|
596
|
+
await edgeInstance.register?.();
|
|
597
|
+
}, "instrumentation register() (edge pass) failed:");
|
|
598
|
+
}
|
|
599
|
+
async function withEdgeRuntime(task, failure) {
|
|
600
|
+
const previous = process.env.NEXT_RUNTIME;
|
|
601
|
+
process.env.NEXT_RUNTIME = "edge";
|
|
602
|
+
try {
|
|
603
|
+
await task();
|
|
604
|
+
} catch (error) {
|
|
605
|
+
console.error(failure, error);
|
|
606
|
+
} finally {
|
|
607
|
+
if (previous === undefined) {
|
|
608
|
+
delete process.env.NEXT_RUNTIME;
|
|
609
|
+
} else {
|
|
610
|
+
process.env.NEXT_RUNTIME = previous;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
var SOURCE_FILE_RE = /\.(?:ts|tsx|js|jsx|mjs|mts|cjs|cts)$/;
|
|
615
|
+
var EDGE_RUNTIME_RE = /\bruntime\b\s*[:=]\s*['"](?:experimental-)?edge['"]/;
|
|
616
|
+
function appHasEdgeEntities(config) {
|
|
617
|
+
const roots = [config.root, path3.join(config.root, "src")];
|
|
618
|
+
for (const root of roots) {
|
|
619
|
+
for (const name of ["middleware", "proxy"]) {
|
|
620
|
+
for (const ext of ["ts", "js", "mts", "mjs"]) {
|
|
621
|
+
if (existsSync2(path3.join(root, `${name}.${ext}`)))
|
|
622
|
+
return true;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
for (const dir of ["app", "pages"]) {
|
|
626
|
+
if (sourceTreeDeclaresEdgeRuntime(path3.join(root, dir)))
|
|
627
|
+
return true;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
return false;
|
|
631
|
+
}
|
|
632
|
+
function sourceTreeDeclaresEdgeRuntime(dir) {
|
|
633
|
+
let entries;
|
|
634
|
+
try {
|
|
635
|
+
entries = readdirSync2(dir);
|
|
636
|
+
} catch {
|
|
637
|
+
return false;
|
|
638
|
+
}
|
|
639
|
+
for (const entry of entries) {
|
|
640
|
+
if (entry === "node_modules" || entry.startsWith("."))
|
|
641
|
+
continue;
|
|
642
|
+
const full = path3.join(dir, entry);
|
|
643
|
+
let stats;
|
|
644
|
+
try {
|
|
645
|
+
stats = statSync(full);
|
|
646
|
+
} catch {
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
649
|
+
if (stats.isDirectory()) {
|
|
650
|
+
if (sourceTreeDeclaresEdgeRuntime(full))
|
|
651
|
+
return true;
|
|
652
|
+
continue;
|
|
653
|
+
}
|
|
654
|
+
if (!SOURCE_FILE_RE.test(entry))
|
|
655
|
+
continue;
|
|
656
|
+
try {
|
|
657
|
+
if (EDGE_RUNTIME_RE.test(readFileSync2(full, "utf8")))
|
|
658
|
+
return true;
|
|
659
|
+
} catch {}
|
|
660
|
+
}
|
|
661
|
+
return false;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// src/compat/lifecycle/error-funnel.ts
|
|
665
|
+
import path4 from "path";
|
|
666
|
+
import {
|
|
667
|
+
isForbiddenError,
|
|
668
|
+
isNotFoundError,
|
|
669
|
+
isRedirectError,
|
|
670
|
+
isUnauthorizedError
|
|
671
|
+
} from "../../../src/api/navigation.ts";
|
|
672
|
+
var ERROR_REPORTED_KEY = Symbol.for("pnext.errorReported");
|
|
673
|
+
function isControlFlowError(error) {
|
|
674
|
+
return isRedirectError(error) || isNotFoundError(error) || isForbiddenError(error) || isUnauthorizedError(error) || isPostpone(error) || isNextDynamicNoSsr(error);
|
|
675
|
+
}
|
|
676
|
+
function isNextDynamicNoSsr(error) {
|
|
677
|
+
const digest = error?.digest;
|
|
678
|
+
return digest === "NEXT_DYNAMIC_NO_SSR_CODE" || typeof digest === "string" && digest.startsWith("DYNAMIC_SERVER_USAGE");
|
|
679
|
+
}
|
|
680
|
+
function toDisplayRoute(route) {
|
|
681
|
+
let value = route.route || "/";
|
|
682
|
+
if (route.catchAll) {
|
|
683
|
+
const pattern = route.catchAllOptional ? `[[...${route.catchAll}]]` : `[...${route.catchAll}]`;
|
|
684
|
+
value = value.replace(`:${route.catchAll}*`, pattern);
|
|
685
|
+
}
|
|
686
|
+
for (const param of route.params)
|
|
687
|
+
value = value.replace(`:${param}`, `[${param}]`);
|
|
688
|
+
return value;
|
|
689
|
+
}
|
|
690
|
+
function routeKindFromFile(runtimeRoot, route) {
|
|
691
|
+
if (!runtimeRoot) {
|
|
692
|
+
return "App Router";
|
|
693
|
+
}
|
|
694
|
+
const normalized = path4.normalize(route.file);
|
|
695
|
+
const pagesRoot = path4.join(runtimeRoot, "pages");
|
|
696
|
+
const appRoot = path4.join(runtimeRoot, "app");
|
|
697
|
+
return normalized.startsWith(pagesRoot + path4.sep) || normalized === pagesRoot ? "Pages Router" : normalized.startsWith(appRoot + path4.sep) || normalized === appRoot ? "App Router" : "App Router";
|
|
698
|
+
}
|
|
699
|
+
function resolveRoute(pathname) {
|
|
700
|
+
const runtime = getRequestRuntime();
|
|
701
|
+
if (!runtime)
|
|
702
|
+
return;
|
|
703
|
+
const selectedPath = pathname.split("?")[0] ?? pathname;
|
|
704
|
+
const matched = selectRouteForRequest(runtime.routes, selectedPath, undefined);
|
|
705
|
+
if (!matched)
|
|
706
|
+
return;
|
|
707
|
+
return { route: matched.route, routePath: toDisplayRoute(matched.route) };
|
|
708
|
+
}
|
|
709
|
+
function resolveRoutePath(path5) {
|
|
710
|
+
try {
|
|
711
|
+
return resolveRoute(path5)?.routePath;
|
|
712
|
+
} catch {
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
function errorDigest(error) {
|
|
717
|
+
const digest = error?.digest;
|
|
718
|
+
return typeof digest === "string" ? digest : undefined;
|
|
719
|
+
}
|
|
720
|
+
function buildContext(error, context, path5) {
|
|
721
|
+
const runtime = getRequestRuntime();
|
|
722
|
+
const match = runtime ? resolveRoute(path5) : undefined;
|
|
723
|
+
const out = {};
|
|
724
|
+
out.routerKind = match ? routeKindFromFile(runtime?.config.root, match.route) : "App Router";
|
|
725
|
+
out.routeType = context.routeKind === "route-handler" ? "route" : "render";
|
|
726
|
+
const routePath = match ? match.routePath : resolveRoutePath(path5);
|
|
727
|
+
if (routePath)
|
|
728
|
+
out.routePath = routePath;
|
|
729
|
+
if (context.routeKind === "html") {
|
|
730
|
+
out.renderSource = context.renderSource ?? "react-server-components";
|
|
731
|
+
}
|
|
732
|
+
const revalidateReason = context.revalidateReason;
|
|
733
|
+
if (revalidateReason)
|
|
734
|
+
out.revalidateReason = revalidateReason;
|
|
735
|
+
const digest = errorDigest(error);
|
|
736
|
+
if (digest)
|
|
737
|
+
out.digest = digest;
|
|
738
|
+
return out;
|
|
739
|
+
}
|
|
740
|
+
function buildActionContext(error, path5) {
|
|
741
|
+
const runtime = getRequestRuntime();
|
|
742
|
+
const match = runtime ? resolveRoute(path5) : undefined;
|
|
743
|
+
const out = {
|
|
744
|
+
routerKind: match ? routeKindFromFile(runtime?.config.root, match.route) : "App Router",
|
|
745
|
+
routeType: "action",
|
|
746
|
+
renderSource: "react-server-components-payload"
|
|
747
|
+
};
|
|
748
|
+
const routePath = match ? match.routePath : resolveRoutePath(path5);
|
|
749
|
+
if (routePath)
|
|
750
|
+
out.routePath = routePath;
|
|
751
|
+
const digest = errorDigest(error);
|
|
752
|
+
if (digest)
|
|
753
|
+
out.digest = digest;
|
|
754
|
+
return out;
|
|
755
|
+
}
|
|
756
|
+
function isServerActionRequest(headers) {
|
|
757
|
+
if (headers.has("next-action"))
|
|
758
|
+
return true;
|
|
759
|
+
const accept = headers.get("accept") ?? "";
|
|
760
|
+
return accept.includes("text/x-component");
|
|
761
|
+
}
|
|
762
|
+
async function reportActionErrorToUser(error, request) {
|
|
763
|
+
if (isControlFlowError(error))
|
|
764
|
+
return;
|
|
765
|
+
const unit = getWorkUnit();
|
|
766
|
+
if (unit) {
|
|
767
|
+
const bag = unit.compat ??= {};
|
|
768
|
+
if (bag[ERROR_REPORTED_KEY])
|
|
769
|
+
return;
|
|
770
|
+
bag[ERROR_REPORTED_KEY] = true;
|
|
771
|
+
}
|
|
772
|
+
await instrumentationReady();
|
|
773
|
+
const hook = getUserOnRequestError();
|
|
774
|
+
if (!hook)
|
|
775
|
+
return;
|
|
776
|
+
let path5 = request.url;
|
|
777
|
+
try {
|
|
778
|
+
const parsed = new URL(request.url);
|
|
779
|
+
path5 = parsed.pathname + parsed.search;
|
|
780
|
+
} catch {}
|
|
781
|
+
try {
|
|
782
|
+
await hook(error, { path: path5, method: request.method, headers: headersToObject(request.headers) }, buildActionContext(error, path5));
|
|
783
|
+
} catch (hookError) {
|
|
784
|
+
console.error("instrumentation onRequestError failed:", hookError);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
function headersToObject(headers) {
|
|
788
|
+
const out = {};
|
|
789
|
+
headers.forEach((value, key) => {
|
|
790
|
+
out[key] = value;
|
|
791
|
+
});
|
|
792
|
+
return out;
|
|
793
|
+
}
|
|
794
|
+
async function reportRequestErrorToUser(error, requestInfo, context) {
|
|
795
|
+
if (isControlFlowError(error))
|
|
796
|
+
return;
|
|
797
|
+
const unit = getWorkUnit();
|
|
798
|
+
if (unit) {
|
|
799
|
+
const bag = unit.compat ??= {};
|
|
800
|
+
if (bag[ERROR_REPORTED_KEY])
|
|
801
|
+
return;
|
|
802
|
+
bag[ERROR_REPORTED_KEY] = true;
|
|
803
|
+
}
|
|
804
|
+
await instrumentationReady();
|
|
805
|
+
const hook = getUserOnRequestError();
|
|
806
|
+
if (!hook)
|
|
807
|
+
return;
|
|
808
|
+
let path5 = requestInfo.url;
|
|
809
|
+
try {
|
|
810
|
+
const parsed = new URL(requestInfo.url);
|
|
811
|
+
path5 = parsed.pathname + parsed.search;
|
|
812
|
+
} catch {}
|
|
813
|
+
const hookContext = isServerActionRequest(requestInfo.headers) ? buildActionContext(error, path5) : buildContext(error, context, path5);
|
|
814
|
+
try {
|
|
815
|
+
await hook(error, { path: path5, method: requestInfo.method, headers: headersToObject(requestInfo.headers) }, hookContext);
|
|
816
|
+
} catch (hookError) {
|
|
817
|
+
console.error("instrumentation onRequestError failed:", hookError);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
var guardInstalled = false;
|
|
821
|
+
function installUnhandledRejectionGuard() {
|
|
822
|
+
if (guardInstalled)
|
|
823
|
+
return;
|
|
824
|
+
if (typeof process === "undefined" || typeof process.on !== "function")
|
|
825
|
+
return;
|
|
826
|
+
guardInstalled = true;
|
|
827
|
+
process.on("unhandledRejection", (reason) => {
|
|
828
|
+
if (isControlFlowError(reason))
|
|
829
|
+
return;
|
|
830
|
+
if (markErrorLogged(reason))
|
|
831
|
+
console.error(reason);
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
// src/compat/lifecycle/node-console.ts
|
|
836
|
+
import { format } from "util";
|
|
837
|
+
var installed = Symbol.for("pnext.node-console-format-installed");
|
|
838
|
+
function installNodeConsoleFormat() {
|
|
839
|
+
const state = globalThis;
|
|
840
|
+
if (state[installed])
|
|
841
|
+
return;
|
|
842
|
+
state[installed] = true;
|
|
843
|
+
const log = console.log.bind(console);
|
|
844
|
+
console.log = (...args) => log(format(...args));
|
|
845
|
+
const error = console.error.bind(console);
|
|
846
|
+
console.error = (...args) => error(format(...args));
|
|
847
|
+
const warn = console.warn.bind(console);
|
|
848
|
+
console.warn = (...args) => warn(format(...args));
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
// src/compat/register/lifecycle.ts
|
|
852
|
+
function testProxyEnabled() {
|
|
853
|
+
const experimental = getNextConfig().experimental;
|
|
854
|
+
return experimental?.testProxy === true;
|
|
855
|
+
}
|
|
856
|
+
function registerLifecycleBootHooks(config) {
|
|
857
|
+
if (!nextCompatEnabled(config))
|
|
858
|
+
return;
|
|
859
|
+
installNodeConsoleFormat();
|
|
860
|
+
setRequestExtensions({ onRequestError: reportRequestErrorToUser });
|
|
861
|
+
installUnhandledRejectionGuard();
|
|
862
|
+
registerInitHooks((cfg, context) => {
|
|
863
|
+
if (!context.build)
|
|
864
|
+
loadInstrumentation(cfg);
|
|
865
|
+
installTestProxyFetch();
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
function registerLifecycleExtensions(config) {
|
|
869
|
+
if (!nextCompatEnabled(config))
|
|
870
|
+
return;
|
|
871
|
+
const lifecycleInterceptor = async (request) => {
|
|
872
|
+
await instrumentationReady();
|
|
873
|
+
try {
|
|
874
|
+
recordRequestPath(new URL(request.url).pathname);
|
|
875
|
+
} catch {}
|
|
876
|
+
if (testProxyEnabled())
|
|
877
|
+
activateTestProxy(request.headers);
|
|
878
|
+
return;
|
|
879
|
+
};
|
|
880
|
+
registerRequestInterceptors(lifecycleInterceptor);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
// src/compat/register/routing.ts
|
|
884
|
+
function registerRoutingExtensions(config) {
|
|
885
|
+
if (!nextCompatEnabled(config))
|
|
886
|
+
return;
|
|
887
|
+
registerRouteConventions({ name: "forbidden", boundary: true }, { name: "unauthorized", boundary: true });
|
|
888
|
+
registerUsageDetectors(usesNextRequestImport, usesNextServerConnection);
|
|
889
|
+
registerRouteDependencyClassifiers(classifyNextRouteDependencies);
|
|
890
|
+
registerClientEntryDetectors({ reason: "actions", detect: usesServerActionForm }, { reason: "form", detect: usesNextForm }, { reason: "control-flow", detect: usesClientControlFlowThrow });
|
|
891
|
+
registerAlwaysClientEntryReason("compat-parity");
|
|
892
|
+
}
|
|
893
|
+
var classificationCache = new Map;
|
|
894
|
+
function classifyNextRouteDependencies({
|
|
895
|
+
kind,
|
|
896
|
+
files
|
|
897
|
+
}) {
|
|
898
|
+
for (const { source } of files) {
|
|
899
|
+
const key = `${kind}\x00${source.length}\x00${Bun.hash(source).toString()}`;
|
|
900
|
+
let usesRequest = classificationCache.get(key);
|
|
901
|
+
if (usesRequest === undefined) {
|
|
902
|
+
usesRequest = sourceUsesRequest(kind, source);
|
|
903
|
+
classificationCache.set(key, usesRequest);
|
|
904
|
+
}
|
|
905
|
+
if (usesRequest)
|
|
906
|
+
return { usesRequest: true };
|
|
907
|
+
}
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
function sourceUsesRequest(kind, source) {
|
|
911
|
+
const requestUse = usesNextRequestImport(source) || usesNextServerConnection(source);
|
|
912
|
+
const afterOnly = hasAfterCallbacks(source) && !hasRequestApiOutsideAfter(source);
|
|
913
|
+
const handlerAfterDraftMode = kind === "handler" && hasAfterDraftMode(source);
|
|
914
|
+
if (requestUse && (kind === "handler" || !afterOnly) || handlerAfterDraftMode)
|
|
915
|
+
return true;
|
|
916
|
+
return kind === "page" && hasAfterCallbacks(source) && !hasRequestApiUse(source) && !hasAfterDraftMode(source) && !hasExplicitStaticDynamic(source);
|
|
917
|
+
}
|
|
918
|
+
function hasAfterDraftMode(source) {
|
|
919
|
+
return hasAfterCallbacks(source) && nextHeadersBindings(source).draftMode.length > 0;
|
|
920
|
+
}
|
|
921
|
+
function hasRequestApiOutsideAfter(source) {
|
|
922
|
+
return hasRequestApiUse(withoutAfterCallbacks(source));
|
|
923
|
+
}
|
|
924
|
+
function hasRequestApiUse(source) {
|
|
925
|
+
const outside = stripCommentsAndStrings(source);
|
|
926
|
+
const headers = nextHeadersBindings(source);
|
|
927
|
+
return headers.headers.some((name) => new RegExp(`\\b${escapeRegex(name)}\\s*\\(`).test(outside)) || headers.cookies.some((name) => new RegExp(`\\b${escapeRegex(name)}\\s*\\(`).test(outside)) || connectionBindings(source).some((name) => new RegExp(`\\b${escapeRegex(name)}\\s*\\(`).test(outside));
|
|
928
|
+
}
|
|
929
|
+
function nextHeadersBindings(source) {
|
|
930
|
+
const headers = [];
|
|
931
|
+
const cookies = [];
|
|
932
|
+
const draftMode = [];
|
|
933
|
+
const pattern = /\bimport\s+\{([^}]*)\}\s+from\s*['"]next\/headers(?:\.js)?['"]/g;
|
|
934
|
+
let match;
|
|
935
|
+
while (match = pattern.exec(stripComments(source))) {
|
|
936
|
+
for (const item of match[1].split(",")) {
|
|
937
|
+
const [imported, local] = item.trim().split(/\s+as\s+/);
|
|
938
|
+
const name = (local ?? imported)?.trim();
|
|
939
|
+
if (!name)
|
|
940
|
+
continue;
|
|
941
|
+
if (imported?.trim() === "headers")
|
|
942
|
+
headers.push(name);
|
|
943
|
+
if (imported?.trim() === "cookies")
|
|
944
|
+
cookies.push(name);
|
|
945
|
+
if (imported?.trim() === "draftMode")
|
|
946
|
+
draftMode.push(name);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
return { headers, cookies, draftMode };
|
|
950
|
+
}
|
|
951
|
+
function connectionBindings(source) {
|
|
952
|
+
const names = [];
|
|
953
|
+
const pattern = /\bimport\s+[^'";]+?\s+from\s*['"]next\/server(?:\.js)?['"]/g;
|
|
954
|
+
let match;
|
|
955
|
+
while (match = pattern.exec(stripComments(source))) {
|
|
956
|
+
const named = /\{([^}]*)\}/.exec(match[0])?.[1];
|
|
957
|
+
if (!named)
|
|
958
|
+
continue;
|
|
959
|
+
for (const item of named.split(",")) {
|
|
960
|
+
const [imported, local] = item.trim().split(/\s+as\s+/);
|
|
961
|
+
if (imported?.trim() === "connection")
|
|
962
|
+
names.push((local ?? imported).trim());
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
return names;
|
|
966
|
+
}
|
|
967
|
+
var AFTER_TOKEN = /\bafter\b/;
|
|
968
|
+
function mentionsAfter(source) {
|
|
969
|
+
return source.includes("after") && AFTER_TOKEN.test(source);
|
|
970
|
+
}
|
|
971
|
+
function hasAfterCallbacks(source) {
|
|
972
|
+
return mentionsAfter(source) && /\bafter\s*\(/.test(maskCommentsAndStrings(source));
|
|
973
|
+
}
|
|
974
|
+
function hasExplicitStaticDynamic(source) {
|
|
975
|
+
return /\bexport\s+const\s+dynamic\s*=\s*['"](?:error|force-static)['"]/.test(stripComments(source));
|
|
976
|
+
}
|
|
977
|
+
function withoutAfterCallbacks(source) {
|
|
978
|
+
if (!mentionsAfter(source))
|
|
979
|
+
return source;
|
|
980
|
+
const chars = [...source];
|
|
981
|
+
const searchable = maskCommentsAndStrings(source);
|
|
982
|
+
const pattern = /\bafter\s*\(/g;
|
|
983
|
+
let match;
|
|
984
|
+
while (match = pattern.exec(searchable)) {
|
|
985
|
+
let depth = 1;
|
|
986
|
+
let index = match.index + match[0].length;
|
|
987
|
+
for (;index < searchable.length && depth > 0; index++) {
|
|
988
|
+
if (searchable[index] === "(")
|
|
989
|
+
depth++;
|
|
990
|
+
else if (searchable[index] === ")")
|
|
991
|
+
depth--;
|
|
992
|
+
}
|
|
993
|
+
if (depth !== 0)
|
|
994
|
+
continue;
|
|
995
|
+
for (let cursor = match.index;cursor < index; cursor++)
|
|
996
|
+
chars[cursor] = " ";
|
|
997
|
+
pattern.lastIndex = index;
|
|
998
|
+
}
|
|
999
|
+
return chars.join("");
|
|
1000
|
+
}
|
|
1001
|
+
var maskCommentsAndStrings = memoizeBySource(maskSource);
|
|
1002
|
+
function maskSource(source) {
|
|
1003
|
+
const chars = [...source];
|
|
1004
|
+
let quote;
|
|
1005
|
+
let lineComment = false;
|
|
1006
|
+
let blockComment = false;
|
|
1007
|
+
for (let index = 0;index < chars.length; index++) {
|
|
1008
|
+
const char = chars[index];
|
|
1009
|
+
const next = chars[index + 1];
|
|
1010
|
+
if (lineComment) {
|
|
1011
|
+
if (char === `
|
|
1012
|
+
`)
|
|
1013
|
+
lineComment = false;
|
|
1014
|
+
else
|
|
1015
|
+
chars[index] = " ";
|
|
1016
|
+
continue;
|
|
1017
|
+
}
|
|
1018
|
+
if (blockComment) {
|
|
1019
|
+
chars[index] = char === `
|
|
1020
|
+
` ? `
|
|
1021
|
+
` : " ";
|
|
1022
|
+
if (char === "*" && next === "/") {
|
|
1023
|
+
chars[index + 1] = " ";
|
|
1024
|
+
blockComment = false;
|
|
1025
|
+
index++;
|
|
1026
|
+
}
|
|
1027
|
+
continue;
|
|
1028
|
+
}
|
|
1029
|
+
if (quote) {
|
|
1030
|
+
chars[index] = char === `
|
|
1031
|
+
` ? `
|
|
1032
|
+
` : " ";
|
|
1033
|
+
if (char === "\\") {
|
|
1034
|
+
if (next && next !== `
|
|
1035
|
+
`)
|
|
1036
|
+
chars[index + 1] = " ";
|
|
1037
|
+
index++;
|
|
1038
|
+
} else if (char === quote) {
|
|
1039
|
+
quote = undefined;
|
|
1040
|
+
}
|
|
1041
|
+
continue;
|
|
1042
|
+
}
|
|
1043
|
+
if (char === "/" && next === "/") {
|
|
1044
|
+
chars[index] = chars[index + 1] = " ";
|
|
1045
|
+
lineComment = true;
|
|
1046
|
+
index++;
|
|
1047
|
+
continue;
|
|
1048
|
+
}
|
|
1049
|
+
if (char === "/" && next === "*") {
|
|
1050
|
+
chars[index] = chars[index + 1] = " ";
|
|
1051
|
+
blockComment = true;
|
|
1052
|
+
index++;
|
|
1053
|
+
continue;
|
|
1054
|
+
}
|
|
1055
|
+
if (char === '"' || char === "'" || char === "`") {
|
|
1056
|
+
chars[index] = " ";
|
|
1057
|
+
quote = char;
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
return chars.join("");
|
|
1061
|
+
}
|
|
1062
|
+
function usesServerActionForm(source) {
|
|
1063
|
+
return source.includes("use server") && /(['"])use server\1/.test(stripComments(source)) || usesClientFunctionFormAction(source);
|
|
1064
|
+
}
|
|
1065
|
+
var CLIENT_FUNCTION_ACTION_PATTERN = /\b(?:action|formAction)\s*=\s*\{\s*(?!['"`])/;
|
|
1066
|
+
function usesClientFunctionFormAction(source) {
|
|
1067
|
+
if (!hasUseClientDirective(source))
|
|
1068
|
+
return false;
|
|
1069
|
+
return CLIENT_FUNCTION_ACTION_PATTERN.test(stripComments(source));
|
|
1070
|
+
}
|
|
1071
|
+
var USE_CLIENT_DIRECTIVE = /^\s*(?:\/\/[^\n]*\n|\/\*[\s\S]*?\*\/\s*|#![^\n]*\n|\s)*(['"])use client\1/;
|
|
1072
|
+
function hasUseClientDirective(source) {
|
|
1073
|
+
return source.includes("use client") && USE_CLIENT_DIRECTIVE.test(source);
|
|
1074
|
+
}
|
|
1075
|
+
var CONTROL_FLOW_IMPORT_PATTERN = /import\s*\{[^}]*\b(?:notFound|forbidden|unauthorized)\b[^}]*\}\s*from\s*['"]next\/navigation(?:\.js)?['"]/;
|
|
1076
|
+
function usesClientControlFlowThrow(source) {
|
|
1077
|
+
return hasUseClientDirective(source) && CONTROL_FLOW_IMPORT_PATTERN.test(source);
|
|
1078
|
+
}
|
|
1079
|
+
var NEXT_FORM_IMPORT_PATTERN = /import\s+[^'";]*\s+from\s+['"]next\/form(?:\.js)?['"]/;
|
|
1080
|
+
function usesNextForm(source) {
|
|
1081
|
+
if (!source.includes("next/form"))
|
|
1082
|
+
return false;
|
|
1083
|
+
const searchable = stripComments(source);
|
|
1084
|
+
if (!NEXT_FORM_IMPORT_PATTERN.test(searchable))
|
|
1085
|
+
return false;
|
|
1086
|
+
return /\b<form\b[^>]*\b(?:action|formAction)\s*=/.test(searchable) || /\bformAction\s*:\s*/.test(searchable) || /<\s*[A-Za-z_$][\w$]*\b[^>]*\b(?:action|formAction)\s*=/.test(searchable);
|
|
1087
|
+
}
|
|
1088
|
+
function usesNextRequestImport(source) {
|
|
1089
|
+
const withoutComments = stripComments(source);
|
|
1090
|
+
const draftModeOnlyImport = /\bimport\s+\{\s*draftMode\s*(?:as\s+[\w$]+\s*)?,?\s*\}\s*from\s*['"]next\/headers(?:\.js)?['"]/g;
|
|
1091
|
+
const headers = nextHeadersImportPattern().test(withoutComments.replace(draftModeOnlyImport, ""));
|
|
1092
|
+
const client = /^\s*['"]use client['"]\s*;?/.test(withoutComments);
|
|
1093
|
+
return headers || !client && importsNextNavigationRequestHook(withoutComments);
|
|
1094
|
+
}
|
|
1095
|
+
function nextHeadersImportPattern() {
|
|
1096
|
+
return /(?:from\s+|import\s*\()\s*['"]next\/headers(?:\.js)?['"]/;
|
|
1097
|
+
}
|
|
1098
|
+
function importsNextNavigationRequestHook(source) {
|
|
1099
|
+
const importPattern = /\bimport\s+(type\s+)?([^'";]+?)\s+from\s+['"]next\/navigation['"]/g;
|
|
1100
|
+
let match;
|
|
1101
|
+
while (match = importPattern.exec(source)) {
|
|
1102
|
+
const [, typeKeyword, clause] = match;
|
|
1103
|
+
if (!typeKeyword && clause && includesRequestNavigationHook(importedExports(clause)))
|
|
1104
|
+
return true;
|
|
1105
|
+
}
|
|
1106
|
+
const exportPattern = /\bexport\s+(type\s+)?\{([^}]*)\}\s+from\s+['"]next\/navigation['"]/g;
|
|
1107
|
+
while (match = exportPattern.exec(source)) {
|
|
1108
|
+
const [, typeKeyword, clause] = match;
|
|
1109
|
+
if (!typeKeyword && clause && includesRequestNavigationHook(exportedNames(clause)))
|
|
1110
|
+
return true;
|
|
1111
|
+
}
|
|
1112
|
+
return false;
|
|
1113
|
+
}
|
|
1114
|
+
function usesNextServerConnection(source) {
|
|
1115
|
+
const withoutComments = stripComments(source);
|
|
1116
|
+
const searchable = stripCommentsAndStrings(source);
|
|
1117
|
+
const importPattern = /\bimport\s+(type\s+)?([^'";]+?)\s+from\s+['"]next\/server(?:\.js)?['"]/g;
|
|
1118
|
+
let match;
|
|
1119
|
+
while (match = importPattern.exec(withoutComments)) {
|
|
1120
|
+
const [, typeKeyword, clause] = match;
|
|
1121
|
+
if (typeKeyword || !clause)
|
|
1122
|
+
continue;
|
|
1123
|
+
for (const pattern of importedConnectionCallPatterns(clause)) {
|
|
1124
|
+
if (pattern.test(searchable))
|
|
1125
|
+
return true;
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
return false;
|
|
1129
|
+
}
|
|
1130
|
+
function importedConnectionCallPatterns(clause) {
|
|
1131
|
+
const patterns = [];
|
|
1132
|
+
const namespace = /\*\s+as\s+([A-Za-z_$][\w$]*)/.exec(clause)?.[1];
|
|
1133
|
+
if (namespace)
|
|
1134
|
+
patterns.push(new RegExp(`\\b${escapeRegex(namespace)}\\.connection\\s*\\(`));
|
|
1135
|
+
const named = /\{([^}]*)\}/.exec(clause)?.[1];
|
|
1136
|
+
if (named) {
|
|
1137
|
+
for (const item of named.split(",")) {
|
|
1138
|
+
const [imported, local] = item.trim().split(/\s+as\s+/);
|
|
1139
|
+
if (imported?.trim() === "connection") {
|
|
1140
|
+
patterns.push(new RegExp(`\\b${escapeRegex((local ?? imported).trim())}\\s*\\(`));
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
return patterns;
|
|
1145
|
+
}
|
|
1146
|
+
function includesRequestNavigationHook(exports) {
|
|
1147
|
+
return exports.includes("*") || exports.includes("useSearchParams") || exports.includes("useRoute");
|
|
1148
|
+
}
|
|
1149
|
+
function importedExports(clause) {
|
|
1150
|
+
const value = clause.trim();
|
|
1151
|
+
if (!value)
|
|
1152
|
+
return [];
|
|
1153
|
+
const exports = new Set;
|
|
1154
|
+
if (value.startsWith("*"))
|
|
1155
|
+
exports.add("*");
|
|
1156
|
+
const defaultImport = /^[A-Za-z_$][\w$]*/.exec(value);
|
|
1157
|
+
if (defaultImport && !value.startsWith("{") && !value.startsWith("*"))
|
|
1158
|
+
exports.add("default");
|
|
1159
|
+
const named = /\{([^}]*)\}/.exec(value);
|
|
1160
|
+
if (named?.[1]) {
|
|
1161
|
+
for (const item of named[1].split(",")) {
|
|
1162
|
+
const [name] = item.trim().split(/\s+as\s+/);
|
|
1163
|
+
if (name)
|
|
1164
|
+
exports.add(name.trim());
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
return [...exports];
|
|
1168
|
+
}
|
|
1169
|
+
function exportedNames(clause) {
|
|
1170
|
+
return clause.split(",").map((item) => item.trim().split(/\s+as\s+/)[0]?.trim()).filter((name) => Boolean(name) && name !== "type");
|
|
1171
|
+
}
|
|
1172
|
+
function memoizeBySource(derive) {
|
|
1173
|
+
const cache = new Map;
|
|
1174
|
+
return (source) => {
|
|
1175
|
+
const hit = cache.get(source);
|
|
1176
|
+
if (hit !== undefined)
|
|
1177
|
+
return hit;
|
|
1178
|
+
const value = derive(source);
|
|
1179
|
+
if (cache.size >= 4)
|
|
1180
|
+
cache.delete(cache.keys().next().value);
|
|
1181
|
+
cache.set(source, value);
|
|
1182
|
+
return value;
|
|
1183
|
+
};
|
|
1184
|
+
}
|
|
1185
|
+
var stripCommentsAndStrings = memoizeBySource((source) => stripComments(source).replace(/(['"`])(?:\\[\s\S]|(?!\1)[^\\])*\1/g, ""));
|
|
1186
|
+
var stripComments = memoizeBySource((source) => {
|
|
1187
|
+
const chars = [...source];
|
|
1188
|
+
let quote;
|
|
1189
|
+
let lineComment = false;
|
|
1190
|
+
let blockComment = false;
|
|
1191
|
+
for (let index = 0;index < chars.length; index++) {
|
|
1192
|
+
const char = chars[index];
|
|
1193
|
+
const next = chars[index + 1];
|
|
1194
|
+
if (lineComment) {
|
|
1195
|
+
if (char === `
|
|
1196
|
+
`)
|
|
1197
|
+
lineComment = false;
|
|
1198
|
+
else
|
|
1199
|
+
chars[index] = " ";
|
|
1200
|
+
continue;
|
|
1201
|
+
}
|
|
1202
|
+
if (blockComment) {
|
|
1203
|
+
chars[index] = char === `
|
|
1204
|
+
` ? `
|
|
1205
|
+
` : " ";
|
|
1206
|
+
if (char === "*" && next === "/") {
|
|
1207
|
+
chars[index + 1] = " ";
|
|
1208
|
+
blockComment = false;
|
|
1209
|
+
index++;
|
|
1210
|
+
}
|
|
1211
|
+
continue;
|
|
1212
|
+
}
|
|
1213
|
+
if (quote) {
|
|
1214
|
+
if (char === "\\")
|
|
1215
|
+
index++;
|
|
1216
|
+
else if (char === quote)
|
|
1217
|
+
quote = undefined;
|
|
1218
|
+
continue;
|
|
1219
|
+
}
|
|
1220
|
+
if (char === '"' || char === "'" || char === "`") {
|
|
1221
|
+
quote = char;
|
|
1222
|
+
continue;
|
|
1223
|
+
}
|
|
1224
|
+
if (char === "/" && next === "/") {
|
|
1225
|
+
chars[index] = chars[index + 1] = " ";
|
|
1226
|
+
lineComment = true;
|
|
1227
|
+
index++;
|
|
1228
|
+
continue;
|
|
1229
|
+
}
|
|
1230
|
+
if (char === "/" && next === "*") {
|
|
1231
|
+
chars[index] = chars[index + 1] = " ";
|
|
1232
|
+
blockComment = true;
|
|
1233
|
+
index++;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
return chars.join("");
|
|
1237
|
+
});
|
|
1238
|
+
|
|
1239
|
+
// src/compat/register/boot.ts
|
|
1240
|
+
var NEXT_PROXY_NAMES = ["proxy", "middleware"];
|
|
1241
|
+
var CORE_BASE_PAGE_EXTENSIONS = new Set(["tsx", "ts", "jsx", "js", "mjs"]);
|
|
1242
|
+
var registered = false;
|
|
1243
|
+
onExtensionHostReset(() => registered = false);
|
|
1244
|
+
function registerCompatBootExtensions(config) {
|
|
1245
|
+
if (registered)
|
|
1246
|
+
return;
|
|
1247
|
+
registered = true;
|
|
1248
|
+
setCompatModeExtensions({
|
|
1249
|
+
nextEnabled: nextCompatEnabled,
|
|
1250
|
+
reactEnabled: reactCompatEnabled,
|
|
1251
|
+
reactCompilerOptions
|
|
1252
|
+
});
|
|
1253
|
+
setImportAliasExtensions({
|
|
1254
|
+
aliases: compatAliases,
|
|
1255
|
+
clientSsrAliases: (cfg) => nextCompatAliases(cfg, "server"),
|
|
1256
|
+
missingImportError: missingCompatImportError,
|
|
1257
|
+
reactServerLayerAliases
|
|
1258
|
+
});
|
|
1259
|
+
setModuleAliases(compatAliases(config, "server"));
|
|
1260
|
+
registerRoutingExtensions(config);
|
|
1261
|
+
registerLifecycleBootHooks(config);
|
|
1262
|
+
if (!nextCompatEnabled(config))
|
|
1263
|
+
return;
|
|
1264
|
+
registerCompatPageExtensions();
|
|
1265
|
+
setBundlerExtensions({ resolveRouteDependency: resolveTranspiledRouteDependency() });
|
|
1266
|
+
materializeNextCssSources(config);
|
|
1267
|
+
setCssExtensions({
|
|
1268
|
+
extraCssExtensions: () => [".scss", ".sass"],
|
|
1269
|
+
resolveCssDependency: nextCssResolveDependency(config)
|
|
1270
|
+
});
|
|
1271
|
+
setProxyExtensions({ names: NEXT_PROXY_NAMES, validateFiles: validateProxyFiles });
|
|
1272
|
+
}
|
|
1273
|
+
function registerCompatPageExtensions() {
|
|
1274
|
+
const configured = getNextConfig().pageExtensions;
|
|
1275
|
+
if (Array.isArray(configured)) {
|
|
1276
|
+
const extras = configured.filter((ext) => typeof ext === "string" && ext.length > 0 && !CORE_BASE_PAGE_EXTENSIONS.has(ext));
|
|
1277
|
+
if (extras.length > 0)
|
|
1278
|
+
registerPageExtensions(...extras);
|
|
1279
|
+
}
|
|
1280
|
+
registerLoadableExtensions("mdx", "md");
|
|
1281
|
+
}
|
|
1282
|
+
function resolveTranspiledRouteDependency() {
|
|
1283
|
+
const transpile = new Set(transpilePackages());
|
|
1284
|
+
return (root, fromFile, specifier) => {
|
|
1285
|
+
const packageName = packageNameOfSpecifier(specifier);
|
|
1286
|
+
if (!packageName || !transpile.has(packageName))
|
|
1287
|
+
return;
|
|
1288
|
+
return resolvePackageSpecifier(root, fromFile, specifier, ["import", "browser", "default"]);
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
async function validateProxyFiles(config) {
|
|
1292
|
+
if (findProxyFiles(config, NEXT_PROXY_NAMES).length === 0)
|
|
1293
|
+
return;
|
|
1294
|
+
const { registerProxyExtensions } = await import("./proxy-w1d0wmsn.js");
|
|
1295
|
+
registerProxyExtensions(config);
|
|
1296
|
+
await getProxyExtensions().validateFiles(config);
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
export { nextCssModuleChunkPlugin, nextCssResolveModule, nextCssLoadModuleForClient, nextCssSource, instrumentationReady, instrumentationLookupRoots, reportActionErrorToUser, registerLifecycleExtensions, registerCompatBootExtensions };
|