@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,44 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
BUILD_INDEX_VERSION,
|
|
4
|
+
attachRelease,
|
|
5
|
+
buildIndexFile,
|
|
6
|
+
captureConventions,
|
|
7
|
+
conventionFileExists,
|
|
8
|
+
frozenDirListing,
|
|
9
|
+
locateRelease,
|
|
10
|
+
productionRelease,
|
|
11
|
+
readBuildIndex,
|
|
12
|
+
releaseConfig,
|
|
13
|
+
releaseModuleHref,
|
|
14
|
+
releaseModuleKey,
|
|
15
|
+
releaseSourceFile,
|
|
16
|
+
releaseSourceKey,
|
|
17
|
+
serializeReleaseConfig,
|
|
18
|
+
servedAppFiles,
|
|
19
|
+
servedConventions,
|
|
20
|
+
servedRelease,
|
|
21
|
+
writeBuildIndex
|
|
22
|
+
} from "./index-tqn2qnnn.js";
|
|
23
|
+
import"./index-rt9qq1va.js";
|
|
24
|
+
export {
|
|
25
|
+
BUILD_INDEX_VERSION,
|
|
26
|
+
attachRelease,
|
|
27
|
+
buildIndexFile,
|
|
28
|
+
captureConventions,
|
|
29
|
+
conventionFileExists,
|
|
30
|
+
frozenDirListing,
|
|
31
|
+
locateRelease,
|
|
32
|
+
productionRelease,
|
|
33
|
+
readBuildIndex,
|
|
34
|
+
releaseConfig,
|
|
35
|
+
releaseModuleHref,
|
|
36
|
+
releaseModuleKey,
|
|
37
|
+
releaseSourceFile,
|
|
38
|
+
releaseSourceKey,
|
|
39
|
+
serializeReleaseConfig,
|
|
40
|
+
servedAppFiles,
|
|
41
|
+
servedConventions,
|
|
42
|
+
servedRelease,
|
|
43
|
+
writeBuildIndex
|
|
44
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
releasedProxy,
|
|
4
|
+
staticProxyConfig
|
|
5
|
+
} from "./index-tvqkq6e6.js";
|
|
6
|
+
import"./index-kq8kpzye.js";
|
|
7
|
+
import"./index-3xbr4eyv.js";
|
|
8
|
+
import"./index-x93hv0sc.js";
|
|
9
|
+
import"./index-tqn2qnnn.js";
|
|
10
|
+
import"./index-grta8ap3.js";
|
|
11
|
+
import"./index-kresp2n8.js";
|
|
12
|
+
import"./index-e3a6yx84.js";
|
|
13
|
+
import"./index-7wc9n8be.js";
|
|
14
|
+
import"./index-pym1cezq.js";
|
|
15
|
+
import"./index-zqpqyg8p.js";
|
|
16
|
+
import"./index-qjj6gddn.js";
|
|
17
|
+
import"./index-rt9qq1va.js";
|
|
18
|
+
export {
|
|
19
|
+
releasedProxy,
|
|
20
|
+
staticProxyConfig
|
|
21
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
registerProxyExtensions
|
|
4
|
+
} from "./index-sv8m6789.js";
|
|
5
|
+
import"./index-2wfv4kvx.js";
|
|
6
|
+
import"./index-eeaanp2e.js";
|
|
7
|
+
import"./index-kq8kpzye.js";
|
|
8
|
+
import"./index-3xbr4eyv.js";
|
|
9
|
+
import"./index-6q7zvrap.js";
|
|
10
|
+
import"./index-6e4fqv30.js";
|
|
11
|
+
import"./index-cjgqs13g.js";
|
|
12
|
+
import"./index-jks0x0a1.js";
|
|
13
|
+
import"./index-6b009mt0.js";
|
|
14
|
+
import"./index-4zzebszd.js";
|
|
15
|
+
import"./index-sq3kvz3g.js";
|
|
16
|
+
import"./index-ckkdpht5.js";
|
|
17
|
+
import"./index-20ppawv7.js";
|
|
18
|
+
import"./index-x93hv0sc.js";
|
|
19
|
+
import"./index-tqn2qnnn.js";
|
|
20
|
+
import"./index-en7n9f7m.js";
|
|
21
|
+
import"./index-grta8ap3.js";
|
|
22
|
+
import"./index-kresp2n8.js";
|
|
23
|
+
import"./index-e3a6yx84.js";
|
|
24
|
+
import"./index-z4z9zv3b.js";
|
|
25
|
+
import"./index-yz54pxrh.js";
|
|
26
|
+
import"./index-7wc9n8be.js";
|
|
27
|
+
import"./index-pym1cezq.js";
|
|
28
|
+
import"./index-zqpqyg8p.js";
|
|
29
|
+
import"./index-qjj6gddn.js";
|
|
30
|
+
import"./index-rt9qq1va.js";
|
|
31
|
+
export {
|
|
32
|
+
registerProxyExtensions
|
|
33
|
+
};
|
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import { join as __pnextJoin } from "node:path";
|
|
3
|
+
const __PNEXT_PACKAGE_ROOT__ = __pnextJoin(import.meta.dirname, "../../..");
|
|
4
|
+
import {
|
|
5
|
+
hasUseClientDirective
|
|
6
|
+
} from "./index-rn8dyr1f.js";
|
|
7
|
+
import {
|
|
8
|
+
getNextConfig
|
|
9
|
+
} from "./index-6e4fqv30.js";
|
|
10
|
+
import"./index-cjgqs13g.js";
|
|
11
|
+
import"./index-jks0x0a1.js";
|
|
12
|
+
import"./index-6b009mt0.js";
|
|
13
|
+
import"./index-4zzebszd.js";
|
|
14
|
+
import"./index-sq3kvz3g.js";
|
|
15
|
+
import"./index-ckkdpht5.js";
|
|
16
|
+
import {
|
|
17
|
+
listFiles,
|
|
18
|
+
listFilesSync,
|
|
19
|
+
toPosixPath
|
|
20
|
+
} from "./index-20ppawv7.js";
|
|
21
|
+
import"./index-x93hv0sc.js";
|
|
22
|
+
import"./index-tqn2qnnn.js";
|
|
23
|
+
import"./index-ras0sdab.js";
|
|
24
|
+
import"./index-grta8ap3.js";
|
|
25
|
+
import"./index-kresp2n8.js";
|
|
26
|
+
import"./index-e3a6yx84.js";
|
|
27
|
+
import"./index-z4z9zv3b.js";
|
|
28
|
+
import"./index-yz54pxrh.js";
|
|
29
|
+
import"./index-7wc9n8be.js";
|
|
30
|
+
import"./index-pym1cezq.js";
|
|
31
|
+
import"./index-zqpqyg8p.js";
|
|
32
|
+
import"./index-qjj6gddn.js";
|
|
33
|
+
import"./index-rt9qq1va.js";
|
|
34
|
+
|
|
35
|
+
// src/compat/pages/router.ts
|
|
36
|
+
import { createHash } from "crypto";
|
|
37
|
+
import { existsSync, statSync } from "fs";
|
|
38
|
+
import {
|
|
39
|
+
copyFile,
|
|
40
|
+
mkdir,
|
|
41
|
+
readdir,
|
|
42
|
+
readFile,
|
|
43
|
+
rename,
|
|
44
|
+
rm,
|
|
45
|
+
symlink,
|
|
46
|
+
writeFile
|
|
47
|
+
} from "fs/promises";
|
|
48
|
+
import path from "path";
|
|
49
|
+
import { tmpdir } from "os";
|
|
50
|
+
import { fileURLToPath } from "url";
|
|
51
|
+
var basePageExtensions = ["tsx", "ts", "jsx", "js", "mjs"];
|
|
52
|
+
function materializeExtensions() {
|
|
53
|
+
const configured = getNextConfig().pageExtensions;
|
|
54
|
+
const extras = Array.isArray(configured) ? configured.filter((ext) => typeof ext === "string" && ext.length > 0) : [];
|
|
55
|
+
return [...new Set([...basePageExtensions, ...extras])];
|
|
56
|
+
}
|
|
57
|
+
var appConventions = new Set([
|
|
58
|
+
"default",
|
|
59
|
+
"error",
|
|
60
|
+
"forbidden",
|
|
61
|
+
"global-error",
|
|
62
|
+
"layout",
|
|
63
|
+
"loading",
|
|
64
|
+
"not-found",
|
|
65
|
+
"page",
|
|
66
|
+
"route",
|
|
67
|
+
"template",
|
|
68
|
+
"unauthorized"
|
|
69
|
+
]);
|
|
70
|
+
var metadataConventionPattern = /^(robots|sitemap|manifest|icon\d*|apple-icon\d*|opengraph-image\d*|twitter-image\d*)$/;
|
|
71
|
+
function isAppConvention(name) {
|
|
72
|
+
return appConventions.has(name) || metadataConventionPattern.test(name);
|
|
73
|
+
}
|
|
74
|
+
async function materializePagesApp(root, base = path.join(tmpdir(), "pnext-pages-compat")) {
|
|
75
|
+
const pagesPath = path.join(root, "pages");
|
|
76
|
+
if (!existsSync(pagesPath))
|
|
77
|
+
return;
|
|
78
|
+
const nativeApp = path.join(root, "app");
|
|
79
|
+
const pages = await discoverPages(pagesPath);
|
|
80
|
+
const apiRoutes = await discoverPagesApi(pagesPath);
|
|
81
|
+
if (pages.length === 0 && apiRoutes.length === 0)
|
|
82
|
+
return;
|
|
83
|
+
const generatedRoot = path.join(base, materializationKey(root, nativeApp, pages, apiRoutes));
|
|
84
|
+
const appPath = path.join(generatedRoot, "app");
|
|
85
|
+
if (existsSync(appPath))
|
|
86
|
+
return appPath;
|
|
87
|
+
const staging = `${generatedRoot}.${process.pid.toString(36)}.staging`;
|
|
88
|
+
await buildMaterializedApp(staging, root, pagesPath, nativeApp, pages, apiRoutes);
|
|
89
|
+
try {
|
|
90
|
+
await rename(staging, generatedRoot);
|
|
91
|
+
} catch {
|
|
92
|
+
await rm(staging, { recursive: true, force: true });
|
|
93
|
+
if (!existsSync(appPath))
|
|
94
|
+
throw new Error(`pnext: could not materialize ${root}/pages`);
|
|
95
|
+
}
|
|
96
|
+
sweepStaleMaterializations(base, isInsideApp(root, generatedRoot) ? path.basename(generatedRoot) : undefined);
|
|
97
|
+
return appPath;
|
|
98
|
+
}
|
|
99
|
+
var isInsideApp = (root, dir) => !path.relative(root, dir).startsWith("..");
|
|
100
|
+
function materializedLinkTarget(root, generatedRoot, target) {
|
|
101
|
+
return isInsideApp(root, generatedRoot) ? path.relative(generatedRoot, target) : target;
|
|
102
|
+
}
|
|
103
|
+
function materializationKey(root, nativeApp, pages, apiRoutes) {
|
|
104
|
+
const stamp = (file) => {
|
|
105
|
+
const info = statSync(file, { throwIfNoEntry: false });
|
|
106
|
+
return info ? `${info.size}:${info.mtimeMs}` : "";
|
|
107
|
+
};
|
|
108
|
+
const nativeFiles = existsSync(nativeApp) ? listFilesSync(nativeApp).map((file) => `${toPosixPath(path.relative(nativeApp, file))}\x00${stamp(file)}`).sort() : [];
|
|
109
|
+
const byRelative = (routes) => [...routes].sort((a, b) => a.relative.localeCompare(b.relative));
|
|
110
|
+
return createHash("sha256").update(JSON.stringify([
|
|
111
|
+
root,
|
|
112
|
+
materializeExtensions(),
|
|
113
|
+
byRelative(pages),
|
|
114
|
+
byRelative(apiRoutes),
|
|
115
|
+
nativeFiles,
|
|
116
|
+
stamp(fileURLToPath(Bun.pathToFileURL(__PNEXT_PACKAGE_ROOT__ + "/src/compat/pages/router.ts").href))
|
|
117
|
+
])).digest("hex").slice(0, 16);
|
|
118
|
+
}
|
|
119
|
+
var STALE_MATERIALIZATION_MS = 7 * 24 * 60 * 60000;
|
|
120
|
+
async function sweepStaleMaterializations(base, current) {
|
|
121
|
+
try {
|
|
122
|
+
const cutoff = current ? Infinity : Date.now() - STALE_MATERIALIZATION_MS;
|
|
123
|
+
for (const entry of await readdir(base)) {
|
|
124
|
+
if (current && (entry === current || entry.endsWith(".staging")))
|
|
125
|
+
continue;
|
|
126
|
+
const dir = path.join(base, entry);
|
|
127
|
+
const info = statSync(dir, { throwIfNoEntry: false });
|
|
128
|
+
if (info && info.mtimeMs < cutoff)
|
|
129
|
+
await rm(dir, { recursive: true, force: true });
|
|
130
|
+
}
|
|
131
|
+
} catch {}
|
|
132
|
+
}
|
|
133
|
+
async function buildMaterializedApp(generatedRoot, root, pagesPath, nativeApp, pages, apiRoutes) {
|
|
134
|
+
const appPath = path.join(generatedRoot, "app");
|
|
135
|
+
const sourcePages = path.join(generatedRoot, "source-pages");
|
|
136
|
+
const sourceApp = path.join(generatedRoot, "source-app");
|
|
137
|
+
const link = (target, at) => symlink(materializedLinkTarget(root, generatedRoot, target), at, "dir");
|
|
138
|
+
await rm(generatedRoot, { recursive: true, force: true });
|
|
139
|
+
await mkdir(appPath, { recursive: true });
|
|
140
|
+
await link(pagesPath, sourcePages);
|
|
141
|
+
const nodeModules = path.join(root, "node_modules");
|
|
142
|
+
if (existsSync(nodeModules) && !isInsideApp(root, generatedRoot)) {
|
|
143
|
+
await link(nodeModules, path.join(generatedRoot, "node_modules"));
|
|
144
|
+
}
|
|
145
|
+
const publicDir = path.join(root, "public");
|
|
146
|
+
if (existsSync(publicDir))
|
|
147
|
+
await link(publicDir, path.join(generatedRoot, "public"));
|
|
148
|
+
if (existsSync(nativeApp)) {
|
|
149
|
+
await link(nativeApp, sourceApp);
|
|
150
|
+
await materializeNativeApp(sourceApp, appPath);
|
|
151
|
+
}
|
|
152
|
+
if (!existsSync(path.join(appPath, "layout.js"))) {
|
|
153
|
+
await writeFile(path.join(appPath, "layout.js"), `export default function PagesLayout({ children }) {
|
|
154
|
+
return <html><body>{children}</body></html>
|
|
155
|
+
}
|
|
156
|
+
`);
|
|
157
|
+
}
|
|
158
|
+
for (const page of pages) {
|
|
159
|
+
const destination = path.join(appPath, ...encodePrivateSegments(page.segments), "page.js");
|
|
160
|
+
if (existsSync(destination))
|
|
161
|
+
continue;
|
|
162
|
+
await mkdir(path.dirname(destination), { recursive: true });
|
|
163
|
+
const pagesPattern = `/${page.segments.join("/")}`.replace(/\/+$/, "") || "/";
|
|
164
|
+
const sourceSpecifier = relativeImport(destination, path.join(sourcePages, page.relative));
|
|
165
|
+
let clientSpecifier;
|
|
166
|
+
if (page.hasStaticProps || page.hasServerSideProps) {
|
|
167
|
+
const clientDestination = path.join(path.dirname(destination), "pnext-page-client.js");
|
|
168
|
+
await writeFile(clientDestination, `'use client';
|
|
169
|
+
export { default } from ${JSON.stringify(sourceSpecifier)};
|
|
170
|
+
`);
|
|
171
|
+
clientSpecifier = "./pnext-page-client.js";
|
|
172
|
+
}
|
|
173
|
+
await writeFile(destination, wrapperSource(sourceSpecifier, !page.hasServerSideProps && !page.hasStaticProps, page.hasServerSideProps, page.hasStaticProps, clientSpecifier, page.runtime, page.maxDuration, pagesPattern));
|
|
174
|
+
}
|
|
175
|
+
for (const apiRoute of apiRoutes) {
|
|
176
|
+
const destination = path.join(appPath, "api", ...apiRoute.segments, "route.js");
|
|
177
|
+
if (existsSync(destination))
|
|
178
|
+
continue;
|
|
179
|
+
await mkdir(path.dirname(destination), { recursive: true });
|
|
180
|
+
await writeFile(destination, pagesApiWrapperSource(relativeImport(destination, path.join(sourcePages, apiRoute.relative)), apiRoute.runtime));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async function materializeNativeApp(sourceApp, appPath) {
|
|
184
|
+
for (const file of await listFiles(sourceApp)) {
|
|
185
|
+
const relative = toPosixPath(path.relative(sourceApp, file));
|
|
186
|
+
const parsed = path.parse(relative);
|
|
187
|
+
if (!materializeExtensions().includes(parsed.ext.slice(1))) {
|
|
188
|
+
const destination2 = path.join(appPath, relative);
|
|
189
|
+
await mkdir(path.dirname(destination2), { recursive: true });
|
|
190
|
+
await copyFile(file, destination2);
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
if (!isAppConvention(parsed.name))
|
|
194
|
+
continue;
|
|
195
|
+
const destination = path.join(appPath, parsed.dir, `${parsed.name}.js`);
|
|
196
|
+
await mkdir(path.dirname(destination), { recursive: true });
|
|
197
|
+
const source = await readFile(file, "utf8");
|
|
198
|
+
const client = hasUseClientDirective(source) || await defaultExportImportsClientModule(file, source);
|
|
199
|
+
await writeFile(destination, wrapperSource(relativeImport(destination, file), client, false, false, undefined, runtimeFromSource(source)));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
async function defaultExportImportsClientModule(file, source) {
|
|
203
|
+
const defaultExport = /export\s+default\s+([A-Za-z_$][\w$]*)\s*;?/.exec(source);
|
|
204
|
+
if (!defaultExport?.[1])
|
|
205
|
+
return false;
|
|
206
|
+
const binding = defaultExport[1];
|
|
207
|
+
const imports = /import\s*\{([^}]*)\}\s*from\s*['"]([^'"]+)['"]/g;
|
|
208
|
+
let match;
|
|
209
|
+
while (match = imports.exec(source)) {
|
|
210
|
+
const importsBinding = (match[1] ?? "").split(",").some((value) => {
|
|
211
|
+
const names = /^\s*([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?\s*$/.exec(value);
|
|
212
|
+
return (names?.[2] ?? names?.[1]) === binding;
|
|
213
|
+
});
|
|
214
|
+
if (!importsBinding || !match[2]?.startsWith("."))
|
|
215
|
+
continue;
|
|
216
|
+
const imported = resolveSourceImport(file, match[2]);
|
|
217
|
+
if (imported && hasUseClientDirective(await readFile(imported, "utf8")))
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
function resolveSourceImport(file, specifier) {
|
|
223
|
+
const base = path.resolve(path.dirname(file), specifier);
|
|
224
|
+
for (const candidate of [
|
|
225
|
+
base,
|
|
226
|
+
...materializeExtensions().flatMap((extension) => [
|
|
227
|
+
`${base}.${extension}`,
|
|
228
|
+
path.join(base, `index.${extension}`)
|
|
229
|
+
])
|
|
230
|
+
]) {
|
|
231
|
+
if (existsSync(candidate) && statSync(candidate).isFile())
|
|
232
|
+
return candidate;
|
|
233
|
+
}
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
function encodePrivateSegments(segments) {
|
|
237
|
+
return segments.map((segment) => segment.startsWith("_") ? `%5F${segment.slice(1)}` : segment);
|
|
238
|
+
}
|
|
239
|
+
async function discoverPages(pagesPath) {
|
|
240
|
+
const routes = new Map;
|
|
241
|
+
const files = await listFiles(pagesPath);
|
|
242
|
+
for (const extension of materializeExtensions()) {
|
|
243
|
+
for (const file of files) {
|
|
244
|
+
if (!file.endsWith(`.${extension}`))
|
|
245
|
+
continue;
|
|
246
|
+
const relative = toPosixPath(path.relative(pagesPath, file));
|
|
247
|
+
const withoutExtension = relative.slice(0, -extension.length - 1);
|
|
248
|
+
const sourceSegments = withoutExtension.split("/");
|
|
249
|
+
if (sourceSegments[0] === "api")
|
|
250
|
+
continue;
|
|
251
|
+
if (sourceSegments.length === 1 && (sourceSegments[0] === "_app" || sourceSegments[0] === "_document" || sourceSegments[0] === "_error")) {
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
const segments = sourceSegments.at(-1) === "index" ? sourceSegments.slice(0, -1) : sourceSegments;
|
|
255
|
+
const key = segments.join("/");
|
|
256
|
+
if (!routes.has(key)) {
|
|
257
|
+
const source = await readFile(file, "utf8");
|
|
258
|
+
routes.set(key, {
|
|
259
|
+
relative,
|
|
260
|
+
segments,
|
|
261
|
+
hasServerSideProps: /\bgetServerSideProps\b/.test(source),
|
|
262
|
+
hasStaticProps: /\bgetStaticProps\b/.test(source),
|
|
263
|
+
runtime: runtimeFromSource(source),
|
|
264
|
+
maxDuration: maxDurationFromSource(source)
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return [...routes.values()];
|
|
270
|
+
}
|
|
271
|
+
async function discoverPagesApi(pagesPath) {
|
|
272
|
+
const routes = new Map;
|
|
273
|
+
const files = await listFiles(path.join(pagesPath, "api"));
|
|
274
|
+
for (const extension of materializeExtensions()) {
|
|
275
|
+
for (const file of files) {
|
|
276
|
+
if (!file.endsWith(`.${extension}`))
|
|
277
|
+
continue;
|
|
278
|
+
const relative = toPosixPath(path.relative(pagesPath, file));
|
|
279
|
+
const segments = relative.slice(0, -extension.length - 1).split("/").slice(1);
|
|
280
|
+
if (segments.some((segment) => segment.startsWith("_")))
|
|
281
|
+
continue;
|
|
282
|
+
const key = segments.join("/");
|
|
283
|
+
if (routes.has(key))
|
|
284
|
+
continue;
|
|
285
|
+
routes.set(key, {
|
|
286
|
+
relative,
|
|
287
|
+
segments,
|
|
288
|
+
runtime: runtimeFromSource(await readFile(file, "utf8"))
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return [...routes.values()];
|
|
293
|
+
}
|
|
294
|
+
function routerStateModulePath() {
|
|
295
|
+
return path.join(__PNEXT_PACKAGE_ROOT__ + "/src/compat/pages", "router-state.ts");
|
|
296
|
+
}
|
|
297
|
+
function routerStateSnippet(pagesPattern) {
|
|
298
|
+
if (!pagesPattern) {
|
|
299
|
+
return { imports: "", render: "return createElement(Page, result?.props ?? {});" };
|
|
300
|
+
}
|
|
301
|
+
return {
|
|
302
|
+
imports: `import { pagesRouterSsrState, serializePagesRouterState } from ${JSON.stringify(routerStateModulePath())};
|
|
303
|
+
`,
|
|
304
|
+
render: `const routerState = pagesRouterSsrState(${JSON.stringify(pagesPattern)}, resolvedParams);
|
|
305
|
+
return createElement(
|
|
306
|
+
Fragment,
|
|
307
|
+
null,
|
|
308
|
+
createElement('script', {
|
|
309
|
+
type: 'application/json',
|
|
310
|
+
id: '__PNEXT_PAGES_DATA__',
|
|
311
|
+
dangerouslySetInnerHTML: { __html: serializePagesRouterState(routerState) },
|
|
312
|
+
}),
|
|
313
|
+
createElement(Page, result?.props ?? {}),
|
|
314
|
+
);`
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function wrapperSource(specifier, client = false, hasServerSideProps = false, hasStaticProps = false, clientSpecifier, runtime, maxDuration, pagesPattern) {
|
|
318
|
+
const runtimeExport = runtime ? `export const runtime = ${JSON.stringify(runtime)};
|
|
319
|
+
` : "";
|
|
320
|
+
const maxDurationExport = maxDuration === undefined ? "" : `export const maxDuration = ${maxDuration};
|
|
321
|
+
`;
|
|
322
|
+
const routerState = routerStateSnippet(pagesPattern);
|
|
323
|
+
if (hasStaticProps && clientSpecifier) {
|
|
324
|
+
return `import { createElement, Fragment } from 'react';
|
|
325
|
+
import { notFound, redirect } from 'next/navigation';
|
|
326
|
+
import Page from ${JSON.stringify(clientSpecifier)};
|
|
327
|
+
import * as pageModule from ${JSON.stringify(specifier)};
|
|
328
|
+
${routerState.imports}export * from ${JSON.stringify(specifier)};
|
|
329
|
+
${runtimeExport}${maxDurationExport}export default async function PagesCompatStaticPage({ params }) {
|
|
330
|
+
// The otel compat exposes a span wrapper (Render.getStaticProps) at runtime.
|
|
331
|
+
const withSpan = globalThis.__PNEXT_PAGES_DATA_SPAN__ ?? ((kind, fn) => fn());
|
|
332
|
+
const resolvedParams = await params;
|
|
333
|
+
const invoke = async () => pageModule.getStaticProps?.({ params: resolvedParams });
|
|
334
|
+
const result = await withSpan('getStaticProps', invoke);
|
|
335
|
+
if (result?.notFound) notFound();
|
|
336
|
+
if (result?.redirect) redirect(result.redirect.destination);
|
|
337
|
+
${routerState.render}
|
|
338
|
+
}
|
|
339
|
+
`;
|
|
340
|
+
}
|
|
341
|
+
if (!hasServerSideProps) {
|
|
342
|
+
if (client) {
|
|
343
|
+
return `'use client';
|
|
344
|
+
export { default } from ${JSON.stringify(specifier)};
|
|
345
|
+
${runtimeExport}${maxDurationExport}`;
|
|
346
|
+
}
|
|
347
|
+
return `import * as __pnext_page_ns from ${JSON.stringify(specifier)};
|
|
348
|
+
export default __pnext_page_ns.default;
|
|
349
|
+
export * from ${JSON.stringify(specifier)};
|
|
350
|
+
${runtimeExport}${maxDurationExport}`;
|
|
351
|
+
}
|
|
352
|
+
return `import { createElement, Fragment } from 'react';
|
|
353
|
+
import { notFound, redirect } from 'next/navigation';
|
|
354
|
+
import { cookies, headers } from 'next/headers';
|
|
355
|
+
import Page from ${JSON.stringify(clientSpecifier)};
|
|
356
|
+
import * as pageModule from ${JSON.stringify(specifier)};
|
|
357
|
+
${routerState.imports}export * from ${JSON.stringify(specifier)};
|
|
358
|
+
export const dynamic = 'force-dynamic';
|
|
359
|
+
${runtimeExport}${maxDurationExport}export default async function PagesCompatPage({ params, searchParams }) {
|
|
360
|
+
// The otel compat exposes a span wrapper (Render.getServerSideProps) at runtime.
|
|
361
|
+
const withSpan = globalThis.__PNEXT_PAGES_DATA_SPAN__ ?? ((kind, fn) => fn());
|
|
362
|
+
const resolvedParams = await params;
|
|
363
|
+
// getServerSideProps reads a node-shaped \`req\`/\`res\`. This page is
|
|
364
|
+
// force-dynamic, so headers()/cookies() are available; \`method\` is always
|
|
365
|
+
// 'GET' and \`res\` is inert (writes are dropped) \u2014 a workable baseline until
|
|
366
|
+
// the pages layer threads the real request through.
|
|
367
|
+
const requestHeaders = Object.fromEntries((await headers()).entries());
|
|
368
|
+
const requestCookies = Object.fromEntries(
|
|
369
|
+
(await cookies()).getAll().map(cookie => [cookie.name, cookie.value]),
|
|
370
|
+
);
|
|
371
|
+
const invoke = async () => pageModule.getServerSideProps?.({
|
|
372
|
+
params: resolvedParams,
|
|
373
|
+
query: (await searchParams) ?? {},
|
|
374
|
+
req: {
|
|
375
|
+
headers: requestHeaders,
|
|
376
|
+
cookies: requestCookies,
|
|
377
|
+
method: 'GET',
|
|
378
|
+
url: ${JSON.stringify(pagesPattern ?? "/")},
|
|
379
|
+
},
|
|
380
|
+
res: {
|
|
381
|
+
statusCode: 200,
|
|
382
|
+
setHeader() {},
|
|
383
|
+
getHeader() {},
|
|
384
|
+
getHeaders() { return {}; },
|
|
385
|
+
removeHeader() {},
|
|
386
|
+
end() {},
|
|
387
|
+
write() { return true; },
|
|
388
|
+
},
|
|
389
|
+
resolvedUrl: ${JSON.stringify(pagesPattern ?? "/")},
|
|
390
|
+
preview: false,
|
|
391
|
+
previewData: undefined,
|
|
392
|
+
draftMode: false,
|
|
393
|
+
});
|
|
394
|
+
const result = await withSpan('getServerSideProps', invoke);
|
|
395
|
+
if (result?.notFound) notFound();
|
|
396
|
+
if (result?.redirect) redirect(result.redirect.destination);
|
|
397
|
+
${routerState.render}
|
|
398
|
+
}
|
|
399
|
+
`;
|
|
400
|
+
}
|
|
401
|
+
function runtimeFromSource(source) {
|
|
402
|
+
const runtime = /\bruntime\b\s*[:=]\s*(['"`])(edge|nodejs|experimental-edge)\1/.exec(source)?.[2];
|
|
403
|
+
return runtime === "experimental-edge" ? "edge" : runtime;
|
|
404
|
+
}
|
|
405
|
+
function maxDurationFromSource(source) {
|
|
406
|
+
const value = /\bmaxDuration\s*:\s*(\d+)\b/.exec(source)?.[1];
|
|
407
|
+
return value === undefined ? undefined : Number(value);
|
|
408
|
+
}
|
|
409
|
+
function pagesApiWrapperSource(specifier, runtime) {
|
|
410
|
+
const runtimeExport = runtime ? `export const runtime = ${JSON.stringify(runtime)};
|
|
411
|
+
` : "";
|
|
412
|
+
return `import handler from ${JSON.stringify(specifier)};
|
|
413
|
+
import { NextRequest } from 'next/server';
|
|
414
|
+
import { Writable } from 'node:stream';
|
|
415
|
+
${runtimeExport}export async function GET(request) {
|
|
416
|
+
return run(handler, request);
|
|
417
|
+
}
|
|
418
|
+
export async function POST(request) {
|
|
419
|
+
return run(handler, request);
|
|
420
|
+
}
|
|
421
|
+
export async function PUT(request) {
|
|
422
|
+
return run(handler, request);
|
|
423
|
+
}
|
|
424
|
+
export async function PATCH(request) {
|
|
425
|
+
return run(handler, request);
|
|
426
|
+
}
|
|
427
|
+
export async function DELETE(request) {
|
|
428
|
+
return run(handler, request);
|
|
429
|
+
}
|
|
430
|
+
// Bridge a pages-API handler onto the app-route Response contract. Edge-style
|
|
431
|
+
// handlers (request-only, return a Response) pass through; node-style handlers
|
|
432
|
+
// get a real Writable \`res\` whose bytes stream into the Response body, with
|
|
433
|
+
// client disconnects surfaced as res 'close'/destroy (stream cancellation).
|
|
434
|
+
async function run(handler, request) {
|
|
435
|
+
const nextRequest = request instanceof NextRequest ? request : new NextRequest(request);
|
|
436
|
+
const state = { status: 200, headers: new Headers() };
|
|
437
|
+
let controller;
|
|
438
|
+
let started = false;
|
|
439
|
+
let notifyStarted = () => {};
|
|
440
|
+
const startedPromise = new Promise(resolve => { notifyStarted = resolve; });
|
|
441
|
+
const start = () => {
|
|
442
|
+
if (!started) {
|
|
443
|
+
started = true;
|
|
444
|
+
notifyStarted();
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
const body = new ReadableStream({
|
|
448
|
+
start(c) { controller = c; },
|
|
449
|
+
cancel() { res.destroy(); },
|
|
450
|
+
});
|
|
451
|
+
const enqueue = chunk => {
|
|
452
|
+
try {
|
|
453
|
+
controller.enqueue(typeof chunk === 'string' ? new TextEncoder().encode(chunk) : new Uint8Array(chunk));
|
|
454
|
+
} catch {}
|
|
455
|
+
};
|
|
456
|
+
const res = new Writable({
|
|
457
|
+
write(chunk, _encoding, callback) { start(); enqueue(chunk); callback(); },
|
|
458
|
+
final(callback) { start(); try { controller.close(); } catch {} callback(); },
|
|
459
|
+
destroy(error, callback) { try { controller.close(); } catch {} callback(error); },
|
|
460
|
+
});
|
|
461
|
+
Object.defineProperty(res, 'statusCode', {
|
|
462
|
+
get: () => state.status,
|
|
463
|
+
set: value => { state.status = value; },
|
|
464
|
+
});
|
|
465
|
+
res.setHeader = (name, value) => { state.headers.set(name, String(value)); return res; };
|
|
466
|
+
res.getHeader = name => state.headers.get(name) ?? undefined;
|
|
467
|
+
res.removeHeader = name => { state.headers.delete(name); };
|
|
468
|
+
res.status = code => { state.status = code; return res; };
|
|
469
|
+
res.json = value => { state.headers.set('content-type', 'application/json'); res.end(JSON.stringify(value)); };
|
|
470
|
+
res.send = value => { res.end(value); };
|
|
471
|
+
// A client disconnect aborts the request signal; pages handlers observe it
|
|
472
|
+
// as the response closing (res.on('close') per Node semantics).
|
|
473
|
+
request.signal?.addEventListener?.('abort', () => res.destroy(), { once: true });
|
|
474
|
+
const finished = Promise.resolve()
|
|
475
|
+
.then(() => handler(nextRequest, res))
|
|
476
|
+
.catch(error => {
|
|
477
|
+
if (!started) throw error;
|
|
478
|
+
try { controller.error(error); } catch {}
|
|
479
|
+
});
|
|
480
|
+
const outcome = await Promise.race([
|
|
481
|
+
startedPromise.then(() => 'started'),
|
|
482
|
+
finished.then(() => 'done'),
|
|
483
|
+
]);
|
|
484
|
+
if (outcome === 'done' && !started) {
|
|
485
|
+
const result = await finished;
|
|
486
|
+
return result instanceof Response ? result : new Response(null, { status: state.status, headers: state.headers });
|
|
487
|
+
}
|
|
488
|
+
return new Response(body, { status: state.status, headers: state.headers });
|
|
489
|
+
}
|
|
490
|
+
`;
|
|
491
|
+
}
|
|
492
|
+
function relativeImport(fromFile, targetFile) {
|
|
493
|
+
const relative = toPosixPath(path.relative(path.dirname(fromFile), targetFile));
|
|
494
|
+
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
495
|
+
}
|
|
496
|
+
export {
|
|
497
|
+
materializePagesApp
|
|
498
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
addClientEntryReason,
|
|
4
|
+
assertNoServerActionsWithoutCompat,
|
|
5
|
+
collectFileCss,
|
|
6
|
+
collectNotFoundCss,
|
|
7
|
+
materializeRouteFacts,
|
|
8
|
+
materializeRouteFactsPaced,
|
|
9
|
+
routeFactsResolved,
|
|
10
|
+
routeFactsVersion,
|
|
11
|
+
scanRoutes,
|
|
12
|
+
setRouteFactsStore
|
|
13
|
+
} from "./index-8k7pfejn.js";
|
|
14
|
+
import"./index-91x12ykq.js";
|
|
15
|
+
import {
|
|
16
|
+
findConventionFiles,
|
|
17
|
+
findGlobalError,
|
|
18
|
+
findLayouts,
|
|
19
|
+
matchInterception,
|
|
20
|
+
matchRoute,
|
|
21
|
+
normalizePathname,
|
|
22
|
+
parseNavState,
|
|
23
|
+
selectRouteForRequest,
|
|
24
|
+
serverActionsUnsupportedMessage
|
|
25
|
+
} from "./index-jepjvcrf.js";
|
|
26
|
+
import"./index-2dv4y4wd.js";
|
|
27
|
+
import"./index-73z4esab.js";
|
|
28
|
+
import"./index-y2jr2n72.js";
|
|
29
|
+
import"./index-web361b8.js";
|
|
30
|
+
import"./index-fp8r0sqs.js";
|
|
31
|
+
import"./index-cjgqs13g.js";
|
|
32
|
+
import"./index-p77b4kcx.js";
|
|
33
|
+
import"./index-20ppawv7.js";
|
|
34
|
+
import"./index-tqn2qnnn.js";
|
|
35
|
+
import"./index-6kp9r0d9.js";
|
|
36
|
+
import"./index-ras0sdab.js";
|
|
37
|
+
import"./index-z4z9zv3b.js";
|
|
38
|
+
import"./index-yz54pxrh.js";
|
|
39
|
+
import"./index-7wc9n8be.js";
|
|
40
|
+
import"./index-pym1cezq.js";
|
|
41
|
+
import"./index-zqpqyg8p.js";
|
|
42
|
+
import"./index-qjj6gddn.js";
|
|
43
|
+
import"./index-rt9qq1va.js";
|
|
44
|
+
export {
|
|
45
|
+
addClientEntryReason,
|
|
46
|
+
assertNoServerActionsWithoutCompat,
|
|
47
|
+
collectFileCss,
|
|
48
|
+
collectNotFoundCss,
|
|
49
|
+
findConventionFiles,
|
|
50
|
+
findGlobalError,
|
|
51
|
+
findLayouts,
|
|
52
|
+
matchInterception,
|
|
53
|
+
matchRoute,
|
|
54
|
+
materializeRouteFacts,
|
|
55
|
+
materializeRouteFactsPaced,
|
|
56
|
+
normalizePathname,
|
|
57
|
+
parseNavState,
|
|
58
|
+
routeFactsResolved,
|
|
59
|
+
routeFactsVersion,
|
|
60
|
+
scanRoutes,
|
|
61
|
+
selectRouteForRequest,
|
|
62
|
+
serverActionsUnsupportedMessage,
|
|
63
|
+
setRouteFactsStore
|
|
64
|
+
};
|