@agegr/pi-web 0.3.3 → 0.3.5

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 (259) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +4 -4
  3. package/.next/build-manifest.json +13 -14
  4. package/.next/next-minimal-server.js.nft.json +1 -1
  5. package/.next/next-server.js.nft.json +1 -1
  6. package/.next/react-loadable-manifest.json +8 -0
  7. package/.next/required-server-files.js +2 -0
  8. package/.next/required-server-files.json +2 -0
  9. package/.next/server/app/_global-error/page.js +32 -10
  10. package/.next/server/app/_global-error/page.js.nft.json +1 -1
  11. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -3
  12. package/.next/server/app/_global-error.html +1 -1
  13. package/.next/server/app/_global-error.meta +2 -1
  14. package/.next/server/app/_global-error.rsc +8 -9
  15. package/.next/server/app/_global-error.segments/_full.segment.rsc +8 -9
  16. package/.next/server/app/_global-error.segments/{__PAGE__.segment.rsc → _global-error/__PAGE__.segment.rsc} +2 -2
  17. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +5 -0
  18. package/.next/server/app/_global-error.segments/_head.segment.rsc +3 -4
  19. package/.next/server/app/_global-error.segments/_index.segment.rsc +3 -3
  20. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  21. package/.next/server/app/_not-found/page.js +2 -13
  22. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  23. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -3
  24. package/.next/server/app/_not-found.html +1 -1
  25. package/.next/server/app/_not-found.rsc +10 -10
  26. package/.next/server/app/_not-found.segments/_full.segment.rsc +10 -10
  27. package/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
  28. package/.next/server/app/_not-found.segments/_index.segment.rsc +4 -4
  29. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  30. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  31. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  32. package/.next/server/app/api/agent/[id]/events/route.js +6 -6
  33. package/.next/server/app/api/agent/[id]/events/route.js.nft.json +1 -1
  34. package/.next/server/app/api/agent/[id]/events/route_client-reference-manifest.js +1 -3
  35. package/.next/server/app/api/agent/[id]/route.js +4 -7
  36. package/.next/server/app/api/agent/[id]/route.js.nft.json +1 -1
  37. package/.next/server/app/api/agent/[id]/route_client-reference-manifest.js +1 -3
  38. package/.next/server/app/api/agent/new/route.js +2 -7
  39. package/.next/server/app/api/agent/new/route.js.nft.json +1 -1
  40. package/.next/server/app/api/agent/new/route_client-reference-manifest.js +1 -3
  41. package/.next/server/app/api/files/[...path]/route.js +3 -7
  42. package/.next/server/app/api/files/[...path]/route.js.nft.json +1 -1
  43. package/.next/server/app/api/files/[...path]/route_client-reference-manifest.js +1 -3
  44. package/.next/server/app/api/models/route.js +3 -6
  45. package/.next/server/app/api/models/route.js.nft.json +1 -1
  46. package/.next/server/app/api/models/route_client-reference-manifest.js +1 -3
  47. package/.next/server/app/api/models-config/route.js +1 -7
  48. package/.next/server/app/api/models-config/route.js.nft.json +1 -1
  49. package/.next/server/app/api/models-config/route_client-reference-manifest.js +1 -3
  50. package/.next/server/app/api/sessions/[id]/context/route.js +3 -7
  51. package/.next/server/app/api/sessions/[id]/context/route.js.nft.json +1 -1
  52. package/.next/server/app/api/sessions/[id]/context/route_client-reference-manifest.js +1 -3
  53. package/.next/server/app/api/sessions/[id]/route.js +3 -7
  54. package/.next/server/app/api/sessions/[id]/route.js.nft.json +1 -1
  55. package/.next/server/app/api/sessions/[id]/route_client-reference-manifest.js +1 -3
  56. package/.next/server/app/api/sessions/new/route.js +1 -6
  57. package/.next/server/app/api/sessions/new/route.js.nft.json +1 -1
  58. package/.next/server/app/api/sessions/new/route_client-reference-manifest.js +1 -3
  59. package/.next/server/app/api/sessions/route.js +3 -7
  60. package/.next/server/app/api/sessions/route.js.nft.json +1 -1
  61. package/.next/server/app/api/sessions/route_client-reference-manifest.js +1 -3
  62. package/.next/server/app/favicon.ico/route.js +1 -8
  63. package/.next/server/app/favicon.ico/route.js.nft.json +1 -1
  64. package/.next/server/app/index.html +1 -1
  65. package/.next/server/app/index.rsc +11 -11
  66. package/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
  67. package/.next/server/app/index.segments/_full.segment.rsc +11 -11
  68. package/.next/server/app/index.segments/_head.segment.rsc +4 -4
  69. package/.next/server/app/index.segments/_index.segment.rsc +4 -4
  70. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  71. package/.next/server/app/page.js +2 -14
  72. package/.next/server/app/page.js.nft.json +1 -1
  73. package/.next/server/app/page_client-reference-manifest.js +1 -3
  74. package/.next/server/app-paths-manifest.json +4 -4
  75. package/.next/server/chunks/573.js +3 -0
  76. package/.next/server/chunks/63.js +45 -0
  77. package/.next/server/chunks/65.js +1 -0
  78. package/.next/server/chunks/741.js +18 -0
  79. package/.next/server/chunks/813.js +1 -0
  80. package/.next/server/chunks/918.js +1 -0
  81. package/.next/server/middleware-build-manifest.js +1 -21
  82. package/.next/server/middleware-manifest.json +2 -2
  83. package/.next/server/middleware-react-loadable-manifest.js +1 -0
  84. package/.next/server/next-font-manifest.js +1 -1
  85. package/.next/server/next-font-manifest.json +1 -6
  86. package/.next/server/pages/404.html +1 -1
  87. package/.next/server/pages/500.html +1 -1
  88. package/.next/server/server-reference-manifest.js +1 -1
  89. package/.next/server/server-reference-manifest.json +1 -5
  90. package/.next/server/webpack-runtime.js +1 -0
  91. package/.next/static/chunks/110-fff6e5d8c205420b.js +1 -0
  92. package/.next/static/chunks/451.1247b87def61e309.js +1 -0
  93. package/.next/static/chunks/4bd1b696-215e5051988c3dde.js +1 -0
  94. package/.next/static/chunks/794-4d0b7b700451cc43.js +32 -0
  95. package/.next/static/chunks/app/_global-error/page-957de1f71e826217.js +1 -0
  96. package/.next/static/chunks/app/_not-found/page-e294ec8de846ea31.js +1 -0
  97. package/.next/static/chunks/app/api/agent/[id]/events/route-957de1f71e826217.js +1 -0
  98. package/.next/static/chunks/app/api/agent/[id]/route-957de1f71e826217.js +1 -0
  99. package/.next/static/chunks/app/api/agent/new/route-957de1f71e826217.js +1 -0
  100. package/.next/static/chunks/app/api/files/[...path]/route-957de1f71e826217.js +1 -0
  101. package/.next/static/chunks/app/api/models/route-957de1f71e826217.js +1 -0
  102. package/.next/static/chunks/app/api/models-config/route-957de1f71e826217.js +1 -0
  103. package/.next/static/chunks/app/api/sessions/[id]/context/route-957de1f71e826217.js +1 -0
  104. package/.next/static/chunks/app/api/sessions/[id]/route-957de1f71e826217.js +1 -0
  105. package/.next/static/chunks/app/api/sessions/new/route-957de1f71e826217.js +1 -0
  106. package/.next/static/chunks/app/api/sessions/route-957de1f71e826217.js +1 -0
  107. package/.next/static/chunks/app/layout-7c348314be580c6a.js +1 -0
  108. package/.next/static/chunks/app/page-8d02664b52fb8562.js +1 -0
  109. package/.next/static/chunks/framework-93cda6578f6c76ec.js +1 -0
  110. package/.next/static/chunks/main-0525ed1bd1807a80.js +5 -0
  111. package/.next/static/chunks/main-app-bd11c9df37a8ab8e.js +1 -0
  112. package/.next/static/chunks/next/dist/client/components/builtin/app-error-957de1f71e826217.js +1 -0
  113. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-957de1f71e826217.js +1 -0
  114. package/.next/static/chunks/next/dist/client/components/builtin/global-error-0dd2035d6f688008.js +1 -0
  115. package/.next/static/chunks/next/dist/client/components/builtin/not-found-957de1f71e826217.js +1 -0
  116. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-957de1f71e826217.js +1 -0
  117. package/.next/static/chunks/webpack-f15a3bb2c3a9cba9.js +1 -0
  118. package/.next/static/css/db181498dfd5fef0.css +1 -0
  119. package/.next/static/o5v8sZDYNWZYyZTqhuhxl/_buildManifest.js +1 -0
  120. package/.next/trace +3 -1
  121. package/.next/trace-build +1 -1
  122. package/.next/types/app/api/agent/[id]/events/route.ts +351 -0
  123. package/.next/types/app/api/agent/[id]/route.ts +351 -0
  124. package/.next/types/app/api/agent/new/route.ts +351 -0
  125. package/.next/types/app/api/files/[...path]/route.ts +351 -0
  126. package/.next/types/app/api/models/route.ts +351 -0
  127. package/.next/types/app/api/models-config/route.ts +351 -0
  128. package/.next/types/app/api/sessions/[id]/context/route.ts +351 -0
  129. package/.next/types/app/api/sessions/[id]/route.ts +351 -0
  130. package/.next/types/app/api/sessions/new/route.ts +351 -0
  131. package/.next/types/app/api/sessions/route.ts +351 -0
  132. package/.next/types/app/layout.ts +87 -0
  133. package/.next/types/app/page.ts +87 -0
  134. package/.next/types/package.json +1 -0
  135. package/package.json +2 -2
  136. package/.next/build/chunks/[root-of-the-server]__0d-m0h0._.js +0 -206
  137. package/.next/build/chunks/[root-of-the-server]__0ubbtyl._.js +0 -500
  138. package/.next/build/chunks/[turbopack-node]_transforms_postcss_ts_06e.r3r._.js +0 -13
  139. package/.next/build/chunks/[turbopack]_runtime.js +0 -890
  140. package/.next/build/chunks/node_modules_13sb.px._.js +0 -6765
  141. package/.next/build/package.json +0 -1
  142. package/.next/build/postcss.js +0 -6
  143. package/.next/diagnostics/route-bundle-stats.json +0 -28
  144. package/.next/fallback-build-manifest.json +0 -13
  145. package/.next/server/app/_global-error/page/app-paths-manifest.json +0 -3
  146. package/.next/server/app/_global-error/page/build-manifest.json +0 -17
  147. package/.next/server/app/_global-error/page/next-font-manifest.json +0 -6
  148. package/.next/server/app/_global-error/page/react-loadable-manifest.json +0 -1
  149. package/.next/server/app/_global-error/page/server-reference-manifest.json +0 -4
  150. package/.next/server/app/_not-found/page/app-paths-manifest.json +0 -3
  151. package/.next/server/app/_not-found/page/build-manifest.json +0 -17
  152. package/.next/server/app/_not-found/page/next-font-manifest.json +0 -6
  153. package/.next/server/app/_not-found/page/react-loadable-manifest.json +0 -1
  154. package/.next/server/app/_not-found/page/server-reference-manifest.json +0 -4
  155. package/.next/server/app/api/agent/[id]/events/route/app-paths-manifest.json +0 -3
  156. package/.next/server/app/api/agent/[id]/events/route/build-manifest.json +0 -9
  157. package/.next/server/app/api/agent/[id]/events/route/server-reference-manifest.json +0 -4
  158. package/.next/server/app/api/agent/[id]/route/app-paths-manifest.json +0 -3
  159. package/.next/server/app/api/agent/[id]/route/build-manifest.json +0 -9
  160. package/.next/server/app/api/agent/[id]/route/server-reference-manifest.json +0 -4
  161. package/.next/server/app/api/agent/new/route/app-paths-manifest.json +0 -3
  162. package/.next/server/app/api/agent/new/route/build-manifest.json +0 -9
  163. package/.next/server/app/api/agent/new/route/server-reference-manifest.json +0 -4
  164. package/.next/server/app/api/files/[...path]/route/app-paths-manifest.json +0 -3
  165. package/.next/server/app/api/files/[...path]/route/build-manifest.json +0 -9
  166. package/.next/server/app/api/files/[...path]/route/server-reference-manifest.json +0 -4
  167. package/.next/server/app/api/models/route/app-paths-manifest.json +0 -3
  168. package/.next/server/app/api/models/route/build-manifest.json +0 -9
  169. package/.next/server/app/api/models/route/server-reference-manifest.json +0 -4
  170. package/.next/server/app/api/models-config/route/app-paths-manifest.json +0 -3
  171. package/.next/server/app/api/models-config/route/build-manifest.json +0 -9
  172. package/.next/server/app/api/models-config/route/server-reference-manifest.json +0 -4
  173. package/.next/server/app/api/sessions/[id]/context/route/app-paths-manifest.json +0 -3
  174. package/.next/server/app/api/sessions/[id]/context/route/build-manifest.json +0 -9
  175. package/.next/server/app/api/sessions/[id]/context/route/server-reference-manifest.json +0 -4
  176. package/.next/server/app/api/sessions/[id]/route/app-paths-manifest.json +0 -3
  177. package/.next/server/app/api/sessions/[id]/route/build-manifest.json +0 -9
  178. package/.next/server/app/api/sessions/[id]/route/server-reference-manifest.json +0 -4
  179. package/.next/server/app/api/sessions/new/route/app-paths-manifest.json +0 -3
  180. package/.next/server/app/api/sessions/new/route/build-manifest.json +0 -9
  181. package/.next/server/app/api/sessions/new/route/server-reference-manifest.json +0 -4
  182. package/.next/server/app/api/sessions/route/app-paths-manifest.json +0 -3
  183. package/.next/server/app/api/sessions/route/build-manifest.json +0 -9
  184. package/.next/server/app/api/sessions/route/server-reference-manifest.json +0 -4
  185. package/.next/server/app/favicon.ico/route/app-paths-manifest.json +0 -3
  186. package/.next/server/app/favicon.ico/route/build-manifest.json +0 -9
  187. package/.next/server/app/page/app-paths-manifest.json +0 -3
  188. package/.next/server/app/page/build-manifest.json +0 -17
  189. package/.next/server/app/page/next-font-manifest.json +0 -6
  190. package/.next/server/app/page/react-loadable-manifest.json +0 -1
  191. package/.next/server/app/page/server-reference-manifest.json +0 -4
  192. package/.next/server/chunks/[externals]_next_dist_0h.fyd6._.js +0 -3
  193. package/.next/server/chunks/[root-of-the-server]__002d92q._.js +0 -6
  194. package/.next/server/chunks/[root-of-the-server]__00a-~o4._.js +0 -3
  195. package/.next/server/chunks/[root-of-the-server]__06qx74m._.js +0 -5
  196. package/.next/server/chunks/[root-of-the-server]__0_ehal9._.js +0 -5
  197. package/.next/server/chunks/[root-of-the-server]__0a-p9wd._.js +0 -3
  198. package/.next/server/chunks/[root-of-the-server]__0b0kii6._.js +0 -8
  199. package/.next/server/chunks/[root-of-the-server]__0cw6f~v._.js +0 -5
  200. package/.next/server/chunks/[root-of-the-server]__0llo_uy._.js +0 -5
  201. package/.next/server/chunks/[root-of-the-server]__0rr3q~-._.js +0 -5
  202. package/.next/server/chunks/[root-of-the-server]__0y7g-4j._.js +0 -4
  203. package/.next/server/chunks/[root-of-the-server]__11j~5mn._.js +0 -3
  204. package/.next/server/chunks/[turbopack]_runtime.js +0 -903
  205. package/.next/server/chunks/_next-internal_server_app_api_agent_[id]_events_route_actions_05o7blz.js +0 -3
  206. package/.next/server/chunks/_next-internal_server_app_api_agent_[id]_route_actions_0kr98j0.js +0 -3
  207. package/.next/server/chunks/_next-internal_server_app_api_agent_new_route_actions_0w3r5tj.js +0 -3
  208. package/.next/server/chunks/_next-internal_server_app_api_files_[___path]_route_actions_0_g4akf.js +0 -3
  209. package/.next/server/chunks/_next-internal_server_app_api_models-config_route_actions_0ipr5cq.js +0 -3
  210. package/.next/server/chunks/_next-internal_server_app_api_models_route_actions_0vfccm4.js +0 -3
  211. package/.next/server/chunks/_next-internal_server_app_api_sessions_[id]_context_route_actions_0d0pnzf.js +0 -3
  212. package/.next/server/chunks/_next-internal_server_app_api_sessions_[id]_route_actions_0eo4u5w.js +0 -3
  213. package/.next/server/chunks/_next-internal_server_app_api_sessions_new_route_actions_093p~n-.js +0 -3
  214. package/.next/server/chunks/_next-internal_server_app_api_sessions_route_actions_0y1t9w0.js +0 -3
  215. package/.next/server/chunks/_next-internal_server_app_favicon_ico_route_actions_095lj93.js +0 -3
  216. package/.next/server/chunks/lib_session-reader_ts_07kvkqq._.js +0 -5
  217. package/.next/server/chunks/node_modules_next_04~_e52._.js +0 -13
  218. package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_0yubv2d.js +0 -3
  219. package/.next/server/chunks/ssr/[root-of-the-server]__00d4x5d._.js +0 -3
  220. package/.next/server/chunks/ssr/[root-of-the-server]__02hi65f._.js +0 -3
  221. package/.next/server/chunks/ssr/[root-of-the-server]__06-2p1a._.js +0 -33
  222. package/.next/server/chunks/ssr/[root-of-the-server]__09z7o2x._.js +0 -19
  223. package/.next/server/chunks/ssr/[root-of-the-server]__0jag6jd._.js +0 -3
  224. package/.next/server/chunks/ssr/[root-of-the-server]__0pr3cat._.js +0 -33
  225. package/.next/server/chunks/ssr/[root-of-the-server]__0pspq~2._.js +0 -6
  226. package/.next/server/chunks/ssr/[root-of-the-server]__0w~zl.s._.js +0 -3
  227. package/.next/server/chunks/ssr/[turbopack]_runtime.js +0 -903
  228. package/.next/server/chunks/ssr/_next-internal_server_app__global-error_page_actions_0k77kol.js +0 -3
  229. package/.next/server/chunks/ssr/_next-internal_server_app__not-found_page_actions_0eq97pa.js +0 -3
  230. package/.next/server/chunks/ssr/_next-internal_server_app_page_actions_09-gtaw.js +0 -3
  231. package/.next/server/chunks/ssr/app_layout_tsx_13yf0ls._.js +0 -3
  232. package/.next/server/chunks/ssr/components_ToolPanel_tsx_0r3vloj._.js +0 -3
  233. package/.next/server/chunks/ssr/components_ToolPanel_tsx_0ybdq6k._.js +0 -3
  234. package/.next/server/chunks/ssr/node_modules_09w7yel._.js +0 -33
  235. package/.next/server/chunks/ssr/node_modules_0vtdjw7._.js +0 -3
  236. package/.next/server/chunks/ssr/node_modules_next_dist_09y1ibj._.js +0 -6
  237. package/.next/server/chunks/ssr/node_modules_next_dist_client_components_0inhx6q._.js +0 -3
  238. package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_forbidden_0ghu-f7.js +0 -3
  239. package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_global-error_0lgvd_..js +0 -3
  240. package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_unauthorized_0cjv-23.js +0 -3
  241. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_002l7yi.js +0 -4
  242. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_02suzhc.js +0 -4
  243. package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0nsg22r.js +0 -4
  244. package/.next/static/DVhMCWBqUD1m2y1ZbH-BY/_buildManifest.js +0 -11
  245. package/.next/static/DVhMCWBqUD1m2y1ZbH-BY/_clientMiddlewareManifest.js +0 -1
  246. package/.next/static/chunks/0-j.wjqnc6zff.js +0 -1
  247. package/.next/static/chunks/02i7dfk78~t~2.js +0 -4
  248. package/.next/static/chunks/02p06lvcsni3l.js +0 -1
  249. package/.next/static/chunks/09dho1gmydle0.js +0 -1
  250. package/.next/static/chunks/0cj37tl-sc0gx.js +0 -2
  251. package/.next/static/chunks/0h4bblvd1oiwg.js +0 -1
  252. package/.next/static/chunks/0j-yjan8jn-8-.js +0 -31
  253. package/.next/static/chunks/168.i5wkbx2o-.js +0 -1
  254. package/.next/static/chunks/18b1hylg5nikt.css +0 -1
  255. package/.next/static/chunks/turbopack-04u~j1o-remaj.js +0 -1
  256. package/.next/static/media/favicon.0~uco8ba8mwit.ico +0 -0
  257. package/.next/turbopack +0 -0
  258. /package/.next/static/chunks/{03~yq9q893hmn.js → polyfills-42372ed130431b0a.js} +0 -0
  259. /package/.next/static/{DVhMCWBqUD1m2y1ZbH-BY → o5v8sZDYNWZYyZTqhuhxl}/_ssgManifest.js +0 -0
@@ -1,903 +0,0 @@
1
- const RUNTIME_PUBLIC_PATH = "server/chunks/[turbopack]_runtime.js";
2
- const RELATIVE_ROOT_PATH = "..";
3
- const ASSET_PREFIX = "/";
4
- const WORKER_FORWARDED_GLOBALS = ["NEXT_DEPLOYMENT_ID","NEXT_CLIENT_ASSET_SUFFIX"];
5
- // Apply forwarded globals from workerData if running in a worker thread
6
- if (typeof require !== 'undefined') {
7
- try {
8
- const { workerData } = require('worker_threads');
9
- if (workerData?.__turbopack_globals__) {
10
- Object.assign(globalThis, workerData.__turbopack_globals__);
11
- // Remove internal data so it's not visible to user code
12
- delete workerData.__turbopack_globals__;
13
- }
14
- } catch (_) {
15
- // Not in a worker thread context, ignore
16
- }
17
- }
18
- /**
19
- * This file contains runtime types and functions that are shared between all
20
- * TurboPack ECMAScript runtimes.
21
- *
22
- * It will be prepended to the runtime code of each runtime.
23
- */ /* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="./runtime-types.d.ts" />
24
- /**
25
- * Describes why a module was instantiated.
26
- * Shared between browser and Node.js runtimes.
27
- */ var SourceType = /*#__PURE__*/ function(SourceType) {
28
- /**
29
- * The module was instantiated because it was included in an evaluated chunk's
30
- * runtime.
31
- * SourceData is a ChunkPath.
32
- */ SourceType[SourceType["Runtime"] = 0] = "Runtime";
33
- /**
34
- * The module was instantiated because a parent module imported it.
35
- * SourceData is a ModuleId.
36
- */ SourceType[SourceType["Parent"] = 1] = "Parent";
37
- /**
38
- * The module was instantiated because it was included in a chunk's hot module
39
- * update.
40
- * SourceData is an array of ModuleIds or undefined.
41
- */ SourceType[SourceType["Update"] = 2] = "Update";
42
- return SourceType;
43
- }(SourceType || {});
44
- /**
45
- * Flag indicating which module object type to create when a module is merged. Set to `true`
46
- * by each runtime that uses ModuleWithDirection (browser dev-base.ts, nodejs dev-base.ts,
47
- * nodejs build-base.ts). Browser production (build-base.ts) leaves it as `false` since it
48
- * uses plain Module objects.
49
- */ let createModuleWithDirectionFlag = false;
50
- const REEXPORTED_OBJECTS = new WeakMap();
51
- /**
52
- * Constructs the `__turbopack_context__` object for a module.
53
- */ function Context(module, exports) {
54
- this.m = module;
55
- // We need to store this here instead of accessing it from the module object to:
56
- // 1. Make it available to factories directly, since we rewrite `this` to
57
- // `__turbopack_context__.e` in CJS modules.
58
- // 2. Support async modules which rewrite `module.exports` to a promise, so we
59
- // can still access the original exports object from functions like
60
- // `esmExport`
61
- // Ideally we could find a new approach for async modules and drop this property altogether.
62
- this.e = exports;
63
- }
64
- const contextPrototype = Context.prototype;
65
- const hasOwnProperty = Object.prototype.hasOwnProperty;
66
- const toStringTag = typeof Symbol !== 'undefined' && Symbol.toStringTag;
67
- function defineProp(obj, name, options) {
68
- if (!hasOwnProperty.call(obj, name)) Object.defineProperty(obj, name, options);
69
- }
70
- function getOverwrittenModule(moduleCache, id) {
71
- let module = moduleCache[id];
72
- if (!module) {
73
- if (createModuleWithDirectionFlag) {
74
- // set in development modes for hmr support
75
- module = createModuleWithDirection(id);
76
- } else {
77
- module = createModuleObject(id);
78
- }
79
- moduleCache[id] = module;
80
- }
81
- return module;
82
- }
83
- /**
84
- * Creates the module object. Only done here to ensure all module objects have the same shape.
85
- */ function createModuleObject(id) {
86
- return {
87
- exports: {},
88
- error: undefined,
89
- id,
90
- namespaceObject: undefined
91
- };
92
- }
93
- function createModuleWithDirection(id) {
94
- return {
95
- exports: {},
96
- error: undefined,
97
- id,
98
- namespaceObject: undefined,
99
- parents: [],
100
- children: []
101
- };
102
- }
103
- const BindingTag_Value = 0;
104
- /**
105
- * Adds the getters to the exports object.
106
- */ function esm(exports, bindings) {
107
- defineProp(exports, '__esModule', {
108
- value: true
109
- });
110
- if (toStringTag) defineProp(exports, toStringTag, {
111
- value: 'Module'
112
- });
113
- let i = 0;
114
- while(i < bindings.length){
115
- const propName = bindings[i++];
116
- const tagOrFunction = bindings[i++];
117
- if (typeof tagOrFunction === 'number') {
118
- if (tagOrFunction === BindingTag_Value) {
119
- defineProp(exports, propName, {
120
- value: bindings[i++],
121
- enumerable: true,
122
- writable: false
123
- });
124
- } else {
125
- throw new Error(`unexpected tag: ${tagOrFunction}`);
126
- }
127
- } else {
128
- const getterFn = tagOrFunction;
129
- if (typeof bindings[i] === 'function') {
130
- const setterFn = bindings[i++];
131
- defineProp(exports, propName, {
132
- get: getterFn,
133
- set: setterFn,
134
- enumerable: true
135
- });
136
- } else {
137
- defineProp(exports, propName, {
138
- get: getterFn,
139
- enumerable: true
140
- });
141
- }
142
- }
143
- }
144
- Object.seal(exports);
145
- }
146
- /**
147
- * Makes the module an ESM with exports
148
- */ function esmExport(bindings, id) {
149
- let module;
150
- let exports;
151
- if (id != null) {
152
- module = getOverwrittenModule(this.c, id);
153
- exports = module.exports;
154
- } else {
155
- module = this.m;
156
- exports = this.e;
157
- }
158
- module.namespaceObject = exports;
159
- esm(exports, bindings);
160
- }
161
- contextPrototype.s = esmExport;
162
- function ensureDynamicExports(module, exports) {
163
- let reexportedObjects = REEXPORTED_OBJECTS.get(module);
164
- if (!reexportedObjects) {
165
- REEXPORTED_OBJECTS.set(module, reexportedObjects = []);
166
- module.exports = module.namespaceObject = new Proxy(exports, {
167
- get (target, prop) {
168
- if (hasOwnProperty.call(target, prop) || prop === 'default' || prop === '__esModule') {
169
- return Reflect.get(target, prop);
170
- }
171
- for (const obj of reexportedObjects){
172
- const value = Reflect.get(obj, prop);
173
- if (value !== undefined) return value;
174
- }
175
- return undefined;
176
- },
177
- ownKeys (target) {
178
- const keys = Reflect.ownKeys(target);
179
- for (const obj of reexportedObjects){
180
- for (const key of Reflect.ownKeys(obj)){
181
- if (key !== 'default' && !keys.includes(key)) keys.push(key);
182
- }
183
- }
184
- return keys;
185
- }
186
- });
187
- }
188
- return reexportedObjects;
189
- }
190
- /**
191
- * Dynamically exports properties from an object
192
- */ function dynamicExport(object, id) {
193
- let module;
194
- let exports;
195
- if (id != null) {
196
- module = getOverwrittenModule(this.c, id);
197
- exports = module.exports;
198
- } else {
199
- module = this.m;
200
- exports = this.e;
201
- }
202
- const reexportedObjects = ensureDynamicExports(module, exports);
203
- if (typeof object === 'object' && object !== null) {
204
- reexportedObjects.push(object);
205
- }
206
- }
207
- contextPrototype.j = dynamicExport;
208
- function exportValue(value, id) {
209
- let module;
210
- if (id != null) {
211
- module = getOverwrittenModule(this.c, id);
212
- } else {
213
- module = this.m;
214
- }
215
- module.exports = value;
216
- }
217
- contextPrototype.v = exportValue;
218
- function exportNamespace(namespace, id) {
219
- let module;
220
- if (id != null) {
221
- module = getOverwrittenModule(this.c, id);
222
- } else {
223
- module = this.m;
224
- }
225
- module.exports = module.namespaceObject = namespace;
226
- }
227
- contextPrototype.n = exportNamespace;
228
- function createGetter(obj, key) {
229
- return ()=>obj[key];
230
- }
231
- /**
232
- * @returns prototype of the object
233
- */ const getProto = Object.getPrototypeOf ? (obj)=>Object.getPrototypeOf(obj) : (obj)=>obj.__proto__;
234
- /** Prototypes that are not expanded for exports */ const LEAF_PROTOTYPES = [
235
- null,
236
- getProto({}),
237
- getProto([]),
238
- getProto(getProto)
239
- ];
240
- /**
241
- * @param raw
242
- * @param ns
243
- * @param allowExportDefault
244
- * * `false`: will have the raw module as default export
245
- * * `true`: will have the default property as default export
246
- */ function interopEsm(raw, ns, allowExportDefault) {
247
- const bindings = [];
248
- let defaultLocation = -1;
249
- for(let current = raw; (typeof current === 'object' || typeof current === 'function') && !LEAF_PROTOTYPES.includes(current); current = getProto(current)){
250
- for (const key of Object.getOwnPropertyNames(current)){
251
- bindings.push(key, createGetter(raw, key));
252
- if (defaultLocation === -1 && key === 'default') {
253
- defaultLocation = bindings.length - 1;
254
- }
255
- }
256
- }
257
- // this is not really correct
258
- // we should set the `default` getter if the imported module is a `.cjs file`
259
- if (!(allowExportDefault && defaultLocation >= 0)) {
260
- // Replace the binding with one for the namespace itself in order to preserve iteration order.
261
- if (defaultLocation >= 0) {
262
- // Replace the getter with the value
263
- bindings.splice(defaultLocation, 1, BindingTag_Value, raw);
264
- } else {
265
- bindings.push('default', BindingTag_Value, raw);
266
- }
267
- }
268
- esm(ns, bindings);
269
- return ns;
270
- }
271
- function createNS(raw) {
272
- if (typeof raw === 'function') {
273
- return function(...args) {
274
- return raw.apply(this, args);
275
- };
276
- } else {
277
- return Object.create(null);
278
- }
279
- }
280
- function esmImport(id) {
281
- const module = getOrInstantiateModuleFromParent(id, this.m);
282
- // any ES module has to have `module.namespaceObject` defined.
283
- if (module.namespaceObject) return module.namespaceObject;
284
- // only ESM can be an async module, so we don't need to worry about exports being a promise here.
285
- const raw = module.exports;
286
- return module.namespaceObject = interopEsm(raw, createNS(raw), raw && raw.__esModule);
287
- }
288
- contextPrototype.i = esmImport;
289
- function asyncLoader(moduleId) {
290
- const loader = this.r(moduleId);
291
- return loader(esmImport.bind(this));
292
- }
293
- contextPrototype.A = asyncLoader;
294
- // Add a simple runtime require so that environments without one can still pass
295
- // `typeof require` CommonJS checks so that exports are correctly registered.
296
- const runtimeRequire = // @ts-ignore
297
- typeof require === 'function' ? require : function require1() {
298
- throw new Error('Unexpected use of runtime require');
299
- };
300
- contextPrototype.t = runtimeRequire;
301
- function commonJsRequire(id) {
302
- return getOrInstantiateModuleFromParent(id, this.m).exports;
303
- }
304
- contextPrototype.r = commonJsRequire;
305
- /**
306
- * Remove fragments and query parameters since they are never part of the context map keys
307
- *
308
- * This matches how we parse patterns at resolving time. Arguably we should only do this for
309
- * strings passed to `import` but the resolve does it for `import` and `require` and so we do
310
- * here as well.
311
- */ function parseRequest(request) {
312
- // Per the URI spec fragments can contain `?` characters, so we should trim it off first
313
- // https://datatracker.ietf.org/doc/html/rfc3986#section-3.5
314
- const hashIndex = request.indexOf('#');
315
- if (hashIndex !== -1) {
316
- request = request.substring(0, hashIndex);
317
- }
318
- const queryIndex = request.indexOf('?');
319
- if (queryIndex !== -1) {
320
- request = request.substring(0, queryIndex);
321
- }
322
- return request;
323
- }
324
- /**
325
- * `require.context` and require/import expression runtime.
326
- */ function moduleContext(map) {
327
- function moduleContext(id) {
328
- id = parseRequest(id);
329
- if (hasOwnProperty.call(map, id)) {
330
- return map[id].module();
331
- }
332
- const e = new Error(`Cannot find module '${id}'`);
333
- e.code = 'MODULE_NOT_FOUND';
334
- throw e;
335
- }
336
- moduleContext.keys = ()=>{
337
- return Object.keys(map);
338
- };
339
- moduleContext.resolve = (id)=>{
340
- id = parseRequest(id);
341
- if (hasOwnProperty.call(map, id)) {
342
- return map[id].id();
343
- }
344
- const e = new Error(`Cannot find module '${id}'`);
345
- e.code = 'MODULE_NOT_FOUND';
346
- throw e;
347
- };
348
- moduleContext.import = async (id)=>{
349
- return await moduleContext(id);
350
- };
351
- return moduleContext;
352
- }
353
- contextPrototype.f = moduleContext;
354
- /**
355
- * Returns the path of a chunk defined by its data.
356
- */ function getChunkPath(chunkData) {
357
- return typeof chunkData === 'string' ? chunkData : chunkData.path;
358
- }
359
- function isPromise(maybePromise) {
360
- return maybePromise != null && typeof maybePromise === 'object' && 'then' in maybePromise && typeof maybePromise.then === 'function';
361
- }
362
- function isAsyncModuleExt(obj) {
363
- return turbopackQueues in obj;
364
- }
365
- function createPromise() {
366
- let resolve;
367
- let reject;
368
- const promise = new Promise((res, rej)=>{
369
- reject = rej;
370
- resolve = res;
371
- });
372
- return {
373
- promise,
374
- resolve: resolve,
375
- reject: reject
376
- };
377
- }
378
- // Load the CompressedmoduleFactories of a chunk into the `moduleFactories` Map.
379
- // The CompressedModuleFactories format is
380
- // - 1 or more module ids
381
- // - a module factory function
382
- // So walking this is a little complex but the flat structure is also fast to
383
- // traverse, we can use `typeof` operators to distinguish the two cases.
384
- function installCompressedModuleFactories(chunkModules, offset, moduleFactories, newModuleId) {
385
- let i = offset;
386
- while(i < chunkModules.length){
387
- let end = i + 1;
388
- // Find our factory function
389
- while(end < chunkModules.length && typeof chunkModules[end] !== 'function'){
390
- end++;
391
- }
392
- if (end === chunkModules.length) {
393
- throw new Error('malformed chunk format, expected a factory function');
394
- }
395
- // Install the factory for each module ID that doesn't already have one.
396
- // When some IDs in this group already have a factory, reuse that existing
397
- // group factory for the missing IDs to keep all IDs in the group consistent.
398
- // Otherwise, install the factory from this chunk.
399
- const moduleFactoryFn = chunkModules[end];
400
- let existingGroupFactory = undefined;
401
- for(let j = i; j < end; j++){
402
- const id = chunkModules[j];
403
- const existingFactory = moduleFactories.get(id);
404
- if (existingFactory) {
405
- existingGroupFactory = existingFactory;
406
- break;
407
- }
408
- }
409
- const factoryToInstall = existingGroupFactory ?? moduleFactoryFn;
410
- let didInstallFactory = false;
411
- for(let j = i; j < end; j++){
412
- const id = chunkModules[j];
413
- if (!moduleFactories.has(id)) {
414
- if (!didInstallFactory) {
415
- if (factoryToInstall === moduleFactoryFn) {
416
- applyModuleFactoryName(moduleFactoryFn);
417
- }
418
- didInstallFactory = true;
419
- }
420
- moduleFactories.set(id, factoryToInstall);
421
- newModuleId?.(id);
422
- }
423
- }
424
- i = end + 1; // end is pointing at the last factory advance to the next id or the end of the array.
425
- }
426
- }
427
- // everything below is adapted from webpack
428
- // https://github.com/webpack/webpack/blob/6be4065ade1e252c1d8dcba4af0f43e32af1bdc1/lib/runtime/AsyncModuleRuntimeModule.js#L13
429
- const turbopackQueues = Symbol('turbopack queues');
430
- const turbopackExports = Symbol('turbopack exports');
431
- const turbopackError = Symbol('turbopack error');
432
- function resolveQueue(queue) {
433
- if (queue && queue.status !== 1) {
434
- queue.status = 1;
435
- queue.forEach((fn)=>fn.queueCount--);
436
- queue.forEach((fn)=>fn.queueCount-- ? fn.queueCount++ : fn());
437
- }
438
- }
439
- function wrapDeps(deps) {
440
- return deps.map((dep)=>{
441
- if (dep !== null && typeof dep === 'object') {
442
- if (isAsyncModuleExt(dep)) return dep;
443
- if (isPromise(dep)) {
444
- const queue = Object.assign([], {
445
- status: 0
446
- });
447
- const obj = {
448
- [turbopackExports]: {},
449
- [turbopackQueues]: (fn)=>fn(queue)
450
- };
451
- dep.then((res)=>{
452
- obj[turbopackExports] = res;
453
- resolveQueue(queue);
454
- }, (err)=>{
455
- obj[turbopackError] = err;
456
- resolveQueue(queue);
457
- });
458
- return obj;
459
- }
460
- }
461
- return {
462
- [turbopackExports]: dep,
463
- [turbopackQueues]: ()=>{}
464
- };
465
- });
466
- }
467
- function asyncModule(body, hasAwait) {
468
- const module = this.m;
469
- const queue = hasAwait ? Object.assign([], {
470
- status: -1
471
- }) : undefined;
472
- const depQueues = new Set();
473
- const { resolve, reject, promise: rawPromise } = createPromise();
474
- const promise = Object.assign(rawPromise, {
475
- [turbopackExports]: module.exports,
476
- [turbopackQueues]: (fn)=>{
477
- queue && fn(queue);
478
- depQueues.forEach(fn);
479
- promise['catch'](()=>{});
480
- }
481
- });
482
- const attributes = {
483
- get () {
484
- return promise;
485
- },
486
- set (v) {
487
- // Calling `esmExport` leads to this.
488
- if (v !== promise) {
489
- promise[turbopackExports] = v;
490
- }
491
- }
492
- };
493
- Object.defineProperty(module, 'exports', attributes);
494
- Object.defineProperty(module, 'namespaceObject', attributes);
495
- function handleAsyncDependencies(deps) {
496
- const currentDeps = wrapDeps(deps);
497
- const getResult = ()=>currentDeps.map((d)=>{
498
- if (d[turbopackError]) throw d[turbopackError];
499
- return d[turbopackExports];
500
- });
501
- const { promise, resolve } = createPromise();
502
- const fn = Object.assign(()=>resolve(getResult), {
503
- queueCount: 0
504
- });
505
- function fnQueue(q) {
506
- if (q !== queue && !depQueues.has(q)) {
507
- depQueues.add(q);
508
- if (q && q.status === 0) {
509
- fn.queueCount++;
510
- q.push(fn);
511
- }
512
- }
513
- }
514
- currentDeps.map((dep)=>dep[turbopackQueues](fnQueue));
515
- return fn.queueCount ? promise : getResult();
516
- }
517
- function asyncResult(err) {
518
- if (err) {
519
- reject(promise[turbopackError] = err);
520
- } else {
521
- resolve(promise[turbopackExports]);
522
- }
523
- resolveQueue(queue);
524
- }
525
- body(handleAsyncDependencies, asyncResult);
526
- if (queue && queue.status === -1) {
527
- queue.status = 0;
528
- }
529
- }
530
- contextPrototype.a = asyncModule;
531
- /**
532
- * A pseudo "fake" URL object to resolve to its relative path.
533
- *
534
- * When UrlRewriteBehavior is set to relative, calls to the `new URL()` will construct url without base using this
535
- * runtime function to generate context-agnostic urls between different rendering context, i.e ssr / client to avoid
536
- * hydration mismatch.
537
- *
538
- * This is based on webpack's existing implementation:
539
- * https://github.com/webpack/webpack/blob/87660921808566ef3b8796f8df61bd79fc026108/lib/runtime/RelativeUrlRuntimeModule.js
540
- */ const relativeURL = function relativeURL(inputUrl) {
541
- const realUrl = new URL(inputUrl, 'x:/');
542
- const values = {};
543
- for(const key in realUrl)values[key] = realUrl[key];
544
- values.href = inputUrl;
545
- values.pathname = inputUrl.replace(/[?#].*/, '');
546
- values.origin = values.protocol = '';
547
- values.toString = values.toJSON = (..._args)=>inputUrl;
548
- for(const key in values)Object.defineProperty(this, key, {
549
- enumerable: true,
550
- configurable: true,
551
- value: values[key]
552
- });
553
- };
554
- relativeURL.prototype = URL.prototype;
555
- contextPrototype.U = relativeURL;
556
- /**
557
- * Utility function to ensure all variants of an enum are handled.
558
- */ function invariant(never, computeMessage) {
559
- throw new Error(`Invariant: ${computeMessage(never)}`);
560
- }
561
- /**
562
- * Constructs an error message for when a module factory is not available.
563
- */ function factoryNotAvailableMessage(moduleId, sourceType, sourceData) {
564
- let instantiationReason;
565
- switch(sourceType){
566
- case 0:
567
- instantiationReason = `as a runtime entry of chunk ${sourceData}`;
568
- break;
569
- case 1:
570
- instantiationReason = `because it was required from module ${sourceData}`;
571
- break;
572
- case 2:
573
- instantiationReason = 'because of an HMR update';
574
- break;
575
- default:
576
- invariant(sourceType, (sourceType)=>`Unknown source type: ${sourceType}`);
577
- }
578
- return `Module ${moduleId} was instantiated ${instantiationReason}, but the module factory is not available.`;
579
- }
580
- /**
581
- * A stub function to make `require` available but non-functional in ESM.
582
- */ function requireStub(_moduleId) {
583
- throw new Error('dynamic usage of require is not supported');
584
- }
585
- contextPrototype.z = requireStub;
586
- // Make `globalThis` available to the module in a way that cannot be shadowed by a local variable.
587
- contextPrototype.g = globalThis;
588
- function applyModuleFactoryName(factory) {
589
- // Give the module factory a nice name to improve stack traces.
590
- Object.defineProperty(factory, 'name', {
591
- value: 'module evaluation'
592
- });
593
- }
594
- /// <reference path="../shared/runtime/runtime-utils.ts" />
595
- /// A 'base' utilities to support runtime can have externals.
596
- /// Currently this is for node.js / edge runtime both.
597
- /// If a fn requires node.js specific behavior, it should be placed in `node-external-utils` instead.
598
- async function externalImport(id) {
599
- let raw;
600
- try {
601
- raw = await import(id);
602
- } catch (err) {
603
- // TODO(alexkirsz) This can happen when a client-side module tries to load
604
- // an external module we don't provide a shim for (e.g. querystring, url).
605
- // For now, we fail semi-silently, but in the future this should be a
606
- // compilation error.
607
- throw new Error(`Failed to load external module ${id}: ${err}`);
608
- }
609
- if (raw && raw.__esModule && raw.default && 'default' in raw.default) {
610
- return interopEsm(raw.default, createNS(raw), true);
611
- }
612
- return raw;
613
- }
614
- contextPrototype.y = externalImport;
615
- function externalRequire(id, thunk, esm = false) {
616
- let raw;
617
- try {
618
- raw = thunk();
619
- } catch (err) {
620
- // TODO(alexkirsz) This can happen when a client-side module tries to load
621
- // an external module we don't provide a shim for (e.g. querystring, url).
622
- // For now, we fail semi-silently, but in the future this should be a
623
- // compilation error.
624
- throw new Error(`Failed to load external module ${id}: ${err}`);
625
- }
626
- if (!esm || raw.__esModule) {
627
- return raw;
628
- }
629
- return interopEsm(raw, createNS(raw), true);
630
- }
631
- externalRequire.resolve = (id, options)=>{
632
- return require.resolve(id, options);
633
- };
634
- contextPrototype.x = externalRequire;
635
- /* eslint-disable @typescript-eslint/no-unused-vars */ const path = require('path');
636
- const relativePathToRuntimeRoot = path.relative(RUNTIME_PUBLIC_PATH, '.');
637
- // Compute the relative path to the `distDir`.
638
- const relativePathToDistRoot = path.join(relativePathToRuntimeRoot, RELATIVE_ROOT_PATH);
639
- const RUNTIME_ROOT = path.resolve(__filename, relativePathToRuntimeRoot);
640
- // Compute the absolute path to the root, by stripping distDir from the absolute path to this file.
641
- const ABSOLUTE_ROOT = path.resolve(__filename, relativePathToDistRoot);
642
- /**
643
- * Returns an absolute path to the given module path.
644
- * Module path should be relative, either path to a file or a directory.
645
- *
646
- * This fn allows to calculate an absolute path for some global static values, such as
647
- * `__dirname` or `import.meta.url` that Turbopack will not embeds in compile time.
648
- * See ImportMetaBinding::code_generation for the usage.
649
- */ function resolveAbsolutePath(modulePath) {
650
- if (modulePath) {
651
- return path.join(ABSOLUTE_ROOT, modulePath);
652
- }
653
- return ABSOLUTE_ROOT;
654
- }
655
- Context.prototype.P = resolveAbsolutePath;
656
- /* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="../shared/runtime/runtime-utils.ts" />
657
- function readWebAssemblyAsResponse(path) {
658
- const { createReadStream } = require('fs');
659
- const { Readable } = require('stream');
660
- const stream = createReadStream(path);
661
- // @ts-ignore unfortunately there's a slight type mismatch with the stream.
662
- return new Response(Readable.toWeb(stream), {
663
- headers: {
664
- 'content-type': 'application/wasm'
665
- }
666
- });
667
- }
668
- async function compileWebAssemblyFromPath(path) {
669
- const response = readWebAssemblyAsResponse(path);
670
- return await WebAssembly.compileStreaming(response);
671
- }
672
- async function instantiateWebAssemblyFromPath(path, importsObj) {
673
- const response = readWebAssemblyAsResponse(path);
674
- const { instance } = await WebAssembly.instantiateStreaming(response, importsObj);
675
- return instance.exports;
676
- }
677
- /* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="../../shared/runtime/runtime-utils.ts" />
678
- /// <reference path="../../shared-node/base-externals-utils.ts" />
679
- /// <reference path="../../shared-node/node-externals-utils.ts" />
680
- /// <reference path="../../shared-node/node-wasm-utils.ts" />
681
- /// <reference path="./nodejs-globals.d.ts" />
682
- /**
683
- * Base Node.js runtime shared between production and development.
684
- * Contains chunk loading, module caching, and other non-HMR functionality.
685
- */ process.env.TURBOPACK = '1';
686
- const url = require('url');
687
- const moduleFactories = new Map();
688
- const moduleCache = Object.create(null);
689
- /**
690
- * Returns an absolute path to the given module's id.
691
- */ function resolvePathFromModule(moduleId) {
692
- const exported = this.r(moduleId);
693
- const exportedPath = exported?.default ?? exported;
694
- if (typeof exportedPath !== 'string') {
695
- return exported;
696
- }
697
- const strippedAssetPrefix = exportedPath.slice(ASSET_PREFIX.length);
698
- const resolved = path.resolve(RUNTIME_ROOT, strippedAssetPrefix);
699
- return url.pathToFileURL(resolved).href;
700
- }
701
- /**
702
- * Exports a URL value. No suffix is added in Node.js runtime.
703
- */ function exportUrl(urlValue, id) {
704
- exportValue.call(this, urlValue, id);
705
- }
706
- function loadRuntimeChunk(sourcePath, chunkData) {
707
- if (typeof chunkData === 'string') {
708
- loadRuntimeChunkPath(sourcePath, chunkData);
709
- } else {
710
- loadRuntimeChunkPath(sourcePath, chunkData.path);
711
- }
712
- }
713
- const loadedChunks = new Set();
714
- const unsupportedLoadChunk = Promise.resolve(undefined);
715
- const loadedChunk = Promise.resolve(undefined);
716
- const chunkCache = new Map();
717
- function clearChunkCache() {
718
- chunkCache.clear();
719
- loadedChunks.clear();
720
- }
721
- function loadRuntimeChunkPath(sourcePath, chunkPath) {
722
- if (!isJs(chunkPath)) {
723
- // We only support loading JS chunks in Node.js.
724
- // This branch can be hit when trying to load a CSS chunk.
725
- return;
726
- }
727
- if (loadedChunks.has(chunkPath)) {
728
- return;
729
- }
730
- try {
731
- const resolved = path.resolve(RUNTIME_ROOT, chunkPath);
732
- const chunkModules = require(resolved);
733
- installCompressedModuleFactories(chunkModules, 0, moduleFactories);
734
- loadedChunks.add(chunkPath);
735
- } catch (cause) {
736
- let errorMessage = `Failed to load chunk ${chunkPath}`;
737
- if (sourcePath) {
738
- errorMessage += ` from runtime for chunk ${sourcePath}`;
739
- }
740
- const error = new Error(errorMessage, {
741
- cause
742
- });
743
- error.name = 'ChunkLoadError';
744
- throw error;
745
- }
746
- }
747
- function loadChunkAsync(chunkData) {
748
- const chunkPath = typeof chunkData === 'string' ? chunkData : chunkData.path;
749
- if (!isJs(chunkPath)) {
750
- // We only support loading JS chunks in Node.js.
751
- // This branch can be hit when trying to load a CSS chunk.
752
- return unsupportedLoadChunk;
753
- }
754
- let entry = chunkCache.get(chunkPath);
755
- if (entry === undefined) {
756
- try {
757
- // resolve to an absolute path to simplify `require` handling
758
- const resolved = path.resolve(RUNTIME_ROOT, chunkPath);
759
- // TODO: consider switching to `import()` to enable concurrent chunk loading and async file io
760
- // However this is incompatible with hot reloading (since `import` doesn't use the require cache)
761
- const chunkModules = require(resolved);
762
- installCompressedModuleFactories(chunkModules, 0, moduleFactories);
763
- entry = loadedChunk;
764
- } catch (cause) {
765
- const errorMessage = `Failed to load chunk ${chunkPath} from module ${this.m.id}`;
766
- const error = new Error(errorMessage, {
767
- cause
768
- });
769
- error.name = 'ChunkLoadError';
770
- // Cache the failure promise, future requests will also get this same rejection
771
- entry = Promise.reject(error);
772
- }
773
- chunkCache.set(chunkPath, entry);
774
- }
775
- // TODO: Return an instrumented Promise that React can use instead of relying on referential equality.
776
- return entry;
777
- }
778
- contextPrototype.l = loadChunkAsync;
779
- function loadChunkAsyncByUrl(chunkUrl) {
780
- const path1 = url.fileURLToPath(new URL(chunkUrl, RUNTIME_ROOT));
781
- return loadChunkAsync.call(this, path1);
782
- }
783
- contextPrototype.L = loadChunkAsyncByUrl;
784
- function loadWebAssembly(chunkPath, _edgeModule, imports) {
785
- const resolved = path.resolve(RUNTIME_ROOT, chunkPath);
786
- return instantiateWebAssemblyFromPath(resolved, imports);
787
- }
788
- contextPrototype.w = loadWebAssembly;
789
- function loadWebAssemblyModule(chunkPath, _edgeModule) {
790
- const resolved = path.resolve(RUNTIME_ROOT, chunkPath);
791
- return compileWebAssemblyFromPath(resolved);
792
- }
793
- contextPrototype.u = loadWebAssemblyModule;
794
- /**
795
- * Creates a Node.js worker thread by instantiating the given WorkerConstructor
796
- * with the appropriate path and options, including forwarded globals.
797
- *
798
- * @param WorkerConstructor The Worker constructor from worker_threads
799
- * @param workerPath Path to the worker entry chunk
800
- * @param workerOptions options to pass to the Worker constructor (optional)
801
- */ function createWorker(WorkerConstructor, workerPath, workerOptions) {
802
- // Build the forwarded globals object
803
- const forwardedGlobals = {};
804
- for (const name of WORKER_FORWARDED_GLOBALS){
805
- forwardedGlobals[name] = globalThis[name];
806
- }
807
- // Merge workerData with forwarded globals
808
- const existingWorkerData = workerOptions?.workerData || {};
809
- const options = {
810
- ...workerOptions,
811
- workerData: {
812
- ...typeof existingWorkerData === 'object' ? existingWorkerData : {},
813
- __turbopack_globals__: forwardedGlobals
814
- }
815
- };
816
- return new WorkerConstructor(workerPath, options);
817
- }
818
- const regexJsUrl = /\.js(?:\?[^#]*)?(?:#.*)?$/;
819
- /**
820
- * Checks if a given path/URL ends with .js, optionally followed by ?query or #fragment.
821
- */ function isJs(chunkUrlOrPath) {
822
- return regexJsUrl.test(chunkUrlOrPath);
823
- }
824
- /* eslint-disable @typescript-eslint/no-unused-vars */ /// <reference path="./runtime-base.ts" />
825
- /**
826
- * Production Node.js runtime.
827
- * Uses ModuleWithDirection and simple module instantiation without HMR support.
828
- */ // moduleCache and moduleFactories are declared in runtime-base.ts
829
- // this is read in runtime-utils.ts so it creates a module with direction for hmr
830
- createModuleWithDirectionFlag = true;
831
- const nodeContextPrototype = Context.prototype;
832
- nodeContextPrototype.q = exportUrl;
833
- nodeContextPrototype.M = moduleFactories;
834
- // Cast moduleCache to ModuleWithDirection for production mode
835
- nodeContextPrototype.c = moduleCache;
836
- nodeContextPrototype.R = resolvePathFromModule;
837
- nodeContextPrototype.b = createWorker;
838
- nodeContextPrototype.C = clearChunkCache;
839
- function instantiateModule(id, sourceType, sourceData) {
840
- const moduleFactory = moduleFactories.get(id);
841
- if (typeof moduleFactory !== 'function') {
842
- // This can happen if modules incorrectly handle HMR disposes/updates,
843
- // e.g. when they keep a `setTimeout` around which still executes old code
844
- // and contains e.g. a `require("something")` call.
845
- throw new Error(factoryNotAvailableMessage(id, sourceType, sourceData));
846
- }
847
- const module1 = createModuleWithDirection(id);
848
- const exports = module1.exports;
849
- moduleCache[id] = module1;
850
- const context = new Context(module1, exports);
851
- // NOTE(alexkirsz) This can fail when the module encounters a runtime error.
852
- try {
853
- moduleFactory(context, module1, exports);
854
- } catch (error) {
855
- module1.error = error;
856
- throw error;
857
- }
858
- ;
859
- module1.loaded = true;
860
- if (module1.namespaceObject && module1.exports !== module1.namespaceObject) {
861
- // in case of a circular dependency: cjs1 -> esm2 -> cjs1
862
- interopEsm(module1.exports, module1.namespaceObject);
863
- }
864
- return module1;
865
- }
866
- /**
867
- * Retrieves a module from the cache, or instantiate it if it is not cached.
868
- */ // @ts-ignore
869
- function getOrInstantiateModuleFromParent(id, sourceModule) {
870
- const module1 = moduleCache[id];
871
- if (module1) {
872
- if (module1.error) {
873
- throw module1.error;
874
- }
875
- return module1;
876
- }
877
- return instantiateModule(id, SourceType.Parent, sourceModule.id);
878
- }
879
- /**
880
- * Instantiates a runtime module.
881
- */ function instantiateRuntimeModule(chunkPath, moduleId) {
882
- return instantiateModule(moduleId, SourceType.Runtime, chunkPath);
883
- }
884
- /**
885
- * Retrieves a module from the cache, or instantiate it as a runtime module if it is not cached.
886
- */ // @ts-ignore TypeScript doesn't separate this module space from the browser runtime
887
- function getOrInstantiateRuntimeModule(chunkPath, moduleId) {
888
- const module1 = moduleCache[moduleId];
889
- if (module1) {
890
- if (module1.error) {
891
- throw module1.error;
892
- }
893
- return module1;
894
- }
895
- return instantiateRuntimeModule(chunkPath, moduleId);
896
- }
897
- module.exports = (sourcePath)=>({
898
- m: (id)=>getOrInstantiateRuntimeModule(sourcePath, id),
899
- c: (chunkData)=>loadRuntimeChunk(sourcePath, chunkData)
900
- });
901
-
902
-
903
- //# sourceMappingURL=%5Bturbopack%5D_runtime.js.map