@wular/pnext 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/pnext +9 -2
- package/dist/server/_chunks/aliases-j47a10ce.js +44 -0
- package/dist/server/_chunks/analyze-arswqe6s.js +445 -0
- package/dist/server/_chunks/boot-af0mv3dy.js +36 -0
- package/dist/server/_chunks/build-spy3dxp4.js +84 -0
- package/dist/server/_chunks/build-t9h0hec3.js +3550 -0
- package/dist/server/_chunks/build-tier-m7yvqz61.js +2472 -0
- package/dist/server/_chunks/compile-53j02j27.js +22 -0
- package/dist/server/_chunks/config-1yzwexq6.js +27 -0
- package/dist/server/_chunks/config-n2z7yxps.js +22 -0
- package/dist/server/_chunks/create-meec9hs6.js +134 -0
- package/dist/server/_chunks/dev-fjmqg6en.js +220 -0
- package/dist/server/_chunks/esbuild-yyktfrtt.js +15 -0
- package/dist/server/_chunks/generate-n9sh6hzt.js +21 -0
- package/dist/server/_chunks/index-0374j2b9.js +66 -0
- package/dist/server/_chunks/index-06nyqntx.js +213 -0
- package/dist/server/_chunks/index-1011cscr.js +5263 -0
- package/dist/server/_chunks/index-11sfk4hb.js +170 -0
- package/dist/server/_chunks/index-20ppawv7.js +297 -0
- package/dist/server/_chunks/index-2dv4y4wd.js +1065 -0
- package/dist/server/_chunks/index-2vz0wzdn.js +59 -0
- package/dist/server/_chunks/index-2wfv4kvx.js +182 -0
- package/dist/server/_chunks/index-357na4a8.js +109 -0
- package/dist/server/_chunks/index-3b3at80h.js +109 -0
- package/dist/server/_chunks/index-3tf1xjsp.js +6166 -0
- package/dist/server/_chunks/index-3xbr4eyv.js +105 -0
- package/dist/server/_chunks/index-4399bvd2.js +18 -0
- package/dist/server/_chunks/index-4hgjrqh7.js +851 -0
- package/dist/server/_chunks/index-4q2gbfwk.js +2530 -0
- package/dist/server/_chunks/index-4t92hdxd.js +172 -0
- package/dist/server/_chunks/index-4zzebszd.js +10 -0
- package/dist/server/_chunks/index-5gyr4emz.js +107 -0
- package/dist/server/_chunks/index-5hr4062s.js +70 -0
- package/dist/server/_chunks/index-68m3mwbd.js +84 -0
- package/dist/server/_chunks/index-6b009mt0.js +56 -0
- package/dist/server/_chunks/index-6e4fqv30.js +588 -0
- package/dist/server/_chunks/index-6gex3pfa.js +15 -0
- package/dist/server/_chunks/index-6kp9r0d9.js +11 -0
- package/dist/server/_chunks/index-6q7zvrap.js +134 -0
- package/dist/server/_chunks/index-73z4esab.js +38 -0
- package/dist/server/_chunks/index-79ngvam8.js +60 -0
- package/dist/server/_chunks/index-7wc9n8be.js +25 -0
- package/dist/server/_chunks/index-8k7pfejn.js +1599 -0
- package/dist/server/_chunks/index-8kcxdfya.js +206 -0
- package/dist/server/_chunks/index-91x12ykq.js +274 -0
- package/dist/server/_chunks/index-9ch50vtq.js +18 -0
- package/dist/server/_chunks/index-9hx2641q.js +28 -0
- package/dist/server/_chunks/index-9n2914ww.js +535 -0
- package/dist/server/_chunks/index-9ych9ma8.js +207 -0
- package/dist/server/_chunks/index-b6wtkdp4.js +24 -0
- package/dist/server/_chunks/index-bcws5eh2.js +35 -0
- package/dist/server/_chunks/index-c0g2wf3z.js +92 -0
- package/dist/server/_chunks/index-cf4rvxv6.js +95 -0
- package/dist/server/_chunks/index-cjgqs13g.js +65 -0
- package/dist/server/_chunks/index-ckkdpht5.js +41 -0
- package/dist/server/_chunks/index-cyfednwb.js +87 -0
- package/dist/server/_chunks/index-danncfhy.js +311 -0
- package/dist/server/_chunks/index-dg0f05zs.js +199 -0
- package/dist/server/_chunks/index-e3a6yx84.js +18 -0
- package/dist/server/_chunks/index-e88tyv35.js +45 -0
- package/dist/server/_chunks/index-eajaspjk.js +1253 -0
- package/dist/server/_chunks/index-eeaanp2e.js +483 -0
- package/dist/server/_chunks/index-egykcqg3.js +101 -0
- package/dist/server/_chunks/index-en7n9f7m.js +22 -0
- package/dist/server/_chunks/index-ezgj0tr1.js +88 -0
- package/dist/server/_chunks/index-fkp000p1.js +590 -0
- package/dist/server/_chunks/index-fn1chkkd.js +214 -0
- package/dist/server/_chunks/index-fp8r0sqs.js +64 -0
- package/dist/server/_chunks/index-ggk2j965.js +9432 -0
- package/dist/server/_chunks/index-grta8ap3.js +238 -0
- package/dist/server/_chunks/index-h2a70tg4.js +7 -0
- package/dist/server/_chunks/index-h4xy648y.js +51 -0
- package/dist/server/_chunks/index-hkdfj58q.js +92 -0
- package/dist/server/_chunks/index-j2zrcp1k.js +66 -0
- package/dist/server/_chunks/index-jcsjq3d1.js +20 -0
- package/dist/server/_chunks/index-jepjvcrf.js +198 -0
- package/dist/server/_chunks/index-jks0x0a1.js +14 -0
- package/dist/server/_chunks/index-jx7bqvw1.js +57 -0
- package/dist/server/_chunks/index-k1g3epw0.js +1299 -0
- package/dist/server/_chunks/index-knp0s912.js +7 -0
- package/dist/server/_chunks/index-kq8kpzye.js +472 -0
- package/dist/server/_chunks/index-kqyy1d4f.js +50 -0
- package/dist/server/_chunks/index-kresp2n8.js +445 -0
- package/dist/server/_chunks/index-ms9v9tnx.js +31 -0
- package/dist/server/_chunks/index-n4hxpng2.js +11 -0
- package/dist/server/_chunks/index-ncnes8c6.js +17 -0
- package/dist/server/_chunks/index-nqh3xhdc.js +57 -0
- package/dist/server/_chunks/index-nyrba2kr.js +4130 -0
- package/dist/server/_chunks/index-p77b4kcx.js +296 -0
- package/dist/server/_chunks/index-pym1cezq.js +39 -0
- package/dist/server/_chunks/index-q738kkhj.js +100 -0
- package/dist/server/_chunks/index-qjj6gddn.js +54 -0
- package/dist/server/_chunks/index-qm6kmhqs.js +110 -0
- package/dist/server/_chunks/index-qn4z5s3c.js +819 -0
- package/dist/server/_chunks/index-qpwsgt3a.js +158 -0
- package/dist/server/_chunks/index-r97ptz1q.js +97 -0
- package/dist/server/_chunks/index-ras0sdab.js +26 -0
- package/dist/server/_chunks/index-rcs322t1.js +19 -0
- package/dist/server/_chunks/index-rn8dyr1f.js +126 -0
- package/dist/server/_chunks/index-rt9qq1va.js +4 -0
- package/dist/server/_chunks/index-rthrsed5.js +356 -0
- package/dist/server/_chunks/index-sctcgyvv.js +185 -0
- package/dist/server/_chunks/index-sjpckxqn.js +213 -0
- package/dist/server/_chunks/index-sq3kvz3g.js +200 -0
- package/dist/server/_chunks/index-stbk3jhn.js +31 -0
- package/dist/server/_chunks/index-sv8m6789.js +266 -0
- package/dist/server/_chunks/index-tgcakdxc.js +125 -0
- package/dist/server/_chunks/index-tgsfjmep.js +74 -0
- package/dist/server/_chunks/index-tq0pc7eg.js +154 -0
- package/dist/server/_chunks/index-tq1f96v7.js +51 -0
- package/dist/server/_chunks/index-tqn2qnnn.js +241 -0
- package/dist/server/_chunks/index-tvqkq6e6.js +128 -0
- package/dist/server/_chunks/index-v1ags1na.js +132 -0
- package/dist/server/_chunks/index-vvmmknm1.js +1431 -0
- package/dist/server/_chunks/index-vvq7rqtn.js +329 -0
- package/dist/server/_chunks/index-vz0km5qk.js +33 -0
- package/dist/server/_chunks/index-w6h8m6vp.js +138 -0
- package/dist/server/_chunks/index-web361b8.js +138 -0
- package/dist/server/_chunks/index-wpfhfbs4.js +194 -0
- package/dist/server/_chunks/index-x0y005nh.js +283 -0
- package/dist/server/_chunks/index-x3yn4ywm.js +22 -0
- package/dist/server/_chunks/index-x93hv0sc.js +271 -0
- package/dist/server/_chunks/index-xvj80c3a.js +30 -0
- package/dist/server/_chunks/index-xywjg2vc.js +100 -0
- package/dist/server/_chunks/index-y2jr2n72.js +152 -0
- package/dist/server/_chunks/index-y36a0ybw.js +57 -0
- package/dist/server/_chunks/index-ye9hmsvf.js +47 -0
- package/dist/server/_chunks/index-yhxkxghe.js +56 -0
- package/dist/server/_chunks/index-ym67zqxp.js +130 -0
- package/dist/server/_chunks/index-ytjvpbm2.js +736 -0
- package/dist/server/_chunks/index-yz54pxrh.js +960 -0
- package/dist/server/_chunks/index-z4z9zv3b.js +733 -0
- package/dist/server/_chunks/index-z84ab1w0.js +1270 -0
- package/dist/server/_chunks/index-z88qv16t.js +11 -0
- package/dist/server/_chunks/index-zqpqyg8p.js +666 -0
- package/dist/server/_chunks/loader-7yw0j98z.js +78 -0
- package/dist/server/_chunks/modules-jn8bmbn8.js +74 -0
- package/dist/server/_chunks/pipeline-yy9jhydf.js +832 -0
- package/dist/server/_chunks/production-jar9ztm3.js +44 -0
- package/dist/server/_chunks/proxy-config-j84dgksn.js +21 -0
- package/dist/server/_chunks/proxy-w1d0wmsn.js +33 -0
- package/dist/server/_chunks/router-k1reahfn.js +498 -0
- package/dist/server/_chunks/routes-2s277fc6.js +64 -0
- package/dist/server/_chunks/run-pvd8bs1t.js +696 -0
- package/dist/server/_chunks/server-mt4a994c.js +1835 -0
- package/dist/server/_chunks/tsconfig-defaults-1nb3308g.js +20 -0
- package/dist/server/_chunks/typegen-0qr0459b.js +35 -0
- package/dist/server/api/client-cache.js +14 -0
- package/dist/server/cli/index.js +378 -0
- package/dist/server/cli/start.js +137 -0
- package/dist/server/client/reference.js +16 -0
- package/dist/server/compat/next/cache.js +56 -0
- package/dist/server/compat/next/canonical-url.js +13 -0
- package/dist/server/compat/next/client-cache.js +57 -0
- package/dist/server/compat/next/client-navigation.js +232 -0
- package/dist/server/compat/next/client-only.js +1 -0
- package/dist/server/compat/next/client-script.js +178 -0
- package/dist/server/compat/next/client-server.js +34 -0
- package/dist/server/compat/next/config-headers.js +32 -0
- package/dist/server/compat/next/config-loader.js +25 -0
- package/dist/server/compat/next/config.js +10 -0
- package/dist/server/compat/next/constants.js +18 -0
- package/dist/server/compat/next/custom-server.js +10 -0
- package/dist/server/compat/next/dist/client/components/app-router-headers.js +48 -0
- package/dist/server/compat/next/dist/server/web/spec-extension/revalidate.js +27 -0
- package/dist/server/compat/next/dist/server/web/spec-extension/unstable-cache.js +25 -0
- package/dist/server/compat/next/dist/server/web/spec-extension/unstable-no-store.js +25 -0
- package/dist/server/compat/next/dynamic.js +32 -0
- package/dist/server/compat/next/error.js +112 -0
- package/dist/server/compat/next/font/cache.js +14 -0
- package/dist/server/compat/next/font/google.js +3 -0
- package/dist/server/compat/next/font/index.js +1 -0
- package/dist/server/compat/next/font/local.js +22 -0
- package/dist/server/compat/next/font/runtime-client.js +33 -0
- package/dist/server/compat/next/font/runtime.js +41 -0
- package/dist/server/compat/next/font/shared.js +22 -0
- package/dist/server/compat/next/form.js +129 -0
- package/dist/server/compat/next/head.js +10 -0
- package/dist/server/compat/next/headers.js +30 -0
- package/dist/server/compat/next/image/client.js +11 -0
- package/dist/server/compat/next/image/config.js +18 -0
- package/dist/server/compat/next/image/optimizer.js +25 -0
- package/dist/server/compat/next/image/patterns.js +12 -0
- package/dist/server/compat/next/image/props.js +16 -0
- package/dist/server/compat/next/image/shared.js +86 -0
- package/dist/server/compat/next/image/static-metadata.js +32 -0
- package/dist/server/compat/next/image/validate.js +8 -0
- package/dist/server/compat/next/image.js +59 -0
- package/dist/server/compat/next/index.js +1 -0
- package/dist/server/compat/next/legacy-image.js +78 -0
- package/dist/server/compat/next/legacy-request-apis.js +24 -0
- package/dist/server/compat/next/link-transform.js +14 -0
- package/dist/server/compat/next/link.js +14 -0
- package/dist/server/compat/next/navigation.js +190 -0
- package/dist/server/compat/next/offline.js +45 -0
- package/dist/server/compat/next/og.js +8 -0
- package/dist/server/compat/next/preferred-region.js +8 -0
- package/dist/server/compat/next/redirects.js +30 -0
- package/dist/server/compat/next/resource-hints.js +30 -0
- package/dist/server/compat/next/rewrites.js +41 -0
- package/dist/server/compat/next/root-params.js +121 -0
- package/dist/server/compat/next/route-state.js +23 -0
- package/dist/server/compat/next/router.js +103 -0
- package/dist/server/compat/next/script.js +37 -0
- package/dist/server/compat/next/server-only.js +1 -0
- package/dist/server/compat/next/server.js +131 -0
- package/dist/server/compat/next/svgr.js +14 -0
- package/dist/server/compat/next/telemetry.js +10 -0
- package/dist/server/compat/next/usage.js +13 -0
- package/dist/server/compat/next/user-agent.js +12 -0
- package/dist/server/compat/next/web-vitals.js +35 -0
- package/dist/server/compat/react/action-state.js +11 -0
- package/dist/server/compat/react/client-lite.js +83 -0
- package/dist/server/compat/react/client.js +131 -0
- package/dist/server/compat/react/compiler-runtime.js +42 -0
- package/dist/server/compat/react/dom-client.js +106 -0
- package/dist/server/compat/react/dom-react-server.js +37 -0
- package/dist/server/compat/react/dom-server.js +40 -0
- package/dist/server/compat/react/dom.js +52 -0
- package/dist/server/compat/react/hooks-extra.js +12 -0
- package/dist/server/compat/react/internals.js +14 -0
- package/dist/server/compat/react/parity.js +11 -0
- package/dist/server/compat/react/preact.js +113 -0
- package/dist/server/compat/react/react-server.js +133 -0
- package/dist/server/compat/react/router-shim.js +8 -0
- package/dist/server/compat/react/server-component-use.js +14 -0
- package/dist/server/compat/react/server-inserted-html.js +14 -0
- package/dist/server/compat/react/server.js +194 -0
- package/dist/server/compat/react/style-values.js +10 -0
- package/dist/server/compat/react/use.js +10 -0
- package/dist/server/compat/react/view-transition.js +12 -0
- package/dist/server/generation.json +1 -0
- package/package.json +4 -1
- package/src/api/dynamic.tsx +2 -0
- package/src/api/server.ts +24 -6
- package/src/cli/adapters/vercel-warm.ts +315 -61
- package/src/cli/adapters/vercel.ts +348 -71
- package/src/cli/build.ts +58 -33
- package/src/cli/index.ts +23 -10
- package/src/cli/serve/entry.ts +21 -159
- package/src/cli/serve/immutable.ts +31 -0
- package/src/cli/serve/pipeline.ts +82 -84
- package/src/cli/start.ts +3 -1
- package/src/client/chunk-fold.ts +19 -6
- package/src/client/react-tier.ts +3 -2
- package/src/client/reference-stub.ts +21 -2
- package/src/compat/actions/client-plugin.ts +4 -2
- package/src/compat/actions/config.ts +6 -5
- package/src/compat/actions/extensions.ts +2 -3
- package/src/compat/aliases.ts +8 -1
- package/src/compat/bundler/config.ts +88 -0
- package/src/compat/bundler/optimize-package-imports.ts +86 -26
- package/src/compat/bundler/relay-transform.ts +15 -3
- package/src/compat/cache-control.ts +16 -8
- package/src/compat/css/modules.ts +18 -5
- package/src/compat/lifecycle/error-funnel.ts +1 -1
- package/src/compat/lifecycle/instrumentation.ts +117 -24
- package/src/compat/lifecycle/testmode.ts +3 -2
- package/src/compat/next/config-loader.ts +137 -13
- package/src/compat/next/font/runtime.ts +22 -2
- package/src/compat/next/og.ts +3 -3
- package/src/compat/next/usage.ts +3 -2
- package/src/compat/pages/api.ts +83 -14
- package/src/compat/pages/router.ts +30 -14
- package/src/compat/register/bundler.ts +3 -1
- package/src/compat/register/middleware.ts +1 -1
- package/src/compat/register/otel.ts +5 -9
- package/src/compat/register/render.ts +3 -1
- package/src/compat/register/use-cache.ts +3 -1
- package/src/compat/release.ts +46 -0
- package/src/compat/segment/serve.ts +1 -1
- package/src/compat/validation/validate.ts +10 -7
- package/src/config.ts +51 -7
- package/src/css/assets.ts +213 -0
- package/src/css/build.ts +174 -238
- package/src/dev/server.ts +27 -8
- package/src/extensions.ts +4 -0
- package/src/render/hooks.ts +13 -0
- package/src/render/renderer.ts +52 -32
- package/src/request/context.ts +9 -0
- package/src/resolve/dynamic.ts +3 -1
- package/src/resolve/imports.ts +12 -52
- package/src/resolve/package-json.ts +56 -0
- package/src/resolve/scan-facts.ts +65 -0
- package/src/routing/href.ts +10 -3
- package/src/routing/match.ts +287 -0
- package/src/routing/metadata-files.ts +19 -5
- package/src/routing/proxy-config.ts +137 -0
- package/src/routing/proxy.ts +35 -134
- package/src/routing/routes.ts +22 -281
- package/src/runtime/fingerprint.ts +23 -8
- package/src/runtime/load.ts +170 -0
- package/src/runtime/loader.ts +215 -43
- package/src/runtime/module-cache.ts +13 -0
- package/src/runtime/modules.ts +370 -81
- package/src/runtime/prebundle.ts +81 -0
- package/src/runtime/production.ts +391 -0
- package/src/runtime/release-graph.ts +334 -0
- package/src/runtime/vendor-build.ts +724 -13
- package/src/runtime/vendor.ts +16 -3
- package/src/types.ts +2 -0
- package/src/utils/fs.ts +89 -3
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
activateTestProxy
|
|
4
|
+
} from "./index-2wfv4kvx.js";
|
|
5
|
+
import {
|
|
6
|
+
nextCompatEnabled
|
|
7
|
+
} from "./index-eeaanp2e.js";
|
|
8
|
+
import {
|
|
9
|
+
findProxyFiles,
|
|
10
|
+
setProxyRewriteObserver
|
|
11
|
+
} from "./index-kq8kpzye.js";
|
|
12
|
+
import {
|
|
13
|
+
getNextConfig
|
|
14
|
+
} from "./index-6e4fqv30.js";
|
|
15
|
+
import {
|
|
16
|
+
readText,
|
|
17
|
+
toPosixPath
|
|
18
|
+
} from "./index-20ppawv7.js";
|
|
19
|
+
import {
|
|
20
|
+
recordCanonicalUrl
|
|
21
|
+
} from "./index-en7n9f7m.js";
|
|
22
|
+
import {
|
|
23
|
+
getWorkUnit,
|
|
24
|
+
legacyRequestAPIs
|
|
25
|
+
} from "./index-grta8ap3.js";
|
|
26
|
+
import {
|
|
27
|
+
moduleExportNames
|
|
28
|
+
} from "./index-z4z9zv3b.js";
|
|
29
|
+
import {
|
|
30
|
+
setProxyExtensions,
|
|
31
|
+
setProxyResponseProtocol
|
|
32
|
+
} from "./index-zqpqyg8p.js";
|
|
33
|
+
|
|
34
|
+
// src/compat/register/proxy.ts
|
|
35
|
+
import path from "path";
|
|
36
|
+
|
|
37
|
+
// src/compat/protocol.ts
|
|
38
|
+
var ROUTER_VARY = [
|
|
39
|
+
"rsc",
|
|
40
|
+
"next-router-state-tree",
|
|
41
|
+
"next-router-prefetch",
|
|
42
|
+
"next-router-segment-prefetch"
|
|
43
|
+
];
|
|
44
|
+
var rewrites = new WeakMap;
|
|
45
|
+
function recordRewrite(from, to) {
|
|
46
|
+
const unit = getWorkUnit();
|
|
47
|
+
if (!unit)
|
|
48
|
+
return;
|
|
49
|
+
if (from.pathname === to.pathname && from.search === to.search)
|
|
50
|
+
return;
|
|
51
|
+
const query = to.search.replace(/^\?/, "");
|
|
52
|
+
rewrites.set(unit, {
|
|
53
|
+
...to.pathname !== from.pathname ? { path: to.pathname } : {},
|
|
54
|
+
...query ? { query } : {}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
var CACHE_BUSTING_REDIRECT_HEADER = "x-pnext-cache-bust";
|
|
58
|
+
var APP_ROUTE_KINDS = new Set([
|
|
59
|
+
"html",
|
|
60
|
+
"data",
|
|
61
|
+
"route-handler"
|
|
62
|
+
]);
|
|
63
|
+
var protocolFinalizer = (ctx) => {
|
|
64
|
+
if (!APP_ROUTE_KINDS.has(ctx.routeKind))
|
|
65
|
+
return;
|
|
66
|
+
if (!isPlainRedirect(ctx))
|
|
67
|
+
mergeVary(ctx.headers, ROUTER_VARY);
|
|
68
|
+
normalizeRscRedirectStatus(ctx);
|
|
69
|
+
applyRewrittenHeaders(ctx);
|
|
70
|
+
applyEdgeRuntimeHeader(ctx);
|
|
71
|
+
};
|
|
72
|
+
function isPlainRedirect(ctx) {
|
|
73
|
+
if (ctx.status < 300 || ctx.status >= 400 || !ctx.headers.has("location"))
|
|
74
|
+
return false;
|
|
75
|
+
return ctx.request.headers.get("rsc") !== "1" && !ctx.request.headers.has("next-router-prefetch") && !ctx.request.headers.has("next-router-segment-prefetch");
|
|
76
|
+
}
|
|
77
|
+
function applyEdgeRuntimeHeader(ctx) {
|
|
78
|
+
const runtime = ctx.hints?.runtime;
|
|
79
|
+
if (runtime === "edge" || runtime === "experimental-edge") {
|
|
80
|
+
ctx.headers.set("x-edge-runtime", "1");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function mergeVary(headers, values) {
|
|
84
|
+
const existing = headers.get("vary");
|
|
85
|
+
const present = new Set((existing ?? "").split(",").map((token) => token.trim().toLowerCase()).filter(Boolean));
|
|
86
|
+
const merged = existing ? existing.split(",").map((token) => token.trim()).filter(Boolean) : [];
|
|
87
|
+
for (const value of values) {
|
|
88
|
+
if (present.has(value.toLowerCase()))
|
|
89
|
+
continue;
|
|
90
|
+
present.add(value.toLowerCase());
|
|
91
|
+
merged.push(value);
|
|
92
|
+
}
|
|
93
|
+
if (merged.length > 0)
|
|
94
|
+
headers.set("vary", merged.join(", "));
|
|
95
|
+
}
|
|
96
|
+
function applyRewrittenHeaders(ctx) {
|
|
97
|
+
if (ctx.request.headers.get("rsc") !== "1")
|
|
98
|
+
return;
|
|
99
|
+
const unit = getWorkUnit();
|
|
100
|
+
if (!unit)
|
|
101
|
+
return;
|
|
102
|
+
const info = rewrites.get(unit);
|
|
103
|
+
if (!info)
|
|
104
|
+
return;
|
|
105
|
+
if (info.path !== undefined)
|
|
106
|
+
ctx.headers.set("x-nextjs-rewritten-path", info.path);
|
|
107
|
+
if (info.query !== undefined)
|
|
108
|
+
ctx.headers.set("x-nextjs-rewritten-query", info.query);
|
|
109
|
+
}
|
|
110
|
+
function normalizeRscRedirectStatus(ctx) {
|
|
111
|
+
if (ctx.headers.has(CACHE_BUSTING_REDIRECT_HEADER)) {
|
|
112
|
+
ctx.headers.delete(CACHE_BUSTING_REDIRECT_HEADER);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (ctx.routeKind !== "html")
|
|
116
|
+
return;
|
|
117
|
+
if (ctx.request.headers.get("rsc") !== "1")
|
|
118
|
+
return;
|
|
119
|
+
if (ctx.request.headers.has("x-pnext-soft-nav"))
|
|
120
|
+
return;
|
|
121
|
+
if (!ctx.headers.has("location"))
|
|
122
|
+
return;
|
|
123
|
+
if (ctx.status !== 307 && ctx.status !== 308)
|
|
124
|
+
return;
|
|
125
|
+
ctx.status = 200;
|
|
126
|
+
}
|
|
127
|
+
function isValidFlightRouterState(value) {
|
|
128
|
+
if (!Array.isArray(value))
|
|
129
|
+
return false;
|
|
130
|
+
const [segment, parallelRoutes] = value;
|
|
131
|
+
if (typeof segment !== "string" && !Array.isArray(segment))
|
|
132
|
+
return false;
|
|
133
|
+
if (typeof parallelRoutes !== "object" || parallelRoutes === null)
|
|
134
|
+
return false;
|
|
135
|
+
if (Array.isArray(parallelRoutes))
|
|
136
|
+
return false;
|
|
137
|
+
return Object.values(parallelRoutes).every(isValidFlightRouterState);
|
|
138
|
+
}
|
|
139
|
+
var routerStateTreeInterceptor = (request) => Promise.resolve(validateRouterStateTree(request));
|
|
140
|
+
function validateRouterStateTree(request) {
|
|
141
|
+
if (request.headers.get("rsc") !== "1")
|
|
142
|
+
return;
|
|
143
|
+
if (request.headers.has("x-pnext-soft-nav"))
|
|
144
|
+
return;
|
|
145
|
+
const header = request.headers.get("next-router-state-tree");
|
|
146
|
+
if (header === null)
|
|
147
|
+
return;
|
|
148
|
+
let tree;
|
|
149
|
+
try {
|
|
150
|
+
tree = JSON.parse(decodeURIComponent(header));
|
|
151
|
+
} catch {
|
|
152
|
+
try {
|
|
153
|
+
tree = JSON.parse(header);
|
|
154
|
+
} catch {
|
|
155
|
+
return new Response("Internal Server Error", { status: 500 });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return isValidFlightRouterState(tree) ? undefined : new Response("Internal Server Error", { status: 500 });
|
|
159
|
+
}
|
|
160
|
+
function protocolInterceptors(config) {
|
|
161
|
+
if (!nextCompatEnabled(config))
|
|
162
|
+
return [];
|
|
163
|
+
return [routerStateTreeInterceptor];
|
|
164
|
+
}
|
|
165
|
+
function protocolFinalizers(config) {
|
|
166
|
+
if (!nextCompatEnabled(config))
|
|
167
|
+
return [];
|
|
168
|
+
return [protocolFinalizer];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// src/compat/register/proxy.ts
|
|
172
|
+
function registerProxyExtensions(_config) {
|
|
173
|
+
setProxyResponseProtocol({
|
|
174
|
+
nextHeader: "x-middleware-next",
|
|
175
|
+
rewriteHeader: "x-middleware-rewrite"
|
|
176
|
+
});
|
|
177
|
+
setProxyExtensions({
|
|
178
|
+
names: ["proxy", "middleware"],
|
|
179
|
+
validateFiles: validateNextProxyFiles,
|
|
180
|
+
handlerExport: (module) => module.proxy ?? module.default ?? module.middleware,
|
|
181
|
+
skipUrlNormalize: () => getNextConfig().skipProxyUrlNormalize === true,
|
|
182
|
+
locale: proxyLocale,
|
|
183
|
+
onExternalRewrite: (request) => activateTestProxy(request.headers),
|
|
184
|
+
clientMaxBodySize: proxyClientMaxBodySize
|
|
185
|
+
});
|
|
186
|
+
setProxyRewriteObserver((from, to) => {
|
|
187
|
+
recordCanonicalUrl(from);
|
|
188
|
+
recordRewrite(from, to);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
var DEFAULT_PROXY_CLIENT_MAX_BODY_SIZE = 10 * 1024 * 1024;
|
|
192
|
+
function proxyClientMaxBodySize() {
|
|
193
|
+
const experimental = getNextConfig().experimental ?? {};
|
|
194
|
+
const raw = experimental.proxyClientMaxBodySize ?? experimental.middlewareClientMaxBodySize;
|
|
195
|
+
if (typeof raw === "number" && raw > 0)
|
|
196
|
+
return raw;
|
|
197
|
+
if (typeof raw === "string") {
|
|
198
|
+
const match = /^(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)?$/i.exec(raw.trim());
|
|
199
|
+
if (match?.[1]) {
|
|
200
|
+
const unit = (match[2] ?? "b").toLowerCase();
|
|
201
|
+
const multiplier = unit === "gb" ? 1024 ** 3 : unit === "mb" ? 1024 ** 2 : unit === "kb" ? 1024 : 1;
|
|
202
|
+
const bytes = Math.floor(Number(match[1]) * multiplier);
|
|
203
|
+
if (bytes > 0)
|
|
204
|
+
return bytes;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return DEFAULT_PROXY_CLIENT_MAX_BODY_SIZE;
|
|
208
|
+
}
|
|
209
|
+
function proxyLocale(url) {
|
|
210
|
+
const i18n = getNextConfig().i18n;
|
|
211
|
+
if (!Array.isArray(i18n?.locales))
|
|
212
|
+
return "";
|
|
213
|
+
const locales = i18n.locales.filter((locale) => typeof locale === "string");
|
|
214
|
+
const dataLocale = /^\/_next\/data\/[^/]+\/([^/]+)(?:\/|$)/.exec(url.pathname)?.[1];
|
|
215
|
+
const candidate = dataLocale ?? url.pathname.split("/")[1];
|
|
216
|
+
return locales.find((locale) => locale.toLowerCase() === candidate?.toLowerCase()) ?? "";
|
|
217
|
+
}
|
|
218
|
+
async function validateNextProxyFiles(config) {
|
|
219
|
+
const files = findProxyFiles(config, ["proxy", "middleware"]);
|
|
220
|
+
const middleware = files.find((file) => path.basename(file).startsWith("middleware."));
|
|
221
|
+
const proxy = files.find((file) => path.basename(file).startsWith("proxy."));
|
|
222
|
+
if (middleware && proxy) {
|
|
223
|
+
throw new Error(`Both middleware file "${relativeProxyPath(config, middleware)}" and proxy file "${relativeProxyPath(config, proxy)}" are detected. Please use "${relativeProxyPath(config, proxy)}" only.`);
|
|
224
|
+
}
|
|
225
|
+
if (middleware && !proxy && !legacyRequestAPIs()) {
|
|
226
|
+
console.warn('The "middleware" file convention is deprecated. Please use "proxy" instead.');
|
|
227
|
+
}
|
|
228
|
+
await Promise.all(files.map((file) => validateNextProxyFile(config, file)));
|
|
229
|
+
}
|
|
230
|
+
async function validateNextProxyFile(config, file) {
|
|
231
|
+
const source = await readText(file);
|
|
232
|
+
const name = path.basename(file).split(".")[0];
|
|
233
|
+
const exports = moduleExportNames(source, file);
|
|
234
|
+
const validExport = exports.includes("default") || (name === "proxy" ? exports.includes("proxy") : exports.includes("middleware"));
|
|
235
|
+
if (!validExport) {
|
|
236
|
+
throw new Error(proxyMissingExportError(config, file));
|
|
237
|
+
}
|
|
238
|
+
if (name === "proxy" && hasRuntimeConfig(source)) {
|
|
239
|
+
throw new Error(`Route segment config is not allowed in Proxy file at "${relativeProxyPath(config, file)}". Proxy always runs on Node.js runtime. Learn more: https://nextjs.org/docs/messages/middleware-to-proxy`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function proxyMissingExportError(config, file) {
|
|
243
|
+
const name = path.basename(file).split(".")[0] === "middleware" ? "middleware" : "proxy";
|
|
244
|
+
const migrationReason = name === "proxy" ? "- You are migrating from `middleware` to `proxy`, but haven't updated the exported function.\n" : "";
|
|
245
|
+
const target = name === "proxy" ? "proxy (previously called middleware)" : "middleware";
|
|
246
|
+
return `The file "${relativeProxyPath(config, file)}" must export a function, either as a default export or as a named "${name}" export.
|
|
247
|
+
This function is what Next.js runs for every request handled by this ${target}.
|
|
248
|
+
|
|
249
|
+
Why this happens:
|
|
250
|
+
${migrationReason}- The file exists but doesn't export a function.
|
|
251
|
+
- The export is not a function (e.g., an object or constant).
|
|
252
|
+
- There's a syntax error preventing the export from being recognized.
|
|
253
|
+
|
|
254
|
+
To fix it:
|
|
255
|
+
- Ensure this file has either a default or "${name}" function export.
|
|
256
|
+
|
|
257
|
+
Learn more: https://nextjs.org/docs/messages/middleware-to-proxy`;
|
|
258
|
+
}
|
|
259
|
+
function hasRuntimeConfig(source) {
|
|
260
|
+
return /\bexport\s+const\s+config\s*=/.test(source) && /\bruntime\s*:/.test(source);
|
|
261
|
+
}
|
|
262
|
+
function relativeProxyPath(config, file) {
|
|
263
|
+
return `./${toPosixPath(path.relative(config.root, file))}`;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export { recordRewrite, CACHE_BUSTING_REDIRECT_HEADER, protocolInterceptors, protocolFinalizers, registerProxyExtensions };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
use
|
|
4
|
+
} from "./index-h4xy648y.js";
|
|
5
|
+
import {
|
|
6
|
+
useActionState
|
|
7
|
+
} from "./index-68m3mwbd.js";
|
|
8
|
+
import {
|
|
9
|
+
setSuspenseParity
|
|
10
|
+
} from "./index-w6h8m6vp.js";
|
|
11
|
+
import {
|
|
12
|
+
useOptimistic,
|
|
13
|
+
useTransition
|
|
14
|
+
} from "./index-j2zrcp1k.js";
|
|
15
|
+
|
|
16
|
+
// src/compat/react/preact.ts
|
|
17
|
+
import ReactCompat from "preact/compat";
|
|
18
|
+
setSuspenseParity({
|
|
19
|
+
beforeThrowSafety: applyAsyncClientComponent,
|
|
20
|
+
afterThrowSafety: applyThenableChildren
|
|
21
|
+
});
|
|
22
|
+
function applyThenableChildren(vnode) {
|
|
23
|
+
const props = vnode.props;
|
|
24
|
+
const children = props.children;
|
|
25
|
+
const resolved = thenableChildren(children);
|
|
26
|
+
if (resolved !== children)
|
|
27
|
+
props.children = resolved;
|
|
28
|
+
}
|
|
29
|
+
function thenableChildren(value) {
|
|
30
|
+
if (value && typeof value.then === "function") {
|
|
31
|
+
return ReactCompat.createElement(ReactCompat.Suspense, { fallback: null }, ReactCompat.createElement(ThenableChild, {
|
|
32
|
+
value
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
if (!Array.isArray(value))
|
|
36
|
+
return value;
|
|
37
|
+
let changed = false;
|
|
38
|
+
const children = value.map((child) => {
|
|
39
|
+
const resolved = thenableChildren(child);
|
|
40
|
+
if (resolved !== child)
|
|
41
|
+
changed = true;
|
|
42
|
+
return resolved;
|
|
43
|
+
});
|
|
44
|
+
return changed ? children : value;
|
|
45
|
+
}
|
|
46
|
+
function ThenableChild({ value }) {
|
|
47
|
+
return use(value);
|
|
48
|
+
}
|
|
49
|
+
var asyncClientComponents = new WeakMap;
|
|
50
|
+
function applyAsyncClientComponent(vnode) {
|
|
51
|
+
if (typeof window === "undefined" || typeof vnode.type !== "function")
|
|
52
|
+
return;
|
|
53
|
+
const component = vnode.type;
|
|
54
|
+
if (component.constructor.name !== "AsyncFunction")
|
|
55
|
+
return;
|
|
56
|
+
const renderComponent = component;
|
|
57
|
+
let wrapper = asyncClientComponents.get(component);
|
|
58
|
+
if (!wrapper) {
|
|
59
|
+
wrapper = (props) => {
|
|
60
|
+
const [result] = ReactCompat.useState(() => Promise.resolve(renderComponent(props)));
|
|
61
|
+
return ReactCompat.createElement(ReactCompat.Suspense, { fallback: null }, ReactCompat.createElement(ThenableChild, { value: result }));
|
|
62
|
+
};
|
|
63
|
+
asyncClientComponents.set(component, wrapper);
|
|
64
|
+
}
|
|
65
|
+
vnode.type = wrapper;
|
|
66
|
+
}
|
|
67
|
+
var preactUseSyncExternalStore = ReactCompat.useSyncExternalStore;
|
|
68
|
+
function serverSnapshotAware(subscribe, getSnapshot, getServerSnapshot) {
|
|
69
|
+
if (typeof window === "undefined") {
|
|
70
|
+
if (!getServerSnapshot)
|
|
71
|
+
throw new Error("Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering.");
|
|
72
|
+
return getServerSnapshot();
|
|
73
|
+
}
|
|
74
|
+
return preactUseSyncExternalStore(subscribe, getSnapshot);
|
|
75
|
+
}
|
|
76
|
+
var useSyncExternalStore = serverSnapshotAware;
|
|
77
|
+
var preact_default = Object.assign(ReactCompat, { use, useActionState, useOptimistic, useTransition });
|
|
78
|
+
if (true)
|
|
79
|
+
ReactCompat.useSyncExternalStore = useSyncExternalStore;
|
|
80
|
+
var Children = ReactCompat.Children;
|
|
81
|
+
var Component = ReactCompat.Component;
|
|
82
|
+
var Fragment = ReactCompat.Fragment;
|
|
83
|
+
var PureComponent = ReactCompat.PureComponent;
|
|
84
|
+
var StrictMode = ReactCompat.StrictMode;
|
|
85
|
+
var Suspense = ReactCompat.Suspense;
|
|
86
|
+
var SuspenseList = ReactCompat.SuspenseList;
|
|
87
|
+
var cloneElement = ReactCompat.cloneElement;
|
|
88
|
+
var createContext = ReactCompat.createContext;
|
|
89
|
+
var createElement = ReactCompat.createElement;
|
|
90
|
+
var createFactory = ReactCompat.createFactory;
|
|
91
|
+
var createPortal = ReactCompat.createPortal;
|
|
92
|
+
var createRef = ReactCompat.createRef;
|
|
93
|
+
var findDOMNode = ReactCompat.findDOMNode;
|
|
94
|
+
var flushSync = ReactCompat.flushSync;
|
|
95
|
+
var forwardRef = ReactCompat.forwardRef;
|
|
96
|
+
var hydrate = ReactCompat.hydrate;
|
|
97
|
+
var isFragment = ReactCompat.isFragment;
|
|
98
|
+
var isMemo = ReactCompat.isMemo;
|
|
99
|
+
var isValidElement = ReactCompat.isValidElement;
|
|
100
|
+
var lazy = (loader) => {
|
|
101
|
+
const component = ReactCompat.lazy(loader);
|
|
102
|
+
component[Symbol.for("pnext.lazy")] = true;
|
|
103
|
+
return component;
|
|
104
|
+
};
|
|
105
|
+
var memo = ReactCompat.memo;
|
|
106
|
+
var render = ReactCompat.render;
|
|
107
|
+
var startTransition = ReactCompat.startTransition;
|
|
108
|
+
var unmountComponentAtNode = ReactCompat.unmountComponentAtNode;
|
|
109
|
+
var unstable_batchedUpdates = ReactCompat.unstable_batchedUpdates;
|
|
110
|
+
var useCallback = ReactCompat.useCallback;
|
|
111
|
+
var useContext = ReactCompat.useContext;
|
|
112
|
+
var useDebugValue = ReactCompat.useDebugValue;
|
|
113
|
+
var useDeferredValue = ReactCompat.useDeferredValue;
|
|
114
|
+
var useEffect = ReactCompat.useEffect;
|
|
115
|
+
var useId = ReactCompat.useId;
|
|
116
|
+
var useImperativeHandle = ReactCompat.useImperativeHandle;
|
|
117
|
+
var useInsertionEffect = ReactCompat.useInsertionEffect;
|
|
118
|
+
var useLayoutEffect = ReactCompat.useLayoutEffect;
|
|
119
|
+
var useMemo = ReactCompat.useMemo;
|
|
120
|
+
var useReducer = ReactCompat.useReducer;
|
|
121
|
+
var useRef = ReactCompat.useRef;
|
|
122
|
+
var useState = ReactCompat.useState;
|
|
123
|
+
var version = ReactCompat.version;
|
|
124
|
+
|
|
125
|
+
export { useSyncExternalStore, preact_default, Children, Component, Fragment, PureComponent, StrictMode, Suspense, SuspenseList, cloneElement, createContext, createElement, createFactory, createPortal, createRef, findDOMNode, flushSync, forwardRef, hydrate, isFragment, isMemo, isValidElement, lazy, memo, render, startTransition, unmountComponentAtNode, unstable_batchedUpdates, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, version };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/compat/next/image/patterns.ts
|
|
3
|
+
function makePathnameRegex(pathname) {
|
|
4
|
+
let source = "";
|
|
5
|
+
const escaped = pathname.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
6
|
+
source = escaped.replace(/\/\*\*/g, "(?:/.*)?").replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*");
|
|
7
|
+
return new RegExp(`^${source}$`);
|
|
8
|
+
}
|
|
9
|
+
function hasLocalMatch(localPatterns, url) {
|
|
10
|
+
if (localPatterns === undefined)
|
|
11
|
+
return true;
|
|
12
|
+
return localPatterns.some((pattern) => {
|
|
13
|
+
if (pattern.pathname !== undefined && !makePathnameRegex(pattern.pathname).test(url.pathname)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (pattern.search !== undefined && pattern.search !== url.search)
|
|
17
|
+
return false;
|
|
18
|
+
return true;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function hasRemoteMatch(domains, remotePatterns, url) {
|
|
22
|
+
if (domains.includes(url.hostname))
|
|
23
|
+
return true;
|
|
24
|
+
return remotePatterns.some((pattern) => {
|
|
25
|
+
if (pattern.protocol !== undefined && pattern.protocol !== url.protocol.replace(/:$/, "")) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (pattern.hostname !== undefined && !matchHostname(pattern.hostname, url.hostname)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (pattern.port !== undefined && pattern.port !== "" && pattern.port !== url.port) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (pattern.pathname !== undefined && !makePathnameRegex(pattern.pathname).test(url.pathname)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (pattern.search !== undefined && pattern.search !== "" && pattern.search !== url.search) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function matchHostname(pattern, hostname) {
|
|
44
|
+
if (pattern.startsWith("**.")) {
|
|
45
|
+
const suffix = pattern.slice(2);
|
|
46
|
+
return hostname.endsWith(suffix) && hostname.length > suffix.length;
|
|
47
|
+
}
|
|
48
|
+
if (pattern.startsWith("*.")) {
|
|
49
|
+
const suffix = pattern.slice(1);
|
|
50
|
+
if (!hostname.endsWith(suffix))
|
|
51
|
+
return false;
|
|
52
|
+
const sub = hostname.slice(0, -suffix.length);
|
|
53
|
+
return sub.length > 0 && !sub.includes(".");
|
|
54
|
+
}
|
|
55
|
+
return pattern === hostname;
|
|
56
|
+
}
|
|
57
|
+
function manifestLocalPatterns(localPatterns) {
|
|
58
|
+
const patterns = localPatterns ?? [{ pathname: undefined, search: "" }];
|
|
59
|
+
const entries = patterns.map((pattern) => ({
|
|
60
|
+
pathname: compileLocalPathname(pattern.pathname),
|
|
61
|
+
search: pattern.search ?? ""
|
|
62
|
+
}));
|
|
63
|
+
return entries;
|
|
64
|
+
}
|
|
65
|
+
function compileLocalPathname(pathname) {
|
|
66
|
+
if (pathname === undefined || pathname === "**") {
|
|
67
|
+
return "^(?:(?!(?:^|\\/)\\.{1,2}(?:\\/|$))(?:(?:(?!(?:^|\\/)\\.{1,2}(?:\\/|$)).)*?)\\/?)$";
|
|
68
|
+
}
|
|
69
|
+
const base = pathname.replace(/\/\*\*$/, "");
|
|
70
|
+
const escaped = base.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\//g, "\\/");
|
|
71
|
+
return `^(?:${escaped}(?:\\/(?!\\.{1,2}(?:\\/|$))(?:(?:(?!(?:^|\\/)\\.{1,2}(?:\\/|$)).)*?)|$))$`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { hasLocalMatch, hasRemoteMatch, manifestLocalPatterns };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
recordUseCacheLife,
|
|
4
|
+
recordUseCacheTags
|
|
5
|
+
} from "./index-eajaspjk.js";
|
|
6
|
+
import {
|
|
7
|
+
bumpRevalidationEvent,
|
|
8
|
+
cachedData,
|
|
9
|
+
currentRenderCacheMeta,
|
|
10
|
+
insideDataCacheProducer,
|
|
11
|
+
insideUnstableCacheProducer,
|
|
12
|
+
markPathRevalidated,
|
|
13
|
+
markTagRevalidated,
|
|
14
|
+
markTagStale,
|
|
15
|
+
recordCacheNoStore,
|
|
16
|
+
recordCacheRevalidate,
|
|
17
|
+
recordCacheTags
|
|
18
|
+
} from "./index-9n2914ww.js";
|
|
19
|
+
import {
|
|
20
|
+
getNextConfig
|
|
21
|
+
} from "./index-6e4fqv30.js";
|
|
22
|
+
import {
|
|
23
|
+
currentRequest,
|
|
24
|
+
getWorkUnit
|
|
25
|
+
} from "./index-grta8ap3.js";
|
|
26
|
+
import {
|
|
27
|
+
isPrerendering
|
|
28
|
+
} from "./index-kresp2n8.js";
|
|
29
|
+
import {
|
|
30
|
+
PostponeError
|
|
31
|
+
} from "./index-e3a6yx84.js";
|
|
32
|
+
|
|
33
|
+
// src/compat/next/cache.ts
|
|
34
|
+
function refresh() {
|
|
35
|
+
const phase = getWorkUnit()?.phase;
|
|
36
|
+
if (phase !== "action" || insideDataCacheProducer()) {
|
|
37
|
+
throw new Error("refresh can only be called from within a Server Action");
|
|
38
|
+
}
|
|
39
|
+
bumpRevalidationEvent();
|
|
40
|
+
}
|
|
41
|
+
var unstable_refresh = refresh;
|
|
42
|
+
function assertRevalidateOutsideRender(expression) {
|
|
43
|
+
const route = currentRenderCacheMeta()?.route ?? "/";
|
|
44
|
+
const suffix = "which is unsupported. To ensure revalidation is performed consistently it must always " + "happen outside of renders and cached functions. See more info here: " + "https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering";
|
|
45
|
+
if (insideDataCacheProducer()) {
|
|
46
|
+
throw new Error(insideUnstableCacheProducer() ? `Route ${route} used "${expression}" inside a function cached with "unstable_cache(...)" ${suffix}` : `Route ${route} used "${expression}" inside a "use cache" ${suffix}`);
|
|
47
|
+
}
|
|
48
|
+
if (getWorkUnit()?.phase !== "render" || isPrerendering())
|
|
49
|
+
return;
|
|
50
|
+
throw new Error(`Route ${route} used "${expression}" during render ${suffix}`);
|
|
51
|
+
}
|
|
52
|
+
function revalidatePath(path, type) {
|
|
53
|
+
assertRevalidateOutsideRender(`revalidatePath ${path}`);
|
|
54
|
+
markPathRevalidated(path, type);
|
|
55
|
+
}
|
|
56
|
+
function revalidateTag(tag, profile) {
|
|
57
|
+
assertRevalidateOutsideRender(`revalidateTag ${tag}`);
|
|
58
|
+
if (profile === undefined) {
|
|
59
|
+
console.warn(`Warning: "revalidateTag" without the second argument is now deprecated. Use updateTag(tag) for read-your-writes semantics, or pass a cache profile (e.g. revalidateTag(tag, 'max')).`);
|
|
60
|
+
markTagRevalidated(tag);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const resolved = typeof profile === "string" ? resolveCacheLifeProfile(profile) : profile;
|
|
64
|
+
if (!resolved || resolved.expire === 0 || resolved.revalidate === 0) {
|
|
65
|
+
markTagRevalidated(tag);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
markTagStale(tag);
|
|
69
|
+
}
|
|
70
|
+
function updateTag(tag) {
|
|
71
|
+
const request = currentRequest();
|
|
72
|
+
const inServerAction = request?.method?.toUpperCase?.() === "POST" && Boolean(request.headers?.get?.("next-action"));
|
|
73
|
+
if (!inServerAction) {
|
|
74
|
+
throw new Error("updateTag can only be called from within a Server Action. Use revalidateTag or expireTag for other contexts.");
|
|
75
|
+
}
|
|
76
|
+
markTagRevalidated(tag);
|
|
77
|
+
}
|
|
78
|
+
var unstable_expirePath = revalidatePath;
|
|
79
|
+
var unstable_expireTag = (tag) => {
|
|
80
|
+
assertRevalidateOutsideRender(`expireTag ${tag}`);
|
|
81
|
+
markTagRevalidated(tag);
|
|
82
|
+
};
|
|
83
|
+
var expirePath = revalidatePath;
|
|
84
|
+
var expireTag = unstable_expireTag;
|
|
85
|
+
function unstable_cache(fn, keyParts, options = {}) {
|
|
86
|
+
const { revalidate } = options;
|
|
87
|
+
if (revalidate !== undefined && revalidate !== false && (typeof revalidate !== "number" || revalidate < 0 || !Number.isFinite(revalidate))) {
|
|
88
|
+
throw new Error(`Invalid revalidate value "${String(revalidate)}" on "unstable_cache(${fn.toString().slice(0, 60)})", must be a non-negative number or false`);
|
|
89
|
+
}
|
|
90
|
+
const baseKey = keyParts?.length ? keyParts.join(",") : fn.toString();
|
|
91
|
+
return (...args) => {
|
|
92
|
+
recordCacheTags(options.tags ?? []);
|
|
93
|
+
if (typeof options.revalidate === "number")
|
|
94
|
+
recordCacheRevalidate(options.revalidate);
|
|
95
|
+
return cachedData(`${baseKey}:${JSON.stringify(args)}`, () => fn(...args), {
|
|
96
|
+
tags: options.tags,
|
|
97
|
+
revalidateSeconds: typeof options.revalidate === "number" ? options.revalidate : undefined
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function unstable_noStore() {
|
|
102
|
+
recordCacheNoStore();
|
|
103
|
+
}
|
|
104
|
+
function cacheTag(...tags) {
|
|
105
|
+
recordUseCacheTags(tags);
|
|
106
|
+
recordCacheTags(tags);
|
|
107
|
+
}
|
|
108
|
+
var DEFAULT_EXPIRE_TIME = 31536000;
|
|
109
|
+
var builtInCacheLifeProfiles = {
|
|
110
|
+
default: { revalidate: 900, expire: DEFAULT_EXPIRE_TIME, stale: 300 },
|
|
111
|
+
seconds: { revalidate: 1, expire: 60, stale: 30 },
|
|
112
|
+
minutes: { revalidate: 60, expire: 3600, stale: 300 },
|
|
113
|
+
hours: { revalidate: 3600, expire: 86400, stale: 300 },
|
|
114
|
+
days: { revalidate: 86400, expire: 604800, stale: 300 },
|
|
115
|
+
weeks: { revalidate: 604800, expire: 2592000, stale: 300 },
|
|
116
|
+
max: { revalidate: 2592000, expire: DEFAULT_EXPIRE_TIME, stale: 300 }
|
|
117
|
+
};
|
|
118
|
+
function resolveCacheLifeProfile(name) {
|
|
119
|
+
const config = getNextConfig();
|
|
120
|
+
const overrides = config.cacheLife;
|
|
121
|
+
const custom = overrides?.[name];
|
|
122
|
+
const builtIn = builtInCacheLifeProfiles[name];
|
|
123
|
+
if (!custom && !builtIn)
|
|
124
|
+
return;
|
|
125
|
+
const expireTime = typeof config.expireTime === "number" ? config.expireTime : DEFAULT_EXPIRE_TIME;
|
|
126
|
+
const merged = { ...builtIn, ...custom };
|
|
127
|
+
return {
|
|
128
|
+
...merged,
|
|
129
|
+
expire: merged.expire ?? expireTime
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function cacheLife(profile) {
|
|
133
|
+
const resolved = typeof profile === "string" ? resolveCacheLifeProfile(profile) : {
|
|
134
|
+
revalidate: typeof profile?.revalidate === "number" ? profile.revalidate : undefined,
|
|
135
|
+
expire: typeof profile?.expire === "number" ? profile.expire : undefined,
|
|
136
|
+
stale: typeof profile?.stale === "number" ? profile.stale : undefined
|
|
137
|
+
};
|
|
138
|
+
if (!resolved)
|
|
139
|
+
return;
|
|
140
|
+
const { revalidate, expire, stale } = resolved;
|
|
141
|
+
recordUseCacheLife({
|
|
142
|
+
...revalidate !== undefined ? { revalidateSeconds: revalidate } : {},
|
|
143
|
+
...expire !== undefined ? { expireSeconds: expire } : {},
|
|
144
|
+
...stale !== undefined ? { staleSeconds: stale } : {}
|
|
145
|
+
});
|
|
146
|
+
if (revalidate !== undefined)
|
|
147
|
+
recordCacheRevalidate(revalidate);
|
|
148
|
+
if (isPrerendering() && stale === 0)
|
|
149
|
+
throw new PostponeError("cacheLife");
|
|
150
|
+
}
|
|
151
|
+
var unstable_cacheTag = cacheTag;
|
|
152
|
+
var unstable_cacheLife = cacheLife;
|
|
153
|
+
|
|
154
|
+
export { refresh, unstable_refresh, revalidatePath, revalidateTag, updateTag, unstable_expirePath, unstable_expireTag, expirePath, expireTag, unstable_cache, unstable_noStore, cacheTag, cacheLife, unstable_cacheTag, unstable_cacheLife };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
traceEnabled
|
|
4
|
+
} from "./index-vz0km5qk.js";
|
|
5
|
+
|
|
6
|
+
// src/cli/boot/trace.ts
|
|
7
|
+
import { loadavg, cpus, arch, platform } from "os";
|
|
8
|
+
import { readdirSync } from "fs";
|
|
9
|
+
import path from "path";
|
|
10
|
+
var enabled = traceEnabled("boot");
|
|
11
|
+
var marks = [];
|
|
12
|
+
var cacheAtStart = enabled ? cacheState() : "cold";
|
|
13
|
+
function cacheState() {
|
|
14
|
+
return countTopLevel(path.join(".pnext", "dev", "cache")) > 0 ? "warm" : "cold";
|
|
15
|
+
}
|
|
16
|
+
var rss = () => typeof process.memoryUsage.rss === "function" ? process.memoryUsage.rss() : process.memoryUsage().rss;
|
|
17
|
+
function markBoot(name) {
|
|
18
|
+
if (enabled)
|
|
19
|
+
marks.push([name, performance.now(), rss()]);
|
|
20
|
+
}
|
|
21
|
+
function traceHeader() {
|
|
22
|
+
const load = loadavg().map((value) => value.toFixed(1)).join(" ");
|
|
23
|
+
const packages = countTopLevel("node_modules");
|
|
24
|
+
return [
|
|
25
|
+
` runtime ${typeof Bun !== "undefined" ? `bun ${Bun.version}` : `node ${process.version}`} \xB7 ${platform()} ${arch()} \xB7 ${cpus().length} cpus \xB7 load ${load}`,
|
|
26
|
+
` app ${packages} node_modules entries \xB7 .pnext/dev cache ${cacheAtStart}`
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
function countTopLevel(dir) {
|
|
30
|
+
try {
|
|
31
|
+
return readdirSync(path.resolve(dir)).length;
|
|
32
|
+
} catch {
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function printBootTrace() {
|
|
37
|
+
if (!enabled || marks.length === 0)
|
|
38
|
+
return;
|
|
39
|
+
const lines = ["boot trace (ms since process start):", ...traceHeader()];
|
|
40
|
+
let previous = 0;
|
|
41
|
+
for (const [name, at, rss2] of marks) {
|
|
42
|
+
const mb = (rss2 / 1048576).toFixed(0).padStart(5);
|
|
43
|
+
lines.push(` ${name.padEnd(16)} +${(at - previous).toFixed(1).padStart(7)} @${at.toFixed(1)} rss ${mb} MB`);
|
|
44
|
+
previous = at;
|
|
45
|
+
}
|
|
46
|
+
lines.push(` total @${performance.now().toFixed(1)}`);
|
|
47
|
+
console.log(lines.join(`
|
|
48
|
+
`));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { markBoot, printBootTrace };
|