visaljs 0.0.0-stage → 0.0.2

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 (520) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -2
  3. package/cli.js +8084 -0
  4. package/node/include/js_node.h +46 -0
  5. package/node/prelude/async_hooks.js +88 -0
  6. package/node/prelude/buffer.js +31 -0
  7. package/node/prelude/crypto.js +114 -0
  8. package/node/prelude/events.js +227 -0
  9. package/node/prelude/fs.js +79 -0
  10. package/node/prelude/http.js +536 -0
  11. package/node/prelude/http2.js +30 -0
  12. package/node/prelude/internal/crypto/asym.js +333 -0
  13. package/node/prelude/internal/crypto/cipher.js +205 -0
  14. package/node/prelude/internal/crypto/hash.js +137 -0
  15. package/node/prelude/internal/crypto/kdf.js +182 -0
  16. package/node/prelude/internal/crypto/keys.js +603 -0
  17. package/node/prelude/internal/crypto/random.js +118 -0
  18. package/node/prelude/internal/crypto/util.js +76 -0
  19. package/node/prelude/internal/errors.js +88 -0
  20. package/node/prelude/internal/querystring.js +105 -0
  21. package/node/prelude/module.js +53 -0
  22. package/node/prelude/net.js +51 -0
  23. package/node/prelude/os.js +129 -0
  24. package/node/prelude/path.js +257 -0
  25. package/node/prelude/process.js +21 -0
  26. package/node/prelude/querystring.js +469 -0
  27. package/node/prelude/stream.js +1327 -0
  28. package/node/prelude/stream_promises.js +7 -0
  29. package/node/prelude/stream_web.js +6 -0
  30. package/node/prelude/string_decoder.js +236 -0
  31. package/node/prelude/tty.js +18 -0
  32. package/node/prelude/url.js +1156 -0
  33. package/node/prelude/util.js +64 -0
  34. package/node/prelude/zlib.js +81 -0
  35. package/node/src/host_fs.c +126 -0
  36. package/node/src/host_http.c +486 -0
  37. package/node/src/host_os.c +505 -0
  38. package/node/src/host_sys.c +78 -0
  39. package/node/third_party/libuv/LICENSE +19 -0
  40. package/node/third_party/libuv/include/uv/aix.h +32 -0
  41. package/node/third_party/libuv/include/uv/bsd.h +34 -0
  42. package/node/third_party/libuv/include/uv/darwin.h +61 -0
  43. package/node/third_party/libuv/include/uv/errno.h +483 -0
  44. package/node/third_party/libuv/include/uv/linux.h +34 -0
  45. package/node/third_party/libuv/include/uv/os390.h +33 -0
  46. package/node/third_party/libuv/include/uv/posix.h +31 -0
  47. package/node/third_party/libuv/include/uv/sunos.h +44 -0
  48. package/node/third_party/libuv/include/uv/threadpool.h +37 -0
  49. package/node/third_party/libuv/include/uv/tree.h +521 -0
  50. package/node/third_party/libuv/include/uv/unix.h +512 -0
  51. package/node/third_party/libuv/include/uv/version.h +43 -0
  52. package/node/third_party/libuv/include/uv/win.h +698 -0
  53. package/node/third_party/libuv/include/uv.h +1990 -0
  54. package/node/third_party/libuv/src/fs-poll.c +290 -0
  55. package/node/third_party/libuv/src/heap-inl.h +245 -0
  56. package/node/third_party/libuv/src/idna.c +560 -0
  57. package/node/third_party/libuv/src/idna.h +31 -0
  58. package/node/third_party/libuv/src/inet.c +298 -0
  59. package/node/third_party/libuv/src/queue.h +90 -0
  60. package/node/third_party/libuv/src/random.c +123 -0
  61. package/node/third_party/libuv/src/strscpy.c +38 -0
  62. package/node/third_party/libuv/src/strscpy.h +39 -0
  63. package/node/third_party/libuv/src/strtok.c +52 -0
  64. package/node/third_party/libuv/src/strtok.h +27 -0
  65. package/node/third_party/libuv/src/thread-common.c +175 -0
  66. package/node/third_party/libuv/src/threadpool.c +419 -0
  67. package/node/third_party/libuv/src/timer.c +200 -0
  68. package/node/third_party/libuv/src/unix/async.c +418 -0
  69. package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +164 -0
  70. package/node/third_party/libuv/src/unix/core.c +2104 -0
  71. package/node/third_party/libuv/src/unix/darwin-proctitle.c +176 -0
  72. package/node/third_party/libuv/src/unix/darwin-stub.h +97 -0
  73. package/node/third_party/libuv/src/unix/darwin-syscalls.h +17 -0
  74. package/node/third_party/libuv/src/unix/darwin.c +237 -0
  75. package/node/third_party/libuv/src/unix/dl.c +80 -0
  76. package/node/third_party/libuv/src/unix/fs.c +2303 -0
  77. package/node/third_party/libuv/src/unix/fsevents.c +906 -0
  78. package/node/third_party/libuv/src/unix/getaddrinfo.c +252 -0
  79. package/node/third_party/libuv/src/unix/getnameinfo.c +121 -0
  80. package/node/third_party/libuv/src/unix/internal.h +530 -0
  81. package/node/third_party/libuv/src/unix/kqueue.c +667 -0
  82. package/node/third_party/libuv/src/unix/linux.c +2761 -0
  83. package/node/third_party/libuv/src/unix/loop-watcher.c +68 -0
  84. package/node/third_party/libuv/src/unix/loop.c +240 -0
  85. package/node/third_party/libuv/src/unix/pipe.c +555 -0
  86. package/node/third_party/libuv/src/unix/poll.c +159 -0
  87. package/node/third_party/libuv/src/unix/process.c +1123 -0
  88. package/node/third_party/libuv/src/unix/procfs-exepath.c +45 -0
  89. package/node/third_party/libuv/src/unix/proctitle.c +157 -0
  90. package/node/third_party/libuv/src/unix/random-devurandom.c +93 -0
  91. package/node/third_party/libuv/src/unix/random-getentropy.c +57 -0
  92. package/node/third_party/libuv/src/unix/random-getrandom.c +86 -0
  93. package/node/third_party/libuv/src/unix/random-sysctl-linux.c +99 -0
  94. package/node/third_party/libuv/src/unix/signal.c +581 -0
  95. package/node/third_party/libuv/src/unix/stream.c +1567 -0
  96. package/node/third_party/libuv/src/unix/tcp.c +673 -0
  97. package/node/third_party/libuv/src/unix/thread.c +975 -0
  98. package/node/third_party/libuv/src/unix/tty.c +510 -0
  99. package/node/third_party/libuv/src/unix/udp.c +1434 -0
  100. package/node/third_party/libuv/src/uv-common.c +1051 -0
  101. package/node/third_party/libuv/src/uv-common.h +474 -0
  102. package/node/third_party/libuv/src/uv-data-getter-setters.c +119 -0
  103. package/node/third_party/libuv/src/version.c +45 -0
  104. package/node/third_party/llhttp/LICENSE +22 -0
  105. package/node/third_party/llhttp/api.c +509 -0
  106. package/node/third_party/llhttp/http.c +170 -0
  107. package/node/third_party/llhttp/llhttp.c +10099 -0
  108. package/node/third_party/llhttp/llhttp.h +907 -0
  109. package/package.json +25 -4
  110. package/runtime/include/js_atoms.gen.h +68 -0
  111. package/runtime/include/js_atoms.h +54 -0
  112. package/runtime/include/js_bigint.h +93 -0
  113. package/runtime/include/js_buffer.h +79 -0
  114. package/runtime/include/js_builtins.h +168 -0
  115. package/runtime/include/js_console.h +58 -0
  116. package/runtime/include/js_convert.h +22 -0
  117. package/runtime/include/js_core.def +188 -0
  118. package/runtime/include/js_crypto.h +58 -0
  119. package/runtime/include/js_error.h +37 -0
  120. package/runtime/include/js_exception.h +65 -0
  121. package/runtime/include/js_function.h +167 -0
  122. package/runtime/include/js_gc.h +195 -0
  123. package/runtime/include/js_generator.h +96 -0
  124. package/runtime/include/js_host.h +19 -0
  125. package/runtime/include/js_jobs.h +84 -0
  126. package/runtime/include/js_module.h +16 -0
  127. package/runtime/include/js_object.h +384 -0
  128. package/runtime/include/js_ops.h +111 -0
  129. package/runtime/include/js_promise.h +45 -0
  130. package/runtime/include/js_regexp.h +25 -0
  131. package/runtime/include/js_runtime.h +30 -0
  132. package/runtime/include/js_symbol.h +62 -0
  133. package/runtime/include/js_web.h +110 -0
  134. package/runtime/include/jscell.h +48 -0
  135. package/runtime/include/jscontext.h +240 -0
  136. package/runtime/include/jsnum.h +42 -0
  137. package/runtime/include/jsstring.h +161 -0
  138. package/runtime/include/jsvalue.h +142 -0
  139. package/runtime/src/arguments.c +115 -0
  140. package/runtime/src/array.c +1145 -0
  141. package/runtime/src/arraybuffer.c +608 -0
  142. package/runtime/src/async_iter.c +479 -0
  143. package/runtime/src/atoms.c +157 -0
  144. package/runtime/src/base64.c +107 -0
  145. package/runtime/src/bigint.c +1189 -0
  146. package/runtime/src/blob.c +371 -0
  147. package/runtime/src/buffer.c +1357 -0
  148. package/runtime/src/builtin_table.c +100 -0
  149. package/runtime/src/builtins.c +987 -0
  150. package/runtime/src/builtins_util.h +53 -0
  151. package/runtime/src/collections.c +912 -0
  152. package/runtime/src/components.c +28 -0
  153. package/runtime/src/console.c +637 -0
  154. package/runtime/src/convert.c +82 -0
  155. package/runtime/src/core_all.c +21 -0
  156. package/runtime/src/crypto.c +116 -0
  157. package/runtime/src/crypto_asym.c +644 -0
  158. package/runtime/src/crypto_cipher.c +671 -0
  159. package/runtime/src/crypto_hash.c +260 -0
  160. package/runtime/src/crypto_host.c +414 -0
  161. package/runtime/src/crypto_internal.h +304 -0
  162. package/runtime/src/crypto_kdf.c +143 -0
  163. package/runtime/src/crypto_key.c +171 -0
  164. package/runtime/src/crypto_pkey.c +794 -0
  165. package/runtime/src/crypto_subtle.c +1675 -0
  166. package/runtime/src/date.c +940 -0
  167. package/runtime/src/domexception.c +169 -0
  168. package/runtime/src/elements.c +312 -0
  169. package/runtime/src/elements.h +45 -0
  170. package/runtime/src/encoding.c +485 -0
  171. package/runtime/src/error.c +297 -0
  172. package/runtime/src/events.c +793 -0
  173. package/runtime/src/exception.c +56 -0
  174. package/runtime/src/fetch.c +772 -0
  175. package/runtime/src/function.c +530 -0
  176. package/runtime/src/gc.c +803 -0
  177. package/runtime/src/generator.c +218 -0
  178. package/runtime/src/global.c +119 -0
  179. package/runtime/src/headers.c +557 -0
  180. package/runtime/src/inspect.c +1792 -0
  181. package/runtime/src/internal.h +80 -0
  182. package/runtime/src/iterate.c +94 -0
  183. package/runtime/src/iterator.c +409 -0
  184. package/runtime/src/jobs.c +337 -0
  185. package/runtime/src/jsnum.c +353 -0
  186. package/runtime/src/json.c +1028 -0
  187. package/runtime/src/math.c +243 -0
  188. package/runtime/src/module.c +336 -0
  189. package/runtime/src/number.c +176 -0
  190. package/runtime/src/object.c +1265 -0
  191. package/runtime/src/ops.c +322 -0
  192. package/runtime/src/os.c +196 -0
  193. package/runtime/src/os.h +29 -0
  194. package/runtime/src/process.c +432 -0
  195. package/runtime/src/promise.c +721 -0
  196. package/runtime/src/proxy.c +570 -0
  197. package/runtime/src/reflect.c +194 -0
  198. package/runtime/src/regexp.c +1141 -0
  199. package/runtime/src/regexp_anchor.h +34 -0
  200. package/runtime/src/regexp_message.h +32 -0
  201. package/runtime/src/shape.c +294 -0
  202. package/runtime/src/shape.h +46 -0
  203. package/runtime/src/streams.c +1046 -0
  204. package/runtime/src/streams.h +47 -0
  205. package/runtime/src/string.c +364 -0
  206. package/runtime/src/string_builtins.c +837 -0
  207. package/runtime/src/symbol.c +143 -0
  208. package/runtime/src/test_host.c +59 -0
  209. package/runtime/src/typedarray.c +1330 -0
  210. package/runtime/src/tznames.gen.h +712 -0
  211. package/runtime/src/uri.c +169 -0
  212. package/runtime/src/url.c +2116 -0
  213. package/runtime/src/weak.c +486 -0
  214. package/runtime/src/web.c +214 -0
  215. package/runtime/src/wrapper.c +59 -0
  216. package/runtime/src/writable.c +1486 -0
  217. package/runtime/third_party/ada-idna/LICENSE-MIT +18 -0
  218. package/runtime/third_party/ada-idna/README.md +27 -0
  219. package/runtime/third_party/ada-idna/convert.mjs +83 -0
  220. package/runtime/third_party/ada-idna/idna.c +416 -0
  221. package/runtime/third_party/ada-idna/idna.h +15 -0
  222. package/runtime/third_party/ada-idna/idna_tables.h +2657 -0
  223. package/runtime/third_party/bearssl/LICENSE.txt +21 -0
  224. package/runtime/third_party/bearssl/README.txt +136 -0
  225. package/runtime/third_party/bearssl/VERSION +1 -0
  226. package/runtime/third_party/bearssl/inc/bearssl.h +183 -0
  227. package/runtime/third_party/bearssl/inc/bearssl_aead.h +1059 -0
  228. package/runtime/third_party/bearssl/inc/bearssl_block.h +2618 -0
  229. package/runtime/third_party/bearssl/inc/bearssl_ec.h +967 -0
  230. package/runtime/third_party/bearssl/inc/bearssl_hash.h +1346 -0
  231. package/runtime/third_party/bearssl/inc/bearssl_hmac.h +241 -0
  232. package/runtime/third_party/bearssl/inc/bearssl_kdf.h +284 -0
  233. package/runtime/third_party/bearssl/inc/bearssl_pem.h +294 -0
  234. package/runtime/third_party/bearssl/inc/bearssl_prf.h +150 -0
  235. package/runtime/third_party/bearssl/inc/bearssl_rand.h +397 -0
  236. package/runtime/third_party/bearssl/inc/bearssl_rsa.h +1655 -0
  237. package/runtime/third_party/bearssl/inc/bearssl_ssl.h +4296 -0
  238. package/runtime/third_party/bearssl/inc/bearssl_x509.h +1474 -0
  239. package/runtime/third_party/bearssl/src/aead/ccm.c +346 -0
  240. package/runtime/third_party/bearssl/src/aead/eax.c +525 -0
  241. package/runtime/third_party/bearssl/src/aead/gcm.c +318 -0
  242. package/runtime/third_party/bearssl/src/codec/ccopy.c +44 -0
  243. package/runtime/third_party/bearssl/src/codec/dec16be.c +38 -0
  244. package/runtime/third_party/bearssl/src/codec/dec16le.c +38 -0
  245. package/runtime/third_party/bearssl/src/codec/dec32be.c +38 -0
  246. package/runtime/third_party/bearssl/src/codec/dec32le.c +38 -0
  247. package/runtime/third_party/bearssl/src/codec/dec64be.c +38 -0
  248. package/runtime/third_party/bearssl/src/codec/dec64le.c +38 -0
  249. package/runtime/third_party/bearssl/src/codec/enc16be.c +38 -0
  250. package/runtime/third_party/bearssl/src/codec/enc16le.c +38 -0
  251. package/runtime/third_party/bearssl/src/codec/enc32be.c +38 -0
  252. package/runtime/third_party/bearssl/src/codec/enc32le.c +38 -0
  253. package/runtime/third_party/bearssl/src/codec/enc64be.c +38 -0
  254. package/runtime/third_party/bearssl/src/codec/enc64le.c +38 -0
  255. package/runtime/third_party/bearssl/src/codec/pemdec.c +526 -0
  256. package/runtime/third_party/bearssl/src/codec/pemdec.t0 +314 -0
  257. package/runtime/third_party/bearssl/src/codec/pemenc.c +173 -0
  258. package/runtime/third_party/bearssl/src/config.h +247 -0
  259. package/runtime/third_party/bearssl/src/ec/ec_all_m15.c +121 -0
  260. package/runtime/third_party/bearssl/src/ec/ec_all_m31.c +171 -0
  261. package/runtime/third_party/bearssl/src/ec/ec_c25519_i15.c +398 -0
  262. package/runtime/third_party/bearssl/src/ec/ec_c25519_i31.c +390 -0
  263. package/runtime/third_party/bearssl/src/ec/ec_c25519_m15.c +1478 -0
  264. package/runtime/third_party/bearssl/src/ec/ec_c25519_m31.c +800 -0
  265. package/runtime/third_party/bearssl/src/ec/ec_c25519_m62.c +605 -0
  266. package/runtime/third_party/bearssl/src/ec/ec_c25519_m64.c +831 -0
  267. package/runtime/third_party/bearssl/src/ec/ec_curve25519.c +46 -0
  268. package/runtime/third_party/bearssl/src/ec/ec_default.c +36 -0
  269. package/runtime/third_party/bearssl/src/ec/ec_keygen.c +86 -0
  270. package/runtime/third_party/bearssl/src/ec/ec_p256_m15.c +2124 -0
  271. package/runtime/third_party/bearssl/src/ec/ec_p256_m31.c +1469 -0
  272. package/runtime/third_party/bearssl/src/ec/ec_p256_m62.c +1765 -0
  273. package/runtime/third_party/bearssl/src/ec/ec_p256_m64.c +1781 -0
  274. package/runtime/third_party/bearssl/src/ec/ec_prime_i15.c +824 -0
  275. package/runtime/third_party/bearssl/src/ec/ec_prime_i31.c +826 -0
  276. package/runtime/third_party/bearssl/src/ec/ec_pubkey.c +85 -0
  277. package/runtime/third_party/bearssl/src/ec/ec_secp256r1.c +51 -0
  278. package/runtime/third_party/bearssl/src/ec/ec_secp384r1.c +57 -0
  279. package/runtime/third_party/bearssl/src/ec/ec_secp521r1.c +64 -0
  280. package/runtime/third_party/bearssl/src/ec/ecdsa_atr.c +134 -0
  281. package/runtime/third_party/bearssl/src/ec/ecdsa_default_sign_asn1.c +36 -0
  282. package/runtime/third_party/bearssl/src/ec/ecdsa_default_sign_raw.c +36 -0
  283. package/runtime/third_party/bearssl/src/ec/ecdsa_default_vrfy_asn1.c +36 -0
  284. package/runtime/third_party/bearssl/src/ec/ecdsa_default_vrfy_raw.c +36 -0
  285. package/runtime/third_party/bearssl/src/ec/ecdsa_i15_bits.c +47 -0
  286. package/runtime/third_party/bearssl/src/ec/ecdsa_i15_sign_asn1.c +45 -0
  287. package/runtime/third_party/bearssl/src/ec/ecdsa_i15_sign_raw.c +174 -0
  288. package/runtime/third_party/bearssl/src/ec/ecdsa_i15_vrfy_asn1.c +48 -0
  289. package/runtime/third_party/bearssl/src/ec/ecdsa_i15_vrfy_raw.c +166 -0
  290. package/runtime/third_party/bearssl/src/ec/ecdsa_i31_bits.c +47 -0
  291. package/runtime/third_party/bearssl/src/ec/ecdsa_i31_sign_asn1.c +45 -0
  292. package/runtime/third_party/bearssl/src/ec/ecdsa_i31_sign_raw.c +173 -0
  293. package/runtime/third_party/bearssl/src/ec/ecdsa_i31_vrfy_asn1.c +48 -0
  294. package/runtime/third_party/bearssl/src/ec/ecdsa_i31_vrfy_raw.c +165 -0
  295. package/runtime/third_party/bearssl/src/ec/ecdsa_rta.c +121 -0
  296. package/runtime/third_party/bearssl/src/hash/dig_oid.c +84 -0
  297. package/runtime/third_party/bearssl/src/hash/dig_size.c +50 -0
  298. package/runtime/third_party/bearssl/src/hash/ghash_ctmul.c +345 -0
  299. package/runtime/third_party/bearssl/src/hash/ghash_ctmul32.c +251 -0
  300. package/runtime/third_party/bearssl/src/hash/ghash_ctmul64.c +154 -0
  301. package/runtime/third_party/bearssl/src/hash/ghash_pclmul.c +389 -0
  302. package/runtime/third_party/bearssl/src/hash/ghash_pwr8.c +411 -0
  303. package/runtime/third_party/bearssl/src/hash/md5.c +208 -0
  304. package/runtime/third_party/bearssl/src/hash/md5sha1.c +141 -0
  305. package/runtime/third_party/bearssl/src/hash/mgf1.c +56 -0
  306. package/runtime/third_party/bearssl/src/hash/multihash.c +166 -0
  307. package/runtime/third_party/bearssl/src/hash/sha1.c +191 -0
  308. package/runtime/third_party/bearssl/src/hash/sha2big.c +285 -0
  309. package/runtime/third_party/bearssl/src/hash/sha2small.c +341 -0
  310. package/runtime/third_party/bearssl/src/inner.h +2577 -0
  311. package/runtime/third_party/bearssl/src/int/i15_add.c +46 -0
  312. package/runtime/third_party/bearssl/src/int/i15_bitlen.c +44 -0
  313. package/runtime/third_party/bearssl/src/int/i15_decmod.c +124 -0
  314. package/runtime/third_party/bearssl/src/int/i15_decode.c +56 -0
  315. package/runtime/third_party/bearssl/src/int/i15_decred.c +100 -0
  316. package/runtime/third_party/bearssl/src/int/i15_encode.c +56 -0
  317. package/runtime/third_party/bearssl/src/int/i15_fmont.c +59 -0
  318. package/runtime/third_party/bearssl/src/int/i15_iszero.c +39 -0
  319. package/runtime/third_party/bearssl/src/int/i15_moddiv.c +465 -0
  320. package/runtime/third_party/bearssl/src/int/i15_modpow.c +50 -0
  321. package/runtime/third_party/bearssl/src/int/i15_modpow2.c +160 -0
  322. package/runtime/third_party/bearssl/src/int/i15_montmul.c +184 -0
  323. package/runtime/third_party/bearssl/src/int/i15_mulacc.c +61 -0
  324. package/runtime/third_party/bearssl/src/int/i15_muladd.c +173 -0
  325. package/runtime/third_party/bearssl/src/int/i15_ninv15.c +38 -0
  326. package/runtime/third_party/bearssl/src/int/i15_reduce.c +66 -0
  327. package/runtime/third_party/bearssl/src/int/i15_rshift.c +47 -0
  328. package/runtime/third_party/bearssl/src/int/i15_sub.c +46 -0
  329. package/runtime/third_party/bearssl/src/int/i15_tmont.c +36 -0
  330. package/runtime/third_party/bearssl/src/int/i31_add.c +46 -0
  331. package/runtime/third_party/bearssl/src/int/i31_bitlen.c +44 -0
  332. package/runtime/third_party/bearssl/src/int/i31_decmod.c +124 -0
  333. package/runtime/third_party/bearssl/src/int/i31_decode.c +57 -0
  334. package/runtime/third_party/bearssl/src/int/i31_decred.c +103 -0
  335. package/runtime/third_party/bearssl/src/int/i31_encode.c +79 -0
  336. package/runtime/third_party/bearssl/src/int/i31_fmont.c +60 -0
  337. package/runtime/third_party/bearssl/src/int/i31_iszero.c +39 -0
  338. package/runtime/third_party/bearssl/src/int/i31_moddiv.c +488 -0
  339. package/runtime/third_party/bearssl/src/int/i31_modpow.c +65 -0
  340. package/runtime/third_party/bearssl/src/int/i31_modpow2.c +160 -0
  341. package/runtime/third_party/bearssl/src/int/i31_montmul.c +127 -0
  342. package/runtime/third_party/bearssl/src/int/i31_mulacc.c +74 -0
  343. package/runtime/third_party/bearssl/src/int/i31_muladd.c +157 -0
  344. package/runtime/third_party/bearssl/src/int/i31_ninv31.c +39 -0
  345. package/runtime/third_party/bearssl/src/int/i31_reduce.c +66 -0
  346. package/runtime/third_party/bearssl/src/int/i31_rshift.c +47 -0
  347. package/runtime/third_party/bearssl/src/int/i31_sub.c +46 -0
  348. package/runtime/third_party/bearssl/src/int/i31_tmont.c +36 -0
  349. package/runtime/third_party/bearssl/src/int/i32_add.c +51 -0
  350. package/runtime/third_party/bearssl/src/int/i32_bitlen.c +44 -0
  351. package/runtime/third_party/bearssl/src/int/i32_decmod.c +77 -0
  352. package/runtime/third_party/bearssl/src/int/i32_decode.c +63 -0
  353. package/runtime/third_party/bearssl/src/int/i32_decred.c +107 -0
  354. package/runtime/third_party/bearssl/src/int/i32_div32.c +56 -0
  355. package/runtime/third_party/bearssl/src/int/i32_encode.c +72 -0
  356. package/runtime/third_party/bearssl/src/int/i32_fmont.c +60 -0
  357. package/runtime/third_party/bearssl/src/int/i32_iszero.c +39 -0
  358. package/runtime/third_party/bearssl/src/int/i32_modpow.c +65 -0
  359. package/runtime/third_party/bearssl/src/int/i32_montmul.c +69 -0
  360. package/runtime/third_party/bearssl/src/int/i32_mulacc.c +56 -0
  361. package/runtime/third_party/bearssl/src/int/i32_muladd.c +138 -0
  362. package/runtime/third_party/bearssl/src/int/i32_ninv32.c +39 -0
  363. package/runtime/third_party/bearssl/src/int/i32_reduce.c +66 -0
  364. package/runtime/third_party/bearssl/src/int/i32_sub.c +51 -0
  365. package/runtime/third_party/bearssl/src/int/i32_tmont.c +36 -0
  366. package/runtime/third_party/bearssl/src/int/i62_modpow2.c +493 -0
  367. package/runtime/third_party/bearssl/src/kdf/hkdf.c +107 -0
  368. package/runtime/third_party/bearssl/src/kdf/shake.c +590 -0
  369. package/runtime/third_party/bearssl/src/mac/hmac.c +122 -0
  370. package/runtime/third_party/bearssl/src/mac/hmac_ct.c +193 -0
  371. package/runtime/third_party/bearssl/src/rand/aesctr_drbg.c +206 -0
  372. package/runtime/third_party/bearssl/src/rand/hmac_drbg.c +157 -0
  373. package/runtime/third_party/bearssl/src/rand/sysrng.c +252 -0
  374. package/runtime/third_party/bearssl/src/rsa/rsa_default_keygen.c +38 -0
  375. package/runtime/third_party/bearssl/src/rsa/rsa_default_modulus.c +36 -0
  376. package/runtime/third_party/bearssl/src/rsa/rsa_default_oaep_decrypt.c +38 -0
  377. package/runtime/third_party/bearssl/src/rsa/rsa_default_oaep_encrypt.c +38 -0
  378. package/runtime/third_party/bearssl/src/rsa/rsa_default_pkcs1_sign.c +38 -0
  379. package/runtime/third_party/bearssl/src/rsa/rsa_default_pkcs1_vrfy.c +38 -0
  380. package/runtime/third_party/bearssl/src/rsa/rsa_default_priv.c +38 -0
  381. package/runtime/third_party/bearssl/src/rsa/rsa_default_privexp.c +36 -0
  382. package/runtime/third_party/bearssl/src/rsa/rsa_default_pss_sign.c +38 -0
  383. package/runtime/third_party/bearssl/src/rsa/rsa_default_pss_vrfy.c +38 -0
  384. package/runtime/third_party/bearssl/src/rsa/rsa_default_pub.c +38 -0
  385. package/runtime/third_party/bearssl/src/rsa/rsa_default_pubexp.c +36 -0
  386. package/runtime/third_party/bearssl/src/rsa/rsa_i15_keygen.c +583 -0
  387. package/runtime/third_party/bearssl/src/rsa/rsa_i15_modulus.c +99 -0
  388. package/runtime/third_party/bearssl/src/rsa/rsa_i15_oaep_decrypt.c +41 -0
  389. package/runtime/third_party/bearssl/src/rsa/rsa_i15_oaep_encrypt.c +44 -0
  390. package/runtime/third_party/bearssl/src/rsa/rsa_i15_pkcs1_sign.c +37 -0
  391. package/runtime/third_party/bearssl/src/rsa/rsa_i15_pkcs1_vrfy.c +43 -0
  392. package/runtime/third_party/bearssl/src/rsa/rsa_i15_priv.c +209 -0
  393. package/runtime/third_party/bearssl/src/rsa/rsa_i15_privexp.c +320 -0
  394. package/runtime/third_party/bearssl/src/rsa/rsa_i15_pss_sign.c +40 -0
  395. package/runtime/third_party/bearssl/src/rsa/rsa_i15_pss_vrfy.c +44 -0
  396. package/runtime/third_party/bearssl/src/rsa/rsa_i15_pub.c +113 -0
  397. package/runtime/third_party/bearssl/src/rsa/rsa_i15_pubexp.c +152 -0
  398. package/runtime/third_party/bearssl/src/rsa/rsa_i31_keygen.c +37 -0
  399. package/runtime/third_party/bearssl/src/rsa/rsa_i31_keygen_inner.c +608 -0
  400. package/runtime/third_party/bearssl/src/rsa/rsa_i31_modulus.c +99 -0
  401. package/runtime/third_party/bearssl/src/rsa/rsa_i31_oaep_decrypt.c +41 -0
  402. package/runtime/third_party/bearssl/src/rsa/rsa_i31_oaep_encrypt.c +44 -0
  403. package/runtime/third_party/bearssl/src/rsa/rsa_i31_pkcs1_sign.c +37 -0
  404. package/runtime/third_party/bearssl/src/rsa/rsa_i31_pkcs1_vrfy.c +43 -0
  405. package/runtime/third_party/bearssl/src/rsa/rsa_i31_priv.c +203 -0
  406. package/runtime/third_party/bearssl/src/rsa/rsa_i31_privexp.c +318 -0
  407. package/runtime/third_party/bearssl/src/rsa/rsa_i31_pss_sign.c +40 -0
  408. package/runtime/third_party/bearssl/src/rsa/rsa_i31_pss_vrfy.c +44 -0
  409. package/runtime/third_party/bearssl/src/rsa/rsa_i31_pub.c +106 -0
  410. package/runtime/third_party/bearssl/src/rsa/rsa_i31_pubexp.c +152 -0
  411. package/runtime/third_party/bearssl/src/rsa/rsa_i32_oaep_decrypt.c +41 -0
  412. package/runtime/third_party/bearssl/src/rsa/rsa_i32_oaep_encrypt.c +44 -0
  413. package/runtime/third_party/bearssl/src/rsa/rsa_i32_pkcs1_sign.c +37 -0
  414. package/runtime/third_party/bearssl/src/rsa/rsa_i32_pkcs1_vrfy.c +43 -0
  415. package/runtime/third_party/bearssl/src/rsa/rsa_i32_priv.c +160 -0
  416. package/runtime/third_party/bearssl/src/rsa/rsa_i32_pss_sign.c +40 -0
  417. package/runtime/third_party/bearssl/src/rsa/rsa_i32_pss_vrfy.c +44 -0
  418. package/runtime/third_party/bearssl/src/rsa/rsa_i32_pub.c +77 -0
  419. package/runtime/third_party/bearssl/src/rsa/rsa_i62_keygen.c +57 -0
  420. package/runtime/third_party/bearssl/src/rsa/rsa_i62_oaep_decrypt.c +61 -0
  421. package/runtime/third_party/bearssl/src/rsa/rsa_i62_oaep_encrypt.c +64 -0
  422. package/runtime/third_party/bearssl/src/rsa/rsa_i62_pkcs1_sign.c +57 -0
  423. package/runtime/third_party/bearssl/src/rsa/rsa_i62_pkcs1_vrfy.c +63 -0
  424. package/runtime/third_party/bearssl/src/rsa/rsa_i62_priv.c +223 -0
  425. package/runtime/third_party/bearssl/src/rsa/rsa_i62_pss_sign.c +60 -0
  426. package/runtime/third_party/bearssl/src/rsa/rsa_i62_pss_vrfy.c +64 -0
  427. package/runtime/third_party/bearssl/src/rsa/rsa_i62_pub.c +125 -0
  428. package/runtime/third_party/bearssl/src/rsa/rsa_oaep_pad.c +112 -0
  429. package/runtime/third_party/bearssl/src/rsa/rsa_oaep_unpad.c +145 -0
  430. package/runtime/third_party/bearssl/src/rsa/rsa_pkcs1_sig_pad.c +100 -0
  431. package/runtime/third_party/bearssl/src/rsa/rsa_pkcs1_sig_unpad.c +121 -0
  432. package/runtime/third_party/bearssl/src/rsa/rsa_pss_sig_pad.c +106 -0
  433. package/runtime/third_party/bearssl/src/rsa/rsa_pss_sig_unpad.c +121 -0
  434. package/runtime/third_party/bearssl/src/rsa/rsa_ssl_decrypt.c +52 -0
  435. package/runtime/third_party/bearssl/src/settings.c +306 -0
  436. package/runtime/third_party/bearssl/src/symcipher/aes_big_cbcdec.c +69 -0
  437. package/runtime/third_party/bearssl/src/symcipher/aes_big_cbcenc.c +67 -0
  438. package/runtime/third_party/bearssl/src/symcipher/aes_big_ctr.c +84 -0
  439. package/runtime/third_party/bearssl/src/symcipher/aes_big_ctrcbc.c +142 -0
  440. package/runtime/third_party/bearssl/src/symcipher/aes_big_dec.c +254 -0
  441. package/runtime/third_party/bearssl/src/symcipher/aes_big_enc.c +157 -0
  442. package/runtime/third_party/bearssl/src/symcipher/aes_common.c +112 -0
  443. package/runtime/third_party/bearssl/src/symcipher/aes_ct.c +328 -0
  444. package/runtime/third_party/bearssl/src/symcipher/aes_ct64.c +398 -0
  445. package/runtime/third_party/bearssl/src/symcipher/aes_ct64_cbcdec.c +104 -0
  446. package/runtime/third_party/bearssl/src/symcipher/aes_ct64_cbcenc.c +81 -0
  447. package/runtime/third_party/bearssl/src/symcipher/aes_ct64_ctr.c +114 -0
  448. package/runtime/third_party/bearssl/src/symcipher/aes_ct64_ctrcbc.c +433 -0
  449. package/runtime/third_party/bearssl/src/symcipher/aes_ct64_dec.c +159 -0
  450. package/runtime/third_party/bearssl/src/symcipher/aes_ct64_enc.c +115 -0
  451. package/runtime/third_party/bearssl/src/symcipher/aes_ct_cbcdec.c +111 -0
  452. package/runtime/third_party/bearssl/src/symcipher/aes_ct_cbcenc.c +91 -0
  453. package/runtime/third_party/bearssl/src/symcipher/aes_ct_ctr.c +116 -0
  454. package/runtime/third_party/bearssl/src/symcipher/aes_ct_ctrcbc.c +422 -0
  455. package/runtime/third_party/bearssl/src/symcipher/aes_ct_dec.c +170 -0
  456. package/runtime/third_party/bearssl/src/symcipher/aes_ct_enc.c +112 -0
  457. package/runtime/third_party/bearssl/src/symcipher/aes_pwr8.c +445 -0
  458. package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_cbcdec.c +670 -0
  459. package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_cbcenc.c +417 -0
  460. package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_ctr.c +717 -0
  461. package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_ctrcbc.c +946 -0
  462. package/runtime/third_party/bearssl/src/symcipher/aes_small_cbcdec.c +69 -0
  463. package/runtime/third_party/bearssl/src/symcipher/aes_small_cbcenc.c +67 -0
  464. package/runtime/third_party/bearssl/src/symcipher/aes_small_ctr.c +84 -0
  465. package/runtime/third_party/bearssl/src/symcipher/aes_small_ctrcbc.c +142 -0
  466. package/runtime/third_party/bearssl/src/symcipher/aes_small_dec.c +176 -0
  467. package/runtime/third_party/bearssl/src/symcipher/aes_small_enc.c +129 -0
  468. package/runtime/third_party/bearssl/src/symcipher/aes_x86ni.c +240 -0
  469. package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_cbcdec.c +223 -0
  470. package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_cbcenc.c +122 -0
  471. package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_ctr.c +211 -0
  472. package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_ctrcbc.c +596 -0
  473. package/runtime/third_party/bearssl/src/symcipher/chacha20_ct.c +106 -0
  474. package/runtime/third_party/bearssl/src/symcipher/chacha20_sse2.c +237 -0
  475. package/runtime/third_party/bearssl/src/symcipher/des_ct.c +411 -0
  476. package/runtime/third_party/bearssl/src/symcipher/des_ct_cbcdec.c +87 -0
  477. package/runtime/third_party/bearssl/src/symcipher/des_ct_cbcenc.c +69 -0
  478. package/runtime/third_party/bearssl/src/symcipher/des_support.c +166 -0
  479. package/runtime/third_party/bearssl/src/symcipher/des_tab.c +310 -0
  480. package/runtime/third_party/bearssl/src/symcipher/des_tab_cbcdec.c +85 -0
  481. package/runtime/third_party/bearssl/src/symcipher/des_tab_cbcenc.c +67 -0
  482. package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmul.c +260 -0
  483. package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmul32.c +297 -0
  484. package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmulq.c +475 -0
  485. package/runtime/third_party/bearssl/src/symcipher/poly1305_i15.c +221 -0
  486. package/runtime/third_party/bearssl/src/x509/asn1.t0 +757 -0
  487. package/runtime/third_party/bearssl/src/x509/asn1enc.c +93 -0
  488. package/runtime/third_party/bearssl/src/x509/encode_ec_pk8der.c +110 -0
  489. package/runtime/third_party/bearssl/src/x509/encode_ec_rawder.c +161 -0
  490. package/runtime/third_party/bearssl/src/x509/encode_rsa_pk8der.c +97 -0
  491. package/runtime/third_party/bearssl/src/x509/encode_rsa_rawder.c +96 -0
  492. package/runtime/third_party/bearssl/src/x509/skey_decoder.c +653 -0
  493. package/runtime/third_party/bearssl/src/x509/skey_decoder.t0 +376 -0
  494. package/runtime/third_party/bearssl/src/x509/x509_decoder.c +776 -0
  495. package/runtime/third_party/bearssl/src/x509/x509_decoder.t0 +324 -0
  496. package/runtime/third_party/bearssl/src/x509/x509_knownkey.c +105 -0
  497. package/runtime/third_party/bearssl/src/x509/x509_minimal.c +1722 -0
  498. package/runtime/third_party/bearssl/src/x509/x509_minimal.t0 +1526 -0
  499. package/runtime/third_party/bearssl/src/x509/x509_minimal_full.c +59 -0
  500. package/runtime/third_party/quickjs-dtoa/LICENSE +22 -0
  501. package/runtime/third_party/quickjs-dtoa/README.md +23 -0
  502. package/runtime/third_party/quickjs-dtoa/dtoa.c +1640 -0
  503. package/runtime/third_party/quickjs-dtoa/dtoa.h +83 -0
  504. package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +89 -0
  505. package/runtime/third_party/quickjs-regexp/LICENSE +22 -0
  506. package/runtime/third_party/quickjs-regexp/README.md +22 -0
  507. package/runtime/third_party/quickjs-regexp/cutils.c +641 -0
  508. package/runtime/third_party/quickjs-regexp/cutils.h +457 -0
  509. package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +73 -0
  510. package/runtime/third_party/quickjs-regexp/libregexp.c +3448 -0
  511. package/runtime/third_party/quickjs-regexp/libregexp.h +65 -0
  512. package/runtime/third_party/quickjs-regexp/libunicode-table.h +5206 -0
  513. package/runtime/third_party/quickjs-regexp/libunicode.c +2124 -0
  514. package/runtime/third_party/quickjs-regexp/libunicode.h +196 -0
  515. package/runtime/third_party/v8-ieee754/LICENSE +61 -0
  516. package/runtime/third_party/v8-ieee754/README.md +22 -0
  517. package/runtime/third_party/v8-ieee754/convert.py +84 -0
  518. package/runtime/third_party/v8-ieee754/ieee754.c +3030 -0
  519. package/runtime/third_party/v8-ieee754/ieee754.h +27 -0
  520. package/runtime/tools/regexp_compile.c +90 -0
@@ -0,0 +1,1156 @@
1
+ // node:url (ADR 0012, layer 3): the legacy url.parse/format/resolve API (Node's lib/url.js, v22.22.2,
2
+ // ported: primordials as plain calls, its requires as imports, Node's bindings as JS over the
3
+ // url component), the WHATWG URL and URLSearchParams (the runtime's), and Node's file-URL and
4
+ // domain helpers (from lib/internal/url.js; POSIX paths). Node's notice for lib/url.js:
5
+ //
6
+ // Copyright Joyent, Inc. and other Node contributors.
7
+ //
8
+ // Permission is hereby granted, free of charge, to any person obtaining a
9
+ // copy of this software and associated documentation files (the
10
+ // "Software"), to deal in the Software without restriction, including
11
+ // without limitation the rights to use, copy, modify, merge, publish,
12
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
13
+ // persons to whom the Software is furnished to do so, subject to the
14
+ // following conditions:
15
+ //
16
+ // The above copyright notice and this permission notice shall be included
17
+ // in all copies or substantial portions of the Software.
18
+ //
19
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
22
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
23
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+
27
+ import { codeError, invalidArgType } from "./internal/errors.js";
28
+ import { encodeStr, hexTable } from "./internal/querystring.js";
29
+ import * as path from "./path.js";
30
+ import querystring from "./querystring.js";
31
+
32
+ const URL = globalThis.URL;
33
+ const URLSearchParams = globalThis.URLSearchParams;
34
+
35
+ /* ---- what Node's bindings and lib/internal/url.js give lib/url.js -------------------------------- */
36
+
37
+ const invalidUrl = (input) => {
38
+ const e = codeError(TypeError, "ERR_INVALID_URL", "Invalid URL");
39
+ e.input = input;
40
+ return e;
41
+ };
42
+
43
+ function validateString(value, name) {
44
+ if (typeof value !== "string") throw invalidArgType(name, "of type string", value);
45
+ }
46
+
47
+ function validateObject(value, name) {
48
+ if (value === null || typeof value !== "object") throw invalidArgType(name, "of type object", value);
49
+ }
50
+
51
+ function spliceOne(list, index) {
52
+ for (; index + 1 < list.length; index++) list[index] = list[index + 1];
53
+ list.pop();
54
+ }
55
+
56
+ // Protocols that can allow "unsafe" and "unwise" chars.
57
+ const unsafeProtocol = new Set(["javascript", "javascript:"]);
58
+ // Protocols that never have a hostname.
59
+ const hostlessProtocol = new Set(["javascript", "javascript:"]);
60
+ // Protocols that always contain a // bit.
61
+ const slashedProtocol = new Set(["http", "http:", "https", "https:", "ftp", "ftp:", "gopher", "gopher:", "file", "file:", "ws", "ws:", "wss", "wss:"]);
62
+
63
+ /* Punycode's decoding (RFC 3492), for domainToUnicode */
64
+ function punycodeDecode(input) {
65
+ const base = 36, tMin = 1, tMax = 26, skew = 38, damp = 700;
66
+ const output = [];
67
+ let basic = input.lastIndexOf("-");
68
+ if (basic < 0) basic = 0;
69
+ for (let j = 0; j < basic; ++j) output.push(input.charCodeAt(j));
70
+ let n = 128, bias = 72, i = 0;
71
+ const adapt = (delta, numPoints, firstTime) => {
72
+ let k = 0;
73
+ delta = firstTime ? Math.floor(delta / damp) : delta >> 1;
74
+ delta += Math.floor(delta / numPoints);
75
+ for (; delta > ((base - tMin) * tMax) >> 1; k += base) delta = Math.floor(delta / (base - tMin));
76
+ return Math.floor(k + ((base - tMin + 1) * delta) / (delta + skew));
77
+ };
78
+ for (let index = basic > 0 ? basic + 1 : 0; index < input.length;) {
79
+ const oldi = i;
80
+ for (let w = 1, k = base; ; k += base) {
81
+ if (index >= input.length) return null;
82
+ const c = input.charCodeAt(index++);
83
+ const digit = c - 48 < 10 ? c - 22 : c - 65 < 26 ? c - 65 : c - 97 < 26 ? c - 97 : base;
84
+ if (digit >= base) return null;
85
+ i += digit * w;
86
+ const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
87
+ if (digit < t) break;
88
+ w *= base - t;
89
+ }
90
+ const out = output.length + 1;
91
+ bias = adapt(i - oldi, out, oldi === 0);
92
+ n += Math.floor(i / out);
93
+ i %= out;
94
+ output.splice(i++, 0, n);
95
+ }
96
+ return String.fromCodePoint(...output);
97
+ }
98
+
99
+ /* bindingUrl.domainToASCII: the host as a URL's host setter takes it ("" when it doesn't) */
100
+ function domainToASCII(domain) {
101
+ if (arguments.length < 1) throw codeError(TypeError, "ERR_MISSING_ARGS", 'The "domain" argument must be specified');
102
+ domain = `${domain}`;
103
+ const u = new URL("ws://x");
104
+ u.hostname = domain;
105
+ return u.hostname === "x" && domain.toLowerCase() !== "x" ? "" : u.hostname;
106
+ }
107
+
108
+ function domainToUnicode(domain) {
109
+ if (arguments.length < 1) throw codeError(TypeError, "ERR_MISSING_ARGS", 'The "domain" argument must be specified');
110
+ const ascii = domainToASCII(domain);
111
+ if (ascii === "") return "";
112
+ return ascii.split(".").map((label) => (label.startsWith("xn--") ? punycodeDecode(label.slice(4)) ?? label : label)).join(".");
113
+ }
114
+
115
+ /* encoding_binding.toASCII: IDNA's ToASCII of a non-ASCII hostname */
116
+ function toASCII(hostname) {
117
+ /* eslint-disable-next-line no-control-regex */
118
+ return /^[\x00-\x7f]*$/.test(hostname) ? hostname : domainToASCII(hostname);
119
+ }
120
+
121
+ /* bindingUrl.format: a WHATWG URL's href without the parts not wanted */
122
+ function formatWhatwg(url, fragment, unicode, search, auth) {
123
+ const u = new URL(url.href);
124
+ if (!fragment) u.hash = "";
125
+ if (!search) u.search = "";
126
+ if (!auth) {
127
+ u.username = "";
128
+ u.password = "";
129
+ }
130
+ let href = u.href;
131
+ if (!fragment && href.endsWith("#")) href = href.slice(0, -1);
132
+ if (unicode && u.hostname) href = href.replace(u.hostname, domainToUnicode(u.hostname));
133
+ return href;
134
+ }
135
+
136
+ function urlToHttpOptions(url) {
137
+ validateObject(url, "url");
138
+ const { hostname, pathname, port, username, password, search } = url;
139
+ const options = {
140
+ __proto__: null,
141
+ ...url, // In case the url object was extended by the user.
142
+ protocol: url.protocol,
143
+ hostname: hostname && hostname[0] === "[" ? hostname.slice(1, -1) : hostname,
144
+ hash: url.hash,
145
+ search: search,
146
+ pathname: pathname,
147
+ path: `${pathname || ""}${search || ""}`,
148
+ href: url.href,
149
+ };
150
+ if (port !== "") options.port = Number(port);
151
+ if (username || password) options.auth = `${decodeURIComponent(username)}:${decodeURIComponent(password)}`;
152
+ return options;
153
+ }
154
+
155
+ function fileUrlOf(path) {
156
+ if (typeof path === "string") return new URL(path);
157
+ if (!(path instanceof URL)) throw invalidArgType("path", "of type string or an instance of URL", path);
158
+ return path;
159
+ }
160
+
161
+ function checkFileUrl(url) {
162
+ if (url.protocol !== "file:") throw codeError(TypeError, "ERR_INVALID_URL_SCHEME", "The URL must be of scheme file");
163
+ if (url.hostname !== "") throw codeError(TypeError, "ERR_INVALID_FILE_URL_HOST", `File URL host must be "localhost" or empty on ${process.platform}`);
164
+ const pathname = url.pathname;
165
+ for (let n = 0; n < pathname.length; n++) {
166
+ if (pathname[n] === "%" && pathname[n + 1] === "2" && (pathname.codePointAt(n + 2) | 0x20) === 102) {
167
+ throw codeError(TypeError, "ERR_INVALID_FILE_URL_PATH", "File URL path must not include encoded / characters");
168
+ }
169
+ }
170
+ return pathname;
171
+ }
172
+
173
+ function fileURLToPath(path) {
174
+ const pathname = checkFileUrl(fileUrlOf(path));
175
+ return pathname.includes("%") ? decodeURIComponent(pathname) : pathname;
176
+ }
177
+
178
+ function fileURLToPathBuffer(path) {
179
+ const pathname = checkFileUrl(fileUrlOf(path));
180
+ const bytes = Buffer.from(pathname, "utf8");
181
+ const out = [];
182
+ for (let i = 0; i < bytes.length; i++) {
183
+ const hex = (c) => (c >= 48 && c <= 57 ? c - 48 : (c | 0x20) >= 97 && (c | 0x20) <= 102 ? (c | 0x20) - 87 : -1);
184
+ if (bytes[i] === 37 && i + 2 < bytes.length && hex(bytes[i + 1]) >= 0 && hex(bytes[i + 2]) >= 0) {
185
+ out.push(hex(bytes[i + 1]) * 16 + hex(bytes[i + 2]));
186
+ i += 2;
187
+ } else {
188
+ out.push(bytes[i]);
189
+ }
190
+ }
191
+ return Buffer.from(out);
192
+ }
193
+
194
+ function pathToFileURL(filepath) {
195
+ validateString(filepath, "path");
196
+ let resolved = path.resolve(filepath);
197
+ /* path.resolve strips trailing slashes, so they're added back */
198
+ if (filepath.charCodeAt(filepath.length - 1) === CHAR_FORWARD_SLASH && resolved[resolved.length - 1] !== path.sep) resolved += "/";
199
+ /* the characters a URL's pathname setter would take differently */
200
+ resolved = resolved.replace(/%/g, "%25").replace(/\\/g, "%5C").replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/\t/g, "%09")
201
+ .replace(/#/g, "%23").replace(/\?/g, "%3F");
202
+ const url = new URL("file://");
203
+ url.pathname = resolved;
204
+ return url;
205
+ }
206
+
207
+ /* ---- Node's lib/url.js -------------------------------------------------------------------------- */
208
+
209
+ // Original url.parse() API
210
+
211
+ function Url() {
212
+ this.protocol = null;
213
+ this.slashes = null;
214
+ this.auth = null;
215
+ this.host = null;
216
+ this.port = null;
217
+ this.hostname = null;
218
+ this.hash = null;
219
+ this.search = null;
220
+ this.query = null;
221
+ this.pathname = null;
222
+ this.path = null;
223
+ this.href = null;
224
+ }
225
+
226
+ // Reference: RFC 3986, RFC 1808, RFC 2396
227
+
228
+ // define these here so at least they only have to be
229
+ // compiled once on the first module load.
230
+ const protocolPattern = /^[a-z0-9.+-]+:/i;
231
+ const portPattern = /:[0-9]*$/;
232
+ const hostPattern = /^\/\/[^@/]+@[^@/]+/;
233
+
234
+ // Special case for a simple path URL
235
+ const simplePathPattern = /^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/;
236
+
237
+ const hostnameMaxLen = 255;
238
+ const CHAR_SPACE = 32, CHAR_TAB = 9, CHAR_CARRIAGE_RETURN = 13, CHAR_LINE_FEED = 10, CHAR_NO_BREAK_SPACE = 160,
239
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE = 65279, CHAR_HASH = 35, CHAR_FORWARD_SLASH = 47, CHAR_LEFT_SQUARE_BRACKET = 91,
240
+ CHAR_RIGHT_SQUARE_BRACKET = 93, CHAR_LEFT_ANGLE_BRACKET = 60, CHAR_RIGHT_ANGLE_BRACKET = 62, CHAR_LEFT_CURLY_BRACKET = 123,
241
+ CHAR_RIGHT_CURLY_BRACKET = 125, CHAR_QUESTION_MARK = 63, CHAR_DOUBLE_QUOTE = 34, CHAR_SINGLE_QUOTE = 39, CHAR_PERCENT = 37,
242
+ CHAR_SEMICOLON = 59, CHAR_BACKWARD_SLASH = 92, CHAR_CIRCUMFLEX_ACCENT = 94, CHAR_GRAVE_ACCENT = 96, CHAR_VERTICAL_LINE = 124,
243
+ CHAR_AT = 64, CHAR_COLON = 58;
244
+
245
+ /* Node warns (DEP0169) only under --pending-deprecation, which a compiled program never has */
246
+ function urlParse(url, parseQueryString, slashesDenoteHost) {
247
+ if (url instanceof Url) return url;
248
+
249
+ const urlObject = new Url();
250
+ urlObject.parse(url, parseQueryString, slashesDenoteHost);
251
+ return urlObject;
252
+ }
253
+
254
+ function isIpv6Hostname(hostname) {
255
+ return (
256
+ hostname.charCodeAt(0) === CHAR_LEFT_SQUARE_BRACKET &&
257
+ hostname.charCodeAt(hostname.length - 1) ===
258
+ CHAR_RIGHT_SQUARE_BRACKET
259
+ );
260
+ }
261
+
262
+ // This prevents some common spoofing bugs due to our use of IDNA toASCII. For
263
+ // compatibility, the set of characters we use here is the *intersection* of
264
+ // "forbidden host code point" in the WHATWG URL Standard [1] and the
265
+ // characters in the host parsing loop in Url.prototype.parse, with the
266
+ // following additions:
267
+ //
268
+ // - ':' since this could cause a "protocol spoofing" bug
269
+ // - '@' since this could cause parts of the hostname to be confused with auth
270
+ // - '[' and ']' since this could cause a non-IPv6 hostname to be interpreted
271
+ // as IPv6 by isIpv6Hostname above
272
+ //
273
+ // [1]: https://url.spec.whatwg.org/#forbidden-host-code-point
274
+ const forbiddenHostChars = /[\0\t\n\r #%/:<>?@[\\\]^|]/;
275
+ // For IPv6, permit '[', ']', and ':'.
276
+ const forbiddenHostCharsIpv6 = /[\0\t\n\r #%/<>?@\\^|]/;
277
+
278
+ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
279
+ validateString(url, 'url');
280
+
281
+ // Copy chrome, IE, opera backslash-handling behavior.
282
+ // Back slashes before the query string get converted to forward slashes
283
+ // See: https://code.google.com/p/chromium/issues/detail?id=25916
284
+ let hasHash = false;
285
+ let hasAt = false;
286
+ let start = -1;
287
+ let end = -1;
288
+ let rest = '';
289
+ let lastPos = 0;
290
+ for (let i = 0, inWs = false, split = false; i < url.length; ++i) {
291
+ const code = url.charCodeAt(i);
292
+
293
+ // Find first and last non-whitespace characters for trimming
294
+ const isWs = code < 33 ||
295
+ code === CHAR_NO_BREAK_SPACE ||
296
+ code === CHAR_ZERO_WIDTH_NOBREAK_SPACE;
297
+ if (start === -1) {
298
+ if (isWs)
299
+ continue;
300
+ lastPos = start = i;
301
+ } else if (inWs) {
302
+ if (!isWs) {
303
+ end = -1;
304
+ inWs = false;
305
+ }
306
+ } else if (isWs) {
307
+ end = i;
308
+ inWs = true;
309
+ }
310
+
311
+ // Only convert backslashes while we haven't seen a split character
312
+ if (!split) {
313
+ switch (code) {
314
+ case CHAR_AT:
315
+ hasAt = true;
316
+ break;
317
+ case CHAR_HASH:
318
+ hasHash = true;
319
+ // Fall through
320
+ case CHAR_QUESTION_MARK:
321
+ split = true;
322
+ break;
323
+ case CHAR_BACKWARD_SLASH:
324
+ if (i - lastPos > 0)
325
+ rest += url.slice(lastPos, i);
326
+ rest += '/';
327
+ lastPos = i + 1;
328
+ break;
329
+ }
330
+ } else if (!hasHash && code === CHAR_HASH) {
331
+ hasHash = true;
332
+ }
333
+ }
334
+
335
+ // Check if string was non-empty (including strings with only whitespace)
336
+ if (start !== -1) {
337
+ if (lastPos === start) {
338
+ // We didn't convert any backslashes
339
+
340
+ if (end === -1) {
341
+ if (start === 0)
342
+ rest = url;
343
+ else
344
+ rest = url.slice(start);
345
+ } else {
346
+ rest = url.slice(start, end);
347
+ }
348
+ } else if (end === -1 && lastPos < url.length) {
349
+ // We converted some backslashes and have only part of the entire string
350
+ rest += url.slice(lastPos);
351
+ } else if (end !== -1 && lastPos < end) {
352
+ // We converted some backslashes and have only part of the entire string
353
+ rest += url.slice(lastPos, end);
354
+ }
355
+ }
356
+
357
+ if (!slashesDenoteHost && !hasHash && !hasAt) {
358
+ // Try fast path regexp
359
+ const simplePath = simplePathPattern.exec(rest);
360
+ if (simplePath) {
361
+ this.path = rest;
362
+ this.href = rest;
363
+ this.pathname = simplePath[1];
364
+ if (simplePath[2]) {
365
+ this.search = simplePath[2];
366
+ if (parseQueryString) {
367
+ this.query = querystring.parse(this.search.slice(1));
368
+ } else {
369
+ this.query = this.search.slice(1);
370
+ }
371
+ } else if (parseQueryString) {
372
+ this.search = null;
373
+ this.query = { __proto__: null };
374
+ }
375
+ return this;
376
+ }
377
+ }
378
+
379
+ let proto = protocolPattern.exec(rest);
380
+ let lowerProto;
381
+ if (proto) {
382
+ proto = proto[0];
383
+ lowerProto = proto.toLowerCase();
384
+ this.protocol = lowerProto;
385
+ rest = rest.slice(proto.length);
386
+ }
387
+
388
+ // Figure out if it's got a host
389
+ // user@server is *always* interpreted as a hostname, and url
390
+ // resolution will treat //foo/bar as host=foo,path=bar because that's
391
+ // how the browser resolves relative URLs.
392
+ let slashes;
393
+ if (slashesDenoteHost || proto || hostPattern.test(rest)) {
394
+ slashes = rest.charCodeAt(0) === CHAR_FORWARD_SLASH &&
395
+ rest.charCodeAt(1) === CHAR_FORWARD_SLASH;
396
+ if (slashes && !(proto && hostlessProtocol.has(lowerProto))) {
397
+ rest = rest.slice(2);
398
+ this.slashes = true;
399
+ }
400
+ }
401
+
402
+ if (!hostlessProtocol.has(lowerProto) &&
403
+ (slashes || (proto && !slashedProtocol.has(proto)))) {
404
+
405
+ // there's a hostname.
406
+ // the first instance of /, ?, ;, or # ends the host.
407
+ //
408
+ // If there is an @ in the hostname, then non-host chars *are* allowed
409
+ // to the left of the last @ sign, unless some host-ending character
410
+ // comes *before* the @-sign.
411
+ // URLs are obnoxious.
412
+ //
413
+ // ex:
414
+ // http://a@b@c/ => user:a@b host:c
415
+ // http://a@b?@c => user:a host:b path:/?@c
416
+
417
+ let hostEnd = -1;
418
+ let atSign = -1;
419
+ let nonHost = -1;
420
+ for (let i = 0; i < rest.length; ++i) {
421
+ switch (rest.charCodeAt(i)) {
422
+ case CHAR_TAB:
423
+ case CHAR_LINE_FEED:
424
+ case CHAR_CARRIAGE_RETURN:
425
+ // WHATWG URL removes tabs, newlines, and carriage returns. Let's do that too.
426
+ rest = rest.slice(0, i) + rest.slice(i + 1);
427
+ i -= 1;
428
+ break;
429
+ case CHAR_SPACE:
430
+ case CHAR_DOUBLE_QUOTE:
431
+ case CHAR_PERCENT:
432
+ case CHAR_SINGLE_QUOTE:
433
+ case CHAR_SEMICOLON:
434
+ case CHAR_LEFT_ANGLE_BRACKET:
435
+ case CHAR_RIGHT_ANGLE_BRACKET:
436
+ case CHAR_BACKWARD_SLASH:
437
+ case CHAR_CIRCUMFLEX_ACCENT:
438
+ case CHAR_GRAVE_ACCENT:
439
+ case CHAR_LEFT_CURLY_BRACKET:
440
+ case CHAR_VERTICAL_LINE:
441
+ case CHAR_RIGHT_CURLY_BRACKET:
442
+ // Characters that are never ever allowed in a hostname from RFC 2396
443
+ if (nonHost === -1)
444
+ nonHost = i;
445
+ break;
446
+ case CHAR_HASH:
447
+ case CHAR_FORWARD_SLASH:
448
+ case CHAR_QUESTION_MARK:
449
+ // Find the first instance of any host-ending characters
450
+ if (nonHost === -1)
451
+ nonHost = i;
452
+ hostEnd = i;
453
+ break;
454
+ case CHAR_AT:
455
+ // At this point, either we have an explicit point where the
456
+ // auth portion cannot go past, or the last @ char is the decider.
457
+ atSign = i;
458
+ nonHost = -1;
459
+ break;
460
+ }
461
+ if (hostEnd !== -1)
462
+ break;
463
+ }
464
+ start = 0;
465
+ if (atSign !== -1) {
466
+ this.auth = decodeURIComponent(rest.slice(0, atSign));
467
+ start = atSign + 1;
468
+ }
469
+ if (nonHost === -1) {
470
+ this.host = rest.slice(start);
471
+ rest = '';
472
+ } else {
473
+ this.host = rest.slice(start, nonHost);
474
+ rest = rest.slice(nonHost);
475
+ }
476
+
477
+ // pull out port.
478
+ this.parseHost();
479
+
480
+ // We've indicated that there is a hostname,
481
+ // so even if it's empty, it has to be present.
482
+ if (typeof this.hostname !== 'string')
483
+ this.hostname = '';
484
+
485
+ const hostname = this.hostname;
486
+
487
+ // If hostname begins with [ and ends with ]
488
+ // assume that it's an IPv6 address.
489
+ const ipv6Hostname = isIpv6Hostname(hostname);
490
+
491
+ // validate a little.
492
+ if (!ipv6Hostname) {
493
+ rest = getHostname(this, rest, hostname, url);
494
+ }
495
+
496
+ if (this.hostname.length > hostnameMaxLen) {
497
+ this.hostname = '';
498
+ } else {
499
+ // Hostnames are always lower case.
500
+ this.hostname = this.hostname.toLowerCase();
501
+ }
502
+
503
+ if (this.hostname !== '') {
504
+ if (ipv6Hostname) {
505
+ if (forbiddenHostCharsIpv6.test(this.hostname)) {
506
+ throw invalidUrl(url);
507
+ }
508
+ } else {
509
+ // IDNA Support: Returns a punycoded representation of "domain".
510
+ // It only converts parts of the domain name that
511
+ // have non-ASCII characters, i.e. it doesn't matter if
512
+ // you call it with a domain that already is ASCII-only.
513
+ this.hostname = toASCII(this.hostname);
514
+
515
+ // Prevent two potential routes of hostname spoofing.
516
+ // 1. If this.hostname is empty, it must have become empty due to toASCII
517
+ // since we checked this.hostname above.
518
+ // 2. If any of forbiddenHostChars appears in this.hostname, it must have
519
+ // also gotten in due to toASCII. This is since getHostname would have
520
+ // filtered them out otherwise.
521
+ // Rather than trying to correct this by moving the non-host part into
522
+ // the pathname as we've done in getHostname, throw an exception to
523
+ // convey the severity of this issue.
524
+ if (this.hostname === '' || forbiddenHostChars.test(this.hostname)) {
525
+ throw invalidUrl(url);
526
+ }
527
+ }
528
+ }
529
+
530
+ const p = this.port ? ':' + this.port : '';
531
+ const h = this.hostname || '';
532
+ this.host = h + p;
533
+
534
+ // strip [ and ] from the hostname
535
+ // the host field still retains them, though
536
+ if (ipv6Hostname) {
537
+ this.hostname = this.hostname.slice(1, -1);
538
+ if (rest[0] !== '/') {
539
+ rest = '/' + rest;
540
+ }
541
+ }
542
+ }
543
+
544
+ // Now rest is set to the post-host stuff.
545
+ // Chop off any delim chars.
546
+ if (!unsafeProtocol.has(lowerProto)) {
547
+ // First, make 100% sure that any "autoEscape" chars get
548
+ // escaped, even if encodeURIComponent doesn't think they
549
+ // need to be.
550
+ rest = autoEscapeStr(rest);
551
+ }
552
+
553
+ let questionIdx = -1;
554
+ let hashIdx = -1;
555
+ for (let i = 0; i < rest.length; ++i) {
556
+ const code = rest.charCodeAt(i);
557
+ if (code === CHAR_HASH) {
558
+ this.hash = rest.slice(i);
559
+ hashIdx = i;
560
+ break;
561
+ } else if (code === CHAR_QUESTION_MARK && questionIdx === -1) {
562
+ questionIdx = i;
563
+ }
564
+ }
565
+
566
+ if (questionIdx !== -1) {
567
+ if (hashIdx === -1) {
568
+ this.search = rest.slice(questionIdx);
569
+ this.query = rest.slice(questionIdx + 1);
570
+ } else {
571
+ this.search = rest.slice(questionIdx, hashIdx);
572
+ this.query = rest.slice(questionIdx + 1, hashIdx);
573
+ }
574
+ if (parseQueryString) {
575
+ this.query = querystring.parse(this.query);
576
+ }
577
+ } else if (parseQueryString) {
578
+ // No query string, but parseQueryString still requested
579
+ this.search = null;
580
+ this.query = { __proto__: null };
581
+ }
582
+
583
+ const useQuestionIdx =
584
+ questionIdx !== -1 && (hashIdx === -1 || questionIdx < hashIdx);
585
+ const firstIdx = useQuestionIdx ? questionIdx : hashIdx;
586
+ if (firstIdx === -1) {
587
+ if (rest.length > 0)
588
+ this.pathname = rest;
589
+ } else if (firstIdx > 0) {
590
+ this.pathname = rest.slice(0, firstIdx);
591
+ }
592
+ if (slashedProtocol.has(lowerProto) &&
593
+ this.hostname && !this.pathname) {
594
+ this.pathname = '/';
595
+ }
596
+
597
+ // To support http.request
598
+ if (this.pathname || this.search) {
599
+ const p = this.pathname || '';
600
+ const s = this.search || '';
601
+ this.path = p + s;
602
+ }
603
+
604
+ // Finally, reconstruct the href based on what has been validated.
605
+ this.href = this.format();
606
+ return this;
607
+ };
608
+
609
+ let warnInvalidPort = true;
610
+ function getHostname(self, rest, hostname, url) {
611
+ for (let i = 0; i < hostname.length; ++i) {
612
+ const code = hostname.charCodeAt(i);
613
+ const isValid = (code !== CHAR_FORWARD_SLASH &&
614
+ code !== CHAR_BACKWARD_SLASH &&
615
+ code !== CHAR_HASH &&
616
+ code !== CHAR_QUESTION_MARK &&
617
+ code !== CHAR_COLON);
618
+
619
+ if (!isValid) {
620
+ // If leftover starts with :, then it represents an invalid port.
621
+ // But url.parse() is lenient about it for now.
622
+ // Issue a warning and continue.
623
+ if (warnInvalidPort && code === CHAR_COLON) {
624
+ const detail = `The URL ${url} is invalid. Future versions of Node.js will throw an error.`;
625
+ process.emitWarning(detail, 'DeprecationWarning', 'DEP0170');
626
+ warnInvalidPort = false;
627
+ }
628
+ self.hostname = hostname.slice(0, i);
629
+ return `/${hostname.slice(i)}${rest}`;
630
+ }
631
+ }
632
+ return rest;
633
+ }
634
+
635
+ // Escaped characters. Use empty strings to fill up unused entries.
636
+ // Using Array is faster than Object/Map
637
+ const escapedCodes = [
638
+ /* 0 - 9 */ '', '', '', '', '', '', '', '', '', '%09',
639
+ /* 10 - 19 */ '%0A', '', '', '%0D', '', '', '', '', '', '',
640
+ /* 20 - 29 */ '', '', '', '', '', '', '', '', '', '',
641
+ /* 30 - 39 */ '', '', '%20', '', '%22', '', '', '', '', '%27',
642
+ /* 40 - 49 */ '', '', '', '', '', '', '', '', '', '',
643
+ /* 50 - 59 */ '', '', '', '', '', '', '', '', '', '',
644
+ /* 60 - 69 */ '%3C', '', '%3E', '', '', '', '', '', '', '',
645
+ /* 70 - 79 */ '', '', '', '', '', '', '', '', '', '',
646
+ /* 80 - 89 */ '', '', '', '', '', '', '', '', '', '',
647
+ /* 90 - 99 */ '', '', '%5C', '', '%5E', '', '%60', '', '', '',
648
+ /* 100 - 109 */ '', '', '', '', '', '', '', '', '', '',
649
+ /* 110 - 119 */ '', '', '', '', '', '', '', '', '', '',
650
+ /* 120 - 125 */ '', '', '', '%7B', '%7C', '%7D',
651
+ ];
652
+
653
+ // Automatically escape all delimiters and unwise characters from RFC 2396.
654
+ // Also escape single quotes in case of an XSS attack.
655
+ // Return the escaped string.
656
+ function autoEscapeStr(rest) {
657
+ let escaped = '';
658
+ let lastEscapedPos = 0;
659
+ for (let i = 0; i < rest.length; ++i) {
660
+ // `escaped` contains substring up to the last escaped character.
661
+ const escapedChar = escapedCodes[rest.charCodeAt(i)];
662
+ if (escapedChar) {
663
+ // Concat if there are ordinary characters in the middle.
664
+ if (i > lastEscapedPos)
665
+ escaped += rest.slice(lastEscapedPos, i);
666
+ escaped += escapedChar;
667
+ lastEscapedPos = i + 1;
668
+ }
669
+ }
670
+ if (lastEscapedPos === 0) // Nothing has been escaped.
671
+ return rest;
672
+
673
+ // There are ordinary characters at the end.
674
+ if (lastEscapedPos < rest.length)
675
+ escaped += rest.slice(lastEscapedPos);
676
+
677
+ return escaped;
678
+ }
679
+
680
+ // Format a parsed object into a url string
681
+ function urlFormat(urlObject, options) {
682
+ // Ensure it's an object, and not a string url.
683
+ // If it's an object, this is a no-op.
684
+ // this way, you can call urlParse() on strings
685
+ // to clean up potentially wonky urls.
686
+ if (typeof urlObject === 'string') {
687
+ urlObject = urlParse(urlObject);
688
+ } else if (typeof urlObject !== 'object' || urlObject === null) {
689
+ throw invalidArgType('urlObject', "one of type object or string", urlObject);
690
+ } else if (urlObject instanceof URL) {
691
+ let fragment = true;
692
+ let unicode = false;
693
+ let search = true;
694
+ let auth = true;
695
+
696
+ if (options) {
697
+ validateObject(options, 'options');
698
+
699
+ if (options.fragment != null) {
700
+ fragment = Boolean(options.fragment);
701
+ }
702
+
703
+ if (options.unicode != null) {
704
+ unicode = Boolean(options.unicode);
705
+ }
706
+
707
+ if (options.search != null) {
708
+ search = Boolean(options.search);
709
+ }
710
+
711
+ if (options.auth != null) {
712
+ auth = Boolean(options.auth);
713
+ }
714
+ }
715
+
716
+ return formatWhatwg(urlObject, fragment, unicode, search, auth);
717
+ }
718
+
719
+ return Url.prototype.format.call(urlObject);
720
+ }
721
+
722
+ // These characters do not need escaping:
723
+ // ! - . _ ~
724
+ // ' ( ) * :
725
+ // digits
726
+ // alpha (uppercase)
727
+ // alpha (lowercase)
728
+ const noEscapeAuth = new Int8Array([
729
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00 - 0x0F
730
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x10 - 0x1F
731
+ 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, // 0x20 - 0x2F
732
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, // 0x30 - 0x3F
733
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 - 0x4F
734
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 0x50 - 0x5F
735
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 - 0x6F
736
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, // 0x70 - 0x7F
737
+ ]);
738
+
739
+ Url.prototype.format = function format() {
740
+ let auth = this.auth || '';
741
+ if (auth) {
742
+ auth = encodeStr(auth, noEscapeAuth, hexTable);
743
+ auth += '@';
744
+ }
745
+
746
+ let protocol = this.protocol || '';
747
+ if (protocol && protocol.charCodeAt(protocol.length - 1) !== 58 /* : */) {
748
+ protocol += ':';
749
+ }
750
+
751
+ let pathname = this.pathname || '';
752
+ let hash = this.hash || '';
753
+ let host = '';
754
+ let query = '';
755
+
756
+ if (this.host) {
757
+ host = auth + this.host;
758
+ } else if (this.hostname) {
759
+ host = auth + (
760
+ this.hostname.indexOf(':') !== -1 && !isIpv6Hostname(this.hostname) ?
761
+ '[' + this.hostname + ']' :
762
+ this.hostname
763
+ );
764
+ if (this.port) {
765
+ host += ':' + this.port;
766
+ }
767
+ }
768
+
769
+ if (this.query !== null && typeof this.query === 'object') {
770
+ query = querystring.stringify(this.query);
771
+ }
772
+ let search = this.search || (query && ('?' + query)) || '';
773
+
774
+ if (pathname.indexOf('#') !== -1 || pathname.indexOf('?') !== -1) {
775
+ let newPathname = '';
776
+ let lastPos = 0;
777
+ const len = pathname.length;
778
+ for (let i = 0; i < len; i++) {
779
+ const code = pathname.charCodeAt(i);
780
+ if (code === CHAR_HASH || code === CHAR_QUESTION_MARK) {
781
+ if (i > lastPos) {
782
+ newPathname += pathname.slice(lastPos, i);
783
+ }
784
+ newPathname += (code === CHAR_HASH ? '%23' : '%3F');
785
+ lastPos = i + 1;
786
+ }
787
+ }
788
+ if (lastPos < len) {
789
+ newPathname += pathname.slice(lastPos);
790
+ }
791
+ pathname = newPathname;
792
+ }
793
+
794
+ // Only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
795
+ // unless they had them to begin with.
796
+ if (this.slashes || slashedProtocol.has(protocol)) {
797
+ if (this.slashes || host) {
798
+ if (pathname && pathname.charCodeAt(0) !== CHAR_FORWARD_SLASH)
799
+ pathname = '/' + pathname;
800
+ host = '//' + host;
801
+ } else if (protocol.length >= 4 &&
802
+ protocol.charCodeAt(0) === 102/* f */ &&
803
+ protocol.charCodeAt(1) === 105/* i */ &&
804
+ protocol.charCodeAt(2) === 108/* l */ &&
805
+ protocol.charCodeAt(3) === 101/* e */) {
806
+ host = '//';
807
+ }
808
+ }
809
+
810
+ // Escape '#' in search.
811
+ if (search.indexOf('#') !== -1) {
812
+ search = search.replaceAll('#', '%23');
813
+ }
814
+
815
+ if (hash && hash.charCodeAt(0) !== CHAR_HASH) {
816
+ hash = '#' + hash;
817
+ }
818
+ if (search && search.charCodeAt(0) !== CHAR_QUESTION_MARK) {
819
+ search = '?' + search;
820
+ }
821
+
822
+ return protocol + host + pathname + search + hash;
823
+ };
824
+
825
+ function urlResolve(source, relative) {
826
+ return urlParse(source, false, true).resolve(relative);
827
+ }
828
+
829
+ Url.prototype.resolve = function resolve(relative) {
830
+ return this.resolveObject(urlParse(relative, false, true)).format();
831
+ };
832
+
833
+ function urlResolveObject(source, relative) {
834
+ if (!source) return relative;
835
+ return urlParse(source, false, true).resolveObject(relative);
836
+ }
837
+
838
+ Url.prototype.resolveObject = function resolveObject(relative) {
839
+ if (typeof relative === 'string') {
840
+ const rel = new Url();
841
+ rel.parse(relative, false, true);
842
+ relative = rel;
843
+ }
844
+
845
+ const result = new Url();
846
+ Object.assign(result, this);
847
+
848
+ // Hash is always overridden, no matter what.
849
+ // even href="" will remove it.
850
+ result.hash = relative.hash;
851
+
852
+ // If the relative url is empty, then there's nothing left to do here.
853
+ if (relative.href === '') {
854
+ result.href = result.format();
855
+ return result;
856
+ }
857
+
858
+ // Hrefs like //foo/bar always cut to the protocol.
859
+ if (relative.slashes && !relative.protocol) {
860
+ // Take everything except the protocol from relative
861
+ const relativeWithoutProtocol = Object.keys(relative).reduce((acc, key) => {
862
+ if (key !== 'protocol') {
863
+ acc[key] = relative[key];
864
+ }
865
+ return acc;
866
+ }, {});
867
+ Object.assign(result, relativeWithoutProtocol);
868
+
869
+ // urlParse appends trailing / to urls like http://www.example.com
870
+ if (slashedProtocol.has(result.protocol) &&
871
+ result.hostname && !result.pathname) {
872
+ result.path = result.pathname = '/';
873
+ }
874
+
875
+ result.href = result.format();
876
+ return result;
877
+ }
878
+
879
+ if (relative.protocol && relative.protocol !== result.protocol) {
880
+ // If it's a known url protocol, then changing
881
+ // the protocol does weird things
882
+ // first, if it's not file:, then we MUST have a host,
883
+ // and if there was a path
884
+ // to begin with, then we MUST have a path.
885
+ // if it is file:, then the host is dropped,
886
+ // because that's known to be hostless.
887
+ // anything else is assumed to be absolute.
888
+ if (!slashedProtocol.has(relative.protocol)) {
889
+ Object.assign(result, relative);
890
+ result.href = result.format();
891
+ return result;
892
+ }
893
+
894
+ result.protocol = relative.protocol;
895
+ if (!relative.host &&
896
+ !/^file:?$/.test(relative.protocol) &&
897
+ !hostlessProtocol.has(relative.protocol)) {
898
+ const relPath = (relative.pathname || '').split('/');
899
+ while (relPath.length && !(relative.host = relPath.shift()));
900
+ relative.host ||= '';
901
+ relative.hostname ||= '';
902
+ if (relPath[0] !== '') relPath.unshift('');
903
+ if (relPath.length < 2) relPath.unshift('');
904
+ result.pathname = relPath.join('/');
905
+ } else {
906
+ result.pathname = relative.pathname;
907
+ }
908
+ result.search = relative.search;
909
+ result.query = relative.query;
910
+ result.host = relative.host || '';
911
+ result.auth = relative.auth;
912
+ result.hostname = relative.hostname || relative.host;
913
+ result.port = relative.port;
914
+ // To support http.request
915
+ if (result.pathname || result.search) {
916
+ const p = result.pathname || '';
917
+ const s = result.search || '';
918
+ result.path = p + s;
919
+ }
920
+ result.slashes ||= relative.slashes;
921
+ result.href = result.format();
922
+ return result;
923
+ }
924
+
925
+ const isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/');
926
+ const isRelAbs = (
927
+ relative.host || (relative.pathname && relative.pathname.charAt(0) === '/')
928
+ );
929
+ let mustEndAbs = (isRelAbs || isSourceAbs ||
930
+ (result.host && relative.pathname));
931
+ const removeAllDots = mustEndAbs;
932
+ let srcPath = (result.pathname && result.pathname.split('/')) || [];
933
+ const relPath = (relative.pathname && relative.pathname.split('/')) || [];
934
+ const noLeadingSlashes = result.protocol &&
935
+ !slashedProtocol.has(result.protocol);
936
+
937
+ // If the url is a non-slashed url, then relative
938
+ // links like ../.. should be able
939
+ // to crawl up to the hostname, as well. This is strange.
940
+ // result.protocol has already been set by now.
941
+ // Later on, put the first path part into the host field.
942
+ if (noLeadingSlashes) {
943
+ result.hostname = '';
944
+ result.port = null;
945
+ if (result.host) {
946
+ if (srcPath[0] === '') srcPath[0] = result.host;
947
+ else srcPath.unshift(result.host);
948
+ }
949
+ result.host = '';
950
+ if (relative.protocol) {
951
+ relative.hostname = null;
952
+ relative.port = null;
953
+ result.auth = null;
954
+ if (relative.host) {
955
+ if (relPath[0] === '') relPath[0] = relative.host;
956
+ else relPath.unshift(relative.host);
957
+ }
958
+ relative.host = null;
959
+ }
960
+ mustEndAbs &&= (relPath[0] === '' || srcPath[0] === '');
961
+ }
962
+
963
+ if (isRelAbs) {
964
+ // it's absolute.
965
+ if (relative.host || relative.host === '') {
966
+ if (result.host !== relative.host) result.auth = null;
967
+ result.host = relative.host;
968
+ result.port = relative.port;
969
+ }
970
+ if (relative.hostname || relative.hostname === '') {
971
+ if (result.hostname !== relative.hostname) result.auth = null;
972
+ result.hostname = relative.hostname;
973
+ }
974
+ result.search = relative.search;
975
+ result.query = relative.query;
976
+ srcPath = relPath;
977
+ // Fall through to the dot-handling below.
978
+ } else if (relPath.length) {
979
+ // it's relative
980
+ // throw away the existing file, and take the new path instead.
981
+ srcPath ||= [];
982
+ srcPath.pop();
983
+ srcPath = srcPath.concat(relPath);
984
+ result.search = relative.search;
985
+ result.query = relative.query;
986
+ } else if (relative.search !== null && relative.search !== undefined) {
987
+ // Just pull out the search.
988
+ // like href='?foo'.
989
+ // Put this after the other two cases because it simplifies the booleans
990
+ if (noLeadingSlashes) {
991
+ result.hostname = result.host = srcPath.shift();
992
+ // Occasionally the auth can get stuck only in host.
993
+ // This especially happens in cases like
994
+ // url.resolveObject('mailto:local1@domain1', 'local2@domain2')
995
+ const authInHost =
996
+ result.host && result.host.indexOf('@') > 0 && result.host.split('@');
997
+ if (authInHost) {
998
+ result.auth = authInHost.shift();
999
+ result.host = result.hostname = authInHost.shift();
1000
+ }
1001
+ }
1002
+ result.search = relative.search;
1003
+ result.query = relative.query;
1004
+ // To support http.request
1005
+ if (result.pathname !== null || result.search !== null) {
1006
+ result.path = (result.pathname ? result.pathname : '') +
1007
+ (result.search ? result.search : '');
1008
+ }
1009
+ result.href = result.format();
1010
+ return result;
1011
+ }
1012
+
1013
+ if (!srcPath.length) {
1014
+ // No path at all. All other things were already handled above.
1015
+ result.pathname = null;
1016
+ // To support http.request
1017
+ if (result.search) {
1018
+ result.path = '/' + result.search;
1019
+ } else {
1020
+ result.path = null;
1021
+ }
1022
+ result.href = result.format();
1023
+ return result;
1024
+ }
1025
+
1026
+ // If a url ENDs in . or .., then it must get a trailing slash.
1027
+ // however, if it ends in anything else non-slashy,
1028
+ // then it must NOT get a trailing slash.
1029
+ let last = srcPath[srcPath.length - 1];
1030
+ const hasTrailingSlash = (
1031
+ ((result.host || relative.host || srcPath.length > 1) &&
1032
+ (last === '.' || last === '..')) || last === '');
1033
+
1034
+ // Strip single dots, resolve double dots to parent dir
1035
+ // if the path tries to go above the root, `up` ends up > 0
1036
+ let up = 0;
1037
+ for (let i = srcPath.length - 1; i >= 0; i--) {
1038
+ last = srcPath[i];
1039
+ if (last === '.') {
1040
+ spliceOne(srcPath, i);
1041
+ } else if (last === '..') {
1042
+ spliceOne(srcPath, i);
1043
+ up++;
1044
+ } else if (up) {
1045
+ spliceOne(srcPath, i);
1046
+ up--;
1047
+ }
1048
+ }
1049
+
1050
+ // If the path is allowed to go above the root, restore leading ..s
1051
+ if (!mustEndAbs && !removeAllDots) {
1052
+ while (up--) {
1053
+ srcPath.unshift('..');
1054
+ }
1055
+ }
1056
+
1057
+ if (mustEndAbs && srcPath[0] !== '' &&
1058
+ (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
1059
+ srcPath.unshift('');
1060
+ }
1061
+
1062
+ if (hasTrailingSlash && srcPath.join('/').at(-1) !== '/') {
1063
+ srcPath.push('');
1064
+ }
1065
+
1066
+ const isAbsolute = srcPath[0] === '' ||
1067
+ (srcPath[0] && srcPath[0].charAt(0) === '/');
1068
+
1069
+ // put the host back
1070
+ if (noLeadingSlashes) {
1071
+ result.hostname =
1072
+ result.host = isAbsolute ? '' : srcPath.length ? srcPath.shift() : '';
1073
+ // Occasionally the auth can get stuck only in host.
1074
+ // This especially happens in cases like
1075
+ // url.resolveObject('mailto:local1@domain1', 'local2@domain2')
1076
+ const authInHost = result.host && result.host.indexOf('@') > 0 ?
1077
+ result.host.split('@') : false;
1078
+ if (authInHost) {
1079
+ result.auth = authInHost.shift();
1080
+ result.host = result.hostname = authInHost.shift();
1081
+ }
1082
+ }
1083
+
1084
+ mustEndAbs ||= (result.host && srcPath.length);
1085
+
1086
+ if (mustEndAbs && !isAbsolute) {
1087
+ srcPath.unshift('');
1088
+ }
1089
+
1090
+ if (!srcPath.length) {
1091
+ result.pathname = null;
1092
+ result.path = null;
1093
+ } else {
1094
+ result.pathname = srcPath.join('/');
1095
+ }
1096
+
1097
+ // To support request.http
1098
+ if (result.pathname !== null || result.search !== null) {
1099
+ result.path = (result.pathname ? result.pathname : '') +
1100
+ (result.search ? result.search : '');
1101
+ }
1102
+ result.auth = relative.auth || result.auth;
1103
+ result.slashes ||= relative.slashes;
1104
+ result.href = result.format();
1105
+ return result;
1106
+ };
1107
+
1108
+ Url.prototype.parseHost = function parseHost() {
1109
+ let host = this.host;
1110
+ let port = portPattern.exec(host);
1111
+ if (port) {
1112
+ port = port[0];
1113
+ if (port !== ':') {
1114
+ this.port = port.slice(1);
1115
+ }
1116
+ host = host.slice(0, host.length - port.length);
1117
+ }
1118
+ if (host) this.hostname = host;
1119
+ };
1120
+
1121
+ export {
1122
+ // Original API
1123
+ Url,
1124
+ urlParse as parse,
1125
+ urlResolve as resolve,
1126
+ urlResolveObject as resolveObject,
1127
+ urlFormat as format,
1128
+
1129
+ // WHATWG API
1130
+ URL,
1131
+ URLSearchParams,
1132
+ domainToASCII,
1133
+ domainToUnicode,
1134
+
1135
+ // Utilities
1136
+ pathToFileURL,
1137
+ fileURLToPath,
1138
+ fileURLToPathBuffer,
1139
+ urlToHttpOptions,
1140
+ };
1141
+
1142
+ export default {
1143
+ Url,
1144
+ parse: urlParse,
1145
+ resolve: urlResolve,
1146
+ resolveObject: urlResolveObject,
1147
+ format: urlFormat,
1148
+ URL,
1149
+ URLSearchParams,
1150
+ domainToASCII,
1151
+ domainToUnicode,
1152
+ pathToFileURL,
1153
+ fileURLToPath,
1154
+ fileURLToPathBuffer,
1155
+ urlToHttpOptions,
1156
+ };