@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,30 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/compat/next/preferred-region.ts
|
|
3
|
+
import { readFileSync } from "fs";
|
|
4
|
+
var PREFERRED_REGION_RE = /\bexport\s+const\s+preferredRegion\s*=\s*(\[[^\]]*\]|['"][^'"]*['"])/;
|
|
5
|
+
function preferredRegionForRoute(route) {
|
|
6
|
+
for (const file of routeSources(route)) {
|
|
7
|
+
let source;
|
|
8
|
+
try {
|
|
9
|
+
source = readFileSync(file, "utf8");
|
|
10
|
+
} catch {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
const match = PREFERRED_REGION_RE.exec(source);
|
|
14
|
+
if (!match?.[1])
|
|
15
|
+
continue;
|
|
16
|
+
return parsePreferredRegion(match[1]);
|
|
17
|
+
}
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
function routeSources(route) {
|
|
21
|
+
return [...new Set([route.file, ...route.sourceFiles])].filter(Boolean);
|
|
22
|
+
}
|
|
23
|
+
function parsePreferredRegion(literal) {
|
|
24
|
+
if (literal.startsWith("[")) {
|
|
25
|
+
return Array.from(literal.matchAll(/['"]([^'"]*)['"]/g), (m) => m[1] ?? "");
|
|
26
|
+
}
|
|
27
|
+
return [literal.slice(1, -1)];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { preferredRegionForRoute };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
useSyncExternalStore
|
|
4
|
+
} from "./index-tgcakdxc.js";
|
|
5
|
+
import {
|
|
6
|
+
useActionState
|
|
7
|
+
} from "./index-68m3mwbd.js";
|
|
8
|
+
import {
|
|
9
|
+
registerResourceHint
|
|
10
|
+
} from "./index-yhxkxghe.js";
|
|
11
|
+
|
|
12
|
+
// src/compat/react/dom.ts
|
|
13
|
+
import ReactCompat from "preact/compat";
|
|
14
|
+
var ReactDomCompat = Object.assign(ReactCompat, {
|
|
15
|
+
preload,
|
|
16
|
+
preconnect,
|
|
17
|
+
prefetchDNS,
|
|
18
|
+
preinit
|
|
19
|
+
});
|
|
20
|
+
var dom_default = ReactDomCompat;
|
|
21
|
+
var render = ReactCompat.render;
|
|
22
|
+
var hydrate = ReactCompat.hydrate;
|
|
23
|
+
var createPortal = ReactCompat.createPortal;
|
|
24
|
+
var findDOMNode = ReactCompat.findDOMNode;
|
|
25
|
+
var flushSync = ReactCompat.flushSync;
|
|
26
|
+
var unmountComponentAtNode = ReactCompat.unmountComponentAtNode;
|
|
27
|
+
var unstable_batchedUpdates = ReactCompat.unstable_batchedUpdates;
|
|
28
|
+
var version = ReactCompat.version;
|
|
29
|
+
function preload(href, options) {
|
|
30
|
+
registerResourceHint({
|
|
31
|
+
rel: "preload",
|
|
32
|
+
url: href,
|
|
33
|
+
...options?.as ? { as: options.as } : {},
|
|
34
|
+
...options?.type ? { type: options.type } : {},
|
|
35
|
+
...options?.fetchPriority ? { fetchPriority: options.fetchPriority } : {},
|
|
36
|
+
...options?.media ? { media: options.media } : {},
|
|
37
|
+
...options?.nonce ? { nonce: options.nonce } : {},
|
|
38
|
+
...options?.crossOrigin ? { crossOrigin: options.crossOrigin } : {}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function preconnect(href, options) {
|
|
42
|
+
registerResourceHint({
|
|
43
|
+
rel: "preconnect",
|
|
44
|
+
url: href,
|
|
45
|
+
...options?.crossOrigin ? { crossOrigin: options.crossOrigin } : {}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function prefetchDNS(href) {
|
|
49
|
+
registerResourceHint({ rel: "dns-prefetch", url: href });
|
|
50
|
+
}
|
|
51
|
+
function preinit(href, options) {
|
|
52
|
+
registerResourceHint({
|
|
53
|
+
rel: "preload",
|
|
54
|
+
url: href,
|
|
55
|
+
...options?.as ? { as: options.as } : {},
|
|
56
|
+
...options?.crossOrigin ? { crossOrigin: options.crossOrigin } : {}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
var useFormState = useActionState;
|
|
60
|
+
var NOT_PENDING = {
|
|
61
|
+
pending: false,
|
|
62
|
+
data: null,
|
|
63
|
+
method: null,
|
|
64
|
+
action: null
|
|
65
|
+
};
|
|
66
|
+
var pendingStack = [];
|
|
67
|
+
var listeners = new Set;
|
|
68
|
+
var storeVersion = 0;
|
|
69
|
+
function __pnextPushFormStatus(status) {
|
|
70
|
+
pendingStack.push(status);
|
|
71
|
+
notify();
|
|
72
|
+
return () => {
|
|
73
|
+
const index = pendingStack.indexOf(status);
|
|
74
|
+
if (index !== -1)
|
|
75
|
+
pendingStack.splice(index, 1);
|
|
76
|
+
notify();
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function notify() {
|
|
80
|
+
storeVersion += 1;
|
|
81
|
+
for (const listener of [...listeners])
|
|
82
|
+
listener();
|
|
83
|
+
}
|
|
84
|
+
function subscribe(listener) {
|
|
85
|
+
listeners.add(listener);
|
|
86
|
+
return () => {
|
|
87
|
+
listeners.delete(listener);
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function useFormStatus() {
|
|
91
|
+
useSyncExternalStore(subscribe, () => storeVersion, () => storeVersion);
|
|
92
|
+
return pendingStack.length > 0 ? pendingStack[pendingStack.length - 1] : NOT_PENDING;
|
|
93
|
+
}
|
|
94
|
+
function requestFormReset(form) {
|
|
95
|
+
if (form && typeof form.reset === "function")
|
|
96
|
+
form.reset();
|
|
97
|
+
}
|
|
98
|
+
Object.assign(ReactDomCompat, { useFormState, useFormStatus, requestFormReset });
|
|
99
|
+
|
|
100
|
+
export { render, hydrate, createPortal, findDOMNode, flushSync, unmountComponentAtNode, unstable_batchedUpdates, version, preload, preconnect, prefetchDNS, preinit, useFormState, __pnextPushFormStatus, useFormStatus, requestFormReset, dom_default };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
currentRenderCacheMeta
|
|
4
|
+
} from "./index-akkrvjn6.js";
|
|
5
|
+
import {
|
|
6
|
+
legacyRequestAPIs
|
|
7
|
+
} from "./index-grta8ap3.js";
|
|
8
|
+
|
|
9
|
+
// src/compat/next/legacy-request-apis.ts
|
|
10
|
+
var PROMISE_PROPS = new Set(["then", "catch", "finally", "constructor"]);
|
|
11
|
+
var warned = new Set;
|
|
12
|
+
function withSyncAccess(promise, api, produce) {
|
|
13
|
+
let value;
|
|
14
|
+
const resolve = () => value ??= produce();
|
|
15
|
+
return new Proxy(promise, {
|
|
16
|
+
get(target, prop) {
|
|
17
|
+
if (PROMISE_PROPS.has(prop) || prop === Symbol.toStringTag) {
|
|
18
|
+
const own = Reflect.get(target, prop, target);
|
|
19
|
+
return typeof own === "function" ? own.bind(target) : own;
|
|
20
|
+
}
|
|
21
|
+
warnSyncApiAccess(api, prop);
|
|
22
|
+
const source = resolve();
|
|
23
|
+
const read = Reflect.get(source, prop, source);
|
|
24
|
+
return typeof read === "function" ? read.bind(source) : read;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function withSyncProps(promise, kind, value) {
|
|
29
|
+
if (!legacyRequestAPIs())
|
|
30
|
+
return promise;
|
|
31
|
+
for (const key of Object.keys(value)) {
|
|
32
|
+
if (key in promise)
|
|
33
|
+
continue;
|
|
34
|
+
Object.defineProperty(promise, key, {
|
|
35
|
+
get() {
|
|
36
|
+
warnSyncPropAccess(kind, key);
|
|
37
|
+
return value[key];
|
|
38
|
+
},
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return promise;
|
|
44
|
+
}
|
|
45
|
+
function warnSyncApiAccess(api, prop) {
|
|
46
|
+
const expression = prop === Symbol.iterator ? `\`...${api}()\` or similar iteration` : `\`${api}().${String(prop)}\``;
|
|
47
|
+
warnSyncAccess(expression, `${api}()`, "value");
|
|
48
|
+
}
|
|
49
|
+
function warnSyncPropAccess(kind, key) {
|
|
50
|
+
warnSyncAccess(`\`${kind}.${key}\``, kind, "properties");
|
|
51
|
+
}
|
|
52
|
+
function warnSyncAccess(expression, subject, noun) {
|
|
53
|
+
const route = currentRenderCacheMeta()?.route;
|
|
54
|
+
const key = `${route ?? ""}|${expression}|${callsite()}`;
|
|
55
|
+
if (warned.has(key))
|
|
56
|
+
return;
|
|
57
|
+
warned.add(key);
|
|
58
|
+
console.warn(`${route ? `Route "${route}" ` : "This route "}used ${expression}. ` + `\`${subject}\` should be awaited before using its ${noun}. ` + "Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis");
|
|
59
|
+
}
|
|
60
|
+
function callsite() {
|
|
61
|
+
const frames = new Error().stack?.split(`
|
|
62
|
+
`).slice(1) ?? [];
|
|
63
|
+
return frames.find((frame) => !frame.includes("legacy-request-apis")) ?? "";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { withSyncAccess, withSyncProps };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
getNextConfig
|
|
4
|
+
} from "./index-m63czgq5.js";
|
|
5
|
+
|
|
6
|
+
// src/compat/mdx/compile.ts
|
|
7
|
+
import { existsSync } from "fs";
|
|
8
|
+
import { createRequire } from "module";
|
|
9
|
+
import path from "path";
|
|
10
|
+
import { pathToFileURL } from "url";
|
|
11
|
+
var cachedModule;
|
|
12
|
+
async function loadMdx() {
|
|
13
|
+
if (cachedModule !== undefined)
|
|
14
|
+
return cachedModule;
|
|
15
|
+
try {
|
|
16
|
+
const specifier = "@mdx-js/mdx";
|
|
17
|
+
cachedModule = await import(specifier);
|
|
18
|
+
} catch {
|
|
19
|
+
cachedModule = null;
|
|
20
|
+
}
|
|
21
|
+
return cachedModule;
|
|
22
|
+
}
|
|
23
|
+
function mdxOptionsFromConfig() {
|
|
24
|
+
const config = getNextConfig();
|
|
25
|
+
return config.mdxOptions ?? {};
|
|
26
|
+
}
|
|
27
|
+
function resolveMdxComponents(root) {
|
|
28
|
+
const bases = [root, path.join(root, "src")];
|
|
29
|
+
const names = [
|
|
30
|
+
"mdx-components.tsx",
|
|
31
|
+
"mdx-components.ts",
|
|
32
|
+
"mdx-components.jsx",
|
|
33
|
+
"mdx-components.js",
|
|
34
|
+
"mdx-components.mjs"
|
|
35
|
+
];
|
|
36
|
+
for (const base of bases) {
|
|
37
|
+
for (const name of names) {
|
|
38
|
+
const candidate = path.join(base, name);
|
|
39
|
+
if (existsSync(candidate))
|
|
40
|
+
return candidate;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
function interopDefault(module) {
|
|
46
|
+
return module?.default ?? module;
|
|
47
|
+
}
|
|
48
|
+
var UNRESOLVED_PLUGIN = Symbol("pnext.mdx.unresolved-plugin");
|
|
49
|
+
async function resolvePlugin(entry, resolveFrom) {
|
|
50
|
+
if (typeof entry === "function")
|
|
51
|
+
return entry;
|
|
52
|
+
if (typeof entry === "string") {
|
|
53
|
+
return loadPlugin(entry, resolveFrom);
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(entry) && typeof entry[0] === "string") {
|
|
56
|
+
const tuple = entry;
|
|
57
|
+
const plugin = await loadPlugin(tuple[0], resolveFrom);
|
|
58
|
+
if (plugin === UNRESOLVED_PLUGIN)
|
|
59
|
+
return UNRESOLVED_PLUGIN;
|
|
60
|
+
return [plugin, ...tuple.slice(1)];
|
|
61
|
+
}
|
|
62
|
+
return entry;
|
|
63
|
+
}
|
|
64
|
+
async function loadPlugin(name, resolveFrom) {
|
|
65
|
+
let resolved;
|
|
66
|
+
try {
|
|
67
|
+
resolved = resolveFrom.resolve(name);
|
|
68
|
+
} catch {
|
|
69
|
+
console.warn(`pnext: MDX plugin '${name}' is configured but not installed; skipping it. Install it to apply this remark/rehype/recma plugin.`);
|
|
70
|
+
return UNRESOLVED_PLUGIN;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
return interopDefault(await import(pathToFileURL(resolved).href));
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.warn(`pnext: MDX plugin '${name}' failed to load and was skipped: ${error instanceof Error ? error.message : String(error)}. ` + "Ensure it is installed in the app\u2019s node_modules (not only Bun\u2019s auto-install cache).");
|
|
76
|
+
return UNRESOLVED_PLUGIN;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function resolvePlugins(plugins, resolveFrom) {
|
|
80
|
+
const resolved = await Promise.all(plugins.map((entry) => resolvePlugin(entry, resolveFrom)));
|
|
81
|
+
return resolved.filter((entry) => entry !== UNRESOLVED_PLUGIN);
|
|
82
|
+
}
|
|
83
|
+
async function compileMdx(source, filePath, root) {
|
|
84
|
+
const mdx = await loadMdx();
|
|
85
|
+
if (!mdx) {
|
|
86
|
+
throw new Error("MDX support requires the '@mdx-js/mdx' package. Install it to render .mdx files.");
|
|
87
|
+
}
|
|
88
|
+
const userOptions = mdxOptionsFromConfig();
|
|
89
|
+
const provider = resolveMdxComponents(root);
|
|
90
|
+
const resolveFrom = createRequire(path.join(root, "noop.js"));
|
|
91
|
+
const [remarkPlugins, rehypePlugins, recmaPlugins] = await Promise.all([
|
|
92
|
+
resolvePlugins(userOptions.remarkPlugins ?? [], resolveFrom),
|
|
93
|
+
resolvePlugins(userOptions.rehypePlugins ?? [], resolveFrom),
|
|
94
|
+
resolvePlugins(userOptions.recmaPlugins ?? [], resolveFrom)
|
|
95
|
+
]);
|
|
96
|
+
const compiled = await mdx.compile({ value: source, path: filePath }, {
|
|
97
|
+
jsx: true,
|
|
98
|
+
jsxImportSource: "preact",
|
|
99
|
+
format: "mdx",
|
|
100
|
+
development: false,
|
|
101
|
+
remarkPlugins,
|
|
102
|
+
rehypePlugins,
|
|
103
|
+
recmaPlugins,
|
|
104
|
+
...userOptions.remarkRehypeOptions ? { remarkRehypeOptions: userOptions.remarkRehypeOptions } : {},
|
|
105
|
+
...userOptions.providerImportSource ? { providerImportSource: userOptions.providerImportSource } : provider ? { providerImportSource: provider } : {}
|
|
106
|
+
});
|
|
107
|
+
return { code: compiled.toString() };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { mdxOptionsFromConfig, resolveMdxComponents, compileMdx };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/utils/html.ts
|
|
3
|
+
function escapeHtml(value) {
|
|
4
|
+
return stringifyHtmlValue(value).replace(/[&<>"']/g, (char) => {
|
|
5
|
+
switch (char) {
|
|
6
|
+
case "&":
|
|
7
|
+
return "&";
|
|
8
|
+
case "<":
|
|
9
|
+
return "<";
|
|
10
|
+
case ">":
|
|
11
|
+
return ">";
|
|
12
|
+
case '"':
|
|
13
|
+
return """;
|
|
14
|
+
case "'":
|
|
15
|
+
return "'";
|
|
16
|
+
default:
|
|
17
|
+
return char;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function stringifyHtmlValue(value) {
|
|
22
|
+
if (value === undefined || value === null)
|
|
23
|
+
return "";
|
|
24
|
+
if (typeof value === "string")
|
|
25
|
+
return value;
|
|
26
|
+
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
|
|
27
|
+
return String(value);
|
|
28
|
+
}
|
|
29
|
+
if (value instanceof URL)
|
|
30
|
+
return value.href;
|
|
31
|
+
if (value instanceof Date)
|
|
32
|
+
return value.toISOString();
|
|
33
|
+
if (typeof value !== "object")
|
|
34
|
+
return "";
|
|
35
|
+
const stringifier = value.toString;
|
|
36
|
+
if (!stringifier || stringifier === Object.prototype.toString)
|
|
37
|
+
return "";
|
|
38
|
+
const stringified = stringifier.call(value);
|
|
39
|
+
if (typeof stringified === "string")
|
|
40
|
+
return stringified;
|
|
41
|
+
if (typeof stringified === "number" || typeof stringified === "boolean" || typeof stringified === "bigint") {
|
|
42
|
+
return String(stringified);
|
|
43
|
+
}
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { escapeHtml, stringifyHtmlValue };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/render/resource-hints.ts
|
|
3
|
+
var HINT_LISTENER = Symbol.for("pnext.resourceHintListener");
|
|
4
|
+
var RENDER_BUFFER_SCOPE = Symbol.for("pnext.renderBufferScope");
|
|
5
|
+
var RENDER_BUFFER_STRAYS = Symbol.for("pnext.renderBufferStrays");
|
|
6
|
+
var newRenderBufferFrame = () => ({ hints: [], head: [], deferred: [] });
|
|
7
|
+
var globals = globalThis;
|
|
8
|
+
function frame() {
|
|
9
|
+
const scope = globals[RENDER_BUFFER_SCOPE];
|
|
10
|
+
return scope?.getStore() ?? (globals[RENDER_BUFFER_STRAYS] ??= newRenderBufferFrame());
|
|
11
|
+
}
|
|
12
|
+
function renderBuffer(kind) {
|
|
13
|
+
return frame()[kind];
|
|
14
|
+
}
|
|
15
|
+
function takeRenderBuffer(kind) {
|
|
16
|
+
const active = frame();
|
|
17
|
+
const buffer = active[kind];
|
|
18
|
+
active[kind] = [];
|
|
19
|
+
return buffer;
|
|
20
|
+
}
|
|
21
|
+
function clearRenderBuffer(kind) {
|
|
22
|
+
frame()[kind] = [];
|
|
23
|
+
const strays = globals[RENDER_BUFFER_STRAYS];
|
|
24
|
+
if (strays)
|
|
25
|
+
strays[kind] = [];
|
|
26
|
+
}
|
|
27
|
+
function setResourceHintListener(listener) {
|
|
28
|
+
globalThis[HINT_LISTENER] = listener;
|
|
29
|
+
}
|
|
30
|
+
function registerResourceHint(hint) {
|
|
31
|
+
if (typeof window !== "undefined")
|
|
32
|
+
return;
|
|
33
|
+
const listener = globalThis[HINT_LISTENER];
|
|
34
|
+
listener?.(hint);
|
|
35
|
+
const hints = renderBuffer("hints");
|
|
36
|
+
if (hints.some((existing) => resourceHintKey(existing) === resourceHintKey(hint)))
|
|
37
|
+
return;
|
|
38
|
+
hints.push(hint);
|
|
39
|
+
}
|
|
40
|
+
function clearResourceHints() {
|
|
41
|
+
clearRenderBuffer("hints");
|
|
42
|
+
}
|
|
43
|
+
function takeResourceHints() {
|
|
44
|
+
return takeRenderBuffer("hints");
|
|
45
|
+
}
|
|
46
|
+
function resourceHintKey(hint) {
|
|
47
|
+
if (hint.rel === "preload" && hint.as === "image") {
|
|
48
|
+
const srcSet = hint.attributes?.imagesrcset;
|
|
49
|
+
const first = typeof srcSet === "string" ? srcSet.split(/[\s,]+/)[0] : undefined;
|
|
50
|
+
return `image:${first || hint.url || ""}`;
|
|
51
|
+
}
|
|
52
|
+
const attributes = Object.entries(hint.attributes ?? {}).sort(([a], [b]) => a.localeCompare(b));
|
|
53
|
+
return JSON.stringify({ ...hint, attributes });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { RENDER_BUFFER_SCOPE, newRenderBufferFrame, renderBuffer, takeRenderBuffer, clearRenderBuffer, setResourceHintListener, registerResourceHint, clearResourceHints, takeResourceHints };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import { join as __pnextJoin } from "node:path";
|
|
3
|
+
const __PNEXT_PACKAGE_ROOT__ = __pnextJoin(import.meta.dirname, "../../..");
|
|
4
|
+
import {
|
|
5
|
+
hasModuleDirective
|
|
6
|
+
} from "./index-jbj7ehef.js";
|
|
7
|
+
import {
|
|
8
|
+
readText
|
|
9
|
+
} from "./index-4da76t62.js";
|
|
10
|
+
import {
|
|
11
|
+
pathToFileHref
|
|
12
|
+
} from "./index-71885zaq.js";
|
|
13
|
+
import {
|
|
14
|
+
clientReferenceId
|
|
15
|
+
} from "./index-ras0sdab.js";
|
|
16
|
+
import {
|
|
17
|
+
moduleExportNames,
|
|
18
|
+
moduleExportStars
|
|
19
|
+
} from "./index-x9c55pzy.js";
|
|
20
|
+
import {
|
|
21
|
+
resolveImport
|
|
22
|
+
} from "./index-d1jsmhhk.js";
|
|
23
|
+
|
|
24
|
+
// src/client/reference-stub.ts
|
|
25
|
+
import path from "path";
|
|
26
|
+
var clientReferenceRuntimeFile = path.resolve(__PNEXT_PACKAGE_ROOT__ + "/src/client", "reference.ts");
|
|
27
|
+
function clientReferenceModuleSource(sourceFile, exportNames, options = {}) {
|
|
28
|
+
const portable = options.portable;
|
|
29
|
+
const located = portable ? `decodeURIComponent(new URL(${JSON.stringify(path.relative(path.dirname(portable.from), portable.target).split(path.sep).join("/"))}, import.meta.url).pathname)` : undefined;
|
|
30
|
+
const file = !located ? JSON.stringify(sourceFile) : portable?.real ? `__pnextRealpath(${located})` : located;
|
|
31
|
+
const reference = (exportName) => `createReference({ id: ${JSON.stringify(`c-${clientReferenceId(sourceFile, exportName)}`)}, file: ${file}, exportName: ${JSON.stringify(exportName)} })`;
|
|
32
|
+
const defaultExport = exportNames.includes("default") ? `export default ${reference("default")};` : "";
|
|
33
|
+
const namedExports = exportNames.filter((name) => name !== "default").map((name) => `export const ${name} = ${reference(name)};`);
|
|
34
|
+
const symbol = options.inlineSymbol ? `const clientReferenceSymbol = Symbol.for('pnext.clientReference');` : `import { clientReferenceSymbol } from ${JSON.stringify(pathToFileHref(clientReferenceRuntimeFile))};`;
|
|
35
|
+
const realpath = portable?.real ? `import { realpathSync as __pnextRealpath } from 'node:fs';
|
|
36
|
+
` : "";
|
|
37
|
+
return `${realpath}${symbol}
|
|
38
|
+
|
|
39
|
+
function createReference(reference) {
|
|
40
|
+
function ClientReference({ children }) {
|
|
41
|
+
return children ?? null;
|
|
42
|
+
}
|
|
43
|
+
ClientReference[clientReferenceSymbol] = reference;
|
|
44
|
+
return ClientReference;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
${defaultExport}
|
|
48
|
+
${namedExports.join(`
|
|
49
|
+
`)}
|
|
50
|
+
`;
|
|
51
|
+
}
|
|
52
|
+
async function clientReferenceExportNames(config, file, source, visited = new Set) {
|
|
53
|
+
const key = path.resolve(file);
|
|
54
|
+
if (visited.has(key))
|
|
55
|
+
return [];
|
|
56
|
+
visited.add(key);
|
|
57
|
+
const text = source ?? await readText(file);
|
|
58
|
+
const names = new Set(moduleExportNames(text, file));
|
|
59
|
+
if (names.size === 0) {
|
|
60
|
+
for (const match of text.matchAll(/\bexports\.([A-Za-z_$][\w$]*)\s*=/g)) {
|
|
61
|
+
if (match[1] !== "__esModule")
|
|
62
|
+
names.add(match[1]);
|
|
63
|
+
}
|
|
64
|
+
if (/\bmodule\.exports\s*=/.test(text))
|
|
65
|
+
names.add("default");
|
|
66
|
+
}
|
|
67
|
+
for (const specifier of moduleExportStars(text, file)) {
|
|
68
|
+
const resolved = resolveImport(config.root, file, specifier, config.workspaceRoot);
|
|
69
|
+
if (!resolved || !isInside(config.workspaceRoot, resolved))
|
|
70
|
+
continue;
|
|
71
|
+
for (const name of await clientReferenceExportNames(config, resolved, undefined, visited)) {
|
|
72
|
+
if (name !== "default")
|
|
73
|
+
names.add(name);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return [...names];
|
|
77
|
+
}
|
|
78
|
+
function hasUseClientDirective(source) {
|
|
79
|
+
return hasModuleDirective(source, "use client");
|
|
80
|
+
}
|
|
81
|
+
function isInside(root, file) {
|
|
82
|
+
const relative = path.relative(root, file);
|
|
83
|
+
return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { clientReferenceModuleSource, clientReferenceExportNames, hasUseClientDirective };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
recordUseCacheLife,
|
|
4
|
+
recordUseCacheTags
|
|
5
|
+
} from "./index-j0m1jxqa.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-akkrvjn6.js";
|
|
19
|
+
import {
|
|
20
|
+
getNextConfig
|
|
21
|
+
} from "./index-m63czgq5.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 };
|