@jointhedots/gear 1.0.21 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (334) hide show
  1. package/browser-modules/asap-raw.js +79 -0
  2. package/browser-modules/asap.js +57 -0
  3. package/browser-modules/buffer.js +3 -1
  4. package/browser-modules/child_process.js +145 -0
  5. package/browser-modules/events.js +200 -0
  6. package/browser-modules/side-effects.js +8 -0
  7. package/browser-modules/stream.js +323 -0
  8. package/browser-modules/util.js +170 -0
  9. package/browser-modules/worker_threads.js +85 -0
  10. package/esm/builder/build-app-bundle.js +190 -0
  11. package/esm/builder/build-app-bundle.js.map +1 -0
  12. package/esm/builder/build-app-host.js +173 -0
  13. package/esm/builder/build-app-host.js.map +1 -0
  14. package/esm/builder/build-application.js +233 -71
  15. package/esm/builder/build-application.js.map +1 -1
  16. package/esm/builder/build-library.js +29 -39
  17. package/esm/builder/build-library.js.map +1 -1
  18. package/esm/builder/build-target.js +63 -105
  19. package/esm/builder/build-target.js.map +1 -1
  20. package/esm/builder/emit-dts.js +110 -87
  21. package/esm/builder/emit-dts.js.map +1 -1
  22. package/esm/builder/esbuild-plugins.js +182 -59
  23. package/esm/builder/esbuild-plugins.js.map +1 -1
  24. package/esm/builder/helpers/path-helpers.js +95 -0
  25. package/esm/builder/helpers/path-helpers.js.map +1 -0
  26. package/esm/cli.js +0 -1
  27. package/esm/cli.js.map +1 -1
  28. package/esm/commands/init.js +1 -0
  29. package/esm/commands/init.js.map +1 -1
  30. package/esm/commands/make.js +52 -9
  31. package/esm/commands/make.js.map +1 -1
  32. package/esm/commands/publish.js +1 -0
  33. package/esm/commands/publish.js.map +1 -1
  34. package/esm/commands/run.js +1 -0
  35. package/esm/commands/run.js.map +1 -1
  36. package/esm/commands/serve.js +42 -9
  37. package/esm/commands/serve.js.map +1 -1
  38. package/esm/model/component.js +6 -11
  39. package/esm/model/component.js.map +1 -1
  40. package/esm/model/helpers/create-manifests.js +69 -0
  41. package/esm/model/helpers/create-manifests.js.map +1 -0
  42. package/esm/model/helpers/discover-workspace.js +258 -0
  43. package/esm/model/helpers/discover-workspace.js.map +1 -0
  44. package/esm/model/helpers/logger.js +116 -0
  45. package/esm/model/helpers/logger.js.map +1 -0
  46. package/esm/model/storage.js +82 -24
  47. package/esm/model/storage.js.map +1 -1
  48. package/esm/model/workspace.js +107 -148
  49. package/esm/model/workspace.js.map +1 -1
  50. package/esm/publish/publish_aws_s3.js +1 -0
  51. package/esm/publish/publish_aws_s3.js.map +1 -1
  52. package/esm/utils/file.js +37 -6
  53. package/esm/utils/file.js.map +1 -1
  54. package/esm/utils/graph-ordering.js +86 -0
  55. package/esm/utils/graph-ordering.js.map +1 -0
  56. package/esm/utils/normalized-name.js +94 -0
  57. package/esm/utils/normalized-name.js.map +1 -0
  58. package/node_modules/@jspm/core/.github/workflows/ci.yml +64 -0
  59. package/node_modules/@jspm/core/LICENSE +796 -0
  60. package/node_modules/@jspm/core/README.md +11 -0
  61. package/node_modules/@jspm/core/chompfile.toml +28 -0
  62. package/node_modules/@jspm/core/generate-node-libs.mjs +10 -0
  63. package/node_modules/@jspm/core/nodelibs/@empty.dew.js +7 -0
  64. package/node_modules/@jspm/core/nodelibs/@empty.js +3 -0
  65. package/node_modules/@jspm/core/nodelibs/browser/_stream_duplex.js +13 -0
  66. package/node_modules/@jspm/core/nodelibs/browser/_stream_passthrough.js +12 -0
  67. package/node_modules/@jspm/core/nodelibs/browser/_stream_readable.js +14 -0
  68. package/node_modules/@jspm/core/nodelibs/browser/_stream_transform.js +12 -0
  69. package/node_modules/@jspm/core/nodelibs/browser/_stream_writable.js +13 -0
  70. package/node_modules/@jspm/core/nodelibs/browser/assert/strict.js +29 -0
  71. package/node_modules/@jspm/core/nodelibs/browser/assert.js +2574 -0
  72. package/node_modules/@jspm/core/nodelibs/browser/async_hooks.js +14 -0
  73. package/node_modules/@jspm/core/nodelibs/browser/buffer.js +10 -0
  74. package/node_modules/@jspm/core/nodelibs/browser/child_process.js +17 -0
  75. package/node_modules/@jspm/core/nodelibs/browser/chunk-B6-G-Ftj.js +158 -0
  76. package/node_modules/@jspm/core/nodelibs/browser/chunk-B738Er4n.js +5524 -0
  77. package/node_modules/@jspm/core/nodelibs/browser/chunk-BlJi4mNy.js +448 -0
  78. package/node_modules/@jspm/core/nodelibs/browser/chunk-BsRZ0PEC.js +74 -0
  79. package/node_modules/@jspm/core/nodelibs/browser/chunk-C4rKjYLo.js +20 -0
  80. package/node_modules/@jspm/core/nodelibs/browser/chunk-CbQqNoLO.js +32 -0
  81. package/node_modules/@jspm/core/nodelibs/browser/chunk-CcCWfKp1.js +360 -0
  82. package/node_modules/@jspm/core/nodelibs/browser/chunk-CjPlbOtt.js +47 -0
  83. package/node_modules/@jspm/core/nodelibs/browser/chunk-CkFCi-G1.js +36 -0
  84. package/node_modules/@jspm/core/nodelibs/browser/chunk-D3uu3VYh.js +33 -0
  85. package/node_modules/@jspm/core/nodelibs/browser/chunk-DEMDiNwt.js +275 -0
  86. package/node_modules/@jspm/core/nodelibs/browser/chunk-DHWh-hmB.js +1344 -0
  87. package/node_modules/@jspm/core/nodelibs/browser/chunk-DtDiafJB.js +96 -0
  88. package/node_modules/@jspm/core/nodelibs/browser/chunk-DtcTpLWz.js +826 -0
  89. package/node_modules/@jspm/core/nodelibs/browser/chunk-DtuTasat.js +1923 -0
  90. package/node_modules/@jspm/core/nodelibs/browser/chunk-b0rmRow7.js +246 -0
  91. package/node_modules/@jspm/core/nodelibs/browser/chunk-tHuMsdT0.js +8 -0
  92. package/node_modules/@jspm/core/nodelibs/browser/cluster.js +33 -0
  93. package/node_modules/@jspm/core/nodelibs/browser/console.js +103 -0
  94. package/node_modules/@jspm/core/nodelibs/browser/constants.js +419 -0
  95. package/node_modules/@jspm/core/nodelibs/browser/crypto.js +109730 -0
  96. package/node_modules/@jspm/core/nodelibs/browser/dgram.js +11 -0
  97. package/node_modules/@jspm/core/nodelibs/browser/diagnostics_channel.js +153 -0
  98. package/node_modules/@jspm/core/nodelibs/browser/dns/promises.js +26 -0
  99. package/node_modules/@jspm/core/nodelibs/browser/dns.js +101 -0
  100. package/node_modules/@jspm/core/nodelibs/browser/domain.js +77 -0
  101. package/node_modules/@jspm/core/nodelibs/browser/events.js +491 -0
  102. package/node_modules/@jspm/core/nodelibs/browser/fs/promises.js +50 -0
  103. package/node_modules/@jspm/core/nodelibs/browser/fs.js +4139 -0
  104. package/node_modules/@jspm/core/nodelibs/browser/http.js +3513 -0
  105. package/node_modules/@jspm/core/nodelibs/browser/http2.js +88 -0
  106. package/node_modules/@jspm/core/nodelibs/browser/https.js +873 -0
  107. package/node_modules/@jspm/core/nodelibs/browser/module.js +58 -0
  108. package/node_modules/@jspm/core/nodelibs/browser/net.js +20 -0
  109. package/node_modules/@jspm/core/nodelibs/browser/os.js +94 -0
  110. package/node_modules/@jspm/core/nodelibs/browser/path/posix.js +40 -0
  111. package/node_modules/@jspm/core/nodelibs/browser/path/win32.js +27 -0
  112. package/node_modules/@jspm/core/nodelibs/browser/path.js +20 -0
  113. package/node_modules/@jspm/core/nodelibs/browser/perf_hooks.js +30 -0
  114. package/node_modules/@jspm/core/nodelibs/browser/process-production.js +274 -0
  115. package/node_modules/@jspm/core/nodelibs/browser/process.js +277 -0
  116. package/node_modules/@jspm/core/nodelibs/browser/punycode.js +436 -0
  117. package/node_modules/@jspm/core/nodelibs/browser/querystring.js +118 -0
  118. package/node_modules/@jspm/core/nodelibs/browser/readline.js +15 -0
  119. package/node_modules/@jspm/core/nodelibs/browser/repl.js +21 -0
  120. package/node_modules/@jspm/core/nodelibs/browser/stream/consumers.js +61 -0
  121. package/node_modules/@jspm/core/nodelibs/browser/stream/promises.js +12 -0
  122. package/node_modules/@jspm/core/nodelibs/browser/stream/web.js +35 -0
  123. package/node_modules/@jspm/core/nodelibs/browser/stream.js +6574 -0
  124. package/node_modules/@jspm/core/nodelibs/browser/string_decoder.js +2 -0
  125. package/node_modules/@jspm/core/nodelibs/browser/sys.js +9 -0
  126. package/node_modules/@jspm/core/nodelibs/browser/timers/promises.js +17 -0
  127. package/node_modules/@jspm/core/nodelibs/browser/timers.js +256 -0
  128. package/node_modules/@jspm/core/nodelibs/browser/tls.js +34 -0
  129. package/node_modules/@jspm/core/nodelibs/browser/tty.js +20 -0
  130. package/node_modules/@jspm/core/nodelibs/browser/url.js +2361 -0
  131. package/node_modules/@jspm/core/nodelibs/browser/util/types.js +51 -0
  132. package/node_modules/@jspm/core/nodelibs/browser/util.js +1345 -0
  133. package/node_modules/@jspm/core/nodelibs/browser/v8.js +21 -0
  134. package/node_modules/@jspm/core/nodelibs/browser/vm.js +139 -0
  135. package/node_modules/@jspm/core/nodelibs/browser/wasi.js +160 -0
  136. package/node_modules/@jspm/core/nodelibs/browser/worker_threads.js +140 -0
  137. package/node_modules/@jspm/core/nodelibs/browser/zlib.js +6545 -0
  138. package/node_modules/@jspm/core/nodelibs/deno/_stream_duplex.ts +5 -0
  139. package/node_modules/@jspm/core/nodelibs/deno/_stream_passthrough.ts +1 -0
  140. package/node_modules/@jspm/core/nodelibs/deno/_stream_readable.ts +5 -0
  141. package/node_modules/@jspm/core/nodelibs/deno/_stream_transform.ts +1 -0
  142. package/node_modules/@jspm/core/nodelibs/deno/_stream_writable.ts +5 -0
  143. package/node_modules/@jspm/core/nodelibs/deno/assert/strict.ts +2 -0
  144. package/node_modules/@jspm/core/nodelibs/deno/assert.ts +2 -0
  145. package/node_modules/@jspm/core/nodelibs/deno/async_hooks.ts +2 -0
  146. package/node_modules/@jspm/core/nodelibs/deno/buffer.ts +5 -0
  147. package/node_modules/@jspm/core/nodelibs/deno/child_process.ts +2 -0
  148. package/node_modules/@jspm/core/nodelibs/deno/cluster.ts +2 -0
  149. package/node_modules/@jspm/core/nodelibs/deno/console.ts +2 -0
  150. package/node_modules/@jspm/core/nodelibs/deno/constants.ts +2 -0
  151. package/node_modules/@jspm/core/nodelibs/deno/crypto.ts +2 -0
  152. package/node_modules/@jspm/core/nodelibs/deno/dgram.ts +2 -0
  153. package/node_modules/@jspm/core/nodelibs/deno/diagnostics_channel.ts +2 -0
  154. package/node_modules/@jspm/core/nodelibs/deno/dns/promises.ts +2 -0
  155. package/node_modules/@jspm/core/nodelibs/deno/dns.ts +2 -0
  156. package/node_modules/@jspm/core/nodelibs/deno/domain.ts +2 -0
  157. package/node_modules/@jspm/core/nodelibs/deno/events.ts +2 -0
  158. package/node_modules/@jspm/core/nodelibs/deno/fs/promises.ts +2 -0
  159. package/node_modules/@jspm/core/nodelibs/deno/fs.ts +2 -0
  160. package/node_modules/@jspm/core/nodelibs/deno/http.ts +2 -0
  161. package/node_modules/@jspm/core/nodelibs/deno/http2.ts +2 -0
  162. package/node_modules/@jspm/core/nodelibs/deno/https.ts +2 -0
  163. package/node_modules/@jspm/core/nodelibs/deno/inspector.ts +2 -0
  164. package/node_modules/@jspm/core/nodelibs/deno/module.ts +2 -0
  165. package/node_modules/@jspm/core/nodelibs/deno/net.ts +2 -0
  166. package/node_modules/@jspm/core/nodelibs/deno/os.ts +2 -0
  167. package/node_modules/@jspm/core/nodelibs/deno/path/posix.ts +2 -0
  168. package/node_modules/@jspm/core/nodelibs/deno/path/win32.ts +2 -0
  169. package/node_modules/@jspm/core/nodelibs/deno/path.ts +2 -0
  170. package/node_modules/@jspm/core/nodelibs/deno/perf_hooks.ts +2 -0
  171. package/node_modules/@jspm/core/nodelibs/deno/process-production.ts +4 -0
  172. package/node_modules/@jspm/core/nodelibs/deno/process.ts +2 -0
  173. package/node_modules/@jspm/core/nodelibs/deno/punycode.ts +2 -0
  174. package/node_modules/@jspm/core/nodelibs/deno/querystring.ts +2 -0
  175. package/node_modules/@jspm/core/nodelibs/deno/readline/promises.ts +2 -0
  176. package/node_modules/@jspm/core/nodelibs/deno/readline.ts +2 -0
  177. package/node_modules/@jspm/core/nodelibs/deno/repl.ts +2 -0
  178. package/node_modules/@jspm/core/nodelibs/deno/stream/consumers.ts +2 -0
  179. package/node_modules/@jspm/core/nodelibs/deno/stream/promises.ts +2 -0
  180. package/node_modules/@jspm/core/nodelibs/deno/stream/web.ts +2 -0
  181. package/node_modules/@jspm/core/nodelibs/deno/stream.ts +2 -0
  182. package/node_modules/@jspm/core/nodelibs/deno/string_decoder.ts +2 -0
  183. package/node_modules/@jspm/core/nodelibs/deno/timers/promises.ts +2 -0
  184. package/node_modules/@jspm/core/nodelibs/deno/timers.ts +2 -0
  185. package/node_modules/@jspm/core/nodelibs/deno/tls.ts +2 -0
  186. package/node_modules/@jspm/core/nodelibs/deno/tty.ts +2 -0
  187. package/node_modules/@jspm/core/nodelibs/deno/url.ts +2 -0
  188. package/node_modules/@jspm/core/nodelibs/deno/util/types.ts +2 -0
  189. package/node_modules/@jspm/core/nodelibs/deno/util.ts +2 -0
  190. package/node_modules/@jspm/core/nodelibs/deno/v8.ts +2 -0
  191. package/node_modules/@jspm/core/nodelibs/deno/vm.ts +2 -0
  192. package/node_modules/@jspm/core/nodelibs/deno/wasi.ts +2 -0
  193. package/node_modules/@jspm/core/nodelibs/deno/worker_threads.ts +2 -0
  194. package/node_modules/@jspm/core/nodelibs/deno/zlib.ts +2 -0
  195. package/node_modules/@jspm/core/nodelibs/node/_http_agent.js +2 -0
  196. package/node_modules/@jspm/core/nodelibs/node/_http_client.js +2 -0
  197. package/node_modules/@jspm/core/nodelibs/node/_http_common.js +2 -0
  198. package/node_modules/@jspm/core/nodelibs/node/_http_incoming.js +2 -0
  199. package/node_modules/@jspm/core/nodelibs/node/_http_outgoing.js +2 -0
  200. package/node_modules/@jspm/core/nodelibs/node/_http_server.js +2 -0
  201. package/node_modules/@jspm/core/nodelibs/node/_stream_duplex.js +2 -0
  202. package/node_modules/@jspm/core/nodelibs/node/_stream_passthrough.js +2 -0
  203. package/node_modules/@jspm/core/nodelibs/node/_stream_readable.js +2 -0
  204. package/node_modules/@jspm/core/nodelibs/node/_stream_transform.js +2 -0
  205. package/node_modules/@jspm/core/nodelibs/node/_stream_wrap.js +2 -0
  206. package/node_modules/@jspm/core/nodelibs/node/_stream_writable.js +2 -0
  207. package/node_modules/@jspm/core/nodelibs/node/_tls_common.js +2 -0
  208. package/node_modules/@jspm/core/nodelibs/node/_tls_wrap.js +2 -0
  209. package/node_modules/@jspm/core/nodelibs/node/assert/strict.js +2 -0
  210. package/node_modules/@jspm/core/nodelibs/node/assert.js +2 -0
  211. package/node_modules/@jspm/core/nodelibs/node/async_hooks.js +2 -0
  212. package/node_modules/@jspm/core/nodelibs/node/buffer.js +2 -0
  213. package/node_modules/@jspm/core/nodelibs/node/child_process.js +2 -0
  214. package/node_modules/@jspm/core/nodelibs/node/cluster.js +2 -0
  215. package/node_modules/@jspm/core/nodelibs/node/console.js +2 -0
  216. package/node_modules/@jspm/core/nodelibs/node/constants.js +2 -0
  217. package/node_modules/@jspm/core/nodelibs/node/crypto.js +2 -0
  218. package/node_modules/@jspm/core/nodelibs/node/dgram.js +2 -0
  219. package/node_modules/@jspm/core/nodelibs/node/diagnostics_channel.js +2 -0
  220. package/node_modules/@jspm/core/nodelibs/node/dns/promises.js +2 -0
  221. package/node_modules/@jspm/core/nodelibs/node/dns.js +2 -0
  222. package/node_modules/@jspm/core/nodelibs/node/domain.js +2 -0
  223. package/node_modules/@jspm/core/nodelibs/node/events.js +2 -0
  224. package/node_modules/@jspm/core/nodelibs/node/fs/promises.js +2 -0
  225. package/node_modules/@jspm/core/nodelibs/node/fs.js +2 -0
  226. package/node_modules/@jspm/core/nodelibs/node/http.js +2 -0
  227. package/node_modules/@jspm/core/nodelibs/node/http2.js +2 -0
  228. package/node_modules/@jspm/core/nodelibs/node/https.js +2 -0
  229. package/node_modules/@jspm/core/nodelibs/node/inspector/promises.js +2 -0
  230. package/node_modules/@jspm/core/nodelibs/node/inspector.js +2 -0
  231. package/node_modules/@jspm/core/nodelibs/node/module.js +2 -0
  232. package/node_modules/@jspm/core/nodelibs/node/net.js +2 -0
  233. package/node_modules/@jspm/core/nodelibs/node/os.js +2 -0
  234. package/node_modules/@jspm/core/nodelibs/node/path/posix.js +2 -0
  235. package/node_modules/@jspm/core/nodelibs/node/path/win32.js +2 -0
  236. package/node_modules/@jspm/core/nodelibs/node/path.js +2 -0
  237. package/node_modules/@jspm/core/nodelibs/node/perf_hooks.js +2 -0
  238. package/node_modules/@jspm/core/nodelibs/node/process-production.js +4 -0
  239. package/node_modules/@jspm/core/nodelibs/node/process.js +2 -0
  240. package/node_modules/@jspm/core/nodelibs/node/punycode.js +2 -0
  241. package/node_modules/@jspm/core/nodelibs/node/querystring.js +2 -0
  242. package/node_modules/@jspm/core/nodelibs/node/readline/promises.js +2 -0
  243. package/node_modules/@jspm/core/nodelibs/node/readline.js +2 -0
  244. package/node_modules/@jspm/core/nodelibs/node/repl.js +2 -0
  245. package/node_modules/@jspm/core/nodelibs/node/stream/consumers.js +2 -0
  246. package/node_modules/@jspm/core/nodelibs/node/stream/promises.js +2 -0
  247. package/node_modules/@jspm/core/nodelibs/node/stream/web.js +2 -0
  248. package/node_modules/@jspm/core/nodelibs/node/stream.js +2 -0
  249. package/node_modules/@jspm/core/nodelibs/node/string_decoder.js +2 -0
  250. package/node_modules/@jspm/core/nodelibs/node/sys.js +2 -0
  251. package/node_modules/@jspm/core/nodelibs/node/timers/promises.js +2 -0
  252. package/node_modules/@jspm/core/nodelibs/node/timers.js +2 -0
  253. package/node_modules/@jspm/core/nodelibs/node/tls.js +2 -0
  254. package/node_modules/@jspm/core/nodelibs/node/trace_events.js +2 -0
  255. package/node_modules/@jspm/core/nodelibs/node/tty.js +2 -0
  256. package/node_modules/@jspm/core/nodelibs/node/url.js +2 -0
  257. package/node_modules/@jspm/core/nodelibs/node/util/types.js +2 -0
  258. package/node_modules/@jspm/core/nodelibs/node/util.js +2 -0
  259. package/node_modules/@jspm/core/nodelibs/node/v8.js +2 -0
  260. package/node_modules/@jspm/core/nodelibs/node/vm.js +2 -0
  261. package/node_modules/@jspm/core/nodelibs/node/wasi.js +2 -0
  262. package/node_modules/@jspm/core/nodelibs/node/worker_threads.js +2 -0
  263. package/node_modules/@jspm/core/nodelibs/node/zlib.js +2 -0
  264. package/node_modules/@jspm/core/package.json +75 -0
  265. package/node_modules/@jspm/core/rollup.config.mjs +55 -0
  266. package/node_modules/@jspm/core/src-browser/__tty.js +11 -0
  267. package/node_modules/@jspm/core/src-browser/_stream_duplex.js +3 -0
  268. package/node_modules/@jspm/core/src-browser/_stream_passthrough.js +2 -0
  269. package/node_modules/@jspm/core/src-browser/_stream_readable.js +5 -0
  270. package/node_modules/@jspm/core/src-browser/_stream_transform.js +2 -0
  271. package/node_modules/@jspm/core/src-browser/_stream_writable.js +3 -0
  272. package/node_modules/@jspm/core/src-browser/assert/strict.js +26 -0
  273. package/node_modules/@jspm/core/src-browser/assert.js +19 -0
  274. package/node_modules/@jspm/core/src-browser/async_hooks.js +21 -0
  275. package/node_modules/@jspm/core/src-browser/buffer.js +5 -0
  276. package/node_modules/@jspm/core/src-browser/child_process.js +27 -0
  277. package/node_modules/@jspm/core/src-browser/cluster.js +38 -0
  278. package/node_modules/@jspm/core/src-browser/console.js +25 -0
  279. package/node_modules/@jspm/core/src-browser/constants.js +209 -0
  280. package/node_modules/@jspm/core/src-browser/crypto.js +63 -0
  281. package/node_modules/@jspm/core/src-browser/dgram.js +15 -0
  282. package/node_modules/@jspm/core/src-browser/diagnostics_channel.js +6 -0
  283. package/node_modules/@jspm/core/src-browser/dns/promises.js +45 -0
  284. package/node_modules/@jspm/core/src-browser/dns.js +121 -0
  285. package/node_modules/@jspm/core/src-browser/domain.js +4 -0
  286. package/node_modules/@jspm/core/src-browser/events.js +105 -0
  287. package/node_modules/@jspm/core/src-browser/fs/promises.js +34 -0
  288. package/node_modules/@jspm/core/src-browser/fs.js +209 -0
  289. package/node_modules/@jspm/core/src-browser/http.js +10 -0
  290. package/node_modules/@jspm/core/src-browser/http2.js +86 -0
  291. package/node_modules/@jspm/core/src-browser/https.js +10 -0
  292. package/node_modules/@jspm/core/src-browser/module.js +75 -0
  293. package/node_modules/@jspm/core/src-browser/net.js +33 -0
  294. package/node_modules/@jspm/core/src-browser/os.js +35 -0
  295. package/node_modules/@jspm/core/src-browser/path/posix.js +38 -0
  296. package/node_modules/@jspm/core/src-browser/path/win32.js +42 -0
  297. package/node_modules/@jspm/core/src-browser/path.js +17 -0
  298. package/node_modules/@jspm/core/src-browser/perf_hooks.js +30 -0
  299. package/node_modules/@jspm/core/src-browser/process-production.js +279 -0
  300. package/node_modules/@jspm/core/src-browser/process.js +282 -0
  301. package/node_modules/@jspm/core/src-browser/punycode.js +8 -0
  302. package/node_modules/@jspm/core/src-browser/querystring.js +6 -0
  303. package/node_modules/@jspm/core/src-browser/readline.js +23 -0
  304. package/node_modules/@jspm/core/src-browser/repl.js +26 -0
  305. package/node_modules/@jspm/core/src-browser/stream/consumers.js +57 -0
  306. package/node_modules/@jspm/core/src-browser/stream/promises.js +4 -0
  307. package/node_modules/@jspm/core/src-browser/stream/web.js +33 -0
  308. package/node_modules/@jspm/core/src-browser/stream.js +26 -0
  309. package/node_modules/@jspm/core/src-browser/string_decoder.js +3 -0
  310. package/node_modules/@jspm/core/src-browser/sys.js +3 -0
  311. package/node_modules/@jspm/core/src-browser/timers/promises.js +12 -0
  312. package/node_modules/@jspm/core/src-browser/timers.js +13 -0
  313. package/node_modules/@jspm/core/src-browser/tls.js +46 -0
  314. package/node_modules/@jspm/core/src-browser/tty.js +3 -0
  315. package/node_modules/@jspm/core/src-browser/url.js +154 -0
  316. package/node_modules/@jspm/core/src-browser/util/types.js +48 -0
  317. package/node_modules/@jspm/core/src-browser/util.js +30 -0
  318. package/node_modules/@jspm/core/src-browser/v8.js +35 -0
  319. package/node_modules/@jspm/core/src-browser/vm.js +9 -0
  320. package/node_modules/@jspm/core/src-browser/wasi.js +15 -0
  321. package/node_modules/@jspm/core/src-browser/worker_threads.js +139 -0
  322. package/node_modules/@jspm/core/src-browser/zlib.js +71 -0
  323. package/node_modules/@jspm/core/test/chrome-worker_threads.test.js +14 -0
  324. package/node_modules/@jspm/core/test/cowsay.wasm +0 -0
  325. package/node_modules/@jspm/core/test/exports.test.js +99 -0
  326. package/node_modules/@jspm/core/test/fs.test.js +13 -0
  327. package/node_modules/@jspm/core/test/os.test.js +7 -0
  328. package/node_modules/@jspm/core/test/process.test.js +15 -0
  329. package/node_modules/@jspm/core/test/server.js +177 -0
  330. package/node_modules/@jspm/core/test/test.html +29 -0
  331. package/node_modules/@jspm/core/test/wasi.test.js +13 -0
  332. package/package.json +39 -24
  333. package/esm/utils/helpers.js +0 -32
  334. package/esm/utils/helpers.js.map +0 -1
@@ -0,0 +1,3513 @@
1
+ import { d as dew$m } from './chunk-CkFCi-G1.js';
2
+ import './chunk-DtDiafJB.js';
3
+ import { y } from './chunk-tHuMsdT0.js';
4
+ import { d as dew$l } from './chunk-DtuTasat.js';
5
+ import './chunk-CbQqNoLO.js';
6
+ import { X } from './chunk-D3uu3VYh.js';
7
+ import { p as process } from './chunk-DEMDiNwt.js';
8
+ import { d as dew$n } from './chunk-BsRZ0PEC.js';
9
+ import { e as exports$m } from './chunk-CcCWfKp1.js';
10
+ import { h } from './chunk-DHWh-hmB.js';
11
+ import './chunk-b0rmRow7.js';
12
+
13
+ var exports$l = {},
14
+ _dewExec$k = false;
15
+ var _global$5 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
16
+ function dew$k() {
17
+ if (_dewExec$k) return exports$l;
18
+ _dewExec$k = true;
19
+ exports$l.fetch = isFunction(_global$5.fetch) && isFunction(_global$5.ReadableStream);
20
+ exports$l.writableStream = isFunction(_global$5.WritableStream);
21
+ exports$l.abortController = isFunction(_global$5.AbortController);
22
+
23
+ // The xhr request to example.com may violate some restrictive CSP configurations,
24
+ // so if we're running in a browser that supports `fetch`, avoid calling getXHR()
25
+ // and assume support for certain features below.
26
+ var xhr;
27
+ function getXHR() {
28
+ // Cache the xhr value
29
+ if (xhr !== undefined) return xhr;
30
+ if (_global$5.XMLHttpRequest) {
31
+ xhr = new _global$5.XMLHttpRequest();
32
+ // If XDomainRequest is available (ie only, where xhr might not work
33
+ // cross domain), use the page location. Otherwise use example.com
34
+ // Note: this doesn't actually make an http request.
35
+ try {
36
+ xhr.open("GET", _global$5.XDomainRequest ? "/" : "https://example.com");
37
+ } catch (e) {
38
+ xhr = null;
39
+ }
40
+ } else {
41
+ // Service workers don't have XHR
42
+ xhr = null;
43
+ }
44
+ return xhr;
45
+ }
46
+ function checkTypeSupport(type) {
47
+ var xhr = getXHR();
48
+ if (!xhr) return false;
49
+ try {
50
+ xhr.responseType = type;
51
+ return xhr.responseType === type;
52
+ } catch (e) {}
53
+ return false;
54
+ }
55
+
56
+ // If fetch is supported, then arraybuffer will be supported too. Skip calling
57
+ // checkTypeSupport(), since that calls getXHR().
58
+ exports$l.arraybuffer = exports$l.fetch || checkTypeSupport("arraybuffer");
59
+
60
+ // These next two tests unavoidably show warnings in Chrome. Since fetch will always
61
+ // be used if it's available, just return false for these to avoid the warnings.
62
+ exports$l.msstream = !exports$l.fetch && checkTypeSupport("ms-stream");
63
+ exports$l.mozchunkedarraybuffer = !exports$l.fetch && checkTypeSupport("moz-chunked-arraybuffer");
64
+
65
+ // If fetch is supported, then overrideMimeType will be supported too. Skip calling
66
+ // getXHR().
67
+ exports$l.overrideMimeType = exports$l.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false);
68
+ function isFunction(value) {
69
+ return typeof value === "function";
70
+ }
71
+ xhr = null; // Help gc
72
+ return exports$l;
73
+ }
74
+
75
+ var exports$k = {},
76
+ _dewExec$j = false;
77
+ function dew$j() {
78
+ if (_dewExec$j) return exports$k;
79
+ _dewExec$j = true;
80
+ exports$k = y.EventEmitter;
81
+ return exports$k;
82
+ }
83
+
84
+ var exports$j = {},
85
+ _dewExec$i = false;
86
+ function dew$i() {
87
+ if (_dewExec$i) return exports$j;
88
+ _dewExec$i = true;
89
+ function ownKeys(object, enumerableOnly) {
90
+ var keys = Object.keys(object);
91
+ if (Object.getOwnPropertySymbols) {
92
+ var symbols = Object.getOwnPropertySymbols(object);
93
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
94
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
95
+ })), keys.push.apply(keys, symbols);
96
+ }
97
+ return keys;
98
+ }
99
+ function _objectSpread(target) {
100
+ for (var i = 1; i < arguments.length; i++) {
101
+ var source = null != arguments[i] ? arguments[i] : {};
102
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
103
+ _defineProperty(target, key, source[key]);
104
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
105
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
106
+ });
107
+ }
108
+ return target;
109
+ }
110
+ function _defineProperty(obj, key, value) {
111
+ key = _toPropertyKey(key);
112
+ if (key in obj) {
113
+ Object.defineProperty(obj, key, {
114
+ value: value,
115
+ enumerable: true,
116
+ configurable: true,
117
+ writable: true
118
+ });
119
+ } else {
120
+ obj[key] = value;
121
+ }
122
+ return obj;
123
+ }
124
+ function _classCallCheck(instance, Constructor) {
125
+ if (!(instance instanceof Constructor)) {
126
+ throw new TypeError("Cannot call a class as a function");
127
+ }
128
+ }
129
+ function _defineProperties(target, props) {
130
+ for (var i = 0; i < props.length; i++) {
131
+ var descriptor = props[i];
132
+ descriptor.enumerable = descriptor.enumerable || false;
133
+ descriptor.configurable = true;
134
+ if ("value" in descriptor) descriptor.writable = true;
135
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
136
+ }
137
+ }
138
+ function _createClass(Constructor, protoProps, staticProps) {
139
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
140
+ Object.defineProperty(Constructor, "prototype", {
141
+ writable: false
142
+ });
143
+ return Constructor;
144
+ }
145
+ function _toPropertyKey(arg) {
146
+ var key = _toPrimitive(arg, "string");
147
+ return typeof key === "symbol" ? key : String(key);
148
+ }
149
+ function _toPrimitive(input, hint) {
150
+ if (typeof input !== "object" || input === null) return input;
151
+ var prim = input[Symbol.toPrimitive];
152
+ if (prim !== undefined) {
153
+ var res = prim.call(input, hint || "default");
154
+ if (typeof res !== "object") return res;
155
+ throw new TypeError("@@toPrimitive must return a primitive value.");
156
+ }
157
+ return (hint === "string" ? String : Number)(input);
158
+ }
159
+ var _require = dew$l(),
160
+ Buffer = _require.Buffer;
161
+ var _require2 = X,
162
+ inspect = _require2.inspect;
163
+ var custom = inspect && inspect.custom || "inspect";
164
+ function copyBuffer(src, target, offset) {
165
+ Buffer.prototype.copy.call(src, target, offset);
166
+ }
167
+ exports$j = /*#__PURE__*/function () {
168
+ function BufferList() {
169
+ _classCallCheck(this, BufferList);
170
+ this.head = null;
171
+ this.tail = null;
172
+ this.length = 0;
173
+ }
174
+ _createClass(BufferList, [{
175
+ key: "push",
176
+ value: function push(v) {
177
+ var entry = {
178
+ data: v,
179
+ next: null
180
+ };
181
+ if (this.length > 0) this.tail.next = entry;else this.head = entry;
182
+ this.tail = entry;
183
+ ++this.length;
184
+ }
185
+ }, {
186
+ key: "unshift",
187
+ value: function unshift(v) {
188
+ var entry = {
189
+ data: v,
190
+ next: this.head
191
+ };
192
+ if (this.length === 0) this.tail = entry;
193
+ this.head = entry;
194
+ ++this.length;
195
+ }
196
+ }, {
197
+ key: "shift",
198
+ value: function shift() {
199
+ if (this.length === 0) return;
200
+ var ret = this.head.data;
201
+ if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
202
+ --this.length;
203
+ return ret;
204
+ }
205
+ }, {
206
+ key: "clear",
207
+ value: function clear() {
208
+ this.head = this.tail = null;
209
+ this.length = 0;
210
+ }
211
+ }, {
212
+ key: "join",
213
+ value: function join(s) {
214
+ if (this.length === 0) return "";
215
+ var p = this.head;
216
+ var ret = "" + p.data;
217
+ while (p = p.next) ret += s + p.data;
218
+ return ret;
219
+ }
220
+ }, {
221
+ key: "concat",
222
+ value: function concat(n) {
223
+ if (this.length === 0) return Buffer.alloc(0);
224
+ var ret = Buffer.allocUnsafe(n >>> 0);
225
+ var p = this.head;
226
+ var i = 0;
227
+ while (p) {
228
+ copyBuffer(p.data, ret, i);
229
+ i += p.data.length;
230
+ p = p.next;
231
+ }
232
+ return ret;
233
+ }
234
+
235
+ // Consumes a specified amount of bytes or characters from the buffered data.
236
+ }, {
237
+ key: "consume",
238
+ value: function consume(n, hasStrings) {
239
+ var ret;
240
+ if (n < this.head.data.length) {
241
+ // `slice` is the same for buffers and strings.
242
+ ret = this.head.data.slice(0, n);
243
+ this.head.data = this.head.data.slice(n);
244
+ } else if (n === this.head.data.length) {
245
+ // First chunk is a perfect match.
246
+ ret = this.shift();
247
+ } else {
248
+ // Result spans more than one buffer.
249
+ ret = hasStrings ? this._getString(n) : this._getBuffer(n);
250
+ }
251
+ return ret;
252
+ }
253
+ }, {
254
+ key: "first",
255
+ value: function first() {
256
+ return this.head.data;
257
+ }
258
+
259
+ // Consumes a specified amount of characters from the buffered data.
260
+ }, {
261
+ key: "_getString",
262
+ value: function _getString(n) {
263
+ var p = this.head;
264
+ var c = 1;
265
+ var ret = p.data;
266
+ n -= ret.length;
267
+ while (p = p.next) {
268
+ var str = p.data;
269
+ var nb = n > str.length ? str.length : n;
270
+ if (nb === str.length) ret += str;else ret += str.slice(0, n);
271
+ n -= nb;
272
+ if (n === 0) {
273
+ if (nb === str.length) {
274
+ ++c;
275
+ if (p.next) this.head = p.next;else this.head = this.tail = null;
276
+ } else {
277
+ this.head = p;
278
+ p.data = str.slice(nb);
279
+ }
280
+ break;
281
+ }
282
+ ++c;
283
+ }
284
+ this.length -= c;
285
+ return ret;
286
+ }
287
+
288
+ // Consumes a specified amount of bytes from the buffered data.
289
+ }, {
290
+ key: "_getBuffer",
291
+ value: function _getBuffer(n) {
292
+ var ret = Buffer.allocUnsafe(n);
293
+ var p = this.head;
294
+ var c = 1;
295
+ p.data.copy(ret);
296
+ n -= p.data.length;
297
+ while (p = p.next) {
298
+ var buf = p.data;
299
+ var nb = n > buf.length ? buf.length : n;
300
+ buf.copy(ret, ret.length - n, 0, nb);
301
+ n -= nb;
302
+ if (n === 0) {
303
+ if (nb === buf.length) {
304
+ ++c;
305
+ if (p.next) this.head = p.next;else this.head = this.tail = null;
306
+ } else {
307
+ this.head = p;
308
+ p.data = buf.slice(nb);
309
+ }
310
+ break;
311
+ }
312
+ ++c;
313
+ }
314
+ this.length -= c;
315
+ return ret;
316
+ }
317
+
318
+ // Make sure the linked list only shows the minimal necessary information.
319
+ }, {
320
+ key: custom,
321
+ value: function value(_, options) {
322
+ return inspect(this, _objectSpread(_objectSpread({}, options), {}, {
323
+ // Only inspect one level.
324
+ depth: 0,
325
+ // It should not recurse.
326
+ customInspect: false
327
+ }));
328
+ }
329
+ }]);
330
+ return BufferList;
331
+ }();
332
+ return exports$j;
333
+ }
334
+
335
+ var exports$i = {},
336
+ _dewExec$h = false;
337
+ function dew$h() {
338
+ if (_dewExec$h) return exports$i;
339
+ _dewExec$h = true;
340
+ var process$1 = process;
341
+ // undocumented cb() API, needed for core, not for public API
342
+ function destroy(err, cb) {
343
+ var _this = this;
344
+ var readableDestroyed = this._readableState && this._readableState.destroyed;
345
+ var writableDestroyed = this._writableState && this._writableState.destroyed;
346
+ if (readableDestroyed || writableDestroyed) {
347
+ if (cb) {
348
+ cb(err);
349
+ } else if (err) {
350
+ if (!this._writableState) {
351
+ process$1.nextTick(emitErrorNT, this, err);
352
+ } else if (!this._writableState.errorEmitted) {
353
+ this._writableState.errorEmitted = true;
354
+ process$1.nextTick(emitErrorNT, this, err);
355
+ }
356
+ }
357
+ return this;
358
+ }
359
+
360
+ // we set destroyed to true before firing error callbacks in order
361
+ // to make it re-entrance safe in case destroy() is called within callbacks
362
+
363
+ if (this._readableState) {
364
+ this._readableState.destroyed = true;
365
+ }
366
+
367
+ // if this is a duplex stream mark the writable part as destroyed as well
368
+ if (this._writableState) {
369
+ this._writableState.destroyed = true;
370
+ }
371
+ this._destroy(err || null, function (err) {
372
+ if (!cb && err) {
373
+ if (!_this._writableState) {
374
+ process$1.nextTick(emitErrorAndCloseNT, _this, err);
375
+ } else if (!_this._writableState.errorEmitted) {
376
+ _this._writableState.errorEmitted = true;
377
+ process$1.nextTick(emitErrorAndCloseNT, _this, err);
378
+ } else {
379
+ process$1.nextTick(emitCloseNT, _this);
380
+ }
381
+ } else if (cb) {
382
+ process$1.nextTick(emitCloseNT, _this);
383
+ cb(err);
384
+ } else {
385
+ process$1.nextTick(emitCloseNT, _this);
386
+ }
387
+ });
388
+ return this;
389
+ }
390
+ function emitErrorAndCloseNT(self, err) {
391
+ emitErrorNT(self, err);
392
+ emitCloseNT(self);
393
+ }
394
+ function emitCloseNT(self) {
395
+ if (self._writableState && !self._writableState.emitClose) return;
396
+ if (self._readableState && !self._readableState.emitClose) return;
397
+ self.emit("close");
398
+ }
399
+ function undestroy() {
400
+ if (this._readableState) {
401
+ this._readableState.destroyed = false;
402
+ this._readableState.reading = false;
403
+ this._readableState.ended = false;
404
+ this._readableState.endEmitted = false;
405
+ }
406
+ if (this._writableState) {
407
+ this._writableState.destroyed = false;
408
+ this._writableState.ended = false;
409
+ this._writableState.ending = false;
410
+ this._writableState.finalCalled = false;
411
+ this._writableState.prefinished = false;
412
+ this._writableState.finished = false;
413
+ this._writableState.errorEmitted = false;
414
+ }
415
+ }
416
+ function emitErrorNT(self, err) {
417
+ self.emit("error", err);
418
+ }
419
+ function errorOrDestroy(stream, err) {
420
+ // We have tests that rely on errors being emitted
421
+ // in the same tick, so changing this is semver major.
422
+ // For now when you opt-in to autoDestroy we allow
423
+ // the error to be emitted nextTick. In a future
424
+ // semver major update we should change the default to this.
425
+
426
+ var rState = stream._readableState;
427
+ var wState = stream._writableState;
428
+ if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit("error", err);
429
+ }
430
+ exports$i = {
431
+ destroy: destroy,
432
+ undestroy: undestroy,
433
+ errorOrDestroy: errorOrDestroy
434
+ };
435
+ return exports$i;
436
+ }
437
+
438
+ var exports$h = {},
439
+ _dewExec$g = false;
440
+ function dew$g() {
441
+ if (_dewExec$g) return exports$h;
442
+ _dewExec$g = true;
443
+ const codes = {};
444
+ function createErrorType(code, message, Base) {
445
+ if (!Base) {
446
+ Base = Error;
447
+ }
448
+ function getMessage(arg1, arg2, arg3) {
449
+ if (typeof message === "string") {
450
+ return message;
451
+ } else {
452
+ return message(arg1, arg2, arg3);
453
+ }
454
+ }
455
+ class NodeError extends Base {
456
+ constructor(arg1, arg2, arg3) {
457
+ super(getMessage(arg1, arg2, arg3));
458
+ }
459
+ }
460
+ NodeError.prototype.name = Base.name;
461
+ NodeError.prototype.code = code;
462
+ codes[code] = NodeError;
463
+ }
464
+
465
+ // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
466
+ function oneOf(expected, thing) {
467
+ if (Array.isArray(expected)) {
468
+ const len = expected.length;
469
+ expected = expected.map(i => String(i));
470
+ if (len > 2) {
471
+ return `one of ${thing} ${expected.slice(0, len - 1).join(", ")}, or ` + expected[len - 1];
472
+ } else if (len === 2) {
473
+ return `one of ${thing} ${expected[0]} or ${expected[1]}`;
474
+ } else {
475
+ return `of ${thing} ${expected[0]}`;
476
+ }
477
+ } else {
478
+ return `of ${thing} ${String(expected)}`;
479
+ }
480
+ }
481
+
482
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
483
+ function startsWith(str, search, pos) {
484
+ return str.substr(0 , search.length) === search;
485
+ }
486
+
487
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
488
+ function endsWith(str, search, this_len) {
489
+ if (this_len === undefined || this_len > str.length) {
490
+ this_len = str.length;
491
+ }
492
+ return str.substring(this_len - search.length, this_len) === search;
493
+ }
494
+
495
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
496
+ function includes(str, search, start) {
497
+ if (typeof start !== "number") {
498
+ start = 0;
499
+ }
500
+ if (start + search.length > str.length) {
501
+ return false;
502
+ } else {
503
+ return str.indexOf(search, start) !== -1;
504
+ }
505
+ }
506
+ createErrorType("ERR_INVALID_OPT_VALUE", function (name, value) {
507
+ return "The value \"" + value + "\" is invalid for option \"" + name + "\"";
508
+ }, TypeError);
509
+ createErrorType("ERR_INVALID_ARG_TYPE", function (name, expected, actual) {
510
+ // determiner: 'must be' or 'must not be'
511
+ let determiner;
512
+ if (typeof expected === "string" && startsWith(expected, "not ")) {
513
+ determiner = "must not be";
514
+ expected = expected.replace(/^not /, "");
515
+ } else {
516
+ determiner = "must be";
517
+ }
518
+ let msg;
519
+ if (endsWith(name, " argument")) {
520
+ // For cases like 'first argument'
521
+ msg = `The ${name} ${determiner} ${oneOf(expected, "type")}`;
522
+ } else {
523
+ const type = includes(name, ".") ? "property" : "argument";
524
+ msg = `The "${name}" ${type} ${determiner} ${oneOf(expected, "type")}`;
525
+ }
526
+ msg += `. Received type ${typeof actual}`;
527
+ return msg;
528
+ }, TypeError);
529
+ createErrorType("ERR_STREAM_PUSH_AFTER_EOF", "stream.push() after EOF");
530
+ createErrorType("ERR_METHOD_NOT_IMPLEMENTED", function (name) {
531
+ return "The " + name + " method is not implemented";
532
+ });
533
+ createErrorType("ERR_STREAM_PREMATURE_CLOSE", "Premature close");
534
+ createErrorType("ERR_STREAM_DESTROYED", function (name) {
535
+ return "Cannot call " + name + " after a stream was destroyed";
536
+ });
537
+ createErrorType("ERR_MULTIPLE_CALLBACK", "Callback called multiple times");
538
+ createErrorType("ERR_STREAM_CANNOT_PIPE", "Cannot pipe, not readable");
539
+ createErrorType("ERR_STREAM_WRITE_AFTER_END", "write after end");
540
+ createErrorType("ERR_STREAM_NULL_VALUES", "May not write null values to stream", TypeError);
541
+ createErrorType("ERR_UNKNOWN_ENCODING", function (arg) {
542
+ return "Unknown encoding: " + arg;
543
+ }, TypeError);
544
+ createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT", "stream.unshift() after end event");
545
+ exports$h.codes = codes;
546
+ return exports$h;
547
+ }
548
+
549
+ var exports$g = {},
550
+ _dewExec$f = false;
551
+ function dew$f() {
552
+ if (_dewExec$f) return exports$g;
553
+ _dewExec$f = true;
554
+ var ERR_INVALID_OPT_VALUE = dew$g().codes.ERR_INVALID_OPT_VALUE;
555
+ function highWaterMarkFrom(options, isDuplex, duplexKey) {
556
+ return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
557
+ }
558
+ function getHighWaterMark(state, options, duplexKey, isDuplex) {
559
+ var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
560
+ if (hwm != null) {
561
+ if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
562
+ var name = isDuplex ? duplexKey : "highWaterMark";
563
+ throw new ERR_INVALID_OPT_VALUE(name, hwm);
564
+ }
565
+ return Math.floor(hwm);
566
+ }
567
+
568
+ // Default value
569
+ return state.objectMode ? 16 : 16 * 1024;
570
+ }
571
+ exports$g = {
572
+ getHighWaterMark: getHighWaterMark
573
+ };
574
+ return exports$g;
575
+ }
576
+
577
+ var exports$f = {},
578
+ _dewExec$e = false;
579
+ var _global$4 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
580
+ function dew$e() {
581
+ if (_dewExec$e) return exports$f;
582
+ _dewExec$e = true;
583
+ var process$1 = process;
584
+ exports$f = Writable;
585
+
586
+ // It seems a linked list but it is not
587
+ // there will be only 2 of these for each stream
588
+ function CorkedRequest(state) {
589
+ var _this = this;
590
+ this.next = null;
591
+ this.entry = null;
592
+ this.finish = function () {
593
+ onCorkedFinish(_this, state);
594
+ };
595
+ }
596
+ /* </replacement> */
597
+
598
+ /*<replacement>*/
599
+ var Duplex;
600
+ /*</replacement>*/
601
+
602
+ Writable.WritableState = WritableState;
603
+
604
+ /*<replacement>*/
605
+ var internalUtil = {
606
+ deprecate: dew$n()
607
+ };
608
+ /*</replacement>*/
609
+
610
+ /*<replacement>*/
611
+ var Stream = dew$j();
612
+ /*</replacement>*/
613
+
614
+ var Buffer = dew$l().Buffer;
615
+ var OurUint8Array = (typeof _global$4 !== "undefined" ? _global$4 : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function () {};
616
+ function _uint8ArrayToBuffer(chunk) {
617
+ return Buffer.from(chunk);
618
+ }
619
+ function _isUint8Array(obj) {
620
+ return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
621
+ }
622
+ var destroyImpl = dew$h();
623
+ var _require = dew$f(),
624
+ getHighWaterMark = _require.getHighWaterMark;
625
+ var _require$codes = dew$g().codes,
626
+ ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
627
+ ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
628
+ ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
629
+ ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,
630
+ ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,
631
+ ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,
632
+ ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,
633
+ ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
634
+ var errorOrDestroy = destroyImpl.errorOrDestroy;
635
+ dew$m()(Writable, Stream);
636
+ function nop() {}
637
+ function WritableState(options, stream, isDuplex) {
638
+ Duplex = Duplex || dew$d();
639
+ options = options || {};
640
+
641
+ // Duplex streams are both readable and writable, but share
642
+ // the same options object.
643
+ // However, some cases require setting options to different
644
+ // values for the readable and the writable sides of the duplex stream,
645
+ // e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
646
+ if (typeof isDuplex !== "boolean") isDuplex = stream instanceof Duplex;
647
+
648
+ // object stream flag to indicate whether or not this stream
649
+ // contains buffers or objects.
650
+ this.objectMode = !!options.objectMode;
651
+ if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
652
+
653
+ // the point at which write() starts returning false
654
+ // Note: 0 is a valid value, means that we always return false if
655
+ // the entire buffer is not flushed immediately on write()
656
+ this.highWaterMark = getHighWaterMark(this, options, "writableHighWaterMark", isDuplex);
657
+
658
+ // if _final has been called
659
+ this.finalCalled = false;
660
+
661
+ // drain event flag.
662
+ this.needDrain = false;
663
+ // at the start of calling end()
664
+ this.ending = false;
665
+ // when end() has been called, and returned
666
+ this.ended = false;
667
+ // when 'finish' is emitted
668
+ this.finished = false;
669
+
670
+ // has it been destroyed
671
+ this.destroyed = false;
672
+
673
+ // should we decode strings into buffers before passing to _write?
674
+ // this is here so that some node-core streams can optimize string
675
+ // handling at a lower level.
676
+ var noDecode = options.decodeStrings === false;
677
+ this.decodeStrings = !noDecode;
678
+
679
+ // Crypto is kind of old and crusty. Historically, its default string
680
+ // encoding is 'binary' so we have to make this configurable.
681
+ // Everything else in the universe uses 'utf8', though.
682
+ this.defaultEncoding = options.defaultEncoding || "utf8";
683
+
684
+ // not an actual buffer we keep track of, but a measurement
685
+ // of how much we're waiting to get pushed to some underlying
686
+ // socket or file.
687
+ this.length = 0;
688
+
689
+ // a flag to see when we're in the middle of a write.
690
+ this.writing = false;
691
+
692
+ // when true all writes will be buffered until .uncork() call
693
+ this.corked = 0;
694
+
695
+ // a flag to be able to tell if the onwrite cb is called immediately,
696
+ // or on a later tick. We set this to true at first, because any
697
+ // actions that shouldn't happen until "later" should generally also
698
+ // not happen before the first write call.
699
+ this.sync = true;
700
+
701
+ // a flag to know if we're processing previously buffered items, which
702
+ // may call the _write() callback in the same tick, so that we don't
703
+ // end up in an overlapped onwrite situation.
704
+ this.bufferProcessing = false;
705
+
706
+ // the callback that's passed to _write(chunk,cb)
707
+ this.onwrite = function (er) {
708
+ onwrite(stream, er);
709
+ };
710
+
711
+ // the callback that the user supplies to write(chunk,encoding,cb)
712
+ this.writecb = null;
713
+
714
+ // the amount that is being written when _write is called.
715
+ this.writelen = 0;
716
+ this.bufferedRequest = null;
717
+ this.lastBufferedRequest = null;
718
+
719
+ // number of pending user-supplied write callbacks
720
+ // this must be 0 before 'finish' can be emitted
721
+ this.pendingcb = 0;
722
+
723
+ // emit prefinish if the only thing we're waiting for is _write cbs
724
+ // This is relevant for synchronous Transform streams
725
+ this.prefinished = false;
726
+
727
+ // True if the error was already emitted and should not be thrown again
728
+ this.errorEmitted = false;
729
+
730
+ // Should close be emitted on destroy. Defaults to true.
731
+ this.emitClose = options.emitClose !== false;
732
+
733
+ // Should .destroy() be called after 'finish' (and potentially 'end')
734
+ this.autoDestroy = !!options.autoDestroy;
735
+
736
+ // count buffered requests
737
+ this.bufferedRequestCount = 0;
738
+
739
+ // allocate the first CorkedRequest, there is always
740
+ // one allocated and free to use, and we maintain at most two
741
+ this.corkedRequestsFree = new CorkedRequest(this);
742
+ }
743
+ WritableState.prototype.getBuffer = function getBuffer() {
744
+ var current = this.bufferedRequest;
745
+ var out = [];
746
+ while (current) {
747
+ out.push(current);
748
+ current = current.next;
749
+ }
750
+ return out;
751
+ };
752
+ (function () {
753
+ try {
754
+ Object.defineProperty(WritableState.prototype, "buffer", {
755
+ get: internalUtil.deprecate(function writableStateBufferGetter() {
756
+ return this.getBuffer();
757
+ }, "_writableState.buffer is deprecated. Use _writableState.getBuffer " + "instead.", "DEP0003")
758
+ });
759
+ } catch (_) {}
760
+ })();
761
+
762
+ // Test _writableState for inheritance to account for Duplex streams,
763
+ // whose prototype chain only points to Readable.
764
+ var realHasInstance;
765
+ if (typeof Symbol === "function" && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === "function") {
766
+ realHasInstance = Function.prototype[Symbol.hasInstance];
767
+ Object.defineProperty(Writable, Symbol.hasInstance, {
768
+ value: function value(object) {
769
+ if (realHasInstance.call(this, object)) return true;
770
+ if (this !== Writable) return false;
771
+ return object && object._writableState instanceof WritableState;
772
+ }
773
+ });
774
+ } else {
775
+ realHasInstance = function realHasInstance(object) {
776
+ return object instanceof this;
777
+ };
778
+ }
779
+ function Writable(options) {
780
+ Duplex = Duplex || dew$d();
781
+
782
+ // Writable ctor is applied to Duplexes, too.
783
+ // `realHasInstance` is necessary because using plain `instanceof`
784
+ // would return false, as no `_writableState` property is attached.
785
+
786
+ // Trying to use the custom `instanceof` for Writable here will also break the
787
+ // Node.js LazyTransform implementation, which has a non-trivial getter for
788
+ // `_writableState` that would lead to infinite recursion.
789
+
790
+ // Checking for a Stream.Duplex instance is faster here instead of inside
791
+ // the WritableState constructor, at least with V8 6.5
792
+ var isDuplex = this instanceof Duplex;
793
+ if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);
794
+ this._writableState = new WritableState(options, this, isDuplex);
795
+
796
+ // legacy.
797
+ this.writable = true;
798
+ if (options) {
799
+ if (typeof options.write === "function") this._write = options.write;
800
+ if (typeof options.writev === "function") this._writev = options.writev;
801
+ if (typeof options.destroy === "function") this._destroy = options.destroy;
802
+ if (typeof options.final === "function") this._final = options.final;
803
+ }
804
+ Stream.call(this);
805
+ }
806
+
807
+ // Otherwise people can pipe Writable streams, which is just wrong.
808
+ Writable.prototype.pipe = function () {
809
+ errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
810
+ };
811
+ function writeAfterEnd(stream, cb) {
812
+ var er = new ERR_STREAM_WRITE_AFTER_END();
813
+ // TODO: defer error events consistently everywhere, not just the cb
814
+ errorOrDestroy(stream, er);
815
+ process$1.nextTick(cb, er);
816
+ }
817
+
818
+ // Checks that a user-supplied chunk is valid, especially for the particular
819
+ // mode the stream is in. Currently this means that `null` is never accepted
820
+ // and undefined/non-string values are only allowed in object mode.
821
+ function validChunk(stream, state, chunk, cb) {
822
+ var er;
823
+ if (chunk === null) {
824
+ er = new ERR_STREAM_NULL_VALUES();
825
+ } else if (typeof chunk !== "string" && !state.objectMode) {
826
+ er = new ERR_INVALID_ARG_TYPE("chunk", ["string", "Buffer"], chunk);
827
+ }
828
+ if (er) {
829
+ errorOrDestroy(stream, er);
830
+ process$1.nextTick(cb, er);
831
+ return false;
832
+ }
833
+ return true;
834
+ }
835
+ Writable.prototype.write = function (chunk, encoding, cb) {
836
+ var state = this._writableState;
837
+ var ret = false;
838
+ var isBuf = !state.objectMode && _isUint8Array(chunk);
839
+ if (isBuf && !Buffer.isBuffer(chunk)) {
840
+ chunk = _uint8ArrayToBuffer(chunk);
841
+ }
842
+ if (typeof encoding === "function") {
843
+ cb = encoding;
844
+ encoding = null;
845
+ }
846
+ if (isBuf) encoding = "buffer";else if (!encoding) encoding = state.defaultEncoding;
847
+ if (typeof cb !== "function") cb = nop;
848
+ if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
849
+ state.pendingcb++;
850
+ ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
851
+ }
852
+ return ret;
853
+ };
854
+ Writable.prototype.cork = function () {
855
+ this._writableState.corked++;
856
+ };
857
+ Writable.prototype.uncork = function () {
858
+ var state = this._writableState;
859
+ if (state.corked) {
860
+ state.corked--;
861
+ if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
862
+ }
863
+ };
864
+ Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
865
+ // node::ParseEncoding() requires lower case.
866
+ if (typeof encoding === "string") encoding = encoding.toLowerCase();
867
+ if (!(["hex", "utf8", "utf-8", "ascii", "binary", "base64", "ucs2", "ucs-2", "utf16le", "utf-16le", "raw"].indexOf((encoding + "").toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding);
868
+ this._writableState.defaultEncoding = encoding;
869
+ return this;
870
+ };
871
+ Object.defineProperty(Writable.prototype, "writableBuffer", {
872
+ // making it explicit this property is not enumerable
873
+ // because otherwise some prototype manipulation in
874
+ // userland will fail
875
+ enumerable: false,
876
+ get: function get() {
877
+ return this._writableState && this._writableState.getBuffer();
878
+ }
879
+ });
880
+ function decodeChunk(state, chunk, encoding) {
881
+ if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") {
882
+ chunk = Buffer.from(chunk, encoding);
883
+ }
884
+ return chunk;
885
+ }
886
+ Object.defineProperty(Writable.prototype, "writableHighWaterMark", {
887
+ // making it explicit this property is not enumerable
888
+ // because otherwise some prototype manipulation in
889
+ // userland will fail
890
+ enumerable: false,
891
+ get: function get() {
892
+ return this._writableState.highWaterMark;
893
+ }
894
+ });
895
+
896
+ // if we're already writing something, then just put this
897
+ // in the queue, and wait our turn. Otherwise, call _write
898
+ // If we return false, then we need a drain event, so set that flag.
899
+ function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
900
+ if (!isBuf) {
901
+ var newChunk = decodeChunk(state, chunk, encoding);
902
+ if (chunk !== newChunk) {
903
+ isBuf = true;
904
+ encoding = "buffer";
905
+ chunk = newChunk;
906
+ }
907
+ }
908
+ var len = state.objectMode ? 1 : chunk.length;
909
+ state.length += len;
910
+ var ret = state.length < state.highWaterMark;
911
+ // we must ensure that previous needDrain will not be reset to false.
912
+ if (!ret) state.needDrain = true;
913
+ if (state.writing || state.corked) {
914
+ var last = state.lastBufferedRequest;
915
+ state.lastBufferedRequest = {
916
+ chunk: chunk,
917
+ encoding: encoding,
918
+ isBuf: isBuf,
919
+ callback: cb,
920
+ next: null
921
+ };
922
+ if (last) {
923
+ last.next = state.lastBufferedRequest;
924
+ } else {
925
+ state.bufferedRequest = state.lastBufferedRequest;
926
+ }
927
+ state.bufferedRequestCount += 1;
928
+ } else {
929
+ doWrite(stream, state, false, len, chunk, encoding, cb);
930
+ }
931
+ return ret;
932
+ }
933
+ function doWrite(stream, state, writev, len, chunk, encoding, cb) {
934
+ state.writelen = len;
935
+ state.writecb = cb;
936
+ state.writing = true;
937
+ state.sync = true;
938
+ if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED("write"));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
939
+ state.sync = false;
940
+ }
941
+ function onwriteError(stream, state, sync, er, cb) {
942
+ --state.pendingcb;
943
+ if (sync) {
944
+ // defer the callback if we are being called synchronously
945
+ // to avoid piling up things on the stack
946
+ process$1.nextTick(cb, er);
947
+ // this can emit finish, and it will always happen
948
+ // after error
949
+ process$1.nextTick(finishMaybe, stream, state);
950
+ stream._writableState.errorEmitted = true;
951
+ errorOrDestroy(stream, er);
952
+ } else {
953
+ // the caller expect this to happen before if
954
+ // it is async
955
+ cb(er);
956
+ stream._writableState.errorEmitted = true;
957
+ errorOrDestroy(stream, er);
958
+ // this can emit finish, but finish must
959
+ // always follow error
960
+ finishMaybe(stream, state);
961
+ }
962
+ }
963
+ function onwriteStateUpdate(state) {
964
+ state.writing = false;
965
+ state.writecb = null;
966
+ state.length -= state.writelen;
967
+ state.writelen = 0;
968
+ }
969
+ function onwrite(stream, er) {
970
+ var state = stream._writableState;
971
+ var sync = state.sync;
972
+ var cb = state.writecb;
973
+ if (typeof cb !== "function") throw new ERR_MULTIPLE_CALLBACK();
974
+ onwriteStateUpdate(state);
975
+ if (er) onwriteError(stream, state, sync, er, cb);else {
976
+ // Check if we're actually ready to finish, but don't emit yet
977
+ var finished = needFinish(state) || stream.destroyed;
978
+ if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
979
+ clearBuffer(stream, state);
980
+ }
981
+ if (sync) {
982
+ process$1.nextTick(afterWrite, stream, state, finished, cb);
983
+ } else {
984
+ afterWrite(stream, state, finished, cb);
985
+ }
986
+ }
987
+ }
988
+ function afterWrite(stream, state, finished, cb) {
989
+ if (!finished) onwriteDrain(stream, state);
990
+ state.pendingcb--;
991
+ cb();
992
+ finishMaybe(stream, state);
993
+ }
994
+
995
+ // Must force callback to be called on nextTick, so that we don't
996
+ // emit 'drain' before the write() consumer gets the 'false' return
997
+ // value, and has a chance to attach a 'drain' listener.
998
+ function onwriteDrain(stream, state) {
999
+ if (state.length === 0 && state.needDrain) {
1000
+ state.needDrain = false;
1001
+ stream.emit("drain");
1002
+ }
1003
+ }
1004
+
1005
+ // if there's something in the buffer waiting, then process it
1006
+ function clearBuffer(stream, state) {
1007
+ state.bufferProcessing = true;
1008
+ var entry = state.bufferedRequest;
1009
+ if (stream._writev && entry && entry.next) {
1010
+ // Fast case, write everything using _writev()
1011
+ var l = state.bufferedRequestCount;
1012
+ var buffer = new Array(l);
1013
+ var holder = state.corkedRequestsFree;
1014
+ holder.entry = entry;
1015
+ var count = 0;
1016
+ var allBuffers = true;
1017
+ while (entry) {
1018
+ buffer[count] = entry;
1019
+ if (!entry.isBuf) allBuffers = false;
1020
+ entry = entry.next;
1021
+ count += 1;
1022
+ }
1023
+ buffer.allBuffers = allBuffers;
1024
+ doWrite(stream, state, true, state.length, buffer, "", holder.finish);
1025
+
1026
+ // doWrite is almost always async, defer these to save a bit of time
1027
+ // as the hot path ends with doWrite
1028
+ state.pendingcb++;
1029
+ state.lastBufferedRequest = null;
1030
+ if (holder.next) {
1031
+ state.corkedRequestsFree = holder.next;
1032
+ holder.next = null;
1033
+ } else {
1034
+ state.corkedRequestsFree = new CorkedRequest(state);
1035
+ }
1036
+ state.bufferedRequestCount = 0;
1037
+ } else {
1038
+ // Slow case, write chunks one-by-one
1039
+ while (entry) {
1040
+ var chunk = entry.chunk;
1041
+ var encoding = entry.encoding;
1042
+ var cb = entry.callback;
1043
+ var len = state.objectMode ? 1 : chunk.length;
1044
+ doWrite(stream, state, false, len, chunk, encoding, cb);
1045
+ entry = entry.next;
1046
+ state.bufferedRequestCount--;
1047
+ // if we didn't call the onwrite immediately, then
1048
+ // it means that we need to wait until it does.
1049
+ // also, that means that the chunk and cb are currently
1050
+ // being processed, so move the buffer counter past them.
1051
+ if (state.writing) {
1052
+ break;
1053
+ }
1054
+ }
1055
+ if (entry === null) state.lastBufferedRequest = null;
1056
+ }
1057
+ state.bufferedRequest = entry;
1058
+ state.bufferProcessing = false;
1059
+ }
1060
+ Writable.prototype._write = function (chunk, encoding, cb) {
1061
+ cb(new ERR_METHOD_NOT_IMPLEMENTED("_write()"));
1062
+ };
1063
+ Writable.prototype._writev = null;
1064
+ Writable.prototype.end = function (chunk, encoding, cb) {
1065
+ var state = this._writableState;
1066
+ if (typeof chunk === "function") {
1067
+ cb = chunk;
1068
+ chunk = null;
1069
+ encoding = null;
1070
+ } else if (typeof encoding === "function") {
1071
+ cb = encoding;
1072
+ encoding = null;
1073
+ }
1074
+ if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
1075
+
1076
+ // .end() fully uncorks
1077
+ if (state.corked) {
1078
+ state.corked = 1;
1079
+ this.uncork();
1080
+ }
1081
+
1082
+ // ignore unnecessary end() calls.
1083
+ if (!state.ending) endWritable(this, state, cb);
1084
+ return this;
1085
+ };
1086
+ Object.defineProperty(Writable.prototype, "writableLength", {
1087
+ // making it explicit this property is not enumerable
1088
+ // because otherwise some prototype manipulation in
1089
+ // userland will fail
1090
+ enumerable: false,
1091
+ get: function get() {
1092
+ return this._writableState.length;
1093
+ }
1094
+ });
1095
+ function needFinish(state) {
1096
+ return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
1097
+ }
1098
+ function callFinal(stream, state) {
1099
+ stream._final(function (err) {
1100
+ state.pendingcb--;
1101
+ if (err) {
1102
+ errorOrDestroy(stream, err);
1103
+ }
1104
+ state.prefinished = true;
1105
+ stream.emit("prefinish");
1106
+ finishMaybe(stream, state);
1107
+ });
1108
+ }
1109
+ function prefinish(stream, state) {
1110
+ if (!state.prefinished && !state.finalCalled) {
1111
+ if (typeof stream._final === "function" && !state.destroyed) {
1112
+ state.pendingcb++;
1113
+ state.finalCalled = true;
1114
+ process$1.nextTick(callFinal, stream, state);
1115
+ } else {
1116
+ state.prefinished = true;
1117
+ stream.emit("prefinish");
1118
+ }
1119
+ }
1120
+ }
1121
+ function finishMaybe(stream, state) {
1122
+ var need = needFinish(state);
1123
+ if (need) {
1124
+ prefinish(stream, state);
1125
+ if (state.pendingcb === 0) {
1126
+ state.finished = true;
1127
+ stream.emit("finish");
1128
+ if (state.autoDestroy) {
1129
+ // In case of duplex streams we need a way to detect
1130
+ // if the readable side is ready for autoDestroy as well
1131
+ var rState = stream._readableState;
1132
+ if (!rState || rState.autoDestroy && rState.endEmitted) {
1133
+ stream.destroy();
1134
+ }
1135
+ }
1136
+ }
1137
+ }
1138
+ return need;
1139
+ }
1140
+ function endWritable(stream, state, cb) {
1141
+ state.ending = true;
1142
+ finishMaybe(stream, state);
1143
+ if (cb) {
1144
+ if (state.finished) process$1.nextTick(cb);else stream.once("finish", cb);
1145
+ }
1146
+ state.ended = true;
1147
+ stream.writable = false;
1148
+ }
1149
+ function onCorkedFinish(corkReq, state, err) {
1150
+ var entry = corkReq.entry;
1151
+ corkReq.entry = null;
1152
+ while (entry) {
1153
+ var cb = entry.callback;
1154
+ state.pendingcb--;
1155
+ cb(err);
1156
+ entry = entry.next;
1157
+ }
1158
+
1159
+ // reuse the free corkReq.
1160
+ state.corkedRequestsFree.next = corkReq;
1161
+ }
1162
+ Object.defineProperty(Writable.prototype, "destroyed", {
1163
+ // making it explicit this property is not enumerable
1164
+ // because otherwise some prototype manipulation in
1165
+ // userland will fail
1166
+ enumerable: false,
1167
+ get: function get() {
1168
+ if (this._writableState === undefined) {
1169
+ return false;
1170
+ }
1171
+ return this._writableState.destroyed;
1172
+ },
1173
+ set: function set(value) {
1174
+ // we ignore the value if the stream
1175
+ // has not been initialized yet
1176
+ if (!this._writableState) {
1177
+ return;
1178
+ }
1179
+
1180
+ // backward compatibility, the user is explicitly
1181
+ // managing destroyed
1182
+ this._writableState.destroyed = value;
1183
+ }
1184
+ });
1185
+ Writable.prototype.destroy = destroyImpl.destroy;
1186
+ Writable.prototype._undestroy = destroyImpl.undestroy;
1187
+ Writable.prototype._destroy = function (err, cb) {
1188
+ cb(err);
1189
+ };
1190
+ return exports$f;
1191
+ }
1192
+
1193
+ var exports$e = {},
1194
+ _dewExec$d = false;
1195
+ function dew$d() {
1196
+ if (_dewExec$d) return exports$e;
1197
+ _dewExec$d = true;
1198
+ var process$1 = process;
1199
+ /*<replacement>*/
1200
+ var objectKeys = Object.keys || function (obj) {
1201
+ var keys = [];
1202
+ for (var key in obj) keys.push(key);
1203
+ return keys;
1204
+ };
1205
+ /*</replacement>*/
1206
+
1207
+ exports$e = Duplex;
1208
+ var Readable = dew$9();
1209
+ var Writable = dew$e();
1210
+ dew$m()(Duplex, Readable);
1211
+ {
1212
+ // Allow the keys array to be GC'ed.
1213
+ var keys = objectKeys(Writable.prototype);
1214
+ for (var v = 0; v < keys.length; v++) {
1215
+ var method = keys[v];
1216
+ if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
1217
+ }
1218
+ }
1219
+ function Duplex(options) {
1220
+ if (!(this instanceof Duplex)) return new Duplex(options);
1221
+ Readable.call(this, options);
1222
+ Writable.call(this, options);
1223
+ this.allowHalfOpen = true;
1224
+ if (options) {
1225
+ if (options.readable === false) this.readable = false;
1226
+ if (options.writable === false) this.writable = false;
1227
+ if (options.allowHalfOpen === false) {
1228
+ this.allowHalfOpen = false;
1229
+ this.once("end", onend);
1230
+ }
1231
+ }
1232
+ }
1233
+ Object.defineProperty(Duplex.prototype, "writableHighWaterMark", {
1234
+ // making it explicit this property is not enumerable
1235
+ // because otherwise some prototype manipulation in
1236
+ // userland will fail
1237
+ enumerable: false,
1238
+ get: function get() {
1239
+ return this._writableState.highWaterMark;
1240
+ }
1241
+ });
1242
+ Object.defineProperty(Duplex.prototype, "writableBuffer", {
1243
+ // making it explicit this property is not enumerable
1244
+ // because otherwise some prototype manipulation in
1245
+ // userland will fail
1246
+ enumerable: false,
1247
+ get: function get() {
1248
+ return this._writableState && this._writableState.getBuffer();
1249
+ }
1250
+ });
1251
+ Object.defineProperty(Duplex.prototype, "writableLength", {
1252
+ // making it explicit this property is not enumerable
1253
+ // because otherwise some prototype manipulation in
1254
+ // userland will fail
1255
+ enumerable: false,
1256
+ get: function get() {
1257
+ return this._writableState.length;
1258
+ }
1259
+ });
1260
+
1261
+ // the no-half-open enforcer
1262
+ function onend() {
1263
+ // If the writable side ended, then we're ok.
1264
+ if (this._writableState.ended) return;
1265
+
1266
+ // no more data can be written.
1267
+ // But allow more writes to happen in this tick.
1268
+ process$1.nextTick(onEndNT, this);
1269
+ }
1270
+ function onEndNT(self) {
1271
+ self.end();
1272
+ }
1273
+ Object.defineProperty(Duplex.prototype, "destroyed", {
1274
+ // making it explicit this property is not enumerable
1275
+ // because otherwise some prototype manipulation in
1276
+ // userland will fail
1277
+ enumerable: false,
1278
+ get: function get() {
1279
+ if (this._readableState === undefined || this._writableState === undefined) {
1280
+ return false;
1281
+ }
1282
+ return this._readableState.destroyed && this._writableState.destroyed;
1283
+ },
1284
+ set: function set(value) {
1285
+ // we ignore the value if the stream
1286
+ // has not been initialized yet
1287
+ if (this._readableState === undefined || this._writableState === undefined) {
1288
+ return;
1289
+ }
1290
+
1291
+ // backward compatibility, the user is explicitly
1292
+ // managing destroyed
1293
+ this._readableState.destroyed = value;
1294
+ this._writableState.destroyed = value;
1295
+ }
1296
+ });
1297
+ return exports$e;
1298
+ }
1299
+
1300
+ var exports$d = {},
1301
+ _dewExec$c = false;
1302
+ function dew$c() {
1303
+ if (_dewExec$c) return exports$d;
1304
+ _dewExec$c = true;
1305
+ var ERR_STREAM_PREMATURE_CLOSE = dew$g().codes.ERR_STREAM_PREMATURE_CLOSE;
1306
+ function once(callback) {
1307
+ var called = false;
1308
+ return function () {
1309
+ if (called) return;
1310
+ called = true;
1311
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1312
+ args[_key] = arguments[_key];
1313
+ }
1314
+ callback.apply(this, args);
1315
+ };
1316
+ }
1317
+ function noop() {}
1318
+ function isRequest(stream) {
1319
+ return stream.setHeader && typeof stream.abort === "function";
1320
+ }
1321
+ function eos(stream, opts, callback) {
1322
+ if (typeof opts === "function") return eos(stream, null, opts);
1323
+ if (!opts) opts = {};
1324
+ callback = once(callback || noop);
1325
+ var readable = opts.readable || opts.readable !== false && stream.readable;
1326
+ var writable = opts.writable || opts.writable !== false && stream.writable;
1327
+ var onlegacyfinish = function onlegacyfinish() {
1328
+ if (!stream.writable) onfinish();
1329
+ };
1330
+ var writableEnded = stream._writableState && stream._writableState.finished;
1331
+ var onfinish = function onfinish() {
1332
+ writable = false;
1333
+ writableEnded = true;
1334
+ if (!readable) callback.call(stream);
1335
+ };
1336
+ var readableEnded = stream._readableState && stream._readableState.endEmitted;
1337
+ var onend = function onend() {
1338
+ readable = false;
1339
+ readableEnded = true;
1340
+ if (!writable) callback.call(stream);
1341
+ };
1342
+ var onerror = function onerror(err) {
1343
+ callback.call(stream, err);
1344
+ };
1345
+ var onclose = function onclose() {
1346
+ var err;
1347
+ if (readable && !readableEnded) {
1348
+ if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
1349
+ return callback.call(stream, err);
1350
+ }
1351
+ if (writable && !writableEnded) {
1352
+ if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
1353
+ return callback.call(stream, err);
1354
+ }
1355
+ };
1356
+ var onrequest = function onrequest() {
1357
+ stream.req.on("finish", onfinish);
1358
+ };
1359
+ if (isRequest(stream)) {
1360
+ stream.on("complete", onfinish);
1361
+ stream.on("abort", onclose);
1362
+ if (stream.req) onrequest();else stream.on("request", onrequest);
1363
+ } else if (writable && !stream._writableState) {
1364
+ // legacy streams
1365
+ stream.on("end", onlegacyfinish);
1366
+ stream.on("close", onlegacyfinish);
1367
+ }
1368
+ stream.on("end", onend);
1369
+ stream.on("finish", onfinish);
1370
+ if (opts.error !== false) stream.on("error", onerror);
1371
+ stream.on("close", onclose);
1372
+ return function () {
1373
+ stream.removeListener("complete", onfinish);
1374
+ stream.removeListener("abort", onclose);
1375
+ stream.removeListener("request", onrequest);
1376
+ if (stream.req) stream.req.removeListener("finish", onfinish);
1377
+ stream.removeListener("end", onlegacyfinish);
1378
+ stream.removeListener("close", onlegacyfinish);
1379
+ stream.removeListener("finish", onfinish);
1380
+ stream.removeListener("end", onend);
1381
+ stream.removeListener("error", onerror);
1382
+ stream.removeListener("close", onclose);
1383
+ };
1384
+ }
1385
+ exports$d = eos;
1386
+ return exports$d;
1387
+ }
1388
+
1389
+ var exports$c = {},
1390
+ _dewExec$b = false;
1391
+ function dew$b() {
1392
+ if (_dewExec$b) return exports$c;
1393
+ _dewExec$b = true;
1394
+ var process$1 = process;
1395
+ var _Object$setPrototypeO;
1396
+ function _defineProperty(obj, key, value) {
1397
+ key = _toPropertyKey(key);
1398
+ if (key in obj) {
1399
+ Object.defineProperty(obj, key, {
1400
+ value: value,
1401
+ enumerable: true,
1402
+ configurable: true,
1403
+ writable: true
1404
+ });
1405
+ } else {
1406
+ obj[key] = value;
1407
+ }
1408
+ return obj;
1409
+ }
1410
+ function _toPropertyKey(arg) {
1411
+ var key = _toPrimitive(arg, "string");
1412
+ return typeof key === "symbol" ? key : String(key);
1413
+ }
1414
+ function _toPrimitive(input, hint) {
1415
+ if (typeof input !== "object" || input === null) return input;
1416
+ var prim = input[Symbol.toPrimitive];
1417
+ if (prim !== undefined) {
1418
+ var res = prim.call(input, hint || "default");
1419
+ if (typeof res !== "object") return res;
1420
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1421
+ }
1422
+ return (hint === "string" ? String : Number)(input);
1423
+ }
1424
+ var finished = dew$c();
1425
+ var kLastResolve = Symbol("lastResolve");
1426
+ var kLastReject = Symbol("lastReject");
1427
+ var kError = Symbol("error");
1428
+ var kEnded = Symbol("ended");
1429
+ var kLastPromise = Symbol("lastPromise");
1430
+ var kHandlePromise = Symbol("handlePromise");
1431
+ var kStream = Symbol("stream");
1432
+ function createIterResult(value, done) {
1433
+ return {
1434
+ value: value,
1435
+ done: done
1436
+ };
1437
+ }
1438
+ function readAndResolve(iter) {
1439
+ var resolve = iter[kLastResolve];
1440
+ if (resolve !== null) {
1441
+ var data = iter[kStream].read();
1442
+ // we defer if data is null
1443
+ // we can be expecting either 'end' or
1444
+ // 'error'
1445
+ if (data !== null) {
1446
+ iter[kLastPromise] = null;
1447
+ iter[kLastResolve] = null;
1448
+ iter[kLastReject] = null;
1449
+ resolve(createIterResult(data, false));
1450
+ }
1451
+ }
1452
+ }
1453
+ function onReadable(iter) {
1454
+ // we wait for the next tick, because it might
1455
+ // emit an error with process.nextTick
1456
+ process$1.nextTick(readAndResolve, iter);
1457
+ }
1458
+ function wrapForNext(lastPromise, iter) {
1459
+ return function (resolve, reject) {
1460
+ lastPromise.then(function () {
1461
+ if (iter[kEnded]) {
1462
+ resolve(createIterResult(undefined, true));
1463
+ return;
1464
+ }
1465
+ iter[kHandlePromise](resolve, reject);
1466
+ }, reject);
1467
+ };
1468
+ }
1469
+ var AsyncIteratorPrototype = Object.getPrototypeOf(function () {});
1470
+ var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {
1471
+ get stream() {
1472
+ return this[kStream];
1473
+ },
1474
+ next: function next() {
1475
+ var _this = this;
1476
+ // if we have detected an error in the meanwhile
1477
+ // reject straight away
1478
+ var error = this[kError];
1479
+ if (error !== null) {
1480
+ return Promise.reject(error);
1481
+ }
1482
+ if (this[kEnded]) {
1483
+ return Promise.resolve(createIterResult(undefined, true));
1484
+ }
1485
+ if (this[kStream].destroyed) {
1486
+ // We need to defer via nextTick because if .destroy(err) is
1487
+ // called, the error will be emitted via nextTick, and
1488
+ // we cannot guarantee that there is no error lingering around
1489
+ // waiting to be emitted.
1490
+ return new Promise(function (resolve, reject) {
1491
+ process$1.nextTick(function () {
1492
+ if (_this[kError]) {
1493
+ reject(_this[kError]);
1494
+ } else {
1495
+ resolve(createIterResult(undefined, true));
1496
+ }
1497
+ });
1498
+ });
1499
+ }
1500
+
1501
+ // if we have multiple next() calls
1502
+ // we will wait for the previous Promise to finish
1503
+ // this logic is optimized to support for await loops,
1504
+ // where next() is only called once at a time
1505
+ var lastPromise = this[kLastPromise];
1506
+ var promise;
1507
+ if (lastPromise) {
1508
+ promise = new Promise(wrapForNext(lastPromise, this));
1509
+ } else {
1510
+ // fast path needed to support multiple this.push()
1511
+ // without triggering the next() queue
1512
+ var data = this[kStream].read();
1513
+ if (data !== null) {
1514
+ return Promise.resolve(createIterResult(data, false));
1515
+ }
1516
+ promise = new Promise(this[kHandlePromise]);
1517
+ }
1518
+ this[kLastPromise] = promise;
1519
+ return promise;
1520
+ }
1521
+ }, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () {
1522
+ return this;
1523
+ }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
1524
+ var _this2 = this;
1525
+ // destroy(err, cb) is a private API
1526
+ // we can guarantee we have that here, because we control the
1527
+ // Readable class this is attached to
1528
+ return new Promise(function (resolve, reject) {
1529
+ _this2[kStream].destroy(null, function (err) {
1530
+ if (err) {
1531
+ reject(err);
1532
+ return;
1533
+ }
1534
+ resolve(createIterResult(undefined, true));
1535
+ });
1536
+ });
1537
+ }), _Object$setPrototypeO), AsyncIteratorPrototype);
1538
+ var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {
1539
+ var _Object$create;
1540
+ var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
1541
+ value: stream,
1542
+ writable: true
1543
+ }), _defineProperty(_Object$create, kLastResolve, {
1544
+ value: null,
1545
+ writable: true
1546
+ }), _defineProperty(_Object$create, kLastReject, {
1547
+ value: null,
1548
+ writable: true
1549
+ }), _defineProperty(_Object$create, kError, {
1550
+ value: null,
1551
+ writable: true
1552
+ }), _defineProperty(_Object$create, kEnded, {
1553
+ value: stream._readableState.endEmitted,
1554
+ writable: true
1555
+ }), _defineProperty(_Object$create, kHandlePromise, {
1556
+ value: function value(resolve, reject) {
1557
+ var data = iterator[kStream].read();
1558
+ if (data) {
1559
+ iterator[kLastPromise] = null;
1560
+ iterator[kLastResolve] = null;
1561
+ iterator[kLastReject] = null;
1562
+ resolve(createIterResult(data, false));
1563
+ } else {
1564
+ iterator[kLastResolve] = resolve;
1565
+ iterator[kLastReject] = reject;
1566
+ }
1567
+ },
1568
+ writable: true
1569
+ }), _Object$create));
1570
+ iterator[kLastPromise] = null;
1571
+ finished(stream, function (err) {
1572
+ if (err && err.code !== "ERR_STREAM_PREMATURE_CLOSE") {
1573
+ var reject = iterator[kLastReject];
1574
+ // reject if we are waiting for data in the Promise
1575
+ // returned by next() and store the error
1576
+ if (reject !== null) {
1577
+ iterator[kLastPromise] = null;
1578
+ iterator[kLastResolve] = null;
1579
+ iterator[kLastReject] = null;
1580
+ reject(err);
1581
+ }
1582
+ iterator[kError] = err;
1583
+ return;
1584
+ }
1585
+ var resolve = iterator[kLastResolve];
1586
+ if (resolve !== null) {
1587
+ iterator[kLastPromise] = null;
1588
+ iterator[kLastResolve] = null;
1589
+ iterator[kLastReject] = null;
1590
+ resolve(createIterResult(undefined, true));
1591
+ }
1592
+ iterator[kEnded] = true;
1593
+ });
1594
+ stream.on("readable", onReadable.bind(null, iterator));
1595
+ return iterator;
1596
+ };
1597
+ exports$c = createReadableStreamAsyncIterator;
1598
+ return exports$c;
1599
+ }
1600
+
1601
+ var exports$b = {},
1602
+ _dewExec$a = false;
1603
+ function dew$a() {
1604
+ if (_dewExec$a) return exports$b;
1605
+ _dewExec$a = true;
1606
+ exports$b = function () {
1607
+ throw new Error("Readable.from is not available in the browser");
1608
+ };
1609
+ return exports$b;
1610
+ }
1611
+
1612
+ var exports$a = {},
1613
+ _dewExec$9 = false;
1614
+ var _global$3 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
1615
+ function dew$9() {
1616
+ if (_dewExec$9) return exports$a;
1617
+ _dewExec$9 = true;
1618
+ var process$1 = process;
1619
+ exports$a = Readable;
1620
+
1621
+ /*<replacement>*/
1622
+ var Duplex;
1623
+ /*</replacement>*/
1624
+
1625
+ Readable.ReadableState = ReadableState;
1626
+
1627
+ /*<replacement>*/
1628
+ y.EventEmitter;
1629
+ var EElistenerCount = function EElistenerCount(emitter, type) {
1630
+ return emitter.listeners(type).length;
1631
+ };
1632
+ /*</replacement>*/
1633
+
1634
+ /*<replacement>*/
1635
+ var Stream = dew$j();
1636
+ /*</replacement>*/
1637
+
1638
+ var Buffer = dew$l().Buffer;
1639
+ var OurUint8Array = (typeof _global$3 !== "undefined" ? _global$3 : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function () {};
1640
+ function _uint8ArrayToBuffer(chunk) {
1641
+ return Buffer.from(chunk);
1642
+ }
1643
+ function _isUint8Array(obj) {
1644
+ return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
1645
+ }
1646
+
1647
+ /*<replacement>*/
1648
+ var debugUtil = X;
1649
+ var debug;
1650
+ if (debugUtil && debugUtil.debuglog) {
1651
+ debug = debugUtil.debuglog("stream");
1652
+ } else {
1653
+ debug = function debug() {};
1654
+ }
1655
+ /*</replacement>*/
1656
+
1657
+ var BufferList = dew$i();
1658
+ var destroyImpl = dew$h();
1659
+ var _require = dew$f(),
1660
+ getHighWaterMark = _require.getHighWaterMark;
1661
+ var _require$codes = dew$g().codes,
1662
+ ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
1663
+ ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF,
1664
+ ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
1665
+ ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;
1666
+
1667
+ // Lazy loaded to improve the startup performance.
1668
+ var StringDecoder;
1669
+ var createReadableStreamAsyncIterator;
1670
+ var from;
1671
+ dew$m()(Readable, Stream);
1672
+ var errorOrDestroy = destroyImpl.errorOrDestroy;
1673
+ var kProxyEvents = ["error", "close", "destroy", "pause", "resume"];
1674
+ function prependListener(emitter, event, fn) {
1675
+ // Sadly this is not cacheable as some libraries bundle their own
1676
+ // event emitter implementation with them.
1677
+ if (typeof emitter.prependListener === "function") return emitter.prependListener(event, fn);
1678
+
1679
+ // This is a hack to make sure that our error handler is attached before any
1680
+ // userland ones. NEVER DO THIS. This is here only because this code needs
1681
+ // to continue to work with older versions of Node.js that do not include
1682
+ // the prependListener() method. The goal is to eventually remove this hack.
1683
+ if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
1684
+ }
1685
+ function ReadableState(options, stream, isDuplex) {
1686
+ Duplex = Duplex || dew$d();
1687
+ options = options || {};
1688
+
1689
+ // Duplex streams are both readable and writable, but share
1690
+ // the same options object.
1691
+ // However, some cases require setting options to different
1692
+ // values for the readable and the writable sides of the duplex stream.
1693
+ // These options can be provided separately as readableXXX and writableXXX.
1694
+ if (typeof isDuplex !== "boolean") isDuplex = stream instanceof Duplex;
1695
+
1696
+ // object stream flag. Used to make read(n) ignore n and to
1697
+ // make all the buffer merging and length checks go away
1698
+ this.objectMode = !!options.objectMode;
1699
+ if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
1700
+
1701
+ // the point at which it stops calling _read() to fill the buffer
1702
+ // Note: 0 is a valid value, means "don't call _read preemptively ever"
1703
+ this.highWaterMark = getHighWaterMark(this, options, "readableHighWaterMark", isDuplex);
1704
+
1705
+ // A linked list is used to store data chunks instead of an array because the
1706
+ // linked list can remove elements from the beginning faster than
1707
+ // array.shift()
1708
+ this.buffer = new BufferList();
1709
+ this.length = 0;
1710
+ this.pipes = null;
1711
+ this.pipesCount = 0;
1712
+ this.flowing = null;
1713
+ this.ended = false;
1714
+ this.endEmitted = false;
1715
+ this.reading = false;
1716
+
1717
+ // a flag to be able to tell if the event 'readable'/'data' is emitted
1718
+ // immediately, or on a later tick. We set this to true at first, because
1719
+ // any actions that shouldn't happen until "later" should generally also
1720
+ // not happen before the first read call.
1721
+ this.sync = true;
1722
+
1723
+ // whenever we return null, then we set a flag to say
1724
+ // that we're awaiting a 'readable' event emission.
1725
+ this.needReadable = false;
1726
+ this.emittedReadable = false;
1727
+ this.readableListening = false;
1728
+ this.resumeScheduled = false;
1729
+ this.paused = true;
1730
+
1731
+ // Should close be emitted on destroy. Defaults to true.
1732
+ this.emitClose = options.emitClose !== false;
1733
+
1734
+ // Should .destroy() be called after 'end' (and potentially 'finish')
1735
+ this.autoDestroy = !!options.autoDestroy;
1736
+
1737
+ // has it been destroyed
1738
+ this.destroyed = false;
1739
+
1740
+ // Crypto is kind of old and crusty. Historically, its default string
1741
+ // encoding is 'binary' so we have to make this configurable.
1742
+ // Everything else in the universe uses 'utf8', though.
1743
+ this.defaultEncoding = options.defaultEncoding || "utf8";
1744
+
1745
+ // the number of writers that are awaiting a drain event in .pipe()s
1746
+ this.awaitDrain = 0;
1747
+
1748
+ // if true, a maybeReadMore has been scheduled
1749
+ this.readingMore = false;
1750
+ this.decoder = null;
1751
+ this.encoding = null;
1752
+ if (options.encoding) {
1753
+ if (!StringDecoder) StringDecoder = exports$m.StringDecoder;
1754
+ this.decoder = new StringDecoder(options.encoding);
1755
+ this.encoding = options.encoding;
1756
+ }
1757
+ }
1758
+ function Readable(options) {
1759
+ Duplex = Duplex || dew$d();
1760
+ if (!(this instanceof Readable)) return new Readable(options);
1761
+
1762
+ // Checking for a Stream.Duplex instance is faster here instead of inside
1763
+ // the ReadableState constructor, at least with V8 6.5
1764
+ var isDuplex = this instanceof Duplex;
1765
+ this._readableState = new ReadableState(options, this, isDuplex);
1766
+
1767
+ // legacy
1768
+ this.readable = true;
1769
+ if (options) {
1770
+ if (typeof options.read === "function") this._read = options.read;
1771
+ if (typeof options.destroy === "function") this._destroy = options.destroy;
1772
+ }
1773
+ Stream.call(this);
1774
+ }
1775
+ Object.defineProperty(Readable.prototype, "destroyed", {
1776
+ // making it explicit this property is not enumerable
1777
+ // because otherwise some prototype manipulation in
1778
+ // userland will fail
1779
+ enumerable: false,
1780
+ get: function get() {
1781
+ if (this._readableState === undefined) {
1782
+ return false;
1783
+ }
1784
+ return this._readableState.destroyed;
1785
+ },
1786
+ set: function set(value) {
1787
+ // we ignore the value if the stream
1788
+ // has not been initialized yet
1789
+ if (!this._readableState) {
1790
+ return;
1791
+ }
1792
+
1793
+ // backward compatibility, the user is explicitly
1794
+ // managing destroyed
1795
+ this._readableState.destroyed = value;
1796
+ }
1797
+ });
1798
+ Readable.prototype.destroy = destroyImpl.destroy;
1799
+ Readable.prototype._undestroy = destroyImpl.undestroy;
1800
+ Readable.prototype._destroy = function (err, cb) {
1801
+ cb(err);
1802
+ };
1803
+
1804
+ // Manually shove something into the read() buffer.
1805
+ // This returns true if the highWaterMark has not been hit yet,
1806
+ // similar to how Writable.write() returns true if you should
1807
+ // write() some more.
1808
+ Readable.prototype.push = function (chunk, encoding) {
1809
+ var state = this._readableState;
1810
+ var skipChunkCheck;
1811
+ if (!state.objectMode) {
1812
+ if (typeof chunk === "string") {
1813
+ encoding = encoding || state.defaultEncoding;
1814
+ if (encoding !== state.encoding) {
1815
+ chunk = Buffer.from(chunk, encoding);
1816
+ encoding = "";
1817
+ }
1818
+ skipChunkCheck = true;
1819
+ }
1820
+ } else {
1821
+ skipChunkCheck = true;
1822
+ }
1823
+ return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
1824
+ };
1825
+
1826
+ // Unshift should *always* be something directly out of read()
1827
+ Readable.prototype.unshift = function (chunk) {
1828
+ return readableAddChunk(this, chunk, null, true, false);
1829
+ };
1830
+ function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
1831
+ debug("readableAddChunk", chunk);
1832
+ var state = stream._readableState;
1833
+ if (chunk === null) {
1834
+ state.reading = false;
1835
+ onEofChunk(stream, state);
1836
+ } else {
1837
+ var er;
1838
+ if (!skipChunkCheck) er = chunkInvalid(state, chunk);
1839
+ if (er) {
1840
+ errorOrDestroy(stream, er);
1841
+ } else if (state.objectMode || chunk && chunk.length > 0) {
1842
+ if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
1843
+ chunk = _uint8ArrayToBuffer(chunk);
1844
+ }
1845
+ if (addToFront) {
1846
+ if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true);
1847
+ } else if (state.ended) {
1848
+ errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());
1849
+ } else if (state.destroyed) {
1850
+ return false;
1851
+ } else {
1852
+ state.reading = false;
1853
+ if (state.decoder && !encoding) {
1854
+ chunk = state.decoder.write(chunk);
1855
+ if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
1856
+ } else {
1857
+ addChunk(stream, state, chunk, false);
1858
+ }
1859
+ }
1860
+ } else if (!addToFront) {
1861
+ state.reading = false;
1862
+ maybeReadMore(stream, state);
1863
+ }
1864
+ }
1865
+
1866
+ // We can push more data if we are below the highWaterMark.
1867
+ // Also, if we have no data yet, we can stand some more bytes.
1868
+ // This is to work around cases where hwm=0, such as the repl.
1869
+ return !state.ended && (state.length < state.highWaterMark || state.length === 0);
1870
+ }
1871
+ function addChunk(stream, state, chunk, addToFront) {
1872
+ if (state.flowing && state.length === 0 && !state.sync) {
1873
+ state.awaitDrain = 0;
1874
+ stream.emit("data", chunk);
1875
+ } else {
1876
+ // update the buffer info.
1877
+ state.length += state.objectMode ? 1 : chunk.length;
1878
+ if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
1879
+ if (state.needReadable) emitReadable(stream);
1880
+ }
1881
+ maybeReadMore(stream, state);
1882
+ }
1883
+ function chunkInvalid(state, chunk) {
1884
+ var er;
1885
+ if (!_isUint8Array(chunk) && typeof chunk !== "string" && chunk !== undefined && !state.objectMode) {
1886
+ er = new ERR_INVALID_ARG_TYPE("chunk", ["string", "Buffer", "Uint8Array"], chunk);
1887
+ }
1888
+ return er;
1889
+ }
1890
+ Readable.prototype.isPaused = function () {
1891
+ return this._readableState.flowing === false;
1892
+ };
1893
+
1894
+ // backwards compatibility.
1895
+ Readable.prototype.setEncoding = function (enc) {
1896
+ if (!StringDecoder) StringDecoder = exports$m.StringDecoder;
1897
+ var decoder = new StringDecoder(enc);
1898
+ this._readableState.decoder = decoder;
1899
+ // If setEncoding(null), decoder.encoding equals utf8
1900
+ this._readableState.encoding = this._readableState.decoder.encoding;
1901
+
1902
+ // Iterate over current buffer to convert already stored Buffers:
1903
+ var p = this._readableState.buffer.head;
1904
+ var content = "";
1905
+ while (p !== null) {
1906
+ content += decoder.write(p.data);
1907
+ p = p.next;
1908
+ }
1909
+ this._readableState.buffer.clear();
1910
+ if (content !== "") this._readableState.buffer.push(content);
1911
+ this._readableState.length = content.length;
1912
+ return this;
1913
+ };
1914
+
1915
+ // Don't raise the hwm > 1GB
1916
+ var MAX_HWM = 1073741824;
1917
+ function computeNewHighWaterMark(n) {
1918
+ if (n >= MAX_HWM) {
1919
+ // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
1920
+ n = MAX_HWM;
1921
+ } else {
1922
+ // Get the next highest power of 2 to prevent increasing hwm excessively in
1923
+ // tiny amounts
1924
+ n--;
1925
+ n |= n >>> 1;
1926
+ n |= n >>> 2;
1927
+ n |= n >>> 4;
1928
+ n |= n >>> 8;
1929
+ n |= n >>> 16;
1930
+ n++;
1931
+ }
1932
+ return n;
1933
+ }
1934
+
1935
+ // This function is designed to be inlinable, so please take care when making
1936
+ // changes to the function body.
1937
+ function howMuchToRead(n, state) {
1938
+ if (n <= 0 || state.length === 0 && state.ended) return 0;
1939
+ if (state.objectMode) return 1;
1940
+ if (n !== n) {
1941
+ // Only flow one buffer at a time
1942
+ if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
1943
+ }
1944
+ // If we're asking for more than the current hwm, then raise the hwm.
1945
+ if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
1946
+ if (n <= state.length) return n;
1947
+ // Don't have enough
1948
+ if (!state.ended) {
1949
+ state.needReadable = true;
1950
+ return 0;
1951
+ }
1952
+ return state.length;
1953
+ }
1954
+
1955
+ // you can override either this method, or the async _read(n) below.
1956
+ Readable.prototype.read = function (n) {
1957
+ debug("read", n);
1958
+ n = parseInt(n, 10);
1959
+ var state = this._readableState;
1960
+ var nOrig = n;
1961
+ if (n !== 0) state.emittedReadable = false;
1962
+
1963
+ // if we're doing read(0) to trigger a readable event, but we
1964
+ // already have a bunch of data in the buffer, then just trigger
1965
+ // the 'readable' event and move on.
1966
+ if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
1967
+ debug("read: emitReadable", state.length, state.ended);
1968
+ if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
1969
+ return null;
1970
+ }
1971
+ n = howMuchToRead(n, state);
1972
+
1973
+ // if we've ended, and we're now clear, then finish it up.
1974
+ if (n === 0 && state.ended) {
1975
+ if (state.length === 0) endReadable(this);
1976
+ return null;
1977
+ }
1978
+
1979
+ // All the actual chunk generation logic needs to be
1980
+ // *below* the call to _read. The reason is that in certain
1981
+ // synthetic stream cases, such as passthrough streams, _read
1982
+ // may be a completely synchronous operation which may change
1983
+ // the state of the read buffer, providing enough data when
1984
+ // before there was *not* enough.
1985
+ //
1986
+ // So, the steps are:
1987
+ // 1. Figure out what the state of things will be after we do
1988
+ // a read from the buffer.
1989
+ //
1990
+ // 2. If that resulting state will trigger a _read, then call _read.
1991
+ // Note that this may be asynchronous, or synchronous. Yes, it is
1992
+ // deeply ugly to write APIs this way, but that still doesn't mean
1993
+ // that the Readable class should behave improperly, as streams are
1994
+ // designed to be sync/async agnostic.
1995
+ // Take note if the _read call is sync or async (ie, if the read call
1996
+ // has returned yet), so that we know whether or not it's safe to emit
1997
+ // 'readable' etc.
1998
+ //
1999
+ // 3. Actually pull the requested chunks out of the buffer and return.
2000
+
2001
+ // if we need a readable event, then we need to do some reading.
2002
+ var doRead = state.needReadable;
2003
+ debug("need readable", doRead);
2004
+
2005
+ // if we currently have less than the highWaterMark, then also read some
2006
+ if (state.length === 0 || state.length - n < state.highWaterMark) {
2007
+ doRead = true;
2008
+ debug("length less than watermark", doRead);
2009
+ }
2010
+
2011
+ // however, if we've ended, then there's no point, and if we're already
2012
+ // reading, then it's unnecessary.
2013
+ if (state.ended || state.reading) {
2014
+ doRead = false;
2015
+ debug("reading or ended", doRead);
2016
+ } else if (doRead) {
2017
+ debug("do read");
2018
+ state.reading = true;
2019
+ state.sync = true;
2020
+ // if the length is currently zero, then we *need* a readable event.
2021
+ if (state.length === 0) state.needReadable = true;
2022
+ // call internal read method
2023
+ this._read(state.highWaterMark);
2024
+ state.sync = false;
2025
+ // If _read pushed data synchronously, then `reading` will be false,
2026
+ // and we need to re-evaluate how much data we can return to the user.
2027
+ if (!state.reading) n = howMuchToRead(nOrig, state);
2028
+ }
2029
+ var ret;
2030
+ if (n > 0) ret = fromList(n, state);else ret = null;
2031
+ if (ret === null) {
2032
+ state.needReadable = state.length <= state.highWaterMark;
2033
+ n = 0;
2034
+ } else {
2035
+ state.length -= n;
2036
+ state.awaitDrain = 0;
2037
+ }
2038
+ if (state.length === 0) {
2039
+ // If we have nothing in the buffer, then we want to know
2040
+ // as soon as we *do* get something into the buffer.
2041
+ if (!state.ended) state.needReadable = true;
2042
+
2043
+ // If we tried to read() past the EOF, then emit end on the next tick.
2044
+ if (nOrig !== n && state.ended) endReadable(this);
2045
+ }
2046
+ if (ret !== null) this.emit("data", ret);
2047
+ return ret;
2048
+ };
2049
+ function onEofChunk(stream, state) {
2050
+ debug("onEofChunk");
2051
+ if (state.ended) return;
2052
+ if (state.decoder) {
2053
+ var chunk = state.decoder.end();
2054
+ if (chunk && chunk.length) {
2055
+ state.buffer.push(chunk);
2056
+ state.length += state.objectMode ? 1 : chunk.length;
2057
+ }
2058
+ }
2059
+ state.ended = true;
2060
+ if (state.sync) {
2061
+ // if we are sync, wait until next tick to emit the data.
2062
+ // Otherwise we risk emitting data in the flow()
2063
+ // the readable code triggers during a read() call
2064
+ emitReadable(stream);
2065
+ } else {
2066
+ // emit 'readable' now to make sure it gets picked up.
2067
+ state.needReadable = false;
2068
+ if (!state.emittedReadable) {
2069
+ state.emittedReadable = true;
2070
+ emitReadable_(stream);
2071
+ }
2072
+ }
2073
+ }
2074
+
2075
+ // Don't emit readable right away in sync mode, because this can trigger
2076
+ // another read() call => stack overflow. This way, it might trigger
2077
+ // a nextTick recursion warning, but that's not so bad.
2078
+ function emitReadable(stream) {
2079
+ var state = stream._readableState;
2080
+ debug("emitReadable", state.needReadable, state.emittedReadable);
2081
+ state.needReadable = false;
2082
+ if (!state.emittedReadable) {
2083
+ debug("emitReadable", state.flowing);
2084
+ state.emittedReadable = true;
2085
+ process$1.nextTick(emitReadable_, stream);
2086
+ }
2087
+ }
2088
+ function emitReadable_(stream) {
2089
+ var state = stream._readableState;
2090
+ debug("emitReadable_", state.destroyed, state.length, state.ended);
2091
+ if (!state.destroyed && (state.length || state.ended)) {
2092
+ stream.emit("readable");
2093
+ state.emittedReadable = false;
2094
+ }
2095
+
2096
+ // The stream needs another readable event if
2097
+ // 1. It is not flowing, as the flow mechanism will take
2098
+ // care of it.
2099
+ // 2. It is not ended.
2100
+ // 3. It is below the highWaterMark, so we can schedule
2101
+ // another readable later.
2102
+ state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;
2103
+ flow(stream);
2104
+ }
2105
+
2106
+ // at this point, the user has presumably seen the 'readable' event,
2107
+ // and called read() to consume some data. that may have triggered
2108
+ // in turn another _read(n) call, in which case reading = true if
2109
+ // it's in progress.
2110
+ // However, if we're not ended, or reading, and the length < hwm,
2111
+ // then go ahead and try to read some more preemptively.
2112
+ function maybeReadMore(stream, state) {
2113
+ if (!state.readingMore) {
2114
+ state.readingMore = true;
2115
+ process$1.nextTick(maybeReadMore_, stream, state);
2116
+ }
2117
+ }
2118
+ function maybeReadMore_(stream, state) {
2119
+ // Attempt to read more data if we should.
2120
+ //
2121
+ // The conditions for reading more data are (one of):
2122
+ // - Not enough data buffered (state.length < state.highWaterMark). The loop
2123
+ // is responsible for filling the buffer with enough data if such data
2124
+ // is available. If highWaterMark is 0 and we are not in the flowing mode
2125
+ // we should _not_ attempt to buffer any extra data. We'll get more data
2126
+ // when the stream consumer calls read() instead.
2127
+ // - No data in the buffer, and the stream is in flowing mode. In this mode
2128
+ // the loop below is responsible for ensuring read() is called. Failing to
2129
+ // call read here would abort the flow and there's no other mechanism for
2130
+ // continuing the flow if the stream consumer has just subscribed to the
2131
+ // 'data' event.
2132
+ //
2133
+ // In addition to the above conditions to keep reading data, the following
2134
+ // conditions prevent the data from being read:
2135
+ // - The stream has ended (state.ended).
2136
+ // - There is already a pending 'read' operation (state.reading). This is a
2137
+ // case where the the stream has called the implementation defined _read()
2138
+ // method, but they are processing the call asynchronously and have _not_
2139
+ // called push() with new data. In this case we skip performing more
2140
+ // read()s. The execution ends in this method again after the _read() ends
2141
+ // up calling push() with more data.
2142
+ while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
2143
+ var len = state.length;
2144
+ debug("maybeReadMore read 0");
2145
+ stream.read(0);
2146
+ if (len === state.length)
2147
+ // didn't get any data, stop spinning.
2148
+ break;
2149
+ }
2150
+ state.readingMore = false;
2151
+ }
2152
+
2153
+ // abstract method. to be overridden in specific implementation classes.
2154
+ // call cb(er, data) where data is <= n in length.
2155
+ // for virtual (non-string, non-buffer) streams, "length" is somewhat
2156
+ // arbitrary, and perhaps not very meaningful.
2157
+ Readable.prototype._read = function (n) {
2158
+ errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED("_read()"));
2159
+ };
2160
+ Readable.prototype.pipe = function (dest, pipeOpts) {
2161
+ var src = this;
2162
+ var state = this._readableState;
2163
+ switch (state.pipesCount) {
2164
+ case 0:
2165
+ state.pipes = dest;
2166
+ break;
2167
+ case 1:
2168
+ state.pipes = [state.pipes, dest];
2169
+ break;
2170
+ default:
2171
+ state.pipes.push(dest);
2172
+ break;
2173
+ }
2174
+ state.pipesCount += 1;
2175
+ debug("pipe count=%d opts=%j", state.pipesCount, pipeOpts);
2176
+ var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process$1.stdout && dest !== process$1.stderr;
2177
+ var endFn = doEnd ? onend : unpipe;
2178
+ if (state.endEmitted) process$1.nextTick(endFn);else src.once("end", endFn);
2179
+ dest.on("unpipe", onunpipe);
2180
+ function onunpipe(readable, unpipeInfo) {
2181
+ debug("onunpipe");
2182
+ if (readable === src) {
2183
+ if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
2184
+ unpipeInfo.hasUnpiped = true;
2185
+ cleanup();
2186
+ }
2187
+ }
2188
+ }
2189
+ function onend() {
2190
+ debug("onend");
2191
+ dest.end();
2192
+ }
2193
+
2194
+ // when the dest drains, it reduces the awaitDrain counter
2195
+ // on the source. This would be more elegant with a .once()
2196
+ // handler in flow(), but adding and removing repeatedly is
2197
+ // too slow.
2198
+ var ondrain = pipeOnDrain(src);
2199
+ dest.on("drain", ondrain);
2200
+ var cleanedUp = false;
2201
+ function cleanup() {
2202
+ debug("cleanup");
2203
+ // cleanup event handlers once the pipe is broken
2204
+ dest.removeListener("close", onclose);
2205
+ dest.removeListener("finish", onfinish);
2206
+ dest.removeListener("drain", ondrain);
2207
+ dest.removeListener("error", onerror);
2208
+ dest.removeListener("unpipe", onunpipe);
2209
+ src.removeListener("end", onend);
2210
+ src.removeListener("end", unpipe);
2211
+ src.removeListener("data", ondata);
2212
+ cleanedUp = true;
2213
+
2214
+ // if the reader is waiting for a drain event from this
2215
+ // specific writer, then it would cause it to never start
2216
+ // flowing again.
2217
+ // So, if this is awaiting a drain, then we just call it now.
2218
+ // If we don't know, then assume that we are waiting for one.
2219
+ if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
2220
+ }
2221
+ src.on("data", ondata);
2222
+ function ondata(chunk) {
2223
+ debug("ondata");
2224
+ var ret = dest.write(chunk);
2225
+ debug("dest.write", ret);
2226
+ if (ret === false) {
2227
+ // If the user unpiped during `dest.write()`, it is possible
2228
+ // to get stuck in a permanently paused state if that write
2229
+ // also returned false.
2230
+ // => Check whether `dest` is still a piping destination.
2231
+ if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
2232
+ debug("false write response, pause", state.awaitDrain);
2233
+ state.awaitDrain++;
2234
+ }
2235
+ src.pause();
2236
+ }
2237
+ }
2238
+
2239
+ // if the dest has an error, then stop piping into it.
2240
+ // however, don't suppress the throwing behavior for this.
2241
+ function onerror(er) {
2242
+ debug("onerror", er);
2243
+ unpipe();
2244
+ dest.removeListener("error", onerror);
2245
+ if (EElistenerCount(dest, "error") === 0) errorOrDestroy(dest, er);
2246
+ }
2247
+
2248
+ // Make sure our error handler is attached before userland ones.
2249
+ prependListener(dest, "error", onerror);
2250
+
2251
+ // Both close and finish should trigger unpipe, but only once.
2252
+ function onclose() {
2253
+ dest.removeListener("finish", onfinish);
2254
+ unpipe();
2255
+ }
2256
+ dest.once("close", onclose);
2257
+ function onfinish() {
2258
+ debug("onfinish");
2259
+ dest.removeListener("close", onclose);
2260
+ unpipe();
2261
+ }
2262
+ dest.once("finish", onfinish);
2263
+ function unpipe() {
2264
+ debug("unpipe");
2265
+ src.unpipe(dest);
2266
+ }
2267
+
2268
+ // tell the dest that it's being piped to
2269
+ dest.emit("pipe", src);
2270
+
2271
+ // start the flow if it hasn't been started already.
2272
+ if (!state.flowing) {
2273
+ debug("pipe resume");
2274
+ src.resume();
2275
+ }
2276
+ return dest;
2277
+ };
2278
+ function pipeOnDrain(src) {
2279
+ return function pipeOnDrainFunctionResult() {
2280
+ var state = src._readableState;
2281
+ debug("pipeOnDrain", state.awaitDrain);
2282
+ if (state.awaitDrain) state.awaitDrain--;
2283
+ if (state.awaitDrain === 0 && EElistenerCount(src, "data")) {
2284
+ state.flowing = true;
2285
+ flow(src);
2286
+ }
2287
+ };
2288
+ }
2289
+ Readable.prototype.unpipe = function (dest) {
2290
+ var state = this._readableState;
2291
+ var unpipeInfo = {
2292
+ hasUnpiped: false
2293
+ };
2294
+
2295
+ // if we're not piping anywhere, then do nothing.
2296
+ if (state.pipesCount === 0) return this;
2297
+
2298
+ // just one destination. most common case.
2299
+ if (state.pipesCount === 1) {
2300
+ // passed in one, but it's not the right one.
2301
+ if (dest && dest !== state.pipes) return this;
2302
+ if (!dest) dest = state.pipes;
2303
+
2304
+ // got a match.
2305
+ state.pipes = null;
2306
+ state.pipesCount = 0;
2307
+ state.flowing = false;
2308
+ if (dest) dest.emit("unpipe", this, unpipeInfo);
2309
+ return this;
2310
+ }
2311
+
2312
+ // slow case. multiple pipe destinations.
2313
+
2314
+ if (!dest) {
2315
+ // remove all.
2316
+ var dests = state.pipes;
2317
+ var len = state.pipesCount;
2318
+ state.pipes = null;
2319
+ state.pipesCount = 0;
2320
+ state.flowing = false;
2321
+ for (var i = 0; i < len; i++) dests[i].emit("unpipe", this, {
2322
+ hasUnpiped: false
2323
+ });
2324
+ return this;
2325
+ }
2326
+
2327
+ // try to find the right one.
2328
+ var index = indexOf(state.pipes, dest);
2329
+ if (index === -1) return this;
2330
+ state.pipes.splice(index, 1);
2331
+ state.pipesCount -= 1;
2332
+ if (state.pipesCount === 1) state.pipes = state.pipes[0];
2333
+ dest.emit("unpipe", this, unpipeInfo);
2334
+ return this;
2335
+ };
2336
+
2337
+ // set up data events if they are asked for
2338
+ // Ensure readable listeners eventually get something
2339
+ Readable.prototype.on = function (ev, fn) {
2340
+ var res = Stream.prototype.on.call(this, ev, fn);
2341
+ var state = this._readableState;
2342
+ if (ev === "data") {
2343
+ // update readableListening so that resume() may be a no-op
2344
+ // a few lines down. This is needed to support once('readable').
2345
+ state.readableListening = this.listenerCount("readable") > 0;
2346
+
2347
+ // Try start flowing on next tick if stream isn't explicitly paused
2348
+ if (state.flowing !== false) this.resume();
2349
+ } else if (ev === "readable") {
2350
+ if (!state.endEmitted && !state.readableListening) {
2351
+ state.readableListening = state.needReadable = true;
2352
+ state.flowing = false;
2353
+ state.emittedReadable = false;
2354
+ debug("on readable", state.length, state.reading);
2355
+ if (state.length) {
2356
+ emitReadable(this);
2357
+ } else if (!state.reading) {
2358
+ process$1.nextTick(nReadingNextTick, this);
2359
+ }
2360
+ }
2361
+ }
2362
+ return res;
2363
+ };
2364
+ Readable.prototype.addListener = Readable.prototype.on;
2365
+ Readable.prototype.removeListener = function (ev, fn) {
2366
+ var res = Stream.prototype.removeListener.call(this, ev, fn);
2367
+ if (ev === "readable") {
2368
+ // We need to check if there is someone still listening to
2369
+ // readable and reset the state. However this needs to happen
2370
+ // after readable has been emitted but before I/O (nextTick) to
2371
+ // support once('readable', fn) cycles. This means that calling
2372
+ // resume within the same tick will have no
2373
+ // effect.
2374
+ process$1.nextTick(updateReadableListening, this);
2375
+ }
2376
+ return res;
2377
+ };
2378
+ Readable.prototype.removeAllListeners = function (ev) {
2379
+ var res = Stream.prototype.removeAllListeners.apply(this, arguments);
2380
+ if (ev === "readable" || ev === undefined) {
2381
+ // We need to check if there is someone still listening to
2382
+ // readable and reset the state. However this needs to happen
2383
+ // after readable has been emitted but before I/O (nextTick) to
2384
+ // support once('readable', fn) cycles. This means that calling
2385
+ // resume within the same tick will have no
2386
+ // effect.
2387
+ process$1.nextTick(updateReadableListening, this);
2388
+ }
2389
+ return res;
2390
+ };
2391
+ function updateReadableListening(self) {
2392
+ var state = self._readableState;
2393
+ state.readableListening = self.listenerCount("readable") > 0;
2394
+ if (state.resumeScheduled && !state.paused) {
2395
+ // flowing needs to be set to true now, otherwise
2396
+ // the upcoming resume will not flow.
2397
+ state.flowing = true;
2398
+
2399
+ // crude way to check if we should resume
2400
+ } else if (self.listenerCount("data") > 0) {
2401
+ self.resume();
2402
+ }
2403
+ }
2404
+ function nReadingNextTick(self) {
2405
+ debug("readable nexttick read 0");
2406
+ self.read(0);
2407
+ }
2408
+
2409
+ // pause() and resume() are remnants of the legacy readable stream API
2410
+ // If the user uses them, then switch into old mode.
2411
+ Readable.prototype.resume = function () {
2412
+ var state = this._readableState;
2413
+ if (!state.flowing) {
2414
+ debug("resume");
2415
+ // we flow only if there is no one listening
2416
+ // for readable, but we still have to call
2417
+ // resume()
2418
+ state.flowing = !state.readableListening;
2419
+ resume(this, state);
2420
+ }
2421
+ state.paused = false;
2422
+ return this;
2423
+ };
2424
+ function resume(stream, state) {
2425
+ if (!state.resumeScheduled) {
2426
+ state.resumeScheduled = true;
2427
+ process$1.nextTick(resume_, stream, state);
2428
+ }
2429
+ }
2430
+ function resume_(stream, state) {
2431
+ debug("resume", state.reading);
2432
+ if (!state.reading) {
2433
+ stream.read(0);
2434
+ }
2435
+ state.resumeScheduled = false;
2436
+ stream.emit("resume");
2437
+ flow(stream);
2438
+ if (state.flowing && !state.reading) stream.read(0);
2439
+ }
2440
+ Readable.prototype.pause = function () {
2441
+ debug("call pause flowing=%j", this._readableState.flowing);
2442
+ if (this._readableState.flowing !== false) {
2443
+ debug("pause");
2444
+ this._readableState.flowing = false;
2445
+ this.emit("pause");
2446
+ }
2447
+ this._readableState.paused = true;
2448
+ return this;
2449
+ };
2450
+ function flow(stream) {
2451
+ var state = stream._readableState;
2452
+ debug("flow", state.flowing);
2453
+ while (state.flowing && stream.read() !== null);
2454
+ }
2455
+
2456
+ // wrap an old-style stream as the async data source.
2457
+ // This is *not* part of the readable stream interface.
2458
+ // It is an ugly unfortunate mess of history.
2459
+ Readable.prototype.wrap = function (stream) {
2460
+ var _this = this;
2461
+ var state = this._readableState;
2462
+ var paused = false;
2463
+ stream.on("end", function () {
2464
+ debug("wrapped end");
2465
+ if (state.decoder && !state.ended) {
2466
+ var chunk = state.decoder.end();
2467
+ if (chunk && chunk.length) _this.push(chunk);
2468
+ }
2469
+ _this.push(null);
2470
+ });
2471
+ stream.on("data", function (chunk) {
2472
+ debug("wrapped data");
2473
+ if (state.decoder) chunk = state.decoder.write(chunk);
2474
+
2475
+ // don't skip over falsy values in objectMode
2476
+ if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
2477
+ var ret = _this.push(chunk);
2478
+ if (!ret) {
2479
+ paused = true;
2480
+ stream.pause();
2481
+ }
2482
+ });
2483
+
2484
+ // proxy all the other methods.
2485
+ // important when wrapping filters and duplexes.
2486
+ for (var i in stream) {
2487
+ if (this[i] === undefined && typeof stream[i] === "function") {
2488
+ this[i] = function methodWrap(method) {
2489
+ return function methodWrapReturnFunction() {
2490
+ return stream[method].apply(stream, arguments);
2491
+ };
2492
+ }(i);
2493
+ }
2494
+ }
2495
+
2496
+ // proxy certain important events.
2497
+ for (var n = 0; n < kProxyEvents.length; n++) {
2498
+ stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
2499
+ }
2500
+
2501
+ // when we try to consume some more bytes, simply unpause the
2502
+ // underlying stream.
2503
+ this._read = function (n) {
2504
+ debug("wrapped _read", n);
2505
+ if (paused) {
2506
+ paused = false;
2507
+ stream.resume();
2508
+ }
2509
+ };
2510
+ return this;
2511
+ };
2512
+ if (typeof Symbol === "function") {
2513
+ Readable.prototype[Symbol.asyncIterator] = function () {
2514
+ if (createReadableStreamAsyncIterator === undefined) {
2515
+ createReadableStreamAsyncIterator = dew$b();
2516
+ }
2517
+ return createReadableStreamAsyncIterator(this);
2518
+ };
2519
+ }
2520
+ Object.defineProperty(Readable.prototype, "readableHighWaterMark", {
2521
+ // making it explicit this property is not enumerable
2522
+ // because otherwise some prototype manipulation in
2523
+ // userland will fail
2524
+ enumerable: false,
2525
+ get: function get() {
2526
+ return this._readableState.highWaterMark;
2527
+ }
2528
+ });
2529
+ Object.defineProperty(Readable.prototype, "readableBuffer", {
2530
+ // making it explicit this property is not enumerable
2531
+ // because otherwise some prototype manipulation in
2532
+ // userland will fail
2533
+ enumerable: false,
2534
+ get: function get() {
2535
+ return this._readableState && this._readableState.buffer;
2536
+ }
2537
+ });
2538
+ Object.defineProperty(Readable.prototype, "readableFlowing", {
2539
+ // making it explicit this property is not enumerable
2540
+ // because otherwise some prototype manipulation in
2541
+ // userland will fail
2542
+ enumerable: false,
2543
+ get: function get() {
2544
+ return this._readableState.flowing;
2545
+ },
2546
+ set: function set(state) {
2547
+ if (this._readableState) {
2548
+ this._readableState.flowing = state;
2549
+ }
2550
+ }
2551
+ });
2552
+
2553
+ // exposed for testing purposes only.
2554
+ Readable._fromList = fromList;
2555
+ Object.defineProperty(Readable.prototype, "readableLength", {
2556
+ // making it explicit this property is not enumerable
2557
+ // because otherwise some prototype manipulation in
2558
+ // userland will fail
2559
+ enumerable: false,
2560
+ get: function get() {
2561
+ return this._readableState.length;
2562
+ }
2563
+ });
2564
+
2565
+ // Pluck off n bytes from an array of buffers.
2566
+ // Length is the combined lengths of all the buffers in the list.
2567
+ // This function is designed to be inlinable, so please take care when making
2568
+ // changes to the function body.
2569
+ function fromList(n, state) {
2570
+ // nothing buffered
2571
+ if (state.length === 0) return null;
2572
+ var ret;
2573
+ if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
2574
+ // read it all, truncate the list
2575
+ if (state.decoder) ret = state.buffer.join("");else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length);
2576
+ state.buffer.clear();
2577
+ } else {
2578
+ // read part of list
2579
+ ret = state.buffer.consume(n, state.decoder);
2580
+ }
2581
+ return ret;
2582
+ }
2583
+ function endReadable(stream) {
2584
+ var state = stream._readableState;
2585
+ debug("endReadable", state.endEmitted);
2586
+ if (!state.endEmitted) {
2587
+ state.ended = true;
2588
+ process$1.nextTick(endReadableNT, state, stream);
2589
+ }
2590
+ }
2591
+ function endReadableNT(state, stream) {
2592
+ debug("endReadableNT", state.endEmitted, state.length);
2593
+
2594
+ // Check that we didn't get one last unshift.
2595
+ if (!state.endEmitted && state.length === 0) {
2596
+ state.endEmitted = true;
2597
+ stream.readable = false;
2598
+ stream.emit("end");
2599
+ if (state.autoDestroy) {
2600
+ // In case of duplex streams we need a way to detect
2601
+ // if the writable side is ready for autoDestroy as well
2602
+ var wState = stream._writableState;
2603
+ if (!wState || wState.autoDestroy && wState.finished) {
2604
+ stream.destroy();
2605
+ }
2606
+ }
2607
+ }
2608
+ }
2609
+ if (typeof Symbol === "function") {
2610
+ Readable.from = function (iterable, opts) {
2611
+ if (from === undefined) {
2612
+ from = dew$a();
2613
+ }
2614
+ return from(Readable, iterable, opts);
2615
+ };
2616
+ }
2617
+ function indexOf(xs, x) {
2618
+ for (var i = 0, l = xs.length; i < l; i++) {
2619
+ if (xs[i] === x) return i;
2620
+ }
2621
+ return -1;
2622
+ }
2623
+ return exports$a;
2624
+ }
2625
+
2626
+ var exports$9 = {},
2627
+ _dewExec$8 = false;
2628
+ function dew$8() {
2629
+ if (_dewExec$8) return exports$9;
2630
+ _dewExec$8 = true;
2631
+ exports$9 = Transform;
2632
+ var _require$codes = dew$g().codes,
2633
+ ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
2634
+ ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
2635
+ ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
2636
+ ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
2637
+ var Duplex = dew$d();
2638
+ dew$m()(Transform, Duplex);
2639
+ function afterTransform(er, data) {
2640
+ var ts = this._transformState;
2641
+ ts.transforming = false;
2642
+ var cb = ts.writecb;
2643
+ if (cb === null) {
2644
+ return this.emit("error", new ERR_MULTIPLE_CALLBACK());
2645
+ }
2646
+ ts.writechunk = null;
2647
+ ts.writecb = null;
2648
+ if (data != null)
2649
+ // single equals check for both `null` and `undefined`
2650
+ this.push(data);
2651
+ cb(er);
2652
+ var rs = this._readableState;
2653
+ rs.reading = false;
2654
+ if (rs.needReadable || rs.length < rs.highWaterMark) {
2655
+ this._read(rs.highWaterMark);
2656
+ }
2657
+ }
2658
+ function Transform(options) {
2659
+ if (!(this instanceof Transform)) return new Transform(options);
2660
+ Duplex.call(this, options);
2661
+ this._transformState = {
2662
+ afterTransform: afterTransform.bind(this),
2663
+ needTransform: false,
2664
+ transforming: false,
2665
+ writecb: null,
2666
+ writechunk: null,
2667
+ writeencoding: null
2668
+ };
2669
+
2670
+ // start out asking for a readable event once data is transformed.
2671
+ this._readableState.needReadable = true;
2672
+
2673
+ // we have implemented the _read method, and done the other things
2674
+ // that Readable wants before the first _read call, so unset the
2675
+ // sync guard flag.
2676
+ this._readableState.sync = false;
2677
+ if (options) {
2678
+ if (typeof options.transform === "function") this._transform = options.transform;
2679
+ if (typeof options.flush === "function") this._flush = options.flush;
2680
+ }
2681
+
2682
+ // When the writable side finishes, then flush out anything remaining.
2683
+ this.on("prefinish", prefinish);
2684
+ }
2685
+ function prefinish() {
2686
+ var _this = this;
2687
+ if (typeof this._flush === "function" && !this._readableState.destroyed) {
2688
+ this._flush(function (er, data) {
2689
+ done(_this, er, data);
2690
+ });
2691
+ } else {
2692
+ done(this, null, null);
2693
+ }
2694
+ }
2695
+ Transform.prototype.push = function (chunk, encoding) {
2696
+ this._transformState.needTransform = false;
2697
+ return Duplex.prototype.push.call(this, chunk, encoding);
2698
+ };
2699
+
2700
+ // This is the part where you do stuff!
2701
+ // override this function in implementation classes.
2702
+ // 'chunk' is an input chunk.
2703
+ //
2704
+ // Call `push(newChunk)` to pass along transformed output
2705
+ // to the readable side. You may call 'push' zero or more times.
2706
+ //
2707
+ // Call `cb(err)` when you are done with this chunk. If you pass
2708
+ // an error, then that'll put the hurt on the whole operation. If you
2709
+ // never call cb(), then you'll never get another chunk.
2710
+ Transform.prototype._transform = function (chunk, encoding, cb) {
2711
+ cb(new ERR_METHOD_NOT_IMPLEMENTED("_transform()"));
2712
+ };
2713
+ Transform.prototype._write = function (chunk, encoding, cb) {
2714
+ var ts = this._transformState;
2715
+ ts.writecb = cb;
2716
+ ts.writechunk = chunk;
2717
+ ts.writeencoding = encoding;
2718
+ if (!ts.transforming) {
2719
+ var rs = this._readableState;
2720
+ if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
2721
+ }
2722
+ };
2723
+
2724
+ // Doesn't matter what the args are here.
2725
+ // _transform does all the work.
2726
+ // That we got here means that the readable side wants more data.
2727
+ Transform.prototype._read = function (n) {
2728
+ var ts = this._transformState;
2729
+ if (ts.writechunk !== null && !ts.transforming) {
2730
+ ts.transforming = true;
2731
+ this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
2732
+ } else {
2733
+ // mark that we need a transform, so that any data that comes in
2734
+ // will get processed, now that we've asked for it.
2735
+ ts.needTransform = true;
2736
+ }
2737
+ };
2738
+ Transform.prototype._destroy = function (err, cb) {
2739
+ Duplex.prototype._destroy.call(this, err, function (err2) {
2740
+ cb(err2);
2741
+ });
2742
+ };
2743
+ function done(stream, er, data) {
2744
+ if (er) return stream.emit("error", er);
2745
+ if (data != null)
2746
+ // single equals check for both `null` and `undefined`
2747
+ stream.push(data);
2748
+
2749
+ // TODO(BridgeAR): Write a test for these two error cases
2750
+ // if there's nothing in the write buffer, then that means
2751
+ // that nothing more will ever be provided
2752
+ if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();
2753
+ if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();
2754
+ return stream.push(null);
2755
+ }
2756
+ return exports$9;
2757
+ }
2758
+
2759
+ var exports$8 = {},
2760
+ _dewExec$7 = false;
2761
+ function dew$7() {
2762
+ if (_dewExec$7) return exports$8;
2763
+ _dewExec$7 = true;
2764
+ exports$8 = PassThrough;
2765
+ var Transform = dew$8();
2766
+ dew$m()(PassThrough, Transform);
2767
+ function PassThrough(options) {
2768
+ if (!(this instanceof PassThrough)) return new PassThrough(options);
2769
+ Transform.call(this, options);
2770
+ }
2771
+ PassThrough.prototype._transform = function (chunk, encoding, cb) {
2772
+ cb(null, chunk);
2773
+ };
2774
+ return exports$8;
2775
+ }
2776
+
2777
+ var exports$7 = {},
2778
+ _dewExec$6 = false;
2779
+ function dew$6() {
2780
+ if (_dewExec$6) return exports$7;
2781
+ _dewExec$6 = true;
2782
+ var eos;
2783
+ function once(callback) {
2784
+ var called = false;
2785
+ return function () {
2786
+ if (called) return;
2787
+ called = true;
2788
+ callback.apply(void 0, arguments);
2789
+ };
2790
+ }
2791
+ var _require$codes = dew$g().codes,
2792
+ ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,
2793
+ ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
2794
+ function noop(err) {
2795
+ // Rethrow the error if it exists to avoid swallowing it
2796
+ if (err) throw err;
2797
+ }
2798
+ function isRequest(stream) {
2799
+ return stream.setHeader && typeof stream.abort === "function";
2800
+ }
2801
+ function destroyer(stream, reading, writing, callback) {
2802
+ callback = once(callback);
2803
+ var closed = false;
2804
+ stream.on("close", function () {
2805
+ closed = true;
2806
+ });
2807
+ if (eos === undefined) eos = dew$c();
2808
+ eos(stream, {
2809
+ readable: reading,
2810
+ writable: writing
2811
+ }, function (err) {
2812
+ if (err) return callback(err);
2813
+ closed = true;
2814
+ callback();
2815
+ });
2816
+ var destroyed = false;
2817
+ return function (err) {
2818
+ if (closed) return;
2819
+ if (destroyed) return;
2820
+ destroyed = true;
2821
+
2822
+ // request.destroy just do .end - .abort is what we want
2823
+ if (isRequest(stream)) return stream.abort();
2824
+ if (typeof stream.destroy === "function") return stream.destroy();
2825
+ callback(err || new ERR_STREAM_DESTROYED("pipe"));
2826
+ };
2827
+ }
2828
+ function call(fn) {
2829
+ fn();
2830
+ }
2831
+ function pipe(from, to) {
2832
+ return from.pipe(to);
2833
+ }
2834
+ function popCallback(streams) {
2835
+ if (!streams.length) return noop;
2836
+ if (typeof streams[streams.length - 1] !== "function") return noop;
2837
+ return streams.pop();
2838
+ }
2839
+ function pipeline() {
2840
+ for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {
2841
+ streams[_key] = arguments[_key];
2842
+ }
2843
+ var callback = popCallback(streams);
2844
+ if (Array.isArray(streams[0])) streams = streams[0];
2845
+ if (streams.length < 2) {
2846
+ throw new ERR_MISSING_ARGS("streams");
2847
+ }
2848
+ var error;
2849
+ var destroys = streams.map(function (stream, i) {
2850
+ var reading = i < streams.length - 1;
2851
+ var writing = i > 0;
2852
+ return destroyer(stream, reading, writing, function (err) {
2853
+ if (!error) error = err;
2854
+ if (err) destroys.forEach(call);
2855
+ if (reading) return;
2856
+ destroys.forEach(call);
2857
+ callback(error);
2858
+ });
2859
+ });
2860
+ return streams.reduce(pipe);
2861
+ }
2862
+ exports$7 = pipeline;
2863
+ return exports$7;
2864
+ }
2865
+
2866
+ var exports$6 = {},
2867
+ _dewExec$5 = false;
2868
+ function dew$5() {
2869
+ if (_dewExec$5) return exports$6;
2870
+ _dewExec$5 = true;
2871
+ exports$6 = exports$6 = dew$9();
2872
+ exports$6.Stream = exports$6;
2873
+ exports$6.Readable = exports$6;
2874
+ exports$6.Writable = dew$e();
2875
+ exports$6.Duplex = dew$d();
2876
+ exports$6.Transform = dew$8();
2877
+ exports$6.PassThrough = dew$7();
2878
+ exports$6.finished = dew$c();
2879
+ exports$6.pipeline = dew$6();
2880
+ return exports$6;
2881
+ }
2882
+
2883
+ var exports$5 = {},
2884
+ _dewExec$4 = false;
2885
+ var _global$2 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
2886
+ function dew$4() {
2887
+ if (_dewExec$4) return exports$5;
2888
+ _dewExec$4 = true;
2889
+ var Buffer = dew$l().Buffer;
2890
+ var process$1 = process;
2891
+ var capability = dew$k();
2892
+ var inherits = dew$m();
2893
+ var stream = dew$5();
2894
+ var rStates = exports$5.readyStates = {
2895
+ UNSENT: 0,
2896
+ OPENED: 1,
2897
+ HEADERS_RECEIVED: 2,
2898
+ LOADING: 3,
2899
+ DONE: 4
2900
+ };
2901
+ var IncomingMessage = exports$5.IncomingMessage = function (xhr, response, mode, resetTimers) {
2902
+ var self = this || _global$2;
2903
+ stream.Readable.call(self);
2904
+ self._mode = mode;
2905
+ self.headers = {};
2906
+ self.rawHeaders = [];
2907
+ self.trailers = {};
2908
+ self.rawTrailers = [];
2909
+
2910
+ // Fake the 'close' event, but only once 'end' fires
2911
+ self.on("end", function () {
2912
+ // The nextTick is necessary to prevent the 'request' module from causing an infinite loop
2913
+ process$1.nextTick(function () {
2914
+ self.emit("close");
2915
+ });
2916
+ });
2917
+ if (mode === "fetch") {
2918
+ self._fetchResponse = response;
2919
+ self.url = response.url;
2920
+ self.statusCode = response.status;
2921
+ self.statusMessage = response.statusText;
2922
+ response.headers.forEach(function (header, key) {
2923
+ self.headers[key.toLowerCase()] = header;
2924
+ self.rawHeaders.push(key, header);
2925
+ });
2926
+ if (capability.writableStream) {
2927
+ var writable = new WritableStream({
2928
+ write: function (chunk) {
2929
+ resetTimers(false);
2930
+ return new Promise(function (resolve, reject) {
2931
+ if (self._destroyed) {
2932
+ reject();
2933
+ } else if (self.push(Buffer.from(chunk))) {
2934
+ resolve();
2935
+ } else {
2936
+ self._resumeFetch = resolve;
2937
+ }
2938
+ });
2939
+ },
2940
+ close: function () {
2941
+ resetTimers(true);
2942
+ if (!self._destroyed) self.push(null);
2943
+ },
2944
+ abort: function (err) {
2945
+ resetTimers(true);
2946
+ if (!self._destroyed) self.emit("error", err);
2947
+ }
2948
+ });
2949
+ try {
2950
+ response.body.pipeTo(writable).catch(function (err) {
2951
+ resetTimers(true);
2952
+ if (!self._destroyed) self.emit("error", err);
2953
+ });
2954
+ return;
2955
+ } catch (e) {} // pipeTo method isn't defined. Can't find a better way to feature test this
2956
+ }
2957
+ // fallback for when writableStream or pipeTo aren't available
2958
+ var reader = response.body.getReader();
2959
+ function read() {
2960
+ reader.read().then(function (result) {
2961
+ if (self._destroyed) return;
2962
+ resetTimers(result.done);
2963
+ if (result.done) {
2964
+ self.push(null);
2965
+ return;
2966
+ }
2967
+ self.push(Buffer.from(result.value));
2968
+ read();
2969
+ }).catch(function (err) {
2970
+ resetTimers(true);
2971
+ if (!self._destroyed) self.emit("error", err);
2972
+ });
2973
+ }
2974
+ read();
2975
+ } else {
2976
+ self._xhr = xhr;
2977
+ self._pos = 0;
2978
+ self.url = xhr.responseURL;
2979
+ self.statusCode = xhr.status;
2980
+ self.statusMessage = xhr.statusText;
2981
+ var headers = xhr.getAllResponseHeaders().split(/\r?\n/);
2982
+ headers.forEach(function (header) {
2983
+ var matches = header.match(/^([^:]+):\s*(.*)/);
2984
+ if (matches) {
2985
+ var key = matches[1].toLowerCase();
2986
+ if (key === "set-cookie") {
2987
+ if (self.headers[key] === undefined) {
2988
+ self.headers[key] = [];
2989
+ }
2990
+ self.headers[key].push(matches[2]);
2991
+ } else if (self.headers[key] !== undefined) {
2992
+ self.headers[key] += ", " + matches[2];
2993
+ } else {
2994
+ self.headers[key] = matches[2];
2995
+ }
2996
+ self.rawHeaders.push(matches[1], matches[2]);
2997
+ }
2998
+ });
2999
+ self._charset = "x-user-defined";
3000
+ if (!capability.overrideMimeType) {
3001
+ var mimeType = self.rawHeaders["mime-type"];
3002
+ if (mimeType) {
3003
+ var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/);
3004
+ if (charsetMatch) {
3005
+ self._charset = charsetMatch[1].toLowerCase();
3006
+ }
3007
+ }
3008
+ if (!self._charset) self._charset = "utf-8"; // best guess
3009
+ }
3010
+ }
3011
+ };
3012
+ inherits(IncomingMessage, stream.Readable);
3013
+ IncomingMessage.prototype._read = function () {
3014
+ var self = this || _global$2;
3015
+ var resolve = self._resumeFetch;
3016
+ if (resolve) {
3017
+ self._resumeFetch = null;
3018
+ resolve();
3019
+ }
3020
+ };
3021
+ IncomingMessage.prototype._onXHRProgress = function (resetTimers) {
3022
+ var self = this || _global$2;
3023
+ var xhr = self._xhr;
3024
+ var response = null;
3025
+ switch (self._mode) {
3026
+ case "text":
3027
+ response = xhr.responseText;
3028
+ if (response.length > self._pos) {
3029
+ var newData = response.substr(self._pos);
3030
+ if (self._charset === "x-user-defined") {
3031
+ var buffer = Buffer.alloc(newData.length);
3032
+ for (var i = 0; i < newData.length; i++) buffer[i] = newData.charCodeAt(i) & 255;
3033
+ self.push(buffer);
3034
+ } else {
3035
+ self.push(newData, self._charset);
3036
+ }
3037
+ self._pos = response.length;
3038
+ }
3039
+ break;
3040
+ case "arraybuffer":
3041
+ if (xhr.readyState !== rStates.DONE || !xhr.response) break;
3042
+ response = xhr.response;
3043
+ self.push(Buffer.from(new Uint8Array(response)));
3044
+ break;
3045
+ case "moz-chunked-arraybuffer":
3046
+ // take whole
3047
+ response = xhr.response;
3048
+ if (xhr.readyState !== rStates.LOADING || !response) break;
3049
+ self.push(Buffer.from(new Uint8Array(response)));
3050
+ break;
3051
+ case "ms-stream":
3052
+ response = xhr.response;
3053
+ if (xhr.readyState !== rStates.LOADING) break;
3054
+ var reader = new _global$2.MSStreamReader();
3055
+ reader.onprogress = function () {
3056
+ if (reader.result.byteLength > self._pos) {
3057
+ self.push(Buffer.from(new Uint8Array(reader.result.slice(self._pos))));
3058
+ self._pos = reader.result.byteLength;
3059
+ }
3060
+ };
3061
+ reader.onload = function () {
3062
+ resetTimers(true);
3063
+ self.push(null);
3064
+ };
3065
+ // reader.onerror = ??? // TODO: this
3066
+ reader.readAsArrayBuffer(response);
3067
+ break;
3068
+ }
3069
+
3070
+ // The ms-stream case handles end separately in reader.onload()
3071
+ if (self._xhr.readyState === rStates.DONE && self._mode !== "ms-stream") {
3072
+ resetTimers(true);
3073
+ self.push(null);
3074
+ }
3075
+ };
3076
+ return exports$5;
3077
+ }
3078
+
3079
+ var exports$4 = {},
3080
+ _dewExec$3 = false;
3081
+ var _global$1 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
3082
+ function dew$3() {
3083
+ if (_dewExec$3) return exports$4;
3084
+ _dewExec$3 = true;
3085
+ var Buffer = dew$l().Buffer;
3086
+ var process$1 = process;
3087
+ var capability = dew$k();
3088
+ var inherits = dew$m();
3089
+ var response = dew$4();
3090
+ var stream = dew$5();
3091
+ var IncomingMessage = response.IncomingMessage;
3092
+ var rStates = response.readyStates;
3093
+ function decideMode(preferBinary, useFetch) {
3094
+ if (capability.fetch && useFetch) {
3095
+ return "fetch";
3096
+ } else if (capability.mozchunkedarraybuffer) {
3097
+ return "moz-chunked-arraybuffer";
3098
+ } else if (capability.msstream) {
3099
+ return "ms-stream";
3100
+ } else if (capability.arraybuffer && preferBinary) {
3101
+ return "arraybuffer";
3102
+ } else {
3103
+ return "text";
3104
+ }
3105
+ }
3106
+ var ClientRequest = exports$4 = function (opts) {
3107
+ var self = this || _global$1;
3108
+ stream.Writable.call(self);
3109
+ self._opts = opts;
3110
+ self._body = [];
3111
+ self._headers = {};
3112
+ if (opts.auth) self.setHeader("Authorization", "Basic " + Buffer.from(opts.auth).toString("base64"));
3113
+ Object.keys(opts.headers).forEach(function (name) {
3114
+ self.setHeader(name, opts.headers[name]);
3115
+ });
3116
+ var preferBinary;
3117
+ var useFetch = true;
3118
+ if (opts.mode === "disable-fetch" || "requestTimeout" in opts && !capability.abortController) {
3119
+ // If the use of XHR should be preferred. Not typically needed.
3120
+ useFetch = false;
3121
+ preferBinary = true;
3122
+ } else if (opts.mode === "prefer-streaming") {
3123
+ // If streaming is a high priority but binary compatibility and
3124
+ // the accuracy of the 'content-type' header aren't
3125
+ preferBinary = false;
3126
+ } else if (opts.mode === "allow-wrong-content-type") {
3127
+ // If streaming is more important than preserving the 'content-type' header
3128
+ preferBinary = !capability.overrideMimeType;
3129
+ } else if (!opts.mode || opts.mode === "default" || opts.mode === "prefer-fast") {
3130
+ // Use binary if text streaming may corrupt data or the content-type header, or for speed
3131
+ preferBinary = true;
3132
+ } else {
3133
+ throw new Error("Invalid value for opts.mode");
3134
+ }
3135
+ self._mode = decideMode(preferBinary, useFetch);
3136
+ self._fetchTimer = null;
3137
+ self._socketTimeout = null;
3138
+ self._socketTimer = null;
3139
+ self.on("finish", function () {
3140
+ self._onFinish();
3141
+ });
3142
+ };
3143
+ inherits(ClientRequest, stream.Writable);
3144
+ ClientRequest.prototype.setHeader = function (name, value) {
3145
+ var self = this || _global$1;
3146
+ var lowerName = name.toLowerCase();
3147
+ // This check is not necessary, but it prevents warnings from browsers about setting unsafe
3148
+ // headers. To be honest I'm not entirely sure hiding these warnings is a good thing, but
3149
+ // http-browserify did it, so I will too.
3150
+ if (unsafeHeaders.indexOf(lowerName) !== -1) return;
3151
+ self._headers[lowerName] = {
3152
+ name: name,
3153
+ value: value
3154
+ };
3155
+ };
3156
+ ClientRequest.prototype.getHeader = function (name) {
3157
+ var header = (this || _global$1)._headers[name.toLowerCase()];
3158
+ if (header) return header.value;
3159
+ return null;
3160
+ };
3161
+ ClientRequest.prototype.removeHeader = function (name) {
3162
+ var self = this || _global$1;
3163
+ delete self._headers[name.toLowerCase()];
3164
+ };
3165
+ ClientRequest.prototype._onFinish = function () {
3166
+ var self = this || _global$1;
3167
+ if (self._destroyed) return;
3168
+ var opts = self._opts;
3169
+ if ("timeout" in opts && opts.timeout !== 0) {
3170
+ self.setTimeout(opts.timeout);
3171
+ }
3172
+ var headersObj = self._headers;
3173
+ var body = null;
3174
+ if (opts.method !== "GET" && opts.method !== "HEAD") {
3175
+ body = new Blob(self._body, {
3176
+ type: (headersObj["content-type"] || {}).value || ""
3177
+ });
3178
+ }
3179
+
3180
+ // create flattened list of headers
3181
+ var headersList = [];
3182
+ Object.keys(headersObj).forEach(function (keyName) {
3183
+ var name = headersObj[keyName].name;
3184
+ var value = headersObj[keyName].value;
3185
+ if (Array.isArray(value)) {
3186
+ value.forEach(function (v) {
3187
+ headersList.push([name, v]);
3188
+ });
3189
+ } else {
3190
+ headersList.push([name, value]);
3191
+ }
3192
+ });
3193
+ if (self._mode === "fetch") {
3194
+ var signal = null;
3195
+ if (capability.abortController) {
3196
+ var controller = new AbortController();
3197
+ signal = controller.signal;
3198
+ self._fetchAbortController = controller;
3199
+ if ("requestTimeout" in opts && opts.requestTimeout !== 0) {
3200
+ self._fetchTimer = _global$1.setTimeout(function () {
3201
+ self.emit("requestTimeout");
3202
+ if (self._fetchAbortController) self._fetchAbortController.abort();
3203
+ }, opts.requestTimeout);
3204
+ }
3205
+ }
3206
+ _global$1.fetch(self._opts.url, {
3207
+ method: self._opts.method,
3208
+ headers: headersList,
3209
+ body: body || undefined,
3210
+ mode: "cors",
3211
+ credentials: opts.withCredentials ? "include" : "same-origin",
3212
+ signal: signal
3213
+ }).then(function (response) {
3214
+ self._fetchResponse = response;
3215
+ self._resetTimers(false);
3216
+ self._connect();
3217
+ }, function (reason) {
3218
+ self._resetTimers(true);
3219
+ if (!self._destroyed) self.emit("error", reason);
3220
+ });
3221
+ } else {
3222
+ var xhr = self._xhr = new _global$1.XMLHttpRequest();
3223
+ try {
3224
+ xhr.open(self._opts.method, self._opts.url, true);
3225
+ } catch (err) {
3226
+ process$1.nextTick(function () {
3227
+ self.emit("error", err);
3228
+ });
3229
+ return;
3230
+ }
3231
+
3232
+ // Can't set responseType on really old browsers
3233
+ if ("responseType" in xhr) xhr.responseType = self._mode;
3234
+ if ("withCredentials" in xhr) xhr.withCredentials = !!opts.withCredentials;
3235
+ if (self._mode === "text" && "overrideMimeType" in xhr) xhr.overrideMimeType("text/plain; charset=x-user-defined");
3236
+ if ("requestTimeout" in opts) {
3237
+ xhr.timeout = opts.requestTimeout;
3238
+ xhr.ontimeout = function () {
3239
+ self.emit("requestTimeout");
3240
+ };
3241
+ }
3242
+ headersList.forEach(function (header) {
3243
+ xhr.setRequestHeader(header[0], header[1]);
3244
+ });
3245
+ self._response = null;
3246
+ xhr.onreadystatechange = function () {
3247
+ switch (xhr.readyState) {
3248
+ case rStates.LOADING:
3249
+ case rStates.DONE:
3250
+ self._onXHRProgress();
3251
+ break;
3252
+ }
3253
+ };
3254
+ // Necessary for streaming in Firefox, since xhr.response is ONLY defined
3255
+ // in onprogress, not in onreadystatechange with xhr.readyState = 3
3256
+ if (self._mode === "moz-chunked-arraybuffer") {
3257
+ xhr.onprogress = function () {
3258
+ self._onXHRProgress();
3259
+ };
3260
+ }
3261
+ xhr.onerror = function () {
3262
+ if (self._destroyed) return;
3263
+ self._resetTimers(true);
3264
+ self.emit("error", new Error("XHR error"));
3265
+ };
3266
+ try {
3267
+ xhr.send(body);
3268
+ } catch (err) {
3269
+ process$1.nextTick(function () {
3270
+ self.emit("error", err);
3271
+ });
3272
+ return;
3273
+ }
3274
+ }
3275
+ };
3276
+
3277
+ /**
3278
+ * Checks if xhr.status is readable and non-zero, indicating no error.
3279
+ * Even though the spec says it should be available in readyState 3,
3280
+ * accessing it throws an exception in IE8
3281
+ */
3282
+ function statusValid(xhr) {
3283
+ try {
3284
+ var status = xhr.status;
3285
+ return status !== null && status !== 0;
3286
+ } catch (e) {
3287
+ return false;
3288
+ }
3289
+ }
3290
+ ClientRequest.prototype._onXHRProgress = function () {
3291
+ var self = this || _global$1;
3292
+ self._resetTimers(false);
3293
+ if (!statusValid(self._xhr) || self._destroyed) return;
3294
+ if (!self._response) self._connect();
3295
+ self._response._onXHRProgress(self._resetTimers.bind(self));
3296
+ };
3297
+ ClientRequest.prototype._connect = function () {
3298
+ var self = this || _global$1;
3299
+ if (self._destroyed) return;
3300
+ self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode, self._resetTimers.bind(self));
3301
+ self._response.on("error", function (err) {
3302
+ self.emit("error", err);
3303
+ });
3304
+ self.emit("response", self._response);
3305
+ };
3306
+ ClientRequest.prototype._write = function (chunk, encoding, cb) {
3307
+ var self = this || _global$1;
3308
+ self._body.push(chunk);
3309
+ cb();
3310
+ };
3311
+ ClientRequest.prototype._resetTimers = function (done) {
3312
+ var self = this || _global$1;
3313
+ _global$1.clearTimeout(self._socketTimer);
3314
+ self._socketTimer = null;
3315
+ if (done) {
3316
+ _global$1.clearTimeout(self._fetchTimer);
3317
+ self._fetchTimer = null;
3318
+ } else if (self._socketTimeout) {
3319
+ self._socketTimer = _global$1.setTimeout(function () {
3320
+ self.emit("timeout");
3321
+ }, self._socketTimeout);
3322
+ }
3323
+ };
3324
+ ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function (err) {
3325
+ var self = this || _global$1;
3326
+ self._destroyed = true;
3327
+ self._resetTimers(true);
3328
+ if (self._response) self._response._destroyed = true;
3329
+ if (self._xhr) self._xhr.abort();else if (self._fetchAbortController) self._fetchAbortController.abort();
3330
+ if (err) self.emit("error", err);
3331
+ };
3332
+ ClientRequest.prototype.end = function (data, encoding, cb) {
3333
+ var self = this || _global$1;
3334
+ if (typeof data === "function") {
3335
+ cb = data;
3336
+ data = undefined;
3337
+ }
3338
+ stream.Writable.prototype.end.call(self, data, encoding, cb);
3339
+ };
3340
+ ClientRequest.prototype.setTimeout = function (timeout, cb) {
3341
+ var self = this || _global$1;
3342
+ if (cb) self.once("timeout", cb);
3343
+ self._socketTimeout = timeout;
3344
+ self._resetTimers(false);
3345
+ };
3346
+ ClientRequest.prototype.flushHeaders = function () {};
3347
+ ClientRequest.prototype.setNoDelay = function () {};
3348
+ ClientRequest.prototype.setSocketKeepAlive = function () {};
3349
+
3350
+ // Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method
3351
+ var unsafeHeaders = ["accept-charset", "accept-encoding", "access-control-request-headers", "access-control-request-method", "connection", "content-length", "cookie", "cookie2", "date", "dnt", "expect", "host", "keep-alive", "origin", "referer", "te", "trailer", "transfer-encoding", "upgrade", "via"];
3352
+ return exports$4;
3353
+ }
3354
+
3355
+ var exports$3 = {},
3356
+ _dewExec$2 = false;
3357
+ function dew$2() {
3358
+ if (_dewExec$2) return exports$3;
3359
+ _dewExec$2 = true;
3360
+ exports$3 = extend;
3361
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
3362
+ function extend() {
3363
+ var target = {};
3364
+ for (var i = 0; i < arguments.length; i++) {
3365
+ var source = arguments[i];
3366
+ for (var key in source) {
3367
+ if (hasOwnProperty.call(source, key)) {
3368
+ target[key] = source[key];
3369
+ }
3370
+ }
3371
+ }
3372
+ return target;
3373
+ }
3374
+ return exports$3;
3375
+ }
3376
+
3377
+ var exports$2 = {},
3378
+ _dewExec$1 = false;
3379
+ function dew$1() {
3380
+ if (_dewExec$1) return exports$2;
3381
+ _dewExec$1 = true;
3382
+ exports$2 = {
3383
+ "100": "Continue",
3384
+ "101": "Switching Protocols",
3385
+ "102": "Processing",
3386
+ "200": "OK",
3387
+ "201": "Created",
3388
+ "202": "Accepted",
3389
+ "203": "Non-Authoritative Information",
3390
+ "204": "No Content",
3391
+ "205": "Reset Content",
3392
+ "206": "Partial Content",
3393
+ "207": "Multi-Status",
3394
+ "208": "Already Reported",
3395
+ "226": "IM Used",
3396
+ "300": "Multiple Choices",
3397
+ "301": "Moved Permanently",
3398
+ "302": "Found",
3399
+ "303": "See Other",
3400
+ "304": "Not Modified",
3401
+ "305": "Use Proxy",
3402
+ "307": "Temporary Redirect",
3403
+ "308": "Permanent Redirect",
3404
+ "400": "Bad Request",
3405
+ "401": "Unauthorized",
3406
+ "402": "Payment Required",
3407
+ "403": "Forbidden",
3408
+ "404": "Not Found",
3409
+ "405": "Method Not Allowed",
3410
+ "406": "Not Acceptable",
3411
+ "407": "Proxy Authentication Required",
3412
+ "408": "Request Timeout",
3413
+ "409": "Conflict",
3414
+ "410": "Gone",
3415
+ "411": "Length Required",
3416
+ "412": "Precondition Failed",
3417
+ "413": "Payload Too Large",
3418
+ "414": "URI Too Long",
3419
+ "415": "Unsupported Media Type",
3420
+ "416": "Range Not Satisfiable",
3421
+ "417": "Expectation Failed",
3422
+ "418": "I'm a teapot",
3423
+ "421": "Misdirected Request",
3424
+ "422": "Unprocessable Entity",
3425
+ "423": "Locked",
3426
+ "424": "Failed Dependency",
3427
+ "425": "Unordered Collection",
3428
+ "426": "Upgrade Required",
3429
+ "428": "Precondition Required",
3430
+ "429": "Too Many Requests",
3431
+ "431": "Request Header Fields Too Large",
3432
+ "451": "Unavailable For Legal Reasons",
3433
+ "500": "Internal Server Error",
3434
+ "501": "Not Implemented",
3435
+ "502": "Bad Gateway",
3436
+ "503": "Service Unavailable",
3437
+ "504": "Gateway Timeout",
3438
+ "505": "HTTP Version Not Supported",
3439
+ "506": "Variant Also Negotiates",
3440
+ "507": "Insufficient Storage",
3441
+ "508": "Loop Detected",
3442
+ "509": "Bandwidth Limit Exceeded",
3443
+ "510": "Not Extended",
3444
+ "511": "Network Authentication Required"
3445
+ };
3446
+ return exports$2;
3447
+ }
3448
+
3449
+ var exports$1 = {},
3450
+ _dewExec = false;
3451
+ var _global = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
3452
+ function dew() {
3453
+ if (_dewExec) return exports$1;
3454
+ _dewExec = true;
3455
+ var ClientRequest = dew$3();
3456
+ var response = dew$4();
3457
+ var extend = dew$2();
3458
+ var statusCodes = dew$1();
3459
+ var url = h;
3460
+ var http = exports$1;
3461
+ http.request = function (opts, cb) {
3462
+ if (typeof opts === "string") opts = url.parse(opts);else opts = extend(opts);
3463
+
3464
+ // Normally, the page is loaded from http or https, so not specifying a protocol
3465
+ // will result in a (valid) protocol-relative url. However, this won't work if
3466
+ // the protocol is something else, like 'file:'
3467
+ var defaultProtocol = _global.location.protocol.search(/^https?:$/) === -1 ? "http:" : "";
3468
+ var protocol = opts.protocol || defaultProtocol;
3469
+ var host = opts.hostname || opts.host;
3470
+ var port = opts.port;
3471
+ var path = opts.path || "/";
3472
+
3473
+ // Necessary for IPv6 addresses
3474
+ if (host && host.indexOf(":") !== -1) host = "[" + host + "]";
3475
+
3476
+ // This may be a relative url. The browser should always be able to interpret it correctly.
3477
+ opts.url = (host ? protocol + "//" + host : "") + (port ? ":" + port : "") + path;
3478
+ opts.method = (opts.method || "GET").toUpperCase();
3479
+ opts.headers = opts.headers || {};
3480
+
3481
+ // Also valid opts.auth, opts.mode
3482
+
3483
+ var req = new ClientRequest(opts);
3484
+ if (cb) req.on("response", cb);
3485
+ return req;
3486
+ };
3487
+ http.get = function get(opts, cb) {
3488
+ var req = http.request(opts, cb);
3489
+ req.end();
3490
+ return req;
3491
+ };
3492
+ http.ClientRequest = ClientRequest;
3493
+ http.IncomingMessage = response.IncomingMessage;
3494
+ http.Agent = function () {};
3495
+ http.Agent.defaultMaxSockets = 4;
3496
+ http.globalAgent = new http.Agent();
3497
+ http.STATUS_CODES = statusCodes;
3498
+ http.METHODS = ["CHECKOUT", "CONNECT", "COPY", "DELETE", "GET", "HEAD", "LOCK", "M-SEARCH", "MERGE", "MKACTIVITY", "MKCOL", "MOVE", "NOTIFY", "OPTIONS", "PATCH", "POST", "PROPFIND", "PROPPATCH", "PURGE", "PUT", "REPORT", "SEARCH", "SUBSCRIBE", "TRACE", "UNLOCK", "UNSUBSCRIBE"];
3499
+ return exports$1;
3500
+ }
3501
+
3502
+ const exports = dew();
3503
+
3504
+ var Agent = exports.Agent;
3505
+ var ClientRequest = exports.ClientRequest;
3506
+ var IncomingMessage = exports.IncomingMessage;
3507
+ var METHODS = exports.METHODS;
3508
+ var STATUS_CODES = exports.STATUS_CODES;
3509
+ var get = exports.get;
3510
+ var globalAgent = exports.globalAgent;
3511
+ var request = exports.request;
3512
+
3513
+ export { Agent, ClientRequest, IncomingMessage, METHODS, STATUS_CODES, exports as default, get, globalAgent, request };