uomtiles 0.1.2 → 0.1.3

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 (303) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/_nuxt/7KYNy7kZ.js +1 -0
  3. package/.output/public/_nuxt/7Rgc2iDI2.js +1 -0
  4. package/.output/public/_nuxt/BA52uD81.js +1 -0
  5. package/.output/public/_nuxt/{CU486JdV2.js → BHSn2vP72.js} +2 -2
  6. package/.output/public/_nuxt/BRsHq3Fz2.js +1 -0
  7. package/.output/public/_nuxt/Bh2Uv1S7.js +1 -0
  8. package/.output/public/_nuxt/BiRI-vq-.js +1 -0
  9. package/.output/public/_nuxt/Bpc1HTfh.js +1 -0
  10. package/.output/public/_nuxt/C-b4mqsD.js +1 -0
  11. package/.output/public/_nuxt/C5Y76DD6.js +1 -0
  12. package/.output/public/_nuxt/CD84FXNW.js +1 -0
  13. package/.output/public/_nuxt/CGkIG2vL2.js +1 -0
  14. package/.output/public/_nuxt/CM9IbYJz.js +1 -0
  15. package/.output/public/_nuxt/CUJ4QmLF.js +1 -0
  16. package/.output/public/_nuxt/CUQ3MZqI.js +1 -0
  17. package/.output/public/_nuxt/CVwoxklV.js +1 -0
  18. package/.output/public/_nuxt/CeHZqNQ0.js +1 -0
  19. package/.output/public/_nuxt/CkfS_Wbu.js +3 -0
  20. package/.output/public/_nuxt/CoPjdBwX.js +1 -0
  21. package/.output/public/_nuxt/CxkDmpVY.js +1 -0
  22. package/.output/public/_nuxt/CzRdWh7s2.js +1 -0
  23. package/.output/public/_nuxt/D-IOtyQX.js +1 -0
  24. package/.output/public/_nuxt/D3Us7gX72.js +1 -0
  25. package/.output/public/_nuxt/{DaQqwE3R.js → D8GHPYwQ.js} +44 -44
  26. package/.output/public/_nuxt/DLIy3f3M.js +1 -0
  27. package/.output/public/_nuxt/{CovBj6WN.js → DQ8r1OSk.js} +1 -1
  28. package/.output/public/_nuxt/D_9SjQFe.js +1 -0
  29. package/.output/public/_nuxt/D_Ggu6R_2.js +1 -0
  30. package/.output/public/_nuxt/{Q79ec-Ro.js → DnVJUY7B.js} +1 -1
  31. package/.output/public/_nuxt/{Bd1EvHmY.js → DuGgjt-h2.js} +1 -1
  32. package/.output/public/_nuxt/GEOST6As.js +1 -0
  33. package/.output/public/_nuxt/{DpIPeY5m.js → GqgcWtrL.js} +1 -1
  34. package/.output/public/_nuxt/{0hm88Oke.js → Hbp_Okvs.js} +1 -1
  35. package/.output/public/_nuxt/JdUwgqKv.js +1 -0
  36. package/.output/public/_nuxt/KttxEAyP2.js +1 -0
  37. package/.output/public/_nuxt/L0GXeO1Y2.js +1 -0
  38. package/.output/public/_nuxt/builds/latest.json +1 -1
  39. package/.output/public/_nuxt/builds/meta/ad8f3148-5aa4-4a0f-8e7a-e55147c5de1a.json +1 -0
  40. package/.output/public/_nuxt/entry.U-KS0GEu.css +1 -0
  41. package/.output/public/_nuxt/sMWyPZfC2.js +1 -0
  42. package/.output/public/_nuxt/zUWhKXtw2.js +1 -0
  43. package/.output/server/chunks/_/antigravity-nfz.mjs +629 -0
  44. package/.output/server/chunks/_/antigravity-nfz.mjs.map +1 -0
  45. package/.output/server/chunks/_/config.mjs +1 -1
  46. package/.output/server/chunks/_/file-workspace.mjs +1 -1
  47. package/.output/server/chunks/_/map-layer-update-manager.mjs +770 -0
  48. package/.output/server/chunks/_/map-layer-update-manager.mjs.map +1 -0
  49. package/.output/server/chunks/_/map-service.mjs +1 -1
  50. package/.output/server/chunks/_/uom-auth.mjs +1 -1
  51. package/.output/server/chunks/build/{CompletedTaskSelect-CKTpyHS3.mjs → CompletedTaskSelect-Ba03kTs9.mjs} +6 -7
  52. package/.output/server/chunks/build/{CompletedTaskSelect-CKTpyHS3.mjs.map → CompletedTaskSelect-Ba03kTs9.mjs.map} +1 -1
  53. package/.output/server/chunks/build/{Empty-BGIn09cL.mjs → Empty-CKvANuoV.mjs} +4 -103
  54. package/.output/server/chunks/build/Empty-CKvANuoV.mjs.map +1 -0
  55. package/.output/server/chunks/build/{FormField-DnJWfrKE.mjs → FormField-BJHVyy1m.mjs} +4 -35
  56. package/.output/server/chunks/build/FormField-BJHVyy1m.mjs.map +1 -0
  57. package/.output/server/chunks/build/{Input-AdlINKtJ.mjs → Input-DnAric-z.mjs} +1 -1
  58. package/.output/server/chunks/build/{Input-AdlINKtJ.mjs.map → Input-DnAric-z.mjs.map} +1 -1
  59. package/.output/server/chunks/build/MapLayerControl-DpNmYvcU.mjs +5720 -0
  60. package/.output/server/chunks/build/MapLayerControl-DpNmYvcU.mjs.map +1 -0
  61. package/.output/server/chunks/build/{Modal-CozaqIp1.mjs → Modal-BLhN9Eg2.mjs} +4 -18
  62. package/.output/server/chunks/build/{Modal-CozaqIp1.mjs.map → Modal-BLhN9Eg2.mjs.map} +1 -1
  63. package/.output/server/chunks/build/{OnlineMap-cFSicmkV.mjs → OnlineMap-B-sCfHkC.mjs} +6 -3
  64. package/.output/server/chunks/build/OnlineMap-B-sCfHkC.mjs.map +1 -0
  65. package/.output/server/chunks/build/{Pagination-GvNCxmOW.mjs → Pagination-CUzoLc_-.mjs} +1 -1
  66. package/.output/server/chunks/build/{Pagination-GvNCxmOW.mjs.map → Pagination-CUzoLc_-.mjs.map} +1 -1
  67. package/.output/server/chunks/build/Skeleton-CHp-GjOx.mjs +59 -0
  68. package/.output/server/chunks/build/Skeleton-CHp-GjOx.mjs.map +1 -0
  69. package/.output/server/chunks/build/{Slider-zQx1c7hB.mjs → Slider-CrIUK3pl.mjs} +5 -5
  70. package/.output/server/chunks/build/{Slider-zQx1c7hB.mjs.map → Slider-CrIUK3pl.mjs.map} +1 -1
  71. package/.output/server/chunks/build/{MapBaseLayerTabs-CRl5Zwlr.mjs → Tabs-cdLsZZoL.mjs} +429 -931
  72. package/.output/server/chunks/build/Tabs-cdLsZZoL.mjs.map +1 -0
  73. package/.output/server/chunks/build/{Tooltip-DNUdH4oF.mjs → Tooltip-DExIlyhu.mjs} +4 -195
  74. package/.output/server/chunks/build/Tooltip-DExIlyhu.mjs.map +1 -0
  75. package/.output/server/chunks/build/{advanced-5ZGMUBqC.mjs → advanced-DaSpS8Px.mjs} +31 -34
  76. package/.output/server/chunks/build/advanced-DaSpS8Px.mjs.map +1 -0
  77. package/.output/server/chunks/build/{compare-CtgF4Anj.mjs → compare-DaE10Dhp.mjs} +56 -37
  78. package/.output/server/chunks/build/compare-DaE10Dhp.mjs.map +1 -0
  79. package/.output/server/chunks/build/cookie-CziAmOf1.mjs +175 -0
  80. package/.output/server/chunks/build/cookie-CziAmOf1.mjs.map +1 -0
  81. package/.output/server/chunks/build/{dashboard-GneN-WPG.mjs → dashboard-Dq8mphss.mjs} +12 -6
  82. package/.output/server/chunks/build/{dashboard-GneN-WPG.mjs.map → dashboard-Dq8mphss.mjs.map} +1 -1
  83. package/.output/server/chunks/build/{details-CgufnL1d.mjs → details-DCNvSBgn.mjs} +5 -4
  84. package/.output/server/chunks/build/{details-CgufnL1d.mjs.map → details-DCNvSBgn.mjs.map} +1 -1
  85. package/.output/server/chunks/build/error-404-D9aQjJRn.mjs +1 -1
  86. package/.output/server/chunks/build/error-500-BNyA3wrb.mjs +1 -1
  87. package/.output/server/chunks/build/file-workspace-DMzPuPyG.mjs +104 -0
  88. package/.output/server/chunks/build/file-workspace-DMzPuPyG.mjs.map +1 -0
  89. package/.output/server/chunks/build/{interval-9B2MrM2e.mjs → interval-i5OZnTaK.mjs} +2 -2
  90. package/.output/server/chunks/build/{interval-9B2MrM2e.mjs.map → interval-i5OZnTaK.mjs.map} +1 -1
  91. package/.output/server/chunks/build/layers-50nqoWES.mjs +553 -0
  92. package/.output/server/chunks/build/layers-50nqoWES.mjs.map +1 -0
  93. package/.output/server/chunks/build/{login-Cf5EiCE4.mjs → login-BHSHtO-R.mjs} +6 -5
  94. package/.output/server/chunks/build/{login-Cf5EiCE4.mjs.map → login-BHSHtO-R.mjs.map} +1 -1
  95. package/.output/server/chunks/build/map-layers-C3HJoCLw.mjs +86 -0
  96. package/.output/server/chunks/build/map-layers-C3HJoCLw.mjs.map +1 -0
  97. package/.output/server/chunks/build/{DashboardSidebarToggle-CUI9NSow.mjs → overlay-BS4_B29H.mjs} +411 -4
  98. package/.output/server/chunks/build/overlay-BS4_B29H.mjs.map +1 -0
  99. package/.output/server/chunks/build/pages-5yYRS5nX.mjs +37 -0
  100. package/.output/server/chunks/build/pages-5yYRS5nX.mjs.map +1 -0
  101. package/.output/server/chunks/build/{pages-0c5sp_lv.mjs → pages-DfOPr0fC.mjs} +21 -21
  102. package/.output/server/chunks/build/pages-DfOPr0fC.mjs.map +1 -0
  103. package/.output/server/chunks/build/{services-BB49kSpd.mjs → services-DWlDpsbi.mjs} +45 -41
  104. package/.output/server/chunks/build/{services-BB49kSpd.mjs.map → services-DWlDpsbi.mjs.map} +1 -1
  105. package/.output/server/chunks/build/{tasks-BRcMLuRW.mjs → tasks-4b6D39Uy.mjs} +44 -100
  106. package/.output/server/chunks/build/{tasks-BRcMLuRW.mjs.map → tasks-4b6D39Uy.mjs.map} +1 -1
  107. package/.output/server/chunks/build/{tasks-Aa8PwjVL.mjs → tasks-BPPx2UMG.mjs} +10 -6
  108. package/.output/server/chunks/build/tasks-BPPx2UMG.mjs.map +1 -0
  109. package/.output/server/chunks/nitro/nitro.mjs +303 -244
  110. package/.output/server/chunks/routes/api/map/layers/_overlayLayer/update.get.mjs +29 -0
  111. package/.output/server/chunks/routes/api/map/layers/_overlayLayer/update.get.mjs.map +1 -0
  112. package/.output/server/chunks/routes/api/map/layers/_overlayLayer/update.post.mjs +31 -0
  113. package/.output/server/chunks/routes/api/map/layers/_overlayLayer/update.post.mjs.map +1 -0
  114. package/.output/server/chunks/routes/api/map/layers/_overlayLayer_.get.mjs +39 -0
  115. package/.output/server/chunks/routes/api/map/layers/_overlayLayer_.get.mjs.map +1 -0
  116. package/.output/server/chunks/routes/api/map/layers/status.get.mjs +60 -0
  117. package/.output/server/chunks/routes/api/map/layers/status.get.mjs.map +1 -0
  118. package/.output/server/chunks/routes/api/map/live/status.get.mjs +1 -1
  119. package/.output/server/chunks/routes/api/map/online/_layerGroup/_zoom/_tileX/_tileY_.get.mjs +1 -1
  120. package/.output/server/chunks/routes/api/map/online-root/_layerGroup/_rootX/_rootY_.get.mjs +1 -1
  121. package/.output/server/chunks/routes/api/workspace/_filename/analysis.get.mjs +1 -1
  122. package/.output/server/chunks/routes/api/workspace/_filename/download.get.mjs +1 -1
  123. package/.output/server/chunks/routes/api/workspace/_filename/export/_format_.get.mjs +1 -1
  124. package/.output/server/chunks/routes/api/workspace/_filename/export-estimate.get.mjs +1 -1
  125. package/.output/server/chunks/routes/api/workspace/_filename/tile.get.mjs +1 -1
  126. package/.output/server/chunks/routes/api/workspace/_filename/tiles.get.mjs +1 -1
  127. package/.output/server/chunks/routes/api/workspace/_filename_.delete.mjs +1 -1
  128. package/.output/server/chunks/routes/api/workspace/compare/batch.get.mjs +1 -1
  129. package/.output/server/chunks/routes/api/workspace/files.post.mjs +1 -1
  130. package/.output/server/chunks/routes/api/workspace/stop.post.mjs +1 -1
  131. package/.output/server/chunks/routes/api/workspace/tasks.post.mjs +2 -2
  132. package/.output/server/chunks/routes/renderer.mjs +3 -3
  133. package/.output/server/chunks/routes/services/wms.get.mjs +1 -1
  134. package/.output/server/chunks/routes/services/wmts.get.mjs +1 -1
  135. package/.output/server/chunks/virtual/entry.mjs +320 -443
  136. package/.output/server/chunks/virtual/entry.mjs.map +1 -1
  137. package/.output/server/chunks/virtual/precomputed.mjs +1 -1
  138. package/.output/server/chunks/virtual/styles.mjs +1 -1
  139. package/.output/server/node_modules/undici/index.js +234 -0
  140. package/.output/server/node_modules/undici/lib/api/abort-signal.js +59 -0
  141. package/.output/server/node_modules/undici/lib/api/api-connect.js +110 -0
  142. package/.output/server/node_modules/undici/lib/api/api-pipeline.js +252 -0
  143. package/.output/server/node_modules/undici/lib/api/api-request.js +214 -0
  144. package/.output/server/node_modules/undici/lib/api/api-stream.js +209 -0
  145. package/.output/server/node_modules/undici/lib/api/api-upgrade.js +111 -0
  146. package/.output/server/node_modules/undici/lib/api/index.js +7 -0
  147. package/.output/server/node_modules/undici/lib/api/readable.js +580 -0
  148. package/.output/server/node_modules/undici/lib/cache/memory-cache-store.js +279 -0
  149. package/.output/server/node_modules/undici/lib/cache/sqlite-cache-store.js +467 -0
  150. package/.output/server/node_modules/undici/lib/core/connect.js +153 -0
  151. package/.output/server/node_modules/undici/lib/core/constants.js +143 -0
  152. package/.output/server/node_modules/undici/lib/core/diagnostics.js +227 -0
  153. package/.output/server/node_modules/undici/lib/core/errors.js +477 -0
  154. package/.output/server/node_modules/undici/lib/core/request.js +464 -0
  155. package/.output/server/node_modules/undici/lib/core/socks5-client.js +422 -0
  156. package/.output/server/node_modules/undici/lib/core/socks5-utils.js +212 -0
  157. package/.output/server/node_modules/undici/lib/core/symbols.js +75 -0
  158. package/.output/server/node_modules/undici/lib/core/tree.js +160 -0
  159. package/.output/server/node_modules/undici/lib/core/util.js +992 -0
  160. package/.output/server/node_modules/undici/lib/dispatcher/agent.js +158 -0
  161. package/.output/server/node_modules/undici/lib/dispatcher/balanced-pool.js +219 -0
  162. package/.output/server/node_modules/undici/lib/dispatcher/client-h1.js +1731 -0
  163. package/.output/server/node_modules/undici/lib/dispatcher/client-h2.js +995 -0
  164. package/.output/server/node_modules/undici/lib/dispatcher/client.js +664 -0
  165. package/.output/server/node_modules/undici/lib/dispatcher/dispatcher-base.js +184 -0
  166. package/.output/server/node_modules/undici/lib/dispatcher/dispatcher.js +48 -0
  167. package/.output/server/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +146 -0
  168. package/.output/server/node_modules/undici/lib/dispatcher/fixed-queue.js +135 -0
  169. package/.output/server/node_modules/undici/lib/dispatcher/h2c-client.js +51 -0
  170. package/.output/server/node_modules/undici/lib/dispatcher/pool-base.js +214 -0
  171. package/.output/server/node_modules/undici/lib/dispatcher/pool.js +118 -0
  172. package/.output/server/node_modules/undici/lib/dispatcher/proxy-agent.js +319 -0
  173. package/.output/server/node_modules/undici/lib/dispatcher/retry-agent.js +35 -0
  174. package/.output/server/node_modules/undici/lib/dispatcher/round-robin-pool.js +137 -0
  175. package/.output/server/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +260 -0
  176. package/.output/server/node_modules/undici/lib/encoding/index.js +33 -0
  177. package/.output/server/node_modules/undici/lib/global.js +59 -0
  178. package/.output/server/node_modules/undici/lib/handler/cache-handler.js +760 -0
  179. package/.output/server/node_modules/undici/lib/handler/cache-revalidation-handler.js +124 -0
  180. package/.output/server/node_modules/undici/lib/handler/decorator-handler.js +67 -0
  181. package/.output/server/node_modules/undici/lib/handler/deduplication-handler.js +460 -0
  182. package/.output/server/node_modules/undici/lib/handler/redirect-handler.js +238 -0
  183. package/.output/server/node_modules/undici/lib/handler/retry-handler.js +418 -0
  184. package/.output/server/node_modules/undici/lib/handler/unwrap-handler.js +106 -0
  185. package/.output/server/node_modules/undici/lib/handler/wrap-handler.js +105 -0
  186. package/.output/server/node_modules/undici/lib/interceptor/cache.js +602 -0
  187. package/.output/server/node_modules/undici/lib/interceptor/decompress.js +259 -0
  188. package/.output/server/node_modules/undici/lib/interceptor/deduplicate.js +117 -0
  189. package/.output/server/node_modules/undici/lib/interceptor/dns.js +571 -0
  190. package/.output/server/node_modules/undici/lib/interceptor/dump.js +112 -0
  191. package/.output/server/node_modules/undici/lib/interceptor/redirect.js +21 -0
  192. package/.output/server/node_modules/undici/lib/interceptor/response-error.js +95 -0
  193. package/.output/server/node_modules/undici/lib/interceptor/retry.js +19 -0
  194. package/.output/server/node_modules/undici/lib/llhttp/constants.js +531 -0
  195. package/.output/server/node_modules/undici/lib/llhttp/llhttp-wasm.js +15 -0
  196. package/.output/server/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +15 -0
  197. package/.output/server/node_modules/undici/lib/llhttp/utils.js +12 -0
  198. package/.output/server/node_modules/undici/lib/mock/mock-agent.js +232 -0
  199. package/.output/server/node_modules/undici/lib/mock/mock-call-history.js +248 -0
  200. package/.output/server/node_modules/undici/lib/mock/mock-client.js +68 -0
  201. package/.output/server/node_modules/undici/lib/mock/mock-errors.js +29 -0
  202. package/.output/server/node_modules/undici/lib/mock/mock-interceptor.js +209 -0
  203. package/.output/server/node_modules/undici/lib/mock/mock-pool.js +68 -0
  204. package/.output/server/node_modules/undici/lib/mock/mock-symbols.js +32 -0
  205. package/.output/server/node_modules/undici/lib/mock/mock-utils.js +486 -0
  206. package/.output/server/node_modules/undici/lib/mock/pending-interceptors-formatter.js +43 -0
  207. package/.output/server/node_modules/undici/lib/mock/snapshot-agent.js +353 -0
  208. package/.output/server/node_modules/undici/lib/mock/snapshot-recorder.js +588 -0
  209. package/.output/server/node_modules/undici/lib/mock/snapshot-utils.js +158 -0
  210. package/.output/server/node_modules/undici/lib/util/cache.js +676 -0
  211. package/.output/server/node_modules/undici/lib/util/date.js +670 -0
  212. package/.output/server/node_modules/undici/lib/util/promise.js +28 -0
  213. package/.output/server/node_modules/undici/lib/util/runtime-features.js +124 -0
  214. package/.output/server/node_modules/undici/lib/util/stats.js +32 -0
  215. package/.output/server/node_modules/undici/lib/util/timers.js +425 -0
  216. package/.output/server/node_modules/undici/lib/web/cache/cache.js +864 -0
  217. package/.output/server/node_modules/undici/lib/web/cache/cachestorage.js +152 -0
  218. package/.output/server/node_modules/undici/lib/web/cache/util.js +45 -0
  219. package/.output/server/node_modules/undici/lib/web/cookies/constants.js +12 -0
  220. package/.output/server/node_modules/undici/lib/web/cookies/index.js +199 -0
  221. package/.output/server/node_modules/undici/lib/web/cookies/parse.js +314 -0
  222. package/.output/server/node_modules/undici/lib/web/cookies/util.js +352 -0
  223. package/.output/server/node_modules/undici/lib/web/eventsource/eventsource-stream.js +399 -0
  224. package/.output/server/node_modules/undici/lib/web/eventsource/eventsource.js +501 -0
  225. package/.output/server/node_modules/undici/lib/web/eventsource/util.js +29 -0
  226. package/.output/server/node_modules/undici/lib/web/fetch/body.js +509 -0
  227. package/.output/server/node_modules/undici/lib/web/fetch/constants.js +131 -0
  228. package/.output/server/node_modules/undici/lib/web/fetch/data-url.js +596 -0
  229. package/.output/server/node_modules/undici/lib/web/fetch/formdata-parser.js +586 -0
  230. package/.output/server/node_modules/undici/lib/web/fetch/formdata.js +259 -0
  231. package/.output/server/node_modules/undici/lib/web/fetch/global.js +40 -0
  232. package/.output/server/node_modules/undici/lib/web/fetch/headers.js +719 -0
  233. package/.output/server/node_modules/undici/lib/web/fetch/index.js +2413 -0
  234. package/.output/server/node_modules/undici/lib/web/fetch/request.js +1115 -0
  235. package/.output/server/node_modules/undici/lib/web/fetch/response.js +641 -0
  236. package/.output/server/node_modules/undici/lib/web/fetch/util.js +1522 -0
  237. package/.output/server/node_modules/undici/lib/web/infra/index.js +229 -0
  238. package/.output/server/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +307 -0
  239. package/.output/server/node_modules/undici/lib/web/webidl/index.js +1006 -0
  240. package/.output/server/node_modules/undici/lib/web/websocket/connection.js +329 -0
  241. package/.output/server/node_modules/undici/lib/web/websocket/constants.js +126 -0
  242. package/.output/server/node_modules/undici/lib/web/websocket/events.js +331 -0
  243. package/.output/server/node_modules/undici/lib/web/websocket/frame.js +133 -0
  244. package/.output/server/node_modules/undici/lib/web/websocket/permessage-deflate.js +100 -0
  245. package/.output/server/node_modules/undici/lib/web/websocket/receiver.js +507 -0
  246. package/.output/server/node_modules/undici/lib/web/websocket/sender.js +109 -0
  247. package/.output/server/node_modules/undici/lib/web/websocket/stream/websocketerror.js +104 -0
  248. package/.output/server/node_modules/undici/lib/web/websocket/stream/websocketstream.js +498 -0
  249. package/.output/server/node_modules/undici/lib/web/websocket/util.js +347 -0
  250. package/.output/server/node_modules/undici/lib/web/websocket/websocket.js +758 -0
  251. package/.output/server/node_modules/undici/package.json +152 -0
  252. package/.output/server/package.json +2 -1
  253. package/LICENSE +201 -2
  254. package/README.md +17 -4
  255. package/dist/package.json +3 -2
  256. package/dist/shared/antigravity-schema.js +45 -0
  257. package/dist/shared/dji-grid.js +62 -0
  258. package/dist/shared/types/map-layers.js +2 -0
  259. package/dist/src/cli.js +63 -5
  260. package/dist/src/core/dji-snapshot.js +135 -0
  261. package/dist/src/core/map-layer-paths.js +11 -0
  262. package/dist/src/map-layer-update.js +646 -0
  263. package/package.json +3 -2
  264. package/.output/public/_nuxt/BNfSclJ4.js +0 -1
  265. package/.output/public/_nuxt/BYzlinOr2.js +0 -1
  266. package/.output/public/_nuxt/Be4dNlar.js +0 -1
  267. package/.output/public/_nuxt/C7fHMLd7.js +0 -1
  268. package/.output/public/_nuxt/CNs_Ozdc.js +0 -1
  269. package/.output/public/_nuxt/CQ8inUdm.js +0 -1
  270. package/.output/public/_nuxt/Cc_JfSB1.js +0 -1
  271. package/.output/public/_nuxt/CyZDc0eO2.js +0 -1
  272. package/.output/public/_nuxt/CzFefJH0.js +0 -1
  273. package/.output/public/_nuxt/D-t0hXHB.js +0 -1
  274. package/.output/public/_nuxt/D3Pl7yw22.js +0 -1
  275. package/.output/public/_nuxt/D4gbGuiW.js +0 -1
  276. package/.output/public/_nuxt/DDp9lK3g.js +0 -1
  277. package/.output/public/_nuxt/DIIXHC50.js +0 -1
  278. package/.output/public/_nuxt/DWFUvzz0.js +0 -1
  279. package/.output/public/_nuxt/D_VoD6-f.js +0 -1
  280. package/.output/public/_nuxt/DfXX-x_z.js +0 -1
  281. package/.output/public/_nuxt/Dgyf2aNY.js +0 -1
  282. package/.output/public/_nuxt/GM5myUL22.js +0 -1
  283. package/.output/public/_nuxt/IC4wc76W.js +0 -1
  284. package/.output/public/_nuxt/IfL46N3Z.js +0 -1
  285. package/.output/public/_nuxt/KEU2l6zJ.js +0 -3
  286. package/.output/public/_nuxt/SEETjfdJ.js +0 -1
  287. package/.output/public/_nuxt/builds/meta/2c4adba2-91b5-44e4-91d3-50a61695207b.json +0 -1
  288. package/.output/public/_nuxt/entry.CZ_dkjcs.css +0 -1
  289. package/.output/public/_nuxt/nGp0t_eD.js +0 -1
  290. package/.output/server/chunks/build/Alert-DHVVSgdD.mjs +0 -1074
  291. package/.output/server/chunks/build/Alert-DHVVSgdD.mjs.map +0 -1
  292. package/.output/server/chunks/build/DashboardSidebarToggle-CUI9NSow.mjs.map +0 -1
  293. package/.output/server/chunks/build/Empty-BGIn09cL.mjs.map +0 -1
  294. package/.output/server/chunks/build/FocusScope-DNZVMnza.mjs +0 -207
  295. package/.output/server/chunks/build/FocusScope-DNZVMnza.mjs.map +0 -1
  296. package/.output/server/chunks/build/FormField-DnJWfrKE.mjs.map +0 -1
  297. package/.output/server/chunks/build/MapBaseLayerTabs-CRl5Zwlr.mjs.map +0 -1
  298. package/.output/server/chunks/build/OnlineMap-cFSicmkV.mjs.map +0 -1
  299. package/.output/server/chunks/build/Tooltip-DNUdH4oF.mjs.map +0 -1
  300. package/.output/server/chunks/build/advanced-5ZGMUBqC.mjs.map +0 -1
  301. package/.output/server/chunks/build/compare-CtgF4Anj.mjs.map +0 -1
  302. package/.output/server/chunks/build/pages-0c5sp_lv.mjs.map +0 -1
  303. package/.output/server/chunks/build/tasks-Aa8PwjVL.mjs.map +0 -1
@@ -0,0 +1,1731 @@
1
+ 'use strict'
2
+
3
+ /* global WebAssembly */
4
+
5
+ const assert = require('node:assert')
6
+ const util = require('../core/util.js')
7
+ const { channels } = require('../core/diagnostics.js')
8
+ const timers = require('../util/timers.js')
9
+ const {
10
+ RequestContentLengthMismatchError,
11
+ ResponseContentLengthMismatchError,
12
+ RequestAbortedError,
13
+ InvalidArgumentError,
14
+ HeadersTimeoutError,
15
+ HeadersOverflowError,
16
+ SocketError,
17
+ InformationalError,
18
+ BodyTimeoutError,
19
+ HTTPParserError,
20
+ ResponseExceededMaxSizeError
21
+ } = require('../core/errors.js')
22
+ const {
23
+ kUrl,
24
+ kReset,
25
+ kClient,
26
+ kParser,
27
+ kBlocking,
28
+ kRunning,
29
+ kPending,
30
+ kSize,
31
+ kWriting,
32
+ kQueue,
33
+ kNoRef,
34
+ kKeepAliveDefaultTimeout,
35
+ kHostHeader,
36
+ kPendingIdx,
37
+ kRunningIdx,
38
+ kError,
39
+ kPipelining,
40
+ kSocket,
41
+ kKeepAliveTimeoutValue,
42
+ kMaxHeadersSize,
43
+ kKeepAliveMaxTimeout,
44
+ kKeepAliveTimeoutThreshold,
45
+ kHeadersTimeout,
46
+ kBodyTimeout,
47
+ kStrictContentLength,
48
+ kMaxRequests,
49
+ kCounter,
50
+ kMaxResponseSize,
51
+ kOnError,
52
+ kResume,
53
+ kHTTPContext,
54
+ kClosed
55
+ } = require('../core/symbols.js')
56
+
57
+ const constants = require('../llhttp/constants.js')
58
+ const EMPTY_BUF = Buffer.alloc(0)
59
+ const FastBuffer = Buffer[Symbol.species]
60
+ const removeAllListeners = util.removeAllListeners
61
+ const kIdleSocketValidation = Symbol('kIdleSocketValidation')
62
+ const kIdleSocketValidationTimeout = Symbol('kIdleSocketValidationTimeout')
63
+ const kSocketUsed = Symbol('kSocketUsed')
64
+
65
+ let extractBody
66
+
67
+ function lazyllhttp () {
68
+ const llhttpWasmData = process.env.JEST_WORKER_ID ? require('../llhttp/llhttp-wasm.js') : undefined
69
+
70
+ let mod
71
+
72
+ // We disable wasm SIMD on ppc64 as it seems to be broken on Power 9 architectures.
73
+ let useWasmSIMD = process.arch !== 'ppc64'
74
+ // The Env Variable UNDICI_NO_WASM_SIMD allows explicitly overriding the default behavior
75
+ if (process.env.UNDICI_NO_WASM_SIMD === '1') {
76
+ useWasmSIMD = false
77
+ } else if (process.env.UNDICI_NO_WASM_SIMD === '0') {
78
+ useWasmSIMD = true
79
+ }
80
+
81
+ if (useWasmSIMD) {
82
+ try {
83
+ mod = new WebAssembly.Module(require('../llhttp/llhttp_simd-wasm.js'))
84
+ } catch {
85
+ }
86
+ }
87
+
88
+ if (!mod) {
89
+ // We could check if the error was caused by the simd option not
90
+ // being enabled, but the occurring of this other error
91
+ // * https://github.com/emscripten-core/emscripten/issues/11495
92
+ // got me to remove that check to avoid breaking Node 12.
93
+ mod = new WebAssembly.Module(llhttpWasmData || require('../llhttp/llhttp-wasm.js'))
94
+ }
95
+
96
+ return new WebAssembly.Instance(mod, {
97
+ env: {
98
+ /**
99
+ * @param {number} p
100
+ * @param {number} at
101
+ * @param {number} len
102
+ * @returns {number}
103
+ */
104
+ wasm_on_url: (p, at, len) => {
105
+ return 0
106
+ },
107
+ /**
108
+ * @param {number} p
109
+ * @param {number} at
110
+ * @param {number} len
111
+ * @returns {number}
112
+ */
113
+ wasm_on_status: (p, at, len) => {
114
+ assert(currentParser.ptr === p)
115
+ const start = at - currentBufferPtr + currentBufferRef.byteOffset
116
+ return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len))
117
+ },
118
+ /**
119
+ * @param {number} p
120
+ * @returns {number}
121
+ */
122
+ wasm_on_message_begin: (p) => {
123
+ assert(currentParser.ptr === p)
124
+ return currentParser.onMessageBegin()
125
+ },
126
+ /**
127
+ * @param {number} p
128
+ * @param {number} at
129
+ * @param {number} len
130
+ * @returns {number}
131
+ */
132
+ wasm_on_header_field: (p, at, len) => {
133
+ assert(currentParser.ptr === p)
134
+ const start = at - currentBufferPtr + currentBufferRef.byteOffset
135
+ return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len))
136
+ },
137
+ /**
138
+ * @param {number} p
139
+ * @param {number} at
140
+ * @param {number} len
141
+ * @returns {number}
142
+ */
143
+ wasm_on_header_value: (p, at, len) => {
144
+ assert(currentParser.ptr === p)
145
+ const start = at - currentBufferPtr + currentBufferRef.byteOffset
146
+ return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len))
147
+ },
148
+ /**
149
+ * @param {number} p
150
+ * @param {number} statusCode
151
+ * @param {0|1} upgrade
152
+ * @param {0|1} shouldKeepAlive
153
+ * @returns {number}
154
+ */
155
+ wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => {
156
+ assert(currentParser.ptr === p)
157
+ return currentParser.onHeadersComplete(statusCode, upgrade === 1, shouldKeepAlive === 1)
158
+ },
159
+ /**
160
+ * @param {number} p
161
+ * @param {number} at
162
+ * @param {number} len
163
+ * @returns {number}
164
+ */
165
+ wasm_on_body: (p, at, len) => {
166
+ assert(currentParser.ptr === p)
167
+ const start = at - currentBufferPtr + currentBufferRef.byteOffset
168
+ return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len))
169
+ },
170
+ /**
171
+ * @param {number} p
172
+ * @returns {number}
173
+ */
174
+ wasm_on_message_complete: (p) => {
175
+ assert(currentParser.ptr === p)
176
+ return currentParser.onMessageComplete()
177
+ }
178
+
179
+ }
180
+ })
181
+ }
182
+
183
+ let llhttpInstance = null
184
+
185
+ /**
186
+ * @type {Parser|null}
187
+ */
188
+ let currentParser = null
189
+ let currentBufferRef = null
190
+ /**
191
+ * @type {number}
192
+ */
193
+ let currentBufferSize = 0
194
+ let currentBufferPtr = null
195
+
196
+ const USE_NATIVE_TIMER = 0
197
+ const USE_FAST_TIMER = 1
198
+
199
+ // Use fast timers for headers and body to take eventual event loop
200
+ // latency into account.
201
+ const TIMEOUT_HEADERS = 2 | USE_FAST_TIMER
202
+ const TIMEOUT_BODY = 4 | USE_FAST_TIMER
203
+
204
+ // Use native timers to ignore event loop latency for keep-alive
205
+ // handling.
206
+ const TIMEOUT_KEEP_ALIVE = 8 | USE_NATIVE_TIMER
207
+
208
+ class Parser {
209
+ /**
210
+ * @param {import('./client.js')} client
211
+ * @param {import('net').Socket} socket
212
+ * @param {*} llhttp
213
+ */
214
+ constructor (client, socket, { exports }) {
215
+ this.llhttp = exports
216
+ this.ptr = this.llhttp.llhttp_alloc(constants.TYPE.RESPONSE)
217
+ this.client = client
218
+ /**
219
+ * @type {import('net').Socket}
220
+ */
221
+ this.socket = socket
222
+ this.timeout = null
223
+ this.timeoutWeakRef = new WeakRef(this)
224
+ this.timeoutValue = null
225
+ this.timeoutType = null
226
+ this.statusCode = 0
227
+ this.statusText = ''
228
+ this.upgrade = false
229
+ this.headers = []
230
+ this.headersSize = 0
231
+ this.headersMaxSize = client[kMaxHeadersSize]
232
+ this.shouldKeepAlive = false
233
+ this.paused = false
234
+ this.resume = this.resume.bind(this)
235
+
236
+ this.bytesRead = 0
237
+
238
+ this.keepAlive = ''
239
+ this.contentLength = ''
240
+ this.connection = ''
241
+ this.maxResponseSize = client[kMaxResponseSize]
242
+ }
243
+
244
+ setTimeout (delay, type) {
245
+ // If the existing timer and the new timer are of different timer type
246
+ // (fast or native) or have different delay, we need to clear the existing
247
+ // timer and set a new one.
248
+ if (
249
+ delay !== this.timeoutValue ||
250
+ (type & USE_FAST_TIMER) ^ (this.timeoutType & USE_FAST_TIMER)
251
+ ) {
252
+ // If a timeout is already set, clear it with clearTimeout of the fast
253
+ // timer implementation, as it can clear fast and native timers.
254
+ if (this.timeout) {
255
+ timers.clearTimeout(this.timeout)
256
+ this.timeout = null
257
+ }
258
+
259
+ if (delay) {
260
+ if (type & USE_FAST_TIMER) {
261
+ this.timeout = timers.setFastTimeout(onParserTimeout, delay, this.timeoutWeakRef)
262
+ } else {
263
+ this.timeout = setTimeout(onParserTimeout, delay, this.timeoutWeakRef)
264
+ this.timeout?.unref()
265
+ }
266
+ }
267
+
268
+ this.timeoutValue = delay
269
+ } else if (this.timeout) {
270
+ if (this.timeout.refresh) {
271
+ this.timeout.refresh()
272
+ }
273
+ }
274
+
275
+ this.timeoutType = type
276
+ }
277
+
278
+ resume () {
279
+ if (this.socket.destroyed || !this.paused) {
280
+ return
281
+ }
282
+
283
+ assert(this.ptr != null)
284
+ assert(currentParser === null)
285
+
286
+ this.llhttp.llhttp_resume(this.ptr)
287
+
288
+ assert(this.timeoutType === TIMEOUT_BODY)
289
+ if (this.timeout) {
290
+ if (this.timeout.refresh) {
291
+ this.timeout.refresh()
292
+ }
293
+ }
294
+
295
+ this.paused = false
296
+ this.execute(this.socket.read() || EMPTY_BUF) // Flush parser.
297
+ this.readMore()
298
+ }
299
+
300
+ readMore () {
301
+ while (!this.paused && this.ptr) {
302
+ const chunk = this.socket.read()
303
+ if (chunk === null) {
304
+ break
305
+ }
306
+ this.execute(chunk)
307
+ }
308
+ }
309
+
310
+ /**
311
+ * @param {Buffer} chunk
312
+ */
313
+ execute (chunk) {
314
+ assert(currentParser === null)
315
+ assert(this.ptr != null)
316
+ assert(!this.paused)
317
+
318
+ const { socket, llhttp } = this
319
+
320
+ // Allocate a new buffer if the current buffer is too small.
321
+ if (chunk.length > currentBufferSize) {
322
+ if (currentBufferPtr) {
323
+ llhttp.free(currentBufferPtr)
324
+ }
325
+ // Allocate a buffer that is a multiple of 4096 bytes.
326
+ currentBufferSize = Math.ceil(chunk.length / 4096) * 4096
327
+ currentBufferPtr = llhttp.malloc(currentBufferSize)
328
+ }
329
+
330
+ new Uint8Array(llhttp.memory.buffer, currentBufferPtr, currentBufferSize).set(chunk)
331
+
332
+ // Call `execute` on the wasm parser.
333
+ // We pass the `llhttp_parser` pointer address, the pointer address of buffer view data,
334
+ // and finally the length of bytes to parse.
335
+ // The return value is an error code or `constants.ERROR.OK`.
336
+ try {
337
+ let ret
338
+
339
+ try {
340
+ currentBufferRef = chunk
341
+ currentParser = this
342
+ ret = llhttp.llhttp_execute(this.ptr, currentBufferPtr, chunk.length)
343
+ } finally {
344
+ currentParser = null
345
+ currentBufferRef = null
346
+ }
347
+
348
+ if (ret !== constants.ERROR.OK) {
349
+ const data = chunk.subarray(llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr)
350
+
351
+ if (ret === constants.ERROR.PAUSED_UPGRADE) {
352
+ this.onUpgrade(data)
353
+ } else if (ret === constants.ERROR.PAUSED) {
354
+ this.paused = true
355
+ socket.unshift(data)
356
+ } else {
357
+ throw this.createError(ret, data)
358
+ }
359
+ }
360
+ } catch (err) {
361
+ util.destroy(socket, err)
362
+ }
363
+ }
364
+
365
+ finish () {
366
+ assert(currentParser === null)
367
+ assert(this.ptr != null)
368
+ assert(!this.paused)
369
+
370
+ const { llhttp } = this
371
+
372
+ let ret
373
+
374
+ try {
375
+ currentParser = this
376
+ ret = llhttp.llhttp_finish(this.ptr)
377
+ } finally {
378
+ currentParser = null
379
+ }
380
+
381
+ if (ret === constants.ERROR.OK) {
382
+ return null
383
+ }
384
+
385
+ if (ret === constants.ERROR.PAUSED || ret === constants.ERROR.PAUSED_UPGRADE) {
386
+ this.paused = true
387
+ return null
388
+ }
389
+
390
+ return this.createError(ret, EMPTY_BUF)
391
+ }
392
+
393
+ createError (ret, data) {
394
+ const { llhttp, contentLength, bytesRead } = this
395
+
396
+ if (contentLength && bytesRead !== parseInt(contentLength, 10)) {
397
+ return new ResponseContentLengthMismatchError()
398
+ }
399
+
400
+ const ptr = llhttp.llhttp_get_error_reason(this.ptr)
401
+ let message = ''
402
+ if (ptr) {
403
+ const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0)
404
+ message =
405
+ 'Response does not match the HTTP/1.1 protocol (' +
406
+ Buffer.from(llhttp.memory.buffer, ptr, len).toString() +
407
+ ')'
408
+ }
409
+
410
+ return new HTTPParserError(message, constants.ERROR[ret], data)
411
+ }
412
+
413
+ destroy () {
414
+ assert(currentParser === null)
415
+ assert(this.ptr != null)
416
+
417
+ this.llhttp.llhttp_free(this.ptr)
418
+ this.ptr = null
419
+
420
+ this.timeout && timers.clearTimeout(this.timeout)
421
+ this.timeout = null
422
+ this.timeoutValue = null
423
+ this.timeoutType = null
424
+
425
+ this.paused = false
426
+ }
427
+
428
+ /**
429
+ * @param {Buffer} buf
430
+ * @returns {0}
431
+ */
432
+ onStatus (buf) {
433
+ this.statusText = buf.toString()
434
+ return 0
435
+ }
436
+
437
+ /**
438
+ * @returns {0|-1}
439
+ */
440
+ onMessageBegin () {
441
+ const { socket, client } = this
442
+
443
+ if (socket.destroyed) {
444
+ return -1
445
+ }
446
+
447
+ if (client[kRunning] === 0) {
448
+ util.destroy(socket, new SocketError('bad response', util.getSocketInfo(socket)))
449
+ return -1
450
+ }
451
+
452
+ const request = client[kQueue][client[kRunningIdx]]
453
+ if (!request) {
454
+ return -1
455
+ }
456
+ request.onResponseStarted()
457
+
458
+ return 0
459
+ }
460
+
461
+ /**
462
+ * @param {Buffer} buf
463
+ * @returns {number}
464
+ */
465
+ onHeaderField (buf) {
466
+ const len = this.headers.length
467
+
468
+ if ((len & 1) === 0) {
469
+ this.headers.push(buf)
470
+ } else {
471
+ this.headers[len - 1] = Buffer.concat([this.headers[len - 1], buf])
472
+ }
473
+
474
+ this.trackHeader(buf.length)
475
+
476
+ return 0
477
+ }
478
+
479
+ /**
480
+ * @param {Buffer} buf
481
+ * @returns {number}
482
+ */
483
+ onHeaderValue (buf) {
484
+ let len = this.headers.length
485
+
486
+ if ((len & 1) === 1) {
487
+ this.headers.push(buf)
488
+ len += 1
489
+ } else {
490
+ this.headers[len - 1] = Buffer.concat([this.headers[len - 1], buf])
491
+ }
492
+
493
+ const key = this.headers[len - 2]
494
+ if (key.length === 10) {
495
+ const headerName = util.bufferToLowerCasedHeaderName(key)
496
+ if (headerName === 'keep-alive') {
497
+ this.keepAlive += buf.toString()
498
+ } else if (headerName === 'connection') {
499
+ this.connection += buf.toString()
500
+ }
501
+ } else if (key.length === 14 && util.bufferToLowerCasedHeaderName(key) === 'content-length') {
502
+ this.contentLength += buf.toString()
503
+ }
504
+
505
+ this.trackHeader(buf.length)
506
+
507
+ return 0
508
+ }
509
+
510
+ /**
511
+ * @param {number} len
512
+ */
513
+ trackHeader (len) {
514
+ this.headersSize += len
515
+ if (this.headersSize >= this.headersMaxSize) {
516
+ util.destroy(this.socket, new HeadersOverflowError())
517
+ }
518
+ }
519
+
520
+ /**
521
+ * @param {Buffer} head
522
+ */
523
+ onUpgrade (head) {
524
+ const { upgrade, client, socket, headers, statusCode } = this
525
+
526
+ assert(upgrade)
527
+ assert(client[kSocket] === socket)
528
+ assert(!socket.destroyed)
529
+ assert(!this.paused)
530
+ assert((headers.length & 1) === 0)
531
+
532
+ const request = client[kQueue][client[kRunningIdx]]
533
+ assert(request)
534
+ assert(request.upgrade || request.method === 'CONNECT')
535
+
536
+ this.statusCode = 0
537
+ this.statusText = ''
538
+ this.shouldKeepAlive = false
539
+
540
+ this.headers = []
541
+ this.headersSize = 0
542
+
543
+ socket.unshift(head)
544
+
545
+ socket[kParser].destroy()
546
+ socket[kParser] = null
547
+
548
+ socket[kClient] = null
549
+ socket[kError] = null
550
+
551
+ removeAllListeners(socket)
552
+
553
+ client[kSocket] = null
554
+ client[kHTTPContext] = null // TODO (fix): This is hacky...
555
+ client[kQueue][client[kRunningIdx]++] = null
556
+ client.emit('disconnect', client[kUrl], [client], new InformationalError('upgrade'))
557
+
558
+ try {
559
+ request.onUpgrade(statusCode, headers, socket)
560
+ } catch (err) {
561
+ util.destroy(socket, err)
562
+ }
563
+
564
+ client[kResume]()
565
+ }
566
+
567
+ /**
568
+ * @param {number} statusCode
569
+ * @param {boolean} upgrade
570
+ * @param {boolean} shouldKeepAlive
571
+ * @returns {number}
572
+ */
573
+ onHeadersComplete (statusCode, upgrade, shouldKeepAlive) {
574
+ const { client, socket, headers, statusText } = this
575
+
576
+ if (socket.destroyed) {
577
+ return -1
578
+ }
579
+
580
+ if (client[kRunning] === 0) {
581
+ util.destroy(socket, new SocketError('bad response', util.getSocketInfo(socket)))
582
+ return -1
583
+ }
584
+
585
+ const request = client[kQueue][client[kRunningIdx]]
586
+
587
+ if (!request) {
588
+ return -1
589
+ }
590
+
591
+ assert(!this.upgrade)
592
+ assert(this.statusCode < 200)
593
+
594
+ if (statusCode === 100) {
595
+ util.destroy(socket, new SocketError('bad response', util.getSocketInfo(socket)))
596
+ return -1
597
+ }
598
+
599
+ /* this can only happen if server is misbehaving */
600
+ if (upgrade && !request.upgrade) {
601
+ util.destroy(socket, new SocketError('bad upgrade', util.getSocketInfo(socket)))
602
+ return -1
603
+ }
604
+
605
+ assert(this.timeoutType === TIMEOUT_HEADERS)
606
+
607
+ this.statusCode = statusCode
608
+ this.shouldKeepAlive = (
609
+ shouldKeepAlive ||
610
+ // Override llhttp value which does not allow keepAlive for HEAD.
611
+ (request.method === 'HEAD' && !socket[kReset] && this.connection.toLowerCase() === 'keep-alive')
612
+ )
613
+
614
+ if (this.statusCode >= 200) {
615
+ const bodyTimeout = request.bodyTimeout != null
616
+ ? request.bodyTimeout
617
+ : client[kBodyTimeout]
618
+ this.setTimeout(bodyTimeout, TIMEOUT_BODY)
619
+ } else if (this.timeout) {
620
+ if (this.timeout.refresh) {
621
+ this.timeout.refresh()
622
+ }
623
+ }
624
+
625
+ if (request.method === 'CONNECT') {
626
+ assert(client[kRunning] === 1)
627
+ this.upgrade = true
628
+ return 2
629
+ }
630
+
631
+ if (upgrade) {
632
+ assert(client[kRunning] === 1)
633
+ this.upgrade = true
634
+ return 2
635
+ }
636
+
637
+ assert((this.headers.length & 1) === 0)
638
+ this.headers = []
639
+ this.headersSize = 0
640
+
641
+ if (this.shouldKeepAlive && client[kPipelining]) {
642
+ const keepAliveTimeout = this.keepAlive ? util.parseKeepAliveTimeout(this.keepAlive) : null
643
+
644
+ if (keepAliveTimeout != null) {
645
+ const timeout = Math.min(
646
+ keepAliveTimeout - client[kKeepAliveTimeoutThreshold],
647
+ client[kKeepAliveMaxTimeout]
648
+ )
649
+ if (timeout <= 0) {
650
+ socket[kReset] = true
651
+ } else {
652
+ client[kKeepAliveTimeoutValue] = timeout
653
+ }
654
+ } else {
655
+ client[kKeepAliveTimeoutValue] = client[kKeepAliveDefaultTimeout]
656
+ }
657
+ } else {
658
+ // Stop more requests from being dispatched.
659
+ socket[kReset] = true
660
+ }
661
+
662
+ const pause = request.onHeaders(statusCode, headers, this.resume, statusText) === false
663
+
664
+ if (request.aborted) {
665
+ return -1
666
+ }
667
+
668
+ if (request.method === 'HEAD') {
669
+ return 1
670
+ }
671
+
672
+ if (statusCode < 200) {
673
+ return 1
674
+ }
675
+
676
+ if (socket[kBlocking]) {
677
+ socket[kBlocking] = false
678
+ client[kResume]()
679
+ }
680
+
681
+ return pause ? constants.ERROR.PAUSED : 0
682
+ }
683
+
684
+ /**
685
+ * @param {Buffer} buf
686
+ * @returns {number}
687
+ */
688
+ onBody (buf) {
689
+ const { client, socket, statusCode, maxResponseSize } = this
690
+
691
+ if (socket.destroyed) {
692
+ return -1
693
+ }
694
+
695
+ const request = client[kQueue][client[kRunningIdx]]
696
+ assert(request)
697
+
698
+ assert(this.timeoutType === TIMEOUT_BODY)
699
+ if (this.timeout) {
700
+ if (this.timeout.refresh) {
701
+ this.timeout.refresh()
702
+ }
703
+ }
704
+
705
+ assert(statusCode >= 200)
706
+
707
+ if (maxResponseSize > -1 && this.bytesRead + buf.length > maxResponseSize) {
708
+ util.destroy(socket, new ResponseExceededMaxSizeError())
709
+ return -1
710
+ }
711
+
712
+ this.bytesRead += buf.length
713
+
714
+ if (request.onData(buf) === false) {
715
+ return constants.ERROR.PAUSED
716
+ }
717
+
718
+ return 0
719
+ }
720
+
721
+ /**
722
+ * @returns {number}
723
+ */
724
+ onMessageComplete () {
725
+ const { client, socket, statusCode, upgrade, headers, contentLength, bytesRead, shouldKeepAlive } = this
726
+
727
+ if (socket.destroyed && (!statusCode || shouldKeepAlive)) {
728
+ return -1
729
+ }
730
+
731
+ if (upgrade) {
732
+ return 0
733
+ }
734
+
735
+ assert(statusCode >= 100)
736
+ assert((this.headers.length & 1) === 0)
737
+
738
+ const request = client[kQueue][client[kRunningIdx]]
739
+ assert(request)
740
+
741
+ this.statusCode = 0
742
+ this.statusText = ''
743
+ this.bytesRead = 0
744
+ this.contentLength = ''
745
+ this.keepAlive = ''
746
+ this.connection = ''
747
+
748
+ this.headers = []
749
+ this.headersSize = 0
750
+
751
+ if (statusCode < 200) {
752
+ return 0
753
+ }
754
+
755
+ if (request.method !== 'HEAD' && contentLength && bytesRead !== parseInt(contentLength, 10)) {
756
+ util.destroy(socket, new ResponseContentLengthMismatchError())
757
+ return -1
758
+ }
759
+
760
+ request.onComplete(headers)
761
+
762
+ client[kQueue][client[kRunningIdx]++] = null
763
+ socket[kSocketUsed] = client[kPending] === 0
764
+
765
+ if (socket[kWriting]) {
766
+ assert(client[kRunning] === 0)
767
+ // Response completed before request.
768
+ util.destroy(socket, new InformationalError('reset'))
769
+ return constants.ERROR.PAUSED
770
+ } else if (!shouldKeepAlive) {
771
+ util.destroy(socket, new InformationalError('reset'))
772
+ return constants.ERROR.PAUSED
773
+ } else if (socket[kReset] && client[kRunning] === 0) {
774
+ // Destroy socket once all requests have completed.
775
+ // The request at the tail of the pipeline is the one
776
+ // that requested reset and no further requests should
777
+ // have been queued since then.
778
+ util.destroy(socket, new InformationalError('reset'))
779
+ return constants.ERROR.PAUSED
780
+ } else if (client[kPipelining] == null || client[kPipelining] === 1) {
781
+ // We must wait a full event loop cycle to reuse this socket to make sure
782
+ // that non-spec compliant servers are not closing the connection even if they
783
+ // said they won't.
784
+ setImmediate(client[kResume])
785
+ } else {
786
+ client[kResume]()
787
+ }
788
+
789
+ return 0
790
+ }
791
+ }
792
+
793
+ function onParserTimeout (parserWeakRef) {
794
+ const parser = parserWeakRef.deref()
795
+ if (!parser) {
796
+ return
797
+ }
798
+
799
+ const { socket, timeoutType, client, paused } = parser
800
+
801
+ if (timeoutType === TIMEOUT_HEADERS) {
802
+ if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) {
803
+ assert(!paused, 'cannot be paused while waiting for headers')
804
+ util.destroy(socket, new HeadersTimeoutError())
805
+ }
806
+ } else if (timeoutType === TIMEOUT_BODY) {
807
+ if (!paused) {
808
+ util.destroy(socket, new BodyTimeoutError())
809
+ }
810
+ } else if (timeoutType === TIMEOUT_KEEP_ALIVE) {
811
+ assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue])
812
+ util.destroy(socket, new InformationalError('socket idle timeout'))
813
+ }
814
+ }
815
+
816
+ /**
817
+ * @param {import ('./client.js')} client
818
+ * @param {import('net').Socket} socket
819
+ * @returns
820
+ */
821
+ function connectH1 (client, socket) {
822
+ client[kSocket] = socket
823
+
824
+ if (!llhttpInstance) {
825
+ llhttpInstance = lazyllhttp()
826
+ }
827
+
828
+ if (socket.errored) {
829
+ throw socket.errored
830
+ }
831
+
832
+ if (socket.destroyed) {
833
+ throw new SocketError('destroyed')
834
+ }
835
+
836
+ socket[kNoRef] = false
837
+ socket[kWriting] = false
838
+ socket[kReset] = false
839
+ socket[kBlocking] = false
840
+ socket[kIdleSocketValidation] = 0
841
+ socket[kIdleSocketValidationTimeout] = null
842
+ socket[kSocketUsed] = false
843
+ socket[kParser] = new Parser(client, socket, llhttpInstance)
844
+
845
+ util.addListener(socket, 'error', onHttpSocketError)
846
+ util.addListener(socket, 'readable', onHttpSocketReadable)
847
+ util.addListener(socket, 'end', onHttpSocketEnd)
848
+ util.addListener(socket, 'close', onHttpSocketClose)
849
+
850
+ socket[kClosed] = false
851
+ socket.on('close', onSocketClose)
852
+
853
+ return {
854
+ version: 'h1',
855
+ defaultPipelining: 1,
856
+ write (request) {
857
+ return writeH1(client, request)
858
+ },
859
+ resume () {
860
+ resumeH1(client)
861
+ },
862
+ /**
863
+ * @param {Error|undefined} err
864
+ * @param {() => void} callback
865
+ */
866
+ destroy (err, callback) {
867
+ if (socket[kClosed]) {
868
+ queueMicrotask(callback)
869
+ } else {
870
+ socket.on('close', callback)
871
+ socket.destroy(err)
872
+ }
873
+ },
874
+ /**
875
+ * @returns {boolean}
876
+ */
877
+ get destroyed () {
878
+ return socket.destroyed
879
+ },
880
+ /**
881
+ * @param {import('../core/request.js')} request
882
+ * @returns {boolean}
883
+ */
884
+ busy (request) {
885
+ if (socket[kWriting] || socket[kReset] || socket[kBlocking] || socket[kIdleSocketValidation] === 1) {
886
+ return true
887
+ }
888
+
889
+ if (request) {
890
+ if (client[kRunning] > 0 && !request.idempotent) {
891
+ // Non-idempotent request cannot be retried.
892
+ // Ensure that no other requests are inflight and
893
+ // could cause failure.
894
+ return true
895
+ }
896
+
897
+ if (client[kRunning] > 0 && (request.upgrade || request.method === 'CONNECT')) {
898
+ // Don't dispatch an upgrade until all preceding requests have completed.
899
+ // A misbehaving server might upgrade the connection before all pipelined
900
+ // request has completed.
901
+ return true
902
+ }
903
+
904
+ if (client[kRunning] > 0 && util.bodyLength(request.body) !== 0 &&
905
+ (util.isStream(request.body) || util.isAsyncIterable(request.body) || util.isFormDataLike(request.body))) {
906
+ // Request with stream or iterator body can error while other requests
907
+ // are inflight and indirectly error those as well.
908
+ // Ensure this doesn't happen by waiting for inflight
909
+ // to complete before dispatching.
910
+
911
+ // Request with stream or iterator body cannot be retried.
912
+ // Ensure that no other requests are inflight and
913
+ // could cause failure.
914
+ return true
915
+ }
916
+ }
917
+
918
+ return false
919
+ }
920
+ }
921
+ }
922
+
923
+ function onHttpSocketError (err) {
924
+ assert(err.code !== 'ERR_TLS_CERT_ALTNAME_INVALID')
925
+
926
+ const parser = this[kParser]
927
+
928
+ // On Mac OS, we get an ECONNRESET even if there is a full body to be forwarded
929
+ // to the user.
930
+ if (err.code === 'ECONNRESET' && parser.statusCode && !parser.shouldKeepAlive) {
931
+ const parserErr = parser.finish()
932
+ if (parserErr) {
933
+ this[kError] = parserErr
934
+ this[kClient][kOnError](parserErr)
935
+ }
936
+ return
937
+ }
938
+
939
+ this[kError] = err
940
+
941
+ this[kClient][kOnError](err)
942
+ }
943
+
944
+ function onHttpSocketReadable () {
945
+ this[kParser]?.readMore()
946
+ }
947
+
948
+ function onHttpSocketEnd () {
949
+ const parser = this[kParser]
950
+
951
+ if (parser.statusCode && !parser.shouldKeepAlive) {
952
+ const parserErr = parser.finish()
953
+ if (parserErr) {
954
+ util.destroy(this, parserErr)
955
+ }
956
+ return
957
+ }
958
+
959
+ util.destroy(this, new SocketError('other side closed', util.getSocketInfo(this)))
960
+ }
961
+
962
+ function onHttpSocketClose () {
963
+ const parser = this[kParser]
964
+
965
+ clearIdleSocketValidation(this)
966
+
967
+ if (parser) {
968
+ if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) {
969
+ this[kError] = parser.finish() || this[kError]
970
+ }
971
+
972
+ this[kParser].destroy()
973
+ this[kParser] = null
974
+ }
975
+
976
+ const err = this[kError] || new SocketError('closed', util.getSocketInfo(this))
977
+
978
+ const client = this[kClient]
979
+
980
+ client[kSocket] = null
981
+ client[kHTTPContext] = null // TODO (fix): This is hacky...
982
+
983
+ if (client.destroyed) {
984
+ assert(client[kPending] === 0)
985
+
986
+ // Fail entire queue.
987
+ const requests = client[kQueue].splice(client[kRunningIdx])
988
+ for (let i = 0; i < requests.length; i++) {
989
+ const request = requests[i]
990
+ util.errorRequest(client, request, err)
991
+ }
992
+ } else if (client[kRunning] > 0 && err.code !== 'UND_ERR_INFO') {
993
+ // Fail head of pipeline.
994
+ const request = client[kQueue][client[kRunningIdx]]
995
+ client[kQueue][client[kRunningIdx]++] = null
996
+
997
+ util.errorRequest(client, request, err)
998
+ }
999
+
1000
+ client[kPendingIdx] = client[kRunningIdx]
1001
+
1002
+ assert(client[kRunning] === 0)
1003
+
1004
+ client.emit('disconnect', client[kUrl], [client], err)
1005
+
1006
+ client[kResume]()
1007
+ }
1008
+
1009
+ function onSocketClose () {
1010
+ this[kClosed] = true
1011
+ }
1012
+
1013
+ function clearIdleSocketValidation (socket) {
1014
+ if (socket[kIdleSocketValidationTimeout]) {
1015
+ clearTimeout(socket[kIdleSocketValidationTimeout])
1016
+ socket[kIdleSocketValidationTimeout] = null
1017
+ }
1018
+
1019
+ socket[kIdleSocketValidation] = 0
1020
+ }
1021
+
1022
+ function scheduleIdleSocketValidation (client, socket) {
1023
+ socket[kIdleSocketValidation] = 1
1024
+ socket[kIdleSocketValidationTimeout] = setTimeout(() => {
1025
+ socket[kIdleSocketValidationTimeout] = null
1026
+ socket[kIdleSocketValidation] = 2
1027
+
1028
+ if (client[kSocket] === socket && !socket.destroyed) {
1029
+ client[kResume]()
1030
+ }
1031
+ }, 0)
1032
+ socket[kIdleSocketValidationTimeout].unref?.()
1033
+ }
1034
+
1035
+ /**
1036
+ * @param {import('./client.js')} client
1037
+ */
1038
+ function resumeH1 (client) {
1039
+ const socket = client[kSocket]
1040
+
1041
+ if (socket && !socket.destroyed) {
1042
+ if (client[kSize] === 0) {
1043
+ if (!socket[kNoRef] && socket.unref) {
1044
+ socket.unref()
1045
+ socket[kNoRef] = true
1046
+ }
1047
+ } else if (socket[kNoRef] && socket.ref) {
1048
+ socket.ref()
1049
+ socket[kNoRef] = false
1050
+ }
1051
+
1052
+ if (client[kRunning] === 0 && client[kPending] > 0 && socket[kSocketUsed]) {
1053
+ if (socket[kIdleSocketValidation] === 0) {
1054
+ scheduleIdleSocketValidation(client, socket)
1055
+ socket[kParser].readMore()
1056
+ if (socket.destroyed) {
1057
+ return
1058
+ }
1059
+ return
1060
+ }
1061
+
1062
+ if (socket[kIdleSocketValidation] === 1) {
1063
+ socket[kParser].readMore()
1064
+ if (socket.destroyed) {
1065
+ return
1066
+ }
1067
+ return
1068
+ }
1069
+ }
1070
+
1071
+ if (client[kRunning] === 0) {
1072
+ socket[kParser].readMore()
1073
+ if (socket.destroyed) {
1074
+ return
1075
+ }
1076
+ }
1077
+
1078
+ if (client[kSize] === 0) {
1079
+ if (socket[kParser].timeoutType !== TIMEOUT_KEEP_ALIVE) {
1080
+ socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_KEEP_ALIVE)
1081
+ }
1082
+ } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) {
1083
+ if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) {
1084
+ const request = client[kQueue][client[kRunningIdx]]
1085
+ const headersTimeout = request.headersTimeout != null
1086
+ ? request.headersTimeout
1087
+ : client[kHeadersTimeout]
1088
+ socket[kParser].setTimeout(headersTimeout, TIMEOUT_HEADERS)
1089
+ }
1090
+ }
1091
+ }
1092
+ }
1093
+
1094
+ // https://www.rfc-editor.org/rfc/rfc7230#section-3.3.2
1095
+ function shouldSendContentLength (method) {
1096
+ return method !== 'GET' && method !== 'HEAD' && method !== 'OPTIONS' && method !== 'TRACE' && method !== 'CONNECT'
1097
+ }
1098
+
1099
+ /**
1100
+ * @param {import('./client.js')} client
1101
+ * @param {import('../core/request.js')} request
1102
+ * @returns
1103
+ */
1104
+ function writeH1 (client, request) {
1105
+ const { method, path, host, upgrade, blocking, reset } = request
1106
+
1107
+ let { body, headers, contentLength } = request
1108
+
1109
+ // https://tools.ietf.org/html/rfc7231#section-4.3.1
1110
+ // https://tools.ietf.org/html/rfc7231#section-4.3.2
1111
+ // https://tools.ietf.org/html/rfc7231#section-4.3.5
1112
+
1113
+ // Sending a payload body on a request that does not
1114
+ // expect it can cause undefined behavior on some
1115
+ // servers and corrupt connection state. Do not
1116
+ // re-use the connection for further requests.
1117
+
1118
+ const expectsPayload = (
1119
+ method === 'PUT' ||
1120
+ method === 'POST' ||
1121
+ method === 'PATCH' ||
1122
+ method === 'QUERY' ||
1123
+ method === 'PROPFIND' ||
1124
+ method === 'PROPPATCH'
1125
+ )
1126
+
1127
+ if (util.isFormDataLike(body)) {
1128
+ if (!extractBody) {
1129
+ extractBody = require('../web/fetch/body.js').extractBody
1130
+ }
1131
+
1132
+ const [bodyStream, contentType] = extractBody(body)
1133
+ if (request.contentType == null) {
1134
+ headers.push('content-type', contentType)
1135
+ }
1136
+ body = bodyStream.stream
1137
+ contentLength = bodyStream.length
1138
+ } else if (util.isBlobLike(body) && request.contentType == null) {
1139
+ const contentType = body.type
1140
+ if (contentType) {
1141
+ const contentTypeValue = `${contentType}`
1142
+ if (!util.isValidHeaderValue(contentTypeValue)) {
1143
+ util.errorRequest(client, request, new InvalidArgumentError('invalid content-type header'))
1144
+ return false
1145
+ }
1146
+ headers.push('content-type', contentTypeValue)
1147
+ }
1148
+ }
1149
+
1150
+ if (body && typeof body.read === 'function') {
1151
+ // Try to read EOF in order to get length.
1152
+ body.read(0)
1153
+ }
1154
+
1155
+ const bodyLength = util.bodyLength(body)
1156
+
1157
+ contentLength = bodyLength ?? contentLength
1158
+
1159
+ if (contentLength === null) {
1160
+ contentLength = request.contentLength
1161
+ }
1162
+
1163
+ if (contentLength === 0 && !expectsPayload) {
1164
+ // https://tools.ietf.org/html/rfc7230#section-3.3.2
1165
+ // A user agent SHOULD NOT send a Content-Length header field when
1166
+ // the request message does not contain a payload body and the method
1167
+ // semantics do not anticipate such a body.
1168
+
1169
+ contentLength = null
1170
+ }
1171
+
1172
+ // https://github.com/nodejs/undici/issues/2046
1173
+ // A user agent may send a Content-Length header with 0 value, this should be allowed.
1174
+ if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength !== null && request.contentLength !== contentLength) {
1175
+ if (client[kStrictContentLength]) {
1176
+ util.errorRequest(client, request, new RequestContentLengthMismatchError())
1177
+ return false
1178
+ }
1179
+
1180
+ process.emitWarning(new RequestContentLengthMismatchError())
1181
+ }
1182
+
1183
+ const socket = client[kSocket]
1184
+ clearIdleSocketValidation(socket)
1185
+
1186
+ /**
1187
+ * @param {Error} [err]
1188
+ * @returns {void}
1189
+ */
1190
+ const abort = (err) => {
1191
+ if (request.aborted || request.completed) {
1192
+ return
1193
+ }
1194
+
1195
+ util.errorRequest(client, request, err || new RequestAbortedError())
1196
+
1197
+ util.destroy(body)
1198
+ util.destroy(socket, new InformationalError('aborted'))
1199
+ }
1200
+
1201
+ try {
1202
+ request.onConnect(abort)
1203
+ } catch (err) {
1204
+ util.errorRequest(client, request, err)
1205
+ }
1206
+
1207
+ if (request.aborted) {
1208
+ return false
1209
+ }
1210
+
1211
+ if (method === 'HEAD') {
1212
+ // https://github.com/mcollina/undici/issues/258
1213
+ // Close after a HEAD request to interop with misbehaving servers
1214
+ // that may send a body in the response.
1215
+
1216
+ socket[kReset] = true
1217
+ }
1218
+
1219
+ if (upgrade || method === 'CONNECT') {
1220
+ // On CONNECT or upgrade, block pipeline from dispatching further
1221
+ // requests on this connection.
1222
+
1223
+ socket[kReset] = true
1224
+ }
1225
+
1226
+ if (reset != null) {
1227
+ socket[kReset] = reset
1228
+ }
1229
+
1230
+ if (client[kMaxRequests] && socket[kCounter]++ >= client[kMaxRequests]) {
1231
+ socket[kReset] = true
1232
+ }
1233
+
1234
+ if (blocking) {
1235
+ socket[kBlocking] = true
1236
+ }
1237
+
1238
+ if (socket.setTypeOfService) {
1239
+ socket.setTypeOfService(request.typeOfService)
1240
+ }
1241
+
1242
+ let header = `${method} ${path} HTTP/1.1\r\n`
1243
+
1244
+ if (typeof host === 'string') {
1245
+ header += `host: ${host}\r\n`
1246
+ } else {
1247
+ header += client[kHostHeader]
1248
+ }
1249
+
1250
+ if (upgrade) {
1251
+ header += `connection: upgrade\r\nupgrade: ${upgrade}\r\n`
1252
+ } else if (client[kPipelining] && !socket[kReset]) {
1253
+ header += 'connection: keep-alive\r\n'
1254
+ } else {
1255
+ header += 'connection: close\r\n'
1256
+ }
1257
+
1258
+ if (Array.isArray(headers)) {
1259
+ for (let n = 0; n < headers.length; n += 2) {
1260
+ const key = headers[n + 0]
1261
+ const val = headers[n + 1]
1262
+
1263
+ if (Array.isArray(val)) {
1264
+ for (let i = 0; i < val.length; i++) {
1265
+ header += `${key}: ${val[i]}\r\n`
1266
+ }
1267
+ } else {
1268
+ header += `${key}: ${val}\r\n`
1269
+ }
1270
+ }
1271
+ }
1272
+
1273
+ if (channels.sendHeaders.hasSubscribers) {
1274
+ channels.sendHeaders.publish({ request, headers: header, socket })
1275
+ }
1276
+
1277
+ if (!body || bodyLength === 0) {
1278
+ writeBuffer(abort, null, client, request, socket, contentLength, header, expectsPayload)
1279
+ } else if (util.isBuffer(body)) {
1280
+ writeBuffer(abort, body, client, request, socket, contentLength, header, expectsPayload)
1281
+ } else if (util.isBlobLike(body)) {
1282
+ if (typeof body.stream === 'function') {
1283
+ writeIterable(abort, body.stream(), client, request, socket, contentLength, header, expectsPayload)
1284
+ } else {
1285
+ writeBlob(abort, body, client, request, socket, contentLength, header, expectsPayload)
1286
+ }
1287
+ } else if (util.isStream(body)) {
1288
+ writeStream(abort, body, client, request, socket, contentLength, header, expectsPayload)
1289
+ } else if (util.isIterable(body)) {
1290
+ writeIterable(abort, body, client, request, socket, contentLength, header, expectsPayload)
1291
+ } else {
1292
+ assert(false)
1293
+ }
1294
+
1295
+ return true
1296
+ }
1297
+
1298
+ /**
1299
+ * @param {AbortCallback} abort
1300
+ * @param {import('stream').Stream} body
1301
+ * @param {import('./client.js')} client
1302
+ * @param {import('../core/request.js')} request
1303
+ * @param {import('net').Socket} socket
1304
+ * @param {number} contentLength
1305
+ * @param {string} header
1306
+ * @param {boolean} expectsPayload
1307
+ */
1308
+ function writeStream (abort, body, client, request, socket, contentLength, header, expectsPayload) {
1309
+ assert(contentLength !== 0 || client[kRunning] === 0, 'stream body cannot be pipelined')
1310
+
1311
+ let finished = false
1312
+
1313
+ const writer = new AsyncWriter({ abort, socket, request, contentLength, client, expectsPayload, header })
1314
+
1315
+ /**
1316
+ * @param {Buffer} chunk
1317
+ * @returns {void}
1318
+ */
1319
+ const onData = function (chunk) {
1320
+ if (finished) {
1321
+ return
1322
+ }
1323
+
1324
+ try {
1325
+ if (!writer.write(chunk) && this.pause) {
1326
+ this.pause()
1327
+ }
1328
+ } catch (err) {
1329
+ util.destroy(this, err)
1330
+ }
1331
+ }
1332
+
1333
+ /**
1334
+ * @returns {void}
1335
+ */
1336
+ const onDrain = function () {
1337
+ if (finished) {
1338
+ return
1339
+ }
1340
+
1341
+ if (body.resume) {
1342
+ body.resume()
1343
+ }
1344
+ }
1345
+
1346
+ /**
1347
+ * @returns {void}
1348
+ */
1349
+ const onClose = function () {
1350
+ // 'close' might be emitted *before* 'error' for
1351
+ // broken streams. Wait a tick to avoid this case.
1352
+ queueMicrotask(() => {
1353
+ // It's only safe to remove 'error' listener after
1354
+ // 'close'.
1355
+ body.removeListener('error', onFinished)
1356
+ })
1357
+
1358
+ if (!finished) {
1359
+ const err = new RequestAbortedError()
1360
+ queueMicrotask(() => onFinished(err))
1361
+ }
1362
+ }
1363
+
1364
+ /**
1365
+ * @param {Error} [err]
1366
+ * @returns
1367
+ */
1368
+ const onFinished = function (err) {
1369
+ if (finished) {
1370
+ return
1371
+ }
1372
+
1373
+ finished = true
1374
+
1375
+ assert(socket.destroyed || (socket[kWriting] && client[kRunning] <= 1))
1376
+
1377
+ socket
1378
+ .off('drain', onDrain)
1379
+ .off('error', onFinished)
1380
+
1381
+ body
1382
+ .removeListener('data', onData)
1383
+ .removeListener('end', onFinished)
1384
+ .removeListener('close', onClose)
1385
+
1386
+ if (!err) {
1387
+ try {
1388
+ writer.end()
1389
+ } catch (er) {
1390
+ err = er
1391
+ }
1392
+ }
1393
+
1394
+ writer.destroy(err)
1395
+
1396
+ if (err && (err.code !== 'UND_ERR_INFO' || err.message !== 'reset')) {
1397
+ util.destroy(body, err)
1398
+ } else {
1399
+ util.destroy(body)
1400
+ }
1401
+ }
1402
+
1403
+ body
1404
+ .on('data', onData)
1405
+ .on('end', onFinished)
1406
+ .on('error', onFinished)
1407
+ .on('close', onClose)
1408
+
1409
+ if (body.resume) {
1410
+ body.resume()
1411
+ }
1412
+
1413
+ socket
1414
+ .on('drain', onDrain)
1415
+ .on('error', onFinished)
1416
+
1417
+ if (body.errorEmitted ?? body.errored) {
1418
+ setImmediate(onFinished, body.errored)
1419
+ } else if (body.endEmitted ?? body.readableEnded) {
1420
+ setImmediate(onFinished, null)
1421
+ }
1422
+
1423
+ if (body.closeEmitted ?? body.closed) {
1424
+ setImmediate(onClose)
1425
+ }
1426
+ }
1427
+
1428
+ /**
1429
+ * @typedef AbortCallback
1430
+ * @type {Function}
1431
+ * @param {Error} [err]
1432
+ * @returns {void}
1433
+ */
1434
+
1435
+ /**
1436
+ * @param {AbortCallback} abort
1437
+ * @param {Uint8Array|null} body
1438
+ * @param {import('./client.js')} client
1439
+ * @param {import('../core/request.js')} request
1440
+ * @param {import('net').Socket} socket
1441
+ * @param {number} contentLength
1442
+ * @param {string} header
1443
+ * @param {boolean} expectsPayload
1444
+ * @returns {void}
1445
+ */
1446
+ function writeBuffer (abort, body, client, request, socket, contentLength, header, expectsPayload) {
1447
+ try {
1448
+ if (!body) {
1449
+ if (contentLength === 0) {
1450
+ socket.write(`${header}content-length: 0\r\n\r\n`, 'latin1')
1451
+ } else {
1452
+ assert(contentLength === null, 'no body must not have content length')
1453
+ socket.write(`${header}\r\n`, 'latin1')
1454
+ }
1455
+ } else if (util.isBuffer(body)) {
1456
+ assert(contentLength === body.byteLength, 'buffer body must have content length')
1457
+
1458
+ socket.cork()
1459
+ socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1')
1460
+ socket.write(body)
1461
+ socket.uncork()
1462
+ request.onBodySent(body)
1463
+
1464
+ if (!expectsPayload && request.reset !== false) {
1465
+ socket[kReset] = true
1466
+ }
1467
+ }
1468
+ request.onRequestSent()
1469
+
1470
+ client[kResume]()
1471
+ } catch (err) {
1472
+ abort(err)
1473
+ }
1474
+ }
1475
+
1476
+ /**
1477
+ * @param {AbortCallback} abort
1478
+ * @param {Blob} body
1479
+ * @param {import('./client.js')} client
1480
+ * @param {import('../core/request.js')} request
1481
+ * @param {import('net').Socket} socket
1482
+ * @param {number} contentLength
1483
+ * @param {string} header
1484
+ * @param {boolean} expectsPayload
1485
+ * @returns {Promise<void>}
1486
+ */
1487
+ async function writeBlob (abort, body, client, request, socket, contentLength, header, expectsPayload) {
1488
+ assert(contentLength === body.size, 'blob body must have content length')
1489
+
1490
+ try {
1491
+ if (contentLength != null && contentLength !== body.size) {
1492
+ throw new RequestContentLengthMismatchError()
1493
+ }
1494
+
1495
+ const buffer = Buffer.from(await body.arrayBuffer())
1496
+
1497
+ socket.cork()
1498
+ socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1')
1499
+ socket.write(buffer)
1500
+ socket.uncork()
1501
+
1502
+ request.onBodySent(buffer)
1503
+ request.onRequestSent()
1504
+
1505
+ if (!expectsPayload && request.reset !== false) {
1506
+ socket[kReset] = true
1507
+ }
1508
+
1509
+ client[kResume]()
1510
+ } catch (err) {
1511
+ abort(err)
1512
+ }
1513
+ }
1514
+
1515
+ /**
1516
+ * @param {AbortCallback} abort
1517
+ * @param {Iterable} body
1518
+ * @param {import('./client.js')} client
1519
+ * @param {import('../core/request.js')} request
1520
+ * @param {import('net').Socket} socket
1521
+ * @param {number} contentLength
1522
+ * @param {string} header
1523
+ * @param {boolean} expectsPayload
1524
+ * @returns {Promise<void>}
1525
+ */
1526
+ async function writeIterable (abort, body, client, request, socket, contentLength, header, expectsPayload) {
1527
+ assert(contentLength !== 0 || client[kRunning] === 0, 'iterator body cannot be pipelined')
1528
+
1529
+ let callback = null
1530
+ function onDrain () {
1531
+ if (callback) {
1532
+ const cb = callback
1533
+ callback = null
1534
+ cb()
1535
+ }
1536
+ }
1537
+
1538
+ const waitForDrain = () => new Promise((resolve, reject) => {
1539
+ assert(callback === null)
1540
+
1541
+ if (socket[kError]) {
1542
+ reject(socket[kError])
1543
+ } else {
1544
+ callback = resolve
1545
+ }
1546
+ })
1547
+
1548
+ socket
1549
+ .on('close', onDrain)
1550
+ .on('drain', onDrain)
1551
+
1552
+ const writer = new AsyncWriter({ abort, socket, request, contentLength, client, expectsPayload, header })
1553
+ try {
1554
+ // It's up to the user to somehow abort the async iterable.
1555
+ for await (const chunk of body) {
1556
+ if (socket[kError]) {
1557
+ throw socket[kError]
1558
+ }
1559
+
1560
+ if (!writer.write(chunk)) {
1561
+ await waitForDrain()
1562
+ }
1563
+ }
1564
+
1565
+ writer.end()
1566
+ } catch (err) {
1567
+ writer.destroy(err)
1568
+ } finally {
1569
+ socket
1570
+ .off('close', onDrain)
1571
+ .off('drain', onDrain)
1572
+ }
1573
+ }
1574
+
1575
+ class AsyncWriter {
1576
+ /**
1577
+ *
1578
+ * @param {object} arg
1579
+ * @param {AbortCallback} arg.abort
1580
+ * @param {import('net').Socket} arg.socket
1581
+ * @param {import('../core/request.js')} arg.request
1582
+ * @param {number} arg.contentLength
1583
+ * @param {import('./client.js')} arg.client
1584
+ * @param {boolean} arg.expectsPayload
1585
+ * @param {string} arg.header
1586
+ */
1587
+ constructor ({ abort, socket, request, contentLength, client, expectsPayload, header }) {
1588
+ this.socket = socket
1589
+ this.request = request
1590
+ this.contentLength = contentLength
1591
+ this.client = client
1592
+ this.bytesWritten = 0
1593
+ this.expectsPayload = expectsPayload
1594
+ this.header = header
1595
+ this.abort = abort
1596
+
1597
+ socket[kWriting] = true
1598
+ }
1599
+
1600
+ /**
1601
+ * @param {Buffer} chunk
1602
+ * @returns
1603
+ */
1604
+ write (chunk) {
1605
+ const { socket, request, contentLength, client, bytesWritten, expectsPayload, header } = this
1606
+
1607
+ if (socket[kError]) {
1608
+ throw socket[kError]
1609
+ }
1610
+
1611
+ if (socket.destroyed) {
1612
+ return false
1613
+ }
1614
+
1615
+ const len = Buffer.byteLength(chunk)
1616
+ if (!len) {
1617
+ return true
1618
+ }
1619
+
1620
+ // We should defer writing chunks.
1621
+ if (contentLength !== null && bytesWritten + len > contentLength) {
1622
+ if (client[kStrictContentLength]) {
1623
+ throw new RequestContentLengthMismatchError()
1624
+ }
1625
+
1626
+ process.emitWarning(new RequestContentLengthMismatchError())
1627
+ }
1628
+
1629
+ socket.cork()
1630
+
1631
+ if (bytesWritten === 0) {
1632
+ if (!expectsPayload && request.reset !== false) {
1633
+ socket[kReset] = true
1634
+ }
1635
+
1636
+ if (contentLength === null) {
1637
+ socket.write(`${header}transfer-encoding: chunked\r\n`, 'latin1')
1638
+ } else {
1639
+ socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1')
1640
+ }
1641
+ }
1642
+
1643
+ if (contentLength === null) {
1644
+ socket.write(`\r\n${len.toString(16)}\r\n`, 'latin1')
1645
+ }
1646
+
1647
+ this.bytesWritten += len
1648
+
1649
+ const ret = socket.write(chunk)
1650
+
1651
+ socket.uncork()
1652
+
1653
+ request.onBodySent(chunk)
1654
+
1655
+ if (!ret) {
1656
+ if (socket[kParser].timeout && socket[kParser].timeoutType === TIMEOUT_HEADERS) {
1657
+ if (socket[kParser].timeout.refresh) {
1658
+ socket[kParser].timeout.refresh()
1659
+ }
1660
+ }
1661
+ }
1662
+
1663
+ return ret
1664
+ }
1665
+
1666
+ /**
1667
+ * @returns {void}
1668
+ */
1669
+ end () {
1670
+ const { socket, contentLength, client, bytesWritten, expectsPayload, header, request } = this
1671
+ request.onRequestSent()
1672
+
1673
+ socket[kWriting] = false
1674
+
1675
+ if (socket[kError]) {
1676
+ throw socket[kError]
1677
+ }
1678
+
1679
+ if (socket.destroyed) {
1680
+ return
1681
+ }
1682
+
1683
+ if (bytesWritten === 0) {
1684
+ if (expectsPayload) {
1685
+ // https://tools.ietf.org/html/rfc7230#section-3.3.2
1686
+ // A user agent SHOULD send a Content-Length in a request message when
1687
+ // no Transfer-Encoding is sent and the request method defines a meaning
1688
+ // for an enclosed payload body.
1689
+
1690
+ socket.write(`${header}content-length: 0\r\n\r\n`, 'latin1')
1691
+ } else {
1692
+ socket.write(`${header}\r\n`, 'latin1')
1693
+ }
1694
+ } else if (contentLength === null) {
1695
+ socket.write('\r\n0\r\n\r\n', 'latin1')
1696
+ }
1697
+
1698
+ if (contentLength !== null && bytesWritten !== contentLength) {
1699
+ if (client[kStrictContentLength]) {
1700
+ throw new RequestContentLengthMismatchError()
1701
+ } else {
1702
+ process.emitWarning(new RequestContentLengthMismatchError())
1703
+ }
1704
+ }
1705
+
1706
+ if (socket[kParser].timeout && socket[kParser].timeoutType === TIMEOUT_HEADERS) {
1707
+ if (socket[kParser].timeout.refresh) {
1708
+ socket[kParser].timeout.refresh()
1709
+ }
1710
+ }
1711
+
1712
+ client[kResume]()
1713
+ }
1714
+
1715
+ /**
1716
+ * @param {Error} [err]
1717
+ * @returns {void}
1718
+ */
1719
+ destroy (err) {
1720
+ const { socket, client, abort } = this
1721
+
1722
+ socket[kWriting] = false
1723
+
1724
+ if (err) {
1725
+ assert(client[kRunning] <= 1, 'pipeline should only contain this request')
1726
+ abort(err)
1727
+ }
1728
+ }
1729
+ }
1730
+
1731
+ module.exports = connectH1