@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,84 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
hooksUsable
|
|
4
|
+
} from "./index-j2zrcp1k.js";
|
|
5
|
+
|
|
6
|
+
// src/compat/react/action-state.ts
|
|
7
|
+
import { useCallback, useRef, useState } from "preact/hooks";
|
|
8
|
+
function useActionState(action, initialState, _permalink) {
|
|
9
|
+
if (!hooksUsable()) {
|
|
10
|
+
const staticInitial = (consumeActionStateOverride() ?? { value: initialState }).value;
|
|
11
|
+
const staticDispatch = (payload) => void Promise.resolve(action(staticInitial, payload));
|
|
12
|
+
tagFormStateDispatch(staticDispatch, action, staticInitial, _permalink);
|
|
13
|
+
return [staticInitial, staticDispatch, false];
|
|
14
|
+
}
|
|
15
|
+
const initialRef = useRef(null);
|
|
16
|
+
if (!initialRef.current) {
|
|
17
|
+
initialRef.current = {
|
|
18
|
+
value: (consumeActionStateOverride() ?? { value: initialState }).value
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const [state, setState] = useState(initialRef.current.value);
|
|
22
|
+
const [pending, setPending] = useState(0);
|
|
23
|
+
const lastSettled = useRef(initialRef.current.value);
|
|
24
|
+
const chain = useRef(Promise.resolve());
|
|
25
|
+
const pendingError = useRef(null);
|
|
26
|
+
const [, forceRender] = useState(0);
|
|
27
|
+
const dispatch = useCallback((payload) => {
|
|
28
|
+
setPending((count) => count + 1);
|
|
29
|
+
chain.current = chain.current.then(async () => {
|
|
30
|
+
try {
|
|
31
|
+
const redirectsBefore = actionRedirectCount();
|
|
32
|
+
const next = await action(lastSettled.current, payload);
|
|
33
|
+
if (next === undefined && actionRedirectCount() !== redirectsBefore) {
|
|
34
|
+
lastSettled.current = initialRef.current.value;
|
|
35
|
+
setState(() => initialRef.current.value);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
lastSettled.current = next;
|
|
39
|
+
setState(() => next);
|
|
40
|
+
} finally {
|
|
41
|
+
setPending((count) => count - 1);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
chain.current = chain.current.catch((error) => {
|
|
45
|
+
if (typeof window === "undefined")
|
|
46
|
+
return;
|
|
47
|
+
pendingError.current = { error };
|
|
48
|
+
forceRender((count) => count + 1);
|
|
49
|
+
});
|
|
50
|
+
}, [action]);
|
|
51
|
+
if (pendingError.current) {
|
|
52
|
+
const { error } = pendingError.current;
|
|
53
|
+
pendingError.current = null;
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
tagFormStateDispatch(dispatch, action, state, _permalink);
|
|
57
|
+
return [state, dispatch, pending > 0];
|
|
58
|
+
}
|
|
59
|
+
function tagFormStateDispatch(dispatch, action, state, permalink) {
|
|
60
|
+
dispatch.$$pnextFormState = {
|
|
61
|
+
action,
|
|
62
|
+
state,
|
|
63
|
+
...permalink !== undefined ? { permalink } : {}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function actionRedirectCount() {
|
|
67
|
+
return globalThis.__pnextActionRedirects ?? 0;
|
|
68
|
+
}
|
|
69
|
+
function consumeActionStateOverride() {
|
|
70
|
+
const holder = globalThis;
|
|
71
|
+
if (!("__PNEXT_ACTION_STATE__" in holder))
|
|
72
|
+
return;
|
|
73
|
+
const override = holder.__PNEXT_ACTION_STATE__;
|
|
74
|
+
if (override !== null && typeof override === "object" && "skip" in override && typeof override.skip === "number" && override.skip > 0) {
|
|
75
|
+
override.skip--;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
delete holder.__PNEXT_ACTION_STATE__;
|
|
79
|
+
return {
|
|
80
|
+
value: override !== null && typeof override === "object" && "value" in override ? override.value : override
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { useActionState, consumeActionStateOverride };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/compat/next/telemetry.ts
|
|
3
|
+
var EVENT_CLI_SESSION_STARTED = "NEXT_CLI_SESSION_STARTED";
|
|
4
|
+
var EVENT_BUILD_FEATURE_USAGE = "NEXT_BUILD_FEATURE_USAGE";
|
|
5
|
+
var emitted = false;
|
|
6
|
+
var featureUsageEmitted = false;
|
|
7
|
+
function configuredStaleTimes(config) {
|
|
8
|
+
const experimental = config.experimental;
|
|
9
|
+
if (!experimental || typeof experimental !== "object")
|
|
10
|
+
return {};
|
|
11
|
+
const staleTimes = experimental.staleTimes;
|
|
12
|
+
if (!staleTimes || typeof staleTimes !== "object")
|
|
13
|
+
return {};
|
|
14
|
+
const value = staleTimes;
|
|
15
|
+
return {
|
|
16
|
+
...typeof value.static === "number" ? { static: value.static } : {},
|
|
17
|
+
...typeof value.dynamic === "number" ? { dynamic: value.dynamic } : {}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function emitSessionStartedTelemetry(config) {
|
|
21
|
+
if (emitted)
|
|
22
|
+
return;
|
|
23
|
+
if (!process.env.NEXT_TELEMETRY_DEBUG)
|
|
24
|
+
return;
|
|
25
|
+
emitted = true;
|
|
26
|
+
const staleTimes = configuredStaleTimes(config);
|
|
27
|
+
const event = {
|
|
28
|
+
eventName: EVENT_CLI_SESSION_STARTED,
|
|
29
|
+
payload: {
|
|
30
|
+
nodeVersion: process.version,
|
|
31
|
+
cliCommand: process.argv[2] ?? "unknown",
|
|
32
|
+
staticStaleTime: staleTimes.static ?? null,
|
|
33
|
+
dynamicStaleTime: staleTimes.dynamic ?? null
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
console.log(`[telemetry] ${JSON.stringify(event, null, 2)}`);
|
|
37
|
+
}
|
|
38
|
+
function emitBuildFeatureUsageTelemetry(config) {
|
|
39
|
+
if (featureUsageEmitted)
|
|
40
|
+
return;
|
|
41
|
+
if (!process.env.NEXT_TELEMETRY_DEBUG)
|
|
42
|
+
return;
|
|
43
|
+
if ((process.argv[2] ?? "") !== "build")
|
|
44
|
+
return;
|
|
45
|
+
featureUsageEmitted = true;
|
|
46
|
+
const experimental = config.experimental;
|
|
47
|
+
const esmExternals = experimental && typeof experimental === "object" ? experimental.esmExternals : undefined;
|
|
48
|
+
if (esmExternals !== undefined && esmExternals !== true) {
|
|
49
|
+
console.log(`[telemetry] ${JSON.stringify({
|
|
50
|
+
eventName: EVENT_BUILD_FEATURE_USAGE,
|
|
51
|
+
payload: { featureName: "esmExternals", invocationCount: 1 }
|
|
52
|
+
}, null, 2)}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { emitSessionStartedTelemetry, emitBuildFeatureUsageTelemetry };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/compat/actions/unrecognized-error.ts
|
|
3
|
+
class UnrecognizedActionError extends Error {
|
|
4
|
+
constructor(...args) {
|
|
5
|
+
super(...args);
|
|
6
|
+
this.name = "UnrecognizedActionError";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function isUnrecognizedActionError(error) {
|
|
10
|
+
if (error instanceof UnrecognizedActionError)
|
|
11
|
+
return true;
|
|
12
|
+
return error instanceof Error && (error.name === "UnrecognizedActionError" || / was not found on the server\.?$/.test(error.message));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { isUnrecognizedActionError };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/utils/ansi.ts
|
|
3
|
+
function color(open, close) {
|
|
4
|
+
return (value) => process.stdout.isTTY && !process.env.NO_COLOR ? `${open}${value}${close}` : value;
|
|
5
|
+
}
|
|
6
|
+
var dim = color("\x1B[38;5;244m", "\x1B[39m");
|
|
7
|
+
var bold = color("\x1B[1m", "\x1B[22m");
|
|
8
|
+
var cyan = color("\x1B[36m", "\x1B[39m");
|
|
9
|
+
var green = color("\x1B[32m", "\x1B[39m");
|
|
10
|
+
|
|
11
|
+
export { dim, bold, cyan, green };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/compat/actions/ids.ts
|
|
3
|
+
import { createHash } from "crypto";
|
|
4
|
+
import path from "path";
|
|
5
|
+
function actionId(filePath, exportName, root) {
|
|
6
|
+
const key = workspaceRelative(filePath, root);
|
|
7
|
+
return createHash("sha256").update(key).update("\x00").update(exportName).digest("hex").slice(0, 12);
|
|
8
|
+
}
|
|
9
|
+
function workspaceRelative(filePath, root) {
|
|
10
|
+
const rel = root ? path.relative(root, filePath) : filePath;
|
|
11
|
+
return toPosix(rel);
|
|
12
|
+
}
|
|
13
|
+
function toPosix(value) {
|
|
14
|
+
return value.split(path.sep).join("/");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/compat/actions/detect.ts
|
|
18
|
+
var DIRECTIVE = /^(['"])use server\1\s*;?$/;
|
|
19
|
+
var CACHE_DIRECTIVE = /^(['"])use cache\1\s*;?$/;
|
|
20
|
+
function moduleLevelUseServer(source) {
|
|
21
|
+
const first = firstStatementText(stripLeading(source));
|
|
22
|
+
return first !== undefined && DIRECTIVE.test(first.trim());
|
|
23
|
+
}
|
|
24
|
+
function moduleLevelUseCache(source) {
|
|
25
|
+
const first = firstStatementText(stripLeading(source));
|
|
26
|
+
return first !== undefined && CACHE_DIRECTIVE.test(first.trim());
|
|
27
|
+
}
|
|
28
|
+
function inlineUseServerFunctions(source) {
|
|
29
|
+
const found = [];
|
|
30
|
+
const seen = new Set;
|
|
31
|
+
const fnDecl = /(\bexport\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\([^)]*\)\s*\{\s*(['"])use server\3\s*;?/g;
|
|
32
|
+
collect(fnDecl, source, found, seen, { nameGroup: 2, exportGroup: 1, dirGroup: 3 });
|
|
33
|
+
const arrowOrExpr = /(\bexport\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(?:async\s+)?(?:\([^)]*\)|[A-Za-z_$][\w$]*|function\s*\*?\s*\([^)]*\))\s*(?:=>\s*)?\{\s*(['"])use server\3\s*;?/g;
|
|
34
|
+
collect(arrowOrExpr, source, found, seen, { nameGroup: 2, exportGroup: 1, dirGroup: 3 });
|
|
35
|
+
return found.sort((a, b) => a.start - b.start);
|
|
36
|
+
}
|
|
37
|
+
function collect(pattern, source, out, seen, groups) {
|
|
38
|
+
let match;
|
|
39
|
+
while (match = pattern.exec(source)) {
|
|
40
|
+
const name = match[groups.nameGroup];
|
|
41
|
+
if (!name || seen.has(name))
|
|
42
|
+
continue;
|
|
43
|
+
seen.add(name);
|
|
44
|
+
out.push({
|
|
45
|
+
name,
|
|
46
|
+
exported: Boolean(match[groups.exportGroup]),
|
|
47
|
+
start: match.index,
|
|
48
|
+
directiveEnd: match.index + match[0].length
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function moduleActionExports(source) {
|
|
53
|
+
const names = new Set;
|
|
54
|
+
const declRe = /\bexport\s+(?:async\s+)?(?:function\s*\*?\s+|const\s+|let\s+|var\s+|class\s+)([A-Za-z_$][\w$]*)/g;
|
|
55
|
+
for (let m;m = declRe.exec(source); )
|
|
56
|
+
if (m[1])
|
|
57
|
+
names.add(m[1]);
|
|
58
|
+
if (/\bexport\s+default\b/.test(source))
|
|
59
|
+
names.add("default");
|
|
60
|
+
const listRe = /\bexport\s+(?!type\b)\{([^}]*)\}/g;
|
|
61
|
+
for (let m;m = listRe.exec(source); ) {
|
|
62
|
+
for (const part of (m[1] ?? "").split(",")) {
|
|
63
|
+
const trimmed = part.trim();
|
|
64
|
+
if (!trimmed || trimmed.startsWith("type "))
|
|
65
|
+
continue;
|
|
66
|
+
const exportedName = /\bas\s+([A-Za-z_$][\w$]*)\s*$/.exec(trimmed)?.[1];
|
|
67
|
+
const name = exportedName ?? trimmed;
|
|
68
|
+
if (/^[A-Za-z_$][\w$]*$/.test(name))
|
|
69
|
+
names.add(name);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return [...names];
|
|
73
|
+
}
|
|
74
|
+
function stripLeading(source) {
|
|
75
|
+
let s = source.replace(/^\uFEFF/, "");
|
|
76
|
+
if (s.startsWith("#!")) {
|
|
77
|
+
const nl = s.indexOf(`
|
|
78
|
+
`);
|
|
79
|
+
s = nl === -1 ? "" : s.slice(nl + 1);
|
|
80
|
+
}
|
|
81
|
+
return s;
|
|
82
|
+
}
|
|
83
|
+
function firstStatementText(source) {
|
|
84
|
+
let i = 0;
|
|
85
|
+
const n = source.length;
|
|
86
|
+
while (i < n) {
|
|
87
|
+
const ch = source[i];
|
|
88
|
+
if (ch === " " || ch === "\t" || ch === "\r" || ch === `
|
|
89
|
+
`) {
|
|
90
|
+
i++;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (ch === "/" && source[i + 1] === "/") {
|
|
94
|
+
const nl = source.indexOf(`
|
|
95
|
+
`, i);
|
|
96
|
+
if (nl === -1)
|
|
97
|
+
return;
|
|
98
|
+
i = nl + 1;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (ch === "/" && source[i + 1] === "*") {
|
|
102
|
+
const end2 = source.indexOf("*/", i + 2);
|
|
103
|
+
if (end2 === -1)
|
|
104
|
+
return;
|
|
105
|
+
i = end2 + 2;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
if (i >= n)
|
|
111
|
+
return;
|
|
112
|
+
let j = i;
|
|
113
|
+
while (j < n && source[j] !== `
|
|
114
|
+
` && source[j] !== ";")
|
|
115
|
+
j++;
|
|
116
|
+
const end = source[j] === ";" ? j + 1 : j;
|
|
117
|
+
return source.slice(i, end);
|
|
118
|
+
}
|
|
119
|
+
function opensWithUseServerDirective(fn) {
|
|
120
|
+
if (typeof fn !== "function")
|
|
121
|
+
return false;
|
|
122
|
+
let source;
|
|
123
|
+
try {
|
|
124
|
+
source = String(fn);
|
|
125
|
+
} catch {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
const body = source.indexOf("{", source.indexOf(")") + 1);
|
|
129
|
+
if (body === -1)
|
|
130
|
+
return false;
|
|
131
|
+
return /^\s*(['"])use server\1/.test(source.slice(body + 1));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { actionId, workspaceRelative, moduleLevelUseServer, moduleLevelUseCache, inlineUseServerFunctions, moduleActionExports, opensWithUseServerDirective };
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import { join as __pnextJoin } from "node:path";
|
|
3
|
+
const __PNEXT_PACKAGE_ROOT__ = __pnextJoin(import.meta.dirname, "../../..");
|
|
4
|
+
import {
|
|
5
|
+
standaloneOutSegment
|
|
6
|
+
} from "./index-bzd2ef7t.js";
|
|
7
|
+
import {
|
|
8
|
+
attachRelease,
|
|
9
|
+
buildIndexFile,
|
|
10
|
+
linkStandaloneOrigins,
|
|
11
|
+
readBuildIndex,
|
|
12
|
+
releaseConfig,
|
|
13
|
+
releaseSourceRoot,
|
|
14
|
+
servingReleaseDir
|
|
15
|
+
} from "./index-hdbwtdv2.js";
|
|
16
|
+
import {
|
|
17
|
+
setLegacyRequestAPIs
|
|
18
|
+
} from "./index-grta8ap3.js";
|
|
19
|
+
import {
|
|
20
|
+
setCacheComponents
|
|
21
|
+
} from "./index-kresp2n8.js";
|
|
22
|
+
import {
|
|
23
|
+
findWorkspaceRoot
|
|
24
|
+
} from "./index-pym1cezq.js";
|
|
25
|
+
import {
|
|
26
|
+
__require
|
|
27
|
+
} from "./index-rt9qq1va.js";
|
|
28
|
+
|
|
29
|
+
// src/config.ts
|
|
30
|
+
import { existsSync, realpathSync } from "fs";
|
|
31
|
+
import { fileURLToPath, pathToFileURL } from "url";
|
|
32
|
+
import path2 from "path";
|
|
33
|
+
|
|
34
|
+
// src/env.ts
|
|
35
|
+
import { readFile, stat } from "fs/promises";
|
|
36
|
+
import path from "path";
|
|
37
|
+
import { parse } from "dotenv";
|
|
38
|
+
async function loadEnv(root, options = {}) {
|
|
39
|
+
const nodeEnvKey = "NODE_ENV";
|
|
40
|
+
const env = process.env;
|
|
41
|
+
if (!env[nodeEnvKey])
|
|
42
|
+
env[nodeEnvKey] = options.dev ? "development" : "production";
|
|
43
|
+
const mode = process.env[nodeEnvKey] ?? "production";
|
|
44
|
+
const loadedEnvFiles = [];
|
|
45
|
+
for (const file of envFilesForMode(mode)) {
|
|
46
|
+
const filePath = path.join(root, file);
|
|
47
|
+
if (!await isEnvFile(filePath))
|
|
48
|
+
continue;
|
|
49
|
+
const parsed = parse(await readFile(filePath, "utf8"));
|
|
50
|
+
const env2 = expandEnv(parsed);
|
|
51
|
+
for (const [key, value] of Object.entries(env2)) {
|
|
52
|
+
if (process.env[key] === undefined)
|
|
53
|
+
process.env[key] = value;
|
|
54
|
+
}
|
|
55
|
+
loadedEnvFiles.push({ path: file, env: env2 });
|
|
56
|
+
}
|
|
57
|
+
return { mode, loadedEnvFiles };
|
|
58
|
+
}
|
|
59
|
+
function envFilesForMode(mode) {
|
|
60
|
+
return [
|
|
61
|
+
`.env.${mode}.local`,
|
|
62
|
+
mode === "test" ? undefined : ".env.local",
|
|
63
|
+
`.env.${mode}`,
|
|
64
|
+
".env"
|
|
65
|
+
].filter((file) => Boolean(file));
|
|
66
|
+
}
|
|
67
|
+
async function isEnvFile(file) {
|
|
68
|
+
try {
|
|
69
|
+
const info = await stat(file);
|
|
70
|
+
return info.isFile();
|
|
71
|
+
} catch (error) {
|
|
72
|
+
if (error.code === "ENOENT")
|
|
73
|
+
return false;
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function expandEnv(parsed) {
|
|
78
|
+
const env = {};
|
|
79
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
80
|
+
env[key] = expandValue(value, { ...parsed, ...env });
|
|
81
|
+
}
|
|
82
|
+
return env;
|
|
83
|
+
}
|
|
84
|
+
function expandValue(value, parsed) {
|
|
85
|
+
let result = value;
|
|
86
|
+
for (let index = searchLastEnvReference(result), attempts = 0;index !== -1 && attempts < 100; index = searchLastEnvReference(result), attempts += 1) {
|
|
87
|
+
const match = result.slice(index).match(/^\$({?)([\w]+)(?::-([^}]*))?}?/);
|
|
88
|
+
if (!match)
|
|
89
|
+
break;
|
|
90
|
+
const token = match[0] ?? "";
|
|
91
|
+
const braced = match[1] ?? "";
|
|
92
|
+
const key = match[2] ?? "";
|
|
93
|
+
const fallback = match[3] ?? "";
|
|
94
|
+
const hasClosingBrace = braced ? token.endsWith("}") : true;
|
|
95
|
+
if (!hasClosingBrace)
|
|
96
|
+
break;
|
|
97
|
+
const replacement = process.env[key] || fallback || parsed[key] || "";
|
|
98
|
+
result = `${result.slice(0, index)}${replacement}${result.slice(index + token.length)}`;
|
|
99
|
+
}
|
|
100
|
+
return result.replace(/\\\$/g, "$");
|
|
101
|
+
}
|
|
102
|
+
function searchLastEnvReference(value) {
|
|
103
|
+
const matches = [...value.matchAll(/(?<!\\)\$/g)];
|
|
104
|
+
return matches.length > 0 ? matches.at(-1)?.index ?? -1 : -1;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/types.ts
|
|
108
|
+
var PREFETCH_MODES = ["visible", "intent", "load", false];
|
|
109
|
+
|
|
110
|
+
// src/config.ts
|
|
111
|
+
var DEFAULT_OUT_DIR = ".pnext";
|
|
112
|
+
var defaultConfig = {
|
|
113
|
+
outDir: DEFAULT_OUT_DIR,
|
|
114
|
+
basePath: ""
|
|
115
|
+
};
|
|
116
|
+
var configSource;
|
|
117
|
+
function registerConfigSource(source) {
|
|
118
|
+
configSource = source;
|
|
119
|
+
}
|
|
120
|
+
async function resolveConfigSource(config, root, options) {
|
|
121
|
+
if (!config.compat?.next)
|
|
122
|
+
return {};
|
|
123
|
+
if (!configSource) {
|
|
124
|
+
await import("./config-0tvz03a6.js").then((module) => module.registerConfigSource());
|
|
125
|
+
}
|
|
126
|
+
if (!configSource)
|
|
127
|
+
return {};
|
|
128
|
+
return configSource(root, options);
|
|
129
|
+
}
|
|
130
|
+
async function loadConfig(rootInput = process.cwd(), options = {}) {
|
|
131
|
+
const root = canonicalRoot(path2.resolve(rootInput));
|
|
132
|
+
const released = options.serve ? servingReleaseDir() : undefined;
|
|
133
|
+
if (released)
|
|
134
|
+
return loadReleasedConfig(root, released, options);
|
|
135
|
+
await loadEnv(root, options);
|
|
136
|
+
const configPath = path2.join(root, "pnext.config.ts");
|
|
137
|
+
const loadedConfig = existsSync(configPath) ? await import(pathToFileHref(configPath)) : {};
|
|
138
|
+
const config = {
|
|
139
|
+
...loadedConfig.default ?? {},
|
|
140
|
+
...process.env.PNEXT_COMPAT === "next" ? {
|
|
141
|
+
compat: {
|
|
142
|
+
...loadedConfig.default?.compat ?? {},
|
|
143
|
+
next: loadedConfig.default?.compat?.next || true
|
|
144
|
+
}
|
|
145
|
+
} : {}
|
|
146
|
+
};
|
|
147
|
+
validateConfig(config);
|
|
148
|
+
setLegacyRequestAPIs(typeof config.compat?.next === "object" && config.compat.next.legacyRequestAPIs === true);
|
|
149
|
+
setCacheComponents(false);
|
|
150
|
+
const sourceOverrides = stripUndefined(await resolveConfigSource(config, root, options));
|
|
151
|
+
const merged = { ...defaultConfig, ...config, ...sourceOverrides };
|
|
152
|
+
const outRootPath = path2.resolve(root, merged.outDir);
|
|
153
|
+
const release = path2.join(outRootPath, standaloneOutSegment);
|
|
154
|
+
if (options.serve && existsSync(buildIndexFile(release))) {
|
|
155
|
+
return loadReleasedConfig(root, release, { ...options, warnings: false });
|
|
156
|
+
}
|
|
157
|
+
const appPath = await resolveAppPath(root, config, options.dev ? undefined : path2.join(outRootPath, "pnext-pages-compat"));
|
|
158
|
+
const workspaceRoot = canonicalRoot(config.workspaceRoot ? path2.resolve(root, config.workspaceRoot) : findWorkspaceRoot(root) ?? root);
|
|
159
|
+
return {
|
|
160
|
+
...config,
|
|
161
|
+
trailingSlash: merged.trailingSlash ?? config.trailingSlash,
|
|
162
|
+
productionBrowserSourceMaps: merged.productionBrowserSourceMaps ?? config.productionBrowserSourceMaps,
|
|
163
|
+
skipTrailingSlashRedirect: merged.skipTrailingSlashRedirect ?? config.skipTrailingSlashRedirect,
|
|
164
|
+
appDir: path2.relative(root, appPath),
|
|
165
|
+
publicDir: "public",
|
|
166
|
+
outDir: merged.outDir,
|
|
167
|
+
basePath: merged.basePath,
|
|
168
|
+
assetPrefix: merged.assetPrefix ?? merged.basePath,
|
|
169
|
+
root,
|
|
170
|
+
workspaceRoot,
|
|
171
|
+
appPath,
|
|
172
|
+
publicPath: path2.resolve(root, "public"),
|
|
173
|
+
outPath: path2.join(outRootPath, options.dev ? devOutSegment : standaloneOutSegment),
|
|
174
|
+
outRootPath,
|
|
175
|
+
typesPath: path2.join(outRootPath, "types"),
|
|
176
|
+
checksPath: path2.join(outRootPath, "typecheck", "checks")
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
async function loadReleasedConfig(root, outPath, options) {
|
|
180
|
+
const index = readBuildIndex(outPath);
|
|
181
|
+
linkStandaloneOrigins(outPath);
|
|
182
|
+
const sourceRoot = releaseSourceRoot(outPath, index.config.outPath);
|
|
183
|
+
const config = releaseConfig(index.config, sourceRoot, outPath);
|
|
184
|
+
await loadEnv(root, options);
|
|
185
|
+
setLegacyRequestAPIs(typeof config.compat?.next === "object" && config.compat.next.legacyRequestAPIs === true);
|
|
186
|
+
setCacheComponents(false);
|
|
187
|
+
await resolveConfigSource(config, root, {
|
|
188
|
+
...options,
|
|
189
|
+
bundle: index.nextConfig ? path2.resolve(outPath, index.nextConfig) : null,
|
|
190
|
+
handlers: Object.fromEntries(Object.entries(index.compat?.cacheHandlers ?? {}).map(([name, file]) => [
|
|
191
|
+
name,
|
|
192
|
+
path2.resolve(outPath, file)
|
|
193
|
+
]))
|
|
194
|
+
});
|
|
195
|
+
attachRelease(config, index);
|
|
196
|
+
return config;
|
|
197
|
+
}
|
|
198
|
+
var enumFields = [
|
|
199
|
+
["prefetch", PREFETCH_MODES]
|
|
200
|
+
];
|
|
201
|
+
function validateConfig(config) {
|
|
202
|
+
for (const [field, allowed] of enumFields) {
|
|
203
|
+
const value = config[field];
|
|
204
|
+
if (value === undefined || allowed.includes(value))
|
|
205
|
+
continue;
|
|
206
|
+
const list = allowed.map((v) => typeof v === "string" ? `'${v}'` : String(v)).join(", ");
|
|
207
|
+
throw new Error(`Invalid pnext config: '${field}' must be one of ${list} (received ${JSON.stringify(value)}).`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
var devOutSegment = "dev";
|
|
211
|
+
function canonicalRoot(dir) {
|
|
212
|
+
try {
|
|
213
|
+
return realpathSync(dir);
|
|
214
|
+
} catch {
|
|
215
|
+
return dir;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function stripUndefined(value) {
|
|
219
|
+
return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined));
|
|
220
|
+
}
|
|
221
|
+
function pathToFileHref(filePath) {
|
|
222
|
+
return pathToFileURL(path2.resolve(filePath)).href;
|
|
223
|
+
}
|
|
224
|
+
function publicEnvDefines() {
|
|
225
|
+
const publicEnv = Object.fromEntries([
|
|
226
|
+
["NODE_ENV", "production"],
|
|
227
|
+
...Object.entries(process.env).filter(([key]) => key.startsWith("NEXT_PUBLIC_") || key.startsWith("PNEXT_PUBLIC_"))
|
|
228
|
+
]);
|
|
229
|
+
return {
|
|
230
|
+
"process.env": JSON.stringify(publicEnv),
|
|
231
|
+
...Object.fromEntries(Object.entries(publicEnv).map(([key, value]) => [
|
|
232
|
+
`process.env.${key}`,
|
|
233
|
+
JSON.stringify(value)
|
|
234
|
+
]))
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
var frameworkRuntimeAliases;
|
|
238
|
+
function frameworkRuntimeAliasEntries() {
|
|
239
|
+
frameworkRuntimeAliases ??= {
|
|
240
|
+
preact: resolveRuntimeModule("preact"),
|
|
241
|
+
"preact/hooks": resolveRuntimeModule("preact/hooks"),
|
|
242
|
+
"preact/compat": resolveRuntimeModule("preact/compat"),
|
|
243
|
+
"preact/compat/client": resolveRuntimeModule("preact/compat/client"),
|
|
244
|
+
"preact/jsx-runtime": resolveRuntimeModule("preact/jsx-runtime"),
|
|
245
|
+
"preact/jsx-dev-runtime": resolveRuntimeModule("preact/jsx-dev-runtime"),
|
|
246
|
+
"react-compiler-runtime": resolveRuntimeModule("react-compiler-runtime")
|
|
247
|
+
};
|
|
248
|
+
return frameworkRuntimeAliases;
|
|
249
|
+
}
|
|
250
|
+
var frameworkRuntimeSpecifiers = () => Object.keys(frameworkRuntimeAliasEntries());
|
|
251
|
+
function resolveRuntimeModule(specifier) {
|
|
252
|
+
return fileURLToPath(import.meta.resolve(specifier));
|
|
253
|
+
}
|
|
254
|
+
function pnextAliases(target) {
|
|
255
|
+
if (target !== "client")
|
|
256
|
+
return {};
|
|
257
|
+
return {
|
|
258
|
+
"@wular/pnext/cache": path2.resolve(__PNEXT_PACKAGE_ROOT__ + "/src", "api/client-cache.ts")
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
async function resolveAppPath(root, config, pagesBase) {
|
|
262
|
+
const rootApp = path2.join(root, "app");
|
|
263
|
+
if (config.compat?.next) {
|
|
264
|
+
const pagesPath = path2.join(root, "pages");
|
|
265
|
+
const hasPages = existsSync(pagesPath);
|
|
266
|
+
if (existsSync(rootApp)) {
|
|
267
|
+
if (hasPages) {
|
|
268
|
+
const { materializePagesApp: materializePagesApp2 } = await import("./router-xnrva921.js");
|
|
269
|
+
const hybrid = await materializePagesApp2(root, pagesBase);
|
|
270
|
+
if (hybrid)
|
|
271
|
+
return hybrid;
|
|
272
|
+
}
|
|
273
|
+
return rootApp;
|
|
274
|
+
}
|
|
275
|
+
const { materializePagesApp } = await import("./router-xnrva921.js");
|
|
276
|
+
const pagesApp = await materializePagesApp(root, pagesBase);
|
|
277
|
+
if (pagesApp)
|
|
278
|
+
return pagesApp;
|
|
279
|
+
} else if (existsSync(rootApp))
|
|
280
|
+
return rootApp;
|
|
281
|
+
return path2.join(root, "src", "app");
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export { DEFAULT_OUT_DIR, registerConfigSource, loadConfig, devOutSegment, pathToFileHref, publicEnvDefines, frameworkRuntimeAliasEntries, frameworkRuntimeSpecifiers, pnextAliases };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
dim
|
|
4
|
+
} from "./index-6kp9r0d9.js";
|
|
5
|
+
|
|
6
|
+
// src/utils/verbose.ts
|
|
7
|
+
function createVerboseLogger(enabled, scope) {
|
|
8
|
+
const prefix = dim(`pnext ${scope}`);
|
|
9
|
+
const write = (message) => console.log(`${prefix} ${dim(`@${(performance.now() / 1000).toFixed(2)}s`)} ${message}`);
|
|
10
|
+
return {
|
|
11
|
+
enabled,
|
|
12
|
+
log(message) {
|
|
13
|
+
if (enabled)
|
|
14
|
+
write(message);
|
|
15
|
+
},
|
|
16
|
+
async step(label, task) {
|
|
17
|
+
if (!enabled)
|
|
18
|
+
return task();
|
|
19
|
+
write(label);
|
|
20
|
+
const start = performance.now();
|
|
21
|
+
try {
|
|
22
|
+
return await task();
|
|
23
|
+
} finally {
|
|
24
|
+
write(` ${dim(`\u21B3 ${label} ${formatDuration(performance.now() - start)}`)}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function formatDuration(durationMs) {
|
|
30
|
+
const ms = Math.max(0, durationMs);
|
|
31
|
+
if (ms < 10)
|
|
32
|
+
return `${ms.toFixed(1)}ms`;
|
|
33
|
+
if (ms < 1000)
|
|
34
|
+
return `${Math.round(ms)}ms`;
|
|
35
|
+
return `${(ms / 1000).toFixed(ms < 1e4 ? 2 : 1)}s`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { createVerboseLogger, formatDuration };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/compat/client/errors/primitive-throw.ts
|
|
3
|
+
var RAW_VALUE = Symbol("pnext.primitiveThrowValue");
|
|
4
|
+
function tagPrimitiveThrow(value) {
|
|
5
|
+
const error = new Error(String(value));
|
|
6
|
+
error[RAW_VALUE] = value;
|
|
7
|
+
return error;
|
|
8
|
+
}
|
|
9
|
+
function isTaggedPrimitiveThrow(error) {
|
|
10
|
+
return error instanceof Error && RAW_VALUE in error;
|
|
11
|
+
}
|
|
12
|
+
function untagPrimitiveThrow(error) {
|
|
13
|
+
return isTaggedPrimitiveThrow(error) ? error[RAW_VALUE] : error;
|
|
14
|
+
}
|
|
15
|
+
function crashesPreactThenCheck(value) {
|
|
16
|
+
return value === null || value === undefined;
|
|
17
|
+
}
|
|
18
|
+
function retagThrow(value) {
|
|
19
|
+
return crashesPreactThenCheck(value) ? tagPrimitiveThrow(value) : value;
|
|
20
|
+
}
|
|
21
|
+
var wrapped = new WeakMap;
|
|
22
|
+
var ALREADY_WRAPPED = Symbol("pnext.primitiveThrowWrapped");
|
|
23
|
+
function wrapComponentForPrimitiveThrows(type) {
|
|
24
|
+
if (type[ALREADY_WRAPPED])
|
|
25
|
+
return type;
|
|
26
|
+
const cached = wrapped.get(type);
|
|
27
|
+
if (cached)
|
|
28
|
+
return cached;
|
|
29
|
+
if (typeof type !== "function")
|
|
30
|
+
return type;
|
|
31
|
+
const Base = type;
|
|
32
|
+
const result = type.prototype?.render ? class PrimitiveThrowSafe extends Base {
|
|
33
|
+
render(...args) {
|
|
34
|
+
try {
|
|
35
|
+
return super.render(...args);
|
|
36
|
+
} catch (e) {
|
|
37
|
+
throw retagThrow(e);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} : function pnextPrimitiveThrowSafe(...args) {
|
|
41
|
+
try {
|
|
42
|
+
return type.apply(this, args);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
throw retagThrow(e);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(result, "name", { value: Base.name });
|
|
48
|
+
for (const key of Reflect.ownKeys(Base)) {
|
|
49
|
+
if (key === "length" || key === "name" || key === "prototype")
|
|
50
|
+
continue;
|
|
51
|
+
const descriptor = Object.getOwnPropertyDescriptor(Base, key);
|
|
52
|
+
if (descriptor)
|
|
53
|
+
Object.defineProperty(result, key, descriptor);
|
|
54
|
+
}
|
|
55
|
+
Object.defineProperty(result, ALREADY_WRAPPED, { value: true });
|
|
56
|
+
wrapped.set(type, result);
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { tagPrimitiveThrow, isTaggedPrimitiveThrow, untagPrimitiveThrow, wrapComponentForPrimitiveThrows };
|