@highstate/designer 0.20.0 → 0.26.0

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 (240) hide show
  1. package/.output/nitro.json +4 -4
  2. package/.output/public/_nuxt/{BkNNRtnm.js → -aI73seg.js} +1 -1
  3. package/.output/public/_nuxt/32ctXXKs.js +1 -0
  4. package/.output/public/_nuxt/39D0VL7r.js +1 -0
  5. package/.output/public/_nuxt/{ByBNG4eo.js → 3T5CmBSF.js} +1 -1
  6. package/.output/public/_nuxt/4R6BJ3GI.js +1 -0
  7. package/.output/public/_nuxt/77UvFSdd.js +18 -0
  8. package/.output/public/_nuxt/{G13IRnB2.js → B0E2rEnI.js} +1 -1
  9. package/.output/public/_nuxt/B1x03f8R.js +1 -0
  10. package/.output/public/_nuxt/B2CVdECd.js +1 -0
  11. package/.output/public/_nuxt/{DWQRqdcR.js → B2_u9ZKl.js} +1 -1
  12. package/.output/public/_nuxt/{DCR009rv.js → B8uKU-iG.js} +1 -1
  13. package/.output/public/_nuxt/{CxEW7TG8.js → B9BJCsIg.js} +1 -1
  14. package/.output/public/_nuxt/BA47KaF1.js +1 -0
  15. package/.output/public/_nuxt/{DRfxs3PN.js → BBmoak6l.js} +1 -1
  16. package/.output/public/_nuxt/BEOSfHJT.js +1 -0
  17. package/.output/public/_nuxt/{D2aToa54.js → BJV0IIsR.js} +1 -1
  18. package/.output/public/_nuxt/{DCBCRx0O.js → BKaSp7fy.js} +1 -1
  19. package/.output/public/_nuxt/BN7gUcg9.js +1 -0
  20. package/.output/public/_nuxt/{DiTMzCP2.js → BOujskTX.js} +1 -1
  21. package/.output/public/_nuxt/{DJN0y8jO.js → BPboW4rx.js} +1 -1
  22. package/.output/public/_nuxt/{DzWdbJvx.js → BR4jrf3-.js} +1 -1
  23. package/.output/public/_nuxt/{9I37tBe7.js → BSRetNRl.js} +1 -1
  24. package/.output/public/_nuxt/{C1FLL1Qz.js → Ba9NwIJp.js} +1 -1
  25. package/.output/public/_nuxt/{DCinzvm1.js → BbWhHw7B.js} +1 -1
  26. package/.output/public/_nuxt/Bcyj9glE.js +6 -0
  27. package/.output/public/_nuxt/{xA6NntuA.js → Be4ezMZK.js} +1 -1
  28. package/.output/public/_nuxt/BeH2EWoN.js +1 -0
  29. package/.output/public/_nuxt/{CudFwYib.js → BgvYz3Nr.js} +1 -1
  30. package/.output/public/_nuxt/BlGDdimO.js +1 -0
  31. package/.output/public/_nuxt/{ZbicA1ry.js → Bn5R9WlL.js} +1 -1
  32. package/.output/public/_nuxt/{ChaZkl1J.js → BqJDg8iS.js} +1 -1
  33. package/.output/public/_nuxt/BxD6MFcJ.js +1 -0
  34. package/.output/public/_nuxt/{D27ZAKIj.js → BxvmPvww.js} +1 -1
  35. package/.output/public/_nuxt/{BEEt8Am7.js → By1Fxx6d.js} +1 -1
  36. package/.output/public/_nuxt/{xdsXwj_J.js → ByBXn3Vz.js} +1 -1
  37. package/.output/public/_nuxt/C1bzPMRu.js +14 -0
  38. package/.output/public/_nuxt/{CV5MeYf9.js → C29gnYT3.js} +1 -1
  39. package/.output/public/_nuxt/C5BYcBs_.js +1 -0
  40. package/.output/public/_nuxt/{ziXKbM2N.js → C5DRPdxC.js} +1 -1
  41. package/.output/public/_nuxt/{BJK6uMxG.js → C794qwo0.js} +1 -1
  42. package/.output/public/_nuxt/{RCBWmVHz.js → C9OJ0gQB.js} +1 -1
  43. package/.output/public/_nuxt/{B13uiJCv.js → C9n5vGW7.js} +1 -1
  44. package/.output/public/_nuxt/{rcFevLEP.js → CCBTuGSI.js} +2 -2
  45. package/.output/public/_nuxt/CENFIVCM.js +1 -0
  46. package/.output/public/_nuxt/{CzSiA7V6.js → CGLWlIpJ.js} +1 -1
  47. package/.output/public/_nuxt/CI40hKzv.js +2 -0
  48. package/.output/public/_nuxt/{CcOKGYBt.js → CLsyMJ1X.js} +1 -1
  49. package/.output/public/_nuxt/{CaJ-zn_Z.js → CNWyx-82.js} +1 -1
  50. package/.output/public/_nuxt/CRZrAKrA.js +2 -0
  51. package/.output/public/_nuxt/{BxaP9l2T.js → CRb2z3Pg.js} +1 -1
  52. package/.output/public/_nuxt/{BDAHnC4j.js → CWA5Cfde.js} +1 -1
  53. package/.output/public/_nuxt/CYpkKp66.js +1 -0
  54. package/.output/public/_nuxt/{n0RAZLbO.js → C_yayEmb.js} +1 -1
  55. package/.output/public/_nuxt/{rgN_MdZl.js → CaZj7sno.js} +1 -1
  56. package/.output/public/_nuxt/{CGscLIrv.js → CgK0fS9t.js} +1 -1
  57. package/.output/public/_nuxt/CiaugisX.js +1 -0
  58. package/.output/public/_nuxt/Cjs5trkS.js +1 -0
  59. package/.output/public/_nuxt/Cn-bp-IR.js +1 -0
  60. package/.output/public/_nuxt/CoqwalnO.js +2 -0
  61. package/.output/public/_nuxt/{d-NZQb9b.js → CscXh7Vy.js} +1 -1
  62. package/.output/public/_nuxt/{DQHHT9y-.js → CwWsKBf5.js} +1 -1
  63. package/.output/public/_nuxt/Cwefpg1x.js +1 -0
  64. package/.output/public/_nuxt/CxoCegAs.js +13 -0
  65. package/.output/public/_nuxt/{8MSfy8uY.js → CyFj-Mv9.js} +1 -1
  66. package/.output/public/_nuxt/Cz2AlsmD.js +1 -0
  67. package/.output/public/_nuxt/{tsyQDnRt.js → D1BdWMiq.js} +1 -1
  68. package/.output/public/_nuxt/D1yXAE_w.js +1 -0
  69. package/.output/public/_nuxt/{xp27HhqZ.js → D2lHwbtX.js} +1 -1
  70. package/.output/public/_nuxt/{DKhcu7kD.js → D46u9gXN.js} +1 -1
  71. package/.output/public/_nuxt/{CJWmG4YP.js → D4H6aUyZ.js} +7 -7
  72. package/.output/public/_nuxt/{Dg5xB15N.js → D82vCrfD.js} +1 -1
  73. package/.output/public/_nuxt/D8l8udqQ.js +1 -0
  74. package/.output/public/_nuxt/D9ITfHnZ.js +269 -0
  75. package/.output/public/_nuxt/{RNghxpo_.js → DDvzSYfr.js} +1 -1
  76. package/.output/public/_nuxt/{Aopv2gwH.js → DFwfZeyL.js} +1 -1
  77. package/.output/public/_nuxt/{GgtqCdye.js → DMM9kDc1.js} +1 -1
  78. package/.output/public/_nuxt/{DOPqH6_T.js → DNVXBFXP.js} +1 -1
  79. package/.output/public/_nuxt/DPOp833l.js +1 -0
  80. package/.output/public/_nuxt/{D2obegTF.js → DPQHj1GW.js} +1 -1
  81. package/.output/public/_nuxt/DRJZaHtK.js +1 -0
  82. package/.output/public/_nuxt/{BlfjmxyP.js → DRTFVhVr.js} +1 -1
  83. package/.output/public/_nuxt/{TsXTqZ29.js → DSeZwD4N.js} +1 -1
  84. package/.output/public/_nuxt/{C8lm7lgC.js → DTYY2tCY.js} +1 -1
  85. package/.output/public/_nuxt/{DWa2aw6r.js → DVKmRHSk.js} +1 -1
  86. package/.output/public/_nuxt/DYE7WIF3.js +1 -0
  87. package/.output/public/_nuxt/{D-wGZMZP.js → DYYyOkJe.js} +1 -1
  88. package/.output/public/_nuxt/{BCVaR2pQ.js → DcV32yum.js} +1 -1
  89. package/.output/public/_nuxt/DdhYQ3Tv.js +1 -0
  90. package/.output/public/_nuxt/DgsIRcX7.js +1 -0
  91. package/.output/public/_nuxt/{BtvRca6l.js → DjAJT7YJ.js} +1 -1
  92. package/.output/public/_nuxt/DmMgvbsF.js +1 -0
  93. package/.output/public/_nuxt/{pxXmJ8QX.js → DrQCNsTo.js} +1 -1
  94. package/.output/public/_nuxt/{DNqd6Nek.js → DvCXikgN.js} +1 -1
  95. package/.output/public/_nuxt/DzQULtcW.js +1 -0
  96. package/.output/public/_nuxt/{Cm-2nZ05.js → DzowYWbi.js} +1 -1
  97. package/.output/public/_nuxt/{DQwYQDb2.js → FtFNcQmh.js} +1 -1
  98. package/.output/public/_nuxt/{BPcwi1q2.js → I4u-TRO-.js} +1 -1
  99. package/.output/public/_nuxt/{D5z-4QVk.js → O3nsZ-Uz.js} +1 -1
  100. package/.output/public/_nuxt/Qj4UhtaN.js +1 -0
  101. package/.output/public/_nuxt/{BA0jw7CM.js → VF7GAmoY.js} +1 -1
  102. package/.output/public/_nuxt/Ve4PFQV2.js +1 -0
  103. package/.output/public/_nuxt/{xrNU8mHG.js → YpnHruhZ.js} +1 -1
  104. package/.output/public/_nuxt/_H4v1dQx.js +1 -0
  105. package/.output/public/_nuxt/_pageId_.C5KTkEfy.css +1 -0
  106. package/.output/public/_nuxt/_panelId_.CKSHyLNC.css +1 -0
  107. package/.output/public/_nuxt/builds/latest.json +1 -1
  108. package/.output/public/_nuxt/builds/meta/53add2c3-4d7c-4a4f-a116-e73c3787cf98.json +1 -0
  109. package/.output/public/_nuxt/components.a-P9dVi2.css +1 -0
  110. package/.output/public/_nuxt/{entry.Bc0aTA0K.css → entry.DsBbjDm-.css} +1 -1
  111. package/.output/public/_nuxt/eo99z4R2.js +1 -0
  112. package/.output/public/_nuxt/error-404.DnBTUElh.css +1 -0
  113. package/.output/public/_nuxt/error-500.BNyYF0qG.css +1 -0
  114. package/.output/public/_nuxt/{BUNf2Yb8.js → fbfpKHgl.js} +1 -1
  115. package/.output/public/_nuxt/{BDs6uo3D.js → fxmP1KZw.js} +1 -1
  116. package/.output/public/_nuxt/graph-resolver-DhjyrFRu.js +180 -0
  117. package/.output/public/_nuxt/{mUFnM-_q.js → hunqYsQf.js} +1 -1
  118. package/.output/public/_nuxt/iJghVVcV.js +1 -0
  119. package/.output/public/_nuxt/{DyMmfYiE.js → m4Sxwg8n.js} +1 -1
  120. package/.output/public/_nuxt/monaco-editor.DOXZIHvr.css +1 -0
  121. package/.output/public/_nuxt/oH_c3LbQ.js +1 -0
  122. package/.output/public/_nuxt/rZm6bMo-.js +1 -0
  123. package/.output/public/_nuxt/{DOMRsNpU.js → rpHuDh4d.js} +1 -1
  124. package/.output/public/_nuxt/{vuetify.BzdWZaIq.css → vuetify.DtnS3-VQ.css} +1 -1
  125. package/.output/public/_nuxt/{yaml.worker-C1Cl1y5J.js → yaml.worker-CYOhFCVP.js} +248 -252
  126. package/.output/server/index.mjs +3272 -7573
  127. package/.output/server/index.mjs.map +1 -1
  128. package/.output/server/node_modules/@babel/parser/lib/index.js +1 -1
  129. package/.output/server/node_modules/@babel/parser/package.json +1 -1
  130. package/.output/server/node_modules/@trpc/server/dist/adapters/fetch/index.cjs +57 -0
  131. package/.output/server/node_modules/@trpc/server/dist/adapters/fetch/index.mjs +2 -2
  132. package/.output/server/node_modules/@trpc/server/dist/codes-BfZsPdy-.cjs +222 -0
  133. package/.output/server/node_modules/@trpc/server/dist/{contentTypeParsers-SN4WL9ze.mjs → contentTypeParsers-iAFF_pJG.cjs} +7 -2
  134. package/.output/server/node_modules/@trpc/server/dist/getErrorShape-MR4DZeb7.cjs +341 -0
  135. package/.output/server/node_modules/@trpc/server/dist/http.cjs +14 -0
  136. package/.output/server/node_modules/@trpc/server/dist/index.cjs +22 -0
  137. package/.output/server/node_modules/@trpc/server/dist/index.mjs +2 -2
  138. package/.output/server/node_modules/@trpc/server/dist/{initTRPC-RoZMIBeA.mjs → initTRPC-B1ggxyJl.mjs} +2 -2
  139. package/.output/server/node_modules/@trpc/server/dist/initTRPC-BXPPV9Tx.cjs +416 -0
  140. package/.output/server/node_modules/@trpc/server/dist/observable/index.cjs +13 -0
  141. package/.output/server/node_modules/@trpc/server/dist/observable-B1Nk6r1H.cjs +181 -0
  142. package/.output/server/node_modules/@trpc/server/dist/{observable-CUiPknO-.mjs → observable-BVzLuBs6.cjs} +42 -8
  143. package/.output/server/node_modules/@trpc/server/dist/{parseTRPCMessage-CTow-umk.mjs → parseTRPCMessage-7Ltmq-Fb.cjs} +14 -4
  144. package/.output/server/node_modules/@trpc/server/dist/resolveResponse-B0CCg8nq.cjs +2365 -0
  145. package/.output/server/node_modules/@trpc/server/dist/{resolveResponse-BVDlNZwN.mjs → resolveResponse-C5I6V_wc.mjs} +67 -18
  146. package/.output/server/node_modules/@trpc/server/dist/rpc.cjs +6 -0
  147. package/.output/server/node_modules/@trpc/server/dist/{tracked-Bjtgv3wJ.mjs → tracked-DiE3uR1B.mjs} +12 -3
  148. package/.output/server/node_modules/@trpc/server/dist/tracked-Dj_dpOJE.cjs +486 -0
  149. package/.output/server/node_modules/@trpc/server/package.json +15 -5
  150. package/.output/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +2 -2
  151. package/.output/server/node_modules/@vue/compiler-core/package.json +3 -3
  152. package/.output/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +1 -1
  153. package/.output/server/node_modules/@vue/compiler-dom/package.json +3 -3
  154. package/.output/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1 -1
  155. package/.output/server/node_modules/@vue/compiler-ssr/package.json +3 -3
  156. package/.output/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +31 -13
  157. package/.output/server/node_modules/@vue/reactivity/package.json +2 -2
  158. package/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +144 -81
  159. package/.output/server/node_modules/@vue/runtime-core/package.json +3 -3
  160. package/.output/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +70 -9
  161. package/.output/server/node_modules/@vue/runtime-dom/package.json +4 -4
  162. package/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +6 -2
  163. package/.output/server/node_modules/@vue/server-renderer/package.json +4 -4
  164. package/.output/server/node_modules/@vue/shared/dist/shared.cjs.prod.js +1 -1
  165. package/.output/server/node_modules/@vue/shared/package.json +1 -1
  166. package/.output/server/node_modules/devalue/package.json +5 -2
  167. package/.output/server/node_modules/devalue/src/base64.js +46 -96
  168. package/.output/server/node_modules/devalue/src/parse.js +32 -10
  169. package/.output/server/node_modules/devalue/src/stringify.js +13 -28
  170. package/.output/server/node_modules/devalue/src/uneval.js +117 -55
  171. package/.output/server/node_modules/devalue/src/utils.js +3 -7
  172. package/.output/server/node_modules/hookable/dist/index.mjs +5 -14
  173. package/.output/server/node_modules/hookable/package.json +24 -23
  174. package/.output/server/node_modules/trpc-bun-adapter/dist/index.js +406 -0
  175. package/.output/server/node_modules/trpc-bun-adapter/package.json +44 -0
  176. package/.output/server/node_modules/unhead/dist/plugins.mjs +3 -3
  177. package/.output/server/node_modules/unhead/dist/server.mjs +2 -2
  178. package/.output/server/node_modules/unhead/dist/shared/{unhead.eK9_7LaY.mjs → unhead.B5FWS6X0.mjs} +22 -13
  179. package/.output/server/node_modules/unhead/dist/shared/{unhead.BFfcxOoW.mjs → unhead.Ct24BOby.mjs} +4 -2
  180. package/.output/server/node_modules/unhead/dist/shared/unhead.D4vSFytZ.mjs +236 -0
  181. package/.output/server/node_modules/unhead/dist/shared/{unhead.ckV6dpEQ.mjs → unhead.TxTMM7cM.mjs} +1 -1
  182. package/.output/server/node_modules/unhead/dist/utils.mjs +1 -1
  183. package/.output/server/node_modules/unhead/package.json +1 -1
  184. package/.output/server/node_modules/vue/dist/vue.cjs.js +1 -1
  185. package/.output/server/node_modules/vue/dist/vue.cjs.prod.js +1 -1
  186. package/.output/server/node_modules/vue/package.json +7 -7
  187. package/.output/server/node_modules/ws/lib/permessage-deflate.js +6 -6
  188. package/.output/server/node_modules/ws/lib/websocket-server.js +5 -5
  189. package/.output/server/node_modules/ws/lib/websocket.js +6 -6
  190. package/.output/server/node_modules/ws/package.json +4 -3
  191. package/.output/server/node_modules/ws/wrapper.mjs +14 -1
  192. package/.output/server/package.json +17 -16
  193. package/package.json +20 -14
  194. package/.output/public/_nuxt/57B6Rca8.js +0 -1
  195. package/.output/public/_nuxt/83L43bj1.js +0 -1
  196. package/.output/public/_nuxt/B8nw2aST.js +0 -2
  197. package/.output/public/_nuxt/B93PlW-d.js +0 -1
  198. package/.output/public/_nuxt/BDa1f6PF.js +0 -2
  199. package/.output/public/_nuxt/BE_Meo09.js +0 -269
  200. package/.output/public/_nuxt/BLF3u89x.js +0 -1
  201. package/.output/public/_nuxt/Ba13S78F.js +0 -1
  202. package/.output/public/_nuxt/BhRPY-oY.js +0 -1
  203. package/.output/public/_nuxt/Bhrxn6JZ.js +0 -1
  204. package/.output/public/_nuxt/Bo8jzlL1.js +0 -18
  205. package/.output/public/_nuxt/BpkvlDNi.js +0 -1
  206. package/.output/public/_nuxt/BrzmwbiE.js +0 -1
  207. package/.output/public/_nuxt/BuJgCY_C.js +0 -1
  208. package/.output/public/_nuxt/C-sUppwS.js +0 -1
  209. package/.output/public/_nuxt/C47S-Tmv.js +0 -1
  210. package/.output/public/_nuxt/CMjwMIkn.js +0 -1
  211. package/.output/public/_nuxt/CPZSvMBB.js +0 -1
  212. package/.output/public/_nuxt/CPpO8vcZ.js +0 -1
  213. package/.output/public/_nuxt/CQ8jqdy-.js +0 -1
  214. package/.output/public/_nuxt/CjoLj4QM.js +0 -1
  215. package/.output/public/_nuxt/D6fh7rEe.js +0 -2
  216. package/.output/public/_nuxt/D91rOou-.js +0 -13
  217. package/.output/public/_nuxt/DMwsHuHA.js +0 -1
  218. package/.output/public/_nuxt/DYoxhk2S.js +0 -1
  219. package/.output/public/_nuxt/Dbwml2gB.js +0 -1
  220. package/.output/public/_nuxt/DsS90Fp6.js +0 -1
  221. package/.output/public/_nuxt/Dv7Oe6Be.js +0 -1
  222. package/.output/public/_nuxt/DxERyYWQ.js +0 -1
  223. package/.output/public/_nuxt/GDxZ_Nvm.js +0 -14
  224. package/.output/public/_nuxt/VCDPK7BO.js +0 -1
  225. package/.output/public/_nuxt/builds/meta/a1fec520-0c95-4ae0-af5e-964780fad341.json +0 -1
  226. package/.output/public/_nuxt/components.CIe9upZ4.css +0 -1
  227. package/.output/public/_nuxt/error-404.X7H_YhdC.css +0 -1
  228. package/.output/public/_nuxt/error-500.BOQe1fsk.css +0 -1
  229. package/.output/public/_nuxt/f3TOpYbw.js +0 -1
  230. package/.output/public/_nuxt/graph-resolver-DKNtntr2.js +0 -180
  231. package/.output/public/_nuxt/monaco-editor.D_J4ItrK.css +0 -1
  232. package/.output/public/_nuxt/o_m1mZtJ.js +0 -6
  233. package/.output/server/node_modules/@trpc/server/dist/adapters/ws.mjs +0 -15
  234. package/.output/server/node_modules/@trpc/server/dist/node-http-DtA2iLK9.mjs +0 -224
  235. package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import-9NNw8uQM.mjs +0 -31
  236. package/.output/server/node_modules/@trpc/server/dist/ws-CJgZE7Hg.mjs +0 -460
  237. package/.output/server/node_modules/unhead/dist/shared/unhead.CApf5sj3.mjs +0 -148
  238. package/LICENSE +0 -21
  239. /package/.output/public/_nuxt/{XEA9GSJd.js → B69Z0Xk1.js} +0 -0
  240. /package/.output/server/node_modules/@trpc/server/dist/{http-CWyjOa1l.mjs → http-DXy3XyhL.cjs} +0 -0
@@ -0,0 +1,2365 @@
1
+ const require_getErrorShape = require('./getErrorShape-MR4DZeb7.cjs');
2
+ const require_codes = require('./codes-BfZsPdy-.cjs');
3
+ const require_tracked = require('./tracked-Dj_dpOJE.cjs');
4
+ const require_observable = require('./observable-B1Nk6r1H.cjs');
5
+
6
+ //#region src/unstable-core-do-not-import/http/parseConnectionParams.ts
7
+ function parseConnectionParamsFromUnknown(parsed) {
8
+ try {
9
+ if (parsed === null) return null;
10
+ if (!require_codes.isObject(parsed)) throw new Error("Expected object");
11
+ const nonStringValues = Object.entries(parsed).filter(([_key, value]) => typeof value !== "string");
12
+ if (nonStringValues.length > 0) throw new Error(`Expected connectionParams to be string values. Got ${nonStringValues.map(([key, value]) => `${key}: ${typeof value}`).join(", ")}`);
13
+ return parsed;
14
+ } catch (cause) {
15
+ throw new require_tracked.TRPCError({
16
+ code: "PARSE_ERROR",
17
+ message: "Invalid connection params shape",
18
+ cause
19
+ });
20
+ }
21
+ }
22
+ function parseConnectionParamsFromString(str) {
23
+ let parsed;
24
+ try {
25
+ parsed = JSON.parse(str);
26
+ } catch (cause) {
27
+ throw new require_tracked.TRPCError({
28
+ code: "PARSE_ERROR",
29
+ message: "Not JSON-parsable query params",
30
+ cause
31
+ });
32
+ }
33
+ return parseConnectionParamsFromUnknown(parsed);
34
+ }
35
+
36
+ //#endregion
37
+ //#region src/unstable-core-do-not-import/http/contentType.ts
38
+ var import_objectSpread2$1 = require_getErrorShape.__toESM(require_getErrorShape.require_objectSpread2(), 1);
39
+ function getAcceptHeader(headers) {
40
+ var _ref, _headers$get;
41
+ return (_ref = headers.get("trpc-accept")) !== null && _ref !== void 0 ? _ref : ((_headers$get = headers.get("accept")) === null || _headers$get === void 0 ? void 0 : _headers$get.split(",").some((t) => t.trim() === "application/jsonl")) ? "application/jsonl" : null;
42
+ }
43
+ /**
44
+ * Memoize a function that takes no arguments
45
+ * @internal
46
+ */
47
+ function memo(fn) {
48
+ let promise = null;
49
+ const sym = Symbol.for("@trpc/server/http/memo");
50
+ let value = sym;
51
+ return {
52
+ read: async () => {
53
+ var _promise;
54
+ if (value !== sym) return value;
55
+ (_promise = promise) !== null && _promise !== void 0 || (promise = fn().catch((cause) => {
56
+ if (cause instanceof require_tracked.TRPCError) throw cause;
57
+ throw new require_tracked.TRPCError({
58
+ code: "BAD_REQUEST",
59
+ message: cause instanceof Error ? cause.message : "Invalid input",
60
+ cause
61
+ });
62
+ }));
63
+ value = await promise;
64
+ promise = null;
65
+ return value;
66
+ },
67
+ result: () => {
68
+ return value !== sym ? value : void 0;
69
+ }
70
+ };
71
+ }
72
+ const jsonContentTypeHandler = {
73
+ isMatch(req) {
74
+ var _req$headers$get;
75
+ return !!((_req$headers$get = req.headers.get("content-type")) === null || _req$headers$get === void 0 ? void 0 : _req$headers$get.startsWith("application/json"));
76
+ },
77
+ async parse(opts) {
78
+ var _types$values$next$va;
79
+ const { req } = opts;
80
+ const isBatchCall = opts.searchParams.get("batch") === "1";
81
+ const maxBatchSize = opts.maxBatchSize;
82
+ const paths = isBatchCall ? opts.path.split(",") : [opts.path];
83
+ if (isBatchCall && typeof maxBatchSize === "number" && paths.length > maxBatchSize) throw new require_tracked.TRPCError({
84
+ code: "BAD_REQUEST",
85
+ message: `Batch call exceeds maximum size`
86
+ });
87
+ const getInputs = memo(async () => {
88
+ let inputs = void 0;
89
+ if (req.method === "GET") {
90
+ const queryInput = opts.searchParams.get("input");
91
+ if (queryInput) inputs = JSON.parse(queryInput);
92
+ } else inputs = await req.json();
93
+ if (inputs === void 0) return require_codes.emptyObject();
94
+ if (!isBatchCall) {
95
+ const result = require_codes.emptyObject();
96
+ result[0] = opts.router._def._config.transformer.input.deserialize(inputs);
97
+ return result;
98
+ }
99
+ if (!require_codes.isObject(inputs)) throw new require_tracked.TRPCError({
100
+ code: "BAD_REQUEST",
101
+ message: "\"input\" needs to be an object when doing a batch call"
102
+ });
103
+ const acc = require_codes.emptyObject();
104
+ for (const index of paths.keys()) {
105
+ const input = inputs[index];
106
+ if (input !== void 0) acc[index] = opts.router._def._config.transformer.input.deserialize(input);
107
+ }
108
+ return acc;
109
+ });
110
+ const calls = await Promise.all(paths.map(async (path, index) => {
111
+ const procedure = await require_tracked.getProcedureAtPath(opts.router, path);
112
+ return {
113
+ batchIndex: index,
114
+ path,
115
+ procedure,
116
+ getRawInput: async () => {
117
+ const inputs = await getInputs.read();
118
+ let input = inputs[index];
119
+ if ((procedure === null || procedure === void 0 ? void 0 : procedure._def.type) === "subscription") {
120
+ var _ref2, _opts$headers$get;
121
+ const lastEventId = (_ref2 = (_opts$headers$get = opts.headers.get("last-event-id")) !== null && _opts$headers$get !== void 0 ? _opts$headers$get : opts.searchParams.get("lastEventId")) !== null && _ref2 !== void 0 ? _ref2 : opts.searchParams.get("Last-Event-Id");
122
+ if (lastEventId) if (require_codes.isObject(input)) input = (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, input), {}, { lastEventId });
123
+ else {
124
+ var _input;
125
+ (_input = input) !== null && _input !== void 0 || (input = { lastEventId });
126
+ }
127
+ }
128
+ return input;
129
+ },
130
+ result: () => {
131
+ var _getInputs$result;
132
+ return (_getInputs$result = getInputs.result()) === null || _getInputs$result === void 0 ? void 0 : _getInputs$result[index];
133
+ }
134
+ };
135
+ }));
136
+ const types = new Set(calls.map((call) => {
137
+ var _call$procedure;
138
+ return (_call$procedure = call.procedure) === null || _call$procedure === void 0 ? void 0 : _call$procedure._def.type;
139
+ }).filter(Boolean));
140
+ /* istanbul ignore if -- @preserve */
141
+ if (types.size > 1) throw new require_tracked.TRPCError({
142
+ code: "BAD_REQUEST",
143
+ message: `Cannot mix procedure types in call: ${Array.from(types).join(", ")}`
144
+ });
145
+ const type = (_types$values$next$va = types.values().next().value) !== null && _types$values$next$va !== void 0 ? _types$values$next$va : "unknown";
146
+ const connectionParamsStr = opts.searchParams.get("connectionParams");
147
+ const info = {
148
+ isBatchCall,
149
+ accept: getAcceptHeader(req.headers),
150
+ calls,
151
+ type,
152
+ connectionParams: connectionParamsStr === null ? null : parseConnectionParamsFromString(connectionParamsStr),
153
+ signal: req.signal,
154
+ url: opts.url
155
+ };
156
+ return info;
157
+ }
158
+ };
159
+ const formDataContentTypeHandler = {
160
+ isMatch(req) {
161
+ var _req$headers$get2;
162
+ return !!((_req$headers$get2 = req.headers.get("content-type")) === null || _req$headers$get2 === void 0 ? void 0 : _req$headers$get2.startsWith("multipart/form-data"));
163
+ },
164
+ async parse(opts) {
165
+ const { req } = opts;
166
+ if (req.method !== "POST") throw new require_tracked.TRPCError({
167
+ code: "METHOD_NOT_SUPPORTED",
168
+ message: "Only POST requests are supported for multipart/form-data requests"
169
+ });
170
+ const getInputs = memo(async () => {
171
+ const fd = await req.formData();
172
+ return fd;
173
+ });
174
+ const procedure = await require_tracked.getProcedureAtPath(opts.router, opts.path);
175
+ return {
176
+ accept: null,
177
+ calls: [{
178
+ batchIndex: 0,
179
+ path: opts.path,
180
+ getRawInput: getInputs.read,
181
+ result: getInputs.result,
182
+ procedure
183
+ }],
184
+ isBatchCall: false,
185
+ type: "mutation",
186
+ connectionParams: null,
187
+ signal: req.signal,
188
+ url: opts.url
189
+ };
190
+ }
191
+ };
192
+ const octetStreamContentTypeHandler = {
193
+ isMatch(req) {
194
+ var _req$headers$get3;
195
+ return !!((_req$headers$get3 = req.headers.get("content-type")) === null || _req$headers$get3 === void 0 ? void 0 : _req$headers$get3.startsWith("application/octet-stream"));
196
+ },
197
+ async parse(opts) {
198
+ const { req } = opts;
199
+ if (req.method !== "POST") throw new require_tracked.TRPCError({
200
+ code: "METHOD_NOT_SUPPORTED",
201
+ message: "Only POST requests are supported for application/octet-stream requests"
202
+ });
203
+ const getInputs = memo(async () => {
204
+ return req.body;
205
+ });
206
+ return {
207
+ calls: [{
208
+ batchIndex: 0,
209
+ path: opts.path,
210
+ getRawInput: getInputs.read,
211
+ result: getInputs.result,
212
+ procedure: await require_tracked.getProcedureAtPath(opts.router, opts.path)
213
+ }],
214
+ isBatchCall: false,
215
+ accept: null,
216
+ type: "mutation",
217
+ connectionParams: null,
218
+ signal: req.signal,
219
+ url: opts.url
220
+ };
221
+ }
222
+ };
223
+ const handlers = [
224
+ jsonContentTypeHandler,
225
+ formDataContentTypeHandler,
226
+ octetStreamContentTypeHandler
227
+ ];
228
+ function getContentTypeHandler(req) {
229
+ const handler = handlers.find((handler$1) => handler$1.isMatch(req));
230
+ if (handler) return handler;
231
+ if (!handler && req.method === "GET") return jsonContentTypeHandler;
232
+ throw new require_tracked.TRPCError({
233
+ code: "UNSUPPORTED_MEDIA_TYPE",
234
+ message: req.headers.has("content-type") ? `Unsupported content-type "${req.headers.get("content-type")}` : "Missing content-type header"
235
+ });
236
+ }
237
+ async function getRequestInfo(opts) {
238
+ const handler = getContentTypeHandler(opts.req);
239
+ return await handler.parse(opts);
240
+ }
241
+
242
+ //#endregion
243
+ //#region src/unstable-core-do-not-import/http/abortError.ts
244
+ function isAbortError(error) {
245
+ return require_codes.isObject(error) && error["name"] === "AbortError";
246
+ }
247
+ function throwAbortError(message = "AbortError") {
248
+ throw new DOMException(message, "AbortError");
249
+ }
250
+
251
+ //#endregion
252
+ //#region src/vendor/is-plain-object.ts
253
+ /*!
254
+ * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
255
+ *
256
+ * Copyright (c) 2014-2017, Jon Schlinkert.
257
+ * Released under the MIT License.
258
+ */
259
+ function isObject$1(o) {
260
+ return Object.prototype.toString.call(o) === "[object Object]";
261
+ }
262
+ function isPlainObject(o) {
263
+ var ctor, prot;
264
+ if (isObject$1(o) === false) return false;
265
+ ctor = o.constructor;
266
+ if (ctor === void 0) return true;
267
+ prot = ctor.prototype;
268
+ if (isObject$1(prot) === false) return false;
269
+ if (prot.hasOwnProperty("isPrototypeOf") === false) return false;
270
+ return true;
271
+ }
272
+
273
+ //#endregion
274
+ //#region src/vendor/unpromise/unpromise.ts
275
+ var import_defineProperty = require_getErrorShape.__toESM(require_getErrorShape.require_defineProperty(), 1);
276
+ let _Symbol$toStringTag;
277
+ /** Memory safe (weakmapped) cache of the ProxyPromise for each Promise,
278
+ * which is retained for the lifetime of the original Promise.
279
+ */
280
+ const subscribableCache = /* @__PURE__ */ new WeakMap();
281
+ /** A NOOP function allowing a consistent interface for settled
282
+ * SubscribedPromises (settled promises are not subscribed - they resolve
283
+ * immediately). */
284
+ const NOOP = () => {};
285
+ _Symbol$toStringTag = Symbol.toStringTag;
286
+ /**
287
+ * Every `Promise<T>` can be shadowed by a single `ProxyPromise<T>`. It is
288
+ * created once, cached and reused throughout the lifetime of the Promise. Get a
289
+ * Promise's ProxyPromise using `Unpromise.proxy(promise)`.
290
+ *
291
+ * The `ProxyPromise<T>` attaches handlers to the original `Promise<T>`
292
+ * `.then()` and `.catch()` just once. Promises derived from it use a
293
+ * subscription- (and unsubscription-) based mechanism that monitors these
294
+ * handlers.
295
+ *
296
+ * Every time you call `.subscribe()`, `.then()` `.catch()` or `.finally()` on a
297
+ * `ProxyPromise<T>` it returns a `SubscribedPromise<T>` having an additional
298
+ * `unsubscribe()` method. Calling `unsubscribe()` detaches reference chains
299
+ * from the original, potentially long-lived Promise, eliminating memory leaks.
300
+ *
301
+ * This approach can eliminate the memory leaks that otherwise come about from
302
+ * repeated `race()` or `any()` calls invoking `.then()` and `.catch()` multiple
303
+ * times on the same long-lived native Promise (subscriptions which can never be
304
+ * cleaned up).
305
+ *
306
+ * `Unpromise.race(promises)` is a reference implementation of `Promise.race`
307
+ * avoiding memory leaks when using long-lived unsettled Promises.
308
+ *
309
+ * `Unpromise.any(promises)` is a reference implementation of `Promise.any`
310
+ * avoiding memory leaks when using long-lived unsettled Promises.
311
+ *
312
+ * `Unpromise.resolve(promise)` returns an ephemeral `SubscribedPromise<T>` for
313
+ * any given `Promise<T>` facilitating arbitrary async/await patterns. Behind
314
+ * the scenes, `resolve` is implemented simply as
315
+ * `Unpromise.proxy(promise).subscribe()`. Don't forget to call `.unsubscribe()`
316
+ * to tidy up!
317
+ *
318
+ */
319
+ var Unpromise = class Unpromise {
320
+ constructor(arg) {
321
+ (0, import_defineProperty.default)(this, "promise", void 0);
322
+ (0, import_defineProperty.default)(this, "subscribers", []);
323
+ (0, import_defineProperty.default)(this, "settlement", null);
324
+ (0, import_defineProperty.default)(this, _Symbol$toStringTag, "Unpromise");
325
+ if (typeof arg === "function") this.promise = new Promise(arg);
326
+ else this.promise = arg;
327
+ const thenReturn = this.promise.then((value) => {
328
+ const { subscribers } = this;
329
+ this.subscribers = null;
330
+ this.settlement = {
331
+ status: "fulfilled",
332
+ value
333
+ };
334
+ subscribers === null || subscribers === void 0 || subscribers.forEach(({ resolve }) => {
335
+ resolve(value);
336
+ });
337
+ });
338
+ if ("catch" in thenReturn) thenReturn.catch((reason) => {
339
+ const { subscribers } = this;
340
+ this.subscribers = null;
341
+ this.settlement = {
342
+ status: "rejected",
343
+ reason
344
+ };
345
+ subscribers === null || subscribers === void 0 || subscribers.forEach(({ reject }) => {
346
+ reject(reason);
347
+ });
348
+ });
349
+ }
350
+ /** Create a promise that mitigates uncontrolled subscription to a long-lived
351
+ * Promise via .then() and .catch() - otherwise a source of memory leaks.
352
+ *
353
+ * The returned promise has an `unsubscribe()` method which can be called when
354
+ * the Promise is no longer being tracked by application logic, and which
355
+ * ensures that there is no reference chain from the original promise to the
356
+ * new one, and therefore no memory leak.
357
+ *
358
+ * If original promise has not yet settled, this adds a new unique promise
359
+ * that listens to then/catch events, along with an `unsubscribe()` method to
360
+ * detach it.
361
+ *
362
+ * If original promise has settled, then creates a new Promise.resolve() or
363
+ * Promise.reject() and provided unsubscribe is a noop.
364
+ *
365
+ * If you call `unsubscribe()` before the returned Promise has settled, it
366
+ * will never settle.
367
+ */
368
+ subscribe() {
369
+ let promise;
370
+ let unsubscribe;
371
+ const { settlement } = this;
372
+ if (settlement === null) {
373
+ if (this.subscribers === null) throw new Error("Unpromise settled but still has subscribers");
374
+ const subscriber = withResolvers();
375
+ this.subscribers = listWithMember(this.subscribers, subscriber);
376
+ promise = subscriber.promise;
377
+ unsubscribe = () => {
378
+ if (this.subscribers !== null) this.subscribers = listWithoutMember(this.subscribers, subscriber);
379
+ };
380
+ } else {
381
+ const { status } = settlement;
382
+ if (status === "fulfilled") promise = Promise.resolve(settlement.value);
383
+ else promise = Promise.reject(settlement.reason);
384
+ unsubscribe = NOOP;
385
+ }
386
+ return Object.assign(promise, { unsubscribe });
387
+ }
388
+ /** STANDARD PROMISE METHODS (but returning a SubscribedPromise) */
389
+ then(onfulfilled, onrejected) {
390
+ const subscribed = this.subscribe();
391
+ const { unsubscribe } = subscribed;
392
+ return Object.assign(subscribed.then(onfulfilled, onrejected), { unsubscribe });
393
+ }
394
+ catch(onrejected) {
395
+ const subscribed = this.subscribe();
396
+ const { unsubscribe } = subscribed;
397
+ return Object.assign(subscribed.catch(onrejected), { unsubscribe });
398
+ }
399
+ finally(onfinally) {
400
+ const subscribed = this.subscribe();
401
+ const { unsubscribe } = subscribed;
402
+ return Object.assign(subscribed.finally(onfinally), { unsubscribe });
403
+ }
404
+ /** Unpromise STATIC METHODS */
405
+ /** Create or Retrieve the proxy Unpromise (a re-used Unpromise for the VM lifetime
406
+ * of the provided Promise reference) */
407
+ static proxy(promise) {
408
+ const cached = Unpromise.getSubscribablePromise(promise);
409
+ return typeof cached !== "undefined" ? cached : Unpromise.createSubscribablePromise(promise);
410
+ }
411
+ /** Create and store an Unpromise keyed by an original Promise. */
412
+ static createSubscribablePromise(promise) {
413
+ const created = new Unpromise(promise);
414
+ subscribableCache.set(promise, created);
415
+ subscribableCache.set(created, created);
416
+ return created;
417
+ }
418
+ /** Retrieve a previously-created Unpromise keyed by an original Promise. */
419
+ static getSubscribablePromise(promise) {
420
+ return subscribableCache.get(promise);
421
+ }
422
+ /** Promise STATIC METHODS */
423
+ /** Lookup the Unpromise for this promise, and derive a SubscribedPromise from
424
+ * it (that can be later unsubscribed to eliminate Memory leaks) */
425
+ static resolve(value) {
426
+ const promise = typeof value === "object" && value !== null && "then" in value && typeof value.then === "function" ? value : Promise.resolve(value);
427
+ return Unpromise.proxy(promise).subscribe();
428
+ }
429
+ static async any(values) {
430
+ const valuesArray = Array.isArray(values) ? values : [...values];
431
+ const subscribedPromises = valuesArray.map(Unpromise.resolve);
432
+ try {
433
+ return await Promise.any(subscribedPromises);
434
+ } finally {
435
+ subscribedPromises.forEach(({ unsubscribe }) => {
436
+ unsubscribe();
437
+ });
438
+ }
439
+ }
440
+ static async race(values) {
441
+ const valuesArray = Array.isArray(values) ? values : [...values];
442
+ const subscribedPromises = valuesArray.map(Unpromise.resolve);
443
+ try {
444
+ return await Promise.race(subscribedPromises);
445
+ } finally {
446
+ subscribedPromises.forEach(({ unsubscribe }) => {
447
+ unsubscribe();
448
+ });
449
+ }
450
+ }
451
+ /** Create a race of SubscribedPromises that will fulfil to a single winning
452
+ * Promise (in a 1-Tuple). Eliminates memory leaks from long-lived promises
453
+ * accumulating .then() and .catch() subscribers. Allows simple logic to
454
+ * consume the result, like...
455
+ * ```ts
456
+ * const [ winner ] = await Unpromise.race([ promiseA, promiseB ]);
457
+ * if(winner === promiseB){
458
+ * const result = await promiseB;
459
+ * // do the thing
460
+ * }
461
+ * ```
462
+ * */
463
+ static async raceReferences(promises) {
464
+ const selfPromises = promises.map(resolveSelfTuple);
465
+ try {
466
+ return await Promise.race(selfPromises);
467
+ } finally {
468
+ for (const promise of selfPromises) promise.unsubscribe();
469
+ }
470
+ }
471
+ };
472
+ /** Promises a 1-tuple containing the original promise when it resolves. Allows
473
+ * awaiting the eventual Promise ***reference*** (easy to destructure and
474
+ * exactly compare with ===). Avoids resolving to the Promise ***value*** (which
475
+ * may be ambiguous and therefore hard to identify as the winner of a race).
476
+ * You can call unsubscribe on the Promise to mitigate memory leaks.
477
+ * */
478
+ function resolveSelfTuple(promise) {
479
+ return Unpromise.proxy(promise).then(() => [promise]);
480
+ }
481
+ /** VENDORED (Future) PROMISE UTILITIES */
482
+ /** Reference implementation of https://github.com/tc39/proposal-promise-with-resolvers */
483
+ function withResolvers() {
484
+ let resolve;
485
+ let reject;
486
+ const promise = new Promise((_resolve, _reject) => {
487
+ resolve = _resolve;
488
+ reject = _reject;
489
+ });
490
+ return {
491
+ promise,
492
+ resolve,
493
+ reject
494
+ };
495
+ }
496
+ /** IMMUTABLE LIST OPERATIONS */
497
+ function listWithMember(arr, member) {
498
+ return [...arr, member];
499
+ }
500
+ function listWithoutIndex(arr, index) {
501
+ return [...arr.slice(0, index), ...arr.slice(index + 1)];
502
+ }
503
+ function listWithoutMember(arr, member) {
504
+ const index = arr.indexOf(member);
505
+ if (index !== -1) return listWithoutIndex(arr, index);
506
+ return arr;
507
+ }
508
+
509
+ //#endregion
510
+ //#region src/unstable-core-do-not-import/stream/utils/disposable.ts
511
+ var _Symbol, _Symbol$dispose, _Symbol2, _Symbol2$asyncDispose;
512
+ (_Symbol$dispose = (_Symbol = Symbol).dispose) !== null && _Symbol$dispose !== void 0 || (_Symbol.dispose = Symbol());
513
+ (_Symbol2$asyncDispose = (_Symbol2 = Symbol).asyncDispose) !== null && _Symbol2$asyncDispose !== void 0 || (_Symbol2.asyncDispose = Symbol());
514
+ /**
515
+ * Takes a value and a dispose function and returns a new object that implements the Disposable interface.
516
+ * The returned object is the original value augmented with a Symbol.dispose method.
517
+ * @param thing The value to make disposable
518
+ * @param dispose Function to call when disposing the resource
519
+ * @returns The original value with Symbol.dispose method added
520
+ */
521
+ function makeResource(thing, dispose) {
522
+ const it = thing;
523
+ const existing = it[Symbol.dispose];
524
+ it[Symbol.dispose] = () => {
525
+ dispose();
526
+ existing === null || existing === void 0 || existing();
527
+ };
528
+ return it;
529
+ }
530
+ /**
531
+ * Takes a value and an async dispose function and returns a new object that implements the AsyncDisposable interface.
532
+ * The returned object is the original value augmented with a Symbol.asyncDispose method.
533
+ * @param thing The value to make async disposable
534
+ * @param dispose Async function to call when disposing the resource
535
+ * @returns The original value with Symbol.asyncDispose method added
536
+ */
537
+ function makeAsyncResource(thing, dispose) {
538
+ const it = thing;
539
+ const existing = it[Symbol.asyncDispose];
540
+ it[Symbol.asyncDispose] = async () => {
541
+ await dispose();
542
+ await (existing === null || existing === void 0 ? void 0 : existing());
543
+ };
544
+ return it;
545
+ }
546
+
547
+ //#endregion
548
+ //#region src/unstable-core-do-not-import/stream/utils/timerResource.ts
549
+ const disposablePromiseTimerResult = Symbol();
550
+ function timerResource(ms) {
551
+ let timer = null;
552
+ return makeResource({ start() {
553
+ if (timer) throw new Error("Timer already started");
554
+ const promise = new Promise((resolve) => {
555
+ timer = setTimeout(() => resolve(disposablePromiseTimerResult), ms);
556
+ });
557
+ return promise;
558
+ } }, () => {
559
+ if (timer) clearTimeout(timer);
560
+ });
561
+ }
562
+
563
+ //#endregion
564
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js
565
+ var require_usingCtx = require_getErrorShape.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(exports, module) {
566
+ function _usingCtx() {
567
+ var r = "function" == typeof SuppressedError ? SuppressedError : function(r$1, e$1) {
568
+ var n$1 = Error();
569
+ return n$1.name = "SuppressedError", n$1.error = r$1, n$1.suppressed = e$1, n$1;
570
+ }, e = {}, n = [];
571
+ function using(r$1, e$1) {
572
+ if (null != e$1) {
573
+ if (Object(e$1) !== e$1) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
574
+ if (r$1) var o = e$1[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
575
+ if (void 0 === o && (o = e$1[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r$1)) var t = o;
576
+ if ("function" != typeof o) throw new TypeError("Object is not disposable.");
577
+ t && (o = function o$1() {
578
+ try {
579
+ t.call(e$1);
580
+ } catch (r$2) {
581
+ return Promise.reject(r$2);
582
+ }
583
+ }), n.push({
584
+ v: e$1,
585
+ d: o,
586
+ a: r$1
587
+ });
588
+ } else r$1 && n.push({
589
+ d: e$1,
590
+ a: r$1
591
+ });
592
+ return e$1;
593
+ }
594
+ return {
595
+ e,
596
+ u: using.bind(null, !1),
597
+ a: using.bind(null, !0),
598
+ d: function d() {
599
+ var o, t = this.e, s = 0;
600
+ function next() {
601
+ for (; o = n.pop();) try {
602
+ if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next);
603
+ if (o.d) {
604
+ var r$1 = o.d.call(o.v);
605
+ if (o.a) return s |= 2, Promise.resolve(r$1).then(next, err);
606
+ } else s |= 1;
607
+ } catch (r$2) {
608
+ return err(r$2);
609
+ }
610
+ if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve();
611
+ if (t !== e) throw t;
612
+ }
613
+ function err(n$1) {
614
+ return t = t !== e ? new r(n$1, t) : n$1, next();
615
+ }
616
+ return next();
617
+ }
618
+ };
619
+ }
620
+ module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports;
621
+ } });
622
+
623
+ //#endregion
624
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js
625
+ var require_OverloadYield = require_getErrorShape.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(exports, module) {
626
+ function _OverloadYield(e, d) {
627
+ this.v = e, this.k = d;
628
+ }
629
+ module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
630
+ } });
631
+
632
+ //#endregion
633
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js
634
+ var require_awaitAsyncGenerator = require_getErrorShape.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(exports, module) {
635
+ var OverloadYield$2 = require_OverloadYield();
636
+ function _awaitAsyncGenerator$5(e) {
637
+ return new OverloadYield$2(e, 0);
638
+ }
639
+ module.exports = _awaitAsyncGenerator$5, module.exports.__esModule = true, module.exports["default"] = module.exports;
640
+ } });
641
+
642
+ //#endregion
643
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js
644
+ var require_wrapAsyncGenerator = require_getErrorShape.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(exports, module) {
645
+ var OverloadYield$1 = require_OverloadYield();
646
+ function _wrapAsyncGenerator$6(e) {
647
+ return function() {
648
+ return new AsyncGenerator(e.apply(this, arguments));
649
+ };
650
+ }
651
+ function AsyncGenerator(e) {
652
+ var r, t;
653
+ function resume(r$1, t$1) {
654
+ try {
655
+ var n = e[r$1](t$1), o = n.value, u = o instanceof OverloadYield$1;
656
+ Promise.resolve(u ? o.v : o).then(function(t$2) {
657
+ if (u) {
658
+ var i = "return" === r$1 ? "return" : "next";
659
+ if (!o.k || t$2.done) return resume(i, t$2);
660
+ t$2 = e[i](t$2).value;
661
+ }
662
+ settle(n.done ? "return" : "normal", t$2);
663
+ }, function(e$1) {
664
+ resume("throw", e$1);
665
+ });
666
+ } catch (e$1) {
667
+ settle("throw", e$1);
668
+ }
669
+ }
670
+ function settle(e$1, n) {
671
+ switch (e$1) {
672
+ case "return":
673
+ r.resolve({
674
+ value: n,
675
+ done: !0
676
+ });
677
+ break;
678
+ case "throw":
679
+ r.reject(n);
680
+ break;
681
+ default: r.resolve({
682
+ value: n,
683
+ done: !1
684
+ });
685
+ }
686
+ (r = r.next) ? resume(r.key, r.arg) : t = null;
687
+ }
688
+ this._invoke = function(e$1, n) {
689
+ return new Promise(function(o, u) {
690
+ var i = {
691
+ key: e$1,
692
+ arg: n,
693
+ resolve: o,
694
+ reject: u,
695
+ next: null
696
+ };
697
+ t ? t = t.next = i : (r = t = i, resume(e$1, n));
698
+ });
699
+ }, "function" != typeof e["return"] && (this["return"] = void 0);
700
+ }
701
+ AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
702
+ return this;
703
+ }, AsyncGenerator.prototype.next = function(e) {
704
+ return this._invoke("next", e);
705
+ }, AsyncGenerator.prototype["throw"] = function(e) {
706
+ return this._invoke("throw", e);
707
+ }, AsyncGenerator.prototype["return"] = function(e) {
708
+ return this._invoke("return", e);
709
+ };
710
+ module.exports = _wrapAsyncGenerator$6, module.exports.__esModule = true, module.exports["default"] = module.exports;
711
+ } });
712
+
713
+ //#endregion
714
+ //#region src/unstable-core-do-not-import/stream/utils/asyncIterable.ts
715
+ var import_usingCtx$4 = require_getErrorShape.__toESM(require_usingCtx(), 1);
716
+ var import_awaitAsyncGenerator$4 = require_getErrorShape.__toESM(require_awaitAsyncGenerator(), 1);
717
+ var import_wrapAsyncGenerator$5 = require_getErrorShape.__toESM(require_wrapAsyncGenerator(), 1);
718
+ function iteratorResource(iterable) {
719
+ const iterator = iterable[Symbol.asyncIterator]();
720
+ if (iterator[Symbol.asyncDispose]) return iterator;
721
+ return makeAsyncResource(iterator, async () => {
722
+ var _iterator$return;
723
+ await ((_iterator$return = iterator.return) === null || _iterator$return === void 0 ? void 0 : _iterator$return.call(iterator));
724
+ });
725
+ }
726
+ /**
727
+ * Derives a new {@link AsyncGenerator} based of {@link iterable}, that yields its first
728
+ * {@link count} values. Then, a grace period of {@link gracePeriodMs} is started in which further
729
+ * values may still come through. After this period, the generator aborts.
730
+ */
731
+ function takeWithGrace(_x, _x2) {
732
+ return _takeWithGrace.apply(this, arguments);
733
+ }
734
+ function _takeWithGrace() {
735
+ _takeWithGrace = (0, import_wrapAsyncGenerator$5.default)(function* (iterable, opts) {
736
+ try {
737
+ var _usingCtx$1 = (0, import_usingCtx$4.default)();
738
+ const iterator = _usingCtx$1.a(iteratorResource(iterable));
739
+ let result;
740
+ const timer = _usingCtx$1.u(timerResource(opts.gracePeriodMs));
741
+ let count = opts.count;
742
+ let timerPromise = new Promise(() => {});
743
+ while (true) {
744
+ result = yield (0, import_awaitAsyncGenerator$4.default)(Unpromise.race([iterator.next(), timerPromise]));
745
+ if (result === disposablePromiseTimerResult) throwAbortError();
746
+ if (result.done) return result.value;
747
+ yield result.value;
748
+ if (--count === 0) timerPromise = timer.start();
749
+ result = null;
750
+ }
751
+ } catch (_) {
752
+ _usingCtx$1.e = _;
753
+ } finally {
754
+ yield (0, import_awaitAsyncGenerator$4.default)(_usingCtx$1.d());
755
+ }
756
+ });
757
+ return _takeWithGrace.apply(this, arguments);
758
+ }
759
+
760
+ //#endregion
761
+ //#region src/unstable-core-do-not-import/stream/utils/createDeferred.ts
762
+ function createDeferred() {
763
+ let resolve;
764
+ let reject;
765
+ const promise = new Promise((res, rej) => {
766
+ resolve = res;
767
+ reject = rej;
768
+ });
769
+ return {
770
+ promise,
771
+ resolve,
772
+ reject
773
+ };
774
+ }
775
+
776
+ //#endregion
777
+ //#region src/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.ts
778
+ var import_usingCtx$3 = require_getErrorShape.__toESM(require_usingCtx(), 1);
779
+ var import_awaitAsyncGenerator$3 = require_getErrorShape.__toESM(require_awaitAsyncGenerator(), 1);
780
+ var import_wrapAsyncGenerator$4 = require_getErrorShape.__toESM(require_wrapAsyncGenerator(), 1);
781
+ function createManagedIterator(iterable, onResult) {
782
+ const iterator = iterable[Symbol.asyncIterator]();
783
+ let state = "idle";
784
+ function cleanup() {
785
+ state = "done";
786
+ onResult = () => {};
787
+ }
788
+ function pull() {
789
+ if (state !== "idle") return;
790
+ state = "pending";
791
+ const next = iterator.next();
792
+ next.then((result) => {
793
+ if (result.done) {
794
+ state = "done";
795
+ onResult({
796
+ status: "return",
797
+ value: result.value
798
+ });
799
+ cleanup();
800
+ return;
801
+ }
802
+ state = "idle";
803
+ onResult({
804
+ status: "yield",
805
+ value: result.value
806
+ });
807
+ }).catch((cause) => {
808
+ onResult({
809
+ status: "error",
810
+ error: cause
811
+ });
812
+ cleanup();
813
+ });
814
+ }
815
+ return {
816
+ pull,
817
+ destroy: async () => {
818
+ var _iterator$return;
819
+ cleanup();
820
+ await ((_iterator$return = iterator.return) === null || _iterator$return === void 0 ? void 0 : _iterator$return.call(iterator));
821
+ }
822
+ };
823
+ }
824
+ /**
825
+ * Creates a new async iterable that merges multiple async iterables into a single stream.
826
+ * Values from the input iterables are yielded in the order they resolve, similar to Promise.race().
827
+ *
828
+ * New iterables can be added dynamically using the returned {@link MergedAsyncIterables.add} method, even after iteration has started.
829
+ *
830
+ * If any of the input iterables throws an error, that error will be propagated through the merged stream.
831
+ * Other iterables will not continue to be processed.
832
+ *
833
+ * @template TYield The type of values yielded by the input iterables
834
+ */
835
+ function mergeAsyncIterables() {
836
+ let state = "idle";
837
+ let flushSignal = createDeferred();
838
+ /**
839
+ * used while {@link state} is `idle`
840
+ */
841
+ const iterables = [];
842
+ /**
843
+ * used while {@link state} is `pending`
844
+ */
845
+ const iterators = /* @__PURE__ */ new Set();
846
+ const buffer = [];
847
+ function initIterable(iterable) {
848
+ if (state !== "pending") return;
849
+ const iterator = createManagedIterator(iterable, (result) => {
850
+ if (state !== "pending") return;
851
+ switch (result.status) {
852
+ case "yield":
853
+ buffer.push([iterator, result]);
854
+ break;
855
+ case "return":
856
+ iterators.delete(iterator);
857
+ break;
858
+ case "error":
859
+ buffer.push([iterator, result]);
860
+ iterators.delete(iterator);
861
+ break;
862
+ }
863
+ flushSignal.resolve();
864
+ });
865
+ iterators.add(iterator);
866
+ iterator.pull();
867
+ }
868
+ return {
869
+ add(iterable) {
870
+ switch (state) {
871
+ case "idle":
872
+ iterables.push(iterable);
873
+ break;
874
+ case "pending":
875
+ initIterable(iterable);
876
+ break;
877
+ case "done": break;
878
+ }
879
+ },
880
+ [Symbol.asyncIterator]() {
881
+ return (0, import_wrapAsyncGenerator$4.default)(function* () {
882
+ try {
883
+ var _usingCtx$1 = (0, import_usingCtx$3.default)();
884
+ if (state !== "idle") throw new Error("Cannot iterate twice");
885
+ state = "pending";
886
+ const _finally = _usingCtx$1.a(makeAsyncResource({}, async () => {
887
+ state = "done";
888
+ const errors = [];
889
+ await Promise.all(Array.from(iterators.values()).map(async (it) => {
890
+ try {
891
+ await it.destroy();
892
+ } catch (cause) {
893
+ errors.push(cause);
894
+ }
895
+ }));
896
+ buffer.length = 0;
897
+ iterators.clear();
898
+ flushSignal.resolve();
899
+ if (errors.length > 0) throw new AggregateError(errors);
900
+ }));
901
+ while (iterables.length > 0) initIterable(iterables.shift());
902
+ while (iterators.size > 0) {
903
+ yield (0, import_awaitAsyncGenerator$3.default)(flushSignal.promise);
904
+ while (buffer.length > 0) {
905
+ const [iterator, result] = buffer.shift();
906
+ switch (result.status) {
907
+ case "yield":
908
+ yield result.value;
909
+ iterator.pull();
910
+ break;
911
+ case "error": throw result.error;
912
+ }
913
+ }
914
+ flushSignal = createDeferred();
915
+ }
916
+ } catch (_) {
917
+ _usingCtx$1.e = _;
918
+ } finally {
919
+ yield (0, import_awaitAsyncGenerator$3.default)(_usingCtx$1.d());
920
+ }
921
+ })();
922
+ }
923
+ };
924
+ }
925
+
926
+ //#endregion
927
+ //#region src/unstable-core-do-not-import/stream/utils/readableStreamFrom.ts
928
+ /**
929
+ * Creates a ReadableStream from an AsyncIterable.
930
+ *
931
+ * @param iterable - The source AsyncIterable to stream from
932
+ * @returns A ReadableStream that yields values from the AsyncIterable
933
+ */
934
+ function readableStreamFrom(iterable) {
935
+ const iterator = iterable[Symbol.asyncIterator]();
936
+ return new ReadableStream({
937
+ async cancel() {
938
+ var _iterator$return;
939
+ await ((_iterator$return = iterator.return) === null || _iterator$return === void 0 ? void 0 : _iterator$return.call(iterator));
940
+ },
941
+ async pull(controller) {
942
+ const result = await iterator.next();
943
+ if (result.done) {
944
+ controller.close();
945
+ return;
946
+ }
947
+ controller.enqueue(result.value);
948
+ }
949
+ });
950
+ }
951
+
952
+ //#endregion
953
+ //#region src/unstable-core-do-not-import/stream/utils/withPing.ts
954
+ var import_usingCtx$2 = require_getErrorShape.__toESM(require_usingCtx(), 1);
955
+ var import_awaitAsyncGenerator$2 = require_getErrorShape.__toESM(require_awaitAsyncGenerator(), 1);
956
+ var import_wrapAsyncGenerator$3 = require_getErrorShape.__toESM(require_wrapAsyncGenerator(), 1);
957
+ const PING_SYM = Symbol("ping");
958
+ /**
959
+ * Derives a new {@link AsyncGenerator} based of {@link iterable}, that yields {@link PING_SYM}
960
+ * whenever no value has been yielded for {@link pingIntervalMs}.
961
+ */
962
+ function withPing(_x, _x2) {
963
+ return _withPing.apply(this, arguments);
964
+ }
965
+ function _withPing() {
966
+ _withPing = (0, import_wrapAsyncGenerator$3.default)(function* (iterable, pingIntervalMs) {
967
+ try {
968
+ var _usingCtx$1 = (0, import_usingCtx$2.default)();
969
+ const iterator = _usingCtx$1.a(iteratorResource(iterable));
970
+ let result;
971
+ let nextPromise = iterator.next();
972
+ while (true) try {
973
+ var _usingCtx3 = (0, import_usingCtx$2.default)();
974
+ const pingPromise = _usingCtx3.u(timerResource(pingIntervalMs));
975
+ result = yield (0, import_awaitAsyncGenerator$2.default)(Unpromise.race([nextPromise, pingPromise.start()]));
976
+ if (result === disposablePromiseTimerResult) {
977
+ yield PING_SYM;
978
+ continue;
979
+ }
980
+ if (result.done) return result.value;
981
+ nextPromise = iterator.next();
982
+ yield result.value;
983
+ result = null;
984
+ } catch (_) {
985
+ _usingCtx3.e = _;
986
+ } finally {
987
+ _usingCtx3.d();
988
+ }
989
+ } catch (_) {
990
+ _usingCtx$1.e = _;
991
+ } finally {
992
+ yield (0, import_awaitAsyncGenerator$2.default)(_usingCtx$1.d());
993
+ }
994
+ });
995
+ return _withPing.apply(this, arguments);
996
+ }
997
+
998
+ //#endregion
999
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js
1000
+ var require_asyncIterator = require_getErrorShape.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(exports, module) {
1001
+ function _asyncIterator$2(r) {
1002
+ var n, t, o, e = 2;
1003
+ for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) {
1004
+ if (t && null != (n = r[t])) return n.call(r);
1005
+ if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
1006
+ t = "@@asyncIterator", o = "@@iterator";
1007
+ }
1008
+ throw new TypeError("Object is not async iterable");
1009
+ }
1010
+ function AsyncFromSyncIterator(r) {
1011
+ function AsyncFromSyncIteratorContinuation(r$1) {
1012
+ if (Object(r$1) !== r$1) return Promise.reject(new TypeError(r$1 + " is not an object."));
1013
+ var n = r$1.done;
1014
+ return Promise.resolve(r$1.value).then(function(r$2) {
1015
+ return {
1016
+ value: r$2,
1017
+ done: n
1018
+ };
1019
+ });
1020
+ }
1021
+ return AsyncFromSyncIterator = function AsyncFromSyncIterator$1(r$1) {
1022
+ this.s = r$1, this.n = r$1.next;
1023
+ }, AsyncFromSyncIterator.prototype = {
1024
+ s: null,
1025
+ n: null,
1026
+ next: function next() {
1027
+ return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
1028
+ },
1029
+ "return": function _return(r$1) {
1030
+ var n = this.s["return"];
1031
+ return void 0 === n ? Promise.resolve({
1032
+ value: r$1,
1033
+ done: !0
1034
+ }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
1035
+ },
1036
+ "throw": function _throw(r$1) {
1037
+ var n = this.s["return"];
1038
+ return void 0 === n ? Promise.reject(r$1) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
1039
+ }
1040
+ }, new AsyncFromSyncIterator(r);
1041
+ }
1042
+ module.exports = _asyncIterator$2, module.exports.__esModule = true, module.exports["default"] = module.exports;
1043
+ } });
1044
+
1045
+ //#endregion
1046
+ //#region src/unstable-core-do-not-import/stream/jsonl.ts
1047
+ var import_awaitAsyncGenerator$1 = require_getErrorShape.__toESM(require_awaitAsyncGenerator(), 1);
1048
+ var import_wrapAsyncGenerator$2 = require_getErrorShape.__toESM(require_wrapAsyncGenerator(), 1);
1049
+ var import_usingCtx$1 = require_getErrorShape.__toESM(require_usingCtx(), 1);
1050
+ var import_asyncIterator$1 = require_getErrorShape.__toESM(require_asyncIterator(), 1);
1051
+ const CHUNK_VALUE_TYPE_PROMISE = 0;
1052
+ const CHUNK_VALUE_TYPE_ASYNC_ITERABLE = 1;
1053
+ const PROMISE_STATUS_FULFILLED = 0;
1054
+ const PROMISE_STATUS_REJECTED = 1;
1055
+ const ASYNC_ITERABLE_STATUS_RETURN = 0;
1056
+ const ASYNC_ITERABLE_STATUS_YIELD = 1;
1057
+ const ASYNC_ITERABLE_STATUS_ERROR = 2;
1058
+ function isPromise(value) {
1059
+ return (require_codes.isObject(value) || require_codes.isFunction(value)) && typeof (value === null || value === void 0 ? void 0 : value["then"]) === "function" && typeof (value === null || value === void 0 ? void 0 : value["catch"]) === "function";
1060
+ }
1061
+ var MaxDepthError = class extends Error {
1062
+ constructor(path) {
1063
+ super("Max depth reached at path: " + path.join("."));
1064
+ this.path = path;
1065
+ }
1066
+ };
1067
+ function createBatchStreamProducer(_x3) {
1068
+ return _createBatchStreamProducer.apply(this, arguments);
1069
+ }
1070
+ function _createBatchStreamProducer() {
1071
+ _createBatchStreamProducer = (0, import_wrapAsyncGenerator$2.default)(function* (opts) {
1072
+ const { data } = opts;
1073
+ let counter = 0;
1074
+ const placeholder = 0;
1075
+ const mergedIterables = mergeAsyncIterables();
1076
+ function registerAsync(callback) {
1077
+ const idx = counter++;
1078
+ const iterable$1 = callback(idx);
1079
+ mergedIterables.add(iterable$1);
1080
+ return idx;
1081
+ }
1082
+ function encodePromise(promise, path) {
1083
+ return registerAsync(/* @__PURE__ */ function() {
1084
+ var _ref = (0, import_wrapAsyncGenerator$2.default)(function* (idx) {
1085
+ const error = checkMaxDepth(path);
1086
+ if (error) {
1087
+ promise.catch((cause) => {
1088
+ var _opts$onError;
1089
+ (_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, {
1090
+ error: cause,
1091
+ path
1092
+ });
1093
+ });
1094
+ promise = Promise.reject(error);
1095
+ }
1096
+ try {
1097
+ const next = yield (0, import_awaitAsyncGenerator$1.default)(promise);
1098
+ yield [
1099
+ idx,
1100
+ PROMISE_STATUS_FULFILLED,
1101
+ encode(next, path)
1102
+ ];
1103
+ } catch (cause) {
1104
+ var _opts$onError2, _opts$formatError;
1105
+ (_opts$onError2 = opts.onError) === null || _opts$onError2 === void 0 || _opts$onError2.call(opts, {
1106
+ error: cause,
1107
+ path
1108
+ });
1109
+ yield [
1110
+ idx,
1111
+ PROMISE_STATUS_REJECTED,
1112
+ (_opts$formatError = opts.formatError) === null || _opts$formatError === void 0 ? void 0 : _opts$formatError.call(opts, {
1113
+ error: cause,
1114
+ path
1115
+ })
1116
+ ];
1117
+ }
1118
+ });
1119
+ return function(_x) {
1120
+ return _ref.apply(this, arguments);
1121
+ };
1122
+ }());
1123
+ }
1124
+ function encodeAsyncIterable(iterable$1, path) {
1125
+ return registerAsync(/* @__PURE__ */ function() {
1126
+ var _ref2 = (0, import_wrapAsyncGenerator$2.default)(function* (idx) {
1127
+ try {
1128
+ var _usingCtx$1 = (0, import_usingCtx$1.default)();
1129
+ const error = checkMaxDepth(path);
1130
+ if (error) throw error;
1131
+ const iterator = _usingCtx$1.a(iteratorResource(iterable$1));
1132
+ try {
1133
+ while (true) {
1134
+ const next = yield (0, import_awaitAsyncGenerator$1.default)(iterator.next());
1135
+ if (next.done) {
1136
+ yield [
1137
+ idx,
1138
+ ASYNC_ITERABLE_STATUS_RETURN,
1139
+ encode(next.value, path)
1140
+ ];
1141
+ break;
1142
+ }
1143
+ yield [
1144
+ idx,
1145
+ ASYNC_ITERABLE_STATUS_YIELD,
1146
+ encode(next.value, path)
1147
+ ];
1148
+ }
1149
+ } catch (cause) {
1150
+ var _opts$onError3, _opts$formatError2;
1151
+ (_opts$onError3 = opts.onError) === null || _opts$onError3 === void 0 || _opts$onError3.call(opts, {
1152
+ error: cause,
1153
+ path
1154
+ });
1155
+ yield [
1156
+ idx,
1157
+ ASYNC_ITERABLE_STATUS_ERROR,
1158
+ (_opts$formatError2 = opts.formatError) === null || _opts$formatError2 === void 0 ? void 0 : _opts$formatError2.call(opts, {
1159
+ error: cause,
1160
+ path
1161
+ })
1162
+ ];
1163
+ }
1164
+ } catch (_) {
1165
+ _usingCtx$1.e = _;
1166
+ } finally {
1167
+ yield (0, import_awaitAsyncGenerator$1.default)(_usingCtx$1.d());
1168
+ }
1169
+ });
1170
+ return function(_x2) {
1171
+ return _ref2.apply(this, arguments);
1172
+ };
1173
+ }());
1174
+ }
1175
+ function checkMaxDepth(path) {
1176
+ if (opts.maxDepth && path.length > opts.maxDepth) return new MaxDepthError(path);
1177
+ return null;
1178
+ }
1179
+ function encodeAsync(value, path) {
1180
+ if (isPromise(value)) return [CHUNK_VALUE_TYPE_PROMISE, encodePromise(value, path)];
1181
+ if (require_codes.isAsyncIterable(value)) {
1182
+ if (opts.maxDepth && path.length >= opts.maxDepth) throw new Error("Max depth reached");
1183
+ return [CHUNK_VALUE_TYPE_ASYNC_ITERABLE, encodeAsyncIterable(value, path)];
1184
+ }
1185
+ return null;
1186
+ }
1187
+ function encode(value, path) {
1188
+ if (value === void 0) return [[]];
1189
+ const reg = encodeAsync(value, path);
1190
+ if (reg) return [[placeholder], [null, ...reg]];
1191
+ if (!isPlainObject(value)) return [[value]];
1192
+ const newObj = require_codes.emptyObject();
1193
+ const asyncValues = [];
1194
+ for (const [key, item] of Object.entries(value)) {
1195
+ const transformed = encodeAsync(item, [...path, key]);
1196
+ if (!transformed) {
1197
+ newObj[key] = item;
1198
+ continue;
1199
+ }
1200
+ newObj[key] = placeholder;
1201
+ asyncValues.push([key, ...transformed]);
1202
+ }
1203
+ return [[newObj], ...asyncValues];
1204
+ }
1205
+ const newHead = require_codes.emptyObject();
1206
+ for (const [key, item] of Object.entries(data)) newHead[key] = encode(item, [key]);
1207
+ yield newHead;
1208
+ let iterable = mergedIterables;
1209
+ if (opts.pingMs) iterable = withPing(mergedIterables, opts.pingMs);
1210
+ var _iteratorAbruptCompletion = false;
1211
+ var _didIteratorError = false;
1212
+ var _iteratorError;
1213
+ try {
1214
+ for (var _iterator = (0, import_asyncIterator$1.default)(iterable), _step; _iteratorAbruptCompletion = !(_step = yield (0, import_awaitAsyncGenerator$1.default)(_iterator.next())).done; _iteratorAbruptCompletion = false) {
1215
+ const value = _step.value;
1216
+ yield value;
1217
+ }
1218
+ } catch (err) {
1219
+ _didIteratorError = true;
1220
+ _iteratorError = err;
1221
+ } finally {
1222
+ try {
1223
+ if (_iteratorAbruptCompletion && _iterator.return != null) yield (0, import_awaitAsyncGenerator$1.default)(_iterator.return());
1224
+ } finally {
1225
+ if (_didIteratorError) throw _iteratorError;
1226
+ }
1227
+ }
1228
+ });
1229
+ return _createBatchStreamProducer.apply(this, arguments);
1230
+ }
1231
+ /**
1232
+ * JSON Lines stream producer
1233
+ * @see https://jsonlines.org/
1234
+ */
1235
+ function jsonlStreamProducer(opts) {
1236
+ let stream = readableStreamFrom(createBatchStreamProducer(opts));
1237
+ const { serialize } = opts;
1238
+ if (serialize) stream = stream.pipeThrough(new TransformStream({ transform(chunk, controller) {
1239
+ if (chunk === PING_SYM) controller.enqueue(PING_SYM);
1240
+ else controller.enqueue(serialize(chunk));
1241
+ } }));
1242
+ return stream.pipeThrough(new TransformStream({ transform(chunk, controller) {
1243
+ if (chunk === PING_SYM) controller.enqueue(" ");
1244
+ else controller.enqueue(JSON.stringify(chunk) + "\n");
1245
+ } })).pipeThrough(new TextEncoderStream());
1246
+ }
1247
+ var AsyncError = class extends Error {
1248
+ constructor(data) {
1249
+ super("Received error from server");
1250
+ this.data = data;
1251
+ }
1252
+ };
1253
+ const nodeJsStreamToReaderEsque = (source) => {
1254
+ return { getReader() {
1255
+ const stream = new ReadableStream({ start(controller) {
1256
+ source.on("data", (chunk) => {
1257
+ controller.enqueue(chunk);
1258
+ });
1259
+ source.on("end", () => {
1260
+ controller.close();
1261
+ });
1262
+ source.on("error", (error) => {
1263
+ controller.error(error);
1264
+ });
1265
+ } });
1266
+ return stream.getReader();
1267
+ } };
1268
+ };
1269
+ function createLineAccumulator(from) {
1270
+ const reader = "getReader" in from ? from.getReader() : nodeJsStreamToReaderEsque(from).getReader();
1271
+ let lineAggregate = "";
1272
+ return new ReadableStream({
1273
+ async pull(controller) {
1274
+ const { done, value } = await reader.read();
1275
+ if (done) controller.close();
1276
+ else controller.enqueue(value);
1277
+ },
1278
+ cancel() {
1279
+ return reader.cancel();
1280
+ }
1281
+ }).pipeThrough(new TextDecoderStream()).pipeThrough(new TransformStream({ transform(chunk, controller) {
1282
+ var _parts$pop;
1283
+ lineAggregate += chunk;
1284
+ const parts = lineAggregate.split("\n");
1285
+ lineAggregate = (_parts$pop = parts.pop()) !== null && _parts$pop !== void 0 ? _parts$pop : "";
1286
+ for (const part of parts) controller.enqueue(part);
1287
+ } }));
1288
+ }
1289
+ function createConsumerStream(from) {
1290
+ const stream = createLineAccumulator(from);
1291
+ let sentHead = false;
1292
+ return stream.pipeThrough(new TransformStream({ transform(line, controller) {
1293
+ if (!sentHead) {
1294
+ const head = JSON.parse(line);
1295
+ controller.enqueue(head);
1296
+ sentHead = true;
1297
+ } else {
1298
+ const chunk = JSON.parse(line);
1299
+ controller.enqueue(chunk);
1300
+ }
1301
+ } }));
1302
+ }
1303
+ /**
1304
+ * Creates a handler for managing stream controllers and their lifecycle
1305
+ */
1306
+ function createStreamsManager(abortController) {
1307
+ const controllerMap = /* @__PURE__ */ new Map();
1308
+ /**
1309
+ * Checks if there are no pending controllers or deferred promises
1310
+ */
1311
+ function isEmpty() {
1312
+ return Array.from(controllerMap.values()).every((c) => c.closed);
1313
+ }
1314
+ /**
1315
+ * Creates a stream controller
1316
+ */
1317
+ function createStreamController() {
1318
+ let originalController;
1319
+ const stream = new ReadableStream({ start(controller) {
1320
+ originalController = controller;
1321
+ } });
1322
+ const streamController = {
1323
+ enqueue: (v) => originalController.enqueue(v),
1324
+ close: () => {
1325
+ originalController.close();
1326
+ clear();
1327
+ if (isEmpty()) abortController.abort();
1328
+ },
1329
+ closed: false,
1330
+ getReaderResource: () => {
1331
+ const reader = stream.getReader();
1332
+ return makeResource(reader, () => {
1333
+ streamController.close();
1334
+ reader.releaseLock();
1335
+ });
1336
+ },
1337
+ error: (reason) => {
1338
+ originalController.error(reason);
1339
+ clear();
1340
+ }
1341
+ };
1342
+ function clear() {
1343
+ Object.assign(streamController, {
1344
+ closed: true,
1345
+ close: () => {},
1346
+ enqueue: () => {},
1347
+ getReaderResource: null,
1348
+ error: () => {}
1349
+ });
1350
+ }
1351
+ return streamController;
1352
+ }
1353
+ /**
1354
+ * Gets or creates a stream controller
1355
+ */
1356
+ function getOrCreate(chunkId) {
1357
+ let c = controllerMap.get(chunkId);
1358
+ if (!c) {
1359
+ c = createStreamController();
1360
+ controllerMap.set(chunkId, c);
1361
+ }
1362
+ return c;
1363
+ }
1364
+ /**
1365
+ * Cancels all pending controllers and rejects deferred promises
1366
+ */
1367
+ function cancelAll(reason) {
1368
+ for (const controller of controllerMap.values()) controller.error(reason);
1369
+ }
1370
+ /**
1371
+ * Closes all pending controllers to preserve buffered data
1372
+ */
1373
+ function closeAll() {
1374
+ for (const controller of controllerMap.values()) controller.close();
1375
+ }
1376
+ return {
1377
+ getOrCreate,
1378
+ cancelAll,
1379
+ closeAll
1380
+ };
1381
+ }
1382
+ /**
1383
+ * JSON Lines stream consumer
1384
+ * @see https://jsonlines.org/
1385
+ */
1386
+ async function jsonlStreamConsumer(opts) {
1387
+ const { deserialize = (v) => v } = opts;
1388
+ let source = createConsumerStream(opts.from);
1389
+ if (deserialize) source = source.pipeThrough(new TransformStream({ transform(chunk, controller) {
1390
+ controller.enqueue(deserialize(chunk));
1391
+ } }));
1392
+ let headDeferred = createDeferred();
1393
+ const streamManager = createStreamsManager(opts.abortController);
1394
+ function decodeChunkDefinition(value) {
1395
+ const [_path, type, chunkId] = value;
1396
+ const controller = streamManager.getOrCreate(chunkId);
1397
+ switch (type) {
1398
+ case CHUNK_VALUE_TYPE_PROMISE: return require_codes.run(async () => {
1399
+ try {
1400
+ var _usingCtx3 = (0, import_usingCtx$1.default)();
1401
+ const reader = _usingCtx3.u(controller.getReaderResource());
1402
+ const { value: value$1 } = await reader.read();
1403
+ const [_chunkId, status, data] = value$1;
1404
+ switch (status) {
1405
+ case PROMISE_STATUS_FULFILLED: return decode(data);
1406
+ case PROMISE_STATUS_REJECTED:
1407
+ var _opts$formatError3, _opts$formatError4;
1408
+ throw (_opts$formatError3 = (_opts$formatError4 = opts.formatError) === null || _opts$formatError4 === void 0 ? void 0 : _opts$formatError4.call(opts, { error: data })) !== null && _opts$formatError3 !== void 0 ? _opts$formatError3 : new AsyncError(data);
1409
+ }
1410
+ } catch (_) {
1411
+ _usingCtx3.e = _;
1412
+ } finally {
1413
+ _usingCtx3.d();
1414
+ }
1415
+ });
1416
+ case CHUNK_VALUE_TYPE_ASYNC_ITERABLE: return require_codes.run((0, import_wrapAsyncGenerator$2.default)(function* () {
1417
+ try {
1418
+ var _usingCtx4 = (0, import_usingCtx$1.default)();
1419
+ const reader = _usingCtx4.u(controller.getReaderResource());
1420
+ while (true) {
1421
+ const { value: value$1 } = yield (0, import_awaitAsyncGenerator$1.default)(reader.read());
1422
+ const [_chunkId, status, data] = value$1;
1423
+ switch (status) {
1424
+ case ASYNC_ITERABLE_STATUS_YIELD:
1425
+ yield decode(data);
1426
+ break;
1427
+ case ASYNC_ITERABLE_STATUS_RETURN: return decode(data);
1428
+ case ASYNC_ITERABLE_STATUS_ERROR:
1429
+ var _opts$formatError5, _opts$formatError6;
1430
+ throw (_opts$formatError5 = (_opts$formatError6 = opts.formatError) === null || _opts$formatError6 === void 0 ? void 0 : _opts$formatError6.call(opts, { error: data })) !== null && _opts$formatError5 !== void 0 ? _opts$formatError5 : new AsyncError(data);
1431
+ }
1432
+ }
1433
+ } catch (_) {
1434
+ _usingCtx4.e = _;
1435
+ } finally {
1436
+ _usingCtx4.d();
1437
+ }
1438
+ }));
1439
+ }
1440
+ }
1441
+ function decode(value) {
1442
+ const [[data], ...asyncProps] = value;
1443
+ for (const value$1 of asyncProps) {
1444
+ const [key] = value$1;
1445
+ const decoded = decodeChunkDefinition(value$1);
1446
+ if (key === null) return decoded;
1447
+ data[key] = decoded;
1448
+ }
1449
+ return data;
1450
+ }
1451
+ const handleClose = () => {
1452
+ if (headDeferred) {
1453
+ headDeferred.reject(new Error("Stream closed before head was received"));
1454
+ headDeferred = null;
1455
+ }
1456
+ streamManager.closeAll();
1457
+ };
1458
+ const handleAbort = (reason) => {
1459
+ headDeferred === null || headDeferred === void 0 || headDeferred.reject(reason);
1460
+ headDeferred = null;
1461
+ streamManager.cancelAll(reason);
1462
+ };
1463
+ source.pipeTo(new WritableStream({
1464
+ write(chunkOrHead) {
1465
+ if (headDeferred) {
1466
+ const head = chunkOrHead;
1467
+ for (const [key, value] of Object.entries(chunkOrHead)) {
1468
+ const parsed = decode(value);
1469
+ head[key] = parsed;
1470
+ }
1471
+ headDeferred.resolve(head);
1472
+ headDeferred = null;
1473
+ return;
1474
+ }
1475
+ const chunk = chunkOrHead;
1476
+ const [idx] = chunk;
1477
+ const controller = streamManager.getOrCreate(idx);
1478
+ controller.enqueue(chunk);
1479
+ },
1480
+ close: handleClose,
1481
+ abort: handleAbort
1482
+ })).catch((error) => {
1483
+ var _opts$onError4;
1484
+ (_opts$onError4 = opts.onError) === null || _opts$onError4 === void 0 || _opts$onError4.call(opts, { error });
1485
+ handleAbort(error);
1486
+ });
1487
+ return [await headDeferred.promise];
1488
+ }
1489
+
1490
+ //#endregion
1491
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncGeneratorDelegate.js
1492
+ var require_asyncGeneratorDelegate = require_getErrorShape.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncGeneratorDelegate.js"(exports, module) {
1493
+ var OverloadYield = require_OverloadYield();
1494
+ function _asyncGeneratorDelegate$1(t) {
1495
+ var e = {}, n = !1;
1496
+ function pump(e$1, r) {
1497
+ return n = !0, r = new Promise(function(n$1) {
1498
+ n$1(t[e$1](r));
1499
+ }), {
1500
+ done: !1,
1501
+ value: new OverloadYield(r, 1)
1502
+ };
1503
+ }
1504
+ return e["undefined" != typeof Symbol && Symbol.iterator || "@@iterator"] = function() {
1505
+ return this;
1506
+ }, e.next = function(t$1) {
1507
+ return n ? (n = !1, t$1) : pump("next", t$1);
1508
+ }, "function" == typeof t["throw"] && (e["throw"] = function(t$1) {
1509
+ if (n) throw n = !1, t$1;
1510
+ return pump("throw", t$1);
1511
+ }), "function" == typeof t["return"] && (e["return"] = function(t$1) {
1512
+ return n ? (n = !1, t$1) : pump("return", t$1);
1513
+ }), e;
1514
+ }
1515
+ module.exports = _asyncGeneratorDelegate$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
1516
+ } });
1517
+
1518
+ //#endregion
1519
+ //#region src/unstable-core-do-not-import/stream/sse.ts
1520
+ var import_asyncIterator = require_getErrorShape.__toESM(require_asyncIterator(), 1);
1521
+ var import_awaitAsyncGenerator = require_getErrorShape.__toESM(require_awaitAsyncGenerator(), 1);
1522
+ var import_wrapAsyncGenerator$1 = require_getErrorShape.__toESM(require_wrapAsyncGenerator(), 1);
1523
+ var import_asyncGeneratorDelegate = require_getErrorShape.__toESM(require_asyncGeneratorDelegate(), 1);
1524
+ var import_usingCtx = require_getErrorShape.__toESM(require_usingCtx(), 1);
1525
+ const PING_EVENT = "ping";
1526
+ const SERIALIZED_ERROR_EVENT = "serialized-error";
1527
+ const CONNECTED_EVENT = "connected";
1528
+ const RETURN_EVENT = "return";
1529
+ /**
1530
+ *
1531
+ * @see https://html.spec.whatwg.org/multipage/server-sent-events.html
1532
+ */
1533
+ function sseStreamProducer(opts) {
1534
+ var _opts$ping$enabled, _opts$ping, _opts$ping$intervalMs, _opts$ping2, _opts$client;
1535
+ const { serialize = require_codes.identity } = opts;
1536
+ const ping = {
1537
+ enabled: (_opts$ping$enabled = (_opts$ping = opts.ping) === null || _opts$ping === void 0 ? void 0 : _opts$ping.enabled) !== null && _opts$ping$enabled !== void 0 ? _opts$ping$enabled : false,
1538
+ intervalMs: (_opts$ping$intervalMs = (_opts$ping2 = opts.ping) === null || _opts$ping2 === void 0 ? void 0 : _opts$ping2.intervalMs) !== null && _opts$ping$intervalMs !== void 0 ? _opts$ping$intervalMs : 1e3
1539
+ };
1540
+ const client = (_opts$client = opts.client) !== null && _opts$client !== void 0 ? _opts$client : {};
1541
+ if (ping.enabled && client.reconnectAfterInactivityMs && ping.intervalMs > client.reconnectAfterInactivityMs) throw new Error(`Ping interval must be less than client reconnect interval to prevent unnecessary reconnection - ping.intervalMs: ${ping.intervalMs} client.reconnectAfterInactivityMs: ${client.reconnectAfterInactivityMs}`);
1542
+ function generator() {
1543
+ return _generator.apply(this, arguments);
1544
+ }
1545
+ function _generator() {
1546
+ _generator = (0, import_wrapAsyncGenerator$1.default)(function* () {
1547
+ yield {
1548
+ event: CONNECTED_EVENT,
1549
+ data: JSON.stringify(client)
1550
+ };
1551
+ let iterable = opts.data;
1552
+ if (opts.emitAndEndImmediately) iterable = takeWithGrace(iterable, {
1553
+ count: 1,
1554
+ gracePeriodMs: 1
1555
+ });
1556
+ if (ping.enabled && ping.intervalMs !== Infinity && ping.intervalMs > 0) iterable = withPing(iterable, ping.intervalMs);
1557
+ let value;
1558
+ let chunk;
1559
+ var _iteratorAbruptCompletion = false;
1560
+ var _didIteratorError = false;
1561
+ var _iteratorError;
1562
+ try {
1563
+ for (var _iterator = (0, import_asyncIterator.default)(iterable), _step; _iteratorAbruptCompletion = !(_step = yield (0, import_awaitAsyncGenerator.default)(_iterator.next())).done; _iteratorAbruptCompletion = false) {
1564
+ value = _step.value;
1565
+ {
1566
+ if (value === PING_SYM) {
1567
+ yield {
1568
+ event: PING_EVENT,
1569
+ data: ""
1570
+ };
1571
+ continue;
1572
+ }
1573
+ chunk = require_tracked.isTrackedEnvelope(value) ? {
1574
+ id: value[0],
1575
+ data: value[1]
1576
+ } : { data: value };
1577
+ chunk.data = JSON.stringify(serialize(chunk.data));
1578
+ yield chunk;
1579
+ value = null;
1580
+ chunk = null;
1581
+ }
1582
+ }
1583
+ } catch (err) {
1584
+ _didIteratorError = true;
1585
+ _iteratorError = err;
1586
+ } finally {
1587
+ try {
1588
+ if (_iteratorAbruptCompletion && _iterator.return != null) yield (0, import_awaitAsyncGenerator.default)(_iterator.return());
1589
+ } finally {
1590
+ if (_didIteratorError) throw _iteratorError;
1591
+ }
1592
+ }
1593
+ });
1594
+ return _generator.apply(this, arguments);
1595
+ }
1596
+ function generatorWithErrorHandling() {
1597
+ return _generatorWithErrorHandling.apply(this, arguments);
1598
+ }
1599
+ function _generatorWithErrorHandling() {
1600
+ _generatorWithErrorHandling = (0, import_wrapAsyncGenerator$1.default)(function* () {
1601
+ try {
1602
+ yield* (0, import_asyncGeneratorDelegate.default)((0, import_asyncIterator.default)(generator()));
1603
+ yield {
1604
+ event: RETURN_EVENT,
1605
+ data: ""
1606
+ };
1607
+ } catch (cause) {
1608
+ var _opts$formatError, _opts$formatError2;
1609
+ if (isAbortError(cause)) return;
1610
+ const error = require_tracked.getTRPCErrorFromUnknown(cause);
1611
+ const data = (_opts$formatError = (_opts$formatError2 = opts.formatError) === null || _opts$formatError2 === void 0 ? void 0 : _opts$formatError2.call(opts, { error })) !== null && _opts$formatError !== void 0 ? _opts$formatError : null;
1612
+ yield {
1613
+ event: SERIALIZED_ERROR_EVENT,
1614
+ data: JSON.stringify(serialize(data))
1615
+ };
1616
+ }
1617
+ });
1618
+ return _generatorWithErrorHandling.apply(this, arguments);
1619
+ }
1620
+ const stream = readableStreamFrom(generatorWithErrorHandling());
1621
+ return stream.pipeThrough(new TransformStream({ transform(chunk, controller) {
1622
+ if ("event" in chunk) controller.enqueue(`event: ${chunk.event}\n`);
1623
+ if ("data" in chunk) controller.enqueue(`data: ${chunk.data}\n`);
1624
+ if ("id" in chunk) controller.enqueue(`id: ${chunk.id}\n`);
1625
+ if ("comment" in chunk) controller.enqueue(`: ${chunk.comment}\n`);
1626
+ controller.enqueue("\n\n");
1627
+ } })).pipeThrough(new TextEncoderStream());
1628
+ }
1629
+ async function withTimeout(opts) {
1630
+ try {
1631
+ var _usingCtx$1 = (0, import_usingCtx.default)();
1632
+ const timeoutPromise = _usingCtx$1.u(timerResource(opts.timeoutMs));
1633
+ const res = await Unpromise.race([opts.promise, timeoutPromise.start()]);
1634
+ if (res === disposablePromiseTimerResult) return await opts.onTimeout();
1635
+ return res;
1636
+ } catch (_) {
1637
+ _usingCtx$1.e = _;
1638
+ } finally {
1639
+ _usingCtx$1.d();
1640
+ }
1641
+ }
1642
+ /**
1643
+ * @see https://html.spec.whatwg.org/multipage/server-sent-events.html
1644
+ */
1645
+ function sseStreamConsumer(opts) {
1646
+ const { deserialize = (v) => v } = opts;
1647
+ let clientOptions = require_codes.emptyObject();
1648
+ const signal = opts.signal;
1649
+ let _es = null;
1650
+ const createStream = () => new ReadableStream({
1651
+ async start(controller) {
1652
+ const [url, init] = await Promise.all([opts.url(), opts.init()]);
1653
+ const eventSource = _es = new opts.EventSource(url, init);
1654
+ controller.enqueue({
1655
+ type: "connecting",
1656
+ eventSource: _es,
1657
+ event: null
1658
+ });
1659
+ eventSource.addEventListener(CONNECTED_EVENT, (_msg) => {
1660
+ const msg = _msg;
1661
+ const options = JSON.parse(msg.data);
1662
+ clientOptions = options;
1663
+ controller.enqueue({
1664
+ type: "connected",
1665
+ options,
1666
+ eventSource
1667
+ });
1668
+ });
1669
+ eventSource.addEventListener(SERIALIZED_ERROR_EVENT, (_msg) => {
1670
+ const msg = _msg;
1671
+ controller.enqueue({
1672
+ type: "serialized-error",
1673
+ error: deserialize(JSON.parse(msg.data)),
1674
+ eventSource
1675
+ });
1676
+ });
1677
+ eventSource.addEventListener(PING_EVENT, () => {
1678
+ controller.enqueue({
1679
+ type: "ping",
1680
+ eventSource
1681
+ });
1682
+ });
1683
+ eventSource.addEventListener(RETURN_EVENT, () => {
1684
+ eventSource.close();
1685
+ controller.close();
1686
+ _es = null;
1687
+ });
1688
+ eventSource.addEventListener("error", (event) => {
1689
+ if (eventSource.readyState === eventSource.CLOSED) controller.error(event);
1690
+ else controller.enqueue({
1691
+ type: "connecting",
1692
+ eventSource,
1693
+ event
1694
+ });
1695
+ });
1696
+ eventSource.addEventListener("message", (_msg) => {
1697
+ const msg = _msg;
1698
+ const chunk = deserialize(JSON.parse(msg.data));
1699
+ const def = { data: chunk };
1700
+ if (msg.lastEventId) def.id = msg.lastEventId;
1701
+ controller.enqueue({
1702
+ type: "data",
1703
+ data: def,
1704
+ eventSource
1705
+ });
1706
+ });
1707
+ const onAbort = () => {
1708
+ try {
1709
+ eventSource.close();
1710
+ controller.close();
1711
+ } catch (_unused) {}
1712
+ };
1713
+ if (signal.aborted) onAbort();
1714
+ else signal.addEventListener("abort", onAbort);
1715
+ },
1716
+ cancel() {
1717
+ _es === null || _es === void 0 || _es.close();
1718
+ }
1719
+ });
1720
+ const getStreamResource = () => {
1721
+ let stream = createStream();
1722
+ let reader = stream.getReader();
1723
+ async function dispose() {
1724
+ await reader.cancel();
1725
+ _es = null;
1726
+ }
1727
+ return makeAsyncResource({
1728
+ read() {
1729
+ return reader.read();
1730
+ },
1731
+ async recreate() {
1732
+ await dispose();
1733
+ stream = createStream();
1734
+ reader = stream.getReader();
1735
+ }
1736
+ }, dispose);
1737
+ };
1738
+ return require_codes.run((0, import_wrapAsyncGenerator$1.default)(function* () {
1739
+ try {
1740
+ var _usingCtx3 = (0, import_usingCtx.default)();
1741
+ const stream = _usingCtx3.a(getStreamResource());
1742
+ while (true) {
1743
+ let promise = stream.read();
1744
+ const timeoutMs = clientOptions.reconnectAfterInactivityMs;
1745
+ if (timeoutMs) promise = withTimeout({
1746
+ promise,
1747
+ timeoutMs,
1748
+ onTimeout: async () => {
1749
+ const res = {
1750
+ value: {
1751
+ type: "timeout",
1752
+ ms: timeoutMs,
1753
+ eventSource: _es
1754
+ },
1755
+ done: false
1756
+ };
1757
+ await stream.recreate();
1758
+ return res;
1759
+ }
1760
+ });
1761
+ const result = yield (0, import_awaitAsyncGenerator.default)(promise);
1762
+ if (result.done) return result.value;
1763
+ yield result.value;
1764
+ }
1765
+ } catch (_) {
1766
+ _usingCtx3.e = _;
1767
+ } finally {
1768
+ yield (0, import_awaitAsyncGenerator.default)(_usingCtx3.d());
1769
+ }
1770
+ }));
1771
+ }
1772
+ const sseHeaders = {
1773
+ "Content-Type": "text/event-stream",
1774
+ "Cache-Control": "no-cache, no-transform",
1775
+ "X-Accel-Buffering": "no",
1776
+ Connection: "keep-alive"
1777
+ };
1778
+
1779
+ //#endregion
1780
+ //#region src/unstable-core-do-not-import/http/resolveResponse.ts
1781
+ var import_wrapAsyncGenerator = require_getErrorShape.__toESM(require_wrapAsyncGenerator(), 1);
1782
+ var import_objectSpread2 = require_getErrorShape.__toESM(require_getErrorShape.require_objectSpread2(), 1);
1783
+ function errorToAsyncIterable(err) {
1784
+ return require_codes.run((0, import_wrapAsyncGenerator.default)(function* () {
1785
+ throw err;
1786
+ }));
1787
+ }
1788
+ function combinedAbortController(signal) {
1789
+ const controller = new AbortController();
1790
+ const combinedSignal = require_codes.abortSignalsAnyPonyfill([signal, controller.signal]);
1791
+ return {
1792
+ signal: combinedSignal,
1793
+ controller
1794
+ };
1795
+ }
1796
+ const TYPE_ACCEPTED_METHOD_MAP = {
1797
+ mutation: ["POST"],
1798
+ query: ["GET"],
1799
+ subscription: ["GET"]
1800
+ };
1801
+ const TYPE_ACCEPTED_METHOD_MAP_WITH_METHOD_OVERRIDE = {
1802
+ mutation: ["POST"],
1803
+ query: ["GET", "POST"],
1804
+ subscription: ["GET", "POST"]
1805
+ };
1806
+ function initResponse(initOpts) {
1807
+ var _responseMeta, _info$calls$find$proc, _info$calls$find;
1808
+ const { ctx, info, responseMeta, untransformedJSON, errors = [], headers } = initOpts;
1809
+ let status = untransformedJSON ? require_getErrorShape.getHTTPStatusCode(untransformedJSON) : 200;
1810
+ const eagerGeneration = !untransformedJSON;
1811
+ const data = eagerGeneration ? [] : Array.isArray(untransformedJSON) ? untransformedJSON : [untransformedJSON];
1812
+ const meta = (_responseMeta = responseMeta === null || responseMeta === void 0 ? void 0 : responseMeta({
1813
+ ctx,
1814
+ info,
1815
+ paths: info === null || info === void 0 ? void 0 : info.calls.map((call) => call.path),
1816
+ data,
1817
+ errors,
1818
+ eagerGeneration,
1819
+ type: (_info$calls$find$proc = info === null || info === void 0 || (_info$calls$find = info.calls.find((call) => {
1820
+ var _call$procedure;
1821
+ return (_call$procedure = call.procedure) === null || _call$procedure === void 0 ? void 0 : _call$procedure._def.type;
1822
+ })) === null || _info$calls$find === void 0 || (_info$calls$find = _info$calls$find.procedure) === null || _info$calls$find === void 0 ? void 0 : _info$calls$find._def.type) !== null && _info$calls$find$proc !== void 0 ? _info$calls$find$proc : "unknown"
1823
+ })) !== null && _responseMeta !== void 0 ? _responseMeta : {};
1824
+ if (meta.headers) {
1825
+ if (meta.headers instanceof Headers) for (const [key, value] of meta.headers.entries()) headers.append(key, value);
1826
+ else
1827
+ /**
1828
+ * @deprecated, delete in v12
1829
+ */
1830
+ for (const [key, value] of Object.entries(meta.headers)) if (Array.isArray(value)) for (const v of value) headers.append(key, v);
1831
+ else if (typeof value === "string") headers.set(key, value);
1832
+ }
1833
+ if (meta.status) status = meta.status;
1834
+ return { status };
1835
+ }
1836
+ function caughtErrorToData(cause, errorOpts) {
1837
+ const { router, req, onError } = errorOpts.opts;
1838
+ const error = require_tracked.getTRPCErrorFromUnknown(cause);
1839
+ onError === null || onError === void 0 || onError({
1840
+ error,
1841
+ path: errorOpts.path,
1842
+ input: errorOpts.input,
1843
+ ctx: errorOpts.ctx,
1844
+ type: errorOpts.type,
1845
+ req
1846
+ });
1847
+ const untransformedJSON = { error: require_getErrorShape.getErrorShape({
1848
+ config: router._def._config,
1849
+ error,
1850
+ type: errorOpts.type,
1851
+ path: errorOpts.path,
1852
+ input: errorOpts.input,
1853
+ ctx: errorOpts.ctx
1854
+ }) };
1855
+ const transformedJSON = require_tracked.transformTRPCResponse(router._def._config, untransformedJSON);
1856
+ const body = JSON.stringify(transformedJSON);
1857
+ return {
1858
+ error,
1859
+ untransformedJSON,
1860
+ body
1861
+ };
1862
+ }
1863
+ /**
1864
+ * Check if a value is a stream-like object
1865
+ * - if it's an async iterable
1866
+ * - if it's an object with async iterables or promises
1867
+ */
1868
+ function isDataStream(v) {
1869
+ if (!require_codes.isObject(v)) return false;
1870
+ if (require_codes.isAsyncIterable(v)) return true;
1871
+ return Object.values(v).some(isPromise) || Object.values(v).some(require_codes.isAsyncIterable);
1872
+ }
1873
+ async function resolveResponse(opts) {
1874
+ var _ref, _opts$allowBatching, _opts$batching, _opts$allowMethodOver, _config$sse$enabled, _config$sse;
1875
+ const { router, req } = opts;
1876
+ const headers = new Headers([["vary", "trpc-accept, accept"]]);
1877
+ const config = router._def._config;
1878
+ const url = new URL(req.url);
1879
+ if (req.method === "HEAD") return new Response(null, { status: 204 });
1880
+ const allowBatching = (_ref = (_opts$allowBatching = opts.allowBatching) !== null && _opts$allowBatching !== void 0 ? _opts$allowBatching : (_opts$batching = opts.batching) === null || _opts$batching === void 0 ? void 0 : _opts$batching.enabled) !== null && _ref !== void 0 ? _ref : true;
1881
+ const allowMethodOverride = ((_opts$allowMethodOver = opts.allowMethodOverride) !== null && _opts$allowMethodOver !== void 0 ? _opts$allowMethodOver : false) && req.method === "POST";
1882
+ const infoTuple = await require_codes.run(async () => {
1883
+ try {
1884
+ return [void 0, await getRequestInfo({
1885
+ req,
1886
+ path: decodeURIComponent(opts.path),
1887
+ router,
1888
+ searchParams: url.searchParams,
1889
+ headers: opts.req.headers,
1890
+ url,
1891
+ maxBatchSize: opts.maxBatchSize
1892
+ })];
1893
+ } catch (cause) {
1894
+ return [require_tracked.getTRPCErrorFromUnknown(cause), void 0];
1895
+ }
1896
+ });
1897
+ const ctxManager = require_codes.run(() => {
1898
+ let result = void 0;
1899
+ return {
1900
+ valueOrUndefined: () => {
1901
+ if (!result) return void 0;
1902
+ return result[1];
1903
+ },
1904
+ value: () => {
1905
+ const [err, ctx] = result;
1906
+ if (err) throw err;
1907
+ return ctx;
1908
+ },
1909
+ create: async (info) => {
1910
+ if (result) throw new Error("This should only be called once - report a bug in tRPC");
1911
+ try {
1912
+ const ctx = await opts.createContext({ info });
1913
+ result = [void 0, ctx];
1914
+ } catch (cause) {
1915
+ result = [require_tracked.getTRPCErrorFromUnknown(cause), void 0];
1916
+ }
1917
+ }
1918
+ };
1919
+ });
1920
+ const methodMapper = allowMethodOverride ? TYPE_ACCEPTED_METHOD_MAP_WITH_METHOD_OVERRIDE : TYPE_ACCEPTED_METHOD_MAP;
1921
+ /**
1922
+ * @deprecated
1923
+ */
1924
+ const isStreamCall = getAcceptHeader(req.headers) === "application/jsonl";
1925
+ const experimentalSSE = (_config$sse$enabled = (_config$sse = config.sse) === null || _config$sse === void 0 ? void 0 : _config$sse.enabled) !== null && _config$sse$enabled !== void 0 ? _config$sse$enabled : true;
1926
+ try {
1927
+ const [infoError, info] = infoTuple;
1928
+ if (infoError) throw infoError;
1929
+ if (info.isBatchCall && !allowBatching) throw new require_tracked.TRPCError({
1930
+ code: "BAD_REQUEST",
1931
+ message: `Batching is not enabled on the server`
1932
+ });
1933
+ /* istanbul ignore if -- @preserve */
1934
+ if (isStreamCall && !info.isBatchCall) throw new require_tracked.TRPCError({
1935
+ message: `Streaming requests must be batched (you can do a batch of 1)`,
1936
+ code: "BAD_REQUEST"
1937
+ });
1938
+ await ctxManager.create(info);
1939
+ const rpcCalls = info.calls.map(async (call) => {
1940
+ const proc = call.procedure;
1941
+ const combinedAbort = combinedAbortController(opts.req.signal);
1942
+ try {
1943
+ if (opts.error) throw opts.error;
1944
+ if (!proc) throw new require_tracked.TRPCError({
1945
+ code: "NOT_FOUND",
1946
+ message: `No procedure found on path "${call.path}"`
1947
+ });
1948
+ if (!methodMapper[proc._def.type].includes(req.method)) throw new require_tracked.TRPCError({
1949
+ code: "METHOD_NOT_SUPPORTED",
1950
+ message: `Unsupported ${req.method}-request to ${proc._def.type} procedure at path "${call.path}"`
1951
+ });
1952
+ if (proc._def.type === "subscription") {
1953
+ var _config$sse2;
1954
+ /* istanbul ignore if -- @preserve */
1955
+ if (info.isBatchCall) throw new require_tracked.TRPCError({
1956
+ code: "BAD_REQUEST",
1957
+ message: `Cannot batch subscription calls`
1958
+ });
1959
+ if ((_config$sse2 = config.sse) === null || _config$sse2 === void 0 ? void 0 : _config$sse2.maxDurationMs) {
1960
+ function cleanup() {
1961
+ clearTimeout(timer);
1962
+ combinedAbort.signal.removeEventListener("abort", cleanup);
1963
+ combinedAbort.controller.abort();
1964
+ }
1965
+ const timer = setTimeout(cleanup, config.sse.maxDurationMs);
1966
+ combinedAbort.signal.addEventListener("abort", cleanup);
1967
+ }
1968
+ }
1969
+ const data = await proc({
1970
+ path: call.path,
1971
+ getRawInput: call.getRawInput,
1972
+ ctx: ctxManager.value(),
1973
+ type: proc._def.type,
1974
+ signal: combinedAbort.signal,
1975
+ batchIndex: call.batchIndex
1976
+ });
1977
+ return [void 0, {
1978
+ data,
1979
+ signal: proc._def.type === "subscription" ? combinedAbort.signal : void 0
1980
+ }];
1981
+ } catch (cause) {
1982
+ var _opts$onError, _call$procedure$_def$, _call$procedure2;
1983
+ const error = require_tracked.getTRPCErrorFromUnknown(cause);
1984
+ const input = call.result();
1985
+ (_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, {
1986
+ error,
1987
+ path: call.path,
1988
+ input,
1989
+ ctx: ctxManager.valueOrUndefined(),
1990
+ type: (_call$procedure$_def$ = (_call$procedure2 = call.procedure) === null || _call$procedure2 === void 0 ? void 0 : _call$procedure2._def.type) !== null && _call$procedure$_def$ !== void 0 ? _call$procedure$_def$ : "unknown",
1991
+ req: opts.req
1992
+ });
1993
+ return [error, void 0];
1994
+ }
1995
+ });
1996
+ if (!info.isBatchCall) {
1997
+ const [call] = info.calls;
1998
+ const [error, result] = await rpcCalls[0];
1999
+ switch (info.type) {
2000
+ case "unknown":
2001
+ case "mutation":
2002
+ case "query": {
2003
+ headers.set("content-type", "application/json");
2004
+ if (isDataStream(result === null || result === void 0 ? void 0 : result.data)) throw new require_tracked.TRPCError({
2005
+ code: "UNSUPPORTED_MEDIA_TYPE",
2006
+ message: "Cannot use stream-like response in non-streaming request - use httpBatchStreamLink"
2007
+ });
2008
+ const res = error ? { error: require_getErrorShape.getErrorShape({
2009
+ config,
2010
+ ctx: ctxManager.valueOrUndefined(),
2011
+ error,
2012
+ input: call.result(),
2013
+ path: call.path,
2014
+ type: info.type
2015
+ }) } : { result: { data: result.data } };
2016
+ const headResponse$1 = initResponse({
2017
+ ctx: ctxManager.valueOrUndefined(),
2018
+ info,
2019
+ responseMeta: opts.responseMeta,
2020
+ errors: error ? [error] : [],
2021
+ headers,
2022
+ untransformedJSON: [res]
2023
+ });
2024
+ return new Response(JSON.stringify(require_tracked.transformTRPCResponse(config, res)), {
2025
+ status: headResponse$1.status,
2026
+ headers
2027
+ });
2028
+ }
2029
+ case "subscription": {
2030
+ const iterable = require_codes.run(() => {
2031
+ if (error) return errorToAsyncIterable(error);
2032
+ if (!experimentalSSE) return errorToAsyncIterable(new require_tracked.TRPCError({
2033
+ code: "METHOD_NOT_SUPPORTED",
2034
+ message: "Missing experimental flag \"sseSubscriptions\""
2035
+ }));
2036
+ if (!require_observable.isObservable(result.data) && !require_codes.isAsyncIterable(result.data)) return errorToAsyncIterable(new require_tracked.TRPCError({
2037
+ message: `Subscription ${call.path} did not return an observable or a AsyncGenerator`,
2038
+ code: "INTERNAL_SERVER_ERROR"
2039
+ }));
2040
+ const dataAsIterable = require_observable.isObservable(result.data) ? require_observable.observableToAsyncIterable(result.data, opts.req.signal) : result.data;
2041
+ return dataAsIterable;
2042
+ });
2043
+ const stream = sseStreamProducer((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, config.sse), {}, {
2044
+ data: iterable,
2045
+ serialize: (v) => config.transformer.output.serialize(v),
2046
+ formatError(errorOpts) {
2047
+ var _call$procedure$_def$2, _call$procedure3, _opts$onError2;
2048
+ const error$1 = require_tracked.getTRPCErrorFromUnknown(errorOpts.error);
2049
+ const input = call === null || call === void 0 ? void 0 : call.result();
2050
+ const path = call === null || call === void 0 ? void 0 : call.path;
2051
+ const type = (_call$procedure$_def$2 = call === null || call === void 0 || (_call$procedure3 = call.procedure) === null || _call$procedure3 === void 0 ? void 0 : _call$procedure3._def.type) !== null && _call$procedure$_def$2 !== void 0 ? _call$procedure$_def$2 : "unknown";
2052
+ (_opts$onError2 = opts.onError) === null || _opts$onError2 === void 0 || _opts$onError2.call(opts, {
2053
+ error: error$1,
2054
+ path,
2055
+ input,
2056
+ ctx: ctxManager.valueOrUndefined(),
2057
+ req: opts.req,
2058
+ type
2059
+ });
2060
+ const shape = require_getErrorShape.getErrorShape({
2061
+ config,
2062
+ ctx: ctxManager.valueOrUndefined(),
2063
+ error: error$1,
2064
+ input,
2065
+ path,
2066
+ type
2067
+ });
2068
+ return shape;
2069
+ }
2070
+ }));
2071
+ for (const [key, value] of Object.entries(sseHeaders)) headers.set(key, value);
2072
+ const headResponse$1 = initResponse({
2073
+ ctx: ctxManager.valueOrUndefined(),
2074
+ info,
2075
+ responseMeta: opts.responseMeta,
2076
+ errors: [],
2077
+ headers,
2078
+ untransformedJSON: null
2079
+ });
2080
+ const abortSignal = result === null || result === void 0 ? void 0 : result.signal;
2081
+ let responseBody = stream;
2082
+ if (abortSignal) {
2083
+ const reader = stream.getReader();
2084
+ const onAbort = () => void reader.cancel();
2085
+ if (abortSignal.aborted) onAbort();
2086
+ else abortSignal.addEventListener("abort", onAbort, { once: true });
2087
+ responseBody = new ReadableStream({
2088
+ async pull(controller) {
2089
+ const chunk = await reader.read();
2090
+ if (chunk.done) {
2091
+ abortSignal.removeEventListener("abort", onAbort);
2092
+ controller.close();
2093
+ } else controller.enqueue(chunk.value);
2094
+ },
2095
+ cancel() {
2096
+ abortSignal.removeEventListener("abort", onAbort);
2097
+ return reader.cancel();
2098
+ }
2099
+ });
2100
+ }
2101
+ return new Response(responseBody, {
2102
+ headers,
2103
+ status: headResponse$1.status
2104
+ });
2105
+ }
2106
+ }
2107
+ }
2108
+ if (info.accept === "application/jsonl") {
2109
+ headers.set("content-type", "application/json");
2110
+ headers.set("transfer-encoding", "chunked");
2111
+ const headResponse$1 = initResponse({
2112
+ ctx: ctxManager.valueOrUndefined(),
2113
+ info,
2114
+ responseMeta: opts.responseMeta,
2115
+ errors: [],
2116
+ headers,
2117
+ untransformedJSON: null
2118
+ });
2119
+ const stream = jsonlStreamProducer((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, config.jsonl), {}, {
2120
+ maxDepth: Infinity,
2121
+ data: rpcCalls.map(async (res, index) => {
2122
+ const [error, result] = await res;
2123
+ const call = info.calls[index];
2124
+ if (error) {
2125
+ var _procedure$_def$type, _procedure;
2126
+ return { error: require_getErrorShape.getErrorShape({
2127
+ config,
2128
+ ctx: ctxManager.valueOrUndefined(),
2129
+ error,
2130
+ input: call.result(),
2131
+ path: call.path,
2132
+ type: (_procedure$_def$type = (_procedure = call.procedure) === null || _procedure === void 0 ? void 0 : _procedure._def.type) !== null && _procedure$_def$type !== void 0 ? _procedure$_def$type : "unknown"
2133
+ }) };
2134
+ }
2135
+ /**
2136
+ * Not very pretty, but we need to wrap nested data in promises
2137
+ * Our stream producer will only resolve top-level async values or async values that are directly nested in another async value
2138
+ */
2139
+ const iterable = require_observable.isObservable(result.data) ? require_observable.observableToAsyncIterable(result.data, opts.req.signal) : Promise.resolve(result.data);
2140
+ return { result: Promise.resolve({ data: iterable }) };
2141
+ }),
2142
+ serialize: (data) => config.transformer.output.serialize(data),
2143
+ onError: (cause) => {
2144
+ var _opts$onError3, _info$type;
2145
+ (_opts$onError3 = opts.onError) === null || _opts$onError3 === void 0 || _opts$onError3.call(opts, {
2146
+ error: require_tracked.getTRPCErrorFromUnknown(cause),
2147
+ path: void 0,
2148
+ input: void 0,
2149
+ ctx: ctxManager.valueOrUndefined(),
2150
+ req: opts.req,
2151
+ type: (_info$type = info === null || info === void 0 ? void 0 : info.type) !== null && _info$type !== void 0 ? _info$type : "unknown"
2152
+ });
2153
+ },
2154
+ formatError(errorOpts) {
2155
+ var _call$procedure$_def$3, _call$procedure4;
2156
+ const call = info === null || info === void 0 ? void 0 : info.calls[errorOpts.path[0]];
2157
+ const error = require_tracked.getTRPCErrorFromUnknown(errorOpts.error);
2158
+ const input = call === null || call === void 0 ? void 0 : call.result();
2159
+ const path = call === null || call === void 0 ? void 0 : call.path;
2160
+ const type = (_call$procedure$_def$3 = call === null || call === void 0 || (_call$procedure4 = call.procedure) === null || _call$procedure4 === void 0 ? void 0 : _call$procedure4._def.type) !== null && _call$procedure$_def$3 !== void 0 ? _call$procedure$_def$3 : "unknown";
2161
+ const shape = require_getErrorShape.getErrorShape({
2162
+ config,
2163
+ ctx: ctxManager.valueOrUndefined(),
2164
+ error,
2165
+ input,
2166
+ path,
2167
+ type
2168
+ });
2169
+ return shape;
2170
+ }
2171
+ }));
2172
+ return new Response(stream, {
2173
+ headers,
2174
+ status: headResponse$1.status
2175
+ });
2176
+ }
2177
+ /**
2178
+ * Non-streaming response:
2179
+ * - await all responses in parallel, blocking on the slowest one
2180
+ * - create headers with known response body
2181
+ * - return a complete HTTPResponse
2182
+ */
2183
+ headers.set("content-type", "application/json");
2184
+ const results = (await Promise.all(rpcCalls)).map((res) => {
2185
+ const [error, result] = res;
2186
+ if (error) return res;
2187
+ if (isDataStream(result.data)) return [new require_tracked.TRPCError({
2188
+ code: "UNSUPPORTED_MEDIA_TYPE",
2189
+ message: "Cannot use stream-like response in non-streaming request - use httpBatchStreamLink"
2190
+ }), void 0];
2191
+ return res;
2192
+ });
2193
+ const resultAsRPCResponse = results.map(([error, result], index) => {
2194
+ const call = info.calls[index];
2195
+ if (error) {
2196
+ var _call$procedure$_def$4, _call$procedure5;
2197
+ return { error: require_getErrorShape.getErrorShape({
2198
+ config,
2199
+ ctx: ctxManager.valueOrUndefined(),
2200
+ error,
2201
+ input: call.result(),
2202
+ path: call.path,
2203
+ type: (_call$procedure$_def$4 = (_call$procedure5 = call.procedure) === null || _call$procedure5 === void 0 ? void 0 : _call$procedure5._def.type) !== null && _call$procedure$_def$4 !== void 0 ? _call$procedure$_def$4 : "unknown"
2204
+ }) };
2205
+ }
2206
+ return { result: { data: result.data } };
2207
+ });
2208
+ const errors = results.map(([error]) => error).filter(Boolean);
2209
+ const headResponse = initResponse({
2210
+ ctx: ctxManager.valueOrUndefined(),
2211
+ info,
2212
+ responseMeta: opts.responseMeta,
2213
+ untransformedJSON: resultAsRPCResponse,
2214
+ errors,
2215
+ headers
2216
+ });
2217
+ return new Response(JSON.stringify(require_tracked.transformTRPCResponse(config, resultAsRPCResponse)), {
2218
+ status: headResponse.status,
2219
+ headers
2220
+ });
2221
+ } catch (cause) {
2222
+ var _info$type2;
2223
+ const [_infoError, info] = infoTuple;
2224
+ const ctx = ctxManager.valueOrUndefined();
2225
+ const { error, untransformedJSON, body } = caughtErrorToData(cause, {
2226
+ opts,
2227
+ ctx: ctxManager.valueOrUndefined(),
2228
+ type: (_info$type2 = info === null || info === void 0 ? void 0 : info.type) !== null && _info$type2 !== void 0 ? _info$type2 : "unknown"
2229
+ });
2230
+ const headResponse = initResponse({
2231
+ ctx,
2232
+ info,
2233
+ responseMeta: opts.responseMeta,
2234
+ untransformedJSON,
2235
+ errors: [error],
2236
+ headers
2237
+ });
2238
+ return new Response(body, {
2239
+ status: headResponse.status,
2240
+ headers
2241
+ });
2242
+ }
2243
+ }
2244
+
2245
+ //#endregion
2246
+ Object.defineProperty(exports, 'Unpromise', {
2247
+ enumerable: true,
2248
+ get: function () {
2249
+ return Unpromise;
2250
+ }
2251
+ });
2252
+ Object.defineProperty(exports, 'createDeferred', {
2253
+ enumerable: true,
2254
+ get: function () {
2255
+ return createDeferred;
2256
+ }
2257
+ });
2258
+ Object.defineProperty(exports, 'getAcceptHeader', {
2259
+ enumerable: true,
2260
+ get: function () {
2261
+ return getAcceptHeader;
2262
+ }
2263
+ });
2264
+ Object.defineProperty(exports, 'getRequestInfo', {
2265
+ enumerable: true,
2266
+ get: function () {
2267
+ return getRequestInfo;
2268
+ }
2269
+ });
2270
+ Object.defineProperty(exports, 'isAbortError', {
2271
+ enumerable: true,
2272
+ get: function () {
2273
+ return isAbortError;
2274
+ }
2275
+ });
2276
+ Object.defineProperty(exports, 'isPromise', {
2277
+ enumerable: true,
2278
+ get: function () {
2279
+ return isPromise;
2280
+ }
2281
+ });
2282
+ Object.defineProperty(exports, 'iteratorResource', {
2283
+ enumerable: true,
2284
+ get: function () {
2285
+ return iteratorResource;
2286
+ }
2287
+ });
2288
+ Object.defineProperty(exports, 'jsonlStreamConsumer', {
2289
+ enumerable: true,
2290
+ get: function () {
2291
+ return jsonlStreamConsumer;
2292
+ }
2293
+ });
2294
+ Object.defineProperty(exports, 'jsonlStreamProducer', {
2295
+ enumerable: true,
2296
+ get: function () {
2297
+ return jsonlStreamProducer;
2298
+ }
2299
+ });
2300
+ Object.defineProperty(exports, 'makeAsyncResource', {
2301
+ enumerable: true,
2302
+ get: function () {
2303
+ return makeAsyncResource;
2304
+ }
2305
+ });
2306
+ Object.defineProperty(exports, 'makeResource', {
2307
+ enumerable: true,
2308
+ get: function () {
2309
+ return makeResource;
2310
+ }
2311
+ });
2312
+ Object.defineProperty(exports, 'parseConnectionParamsFromString', {
2313
+ enumerable: true,
2314
+ get: function () {
2315
+ return parseConnectionParamsFromString;
2316
+ }
2317
+ });
2318
+ Object.defineProperty(exports, 'parseConnectionParamsFromUnknown', {
2319
+ enumerable: true,
2320
+ get: function () {
2321
+ return parseConnectionParamsFromUnknown;
2322
+ }
2323
+ });
2324
+ Object.defineProperty(exports, 'require_usingCtx', {
2325
+ enumerable: true,
2326
+ get: function () {
2327
+ return require_usingCtx;
2328
+ }
2329
+ });
2330
+ Object.defineProperty(exports, 'resolveResponse', {
2331
+ enumerable: true,
2332
+ get: function () {
2333
+ return resolveResponse;
2334
+ }
2335
+ });
2336
+ Object.defineProperty(exports, 'sseHeaders', {
2337
+ enumerable: true,
2338
+ get: function () {
2339
+ return sseHeaders;
2340
+ }
2341
+ });
2342
+ Object.defineProperty(exports, 'sseStreamConsumer', {
2343
+ enumerable: true,
2344
+ get: function () {
2345
+ return sseStreamConsumer;
2346
+ }
2347
+ });
2348
+ Object.defineProperty(exports, 'sseStreamProducer', {
2349
+ enumerable: true,
2350
+ get: function () {
2351
+ return sseStreamProducer;
2352
+ }
2353
+ });
2354
+ Object.defineProperty(exports, 'takeWithGrace', {
2355
+ enumerable: true,
2356
+ get: function () {
2357
+ return takeWithGrace;
2358
+ }
2359
+ });
2360
+ Object.defineProperty(exports, 'throwAbortError', {
2361
+ enumerable: true,
2362
+ get: function () {
2363
+ return throwAbortError;
2364
+ }
2365
+ });