@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,472 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
devServerModuleHref,
|
|
4
|
+
registerServerRuntime
|
|
5
|
+
} from "./index-3xbr4eyv.js";
|
|
6
|
+
import {
|
|
7
|
+
pathToFileHref
|
|
8
|
+
} from "./index-x93hv0sc.js";
|
|
9
|
+
import {
|
|
10
|
+
runWithRequest
|
|
11
|
+
} from "./index-grta8ap3.js";
|
|
12
|
+
import {
|
|
13
|
+
getProxyExtensions,
|
|
14
|
+
withRouteRuntime
|
|
15
|
+
} from "./index-zqpqyg8p.js";
|
|
16
|
+
import {
|
|
17
|
+
__require
|
|
18
|
+
} from "./index-rt9qq1va.js";
|
|
19
|
+
|
|
20
|
+
// src/routing/proxy.ts
|
|
21
|
+
import { existsSync, readFileSync, statSync } from "fs";
|
|
22
|
+
import path from "path";
|
|
23
|
+
import {
|
|
24
|
+
copyMiddlewareHeaders,
|
|
25
|
+
forwardMiddlewareRequestHeaders,
|
|
26
|
+
getSetCookie,
|
|
27
|
+
NextResponse,
|
|
28
|
+
nextResponseMeta,
|
|
29
|
+
parseCookies,
|
|
30
|
+
requestCookieHeader,
|
|
31
|
+
toNextRequest
|
|
32
|
+
} from "../../../src/api/server.ts";
|
|
33
|
+
import { canonicalTrailingSlashPath, isBuildAssetPathname } from "../../../src/routing/href.ts";
|
|
34
|
+
var proxyRewriteObserver;
|
|
35
|
+
function setProxyRewriteObserver(observer) {
|
|
36
|
+
proxyRewriteObserver = observer;
|
|
37
|
+
}
|
|
38
|
+
var proxyRunObserver;
|
|
39
|
+
function setProxyRunObserver(observer) {
|
|
40
|
+
proxyRunObserver = observer;
|
|
41
|
+
}
|
|
42
|
+
function wrapMiddleware(request, fn) {
|
|
43
|
+
return proxyRunObserver ? proxyRunObserver(request, fn) : fn();
|
|
44
|
+
}
|
|
45
|
+
var proxyExtensions = [".ts", ".tsx", ".js", ".jsx", ".mts"];
|
|
46
|
+
function findProxyFile(config) {
|
|
47
|
+
return findProxyFiles(config)[0];
|
|
48
|
+
}
|
|
49
|
+
function proxyExternalLoadTarget(file) {
|
|
50
|
+
return path.basename(file).startsWith("proxy.") ? "client-ssr" : "edge";
|
|
51
|
+
}
|
|
52
|
+
function findProxyFiles(config, names = getProxyExtensions().names) {
|
|
53
|
+
const files = [];
|
|
54
|
+
for (const base of proxyBases(config)) {
|
|
55
|
+
for (const name of names) {
|
|
56
|
+
for (const extension of proxyExtensions) {
|
|
57
|
+
const file = path.join(base, `${name}${extension}`);
|
|
58
|
+
if (existsSync(file))
|
|
59
|
+
files.push(file);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return files;
|
|
64
|
+
}
|
|
65
|
+
async function validateProxyFiles(config) {
|
|
66
|
+
await getProxyExtensions().validateFiles(config);
|
|
67
|
+
}
|
|
68
|
+
function createProxyRunner(config, runnerOptions = {}) {
|
|
69
|
+
const { released } = runnerOptions;
|
|
70
|
+
const file = released ? released.file : findProxyFile(config);
|
|
71
|
+
const releasedMatchers = released?.config ? proxyMatchers(released.config) : undefined;
|
|
72
|
+
const runtimeReady = registerServerRuntime(config, file ? [file] : []);
|
|
73
|
+
runtimeReady.catch(() => {
|
|
74
|
+
return;
|
|
75
|
+
});
|
|
76
|
+
let moduleKey;
|
|
77
|
+
let modulePromise;
|
|
78
|
+
let matchers;
|
|
79
|
+
function proxyModule(options) {
|
|
80
|
+
const key = proxyModuleKey(options);
|
|
81
|
+
const load = () => runtimeReady.then(() => importProxyModule(config, file, options, runnerOptions));
|
|
82
|
+
if (key !== moduleKey) {
|
|
83
|
+
moduleKey = key;
|
|
84
|
+
modulePromise = load();
|
|
85
|
+
matchers = undefined;
|
|
86
|
+
}
|
|
87
|
+
return modulePromise ??= load();
|
|
88
|
+
}
|
|
89
|
+
const runner = async (request, options = {}) => {
|
|
90
|
+
const url = new URL(request.url);
|
|
91
|
+
if (url.pathname.startsWith("/__pnext/") || !config.compat?.next && isBuildAssetPathname(url.pathname)) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (!file)
|
|
95
|
+
return;
|
|
96
|
+
if (!matchers && proxyMatcherGateEnabled()) {
|
|
97
|
+
const staticMatchers = released ? releasedMatchers : await staticProxyMatchers(file);
|
|
98
|
+
if (staticMatchers && !matchesProxy(staticMatchers, url, request))
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const module = await proxyModule(options);
|
|
102
|
+
matchers ??= proxyMatchers(module.config);
|
|
103
|
+
if (!matchesProxy(matchers, url, request))
|
|
104
|
+
return;
|
|
105
|
+
request = await bufferProxyRequestBody(request, url.pathname);
|
|
106
|
+
const handlerExport = getProxyExtensions().handlerExport(module);
|
|
107
|
+
if (typeof handlerExport !== "function")
|
|
108
|
+
throw new Error(`${file} must export proxy or default`);
|
|
109
|
+
const handler = handlerExport;
|
|
110
|
+
const handlerRequest = getProxyExtensions().skipUrlNormalize() ? request : stripFlightHeaders(stripRscUnionQuery(request));
|
|
111
|
+
const nextRequest = toNextRequest(handlerRequest);
|
|
112
|
+
const proxyResponseHeaders = new Headers;
|
|
113
|
+
let response = await runWithRequest(nextRequest, () => withRouteRuntime("edge", () => wrapMiddleware(nextRequest, () => handler(nextRequest, {
|
|
114
|
+
waitUntil(promise) {}
|
|
115
|
+
}))), {}, { responseHeaders: proxyResponseHeaders });
|
|
116
|
+
const scopedCookies = getSetCookie(proxyResponseHeaders);
|
|
117
|
+
if (scopedCookies.length > 0) {
|
|
118
|
+
if (!response)
|
|
119
|
+
response = NextResponse.next();
|
|
120
|
+
for (const cookie of scopedCookies)
|
|
121
|
+
response.headers.append("set-cookie", cookie);
|
|
122
|
+
}
|
|
123
|
+
if (!response)
|
|
124
|
+
return { request };
|
|
125
|
+
response = await normalizeRedirectResponse(response, url, request.method, config);
|
|
126
|
+
const meta = nextResponseMeta(response);
|
|
127
|
+
if (!meta)
|
|
128
|
+
return response;
|
|
129
|
+
const forwardedRequest = forwardMiddlewareRequestHeaders(response, applyProxyCookies(applyRequestOverride(request, meta.requestHeaders), response));
|
|
130
|
+
if (meta.kind === "rewrite" && meta.url) {
|
|
131
|
+
let rewritten = rewriteRequest(forwardedRequest, meta.url);
|
|
132
|
+
const rewrittenUrl = new URL(rewritten.url);
|
|
133
|
+
if (rewrittenUrl.origin !== url.origin) {
|
|
134
|
+
const rscHash = url.searchParams.get("_rsc");
|
|
135
|
+
if (rscHash !== null && !rewrittenUrl.searchParams.has("_rsc")) {
|
|
136
|
+
rewrittenUrl.searchParams.set("_rsc", rscHash);
|
|
137
|
+
rewritten = new Request(rewrittenUrl, rewritten);
|
|
138
|
+
}
|
|
139
|
+
getProxyExtensions().onExternalRewrite(rewritten);
|
|
140
|
+
const externalHeaders = new Headers(rewritten.headers);
|
|
141
|
+
externalHeaders.delete("host");
|
|
142
|
+
const external = await fetch(new Request(rewritten, { headers: externalHeaders }));
|
|
143
|
+
const headers = new Headers(external.headers);
|
|
144
|
+
headers.delete("content-encoding");
|
|
145
|
+
headers.delete("content-length");
|
|
146
|
+
headers.delete("transfer-encoding");
|
|
147
|
+
const proxied = new Response(external.body, {
|
|
148
|
+
status: external.status,
|
|
149
|
+
statusText: external.statusText,
|
|
150
|
+
headers
|
|
151
|
+
});
|
|
152
|
+
copyMiddlewareHeaders(response, proxied);
|
|
153
|
+
return proxied;
|
|
154
|
+
}
|
|
155
|
+
if (rewrittenUrl.origin === url.origin) {
|
|
156
|
+
proxyRewriteObserver?.(url, rewrittenUrl);
|
|
157
|
+
if (request.headers.get("x-nextjs-data") === "1") {
|
|
158
|
+
response.headers.set("x-nextjs-rewrite", rewrittenUrl.href);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return { request: rewritten, response };
|
|
162
|
+
}
|
|
163
|
+
return { request: forwardedRequest, response };
|
|
164
|
+
};
|
|
165
|
+
runner.warm = (options = {}) => {
|
|
166
|
+
if (!file)
|
|
167
|
+
return;
|
|
168
|
+
proxyModule(options).catch(() => {
|
|
169
|
+
return;
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
return runner;
|
|
173
|
+
}
|
|
174
|
+
async function normalizeRedirectResponse(response, requestUrl, method, config) {
|
|
175
|
+
if (response.status < 300 || response.status >= 400)
|
|
176
|
+
return response;
|
|
177
|
+
const location = response.headers.get("location");
|
|
178
|
+
if (!location)
|
|
179
|
+
return response;
|
|
180
|
+
let target;
|
|
181
|
+
try {
|
|
182
|
+
target = new URL(location, requestUrl);
|
|
183
|
+
} catch {
|
|
184
|
+
return response;
|
|
185
|
+
}
|
|
186
|
+
if (target.origin === requestUrl.origin) {
|
|
187
|
+
if (!config.skipTrailingSlashRedirect && config.trailingSlash) {
|
|
188
|
+
target.pathname = canonicalTrailingSlashPath(target.pathname, true);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const destination = target.origin === requestUrl.origin ? `${target.pathname}${target.search}${target.hash}` : target.href;
|
|
192
|
+
const headers = new Headers(response.headers);
|
|
193
|
+
headers.set("location", destination);
|
|
194
|
+
const body = method.toUpperCase() === "HEAD" || response.body === null ? null : await response.arrayBuffer();
|
|
195
|
+
const synthesizeDestination = method.toUpperCase() !== "HEAD" && (!body || body.byteLength === 0);
|
|
196
|
+
if (synthesizeDestination)
|
|
197
|
+
headers.delete("content-length");
|
|
198
|
+
return new Response(synthesizeDestination ? destination : body, {
|
|
199
|
+
status: response.status,
|
|
200
|
+
statusText: response.statusText,
|
|
201
|
+
headers
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function formatBodyLimit(bytes) {
|
|
205
|
+
if (bytes >= 1024 * 1024 && bytes % (1024 * 1024) === 0)
|
|
206
|
+
return `${bytes / (1024 * 1024)}MB`;
|
|
207
|
+
if (bytes >= 1024 && bytes % 1024 === 0)
|
|
208
|
+
return `${bytes / 1024}KB`;
|
|
209
|
+
return `${bytes}B`;
|
|
210
|
+
}
|
|
211
|
+
async function bufferProxyRequestBody(request, pathname) {
|
|
212
|
+
if (request.method === "GET" || request.method === "HEAD" || !request.body)
|
|
213
|
+
return request;
|
|
214
|
+
const limit = getProxyExtensions().clientMaxBodySize();
|
|
215
|
+
const chunks = [];
|
|
216
|
+
let total = 0;
|
|
217
|
+
let truncated = false;
|
|
218
|
+
const reader = request.body.getReader();
|
|
219
|
+
for (;; ) {
|
|
220
|
+
const { done, value } = await reader.read();
|
|
221
|
+
if (done)
|
|
222
|
+
break;
|
|
223
|
+
if (!truncated && total + value.byteLength > limit) {
|
|
224
|
+
const keep = limit - total;
|
|
225
|
+
if (keep > 0)
|
|
226
|
+
chunks.push(value.subarray(0, keep));
|
|
227
|
+
total = limit;
|
|
228
|
+
truncated = true;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (!truncated) {
|
|
232
|
+
chunks.push(value);
|
|
233
|
+
total += value.byteLength;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (truncated) {
|
|
237
|
+
console.warn(`Request body exceeded ${formatBodyLimit(limit)} for ${pathname}`);
|
|
238
|
+
}
|
|
239
|
+
const body = new Uint8Array(total);
|
|
240
|
+
let offset = 0;
|
|
241
|
+
for (const chunk of chunks) {
|
|
242
|
+
body.set(chunk, offset);
|
|
243
|
+
offset += chunk.byteLength;
|
|
244
|
+
}
|
|
245
|
+
const headers = new Headers(request.headers);
|
|
246
|
+
headers.set("content-length", String(total));
|
|
247
|
+
return new Request(request.url, {
|
|
248
|
+
method: request.method,
|
|
249
|
+
headers,
|
|
250
|
+
body,
|
|
251
|
+
duplex: "half"
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
function applyProxyResponse(response, proxyResponse) {
|
|
255
|
+
if (proxyResponse)
|
|
256
|
+
copyMiddlewareHeaders(proxyResponse, response);
|
|
257
|
+
return response;
|
|
258
|
+
}
|
|
259
|
+
function proxyRoutePatterns(config) {
|
|
260
|
+
const matcher = config?.matcher;
|
|
261
|
+
if (!matcher)
|
|
262
|
+
return ["^/(.*)$"];
|
|
263
|
+
const matchers = Array.isArray(matcher) ? matcher : [matcher];
|
|
264
|
+
return matchers.map((item) => anchoredMatcherPattern(matcherSource(item)));
|
|
265
|
+
}
|
|
266
|
+
async function importProxyModule(config, file, options, runnerOptions) {
|
|
267
|
+
const href = options.dev ? await devServerModuleHref(config, file, options.devImportVersion ?? "dev", {
|
|
268
|
+
conditionTarget: "edge",
|
|
269
|
+
externalLoadTarget: proxyExternalLoadTarget(file),
|
|
270
|
+
reactServerLayer: true
|
|
271
|
+
}) : runnerOptions.compiledModuleHref ?? pathToFileHref(file);
|
|
272
|
+
return import(href);
|
|
273
|
+
}
|
|
274
|
+
function proxyBases(config) {
|
|
275
|
+
return config.appPath === path.join(config.root, "src", "app") ? [path.join(config.root, "src"), config.root] : [config.root];
|
|
276
|
+
}
|
|
277
|
+
function proxyMatcherGateEnabled() {
|
|
278
|
+
return process.env.PNEXT_PROXY_MATCHER_GATE !== "0";
|
|
279
|
+
}
|
|
280
|
+
var staticMatcherCache = new Map;
|
|
281
|
+
async function staticProxyMatchers(file) {
|
|
282
|
+
let key;
|
|
283
|
+
try {
|
|
284
|
+
const stats = statSync(file);
|
|
285
|
+
key = `${stats.size}:${stats.mtimeMs}`;
|
|
286
|
+
} catch {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const cached = staticMatcherCache.get(file);
|
|
290
|
+
if (cached?.key === key)
|
|
291
|
+
return cached.matchers;
|
|
292
|
+
let matchers;
|
|
293
|
+
try {
|
|
294
|
+
const { staticProxyConfig } = await import("./proxy-config-j84dgksn.js");
|
|
295
|
+
const config = staticProxyConfig(file, readFileSync(file, "utf8"));
|
|
296
|
+
if (config)
|
|
297
|
+
matchers = proxyMatchers(config);
|
|
298
|
+
} catch {
|
|
299
|
+
matchers = undefined;
|
|
300
|
+
}
|
|
301
|
+
staticMatcherCache.set(file, { key, matchers });
|
|
302
|
+
return matchers;
|
|
303
|
+
}
|
|
304
|
+
function proxyMatchers(config) {
|
|
305
|
+
const matcher = config?.matcher;
|
|
306
|
+
if (!matcher)
|
|
307
|
+
return [{ regex: /.*/ }];
|
|
308
|
+
const matchers = Array.isArray(matcher) ? matcher : [matcher];
|
|
309
|
+
return matchers.map((item) => ({
|
|
310
|
+
regex: matcherRegex(matcherSource(item)),
|
|
311
|
+
...typeof item === "object" && item.has ? { has: item.has } : {},
|
|
312
|
+
...typeof item === "object" && item.missing ? { missing: item.missing } : {}
|
|
313
|
+
}));
|
|
314
|
+
}
|
|
315
|
+
function matchesProxy(matchers, url, request) {
|
|
316
|
+
const { pathname } = url;
|
|
317
|
+
const decoded = pathname.includes("%") ? decodedPathnames(pathname) : [];
|
|
318
|
+
return matchers.some((matcher) => (matcher.regex.test(pathname) || decoded.some((item) => matcher.regex.test(item))) && matchesConditions(matcher, url, request));
|
|
319
|
+
}
|
|
320
|
+
function matchesConditions(matcher, url, request) {
|
|
321
|
+
if (matcher.has && !matcher.has.every((condition) => hasCondition(condition, url, request))) {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
if (matcher.missing?.some((condition) => hasCondition(condition, url, request))) {
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
329
|
+
function hasCondition(condition, url, request) {
|
|
330
|
+
const actual = conditionValue(condition, url, request);
|
|
331
|
+
if (actual === null)
|
|
332
|
+
return false;
|
|
333
|
+
if (condition.value === undefined)
|
|
334
|
+
return true;
|
|
335
|
+
try {
|
|
336
|
+
return new RegExp(`^${condition.value}$`).test(actual);
|
|
337
|
+
} catch {
|
|
338
|
+
return condition.value === actual;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
function conditionValue(condition, url, request) {
|
|
342
|
+
switch (condition.type) {
|
|
343
|
+
case "header":
|
|
344
|
+
return condition.key ? request.headers.get(condition.key) : null;
|
|
345
|
+
case "query":
|
|
346
|
+
return condition.key ? url.searchParams.get(condition.key) : null;
|
|
347
|
+
case "cookie": {
|
|
348
|
+
if (!condition.key)
|
|
349
|
+
return null;
|
|
350
|
+
const cookie = parseCookies(request.headers.get("cookie") ?? "").find((item) => item.name === condition.key);
|
|
351
|
+
return cookie ? cookie.value : null;
|
|
352
|
+
}
|
|
353
|
+
case "host":
|
|
354
|
+
return url.host;
|
|
355
|
+
default:
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
function decodedPathnames(pathname) {
|
|
360
|
+
const decoded = [pathname.replace(/%2f/gi, "/")];
|
|
361
|
+
try {
|
|
362
|
+
decoded.push(decodeURIComponent(pathname));
|
|
363
|
+
} catch {}
|
|
364
|
+
return decoded;
|
|
365
|
+
}
|
|
366
|
+
function matcherSource(matcher) {
|
|
367
|
+
return typeof matcher === "string" ? matcher : matcher.source;
|
|
368
|
+
}
|
|
369
|
+
function matcherRegex(matcher) {
|
|
370
|
+
return new RegExp(anchoredMatcherPattern(matcher));
|
|
371
|
+
}
|
|
372
|
+
function anchoredMatcherPattern(matcher) {
|
|
373
|
+
return `^(?:${matcherPattern(matcher)})/*$`;
|
|
374
|
+
}
|
|
375
|
+
function matcherPattern(matcher) {
|
|
376
|
+
if (matcher.includes("("))
|
|
377
|
+
return matcher;
|
|
378
|
+
if (matcher === "/")
|
|
379
|
+
return "/";
|
|
380
|
+
let source = "";
|
|
381
|
+
for (const segment of matcher.split("/").filter(Boolean)) {
|
|
382
|
+
if (/^:[^/]+\*$/.test(segment)) {
|
|
383
|
+
source += "(?:/.*)?";
|
|
384
|
+
} else if (/^:[^/]+$/.test(segment)) {
|
|
385
|
+
source += "/[^/]+";
|
|
386
|
+
} else {
|
|
387
|
+
source += `/${escapeRegex(segment)}`;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return source || "/";
|
|
391
|
+
}
|
|
392
|
+
function rewriteRequest(request, url) {
|
|
393
|
+
return new Request(new URL(url, request.url), request);
|
|
394
|
+
}
|
|
395
|
+
function stripRscUnionQuery(request) {
|
|
396
|
+
const url = new URL(request.url);
|
|
397
|
+
if (!url.searchParams.has("_rsc"))
|
|
398
|
+
return request;
|
|
399
|
+
url.searchParams.delete("_rsc");
|
|
400
|
+
return new Request(url, request);
|
|
401
|
+
}
|
|
402
|
+
var FLIGHT_HEADERS = [
|
|
403
|
+
"rsc",
|
|
404
|
+
"next-router-state-tree",
|
|
405
|
+
"next-router-prefetch",
|
|
406
|
+
"next-hmr-refresh",
|
|
407
|
+
"next-router-segment-prefetch"
|
|
408
|
+
];
|
|
409
|
+
function stripFlightHeaders(request) {
|
|
410
|
+
if (!FLIGHT_HEADERS.some((header) => request.headers.has(header)))
|
|
411
|
+
return request;
|
|
412
|
+
const headers = new Headers(request.headers);
|
|
413
|
+
for (const header of FLIGHT_HEADERS)
|
|
414
|
+
headers.delete(header);
|
|
415
|
+
return new Request(request, { headers });
|
|
416
|
+
}
|
|
417
|
+
function applyRequestOverride(request, headers) {
|
|
418
|
+
if (!headers)
|
|
419
|
+
return request;
|
|
420
|
+
return new Request(request, { headers });
|
|
421
|
+
}
|
|
422
|
+
function applyProxyCookies(request, response) {
|
|
423
|
+
const setCookies = getSetCookie(response.headers);
|
|
424
|
+
if (setCookies.length === 0)
|
|
425
|
+
return request;
|
|
426
|
+
const cookies = parseCookies(request.headers.get("cookie") ?? "");
|
|
427
|
+
for (const header of setCookies) {
|
|
428
|
+
const cookie = parseSetCookie(header);
|
|
429
|
+
if (!cookie)
|
|
430
|
+
continue;
|
|
431
|
+
const index = cookies.findIndex((item) => item.name === cookie.name);
|
|
432
|
+
if (cookie.deleted) {
|
|
433
|
+
if (index !== -1)
|
|
434
|
+
cookies.splice(index, 1);
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
if (index === -1)
|
|
438
|
+
cookies.push({ name: cookie.name, value: cookie.value });
|
|
439
|
+
else
|
|
440
|
+
cookies[index] = { name: cookie.name, value: cookie.value };
|
|
441
|
+
}
|
|
442
|
+
const headers = new Headers(request.headers);
|
|
443
|
+
const cookieHeader = requestCookieHeader(cookies);
|
|
444
|
+
if (cookieHeader)
|
|
445
|
+
headers.set("cookie", cookieHeader);
|
|
446
|
+
else
|
|
447
|
+
headers.delete("cookie");
|
|
448
|
+
return new Request(request, { headers });
|
|
449
|
+
}
|
|
450
|
+
function parseSetCookie(header) {
|
|
451
|
+
const [pair = "", ...attributes] = header.split(";").map((part) => part.trim());
|
|
452
|
+
const [name = "", ...valueParts] = pair.split("=");
|
|
453
|
+
if (!name)
|
|
454
|
+
return;
|
|
455
|
+
const deleted = attributes.some((attribute) => /^max-age=0$/i.test(attribute));
|
|
456
|
+
return { name: decodeCookiePart(name), value: decodeCookiePart(valueParts.join("=")), deleted };
|
|
457
|
+
}
|
|
458
|
+
function decodeCookiePart(value) {
|
|
459
|
+
try {
|
|
460
|
+
return decodeURIComponent(value);
|
|
461
|
+
} catch {
|
|
462
|
+
return value;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
function escapeRegex(value) {
|
|
466
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
467
|
+
}
|
|
468
|
+
function proxyModuleKey(options) {
|
|
469
|
+
return options.dev ? `dev:${options.devImportVersion ?? "dev"}` : "prod";
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
export { setProxyRewriteObserver, setProxyRunObserver, findProxyFile, proxyExternalLoadTarget, findProxyFiles, validateProxyFiles, createProxyRunner, applyProxyResponse, proxyRoutePatterns };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/compat/react/style-values.ts
|
|
3
|
+
import { options } from "preact";
|
|
4
|
+
var UNITLESS = " animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex" + " boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative" + " flexOrder fontWeight gridArea gridColumn gridColumnEnd gridColumnSpan gridColumnStart gridRow" + " gridRowEnd gridRowSpan gridRowStart lineClamp lineHeight opacity order orphans scale tabSize widows" + " zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit" + " strokeOpacity strokeWidth ";
|
|
5
|
+
var VENDOR_PREFIX = /^(?:Webkit|Moz|ms|O)(?=[A-Z])/;
|
|
6
|
+
function unitless(name) {
|
|
7
|
+
if (UNITLESS.includes(` ${name} `))
|
|
8
|
+
return true;
|
|
9
|
+
const base = name.replace(VENDOR_PREFIX, "");
|
|
10
|
+
return base !== name && UNITLESS.includes(` ${base[0].toLowerCase()}${base.slice(1)} `);
|
|
11
|
+
}
|
|
12
|
+
function reactStyleValue(name, value) {
|
|
13
|
+
if (typeof value === "boolean")
|
|
14
|
+
return "";
|
|
15
|
+
if (typeof value !== "number")
|
|
16
|
+
return;
|
|
17
|
+
if (value !== 0 && !name.startsWith("--") && !unitless(name))
|
|
18
|
+
return;
|
|
19
|
+
return String(value);
|
|
20
|
+
}
|
|
21
|
+
function applyReactStyleValues(vnode) {
|
|
22
|
+
if (typeof vnode.type !== "string")
|
|
23
|
+
return;
|
|
24
|
+
const props = vnode.props;
|
|
25
|
+
const style = props?.style;
|
|
26
|
+
if (!style || typeof style !== "object" || Array.isArray(style))
|
|
27
|
+
return;
|
|
28
|
+
let normalized;
|
|
29
|
+
for (const name in style) {
|
|
30
|
+
const resolved = reactStyleValue(name, style[name]);
|
|
31
|
+
if (resolved === undefined)
|
|
32
|
+
continue;
|
|
33
|
+
normalized ??= { ...style };
|
|
34
|
+
normalized[name] = resolved;
|
|
35
|
+
}
|
|
36
|
+
if (normalized)
|
|
37
|
+
props.style = normalized;
|
|
38
|
+
}
|
|
39
|
+
var installed = Symbol.for("pnext.react-style-values-installed");
|
|
40
|
+
var styleOptions = options;
|
|
41
|
+
if (!styleOptions[installed]) {
|
|
42
|
+
const previousVNode = options.vnode?.bind(options);
|
|
43
|
+
options.vnode = (vnode) => {
|
|
44
|
+
previousVNode?.(vnode);
|
|
45
|
+
applyReactStyleValues(vnode);
|
|
46
|
+
};
|
|
47
|
+
styleOptions[installed] = true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { reactStyleValue, applyReactStyleValues };
|