@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.
Files changed (337) hide show
  1. package/bin/pnext +9 -2
  2. package/dist/server/_chunks/aliases-pycbtjt1.js +46 -0
  3. package/dist/server/_chunks/analyze-4d9e00g9.js +449 -0
  4. package/dist/server/_chunks/boot-bhemypxz.js +38 -0
  5. package/dist/server/_chunks/build-c991dv65.js +86 -0
  6. package/dist/server/_chunks/build-kh5e3x48.js +3341 -0
  7. package/dist/server/_chunks/build-tier-0a96kmx3.js +2456 -0
  8. package/dist/server/_chunks/compile-040r79gj.js +22 -0
  9. package/dist/server/_chunks/config-0tvz03a6.js +24 -0
  10. package/dist/server/_chunks/config-27rj7830.js +36 -0
  11. package/dist/server/_chunks/create-9rvwshsp.js +135 -0
  12. package/dist/server/_chunks/dev-ex9exynt.js +220 -0
  13. package/dist/server/_chunks/esbuild-yyktfrtt.js +15 -0
  14. package/dist/server/_chunks/generate-myw9hef7.js +22 -0
  15. package/dist/server/_chunks/index-0r5eqfc7.js +279 -0
  16. package/dist/server/_chunks/index-0yjv5v47.js +105 -0
  17. package/dist/server/_chunks/index-11xpbfej.js +17 -0
  18. package/dist/server/_chunks/index-141vcwk6.js +109 -0
  19. package/dist/server/_chunks/index-1pzm1hdy.js +4130 -0
  20. package/dist/server/_chunks/index-29pq0kax.js +590 -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-38xpdxwd.js +194 -0
  24. package/dist/server/_chunks/index-3e075kny.js +128 -0
  25. package/dist/server/_chunks/index-3ycf5ckv.js +472 -0
  26. package/dist/server/_chunks/index-4399bvd2.js +18 -0
  27. package/dist/server/_chunks/index-4da76t62.js +297 -0
  28. package/dist/server/_chunks/index-4t92hdxd.js +172 -0
  29. package/dist/server/_chunks/index-4zzebszd.js +10 -0
  30. package/dist/server/_chunks/index-52k54ykj.js +95 -0
  31. package/dist/server/_chunks/index-5hr4062s.js +70 -0
  32. package/dist/server/_chunks/index-68m3mwbd.js +84 -0
  33. package/dist/server/_chunks/index-6b009mt0.js +56 -0
  34. package/dist/server/_chunks/index-6gex3pfa.js +15 -0
  35. package/dist/server/_chunks/index-6kp9r0d9.js +11 -0
  36. package/dist/server/_chunks/index-6q7zvrap.js +134 -0
  37. package/dist/server/_chunks/index-71885zaq.js +284 -0
  38. package/dist/server/_chunks/index-73z4esab.js +38 -0
  39. package/dist/server/_chunks/index-79ngvam8.js +60 -0
  40. package/dist/server/_chunks/index-7wc9n8be.js +25 -0
  41. package/dist/server/_chunks/index-8ct7rqy3.js +198 -0
  42. package/dist/server/_chunks/index-8kcxdfya.js +206 -0
  43. package/dist/server/_chunks/index-9ch50vtq.js +18 -0
  44. package/dist/server/_chunks/index-9f49w76j.js +213 -0
  45. package/dist/server/_chunks/index-9hz3s0m8.js +851 -0
  46. package/dist/server/_chunks/index-akkrvjn6.js +535 -0
  47. package/dist/server/_chunks/index-b6wtkdp4.js +24 -0
  48. package/dist/server/_chunks/index-b7j671dj.js +207 -0
  49. package/dist/server/_chunks/index-bcws5eh2.js +35 -0
  50. package/dist/server/_chunks/index-bzd2ef7t.js +10 -0
  51. package/dist/server/_chunks/index-cjgqs13g.js +65 -0
  52. package/dist/server/_chunks/index-ckkdpht5.js +41 -0
  53. package/dist/server/_chunks/index-cn86z041.js +296 -0
  54. package/dist/server/_chunks/index-cvr4z22m.js +92 -0
  55. package/dist/server/_chunks/index-cyfednwb.js +87 -0
  56. package/dist/server/_chunks/index-d158y67j.js +152 -0
  57. package/dist/server/_chunks/index-d1jsmhhk.js +955 -0
  58. package/dist/server/_chunks/index-dg0f05zs.js +199 -0
  59. package/dist/server/_chunks/index-dgr390q7.js +9438 -0
  60. package/dist/server/_chunks/index-drwv61cc.js +185 -0
  61. package/dist/server/_chunks/index-e3a6yx84.js +18 -0
  62. package/dist/server/_chunks/index-e88tyv35.js +45 -0
  63. package/dist/server/_chunks/index-en7n9f7m.js +22 -0
  64. package/dist/server/_chunks/index-entm8bmz.js +28 -0
  65. package/dist/server/_chunks/index-evhd413j.js +57 -0
  66. package/dist/server/_chunks/index-ezgj0tr1.js +88 -0
  67. package/dist/server/_chunks/index-fjv96re1.js +5295 -0
  68. package/dist/server/_chunks/index-fn1chkkd.js +214 -0
  69. package/dist/server/_chunks/index-fp8r0sqs.js +64 -0
  70. package/dist/server/_chunks/index-gcmj16xy.js +92 -0
  71. package/dist/server/_chunks/index-gkndxkxf.js +736 -0
  72. package/dist/server/_chunks/index-grta8ap3.js +238 -0
  73. package/dist/server/_chunks/index-h2a70tg4.js +7 -0
  74. package/dist/server/_chunks/index-h4xy648y.js +51 -0
  75. package/dist/server/_chunks/index-hdbwtdv2.js +352 -0
  76. package/dist/server/_chunks/index-he6n2bvp.js +1270 -0
  77. package/dist/server/_chunks/index-j0m1jxqa.js +1253 -0
  78. package/dist/server/_chunks/index-j2zrcp1k.js +66 -0
  79. package/dist/server/_chunks/index-j681c48a.js +2530 -0
  80. package/dist/server/_chunks/index-jbj7ehef.js +50 -0
  81. package/dist/server/_chunks/index-jcsjq3d1.js +20 -0
  82. package/dist/server/_chunks/index-jks0x0a1.js +14 -0
  83. package/dist/server/_chunks/index-jn9rbhrx.js +1599 -0
  84. package/dist/server/_chunks/index-jt8e1pje.js +12 -0
  85. package/dist/server/_chunks/index-kdhxpwyq.js +483 -0
  86. package/dist/server/_chunks/index-knp0s912.js +7 -0
  87. package/dist/server/_chunks/index-kqyy1d4f.js +50 -0
  88. package/dist/server/_chunks/index-kresp2n8.js +445 -0
  89. package/dist/server/_chunks/index-m63czgq5.js +590 -0
  90. package/dist/server/_chunks/index-ms9v9tnx.js +31 -0
  91. package/dist/server/_chunks/index-n4hxpng2.js +11 -0
  92. package/dist/server/_chunks/index-n629dy38.js +1071 -0
  93. package/dist/server/_chunks/index-nf3df4jy.js +266 -0
  94. package/dist/server/_chunks/index-nqh3xhdc.js +57 -0
  95. package/dist/server/_chunks/index-pym1cezq.js +39 -0
  96. package/dist/server/_chunks/index-q3r9z8mq.js +213 -0
  97. package/dist/server/_chunks/index-q738kkhj.js +100 -0
  98. package/dist/server/_chunks/index-qcrvt6er.js +112 -0
  99. package/dist/server/_chunks/index-qjj6gddn.js +54 -0
  100. package/dist/server/_chunks/index-qpwsgt3a.js +158 -0
  101. package/dist/server/_chunks/index-r97ptz1q.js +97 -0
  102. package/dist/server/_chunks/index-ras0sdab.js +26 -0
  103. package/dist/server/_chunks/index-rcs322t1.js +19 -0
  104. package/dist/server/_chunks/index-rgj5mx84.js +101 -0
  105. package/dist/server/_chunks/index-rjegyfx4.js +1435 -0
  106. package/dist/server/_chunks/index-rt9qq1va.js +4 -0
  107. package/dist/server/_chunks/index-rthrsed5.js +356 -0
  108. package/dist/server/_chunks/index-sq3kvz3g.js +200 -0
  109. package/dist/server/_chunks/index-stbk3jhn.js +31 -0
  110. package/dist/server/_chunks/index-tf4j19ge.js +130 -0
  111. package/dist/server/_chunks/index-tgcakdxc.js +125 -0
  112. package/dist/server/_chunks/index-tgsfjmep.js +74 -0
  113. package/dist/server/_chunks/index-tq1f96v7.js +51 -0
  114. package/dist/server/_chunks/index-tq3b39a5.js +107 -0
  115. package/dist/server/_chunks/index-typcbcsv.js +819 -0
  116. package/dist/server/_chunks/index-v1ags1na.js +132 -0
  117. package/dist/server/_chunks/index-vmr35jjw.js +170 -0
  118. package/dist/server/_chunks/index-vvq7rqtn.js +329 -0
  119. package/dist/server/_chunks/index-vz0km5qk.js +33 -0
  120. package/dist/server/_chunks/index-w6h8m6vp.js +138 -0
  121. package/dist/server/_chunks/index-web361b8.js +138 -0
  122. package/dist/server/_chunks/index-wm36rj4v.js +311 -0
  123. package/dist/server/_chunks/index-x0y005nh.js +283 -0
  124. package/dist/server/_chunks/index-x2m17v9c.js +6166 -0
  125. package/dist/server/_chunks/index-x3yn4ywm.js +22 -0
  126. package/dist/server/_chunks/index-x9c55pzy.js +871 -0
  127. package/dist/server/_chunks/index-xh1nbk46.js +1299 -0
  128. package/dist/server/_chunks/index-xvj80c3a.js +30 -0
  129. package/dist/server/_chunks/index-xywjg2vc.js +100 -0
  130. package/dist/server/_chunks/index-y4d02znn.js +66 -0
  131. package/dist/server/_chunks/index-y7mzvq2q.js +110 -0
  132. package/dist/server/_chunks/index-ye9hmsvf.js +47 -0
  133. package/dist/server/_chunks/index-yhxkxghe.js +56 -0
  134. package/dist/server/_chunks/index-yrjkqtfj.js +86 -0
  135. package/dist/server/_chunks/index-z88qv16t.js +11 -0
  136. package/dist/server/_chunks/index-zfrwq472.js +154 -0
  137. package/dist/server/_chunks/index-zqpqyg8p.js +666 -0
  138. package/dist/server/_chunks/loader-5en7wpt5.js +80 -0
  139. package/dist/server/_chunks/modules-t92favpj.js +76 -0
  140. package/dist/server/_chunks/pipeline-4t9q43ht.js +836 -0
  141. package/dist/server/_chunks/production-385bw8df.js +55 -0
  142. package/dist/server/_chunks/proxy-config-60gprphe.js +23 -0
  143. package/dist/server/_chunks/proxy-gfhmktbk.js +35 -0
  144. package/dist/server/_chunks/router-xnrva921.js +501 -0
  145. package/dist/server/_chunks/routes-ht868pdc.js +66 -0
  146. package/dist/server/_chunks/run-d40d63ag.js +697 -0
  147. package/dist/server/_chunks/server-2p8fgqq2.js +1839 -0
  148. package/dist/server/_chunks/tsconfig-defaults-bcn34eqb.js +21 -0
  149. package/dist/server/_chunks/typegen-dvtcjtaw.js +37 -0
  150. package/dist/server/api/client-cache.js +14 -0
  151. package/dist/server/cli/index.js +375 -0
  152. package/dist/server/cli/start.js +158 -0
  153. package/dist/server/client/reference.js +16 -0
  154. package/dist/server/compat/next/cache.js +56 -0
  155. package/dist/server/compat/next/canonical-url.js +13 -0
  156. package/dist/server/compat/next/client-cache.js +57 -0
  157. package/dist/server/compat/next/client-navigation.js +232 -0
  158. package/dist/server/compat/next/client-only.js +1 -0
  159. package/dist/server/compat/next/client-script.js +178 -0
  160. package/dist/server/compat/next/client-server.js +34 -0
  161. package/dist/server/compat/next/config-headers.js +34 -0
  162. package/dist/server/compat/next/config-loader.js +25 -0
  163. package/dist/server/compat/next/config.js +10 -0
  164. package/dist/server/compat/next/constants.js +18 -0
  165. package/dist/server/compat/next/custom-server.js +10 -0
  166. package/dist/server/compat/next/dist/client/components/app-router-headers.js +48 -0
  167. package/dist/server/compat/next/dist/server/web/spec-extension/revalidate.js +27 -0
  168. package/dist/server/compat/next/dist/server/web/spec-extension/unstable-cache.js +25 -0
  169. package/dist/server/compat/next/dist/server/web/spec-extension/unstable-no-store.js +25 -0
  170. package/dist/server/compat/next/dynamic.js +21 -0
  171. package/dist/server/compat/next/error.js +112 -0
  172. package/dist/server/compat/next/font/cache.js +16 -0
  173. package/dist/server/compat/next/font/google.js +3 -0
  174. package/dist/server/compat/next/font/index.js +1 -0
  175. package/dist/server/compat/next/font/local.js +24 -0
  176. package/dist/server/compat/next/font/runtime-client.js +33 -0
  177. package/dist/server/compat/next/font/runtime.js +43 -0
  178. package/dist/server/compat/next/font/shared.js +22 -0
  179. package/dist/server/compat/next/form.js +129 -0
  180. package/dist/server/compat/next/head.js +10 -0
  181. package/dist/server/compat/next/headers.js +30 -0
  182. package/dist/server/compat/next/image/client.js +11 -0
  183. package/dist/server/compat/next/image/config.js +18 -0
  184. package/dist/server/compat/next/image/optimizer.js +25 -0
  185. package/dist/server/compat/next/image/patterns.js +12 -0
  186. package/dist/server/compat/next/image/props.js +16 -0
  187. package/dist/server/compat/next/image/shared.js +86 -0
  188. package/dist/server/compat/next/image/static-metadata.js +32 -0
  189. package/dist/server/compat/next/image/validate.js +8 -0
  190. package/dist/server/compat/next/image.js +59 -0
  191. package/dist/server/compat/next/index.js +1 -0
  192. package/dist/server/compat/next/legacy-image.js +78 -0
  193. package/dist/server/compat/next/legacy-request-apis.js +24 -0
  194. package/dist/server/compat/next/link-transform.js +15 -0
  195. package/dist/server/compat/next/link.js +14 -0
  196. package/dist/server/compat/next/navigation.js +191 -0
  197. package/dist/server/compat/next/offline.js +45 -0
  198. package/dist/server/compat/next/og.js +8 -0
  199. package/dist/server/compat/next/preferred-region.js +8 -0
  200. package/dist/server/compat/next/redirects.js +32 -0
  201. package/dist/server/compat/next/resource-hints.js +30 -0
  202. package/dist/server/compat/next/rewrites.js +43 -0
  203. package/dist/server/compat/next/root-params.js +121 -0
  204. package/dist/server/compat/next/route-state.js +23 -0
  205. package/dist/server/compat/next/router.js +103 -0
  206. package/dist/server/compat/next/script.js +37 -0
  207. package/dist/server/compat/next/server-only.js +1 -0
  208. package/dist/server/compat/next/server.js +131 -0
  209. package/dist/server/compat/next/svgr.js +14 -0
  210. package/dist/server/compat/next/telemetry.js +10 -0
  211. package/dist/server/compat/next/usage.js +13 -0
  212. package/dist/server/compat/next/user-agent.js +12 -0
  213. package/dist/server/compat/next/web-vitals.js +35 -0
  214. package/dist/server/compat/react/action-state.js +11 -0
  215. package/dist/server/compat/react/client-lite.js +83 -0
  216. package/dist/server/compat/react/client.js +131 -0
  217. package/dist/server/compat/react/compiler-runtime.js +42 -0
  218. package/dist/server/compat/react/dom-client.js +106 -0
  219. package/dist/server/compat/react/dom-react-server.js +37 -0
  220. package/dist/server/compat/react/dom-server.js +40 -0
  221. package/dist/server/compat/react/dom.js +52 -0
  222. package/dist/server/compat/react/hooks-extra.js +12 -0
  223. package/dist/server/compat/react/internals.js +14 -0
  224. package/dist/server/compat/react/parity.js +11 -0
  225. package/dist/server/compat/react/preact.js +113 -0
  226. package/dist/server/compat/react/react-server.js +133 -0
  227. package/dist/server/compat/react/router-shim.js +8 -0
  228. package/dist/server/compat/react/server-component-use.js +14 -0
  229. package/dist/server/compat/react/server-inserted-html.js +14 -0
  230. package/dist/server/compat/react/server.js +194 -0
  231. package/dist/server/compat/react/style-values.js +10 -0
  232. package/dist/server/compat/react/use.js +10 -0
  233. package/dist/server/compat/react/view-transition.js +12 -0
  234. package/dist/server/generation.json +1 -0
  235. package/package.json +4 -1
  236. package/reference/compat.md +1 -1
  237. package/reference/config.md +2 -2
  238. package/reference/dev.md +1 -1
  239. package/reference/getting-started.md +1 -1
  240. package/reference/rendering.md +4 -4
  241. package/src/api/dynamic.tsx +86 -4
  242. package/src/api/server.ts +24 -6
  243. package/src/cli/adapters/vercel-warm.ts +327 -62
  244. package/src/cli/adapters/vercel.ts +164 -1054
  245. package/src/cli/analyze.ts +3 -2
  246. package/src/cli/build/cache.ts +6 -6
  247. package/src/cli/build.ts +78 -45
  248. package/src/cli/index.ts +21 -3
  249. package/src/cli/serve/immutable.ts +31 -0
  250. package/src/cli/serve/pipeline.ts +97 -93
  251. package/src/cli/serve/standalone-worker.ts +8 -0
  252. package/src/cli/serve/standalone.ts +703 -0
  253. package/src/cli/start.ts +31 -8
  254. package/src/client/build.ts +1 -1
  255. package/src/client/chunk-fold.ts +19 -6
  256. package/src/client/react-tier.ts +3 -2
  257. package/src/client/reference-stub.ts +23 -36
  258. package/src/compat/actions/client-plugin.ts +4 -2
  259. package/src/compat/actions/config.ts +6 -5
  260. package/src/compat/actions/extensions.ts +5 -5
  261. package/src/compat/aliases.ts +8 -1
  262. package/src/compat/bundler/config.ts +88 -0
  263. package/src/compat/bundler/optimize-package-imports.ts +86 -26
  264. package/src/compat/bundler/relay-transform.ts +15 -3
  265. package/src/compat/bundler/require-context.ts +2 -1
  266. package/src/compat/bundler/webpack-loaders.ts +3 -2
  267. package/src/compat/bundler/worker.ts +2 -2
  268. package/src/compat/cache-control.ts +16 -8
  269. package/src/compat/css/inline-css.ts +1 -1
  270. package/src/compat/css/modules.ts +18 -5
  271. package/src/compat/export/build-complete.ts +1 -1
  272. package/src/compat/export/emit.ts +4 -4
  273. package/src/compat/export/standalone.ts +30 -65
  274. package/src/compat/image-optimizer/optimize.ts +1 -1
  275. package/src/compat/lifecycle/error-funnel.ts +1 -1
  276. package/src/compat/lifecycle/instrumentation-client.ts +4 -3
  277. package/src/compat/lifecycle/instrumentation.ts +117 -24
  278. package/src/compat/lifecycle/testmode.ts +3 -2
  279. package/src/compat/metadata-artifacts.ts +1 -1
  280. package/src/compat/next/config-loader.ts +140 -13
  281. package/src/compat/next/dynamic.tsx +10 -23
  282. package/src/compat/next/font/cache.ts +2 -1
  283. package/src/compat/next/font/runtime.ts +23 -3
  284. package/src/compat/next/og.ts +3 -3
  285. package/src/compat/next/usage.ts +3 -2
  286. package/src/compat/pages/api.ts +83 -14
  287. package/src/compat/pages/router.ts +30 -14
  288. package/src/compat/register/bundler.ts +3 -1
  289. package/src/compat/register/image.ts +1 -1
  290. package/src/compat/register/middleware.ts +1 -1
  291. package/src/compat/register/otel.ts +5 -9
  292. package/src/compat/register/render.ts +3 -1
  293. package/src/compat/register/use-cache.ts +3 -1
  294. package/src/compat/release.ts +46 -0
  295. package/src/compat/segment/serve.ts +1 -1
  296. package/src/compat/typecheck/check.ts +6 -4
  297. package/src/compat/validation/validate.ts +10 -7
  298. package/src/config.ts +76 -9
  299. package/src/css/assets.ts +213 -0
  300. package/src/css/build.ts +190 -247
  301. package/src/dev/client-chunk-store.ts +2 -1
  302. package/src/dev/restart/client-key.ts +2 -1
  303. package/src/dev/restart/global-css.ts +2 -1
  304. package/src/dev/restart/route-bundle-key.ts +2 -1
  305. package/src/dev/restart/route-facts.ts +2 -1
  306. package/src/dev/server.ts +34 -14
  307. package/src/extensions.ts +4 -0
  308. package/src/out-paths.ts +10 -0
  309. package/src/render/hooks.ts +13 -0
  310. package/src/render/renderer.ts +53 -33
  311. package/src/request/context.ts +9 -0
  312. package/src/resolve/dynamic.ts +7 -1
  313. package/src/resolve/engine.ts +2 -12
  314. package/src/resolve/imports.ts +12 -52
  315. package/src/resolve/package-json.ts +56 -0
  316. package/src/resolve/scan-facts.ts +250 -1
  317. package/src/routing/href.ts +10 -3
  318. package/src/routing/match.ts +287 -0
  319. package/src/routing/metadata-files.ts +20 -6
  320. package/src/routing/proxy-config.ts +137 -0
  321. package/src/routing/proxy.ts +35 -134
  322. package/src/routing/routes.ts +22 -281
  323. package/src/runtime/fingerprint.ts +23 -8
  324. package/src/runtime/load.ts +170 -0
  325. package/src/runtime/loader.ts +218 -44
  326. package/src/runtime/module-cache.ts +15 -1
  327. package/src/runtime/modules.ts +405 -82
  328. package/src/runtime/prebundle.ts +101 -0
  329. package/src/runtime/production.ts +456 -0
  330. package/src/runtime/release-graph.ts +342 -0
  331. package/src/runtime/vendor-build.ts +750 -17
  332. package/src/runtime/vendor.ts +16 -3
  333. package/src/types.ts +4 -3
  334. package/src/utils/directive.ts +40 -0
  335. package/src/utils/fs.ts +95 -4
  336. package/src/utils/resource-query.ts +12 -0
  337. package/src/cli/serve/entry.ts +0 -45
@@ -0,0 +1,238 @@
1
+ // @bun
2
+ import {
3
+ cacheComponents,
4
+ hangingPromise,
5
+ isPrerendering,
6
+ isRuntimePrefetchPrerender,
7
+ markRuntimeApiOnAwait
8
+ } from "./index-kresp2n8.js";
9
+ import {
10
+ PostponeError
11
+ } from "./index-e3a6yx84.js";
12
+
13
+ // src/request/context.ts
14
+ import { AsyncLocalStorage } from "async_hooks";
15
+ var WORK_UNIT_STORAGE = Symbol.for("pnext.workUnitStorage");
16
+ var workUnitStorage = globalThis[WORK_UNIT_STORAGE] ??= new AsyncLocalStorage;
17
+ function runWithWorkUnit(phase, callback) {
18
+ const unit = { phase, afterTasks: [], flushed: false };
19
+ return workUnitStorage.run(unit, callback);
20
+ }
21
+ function getWorkUnit() {
22
+ return workUnitStorage.getStore();
23
+ }
24
+ function setWorkUnitRelease(release) {
25
+ const unit = workUnitStorage.getStore();
26
+ if (unit)
27
+ unit.release = release;
28
+ }
29
+ function setPhase(phase) {
30
+ const unit = workUnitStorage.getStore();
31
+ if (unit)
32
+ unit.phase = phase;
33
+ }
34
+ function setWorkUnitRoute(routeKind, routeMode, responseHints) {
35
+ const unit = workUnitStorage.getStore();
36
+ if (!unit)
37
+ return;
38
+ unit.routeKind = routeKind;
39
+ if (routeMode)
40
+ unit.routeMode = routeMode;
41
+ if (responseHints)
42
+ unit.responseHints = responseHints;
43
+ }
44
+ function queueAfterTask(task) {
45
+ const unit = workUnitStorage.getStore();
46
+ if (!unit)
47
+ return false;
48
+ unit.afterTasks.push(task);
49
+ return true;
50
+ }
51
+ function flushWorkUnit(unit = workUnitStorage.getStore()) {
52
+ if (!unit || unit.flushed)
53
+ return;
54
+ unit.flushed = true;
55
+ if (unit.afterTasks.length === 0)
56
+ return;
57
+ const afterUnit = { ...unit, phase: "after" };
58
+ const flushing = workUnitStorage.run(afterUnit, async () => {
59
+ while (afterUnit.afterTasks.length) {
60
+ const tasks = afterUnit.afterTasks;
61
+ afterUnit.afterTasks = [];
62
+ for (const task of tasks) {
63
+ try {
64
+ await task();
65
+ } catch (error) {
66
+ console.error("after() task failed:", error);
67
+ }
68
+ }
69
+ }
70
+ });
71
+ pendingFlushes.add(flushing);
72
+ flushing.finally(() => pendingFlushes.delete(flushing));
73
+ }
74
+ var pendingFlushes = new Set;
75
+ async function drainWorkUnits(timeoutMs = 1e4) {
76
+ if (pendingFlushes.size === 0)
77
+ return;
78
+ await Promise.race([
79
+ Promise.allSettled([...pendingFlushes]),
80
+ new Promise((resolve) => setTimeout(resolve, timeoutMs))
81
+ ]);
82
+ }
83
+ function flushWorkUnitOnClose(response, unit, signal) {
84
+ if (!unit)
85
+ return response;
86
+ if (!response.body) {
87
+ flushWorkUnit(unit);
88
+ return response;
89
+ }
90
+ if (response.headers.has("content-length")) {
91
+ flushWorkUnit(unit);
92
+ return response;
93
+ }
94
+ const reader = response.body.getReader();
95
+ const settle = () => {
96
+ signal?.removeEventListener("abort", settle);
97
+ flushWorkUnit(unit);
98
+ };
99
+ if (signal?.aborted)
100
+ settle();
101
+ else
102
+ signal?.addEventListener("abort", settle, { once: true });
103
+ const observed = new ReadableStream({
104
+ async pull(controller) {
105
+ try {
106
+ const chunk = await reader.read();
107
+ if (chunk.done) {
108
+ settle();
109
+ controller.close();
110
+ } else {
111
+ controller.enqueue(chunk.value);
112
+ }
113
+ } catch (error) {
114
+ settle();
115
+ controller.error(error);
116
+ }
117
+ },
118
+ cancel(reason) {
119
+ settle();
120
+ return reader.cancel(reason);
121
+ }
122
+ });
123
+ return new Response(observed, {
124
+ status: response.status,
125
+ statusText: response.statusText,
126
+ headers: response.headers
127
+ });
128
+ }
129
+ var REQUEST_STORAGE = Symbol.for("pnext.requestStorage");
130
+ var requestStorage = globalThis[REQUEST_STORAGE] ??= new AsyncLocalStorage;
131
+ function currentRequest() {
132
+ return requestStorage.getStore()?.request;
133
+ }
134
+ var WORK_UNIT_EXTERNAL = Symbol.for("pnext.workUnitExternal");
135
+ function workUnitExternalStore() {
136
+ const request = currentRequest();
137
+ const type = isRuntimePrefetchPrerender() ? "prerender-runtime" : isPrerendering() || !request ? "prerender" : "request";
138
+ return {
139
+ type,
140
+ cookies: request?.cookies,
141
+ headers: request?.headers ?? new Headers
142
+ };
143
+ }
144
+ globalThis[WORK_UNIT_EXTERNAL] = workUnitExternalStore;
145
+ function captureRequestScope() {
146
+ const scope = requestStorage.getStore();
147
+ if (!scope)
148
+ return (fn) => fn();
149
+ return (fn) => requestStorage.run(scope, fn);
150
+ }
151
+ function currentParams() {
152
+ return requestStorage.getStore()?.params ?? {};
153
+ }
154
+ function runWithRequest(request, callback, params = {}, extras = {}) {
155
+ if (!request)
156
+ return callback();
157
+ const scope = {
158
+ request,
159
+ params,
160
+ afterCallbacks: [],
161
+ responseHeaders: extras.responseHeaders
162
+ };
163
+ const result = requestStorage.run(scope, callback);
164
+ if (isThenable(result)) {
165
+ return result.then((value) => {
166
+ flushAfterCallbacks(scope);
167
+ return value;
168
+ }, (error) => {
169
+ flushAfterCallbacks(scope);
170
+ throw error;
171
+ });
172
+ }
173
+ flushAfterCallbacks(scope);
174
+ return result;
175
+ }
176
+ function currentResponseHeaders() {
177
+ return requestStorage.getStore()?.responseHeaders;
178
+ }
179
+ async function flushAfterCallbacks(scope) {
180
+ while (scope.afterCallbacks?.length) {
181
+ const callbacks = scope.afterCallbacks;
182
+ scope.afterCallbacks = [];
183
+ for (const callback of callbacks) {
184
+ try {
185
+ await requestStorage.run(scope, callback);
186
+ } catch (error) {
187
+ console.error("after() callback failed:", error);
188
+ }
189
+ }
190
+ }
191
+ }
192
+ function isThenable(value) {
193
+ return typeof value?.then === "function";
194
+ }
195
+ var BAILOUT_PROBE = Symbol.for("pnext.dynamicBailoutProbe");
196
+ function beginDynamicBailoutProbe(route) {
197
+ globalThis[BAILOUT_PROBE] = route;
198
+ }
199
+ function endDynamicBailoutProbe() {
200
+ delete globalThis[BAILOUT_PROBE];
201
+ }
202
+ function dynamicBailoutRoute() {
203
+ const route = globalThis[BAILOUT_PROBE];
204
+ return typeof route === "string" ? route : undefined;
205
+ }
206
+ var LEGACY_REQUEST_APIS = Symbol.for("pnext.legacyRequestAPIs");
207
+ function setLegacyRequestAPIs(enabled) {
208
+ globalThis[LEGACY_REQUEST_APIS] = enabled;
209
+ }
210
+ function legacyRequestAPIs() {
211
+ return globalThis[LEGACY_REQUEST_APIS] === true;
212
+ }
213
+ function requireRequest(api) {
214
+ const probeRoute = dynamicBailoutRoute();
215
+ if (probeRoute !== undefined) {
216
+ const error = new Error(`Route ${probeRoute} couldn't be rendered statically because it used \`${api.replace(/\(\)$/, "")}\`. ` + `See more info here: https://nextjs.org/docs/messages/dynamic-server-error`);
217
+ error.name = "DynamicServerError";
218
+ throw error;
219
+ }
220
+ const request = currentRequest();
221
+ if (!request) {
222
+ if (isPrerendering())
223
+ throw new PostponeError(api);
224
+ throw new Error(`${api} can only be used while rendering a dynamic PNext request.`);
225
+ }
226
+ return request;
227
+ }
228
+ function requestApiPromise(api, produce) {
229
+ if (isPrerendering() && cacheComponents()) {
230
+ if (isRuntimePrefetchPrerender() && api !== "connection()") {
231
+ return markRuntimeApiOnAwait(Promise.resolve(produce()));
232
+ }
233
+ return hangingPromise(api);
234
+ }
235
+ return Promise.resolve(produce());
236
+ }
237
+
238
+ export { runWithWorkUnit, getWorkUnit, setWorkUnitRelease, setPhase, setWorkUnitRoute, queueAfterTask, flushWorkUnit, drainWorkUnits, flushWorkUnitOnClose, currentRequest, captureRequestScope, currentParams, runWithRequest, currentResponseHeaders, beginDynamicBailoutProbe, endDynamicBailoutProbe, setLegacyRequestAPIs, legacyRequestAPIs, requireRequest, requestApiPromise };
@@ -0,0 +1,7 @@
1
+ // @bun
2
+ // src/compat/react/router-shim.ts
3
+ function nextRouterShimScript() {
4
+ return '<script>window.next=window.next||{};window.next.version=window.next.version||"16.3.0";(function(){' + "var r=window.next.router=window.next.router||{};" + 'function d(){try{var n=document.getElementById("__PNEXT_PAGES_DATA__");' + "return n&&n.textContent?JSON.parse(n.textContent):null}catch(e){return null}}" + "function q(){var s=d(),o={};if(s&&s.query){for(var k in s.query)o[k]=s.query[k]}" + 'new URLSearchParams(location.search).forEach(function(v,k){if(k!=="_rsc")o[k]=v});return o}' + "r.isReady=true;r.isFallback=r.isFallback||false;" + 'if(!Object.getOwnPropertyDescriptor(r,"query"))Object.defineProperty(r,"query",{get:q,configurable:true});' + 'if(!Object.getOwnPropertyDescriptor(r,"pathname"))Object.defineProperty(r,"pathname",{get:function(){var s=d();return(s&&s.pathname)||location.pathname},configurable:true});' + 'if(!Object.getOwnPropertyDescriptor(r,"asPath"))Object.defineProperty(r,"asPath",{get:function(){return location.pathname+location.search},configurable:true});' + "r.push=r.push||function(href){var s=String(href);" + "if(window.__PNEXT_ROUTER__&&window.__PNEXT_ROUTER__.navigate){return window.__PNEXT_ROUTER__.navigate(s).then(function(){return true})}" + "location.assign(s);return Promise.resolve(true)};" + "r.replace=r.replace||function(href){location.replace(String(href));return Promise.resolve(true)};" + "r.prefetch=r.prefetch||function(){return Promise.resolve(null)};" + "})();</script>";
5
+ }
6
+
7
+ export { nextRouterShimScript };
@@ -0,0 +1,51 @@
1
+ // @bun
2
+ // src/compat/react/use.ts
3
+ import { useContext } from "preact/hooks";
4
+ var REPLAY_STATE_KEY = Symbol.for("pnext.useReplayState");
5
+ var replayState = globalThis[REPLAY_STATE_KEY] ??= {
6
+ active: null,
7
+ index: 0
8
+ };
9
+ function withUseThenableState(state, run) {
10
+ const previousState = replayState.active;
11
+ const previousIndex = replayState.index;
12
+ replayState.active = state;
13
+ replayState.index = 0;
14
+ try {
15
+ return run();
16
+ } finally {
17
+ replayState.active = previousState;
18
+ replayState.index = previousIndex;
19
+ }
20
+ }
21
+ function use(usable) {
22
+ if (usable && typeof usable.then === "function") {
23
+ let thenable = usable;
24
+ if (replayState.active) {
25
+ const index = replayState.index++;
26
+ const existing = replayState.active.thenables[index];
27
+ if (existing)
28
+ thenable = existing;
29
+ else
30
+ replayState.active.thenables[index] = thenable;
31
+ }
32
+ if (thenable.status === "fulfilled")
33
+ return thenable.value;
34
+ if (thenable.status === "rejected")
35
+ throw thenable.reason;
36
+ if (thenable.status !== "pending") {
37
+ thenable.status = "pending";
38
+ thenable.then((value) => {
39
+ thenable.status = "fulfilled";
40
+ thenable.value = value;
41
+ }, (reason) => {
42
+ thenable.status = "rejected";
43
+ thenable.reason = reason;
44
+ });
45
+ }
46
+ throw thenable;
47
+ }
48
+ return useContext(usable);
49
+ }
50
+
51
+ export { withUseThenableState, use };
@@ -0,0 +1,352 @@
1
+ // @bun
2
+ import { join as __pnextJoin } from "node:path";
3
+ const __PNEXT_PACKAGE_ROOT__ = __pnextJoin(import.meta.dirname, "../../..");
4
+ import {
5
+ splitResourceQuery
6
+ } from "./index-jt8e1pje.js";
7
+
8
+ // src/runtime/production.ts
9
+ import { existsSync, readFileSync as readFileSync2, readdirSync, realpathSync } from "fs";
10
+ import { rename, writeFile } from "fs/promises";
11
+ import path2 from "path";
12
+ import { pathToFileURL } from "url";
13
+
14
+ // src/runtime/prebundle.ts
15
+ import { readFileSync } from "fs";
16
+ import path from "path";
17
+ import { fileURLToPath } from "url";
18
+ var PREBUNDLE_STAMP = path.join("dist", "server", "generation.json");
19
+ var prebundle = typeof { version: "0.1.8", fingerprint: "64aaa993cbaa58df", entries: ["cli/index", "cli/start", "client/reference", "api/client-cache", "compat/next/canonical-url", "compat/next/link-transform", "compat/next/client-navigation", "compat/next/og", "compat/next/link", "compat/next/usage", "compat/next/client-script", "compat/next/headers", "compat/next/custom-server", "compat/next/legacy-image", "compat/next/router", "compat/next/navigation", "compat/next/dist/server/web/spec-extension/unstable-no-store", "compat/next/dist/server/web/spec-extension/unstable-cache", "compat/next/dist/server/web/spec-extension/revalidate", "compat/next/dist/client/components/app-router-headers", "compat/next/web-vitals", "compat/next/root-params", "compat/next/route-state", "compat/next/server-only", "compat/next/client-server", "compat/next/legacy-request-apis", "compat/next/redirects", "compat/next/resource-hints", "compat/next/svgr", "compat/next/client-only", "compat/next/image/props", "compat/next/image/optimizer", "compat/next/image/validate", "compat/next/image/shared", "compat/next/image/patterns", "compat/next/image/config", "compat/next/image/client", "compat/next/image/static-metadata", "compat/next/user-agent", "compat/next/client-cache", "compat/next/head", "compat/next/dynamic", "compat/next/telemetry", "compat/next/offline", "compat/next/cache", "compat/next/constants", "compat/next/error", "compat/next/script", "compat/next/index", "compat/next/font/shared", "compat/next/font/runtime", "compat/next/font/google", "compat/next/font/cache", "compat/next/font/runtime-client", "compat/next/font/local", "compat/next/font/index", "compat/next/config-loader", "compat/next/config", "compat/next/image", "compat/next/server", "compat/next/rewrites", "compat/next/preferred-region", "compat/next/config-headers", "compat/next/form", "compat/react/dom", "compat/react/hooks-extra", "compat/react/react-server", "compat/react/dom-client", "compat/react/style-values", "compat/react/compiler-runtime", "compat/react/router-shim", "compat/react/dom-server", "compat/react/dom-react-server", "compat/react/server-component-use", "compat/react/action-state", "compat/react/client", "compat/react/client-lite", "compat/react/server-inserted-html", "compat/react/parity", "compat/react/preact", "compat/react/use", "compat/react/view-transition", "compat/react/internals", "compat/react/server"] } === "object" ? { version: "0.1.8", fingerprint: "64aaa993cbaa58df", entries: ["cli/index", "cli/start", "client/reference", "api/client-cache", "compat/next/canonical-url", "compat/next/link-transform", "compat/next/client-navigation", "compat/next/og", "compat/next/link", "compat/next/usage", "compat/next/client-script", "compat/next/headers", "compat/next/custom-server", "compat/next/legacy-image", "compat/next/router", "compat/next/navigation", "compat/next/dist/server/web/spec-extension/unstable-no-store", "compat/next/dist/server/web/spec-extension/unstable-cache", "compat/next/dist/server/web/spec-extension/revalidate", "compat/next/dist/client/components/app-router-headers", "compat/next/web-vitals", "compat/next/root-params", "compat/next/route-state", "compat/next/server-only", "compat/next/client-server", "compat/next/legacy-request-apis", "compat/next/redirects", "compat/next/resource-hints", "compat/next/svgr", "compat/next/client-only", "compat/next/image/props", "compat/next/image/optimizer", "compat/next/image/validate", "compat/next/image/shared", "compat/next/image/patterns", "compat/next/image/config", "compat/next/image/client", "compat/next/image/static-metadata", "compat/next/user-agent", "compat/next/client-cache", "compat/next/head", "compat/next/dynamic", "compat/next/telemetry", "compat/next/offline", "compat/next/cache", "compat/next/constants", "compat/next/error", "compat/next/script", "compat/next/index", "compat/next/font/shared", "compat/next/font/runtime", "compat/next/font/google", "compat/next/font/cache", "compat/next/font/runtime-client", "compat/next/font/local", "compat/next/font/index", "compat/next/config-loader", "compat/next/config", "compat/next/image", "compat/next/server", "compat/next/rewrites", "compat/next/preferred-region", "compat/next/config-headers", "compat/next/form", "compat/react/dom", "compat/react/hooks-extra", "compat/react/react-server", "compat/react/dom-client", "compat/react/style-values", "compat/react/compiler-runtime", "compat/react/router-shim", "compat/react/dom-server", "compat/react/dom-react-server", "compat/react/server-component-use", "compat/react/action-state", "compat/react/client", "compat/react/client-lite", "compat/react/server-inserted-html", "compat/react/parity", "compat/react/preact", "compat/react/use", "compat/react/view-transition", "compat/react/internals", "compat/react/server"] } : undefined;
20
+ var packageRoot = path.resolve(__PNEXT_PACKAGE_ROOT__ + "/src/runtime", "..", "..");
21
+ var srcRoot = path.join(packageRoot, "src") + path.sep;
22
+ var distRoot = path.join(packageRoot, "dist", "server");
23
+ var entries = new Set(prebundle?.entries);
24
+ function packageVersion(root) {
25
+ return JSON.parse(readFileSync(path.join(root, "package.json"), "utf8")).version;
26
+ }
27
+ function readPrebundleStamp(frameworkRoot, fingerprint) {
28
+ let stamp;
29
+ try {
30
+ stamp = JSON.parse(readFileSync(path.join(frameworkRoot, PREBUNDLE_STAMP), "utf8"));
31
+ } catch {
32
+ return;
33
+ }
34
+ return stamp.fingerprint === fingerprint && stamp.version === packageVersion(frameworkRoot) ? stamp : undefined;
35
+ }
36
+ function prebundledFile(file) {
37
+ if (!prebundle || !file.startsWith(srcRoot))
38
+ return file;
39
+ const entry = file.slice(srcRoot.length).replace(/\.tsx?$/, "");
40
+ return entries.has(entry) ? path.join(distRoot, `${entry}.js`) : file;
41
+ }
42
+ function registerResolvePlugin(plugin) {
43
+ globalThis.Bun.plugin(plugin);
44
+ }
45
+ var registered = false;
46
+ function registerPrebundleResolve() {
47
+ if (!prebundle || registered)
48
+ return;
49
+ registered = true;
50
+ const escaped = srcRoot.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
51
+ registerResolvePlugin({
52
+ name: "pnext-prebundle",
53
+ setup(build) {
54
+ build.onResolve({ filter: new RegExp(`^${escaped}.*\\.tsx?$`) }, (args) => {
55
+ const target = prebundledFile(args.path);
56
+ return target === args.path ? undefined : { path: target };
57
+ });
58
+ build.onResolve({ filter: /^file:.*\.tsx?$/ }, (args) => {
59
+ const file = fileURLToPath(args.path);
60
+ const target = prebundledFile(file);
61
+ return target === file ? undefined : { path: target };
62
+ });
63
+ build.onResolve({ filter: /^\.\.?\/.*\/src\/.*\.tsx?$/ }, (args) => {
64
+ const file = path.resolve(path.dirname(args.importer), args.path);
65
+ const target = prebundledFile(file);
66
+ return target === file ? undefined : { path: target };
67
+ });
68
+ }
69
+ });
70
+ }
71
+
72
+ // src/runtime/production.ts
73
+ var BUILD_INDEX_VERSION = 1;
74
+ var releases = new WeakMap;
75
+ var WORK_UNIT_STORAGE = Symbol.for("pnext.workUnitStorage");
76
+ function buildIndexFile(outPath) {
77
+ return path2.join(outPath, "server", "build-index.json");
78
+ }
79
+ function buildManifestFile(outPath) {
80
+ return path2.join(outPath, "server", "manifest.json");
81
+ }
82
+ function releaseFrameworkRoot(outPath) {
83
+ try {
84
+ const { name } = JSON.parse(readFileSync2(path2.join(frameworkRoot, "package.json"), "utf8"));
85
+ return realpathSync(path2.join(outPath, "node_modules", name));
86
+ } catch {
87
+ return frameworkRoot;
88
+ }
89
+ }
90
+ function releaseSourceRoot(outPath, serializedOutPath) {
91
+ return path2.resolve(outPath, path2.relative(serializedOutPath, "."));
92
+ }
93
+ function standaloneOriginsFile(outPath) {
94
+ return path2.join(path2.dirname(outPath), "cache", "standalone.json");
95
+ }
96
+ var shippedRelease;
97
+ function servingReleaseDir() {
98
+ if (shippedRelease === undefined) {
99
+ shippedRelease = null;
100
+ for (let dir = path2.dirname(frameworkRoot);dir !== path2.dirname(dir); dir = path2.dirname(dir)) {
101
+ if (path2.basename(dir) === "node_modules" && existsSync(buildIndexFile(path2.dirname(dir)))) {
102
+ shippedRelease = path2.dirname(dir);
103
+ break;
104
+ }
105
+ }
106
+ }
107
+ return shippedRelease ?? undefined;
108
+ }
109
+ var linkedReleases = new Map;
110
+ function linkStandaloneOrigins(release) {
111
+ if (servingReleaseDir() === release)
112
+ return true;
113
+ const known = linkedReleases.get(release);
114
+ if (known !== undefined)
115
+ return known;
116
+ let origins;
117
+ try {
118
+ const parsed = JSON.parse(readFileSync2(standaloneOriginsFile(release), "utf8"));
119
+ if (parsed.release === release)
120
+ origins = parsed.origins;
121
+ } catch {
122
+ origins = undefined;
123
+ }
124
+ linkedReleases.set(release, origins !== undefined);
125
+ if (!origins)
126
+ return false;
127
+ const files = origins;
128
+ const modules = `${path2.join(release, "node_modules")}${path2.sep}`;
129
+ registerResolvePlugin({
130
+ name: "pnext-standalone-origins",
131
+ setup(build) {
132
+ build.onResolve({ filter: /node_modules\// }, (args) => {
133
+ const file = path2.resolve(path2.dirname(args.importer), splitResourceQuery(args.path).path);
134
+ if (!file.startsWith(modules))
135
+ return;
136
+ const origin = files[path2.relative(release, file).split(path2.sep).join("/")];
137
+ return origin && existsSync(origin) ? { path: prebundledFile(origin) } : undefined;
138
+ });
139
+ }
140
+ });
141
+ return true;
142
+ }
143
+ function releaseModuleKey(layer, target, file) {
144
+ return `${layer}:${target}:${file}`;
145
+ }
146
+ function productionRelease(config) {
147
+ return releases.get(config);
148
+ }
149
+ function servedRelease() {
150
+ const units = globalThis[WORK_UNIT_STORAGE];
151
+ return units?.getStore()?.release;
152
+ }
153
+ function servedConventions() {
154
+ return servedRelease()?.conventions;
155
+ }
156
+ function frozenDirListing(dir) {
157
+ const facts = servedConventions();
158
+ if (!facts || !isInsideDir(facts.appPath, dir))
159
+ return;
160
+ return facts.dirs.get(dir) ?? { files: new Set, dirs: [] };
161
+ }
162
+ function conventionFileExists(file) {
163
+ return frozenDirListing(path2.dirname(file))?.files.has(path2.basename(file)) ?? existsSync(file);
164
+ }
165
+ function releaseModuleHref(release, layer, target, file) {
166
+ const href = release.modules.get(releaseModuleKey(layer, target, path2.resolve(file)));
167
+ if (!href) {
168
+ throw new Error(`pnext: ${file} (${layer}, ${target}) is not in this build's release. Run 'pnext build' again.`);
169
+ }
170
+ return href;
171
+ }
172
+ function attachRelease(config, index = readBuildIndex(config.outPath)) {
173
+ const existing = releases.get(config);
174
+ if (existing)
175
+ return existing;
176
+ const fromRoot = (file) => path2.resolve(config.root, file);
177
+ const framework = releaseFrameworkRoot(config.outPath);
178
+ const modules = new Map;
179
+ for (const [key, artifact] of Object.entries(index.modules)) {
180
+ const second = key.indexOf(":", key.indexOf(":") + 1);
181
+ modules.set(`${key.slice(0, second + 1)}${releaseSourceFile(key.slice(second + 1), config.root, config.workspaceRoot, framework)}`, pathToFileURL(path2.resolve(config.outPath, artifact)).href);
182
+ }
183
+ const dirs = new Map;
184
+ for (const [dir, names] of Object.entries(index.conventions)) {
185
+ dirs.set(fromRoot(dir), {
186
+ files: new Set(names.filter((name) => !name.endsWith("/"))),
187
+ dirs: names.filter((name) => name.endsWith("/")).map((name) => name.slice(0, -1))
188
+ });
189
+ }
190
+ const release = {
191
+ modules,
192
+ conventions: {
193
+ appPath: config.appPath,
194
+ dirs,
195
+ client: new Set(index.clientConventions.map(fromRoot)),
196
+ documentLayouts: new Set(index.documentLayouts.map(fromRoot))
197
+ },
198
+ globalCss: index.globalCss.map(fromRoot),
199
+ proxy: index.proxy ? { ...index.proxy, file: fromRoot(index.proxy.file) } : {},
200
+ ...index.compat ? { compat: index.compat } : {},
201
+ ...index.instrumentation ? {
202
+ instrumentation: {
203
+ file: path2.resolve(config.outPath, index.instrumentation.file),
204
+ ...index.instrumentation.edge ? { edge: path2.resolve(config.outPath, index.instrumentation.edge) } : {}
205
+ }
206
+ } : {},
207
+ ...index.fonts ? {
208
+ fonts: Object.fromEntries(Object.entries(index.fonts).map(([key, font]) => [
209
+ key,
210
+ { ...font, files: font.files.map((file) => path2.resolve(config.outPath, file)) }
211
+ ]))
212
+ } : {}
213
+ };
214
+ releases.set(config, release);
215
+ return release;
216
+ }
217
+ var conventionBases = new Set([
218
+ "page",
219
+ "route",
220
+ "layout",
221
+ "template",
222
+ "loading",
223
+ "error",
224
+ "not-found",
225
+ "default",
226
+ "forbidden",
227
+ "unauthorized",
228
+ "global-error",
229
+ "global-not-found"
230
+ ]);
231
+ var metadataBase = /^(?:robots|sitemap|manifest|favicon|(?:apple-)?icon\d*|opengraph-image\d*|twitter-image\d*)$/;
232
+ var codeFile = /\.(?:[cm]?[jt]sx?|mdx?)$/;
233
+ function capturedFile(name) {
234
+ const base = /^[^.]+/.exec(name)?.[0] ?? name;
235
+ return conventionBases.has(base) || metadataBase.test(base);
236
+ }
237
+ function servedAppFiles(facts) {
238
+ return [...facts.dirs].flatMap(([dir, listing]) => [...listing.files].map((name) => path2.join(dir, name)));
239
+ }
240
+ function captureConventions(root, appPath) {
241
+ const conventions = {};
242
+ const files = [];
243
+ const visit = (dir) => {
244
+ let entries2;
245
+ try {
246
+ entries2 = readdirSync(dir, { withFileTypes: true });
247
+ } catch {
248
+ return;
249
+ }
250
+ const names = [];
251
+ for (const entry of entries2) {
252
+ if (entry.isDirectory()) {
253
+ if (entry.name === "node_modules" || entry.name.startsWith("."))
254
+ continue;
255
+ names.push(`${entry.name}/`);
256
+ visit(path2.join(dir, entry.name));
257
+ } else if (capturedFile(entry.name)) {
258
+ names.push(entry.name);
259
+ if (codeFile.test(entry.name))
260
+ files.push(path2.join(dir, entry.name));
261
+ }
262
+ }
263
+ conventions[toPosix(path2.relative(root, dir)) || "."] = names.sort();
264
+ };
265
+ visit(appPath);
266
+ return { conventions, files };
267
+ }
268
+ var frameworkRoot = path2.resolve(__PNEXT_PACKAGE_ROOT__ + "/src/runtime", "..", "..");
269
+ function releaseSourceKey(file, root, workspaceRoot) {
270
+ const inRoot = path2.relative(root, file);
271
+ if (!inRoot.startsWith("..") && !path2.isAbsolute(inRoot))
272
+ return `r:${toPosix(inRoot)}`;
273
+ const inWorkspace = path2.relative(workspaceRoot, file);
274
+ if (!inWorkspace.startsWith("..") && !path2.isAbsolute(inWorkspace))
275
+ return `w:${toPosix(inWorkspace)}`;
276
+ const inFramework = path2.relative(frameworkRoot, file);
277
+ if (!inFramework.startsWith("..") && !path2.isAbsolute(inFramework))
278
+ return `f:${toPosix(inFramework)}`;
279
+ return `r:${toPosix(inRoot)}`;
280
+ }
281
+ function releaseSourceFile(key, root, workspaceRoot, framework = frameworkRoot) {
282
+ const value = key.slice(2);
283
+ if (key.startsWith("r:"))
284
+ return path2.join(root, value);
285
+ if (key.startsWith("w:"))
286
+ return path2.resolve(workspaceRoot, value);
287
+ if (key.startsWith("f:"))
288
+ return path2.resolve(framework, value);
289
+ return path2.join(root, value);
290
+ }
291
+ function toPosix(file) {
292
+ return file.split(path2.sep).join("/");
293
+ }
294
+ function isInsideDir(root, file) {
295
+ return file === root || file.startsWith(`${root}${path2.sep}`);
296
+ }
297
+ function readBuildIndex(outPath) {
298
+ const file = buildIndexFile(outPath);
299
+ let index;
300
+ try {
301
+ index = JSON.parse(readFileSync2(file, "utf8"));
302
+ } catch (error) {
303
+ if (error.code !== "ENOENT")
304
+ throw error;
305
+ throw new Error("No production build found. Run 'pnext build' first.");
306
+ }
307
+ if (index.version !== BUILD_INDEX_VERSION) {
308
+ throw new Error(`pnext: ${file} is from another pnext version. Run 'pnext build' again.`);
309
+ }
310
+ return index;
311
+ }
312
+ function serializeReleaseConfig(config) {
313
+ const relative = (file) => path2.relative(config.root, file) || ".";
314
+ return JSON.parse(JSON.stringify({
315
+ ...config,
316
+ root: ".",
317
+ workspaceRoot: relative(config.workspaceRoot),
318
+ appPath: relative(config.appPath),
319
+ publicPath: relative(config.publicPath),
320
+ outPath: relative(config.outPath),
321
+ outRootPath: relative(config.outRootPath),
322
+ typesPath: relative(config.typesPath),
323
+ checksPath: relative(config.checksPath)
324
+ }, (_key, value) => value instanceof RegExp ? { $regexp: [value.source, value.flags] } : value));
325
+ }
326
+ function releaseConfig(serialized, root, outPath) {
327
+ const config = JSON.parse(JSON.stringify(serialized), (_key, value) => {
328
+ const pattern = value?.$regexp;
329
+ return pattern ? new RegExp(pattern[0], pattern[1]) : value;
330
+ });
331
+ const fromRoot = (file) => path2.resolve(root, file);
332
+ const fromOut = (file) => path2.resolve(outPath, path2.relative(config.outPath, file));
333
+ return {
334
+ ...config,
335
+ root,
336
+ workspaceRoot: fromRoot(config.workspaceRoot),
337
+ appPath: fromRoot(config.appPath),
338
+ publicPath: fromRoot(config.publicPath),
339
+ outPath,
340
+ outRootPath: fromOut(config.outRootPath),
341
+ typesPath: fromOut(config.typesPath),
342
+ checksPath: fromOut(config.checksPath)
343
+ };
344
+ }
345
+ async function writeBuildIndex(config, index) {
346
+ const file = buildIndexFile(config.outPath);
347
+ const temporary = `${file}.${process.pid}.tmp`;
348
+ await writeFile(temporary, JSON.stringify(index));
349
+ await rename(temporary, file);
350
+ }
351
+
352
+ export { PREBUNDLE_STAMP, readPrebundleStamp, prebundledFile, registerPrebundleResolve, BUILD_INDEX_VERSION, buildIndexFile, buildManifestFile, releaseFrameworkRoot, releaseSourceRoot, standaloneOriginsFile, servingReleaseDir, linkStandaloneOrigins, releaseModuleKey, productionRelease, servedRelease, servedConventions, frozenDirListing, conventionFileExists, releaseModuleHref, attachRelease, servedAppFiles, captureConventions, releaseSourceKey, releaseSourceFile, readBuildIndex, serializeReleaseConfig, releaseConfig, writeBuildIndex };