@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.
Files changed (302) hide show
  1. package/bin/pnext +9 -2
  2. package/dist/server/_chunks/aliases-j47a10ce.js +44 -0
  3. package/dist/server/_chunks/analyze-arswqe6s.js +445 -0
  4. package/dist/server/_chunks/boot-af0mv3dy.js +36 -0
  5. package/dist/server/_chunks/build-spy3dxp4.js +84 -0
  6. package/dist/server/_chunks/build-t9h0hec3.js +3550 -0
  7. package/dist/server/_chunks/build-tier-m7yvqz61.js +2472 -0
  8. package/dist/server/_chunks/compile-53j02j27.js +22 -0
  9. package/dist/server/_chunks/config-1yzwexq6.js +27 -0
  10. package/dist/server/_chunks/config-n2z7yxps.js +22 -0
  11. package/dist/server/_chunks/create-meec9hs6.js +134 -0
  12. package/dist/server/_chunks/dev-fjmqg6en.js +220 -0
  13. package/dist/server/_chunks/esbuild-yyktfrtt.js +15 -0
  14. package/dist/server/_chunks/generate-n9sh6hzt.js +21 -0
  15. package/dist/server/_chunks/index-0374j2b9.js +66 -0
  16. package/dist/server/_chunks/index-06nyqntx.js +213 -0
  17. package/dist/server/_chunks/index-1011cscr.js +5263 -0
  18. package/dist/server/_chunks/index-11sfk4hb.js +170 -0
  19. package/dist/server/_chunks/index-20ppawv7.js +297 -0
  20. package/dist/server/_chunks/index-2dv4y4wd.js +1065 -0
  21. package/dist/server/_chunks/index-2vz0wzdn.js +59 -0
  22. package/dist/server/_chunks/index-2wfv4kvx.js +182 -0
  23. package/dist/server/_chunks/index-357na4a8.js +109 -0
  24. package/dist/server/_chunks/index-3b3at80h.js +109 -0
  25. package/dist/server/_chunks/index-3tf1xjsp.js +6166 -0
  26. package/dist/server/_chunks/index-3xbr4eyv.js +105 -0
  27. package/dist/server/_chunks/index-4399bvd2.js +18 -0
  28. package/dist/server/_chunks/index-4hgjrqh7.js +851 -0
  29. package/dist/server/_chunks/index-4q2gbfwk.js +2530 -0
  30. package/dist/server/_chunks/index-4t92hdxd.js +172 -0
  31. package/dist/server/_chunks/index-4zzebszd.js +10 -0
  32. package/dist/server/_chunks/index-5gyr4emz.js +107 -0
  33. package/dist/server/_chunks/index-5hr4062s.js +70 -0
  34. package/dist/server/_chunks/index-68m3mwbd.js +84 -0
  35. package/dist/server/_chunks/index-6b009mt0.js +56 -0
  36. package/dist/server/_chunks/index-6e4fqv30.js +588 -0
  37. package/dist/server/_chunks/index-6gex3pfa.js +15 -0
  38. package/dist/server/_chunks/index-6kp9r0d9.js +11 -0
  39. package/dist/server/_chunks/index-6q7zvrap.js +134 -0
  40. package/dist/server/_chunks/index-73z4esab.js +38 -0
  41. package/dist/server/_chunks/index-79ngvam8.js +60 -0
  42. package/dist/server/_chunks/index-7wc9n8be.js +25 -0
  43. package/dist/server/_chunks/index-8k7pfejn.js +1599 -0
  44. package/dist/server/_chunks/index-8kcxdfya.js +206 -0
  45. package/dist/server/_chunks/index-91x12ykq.js +274 -0
  46. package/dist/server/_chunks/index-9ch50vtq.js +18 -0
  47. package/dist/server/_chunks/index-9hx2641q.js +28 -0
  48. package/dist/server/_chunks/index-9n2914ww.js +535 -0
  49. package/dist/server/_chunks/index-9ych9ma8.js +207 -0
  50. package/dist/server/_chunks/index-b6wtkdp4.js +24 -0
  51. package/dist/server/_chunks/index-bcws5eh2.js +35 -0
  52. package/dist/server/_chunks/index-c0g2wf3z.js +92 -0
  53. package/dist/server/_chunks/index-cf4rvxv6.js +95 -0
  54. package/dist/server/_chunks/index-cjgqs13g.js +65 -0
  55. package/dist/server/_chunks/index-ckkdpht5.js +41 -0
  56. package/dist/server/_chunks/index-cyfednwb.js +87 -0
  57. package/dist/server/_chunks/index-danncfhy.js +311 -0
  58. package/dist/server/_chunks/index-dg0f05zs.js +199 -0
  59. package/dist/server/_chunks/index-e3a6yx84.js +18 -0
  60. package/dist/server/_chunks/index-e88tyv35.js +45 -0
  61. package/dist/server/_chunks/index-eajaspjk.js +1253 -0
  62. package/dist/server/_chunks/index-eeaanp2e.js +483 -0
  63. package/dist/server/_chunks/index-egykcqg3.js +101 -0
  64. package/dist/server/_chunks/index-en7n9f7m.js +22 -0
  65. package/dist/server/_chunks/index-ezgj0tr1.js +88 -0
  66. package/dist/server/_chunks/index-fkp000p1.js +590 -0
  67. package/dist/server/_chunks/index-fn1chkkd.js +214 -0
  68. package/dist/server/_chunks/index-fp8r0sqs.js +64 -0
  69. package/dist/server/_chunks/index-ggk2j965.js +9432 -0
  70. package/dist/server/_chunks/index-grta8ap3.js +238 -0
  71. package/dist/server/_chunks/index-h2a70tg4.js +7 -0
  72. package/dist/server/_chunks/index-h4xy648y.js +51 -0
  73. package/dist/server/_chunks/index-hkdfj58q.js +92 -0
  74. package/dist/server/_chunks/index-j2zrcp1k.js +66 -0
  75. package/dist/server/_chunks/index-jcsjq3d1.js +20 -0
  76. package/dist/server/_chunks/index-jepjvcrf.js +198 -0
  77. package/dist/server/_chunks/index-jks0x0a1.js +14 -0
  78. package/dist/server/_chunks/index-jx7bqvw1.js +57 -0
  79. package/dist/server/_chunks/index-k1g3epw0.js +1299 -0
  80. package/dist/server/_chunks/index-knp0s912.js +7 -0
  81. package/dist/server/_chunks/index-kq8kpzye.js +472 -0
  82. package/dist/server/_chunks/index-kqyy1d4f.js +50 -0
  83. package/dist/server/_chunks/index-kresp2n8.js +445 -0
  84. package/dist/server/_chunks/index-ms9v9tnx.js +31 -0
  85. package/dist/server/_chunks/index-n4hxpng2.js +11 -0
  86. package/dist/server/_chunks/index-ncnes8c6.js +17 -0
  87. package/dist/server/_chunks/index-nqh3xhdc.js +57 -0
  88. package/dist/server/_chunks/index-nyrba2kr.js +4130 -0
  89. package/dist/server/_chunks/index-p77b4kcx.js +296 -0
  90. package/dist/server/_chunks/index-pym1cezq.js +39 -0
  91. package/dist/server/_chunks/index-q738kkhj.js +100 -0
  92. package/dist/server/_chunks/index-qjj6gddn.js +54 -0
  93. package/dist/server/_chunks/index-qm6kmhqs.js +110 -0
  94. package/dist/server/_chunks/index-qn4z5s3c.js +819 -0
  95. package/dist/server/_chunks/index-qpwsgt3a.js +158 -0
  96. package/dist/server/_chunks/index-r97ptz1q.js +97 -0
  97. package/dist/server/_chunks/index-ras0sdab.js +26 -0
  98. package/dist/server/_chunks/index-rcs322t1.js +19 -0
  99. package/dist/server/_chunks/index-rn8dyr1f.js +126 -0
  100. package/dist/server/_chunks/index-rt9qq1va.js +4 -0
  101. package/dist/server/_chunks/index-rthrsed5.js +356 -0
  102. package/dist/server/_chunks/index-sctcgyvv.js +185 -0
  103. package/dist/server/_chunks/index-sjpckxqn.js +213 -0
  104. package/dist/server/_chunks/index-sq3kvz3g.js +200 -0
  105. package/dist/server/_chunks/index-stbk3jhn.js +31 -0
  106. package/dist/server/_chunks/index-sv8m6789.js +266 -0
  107. package/dist/server/_chunks/index-tgcakdxc.js +125 -0
  108. package/dist/server/_chunks/index-tgsfjmep.js +74 -0
  109. package/dist/server/_chunks/index-tq0pc7eg.js +154 -0
  110. package/dist/server/_chunks/index-tq1f96v7.js +51 -0
  111. package/dist/server/_chunks/index-tqn2qnnn.js +241 -0
  112. package/dist/server/_chunks/index-tvqkq6e6.js +128 -0
  113. package/dist/server/_chunks/index-v1ags1na.js +132 -0
  114. package/dist/server/_chunks/index-vvmmknm1.js +1431 -0
  115. package/dist/server/_chunks/index-vvq7rqtn.js +329 -0
  116. package/dist/server/_chunks/index-vz0km5qk.js +33 -0
  117. package/dist/server/_chunks/index-w6h8m6vp.js +138 -0
  118. package/dist/server/_chunks/index-web361b8.js +138 -0
  119. package/dist/server/_chunks/index-wpfhfbs4.js +194 -0
  120. package/dist/server/_chunks/index-x0y005nh.js +283 -0
  121. package/dist/server/_chunks/index-x3yn4ywm.js +22 -0
  122. package/dist/server/_chunks/index-x93hv0sc.js +271 -0
  123. package/dist/server/_chunks/index-xvj80c3a.js +30 -0
  124. package/dist/server/_chunks/index-xywjg2vc.js +100 -0
  125. package/dist/server/_chunks/index-y2jr2n72.js +152 -0
  126. package/dist/server/_chunks/index-y36a0ybw.js +57 -0
  127. package/dist/server/_chunks/index-ye9hmsvf.js +47 -0
  128. package/dist/server/_chunks/index-yhxkxghe.js +56 -0
  129. package/dist/server/_chunks/index-ym67zqxp.js +130 -0
  130. package/dist/server/_chunks/index-ytjvpbm2.js +736 -0
  131. package/dist/server/_chunks/index-yz54pxrh.js +960 -0
  132. package/dist/server/_chunks/index-z4z9zv3b.js +733 -0
  133. package/dist/server/_chunks/index-z84ab1w0.js +1270 -0
  134. package/dist/server/_chunks/index-z88qv16t.js +11 -0
  135. package/dist/server/_chunks/index-zqpqyg8p.js +666 -0
  136. package/dist/server/_chunks/loader-7yw0j98z.js +78 -0
  137. package/dist/server/_chunks/modules-jn8bmbn8.js +74 -0
  138. package/dist/server/_chunks/pipeline-yy9jhydf.js +832 -0
  139. package/dist/server/_chunks/production-jar9ztm3.js +44 -0
  140. package/dist/server/_chunks/proxy-config-j84dgksn.js +21 -0
  141. package/dist/server/_chunks/proxy-w1d0wmsn.js +33 -0
  142. package/dist/server/_chunks/router-k1reahfn.js +498 -0
  143. package/dist/server/_chunks/routes-2s277fc6.js +64 -0
  144. package/dist/server/_chunks/run-pvd8bs1t.js +696 -0
  145. package/dist/server/_chunks/server-mt4a994c.js +1835 -0
  146. package/dist/server/_chunks/tsconfig-defaults-1nb3308g.js +20 -0
  147. package/dist/server/_chunks/typegen-0qr0459b.js +35 -0
  148. package/dist/server/api/client-cache.js +14 -0
  149. package/dist/server/cli/index.js +378 -0
  150. package/dist/server/cli/start.js +137 -0
  151. package/dist/server/client/reference.js +16 -0
  152. package/dist/server/compat/next/cache.js +56 -0
  153. package/dist/server/compat/next/canonical-url.js +13 -0
  154. package/dist/server/compat/next/client-cache.js +57 -0
  155. package/dist/server/compat/next/client-navigation.js +232 -0
  156. package/dist/server/compat/next/client-only.js +1 -0
  157. package/dist/server/compat/next/client-script.js +178 -0
  158. package/dist/server/compat/next/client-server.js +34 -0
  159. package/dist/server/compat/next/config-headers.js +32 -0
  160. package/dist/server/compat/next/config-loader.js +25 -0
  161. package/dist/server/compat/next/config.js +10 -0
  162. package/dist/server/compat/next/constants.js +18 -0
  163. package/dist/server/compat/next/custom-server.js +10 -0
  164. package/dist/server/compat/next/dist/client/components/app-router-headers.js +48 -0
  165. package/dist/server/compat/next/dist/server/web/spec-extension/revalidate.js +27 -0
  166. package/dist/server/compat/next/dist/server/web/spec-extension/unstable-cache.js +25 -0
  167. package/dist/server/compat/next/dist/server/web/spec-extension/unstable-no-store.js +25 -0
  168. package/dist/server/compat/next/dynamic.js +32 -0
  169. package/dist/server/compat/next/error.js +112 -0
  170. package/dist/server/compat/next/font/cache.js +14 -0
  171. package/dist/server/compat/next/font/google.js +3 -0
  172. package/dist/server/compat/next/font/index.js +1 -0
  173. package/dist/server/compat/next/font/local.js +22 -0
  174. package/dist/server/compat/next/font/runtime-client.js +33 -0
  175. package/dist/server/compat/next/font/runtime.js +41 -0
  176. package/dist/server/compat/next/font/shared.js +22 -0
  177. package/dist/server/compat/next/form.js +129 -0
  178. package/dist/server/compat/next/head.js +10 -0
  179. package/dist/server/compat/next/headers.js +30 -0
  180. package/dist/server/compat/next/image/client.js +11 -0
  181. package/dist/server/compat/next/image/config.js +18 -0
  182. package/dist/server/compat/next/image/optimizer.js +25 -0
  183. package/dist/server/compat/next/image/patterns.js +12 -0
  184. package/dist/server/compat/next/image/props.js +16 -0
  185. package/dist/server/compat/next/image/shared.js +86 -0
  186. package/dist/server/compat/next/image/static-metadata.js +32 -0
  187. package/dist/server/compat/next/image/validate.js +8 -0
  188. package/dist/server/compat/next/image.js +59 -0
  189. package/dist/server/compat/next/index.js +1 -0
  190. package/dist/server/compat/next/legacy-image.js +78 -0
  191. package/dist/server/compat/next/legacy-request-apis.js +24 -0
  192. package/dist/server/compat/next/link-transform.js +14 -0
  193. package/dist/server/compat/next/link.js +14 -0
  194. package/dist/server/compat/next/navigation.js +190 -0
  195. package/dist/server/compat/next/offline.js +45 -0
  196. package/dist/server/compat/next/og.js +8 -0
  197. package/dist/server/compat/next/preferred-region.js +8 -0
  198. package/dist/server/compat/next/redirects.js +30 -0
  199. package/dist/server/compat/next/resource-hints.js +30 -0
  200. package/dist/server/compat/next/rewrites.js +41 -0
  201. package/dist/server/compat/next/root-params.js +121 -0
  202. package/dist/server/compat/next/route-state.js +23 -0
  203. package/dist/server/compat/next/router.js +103 -0
  204. package/dist/server/compat/next/script.js +37 -0
  205. package/dist/server/compat/next/server-only.js +1 -0
  206. package/dist/server/compat/next/server.js +131 -0
  207. package/dist/server/compat/next/svgr.js +14 -0
  208. package/dist/server/compat/next/telemetry.js +10 -0
  209. package/dist/server/compat/next/usage.js +13 -0
  210. package/dist/server/compat/next/user-agent.js +12 -0
  211. package/dist/server/compat/next/web-vitals.js +35 -0
  212. package/dist/server/compat/react/action-state.js +11 -0
  213. package/dist/server/compat/react/client-lite.js +83 -0
  214. package/dist/server/compat/react/client.js +131 -0
  215. package/dist/server/compat/react/compiler-runtime.js +42 -0
  216. package/dist/server/compat/react/dom-client.js +106 -0
  217. package/dist/server/compat/react/dom-react-server.js +37 -0
  218. package/dist/server/compat/react/dom-server.js +40 -0
  219. package/dist/server/compat/react/dom.js +52 -0
  220. package/dist/server/compat/react/hooks-extra.js +12 -0
  221. package/dist/server/compat/react/internals.js +14 -0
  222. package/dist/server/compat/react/parity.js +11 -0
  223. package/dist/server/compat/react/preact.js +113 -0
  224. package/dist/server/compat/react/react-server.js +133 -0
  225. package/dist/server/compat/react/router-shim.js +8 -0
  226. package/dist/server/compat/react/server-component-use.js +14 -0
  227. package/dist/server/compat/react/server-inserted-html.js +14 -0
  228. package/dist/server/compat/react/server.js +194 -0
  229. package/dist/server/compat/react/style-values.js +10 -0
  230. package/dist/server/compat/react/use.js +10 -0
  231. package/dist/server/compat/react/view-transition.js +12 -0
  232. package/dist/server/generation.json +1 -0
  233. package/package.json +4 -1
  234. package/src/api/dynamic.tsx +2 -0
  235. package/src/api/server.ts +24 -6
  236. package/src/cli/adapters/vercel-warm.ts +315 -61
  237. package/src/cli/adapters/vercel.ts +348 -71
  238. package/src/cli/build.ts +58 -33
  239. package/src/cli/index.ts +23 -10
  240. package/src/cli/serve/entry.ts +21 -159
  241. package/src/cli/serve/immutable.ts +31 -0
  242. package/src/cli/serve/pipeline.ts +82 -84
  243. package/src/cli/start.ts +3 -1
  244. package/src/client/chunk-fold.ts +19 -6
  245. package/src/client/react-tier.ts +3 -2
  246. package/src/client/reference-stub.ts +21 -2
  247. package/src/compat/actions/client-plugin.ts +4 -2
  248. package/src/compat/actions/config.ts +6 -5
  249. package/src/compat/actions/extensions.ts +2 -3
  250. package/src/compat/aliases.ts +8 -1
  251. package/src/compat/bundler/config.ts +88 -0
  252. package/src/compat/bundler/optimize-package-imports.ts +86 -26
  253. package/src/compat/bundler/relay-transform.ts +15 -3
  254. package/src/compat/cache-control.ts +16 -8
  255. package/src/compat/css/modules.ts +18 -5
  256. package/src/compat/lifecycle/error-funnel.ts +1 -1
  257. package/src/compat/lifecycle/instrumentation.ts +117 -24
  258. package/src/compat/lifecycle/testmode.ts +3 -2
  259. package/src/compat/next/config-loader.ts +137 -13
  260. package/src/compat/next/font/runtime.ts +22 -2
  261. package/src/compat/next/og.ts +3 -3
  262. package/src/compat/next/usage.ts +3 -2
  263. package/src/compat/pages/api.ts +83 -14
  264. package/src/compat/pages/router.ts +30 -14
  265. package/src/compat/register/bundler.ts +3 -1
  266. package/src/compat/register/middleware.ts +1 -1
  267. package/src/compat/register/otel.ts +5 -9
  268. package/src/compat/register/render.ts +3 -1
  269. package/src/compat/register/use-cache.ts +3 -1
  270. package/src/compat/release.ts +46 -0
  271. package/src/compat/segment/serve.ts +1 -1
  272. package/src/compat/validation/validate.ts +10 -7
  273. package/src/config.ts +51 -7
  274. package/src/css/assets.ts +213 -0
  275. package/src/css/build.ts +174 -238
  276. package/src/dev/server.ts +27 -8
  277. package/src/extensions.ts +4 -0
  278. package/src/render/hooks.ts +13 -0
  279. package/src/render/renderer.ts +52 -32
  280. package/src/request/context.ts +9 -0
  281. package/src/resolve/dynamic.ts +3 -1
  282. package/src/resolve/imports.ts +12 -52
  283. package/src/resolve/package-json.ts +56 -0
  284. package/src/resolve/scan-facts.ts +65 -0
  285. package/src/routing/href.ts +10 -3
  286. package/src/routing/match.ts +287 -0
  287. package/src/routing/metadata-files.ts +19 -5
  288. package/src/routing/proxy-config.ts +137 -0
  289. package/src/routing/proxy.ts +35 -134
  290. package/src/routing/routes.ts +22 -281
  291. package/src/runtime/fingerprint.ts +23 -8
  292. package/src/runtime/load.ts +170 -0
  293. package/src/runtime/loader.ts +215 -43
  294. package/src/runtime/module-cache.ts +13 -0
  295. package/src/runtime/modules.ts +370 -81
  296. package/src/runtime/prebundle.ts +81 -0
  297. package/src/runtime/production.ts +391 -0
  298. package/src/runtime/release-graph.ts +334 -0
  299. package/src/runtime/vendor-build.ts +724 -13
  300. package/src/runtime/vendor.ts +16 -3
  301. package/src/types.ts +2 -0
  302. package/src/utils/fs.ts +89 -3
@@ -0,0 +1,241 @@
1
+ // @bun
2
+ import { join as __pnextJoin } from "node:path";
3
+ const __PNEXT_PACKAGE_ROOT__ = __pnextJoin(import.meta.dirname, "../../..");
4
+ // src/runtime/production.ts
5
+ import { existsSync, readFileSync, readdirSync } from "fs";
6
+ import { mkdir, rename, rm, writeFile } from "fs/promises";
7
+ import path from "path";
8
+ import { pathToFileURL } from "url";
9
+ var BUILD_INDEX_VERSION = 1;
10
+ var LOCATOR_FILE = "release-locator.json";
11
+ var releases = new WeakMap;
12
+ var WORK_UNIT_STORAGE = Symbol.for("pnext.workUnitStorage");
13
+ function buildIndexFile(outPath) {
14
+ return path.join(outPath, "server", "build-index.json");
15
+ }
16
+ function releaseModuleKey(layer, target, file) {
17
+ return `${layer}:${target}:${file}`;
18
+ }
19
+ function productionRelease(config) {
20
+ return releases.get(config);
21
+ }
22
+ function servedRelease() {
23
+ const units = globalThis[WORK_UNIT_STORAGE];
24
+ return units?.getStore()?.release;
25
+ }
26
+ function servedConventions() {
27
+ return servedRelease()?.conventions;
28
+ }
29
+ function frozenDirListing(dir) {
30
+ const facts = servedConventions();
31
+ if (!facts || !isInsideDir(facts.appPath, dir))
32
+ return;
33
+ return facts.dirs.get(dir) ?? { files: new Set, dirs: [] };
34
+ }
35
+ function conventionFileExists(file) {
36
+ return frozenDirListing(path.dirname(file))?.files.has(path.basename(file)) ?? existsSync(file);
37
+ }
38
+ function releaseModuleHref(release, layer, target, file) {
39
+ const href = release.modules.get(releaseModuleKey(layer, target, path.resolve(file)));
40
+ if (!href) {
41
+ throw new Error(`pnext: ${file} (${layer}, ${target}) is not in this build's release. Run 'pnext build' again.`);
42
+ }
43
+ return href;
44
+ }
45
+ function attachRelease(config, index = readBuildIndex(config.outPath)) {
46
+ const existing = releases.get(config);
47
+ if (existing)
48
+ return existing;
49
+ const fromRoot = (file) => path.resolve(config.root, file);
50
+ const modules = new Map;
51
+ for (const [key, artifact] of Object.entries(index.modules)) {
52
+ const second = key.indexOf(":", key.indexOf(":") + 1);
53
+ modules.set(`${key.slice(0, second + 1)}${releaseSourceFile(key.slice(second + 1), config.root, config.workspaceRoot)}`, pathToFileURL(path.resolve(config.outPath, artifact)).href);
54
+ }
55
+ const dirs = new Map;
56
+ for (const [dir, names] of Object.entries(index.conventions)) {
57
+ dirs.set(fromRoot(dir), {
58
+ files: new Set(names.filter((name) => !name.endsWith("/"))),
59
+ dirs: names.filter((name) => name.endsWith("/")).map((name) => name.slice(0, -1))
60
+ });
61
+ }
62
+ const release = {
63
+ modules,
64
+ conventions: {
65
+ appPath: config.appPath,
66
+ dirs,
67
+ client: new Set(index.clientConventions.map(fromRoot)),
68
+ documentLayouts: new Set(index.documentLayouts.map(fromRoot))
69
+ },
70
+ globalCss: index.globalCss.map(fromRoot),
71
+ proxy: index.proxy ? { ...index.proxy, file: fromRoot(index.proxy.file) } : {},
72
+ ...index.compat ? { compat: index.compat } : {},
73
+ ...index.instrumentation ? {
74
+ instrumentation: {
75
+ file: path.resolve(config.outPath, index.instrumentation.file),
76
+ ...index.instrumentation.edge ? { edge: path.resolve(config.outPath, index.instrumentation.edge) } : {}
77
+ }
78
+ } : {},
79
+ ...index.fonts ? {
80
+ fonts: Object.fromEntries(Object.entries(index.fonts).map(([key, font]) => [
81
+ key,
82
+ { ...font, files: font.files.map((file) => path.resolve(config.outPath, file)) }
83
+ ]))
84
+ } : {}
85
+ };
86
+ releases.set(config, release);
87
+ return release;
88
+ }
89
+ var conventionBases = new Set([
90
+ "page",
91
+ "route",
92
+ "layout",
93
+ "template",
94
+ "loading",
95
+ "error",
96
+ "not-found",
97
+ "default",
98
+ "forbidden",
99
+ "unauthorized",
100
+ "global-error",
101
+ "global-not-found"
102
+ ]);
103
+ var metadataBase = /^(?:robots|sitemap|manifest|favicon|(?:apple-)?icon\d*|opengraph-image\d*|twitter-image\d*)$/;
104
+ var codeFile = /\.(?:[cm]?[jt]sx?|mdx?)$/;
105
+ function capturedFile(name) {
106
+ const base = /^[^.]+/.exec(name)?.[0] ?? name;
107
+ return conventionBases.has(base) || metadataBase.test(base);
108
+ }
109
+ function servedAppFiles(facts) {
110
+ return [...facts.dirs].flatMap(([dir, listing]) => [...listing.files].map((name) => path.join(dir, name)));
111
+ }
112
+ function captureConventions(root, appPath) {
113
+ const conventions = {};
114
+ const files = [];
115
+ const visit = (dir) => {
116
+ let entries;
117
+ try {
118
+ entries = readdirSync(dir, { withFileTypes: true });
119
+ } catch {
120
+ return;
121
+ }
122
+ const names = [];
123
+ for (const entry of entries) {
124
+ if (entry.isDirectory()) {
125
+ if (entry.name === "node_modules" || entry.name.startsWith("."))
126
+ continue;
127
+ names.push(`${entry.name}/`);
128
+ visit(path.join(dir, entry.name));
129
+ } else if (capturedFile(entry.name)) {
130
+ names.push(entry.name);
131
+ if (codeFile.test(entry.name))
132
+ files.push(path.join(dir, entry.name));
133
+ }
134
+ }
135
+ conventions[toPosix(path.relative(root, dir)) || "."] = names.sort();
136
+ };
137
+ visit(appPath);
138
+ return { conventions, files };
139
+ }
140
+ var frameworkRoot = path.resolve(__PNEXT_PACKAGE_ROOT__ + "/src/runtime", "..", "..");
141
+ function releaseSourceKey(file, root, workspaceRoot) {
142
+ const inRoot = path.relative(root, file);
143
+ if (!inRoot.startsWith("..") && !path.isAbsolute(inRoot))
144
+ return `r:${toPosix(inRoot)}`;
145
+ const inWorkspace = path.relative(workspaceRoot, file);
146
+ if (!inWorkspace.startsWith("..") && !path.isAbsolute(inWorkspace))
147
+ return `w:${toPosix(inWorkspace)}`;
148
+ const inFramework = path.relative(frameworkRoot, file);
149
+ if (!inFramework.startsWith("..") && !path.isAbsolute(inFramework))
150
+ return `f:${toPosix(inFramework)}`;
151
+ return `r:${toPosix(inRoot)}`;
152
+ }
153
+ function releaseSourceFile(key, root, workspaceRoot) {
154
+ const value = key.slice(2);
155
+ if (key.startsWith("r:"))
156
+ return path.join(root, value);
157
+ if (key.startsWith("w:"))
158
+ return path.resolve(workspaceRoot, value);
159
+ if (key.startsWith("f:"))
160
+ return path.resolve(frameworkRoot, value);
161
+ return path.join(root, value);
162
+ }
163
+ function toPosix(file) {
164
+ return file.split(path.sep).join("/");
165
+ }
166
+ function isInsideDir(root, file) {
167
+ return file === root || file.startsWith(`${root}${path.sep}`);
168
+ }
169
+ function readBuildIndex(outPath) {
170
+ const file = buildIndexFile(outPath);
171
+ let index;
172
+ try {
173
+ index = JSON.parse(readFileSync(file, "utf8"));
174
+ } catch (error) {
175
+ if (error.code !== "ENOENT")
176
+ throw error;
177
+ throw new Error("No production build found. Run 'pnext build' first.");
178
+ }
179
+ if (index.version !== BUILD_INDEX_VERSION) {
180
+ throw new Error(`pnext: ${file} is from another pnext version. Run 'pnext build' again.`);
181
+ }
182
+ return index;
183
+ }
184
+ function locateRelease(root, defaultOutDir) {
185
+ const outPath = path.join(root, defaultOutDir);
186
+ try {
187
+ const { outDir } = JSON.parse(readFileSync(path.join(outPath, LOCATOR_FILE), "utf8"));
188
+ return path.resolve(root, outDir);
189
+ } catch {
190
+ return existsSync(buildIndexFile(outPath)) ? outPath : undefined;
191
+ }
192
+ }
193
+ function serializeReleaseConfig(config) {
194
+ const relative = (file) => path.relative(config.root, file) || ".";
195
+ return JSON.parse(JSON.stringify({
196
+ ...config,
197
+ root: ".",
198
+ workspaceRoot: relative(config.workspaceRoot),
199
+ appPath: relative(config.appPath),
200
+ publicPath: relative(config.publicPath),
201
+ outPath: relative(config.outPath),
202
+ outRootPath: relative(config.outRootPath),
203
+ typesPath: relative(config.typesPath),
204
+ checksPath: relative(config.checksPath)
205
+ }, (_key, value) => value instanceof RegExp ? { $regexp: [value.source, value.flags] } : value));
206
+ }
207
+ function releaseConfig(serialized, root, outPath) {
208
+ const config = JSON.parse(JSON.stringify(serialized), (_key, value) => {
209
+ const pattern = value?.$regexp;
210
+ return pattern ? new RegExp(pattern[0], pattern[1]) : value;
211
+ });
212
+ const fromRoot = (file) => path.resolve(root, file);
213
+ const fromOut = (file) => path.resolve(outPath, path.relative(config.outPath, file));
214
+ return {
215
+ ...config,
216
+ root,
217
+ workspaceRoot: fromRoot(config.workspaceRoot),
218
+ appPath: fromRoot(config.appPath),
219
+ publicPath: fromRoot(config.publicPath),
220
+ outPath,
221
+ outRootPath: fromOut(config.outRootPath),
222
+ typesPath: fromOut(config.typesPath),
223
+ checksPath: fromOut(config.checksPath)
224
+ };
225
+ }
226
+ async function writeBuildIndex(config, index, defaultOutDir) {
227
+ const file = buildIndexFile(config.outPath);
228
+ const temporary = `${file}.${process.pid}.tmp`;
229
+ await writeFile(temporary, JSON.stringify(index));
230
+ await rename(temporary, file);
231
+ const defaultOut = path.join(config.root, defaultOutDir);
232
+ if (path.resolve(config.outPath) === path.resolve(defaultOut))
233
+ return;
234
+ await mkdir(defaultOut, { recursive: true });
235
+ const locator = path.join(defaultOut, LOCATOR_FILE);
236
+ await writeFile(`${locator}.${process.pid}.tmp`, JSON.stringify({ outDir: path.relative(config.root, config.outPath) }));
237
+ await rename(`${locator}.${process.pid}.tmp`, locator);
238
+ await rm(buildIndexFile(defaultOut), { force: true });
239
+ }
240
+
241
+ export { BUILD_INDEX_VERSION, buildIndexFile, releaseModuleKey, productionRelease, servedRelease, servedConventions, frozenDirListing, conventionFileExists, releaseModuleHref, attachRelease, servedAppFiles, captureConventions, releaseSourceKey, releaseSourceFile, readBuildIndex, locateRelease, serializeReleaseConfig, releaseConfig, writeBuildIndex };
@@ -0,0 +1,128 @@
1
+ // @bun
2
+ import {
3
+ findProxyFile
4
+ } from "./index-kq8kpzye.js";
5
+ import {
6
+ loadNative
7
+ } from "./index-7wc9n8be.js";
8
+ import {
9
+ __require
10
+ } from "./index-rt9qq1va.js";
11
+
12
+ // src/routing/proxy-config.ts
13
+ import { readFileSync } from "fs";
14
+ import path from "path";
15
+ var parseSync = (...args) => loadNative(() => __require("oxc-parser")).parseSync(...args);
16
+ function releasedProxy(config) {
17
+ const file = findProxyFile(config);
18
+ if (!file)
19
+ return;
20
+ try {
21
+ return { file, config: staticProxyConfig(file, readFileSync(file, "utf8")) };
22
+ } catch {
23
+ return { file };
24
+ }
25
+ }
26
+ function staticProxyConfig(file, source) {
27
+ const result = parseSync(file, source, { lang: parserLang(file) });
28
+ if (result.errors.length > 0)
29
+ return;
30
+ for (const statement of result.program.body) {
31
+ if (statement.type !== "ExportNamedDeclaration")
32
+ continue;
33
+ const declaration = statement.declaration;
34
+ if (declaration?.type !== "VariableDeclaration")
35
+ continue;
36
+ for (const declarator of declaration.declarations ?? []) {
37
+ if (declarator.id?.type !== "Identifier" || declarator.id.name !== "config")
38
+ continue;
39
+ const value = staticValue(declarator.init);
40
+ return isProxyConfigShape(value) ? value : undefined;
41
+ }
42
+ }
43
+ return;
44
+ }
45
+ function parserLang(file) {
46
+ const ext = path.extname(file);
47
+ if (ext === ".tsx")
48
+ return "tsx";
49
+ if (ext === ".jsx")
50
+ return "jsx";
51
+ return ext === ".js" || ext === ".mjs" ? "js" : "ts";
52
+ }
53
+ function staticValue(node) {
54
+ if (!node)
55
+ return;
56
+ switch (node.type) {
57
+ case "TSAsExpression":
58
+ case "TSSatisfiesExpression":
59
+ case "TSNonNullExpression":
60
+ return staticValue(node.expression);
61
+ case "Literal":
62
+ case "StringLiteral":
63
+ case "NumericLiteral":
64
+ case "BooleanLiteral":
65
+ return node.value === null ? undefined : node.value;
66
+ case "TemplateLiteral":
67
+ return node.expressions?.length === 0 ? node.quasis?.[0]?.value?.cooked ?? undefined : undefined;
68
+ case "ArrayExpression": {
69
+ const items = [];
70
+ for (const element of node.elements ?? []) {
71
+ const value = staticValue(element);
72
+ if (value === undefined)
73
+ return;
74
+ items.push(value);
75
+ }
76
+ return items;
77
+ }
78
+ case "ObjectExpression": {
79
+ const object = {};
80
+ for (const property of node.properties ?? []) {
81
+ if (property.type !== "Property" && property.type !== "ObjectProperty")
82
+ return;
83
+ if (property.computed)
84
+ return;
85
+ const key = property.key?.type === "Identifier" ? property.key.name : property.key?.value;
86
+ if (typeof key !== "string")
87
+ return;
88
+ const value = staticValue(property.value);
89
+ if (value === undefined)
90
+ return;
91
+ object[key] = value;
92
+ }
93
+ return object;
94
+ }
95
+ default:
96
+ return;
97
+ }
98
+ }
99
+ function isProxyConfigShape(value) {
100
+ if (typeof value !== "object" || value === null)
101
+ return false;
102
+ const matcher = value.matcher;
103
+ if (matcher === undefined)
104
+ return true;
105
+ const items = Array.isArray(matcher) ? matcher : [matcher];
106
+ return items.every((item) => {
107
+ if (typeof item === "string")
108
+ return true;
109
+ if (typeof item !== "object" || item === null)
110
+ return false;
111
+ const { source, has, missing } = item;
112
+ if (typeof source !== "string")
113
+ return false;
114
+ return [has, missing].every((list) => list === undefined || Array.isArray(list) && list.every(isConditionShape));
115
+ });
116
+ }
117
+ function isConditionShape(value) {
118
+ if (typeof value !== "object" || value === null)
119
+ return false;
120
+ const { type, key, value: expected } = value;
121
+ if (type !== "header" && type !== "query" && type !== "cookie" && type !== "host")
122
+ return false;
123
+ if (key !== undefined && typeof key !== "string")
124
+ return false;
125
+ return expected === undefined || typeof expected === "string";
126
+ }
127
+
128
+ export { releasedProxy, staticProxyConfig };
@@ -0,0 +1,132 @@
1
+ // @bun
2
+ // src/compat/ppr/root-params-scan.ts
3
+ import { existsSync, readdirSync, readFileSync, statSync } from "fs";
4
+ import path from "path";
5
+ var LAYOUT_BASENAMES = ["layout.tsx", "layout.ts", "layout.jsx", "layout.js"];
6
+ function isRootLayoutSource(source) {
7
+ return /<html[\s>]/.test(source);
8
+ }
9
+ function paramNameOfSegment(segment) {
10
+ const optional = /^\[\[\.\.\.(.+)\]\]$/.exec(segment);
11
+ if (optional)
12
+ return optional[1];
13
+ const catchAll = /^\[\.\.\.(.+)\]$/.exec(segment);
14
+ if (catchAll)
15
+ return catchAll[1];
16
+ const dynamic = /^\[(.+)\]$/.exec(segment);
17
+ if (dynamic)
18
+ return dynamic[1];
19
+ return;
20
+ }
21
+ function findLayoutFile(dir) {
22
+ for (const base of LAYOUT_BASENAMES) {
23
+ const candidate = path.join(dir, base);
24
+ if (existsSync(candidate))
25
+ return candidate;
26
+ }
27
+ return;
28
+ }
29
+ function scanRootParams(appPath) {
30
+ const rootParams = new Set;
31
+ if (!existsSync(appPath))
32
+ return rootParams;
33
+ const walk = (dir, paramsAbove) => {
34
+ const layoutFile = findLayoutFile(dir);
35
+ if (layoutFile) {
36
+ let source = "";
37
+ try {
38
+ source = readFileSync(layoutFile, "utf8");
39
+ } catch {
40
+ source = "";
41
+ }
42
+ if (isRootLayoutSource(source)) {
43
+ for (const name of paramsAbove)
44
+ rootParams.add(name);
45
+ }
46
+ }
47
+ let children = [];
48
+ try {
49
+ children = readdirSync(dir);
50
+ } catch {
51
+ return;
52
+ }
53
+ for (const child of children) {
54
+ const childPath = path.join(dir, child);
55
+ let isDir = false;
56
+ try {
57
+ isDir = statSync(childPath).isDirectory();
58
+ } catch {
59
+ isDir = false;
60
+ }
61
+ if (!isDir)
62
+ continue;
63
+ if (child.startsWith("@"))
64
+ continue;
65
+ const param = paramNameOfSegment(child);
66
+ walk(childPath, param ? [...paramsAbove, param] : paramsAbove);
67
+ }
68
+ };
69
+ walk(appPath, []);
70
+ return rootParams;
71
+ }
72
+ function scanRootParamTypes(appPath) {
73
+ const roots = [];
74
+ if (!existsSync(appPath))
75
+ return new Map;
76
+ const walk = (dir, paramsAbove) => {
77
+ const layoutFile = findLayoutFile(dir);
78
+ if (layoutFile) {
79
+ let source = "";
80
+ try {
81
+ source = readFileSync(layoutFile, "utf8");
82
+ } catch {
83
+ source = "";
84
+ }
85
+ if (isRootLayoutSource(source)) {
86
+ const params = new Map;
87
+ for (const { name, segment } of paramsAbove) {
88
+ params.set(name, segment.startsWith("[[...") ? ["string[]", "undefined"] : segment.startsWith("[...") ? ["string[]"] : ["string"]);
89
+ }
90
+ roots.push(params);
91
+ }
92
+ }
93
+ let children = [];
94
+ try {
95
+ children = readdirSync(dir);
96
+ } catch {
97
+ return;
98
+ }
99
+ for (const child of children) {
100
+ const childPath = path.join(dir, child);
101
+ let isDir = false;
102
+ try {
103
+ isDir = statSync(childPath).isDirectory();
104
+ } catch {
105
+ isDir = false;
106
+ }
107
+ if (!isDir)
108
+ continue;
109
+ if (child.startsWith("@"))
110
+ continue;
111
+ const param = paramNameOfSegment(child);
112
+ walk(childPath, param ? [...paramsAbove, { name: param, segment: child }] : paramsAbove);
113
+ }
114
+ };
115
+ walk(appPath, []);
116
+ const combined = new Map;
117
+ for (const params of roots) {
118
+ for (const [name, types] of params) {
119
+ const set = combined.get(name) ?? new Set;
120
+ for (const type of types)
121
+ set.add(type);
122
+ combined.set(name, set);
123
+ }
124
+ }
125
+ for (const [name, set] of combined) {
126
+ if (roots.some((params) => !params.has(name)))
127
+ set.add("undefined");
128
+ }
129
+ return combined;
130
+ }
131
+
132
+ export { scanRootParams, scanRootParamTypes };