@wular/pnext 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/pnext +9 -2
- package/dist/server/_chunks/aliases-pycbtjt1.js +46 -0
- package/dist/server/_chunks/analyze-4d9e00g9.js +449 -0
- package/dist/server/_chunks/boot-bhemypxz.js +38 -0
- package/dist/server/_chunks/build-c991dv65.js +86 -0
- package/dist/server/_chunks/build-kh5e3x48.js +3341 -0
- package/dist/server/_chunks/build-tier-0a96kmx3.js +2456 -0
- package/dist/server/_chunks/compile-040r79gj.js +22 -0
- package/dist/server/_chunks/config-0tvz03a6.js +24 -0
- package/dist/server/_chunks/config-27rj7830.js +36 -0
- package/dist/server/_chunks/create-9rvwshsp.js +135 -0
- package/dist/server/_chunks/dev-ex9exynt.js +220 -0
- package/dist/server/_chunks/esbuild-yyktfrtt.js +15 -0
- package/dist/server/_chunks/generate-myw9hef7.js +22 -0
- package/dist/server/_chunks/index-0r5eqfc7.js +279 -0
- package/dist/server/_chunks/index-0yjv5v47.js +105 -0
- package/dist/server/_chunks/index-11xpbfej.js +17 -0
- package/dist/server/_chunks/index-141vcwk6.js +109 -0
- package/dist/server/_chunks/index-1pzm1hdy.js +4130 -0
- package/dist/server/_chunks/index-29pq0kax.js +590 -0
- package/dist/server/_chunks/index-2vz0wzdn.js +59 -0
- package/dist/server/_chunks/index-2wfv4kvx.js +182 -0
- package/dist/server/_chunks/index-38xpdxwd.js +194 -0
- package/dist/server/_chunks/index-3e075kny.js +128 -0
- package/dist/server/_chunks/index-3ycf5ckv.js +472 -0
- package/dist/server/_chunks/index-4399bvd2.js +18 -0
- package/dist/server/_chunks/index-4da76t62.js +297 -0
- package/dist/server/_chunks/index-4t92hdxd.js +172 -0
- package/dist/server/_chunks/index-4zzebszd.js +10 -0
- package/dist/server/_chunks/index-52k54ykj.js +95 -0
- package/dist/server/_chunks/index-5hr4062s.js +70 -0
- package/dist/server/_chunks/index-68m3mwbd.js +84 -0
- package/dist/server/_chunks/index-6b009mt0.js +56 -0
- package/dist/server/_chunks/index-6gex3pfa.js +15 -0
- package/dist/server/_chunks/index-6kp9r0d9.js +11 -0
- package/dist/server/_chunks/index-6q7zvrap.js +134 -0
- package/dist/server/_chunks/index-71885zaq.js +284 -0
- package/dist/server/_chunks/index-73z4esab.js +38 -0
- package/dist/server/_chunks/index-79ngvam8.js +60 -0
- package/dist/server/_chunks/index-7wc9n8be.js +25 -0
- package/dist/server/_chunks/index-8ct7rqy3.js +198 -0
- package/dist/server/_chunks/index-8kcxdfya.js +206 -0
- package/dist/server/_chunks/index-9ch50vtq.js +18 -0
- package/dist/server/_chunks/index-9f49w76j.js +213 -0
- package/dist/server/_chunks/index-9hz3s0m8.js +851 -0
- package/dist/server/_chunks/index-akkrvjn6.js +535 -0
- package/dist/server/_chunks/index-b6wtkdp4.js +24 -0
- package/dist/server/_chunks/index-b7j671dj.js +207 -0
- package/dist/server/_chunks/index-bcws5eh2.js +35 -0
- package/dist/server/_chunks/index-bzd2ef7t.js +10 -0
- package/dist/server/_chunks/index-cjgqs13g.js +65 -0
- package/dist/server/_chunks/index-ckkdpht5.js +41 -0
- package/dist/server/_chunks/index-cn86z041.js +296 -0
- package/dist/server/_chunks/index-cvr4z22m.js +92 -0
- package/dist/server/_chunks/index-cyfednwb.js +87 -0
- package/dist/server/_chunks/index-d158y67j.js +152 -0
- package/dist/server/_chunks/index-d1jsmhhk.js +955 -0
- package/dist/server/_chunks/index-dg0f05zs.js +199 -0
- package/dist/server/_chunks/index-dgr390q7.js +9438 -0
- package/dist/server/_chunks/index-drwv61cc.js +185 -0
- package/dist/server/_chunks/index-e3a6yx84.js +18 -0
- package/dist/server/_chunks/index-e88tyv35.js +45 -0
- package/dist/server/_chunks/index-en7n9f7m.js +22 -0
- package/dist/server/_chunks/index-entm8bmz.js +28 -0
- package/dist/server/_chunks/index-evhd413j.js +57 -0
- package/dist/server/_chunks/index-ezgj0tr1.js +88 -0
- package/dist/server/_chunks/index-fjv96re1.js +5295 -0
- package/dist/server/_chunks/index-fn1chkkd.js +214 -0
- package/dist/server/_chunks/index-fp8r0sqs.js +64 -0
- package/dist/server/_chunks/index-gcmj16xy.js +92 -0
- package/dist/server/_chunks/index-gkndxkxf.js +736 -0
- package/dist/server/_chunks/index-grta8ap3.js +238 -0
- package/dist/server/_chunks/index-h2a70tg4.js +7 -0
- package/dist/server/_chunks/index-h4xy648y.js +51 -0
- package/dist/server/_chunks/index-hdbwtdv2.js +352 -0
- package/dist/server/_chunks/index-he6n2bvp.js +1270 -0
- package/dist/server/_chunks/index-j0m1jxqa.js +1253 -0
- package/dist/server/_chunks/index-j2zrcp1k.js +66 -0
- package/dist/server/_chunks/index-j681c48a.js +2530 -0
- package/dist/server/_chunks/index-jbj7ehef.js +50 -0
- package/dist/server/_chunks/index-jcsjq3d1.js +20 -0
- package/dist/server/_chunks/index-jks0x0a1.js +14 -0
- package/dist/server/_chunks/index-jn9rbhrx.js +1599 -0
- package/dist/server/_chunks/index-jt8e1pje.js +12 -0
- package/dist/server/_chunks/index-kdhxpwyq.js +483 -0
- package/dist/server/_chunks/index-knp0s912.js +7 -0
- package/dist/server/_chunks/index-kqyy1d4f.js +50 -0
- package/dist/server/_chunks/index-kresp2n8.js +445 -0
- package/dist/server/_chunks/index-m63czgq5.js +590 -0
- package/dist/server/_chunks/index-ms9v9tnx.js +31 -0
- package/dist/server/_chunks/index-n4hxpng2.js +11 -0
- package/dist/server/_chunks/index-n629dy38.js +1071 -0
- package/dist/server/_chunks/index-nf3df4jy.js +266 -0
- package/dist/server/_chunks/index-nqh3xhdc.js +57 -0
- package/dist/server/_chunks/index-pym1cezq.js +39 -0
- package/dist/server/_chunks/index-q3r9z8mq.js +213 -0
- package/dist/server/_chunks/index-q738kkhj.js +100 -0
- package/dist/server/_chunks/index-qcrvt6er.js +112 -0
- package/dist/server/_chunks/index-qjj6gddn.js +54 -0
- package/dist/server/_chunks/index-qpwsgt3a.js +158 -0
- package/dist/server/_chunks/index-r97ptz1q.js +97 -0
- package/dist/server/_chunks/index-ras0sdab.js +26 -0
- package/dist/server/_chunks/index-rcs322t1.js +19 -0
- package/dist/server/_chunks/index-rgj5mx84.js +101 -0
- package/dist/server/_chunks/index-rjegyfx4.js +1435 -0
- package/dist/server/_chunks/index-rt9qq1va.js +4 -0
- package/dist/server/_chunks/index-rthrsed5.js +356 -0
- package/dist/server/_chunks/index-sq3kvz3g.js +200 -0
- package/dist/server/_chunks/index-stbk3jhn.js +31 -0
- package/dist/server/_chunks/index-tf4j19ge.js +130 -0
- package/dist/server/_chunks/index-tgcakdxc.js +125 -0
- package/dist/server/_chunks/index-tgsfjmep.js +74 -0
- package/dist/server/_chunks/index-tq1f96v7.js +51 -0
- package/dist/server/_chunks/index-tq3b39a5.js +107 -0
- package/dist/server/_chunks/index-typcbcsv.js +819 -0
- package/dist/server/_chunks/index-v1ags1na.js +132 -0
- package/dist/server/_chunks/index-vmr35jjw.js +170 -0
- package/dist/server/_chunks/index-vvq7rqtn.js +329 -0
- package/dist/server/_chunks/index-vz0km5qk.js +33 -0
- package/dist/server/_chunks/index-w6h8m6vp.js +138 -0
- package/dist/server/_chunks/index-web361b8.js +138 -0
- package/dist/server/_chunks/index-wm36rj4v.js +311 -0
- package/dist/server/_chunks/index-x0y005nh.js +283 -0
- package/dist/server/_chunks/index-x2m17v9c.js +6166 -0
- package/dist/server/_chunks/index-x3yn4ywm.js +22 -0
- package/dist/server/_chunks/index-x9c55pzy.js +871 -0
- package/dist/server/_chunks/index-xh1nbk46.js +1299 -0
- package/dist/server/_chunks/index-xvj80c3a.js +30 -0
- package/dist/server/_chunks/index-xywjg2vc.js +100 -0
- package/dist/server/_chunks/index-y4d02znn.js +66 -0
- package/dist/server/_chunks/index-y7mzvq2q.js +110 -0
- package/dist/server/_chunks/index-ye9hmsvf.js +47 -0
- package/dist/server/_chunks/index-yhxkxghe.js +56 -0
- package/dist/server/_chunks/index-yrjkqtfj.js +86 -0
- package/dist/server/_chunks/index-z88qv16t.js +11 -0
- package/dist/server/_chunks/index-zfrwq472.js +154 -0
- package/dist/server/_chunks/index-zqpqyg8p.js +666 -0
- package/dist/server/_chunks/loader-5en7wpt5.js +80 -0
- package/dist/server/_chunks/modules-t92favpj.js +76 -0
- package/dist/server/_chunks/pipeline-4t9q43ht.js +836 -0
- package/dist/server/_chunks/production-385bw8df.js +55 -0
- package/dist/server/_chunks/proxy-config-60gprphe.js +23 -0
- package/dist/server/_chunks/proxy-gfhmktbk.js +35 -0
- package/dist/server/_chunks/router-xnrva921.js +501 -0
- package/dist/server/_chunks/routes-ht868pdc.js +66 -0
- package/dist/server/_chunks/run-d40d63ag.js +697 -0
- package/dist/server/_chunks/server-2p8fgqq2.js +1839 -0
- package/dist/server/_chunks/tsconfig-defaults-bcn34eqb.js +21 -0
- package/dist/server/_chunks/typegen-dvtcjtaw.js +37 -0
- package/dist/server/api/client-cache.js +14 -0
- package/dist/server/cli/index.js +375 -0
- package/dist/server/cli/start.js +158 -0
- package/dist/server/client/reference.js +16 -0
- package/dist/server/compat/next/cache.js +56 -0
- package/dist/server/compat/next/canonical-url.js +13 -0
- package/dist/server/compat/next/client-cache.js +57 -0
- package/dist/server/compat/next/client-navigation.js +232 -0
- package/dist/server/compat/next/client-only.js +1 -0
- package/dist/server/compat/next/client-script.js +178 -0
- package/dist/server/compat/next/client-server.js +34 -0
- package/dist/server/compat/next/config-headers.js +34 -0
- package/dist/server/compat/next/config-loader.js +25 -0
- package/dist/server/compat/next/config.js +10 -0
- package/dist/server/compat/next/constants.js +18 -0
- package/dist/server/compat/next/custom-server.js +10 -0
- package/dist/server/compat/next/dist/client/components/app-router-headers.js +48 -0
- package/dist/server/compat/next/dist/server/web/spec-extension/revalidate.js +27 -0
- package/dist/server/compat/next/dist/server/web/spec-extension/unstable-cache.js +25 -0
- package/dist/server/compat/next/dist/server/web/spec-extension/unstable-no-store.js +25 -0
- package/dist/server/compat/next/dynamic.js +21 -0
- package/dist/server/compat/next/error.js +112 -0
- package/dist/server/compat/next/font/cache.js +16 -0
- package/dist/server/compat/next/font/google.js +3 -0
- package/dist/server/compat/next/font/index.js +1 -0
- package/dist/server/compat/next/font/local.js +24 -0
- package/dist/server/compat/next/font/runtime-client.js +33 -0
- package/dist/server/compat/next/font/runtime.js +43 -0
- package/dist/server/compat/next/font/shared.js +22 -0
- package/dist/server/compat/next/form.js +129 -0
- package/dist/server/compat/next/head.js +10 -0
- package/dist/server/compat/next/headers.js +30 -0
- package/dist/server/compat/next/image/client.js +11 -0
- package/dist/server/compat/next/image/config.js +18 -0
- package/dist/server/compat/next/image/optimizer.js +25 -0
- package/dist/server/compat/next/image/patterns.js +12 -0
- package/dist/server/compat/next/image/props.js +16 -0
- package/dist/server/compat/next/image/shared.js +86 -0
- package/dist/server/compat/next/image/static-metadata.js +32 -0
- package/dist/server/compat/next/image/validate.js +8 -0
- package/dist/server/compat/next/image.js +59 -0
- package/dist/server/compat/next/index.js +1 -0
- package/dist/server/compat/next/legacy-image.js +78 -0
- package/dist/server/compat/next/legacy-request-apis.js +24 -0
- package/dist/server/compat/next/link-transform.js +15 -0
- package/dist/server/compat/next/link.js +14 -0
- package/dist/server/compat/next/navigation.js +191 -0
- package/dist/server/compat/next/offline.js +45 -0
- package/dist/server/compat/next/og.js +8 -0
- package/dist/server/compat/next/preferred-region.js +8 -0
- package/dist/server/compat/next/redirects.js +32 -0
- package/dist/server/compat/next/resource-hints.js +30 -0
- package/dist/server/compat/next/rewrites.js +43 -0
- package/dist/server/compat/next/root-params.js +121 -0
- package/dist/server/compat/next/route-state.js +23 -0
- package/dist/server/compat/next/router.js +103 -0
- package/dist/server/compat/next/script.js +37 -0
- package/dist/server/compat/next/server-only.js +1 -0
- package/dist/server/compat/next/server.js +131 -0
- package/dist/server/compat/next/svgr.js +14 -0
- package/dist/server/compat/next/telemetry.js +10 -0
- package/dist/server/compat/next/usage.js +13 -0
- package/dist/server/compat/next/user-agent.js +12 -0
- package/dist/server/compat/next/web-vitals.js +35 -0
- package/dist/server/compat/react/action-state.js +11 -0
- package/dist/server/compat/react/client-lite.js +83 -0
- package/dist/server/compat/react/client.js +131 -0
- package/dist/server/compat/react/compiler-runtime.js +42 -0
- package/dist/server/compat/react/dom-client.js +106 -0
- package/dist/server/compat/react/dom-react-server.js +37 -0
- package/dist/server/compat/react/dom-server.js +40 -0
- package/dist/server/compat/react/dom.js +52 -0
- package/dist/server/compat/react/hooks-extra.js +12 -0
- package/dist/server/compat/react/internals.js +14 -0
- package/dist/server/compat/react/parity.js +11 -0
- package/dist/server/compat/react/preact.js +113 -0
- package/dist/server/compat/react/react-server.js +133 -0
- package/dist/server/compat/react/router-shim.js +8 -0
- package/dist/server/compat/react/server-component-use.js +14 -0
- package/dist/server/compat/react/server-inserted-html.js +14 -0
- package/dist/server/compat/react/server.js +194 -0
- package/dist/server/compat/react/style-values.js +10 -0
- package/dist/server/compat/react/use.js +10 -0
- package/dist/server/compat/react/view-transition.js +12 -0
- package/dist/server/generation.json +1 -0
- package/package.json +4 -1
- package/reference/compat.md +1 -1
- package/reference/config.md +2 -2
- package/reference/dev.md +1 -1
- package/reference/getting-started.md +1 -1
- package/reference/rendering.md +4 -4
- package/src/api/dynamic.tsx +86 -4
- package/src/api/server.ts +24 -6
- package/src/cli/adapters/vercel-warm.ts +327 -62
- package/src/cli/adapters/vercel.ts +164 -1054
- package/src/cli/analyze.ts +3 -2
- package/src/cli/build/cache.ts +6 -6
- package/src/cli/build.ts +78 -45
- package/src/cli/index.ts +21 -3
- package/src/cli/serve/immutable.ts +31 -0
- package/src/cli/serve/pipeline.ts +97 -93
- package/src/cli/serve/standalone-worker.ts +8 -0
- package/src/cli/serve/standalone.ts +703 -0
- package/src/cli/start.ts +31 -8
- package/src/client/build.ts +1 -1
- package/src/client/chunk-fold.ts +19 -6
- package/src/client/react-tier.ts +3 -2
- package/src/client/reference-stub.ts +23 -36
- package/src/compat/actions/client-plugin.ts +4 -2
- package/src/compat/actions/config.ts +6 -5
- package/src/compat/actions/extensions.ts +5 -5
- package/src/compat/aliases.ts +8 -1
- package/src/compat/bundler/config.ts +88 -0
- package/src/compat/bundler/optimize-package-imports.ts +86 -26
- package/src/compat/bundler/relay-transform.ts +15 -3
- package/src/compat/bundler/require-context.ts +2 -1
- package/src/compat/bundler/webpack-loaders.ts +3 -2
- package/src/compat/bundler/worker.ts +2 -2
- package/src/compat/cache-control.ts +16 -8
- package/src/compat/css/inline-css.ts +1 -1
- package/src/compat/css/modules.ts +18 -5
- package/src/compat/export/build-complete.ts +1 -1
- package/src/compat/export/emit.ts +4 -4
- package/src/compat/export/standalone.ts +30 -65
- package/src/compat/image-optimizer/optimize.ts +1 -1
- package/src/compat/lifecycle/error-funnel.ts +1 -1
- package/src/compat/lifecycle/instrumentation-client.ts +4 -3
- package/src/compat/lifecycle/instrumentation.ts +117 -24
- package/src/compat/lifecycle/testmode.ts +3 -2
- package/src/compat/metadata-artifacts.ts +1 -1
- package/src/compat/next/config-loader.ts +140 -13
- package/src/compat/next/dynamic.tsx +10 -23
- package/src/compat/next/font/cache.ts +2 -1
- package/src/compat/next/font/runtime.ts +23 -3
- package/src/compat/next/og.ts +3 -3
- package/src/compat/next/usage.ts +3 -2
- package/src/compat/pages/api.ts +83 -14
- package/src/compat/pages/router.ts +30 -14
- package/src/compat/register/bundler.ts +3 -1
- package/src/compat/register/image.ts +1 -1
- package/src/compat/register/middleware.ts +1 -1
- package/src/compat/register/otel.ts +5 -9
- package/src/compat/register/render.ts +3 -1
- package/src/compat/register/use-cache.ts +3 -1
- package/src/compat/release.ts +46 -0
- package/src/compat/segment/serve.ts +1 -1
- package/src/compat/typecheck/check.ts +6 -4
- package/src/compat/validation/validate.ts +10 -7
- package/src/config.ts +76 -9
- package/src/css/assets.ts +213 -0
- package/src/css/build.ts +190 -247
- package/src/dev/client-chunk-store.ts +2 -1
- package/src/dev/restart/client-key.ts +2 -1
- package/src/dev/restart/global-css.ts +2 -1
- package/src/dev/restart/route-bundle-key.ts +2 -1
- package/src/dev/restart/route-facts.ts +2 -1
- package/src/dev/server.ts +34 -14
- package/src/extensions.ts +4 -0
- package/src/out-paths.ts +10 -0
- package/src/render/hooks.ts +13 -0
- package/src/render/renderer.ts +53 -33
- package/src/request/context.ts +9 -0
- package/src/resolve/dynamic.ts +7 -1
- package/src/resolve/engine.ts +2 -12
- package/src/resolve/imports.ts +12 -52
- package/src/resolve/package-json.ts +56 -0
- package/src/resolve/scan-facts.ts +250 -1
- package/src/routing/href.ts +10 -3
- package/src/routing/match.ts +287 -0
- package/src/routing/metadata-files.ts +20 -6
- package/src/routing/proxy-config.ts +137 -0
- package/src/routing/proxy.ts +35 -134
- package/src/routing/routes.ts +22 -281
- package/src/runtime/fingerprint.ts +23 -8
- package/src/runtime/load.ts +170 -0
- package/src/runtime/loader.ts +218 -44
- package/src/runtime/module-cache.ts +15 -1
- package/src/runtime/modules.ts +405 -82
- package/src/runtime/prebundle.ts +101 -0
- package/src/runtime/production.ts +456 -0
- package/src/runtime/release-graph.ts +342 -0
- package/src/runtime/vendor-build.ts +750 -17
- package/src/runtime/vendor.ts +16 -3
- package/src/types.ts +4 -3
- package/src/utils/directive.ts +40 -0
- package/src/utils/fs.ts +95 -4
- package/src/utils/resource-query.ts +12 -0
- package/src/cli/serve/entry.ts +0 -45
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/compat/ppr/root-params-scan.ts
|
|
3
|
+
import { existsSync, readdirSync, readFileSync, statSync } from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
var LAYOUT_BASENAMES = ["layout.tsx", "layout.ts", "layout.jsx", "layout.js"];
|
|
6
|
+
function isRootLayoutSource(source) {
|
|
7
|
+
return /<html[\s>]/.test(source);
|
|
8
|
+
}
|
|
9
|
+
function paramNameOfSegment(segment) {
|
|
10
|
+
const optional = /^\[\[\.\.\.(.+)\]\]$/.exec(segment);
|
|
11
|
+
if (optional)
|
|
12
|
+
return optional[1];
|
|
13
|
+
const catchAll = /^\[\.\.\.(.+)\]$/.exec(segment);
|
|
14
|
+
if (catchAll)
|
|
15
|
+
return catchAll[1];
|
|
16
|
+
const dynamic = /^\[(.+)\]$/.exec(segment);
|
|
17
|
+
if (dynamic)
|
|
18
|
+
return dynamic[1];
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
function findLayoutFile(dir) {
|
|
22
|
+
for (const base of LAYOUT_BASENAMES) {
|
|
23
|
+
const candidate = path.join(dir, base);
|
|
24
|
+
if (existsSync(candidate))
|
|
25
|
+
return candidate;
|
|
26
|
+
}
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
function scanRootParams(appPath) {
|
|
30
|
+
const rootParams = new Set;
|
|
31
|
+
if (!existsSync(appPath))
|
|
32
|
+
return rootParams;
|
|
33
|
+
const walk = (dir, paramsAbove) => {
|
|
34
|
+
const layoutFile = findLayoutFile(dir);
|
|
35
|
+
if (layoutFile) {
|
|
36
|
+
let source = "";
|
|
37
|
+
try {
|
|
38
|
+
source = readFileSync(layoutFile, "utf8");
|
|
39
|
+
} catch {
|
|
40
|
+
source = "";
|
|
41
|
+
}
|
|
42
|
+
if (isRootLayoutSource(source)) {
|
|
43
|
+
for (const name of paramsAbove)
|
|
44
|
+
rootParams.add(name);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
let children = [];
|
|
48
|
+
try {
|
|
49
|
+
children = readdirSync(dir);
|
|
50
|
+
} catch {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
for (const child of children) {
|
|
54
|
+
const childPath = path.join(dir, child);
|
|
55
|
+
let isDir = false;
|
|
56
|
+
try {
|
|
57
|
+
isDir = statSync(childPath).isDirectory();
|
|
58
|
+
} catch {
|
|
59
|
+
isDir = false;
|
|
60
|
+
}
|
|
61
|
+
if (!isDir)
|
|
62
|
+
continue;
|
|
63
|
+
if (child.startsWith("@"))
|
|
64
|
+
continue;
|
|
65
|
+
const param = paramNameOfSegment(child);
|
|
66
|
+
walk(childPath, param ? [...paramsAbove, param] : paramsAbove);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
walk(appPath, []);
|
|
70
|
+
return rootParams;
|
|
71
|
+
}
|
|
72
|
+
function scanRootParamTypes(appPath) {
|
|
73
|
+
const roots = [];
|
|
74
|
+
if (!existsSync(appPath))
|
|
75
|
+
return new Map;
|
|
76
|
+
const walk = (dir, paramsAbove) => {
|
|
77
|
+
const layoutFile = findLayoutFile(dir);
|
|
78
|
+
if (layoutFile) {
|
|
79
|
+
let source = "";
|
|
80
|
+
try {
|
|
81
|
+
source = readFileSync(layoutFile, "utf8");
|
|
82
|
+
} catch {
|
|
83
|
+
source = "";
|
|
84
|
+
}
|
|
85
|
+
if (isRootLayoutSource(source)) {
|
|
86
|
+
const params = new Map;
|
|
87
|
+
for (const { name, segment } of paramsAbove) {
|
|
88
|
+
params.set(name, segment.startsWith("[[...") ? ["string[]", "undefined"] : segment.startsWith("[...") ? ["string[]"] : ["string"]);
|
|
89
|
+
}
|
|
90
|
+
roots.push(params);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
let children = [];
|
|
94
|
+
try {
|
|
95
|
+
children = readdirSync(dir);
|
|
96
|
+
} catch {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
for (const child of children) {
|
|
100
|
+
const childPath = path.join(dir, child);
|
|
101
|
+
let isDir = false;
|
|
102
|
+
try {
|
|
103
|
+
isDir = statSync(childPath).isDirectory();
|
|
104
|
+
} catch {
|
|
105
|
+
isDir = false;
|
|
106
|
+
}
|
|
107
|
+
if (!isDir)
|
|
108
|
+
continue;
|
|
109
|
+
if (child.startsWith("@"))
|
|
110
|
+
continue;
|
|
111
|
+
const param = paramNameOfSegment(child);
|
|
112
|
+
walk(childPath, param ? [...paramsAbove, { name: param, segment: child }] : paramsAbove);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
walk(appPath, []);
|
|
116
|
+
const combined = new Map;
|
|
117
|
+
for (const params of roots) {
|
|
118
|
+
for (const [name, types] of params) {
|
|
119
|
+
const set = combined.get(name) ?? new Set;
|
|
120
|
+
for (const type of types)
|
|
121
|
+
set.add(type);
|
|
122
|
+
combined.set(name, set);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
for (const [name, set] of combined) {
|
|
126
|
+
if (roots.some((params) => !params.has(name)))
|
|
127
|
+
set.add("undefined");
|
|
128
|
+
}
|
|
129
|
+
return combined;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export { scanRootParams, scanRootParamTypes };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
rewriteFacts
|
|
4
|
+
} from "./index-x9c55pzy.js";
|
|
5
|
+
import {
|
|
6
|
+
loadNative
|
|
7
|
+
} from "./index-7wc9n8be.js";
|
|
8
|
+
import {
|
|
9
|
+
__require
|
|
10
|
+
} from "./index-rt9qq1va.js";
|
|
11
|
+
|
|
12
|
+
// src/compat/next/link-transform.ts
|
|
13
|
+
var parseSync = (...args) => loadNative(() => __require("oxc-parser")).parseSync(...args);
|
|
14
|
+
var marker = "__pnextLegacyChildKind";
|
|
15
|
+
function rewriteLegacyLinkValidation(source, file) {
|
|
16
|
+
if (!source.includes("Link") && !source.includes("legacyBehavior"))
|
|
17
|
+
return source;
|
|
18
|
+
const imports = rewriteFacts(file, source).imports;
|
|
19
|
+
const directLink = imports.some((statement) => statement.specifier === "next/link") && source.includes("legacyBehavior");
|
|
20
|
+
const asyncLinkWrapper = imports.some((statement) => statement.bindings.some((binding) => !binding.type && binding.local.endsWith("Link"))) && /<[A-Za-z_$][\w$]*Link\b/.test(source) && /\basync\s+function\b/.test(source);
|
|
21
|
+
if (!directLink && !asyncLinkWrapper)
|
|
22
|
+
return source;
|
|
23
|
+
const program = parseSync(file, source, { lang: langForFile(file) }).program;
|
|
24
|
+
const linkNames = new Set;
|
|
25
|
+
const asyncNames = new Set;
|
|
26
|
+
const functionNames = new Set;
|
|
27
|
+
const lazyNames = new Set;
|
|
28
|
+
const edits = [];
|
|
29
|
+
const isClient = program.body.some((statement) => statement.type === "ExpressionStatement" && statement.directive === "use client");
|
|
30
|
+
for (const statement of program.body) {
|
|
31
|
+
if (statement.type === "ImportDeclaration" && sourceValue(statement) === "next/link") {
|
|
32
|
+
for (const specifier of statement.specifiers ?? []) {
|
|
33
|
+
const local = identifierName(specifier.local);
|
|
34
|
+
if (!local)
|
|
35
|
+
continue;
|
|
36
|
+
if (specifier.type === "ImportDefaultSpecifier")
|
|
37
|
+
linkNames.add(local);
|
|
38
|
+
else if (identifierName(specifier.imported) === "Link")
|
|
39
|
+
linkNames.add(local);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (statement.type === "FunctionDeclaration") {
|
|
43
|
+
const name = identifierName(statement.id);
|
|
44
|
+
if (name) {
|
|
45
|
+
functionNames.add(name);
|
|
46
|
+
if (statement.async === true)
|
|
47
|
+
asyncNames.add(name);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (statement.type === "VariableDeclaration") {
|
|
51
|
+
for (const declarator of statement.declarations ?? []) {
|
|
52
|
+
const name = identifierName(declarator.id);
|
|
53
|
+
const init = declarator.init;
|
|
54
|
+
if (!name || !init)
|
|
55
|
+
continue;
|
|
56
|
+
if (init.type === "ArrowFunctionExpression" || init.type === "FunctionExpression") {
|
|
57
|
+
functionNames.add(name);
|
|
58
|
+
if (init.async === true)
|
|
59
|
+
asyncNames.add(name);
|
|
60
|
+
}
|
|
61
|
+
if (isLazyCall(init))
|
|
62
|
+
lazyNames.add(name);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
walk(program.body, (node) => {
|
|
67
|
+
if (node.type !== "JSXElement")
|
|
68
|
+
return;
|
|
69
|
+
const element = node;
|
|
70
|
+
if (element.closingElement === null)
|
|
71
|
+
return;
|
|
72
|
+
annotate(element);
|
|
73
|
+
});
|
|
74
|
+
function annotate(element) {
|
|
75
|
+
const opening = element.openingElement;
|
|
76
|
+
if (opening.name.type !== "JSXIdentifier" || hasMarker(opening))
|
|
77
|
+
return;
|
|
78
|
+
const parent = opening.name.name ?? "";
|
|
79
|
+
const isLink = linkNames.has(parent);
|
|
80
|
+
if (!isLink && !parent.endsWith("Link"))
|
|
81
|
+
return;
|
|
82
|
+
const children = element.children.filter(isMeaningfulChild);
|
|
83
|
+
if (children.length !== 1)
|
|
84
|
+
return;
|
|
85
|
+
const kind = childKind(children[0]);
|
|
86
|
+
if (!kind || !isLink && kind !== "server-async")
|
|
87
|
+
return;
|
|
88
|
+
const annotatedKind = !isLink ? "server-async-through-client" : isClient && kind === "lazy" ? "client-lazy" : kind;
|
|
89
|
+
edits.push({ at: opening.name.end, text: ` ${marker}="${annotatedKind}"` });
|
|
90
|
+
}
|
|
91
|
+
function childKind(child) {
|
|
92
|
+
let name;
|
|
93
|
+
if (child.type === "JSXElement") {
|
|
94
|
+
const opening = child.openingElement;
|
|
95
|
+
if (opening.name.type === "JSXIdentifier")
|
|
96
|
+
name = opening.name.name;
|
|
97
|
+
} else if (child.type === "JSXExpressionContainer") {
|
|
98
|
+
const expression = child.expression;
|
|
99
|
+
if (expression?.type === "Identifier")
|
|
100
|
+
name = expression.name;
|
|
101
|
+
}
|
|
102
|
+
if (!name)
|
|
103
|
+
return;
|
|
104
|
+
if (lazyNames.has(name))
|
|
105
|
+
return "lazy";
|
|
106
|
+
if (asyncNames.has(name))
|
|
107
|
+
return "server-async";
|
|
108
|
+
if (!isClient && functionNames.has(name))
|
|
109
|
+
return "server-sync";
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (edits.length === 0)
|
|
113
|
+
return source;
|
|
114
|
+
let output = source;
|
|
115
|
+
for (const edit of edits.sort((a, b) => b.at - a.at)) {
|
|
116
|
+
output = output.slice(0, edit.at) + edit.text + output.slice(edit.at);
|
|
117
|
+
}
|
|
118
|
+
return output;
|
|
119
|
+
}
|
|
120
|
+
function isMeaningfulChild(child) {
|
|
121
|
+
if (child.type === "JSXText") {
|
|
122
|
+
return typeof child.value === "string" && child.value.trim().length > 0;
|
|
123
|
+
}
|
|
124
|
+
if (child.type === "JSXExpressionContainer") {
|
|
125
|
+
return child.expression?.type !== "JSXEmptyExpression";
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
function hasMarker(opening) {
|
|
130
|
+
return opening.attributes.some((attribute) => attribute.type === "JSXAttribute" && attribute.name?.name === marker);
|
|
131
|
+
}
|
|
132
|
+
function isLazyCall(expression) {
|
|
133
|
+
if (expression.type !== "CallExpression")
|
|
134
|
+
return false;
|
|
135
|
+
const callee = expression.callee;
|
|
136
|
+
if (!callee)
|
|
137
|
+
return false;
|
|
138
|
+
if (callee.type === "Identifier")
|
|
139
|
+
return callee.name === "lazy";
|
|
140
|
+
return callee.type === "MemberExpression" && identifierName(callee.property) === "lazy";
|
|
141
|
+
}
|
|
142
|
+
function identifierName(node) {
|
|
143
|
+
const named = node;
|
|
144
|
+
return typeof named?.name === "string" ? named.name : undefined;
|
|
145
|
+
}
|
|
146
|
+
function sourceValue(statement) {
|
|
147
|
+
const literal = statement.source;
|
|
148
|
+
return typeof literal?.value === "string" ? literal.value : undefined;
|
|
149
|
+
}
|
|
150
|
+
function walk(node, visit) {
|
|
151
|
+
if (Array.isArray(node)) {
|
|
152
|
+
for (const item of node)
|
|
153
|
+
walk(item, visit);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (!node || typeof node !== "object")
|
|
157
|
+
return;
|
|
158
|
+
const candidate = node;
|
|
159
|
+
if (typeof candidate.type === "string")
|
|
160
|
+
visit(candidate);
|
|
161
|
+
for (const key in candidate) {
|
|
162
|
+
if (key !== "type")
|
|
163
|
+
walk(candidate[key], visit);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function langForFile(file) {
|
|
167
|
+
return /\.[cm]?ts$/.test(file) ? "ts" : "tsx";
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export { rewriteLegacyLinkValidation };
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
addTransitionType
|
|
4
|
+
} from "./index-9ch50vtq.js";
|
|
5
|
+
import {
|
|
6
|
+
addBasePath
|
|
7
|
+
} from "./index-ms9v9tnx.js";
|
|
8
|
+
|
|
9
|
+
// src/compat/next/link.tsx
|
|
10
|
+
import { cloneElement, h as createElement, toChildArray } from "preact";
|
|
11
|
+
import { useContext, useEffect, useRef, useState } from "preact/hooks";
|
|
12
|
+
import { usePrefetchLifecycle } from "../../../src/api/link.tsx";
|
|
13
|
+
import { blockJavascriptUrl, isJavascriptUrl } from "../../../src/client/router/index.ts";
|
|
14
|
+
import { applyTrailingSlash, routeHref } from "../../../src/routing/href.ts";
|
|
15
|
+
|
|
16
|
+
// src/compat/client/trailing-slash.ts
|
|
17
|
+
function skipTrailingSlashRedirect() {
|
|
18
|
+
if (typeof window !== "undefined")
|
|
19
|
+
return window.__PNEXT_SKIP_TRAILING_SLASH__ === true;
|
|
20
|
+
return globalThis.__PNEXT_SKIP_TRAILING_SLASH__ === true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/compat/client/link-status.ts
|
|
24
|
+
import { createContext } from "preact";
|
|
25
|
+
import { softNavigate } from "../../../src/client/router/index.ts";
|
|
26
|
+
import { locationListeners, onNavigationStart } from "../../../src/client/router/events.ts";
|
|
27
|
+
import { patchHistory } from "../../../src/api/client-navigation.ts";
|
|
28
|
+
var LinkStatusContext = createContext({ pending: false });
|
|
29
|
+
var pendingToken = null;
|
|
30
|
+
var ownNavStart = null;
|
|
31
|
+
var listeners = new Set;
|
|
32
|
+
var wired = false;
|
|
33
|
+
function notify() {
|
|
34
|
+
for (const listener of [...listeners])
|
|
35
|
+
listener();
|
|
36
|
+
}
|
|
37
|
+
function setPending(token) {
|
|
38
|
+
if (pendingToken === token)
|
|
39
|
+
return;
|
|
40
|
+
pendingToken = token;
|
|
41
|
+
notify();
|
|
42
|
+
}
|
|
43
|
+
function onNavStart() {
|
|
44
|
+
if (ownNavStart !== null) {
|
|
45
|
+
ownNavStart = null;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
setPending(null);
|
|
49
|
+
}
|
|
50
|
+
function onLocationChange() {
|
|
51
|
+
setPending(null);
|
|
52
|
+
}
|
|
53
|
+
function wire() {
|
|
54
|
+
if (wired || typeof window === "undefined")
|
|
55
|
+
return;
|
|
56
|
+
wired = true;
|
|
57
|
+
patchHistory();
|
|
58
|
+
onNavigationStart(onNavStart);
|
|
59
|
+
locationListeners().add(onLocationChange);
|
|
60
|
+
window.addEventListener("popstate", onLocationChange);
|
|
61
|
+
}
|
|
62
|
+
function subscribeLinkStatus(_token, listener) {
|
|
63
|
+
wire();
|
|
64
|
+
listeners.add(listener);
|
|
65
|
+
return () => listeners.delete(listener);
|
|
66
|
+
}
|
|
67
|
+
function linkPending(token) {
|
|
68
|
+
return pendingToken === token;
|
|
69
|
+
}
|
|
70
|
+
function navigateWithStatus(token, href, options) {
|
|
71
|
+
ownNavStart = token;
|
|
72
|
+
setPending(token);
|
|
73
|
+
softNavigate(href, options).finally(() => {
|
|
74
|
+
if (pendingToken === token)
|
|
75
|
+
setPending(null);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// src/compat/next/link.tsx
|
|
80
|
+
var reactClientReferenceSymbol = Symbol.for("react.client.reference");
|
|
81
|
+
function Link({
|
|
82
|
+
href,
|
|
83
|
+
as,
|
|
84
|
+
prefetch = null,
|
|
85
|
+
unstable_dynamicOnHover,
|
|
86
|
+
replace,
|
|
87
|
+
scroll,
|
|
88
|
+
locale: _locale,
|
|
89
|
+
legacyBehavior,
|
|
90
|
+
passHref,
|
|
91
|
+
onClick,
|
|
92
|
+
onNavigate,
|
|
93
|
+
transitionTypes,
|
|
94
|
+
onPrefetchStart,
|
|
95
|
+
onPrefetchFinish,
|
|
96
|
+
__pnextLegacyChildKind,
|
|
97
|
+
children,
|
|
98
|
+
ref: forwardedRef,
|
|
99
|
+
...anchorProps
|
|
100
|
+
}) {
|
|
101
|
+
const target = as == null ? href : as;
|
|
102
|
+
const hrefBase = hrefString(target);
|
|
103
|
+
const resolvedHref = addBasePath(skipTrailingSlashRedirect() ? hrefBase : applyTrailingSlash(hrefBase));
|
|
104
|
+
const blocked = isJavascriptUrl(resolvedHref);
|
|
105
|
+
const prefetchMode = nextPrefetchMode(prefetch);
|
|
106
|
+
const lifecycleRef = usePrefetchLifecycle(onPrefetchStart, onPrefetchFinish);
|
|
107
|
+
const anchorRef = useComposedRef(lifecycleRef, forwardedRef);
|
|
108
|
+
const statusToken = useLinkToken();
|
|
109
|
+
const handleClick = (event) => {
|
|
110
|
+
onClick?.(event);
|
|
111
|
+
if (event.defaultPrevented)
|
|
112
|
+
return;
|
|
113
|
+
if (blocked) {
|
|
114
|
+
if (blockJavascriptUrl(resolvedHref))
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (!isPlainLeftClick(event))
|
|
119
|
+
return;
|
|
120
|
+
if (isExternalHref(resolvedHref)) {
|
|
121
|
+
if (replace) {
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
window.location.replace(resolvedHref);
|
|
124
|
+
}
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (onNavigate) {
|
|
128
|
+
const navEvent = navigationEvent();
|
|
129
|
+
onNavigate(navEvent);
|
|
130
|
+
if (navEvent.defaultPrevented) {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
event.preventDefault();
|
|
136
|
+
for (const type of transitionTypes ?? [])
|
|
137
|
+
addTransitionType(type);
|
|
138
|
+
const url = new URL(resolvedHref, window.location.href);
|
|
139
|
+
const samePage = url.pathname === window.location.pathname && url.search === window.location.search;
|
|
140
|
+
if (samePage && url.hash) {
|
|
141
|
+
window.location.hash = url.hash;
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
navigateWithStatus(statusToken, url.href, { replace, scroll });
|
|
145
|
+
};
|
|
146
|
+
const anchorAttributes = {
|
|
147
|
+
...anchorProps,
|
|
148
|
+
ref: anchorRef,
|
|
149
|
+
href: resolvedHref,
|
|
150
|
+
"data-pnext-link": true,
|
|
151
|
+
"data-prefetch": prefetchMode === false ? "false" : prefetchMode,
|
|
152
|
+
"data-prefetch-full": prefetch === true || prefetch === "unstable_forceStale" ? "true" : undefined,
|
|
153
|
+
"data-prefetch-hover-full": unstable_dynamicOnHover ? "true" : undefined,
|
|
154
|
+
"data-pnext-replace": replace ? "true" : undefined,
|
|
155
|
+
"data-pnext-scroll": scroll === false ? "false" : undefined,
|
|
156
|
+
onClick: handleClick
|
|
157
|
+
};
|
|
158
|
+
if (blocked)
|
|
159
|
+
anchorAttributes["data-pnext-blocked-href"] = resolvedHref;
|
|
160
|
+
if ((typeof __PNEXT_LINK_LEGACY__ === "boolean" ? __PNEXT_LINK_LEGACY__ : true) && legacyBehavior) {
|
|
161
|
+
return renderLegacyChild(children, resolvedHref, passHref, handleClick, anchorAttributes, __pnextLegacyChildKind);
|
|
162
|
+
}
|
|
163
|
+
return createElement("a", anchorAttributes, createElement(LinkStatusContext.Provider, { value: { pending: linkPending(statusToken) } }, children));
|
|
164
|
+
}
|
|
165
|
+
var link_default = Link;
|
|
166
|
+
function useLinkStatus() {
|
|
167
|
+
return useContext(LinkStatusContext);
|
|
168
|
+
}
|
|
169
|
+
function useLinkToken() {
|
|
170
|
+
const tokenRef = useRef(null);
|
|
171
|
+
tokenRef.current ??= Symbol("pnext-link");
|
|
172
|
+
const token = tokenRef.current;
|
|
173
|
+
const [, force] = useState(0);
|
|
174
|
+
useEffect(() => subscribeLinkStatus(token, () => force((n) => n + 1)), [token]);
|
|
175
|
+
return token;
|
|
176
|
+
}
|
|
177
|
+
function renderLegacyChild(children, resolvedHref, passHref, onClick, anchorAttributes, annotatedKind) {
|
|
178
|
+
reportLegacyDeprecation();
|
|
179
|
+
const isDev = false;
|
|
180
|
+
const isServer = typeof window === "undefined";
|
|
181
|
+
if (isLazyComponent(children))
|
|
182
|
+
throw unsupportedLegacyChildError();
|
|
183
|
+
if (children == null || children === false) {
|
|
184
|
+
if (isDev) {
|
|
185
|
+
throw validationError(`No children were passed to <Link> with \`href\` of \`${resolvedHref}\` but one child is required https://nextjs.org/docs/messages/link-no-children`, "E320");
|
|
186
|
+
}
|
|
187
|
+
return childrenOnlyOrThrow(children);
|
|
188
|
+
}
|
|
189
|
+
if (typeof children === "string" || typeof children === "number") {
|
|
190
|
+
return createElement("a", { ...anchorAttributes, href: resolvedHref }, children);
|
|
191
|
+
}
|
|
192
|
+
const count = toChildArray(children).length;
|
|
193
|
+
if (count > 1) {
|
|
194
|
+
if (isDev) {
|
|
195
|
+
throw validationError(`Multiple children were passed to <Link> with \`href\` of \`${resolvedHref}\` but only one child is supported https://nextjs.org/docs/messages/link-multiple-children`, "E266");
|
|
196
|
+
}
|
|
197
|
+
return childrenOnlyOrThrow(children);
|
|
198
|
+
}
|
|
199
|
+
const child = childrenOnlyOrThrow(children);
|
|
200
|
+
const kind = annotatedKind ?? (isAsyncFunctionComponent(child.type) ? "server-async" : isLazyComponent(child.type) ? "lazy" : undefined);
|
|
201
|
+
if (isServer && (kind === "server-sync" || kind === "server-async" || kind === "lazy")) {
|
|
202
|
+
reportUnsupportedServerChild(kind, isDev);
|
|
203
|
+
}
|
|
204
|
+
if (kind && kind !== "server-sync") {
|
|
205
|
+
const error = unsupportedLegacyChildError();
|
|
206
|
+
if (isServer && kind === "server-async-through-client") {
|
|
207
|
+
console.error(`\u2A2F ${error.stack ?? `Error: ${error.message}`}`);
|
|
208
|
+
}
|
|
209
|
+
throw error;
|
|
210
|
+
}
|
|
211
|
+
if (isServer && isDev && isServerComponent(child.type)) {
|
|
212
|
+
reportUnsupportedServerChild("server-sync", isDev);
|
|
213
|
+
}
|
|
214
|
+
const childProps = {
|
|
215
|
+
onClick: (event) => {
|
|
216
|
+
child.props.onClick?.(event);
|
|
217
|
+
onClick(event);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
if (passHref || child.type === "a") {
|
|
221
|
+
childProps.href = resolvedHref;
|
|
222
|
+
childProps["data-pnext-link"] = anchorAttributes["data-pnext-link"];
|
|
223
|
+
childProps["data-prefetch"] = anchorAttributes["data-prefetch"];
|
|
224
|
+
childProps["data-prefetch-full"] = anchorAttributes["data-prefetch-full"];
|
|
225
|
+
childProps["data-prefetch-hover-full"] = anchorAttributes["data-prefetch-hover-full"];
|
|
226
|
+
childProps["data-pnext-replace"] = anchorAttributes["data-pnext-replace"];
|
|
227
|
+
childProps["data-pnext-scroll"] = anchorAttributes["data-pnext-scroll"];
|
|
228
|
+
}
|
|
229
|
+
return cloneElement(child, childProps);
|
|
230
|
+
}
|
|
231
|
+
function reportUnsupportedServerChild(kind, isDev) {
|
|
232
|
+
const message = kind === "lazy" ? "Using a Lazy Component as a direct child of `<Link legacyBehavior>` from a Server Component is not supported. If you need legacyBehavior, wrap your Lazy Component in a Client Component that renders the Link's `<a>` tag." : "Using a Server Component as a direct child of `<Link legacyBehavior>` is not supported. If you need legacyBehavior, wrap your Server Component in a Client Component that renders the Link's `<a>` tag.";
|
|
233
|
+
console.error(isDev ? validationError(message, "E394") : message);
|
|
234
|
+
}
|
|
235
|
+
function unsupportedLegacyChildError() {
|
|
236
|
+
return validationError("`<Link legacyBehavior>` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's `<a>` tag.", "E863");
|
|
237
|
+
}
|
|
238
|
+
var deprecationWarned = false;
|
|
239
|
+
function reportLegacyDeprecation() {
|
|
240
|
+
if (deprecationWarned || typeof window === "undefined" || true) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
deprecationWarned = true;
|
|
244
|
+
console.error("`legacyBehavior` is deprecated and will be removed in a future release. A codemod is available to upgrade your components:\n\n" + `npx @next/codemod@latest new-link .
|
|
245
|
+
|
|
246
|
+
` + "Learn more: https://nextjs.org/docs/app/building-your-application/upgrading/codemods#remove-a-tags-from-link-components");
|
|
247
|
+
}
|
|
248
|
+
function validationError(message, digest) {
|
|
249
|
+
return Object.assign(new Error(message), { digest });
|
|
250
|
+
}
|
|
251
|
+
function childrenOnlyOrThrow(children) {
|
|
252
|
+
const array = toChildArray(children);
|
|
253
|
+
if (array.length === 1 && isValidElementLike(array[0]))
|
|
254
|
+
return array[0];
|
|
255
|
+
throw new Error("React.Children.only expected to receive a single React element child.");
|
|
256
|
+
}
|
|
257
|
+
function isValidElementLike(value) {
|
|
258
|
+
return value !== null && typeof value === "object" && "type" in value;
|
|
259
|
+
}
|
|
260
|
+
function isAsyncFunctionComponent(type) {
|
|
261
|
+
if (typeof type !== "function")
|
|
262
|
+
return false;
|
|
263
|
+
const asyncFunctionName = Object.prototype.toString.call(type);
|
|
264
|
+
return asyncFunctionName === "[object AsyncFunction]";
|
|
265
|
+
}
|
|
266
|
+
function isLazyComponent(type) {
|
|
267
|
+
if (type === null || typeof type !== "object" && typeof type !== "function")
|
|
268
|
+
return false;
|
|
269
|
+
const marked = type;
|
|
270
|
+
return marked.$$typeof === Symbol.for("react.lazy") || marked[Symbol.for("pnext.lazy")] === true;
|
|
271
|
+
}
|
|
272
|
+
function isServerComponent(type) {
|
|
273
|
+
if (isClientComponent(type))
|
|
274
|
+
return false;
|
|
275
|
+
return typeof type === "function" && type.$$typeof === undefined;
|
|
276
|
+
}
|
|
277
|
+
function isClientComponent(type) {
|
|
278
|
+
return (typeof type === "object" || typeof type === "function") && type.$$typeof === reactClientReferenceSymbol;
|
|
279
|
+
}
|
|
280
|
+
function useComposedRef(internalRef, userRef) {
|
|
281
|
+
return (node) => {
|
|
282
|
+
internalRef.current = node;
|
|
283
|
+
assignRef(userRef, node);
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function assignRef(ref, node) {
|
|
287
|
+
if (!ref)
|
|
288
|
+
return;
|
|
289
|
+
if (typeof ref === "function") {
|
|
290
|
+
ref(node);
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
ref.current = node;
|
|
294
|
+
}
|
|
295
|
+
function hrefString(href) {
|
|
296
|
+
if (typeof href === "string")
|
|
297
|
+
return href;
|
|
298
|
+
if (href instanceof URL)
|
|
299
|
+
return href.toString();
|
|
300
|
+
return routeHref(href.pathname ?? "", { search: href.query, hash: href.hash });
|
|
301
|
+
}
|
|
302
|
+
function nextPrefetchMode(prefetch) {
|
|
303
|
+
return prefetch === false ? false : "visible";
|
|
304
|
+
}
|
|
305
|
+
function isExternalHref(href) {
|
|
306
|
+
if (typeof window === "undefined")
|
|
307
|
+
return false;
|
|
308
|
+
try {
|
|
309
|
+
return new URL(href, window.location.href).origin !== window.location.origin;
|
|
310
|
+
} catch {
|
|
311
|
+
return true;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function navigationEvent() {
|
|
315
|
+
return {
|
|
316
|
+
defaultPrevented: false,
|
|
317
|
+
preventDefault() {
|
|
318
|
+
this.defaultPrevented = true;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
function isPlainLeftClick(event) {
|
|
323
|
+
return event.button === 0 && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey && isSelfTarget(event.currentTarget.target) && !event.currentTarget.hasAttribute("download");
|
|
324
|
+
}
|
|
325
|
+
function isSelfTarget(target) {
|
|
326
|
+
return target === "" || target === "_self";
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export { Link, useLinkStatus, link_default };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/utils/trace-flags.ts
|
|
3
|
+
function parseTraceFlags(raw) {
|
|
4
|
+
const scopes = new Map;
|
|
5
|
+
for (const entry of raw?.split(",") ?? []) {
|
|
6
|
+
const trimmed = entry.trim();
|
|
7
|
+
if (!trimmed)
|
|
8
|
+
continue;
|
|
9
|
+
const eq = trimmed.indexOf("=");
|
|
10
|
+
const name = eq === -1 ? trimmed : trimmed.slice(0, eq).trim();
|
|
11
|
+
if (!name)
|
|
12
|
+
continue;
|
|
13
|
+
scopes.set(name === "1" ? "boot" : name, eq === -1 ? "" : trimmed.slice(eq + 1).trim());
|
|
14
|
+
}
|
|
15
|
+
return scopes;
|
|
16
|
+
}
|
|
17
|
+
var scopes;
|
|
18
|
+
var all = false;
|
|
19
|
+
function flags() {
|
|
20
|
+
if (!scopes) {
|
|
21
|
+
scopes = parseTraceFlags(process.env.PNEXT_TRACE);
|
|
22
|
+
all = scopes.has("all");
|
|
23
|
+
}
|
|
24
|
+
return scopes;
|
|
25
|
+
}
|
|
26
|
+
function traceEnabled(scope) {
|
|
27
|
+
return flags().has(scope) || all;
|
|
28
|
+
}
|
|
29
|
+
function traceValue(scope) {
|
|
30
|
+
return flags().get(scope) || undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { traceEnabled, traceValue };
|