@capsule-run/sdk 0.8.4 → 0.8.6

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 (333) hide show
  1. package/dist/polyfills/fs.d.ts.map +1 -1
  2. package/dist/polyfills/fs.js +4 -3
  3. package/dist/polyfills/fs.js.map +1 -1
  4. package/dist/polyfills/process.d.ts.map +1 -1
  5. package/dist/polyfills/process.js +10 -8
  6. package/dist/polyfills/process.js.map +1 -1
  7. package/dist/polyfills/unenv-runtime/_internal/types.d.mts +5 -0
  8. package/dist/polyfills/unenv-runtime/_internal/types.mjs +1 -0
  9. package/dist/polyfills/unenv-runtime/_internal/utils.d.mts +14 -0
  10. package/dist/polyfills/unenv-runtime/_internal/utils.mjs +49 -0
  11. package/dist/polyfills/unenv-runtime/mock/empty.d.mts +2 -0
  12. package/dist/polyfills/unenv-runtime/mock/empty.mjs +1 -0
  13. package/dist/polyfills/unenv-runtime/mock/noop.d.mts +2 -0
  14. package/dist/polyfills/unenv-runtime/mock/noop.mjs +1 -0
  15. package/dist/polyfills/unenv-runtime/mock/proxy.d.mts +2 -0
  16. package/dist/polyfills/unenv-runtime/mock/proxy.mjs +43 -0
  17. package/dist/polyfills/unenv-runtime/node/assert/strict.d.mts +4 -0
  18. package/dist/polyfills/unenv-runtime/node/assert/strict.mjs +25 -0
  19. package/dist/polyfills/unenv-runtime/node/assert.d.mts +165 -0
  20. package/dist/polyfills/unenv-runtime/node/assert.mjs +737 -0
  21. package/dist/polyfills/unenv-runtime/node/async_hooks.d.mts +5 -0
  22. package/dist/polyfills/unenv-runtime/node/async_hooks.mjs +15 -0
  23. package/dist/polyfills/unenv-runtime/node/buffer.d.mts +19 -0
  24. package/dist/polyfills/unenv-runtime/node/buffer.mjs +35 -0
  25. package/dist/polyfills/unenv-runtime/node/child_process.d.mts +12 -0
  26. package/dist/polyfills/unenv-runtime/node/child_process.mjs +21 -0
  27. package/dist/polyfills/unenv-runtime/node/cluster.d.mts +33 -0
  28. package/dist/polyfills/unenv-runtime/node/cluster.mjs +71 -0
  29. package/dist/polyfills/unenv-runtime/node/console.d.mts +38 -0
  30. package/dist/polyfills/unenv-runtime/node/console.mjs +74 -0
  31. package/dist/polyfills/unenv-runtime/node/constants.d.mts +13 -0
  32. package/dist/polyfills/unenv-runtime/node/constants.mjs +254 -0
  33. package/dist/polyfills/unenv-runtime/node/crypto.d.mts +6 -0
  34. package/dist/polyfills/unenv-runtime/node/crypto.mjs +138 -0
  35. package/dist/polyfills/unenv-runtime/node/dgram.d.mts +6 -0
  36. package/dist/polyfills/unenv-runtime/node/dgram.mjs +12 -0
  37. package/dist/polyfills/unenv-runtime/node/diagnostics_channel.d.mts +11 -0
  38. package/dist/polyfills/unenv-runtime/node/diagnostics_channel.mjs +34 -0
  39. package/dist/polyfills/unenv-runtime/node/dns/promises.d.mts +27 -0
  40. package/dist/polyfills/unenv-runtime/node/dns/promises.mjs +75 -0
  41. package/dist/polyfills/unenv-runtime/node/dns.d.mts +29 -0
  42. package/dist/polyfills/unenv-runtime/node/dns.mjs +81 -0
  43. package/dist/polyfills/unenv-runtime/node/domain.d.mts +8 -0
  44. package/dist/polyfills/unenv-runtime/node/domain.mjs +16 -0
  45. package/dist/polyfills/unenv-runtime/node/events.d.mts +13 -0
  46. package/dist/polyfills/unenv-runtime/node/events.mjs +12 -0
  47. package/dist/polyfills/unenv-runtime/node/fs/promises.d.mts +7 -0
  48. package/dist/polyfills/unenv-runtime/node/fs/promises.mjs +38 -0
  49. package/dist/polyfills/unenv-runtime/node/fs.d.mts +10 -0
  50. package/dist/polyfills/unenv-runtime/node/fs.mjs +117 -0
  51. package/dist/polyfills/unenv-runtime/node/http.d.mts +23 -0
  52. package/dist/polyfills/unenv-runtime/node/http.mjs +45 -0
  53. package/dist/polyfills/unenv-runtime/node/http2.d.mts +15 -0
  54. package/dist/polyfills/unenv-runtime/node/http2.mjs +284 -0
  55. package/dist/polyfills/unenv-runtime/node/https.d.mts +10 -0
  56. package/dist/polyfills/unenv-runtime/node/https.mjs +16 -0
  57. package/dist/polyfills/unenv-runtime/node/inspector/promises.d.mts +10 -0
  58. package/dist/polyfills/unenv-runtime/node/inspector/promises.mjs +40 -0
  59. package/dist/polyfills/unenv-runtime/node/inspector.d.mts +12 -0
  60. package/dist/polyfills/unenv-runtime/node/inspector.mjs +53 -0
  61. package/dist/polyfills/unenv-runtime/node/internal/async_hooks/async-hook.d.mts +7 -0
  62. package/dist/polyfills/unenv-runtime/node/internal/async_hooks/async-hook.mjs +115 -0
  63. package/dist/polyfills/unenv-runtime/node/internal/async_hooks/async-local-storage.d.mts +2 -0
  64. package/dist/polyfills/unenv-runtime/node/internal/async_hooks/async-local-storage.mjs +36 -0
  65. package/dist/polyfills/unenv-runtime/node/internal/async_hooks/async-resource.d.mts +2 -0
  66. package/dist/polyfills/unenv-runtime/node/internal/async_hooks/async-resource.mjs +37 -0
  67. package/dist/polyfills/unenv-runtime/node/internal/buffer/base64.d.mts +4 -0
  68. package/dist/polyfills/unenv-runtime/node/internal/buffer/base64.mjs +97 -0
  69. package/dist/polyfills/unenv-runtime/node/internal/buffer/buffer.d.mts +13 -0
  70. package/dist/polyfills/unenv-runtime/node/internal/buffer/buffer.mjs +1846 -0
  71. package/dist/polyfills/unenv-runtime/node/internal/buffer/file.d.mts +14 -0
  72. package/dist/polyfills/unenv-runtime/node/internal/buffer/file.mjs +26 -0
  73. package/dist/polyfills/unenv-runtime/node/internal/buffer/ieee754.d.mts +4 -0
  74. package/dist/polyfills/unenv-runtime/node/internal/buffer/ieee754.mjs +89 -0
  75. package/dist/polyfills/unenv-runtime/node/internal/crypto/constants.d.mts +58 -0
  76. package/dist/polyfills/unenv-runtime/node/internal/crypto/constants.mjs +58 -0
  77. package/dist/polyfills/unenv-runtime/node/internal/crypto/node.d.mts +78 -0
  78. package/dist/polyfills/unenv-runtime/node/internal/crypto/node.mjs +110 -0
  79. package/dist/polyfills/unenv-runtime/node/internal/crypto/web.d.mts +5 -0
  80. package/dist/polyfills/unenv-runtime/node/internal/crypto/web.mjs +9 -0
  81. package/dist/polyfills/unenv-runtime/node/internal/dgram/socket.d.mts +31 -0
  82. package/dist/polyfills/unenv-runtime/node/internal/dgram/socket.mjs +61 -0
  83. package/dist/polyfills/unenv-runtime/node/internal/diagnostics_channel/channel.d.mts +18 -0
  84. package/dist/polyfills/unenv-runtime/node/internal/diagnostics_channel/channel.mjs +40 -0
  85. package/dist/polyfills/unenv-runtime/node/internal/diagnostics_channel/tracing-channel.d.mts +19 -0
  86. package/dist/polyfills/unenv-runtime/node/internal/diagnostics_channel/tracing-channel.mjs +48 -0
  87. package/dist/polyfills/unenv-runtime/node/internal/dns/constants.d.mts +28 -0
  88. package/dist/polyfills/unenv-runtime/node/internal/dns/constants.mjs +28 -0
  89. package/dist/polyfills/unenv-runtime/node/internal/domain/domain.d.mts +13 -0
  90. package/dist/polyfills/unenv-runtime/node/internal/domain/domain.mjs +19 -0
  91. package/dist/polyfills/unenv-runtime/node/internal/events/events.d.mts +207 -0
  92. package/dist/polyfills/unenv-runtime/node/internal/events/events.mjs +1097 -0
  93. package/dist/polyfills/unenv-runtime/node/internal/fs/classes.d.mts +8 -0
  94. package/dist/polyfills/unenv-runtime/node/internal/fs/classes.mjs +8 -0
  95. package/dist/polyfills/unenv-runtime/node/internal/fs/constants.d.mts +59 -0
  96. package/dist/polyfills/unenv-runtime/node/internal/fs/constants.mjs +59 -0
  97. package/dist/polyfills/unenv-runtime/node/internal/fs/fs.d.mts +96 -0
  98. package/dist/polyfills/unenv-runtime/node/internal/fs/fs.mjs +106 -0
  99. package/dist/polyfills/unenv-runtime/node/internal/fs/promises.d.mts +32 -0
  100. package/dist/polyfills/unenv-runtime/node/internal/fs/promises.mjs +32 -0
  101. package/dist/polyfills/unenv-runtime/node/internal/http/agent.d.mts +14 -0
  102. package/dist/polyfills/unenv-runtime/node/internal/http/agent.mjs +16 -0
  103. package/dist/polyfills/unenv-runtime/node/internal/http/constants.d.mts +67 -0
  104. package/dist/polyfills/unenv-runtime/node/internal/http/constants.mjs +103 -0
  105. package/dist/polyfills/unenv-runtime/node/internal/http/request.d.mts +31 -0
  106. package/dist/polyfills/unenv-runtime/node/internal/http/request.mjs +53 -0
  107. package/dist/polyfills/unenv-runtime/node/internal/http/response.d.mts +42 -0
  108. package/dist/polyfills/unenv-runtime/node/internal/http/response.mjs +101 -0
  109. package/dist/polyfills/unenv-runtime/node/internal/http2/constants.d.mts +241 -0
  110. package/dist/polyfills/unenv-runtime/node/internal/http2/constants.mjs +241 -0
  111. package/dist/polyfills/unenv-runtime/node/internal/net/server.d.mts +17 -0
  112. package/dist/polyfills/unenv-runtime/node/internal/net/server.mjs +33 -0
  113. package/dist/polyfills/unenv-runtime/node/internal/net/socket.d.mts +45 -0
  114. package/dist/polyfills/unenv-runtime/node/internal/net/socket.mjs +83 -0
  115. package/dist/polyfills/unenv-runtime/node/internal/os/constants.d.mts +133 -0
  116. package/dist/polyfills/unenv-runtime/node/internal/os/constants.mjs +133 -0
  117. package/dist/polyfills/unenv-runtime/node/internal/perf_hooks/constants.d.mts +25 -0
  118. package/dist/polyfills/unenv-runtime/node/internal/perf_hooks/constants.mjs +25 -0
  119. package/dist/polyfills/unenv-runtime/node/internal/perf_hooks/histogram.d.mts +28 -0
  120. package/dist/polyfills/unenv-runtime/node/internal/perf_hooks/histogram.mjs +43 -0
  121. package/dist/polyfills/unenv-runtime/node/internal/perf_hooks/performance.d.mts +103 -0
  122. package/dist/polyfills/unenv-runtime/node/internal/perf_hooks/performance.mjs +232 -0
  123. package/dist/polyfills/unenv-runtime/node/internal/process/env.d.mts +1 -0
  124. package/dist/polyfills/unenv-runtime/node/internal/process/env.mjs +40 -0
  125. package/dist/polyfills/unenv-runtime/node/internal/process/hrtime.d.mts +2 -0
  126. package/dist/polyfills/unenv-runtime/node/internal/process/hrtime.mjs +21 -0
  127. package/dist/polyfills/unenv-runtime/node/internal/process/nexttick.d.mts +3 -0
  128. package/dist/polyfills/unenv-runtime/node/internal/process/nexttick.mjs +55 -0
  129. package/dist/polyfills/unenv-runtime/node/internal/process/node-version.d.mts +2 -0
  130. package/dist/polyfills/unenv-runtime/node/internal/process/node-version.mjs +2 -0
  131. package/dist/polyfills/unenv-runtime/node/internal/process/process.d.mts +113 -0
  132. package/dist/polyfills/unenv-runtime/node/internal/process/process.mjs +238 -0
  133. package/dist/polyfills/unenv-runtime/node/internal/punycode/punycode.d.mts +59 -0
  134. package/dist/polyfills/unenv-runtime/node/internal/punycode/punycode.mjs +410 -0
  135. package/dist/polyfills/unenv-runtime/node/internal/querystring/querystring.d.mts +11 -0
  136. package/dist/polyfills/unenv-runtime/node/internal/querystring/querystring.mjs +320 -0
  137. package/dist/polyfills/unenv-runtime/node/internal/readline/interface.d.mts +20 -0
  138. package/dist/polyfills/unenv-runtime/node/internal/readline/interface.mjs +31 -0
  139. package/dist/polyfills/unenv-runtime/node/internal/readline/promises/interface.d.mts +7 -0
  140. package/dist/polyfills/unenv-runtime/node/internal/readline/promises/interface.mjs +6 -0
  141. package/dist/polyfills/unenv-runtime/node/internal/readline/promises/readline.d.mts +10 -0
  142. package/dist/polyfills/unenv-runtime/node/internal/readline/promises/readline.mjs +20 -0
  143. package/dist/polyfills/unenv-runtime/node/internal/stream/duplex.d.mts +3 -0
  144. package/dist/polyfills/unenv-runtime/node/internal/stream/duplex.mjs +19 -0
  145. package/dist/polyfills/unenv-runtime/node/internal/stream/readable.d.mts +67 -0
  146. package/dist/polyfills/unenv-runtime/node/internal/stream/readable.mjs +112 -0
  147. package/dist/polyfills/unenv-runtime/node/internal/stream/transform.d.mts +10 -0
  148. package/dist/polyfills/unenv-runtime/node/internal/stream/transform.mjs +9 -0
  149. package/dist/polyfills/unenv-runtime/node/internal/stream/writable.d.mts +2 -0
  150. package/dist/polyfills/unenv-runtime/node/internal/stream/writable.mjs +87 -0
  151. package/dist/polyfills/unenv-runtime/node/internal/timers/immediate.d.mts +9 -0
  152. package/dist/polyfills/unenv-runtime/node/internal/timers/immediate.mjs +28 -0
  153. package/dist/polyfills/unenv-runtime/node/internal/timers/scheduler.d.mts +6 -0
  154. package/dist/polyfills/unenv-runtime/node/internal/timers/scheduler.mjs +10 -0
  155. package/dist/polyfills/unenv-runtime/node/internal/timers/set-immediate.d.mts +3 -0
  156. package/dist/polyfills/unenv-runtime/node/internal/timers/set-immediate.mjs +13 -0
  157. package/dist/polyfills/unenv-runtime/node/internal/timers/set-interval.d.mts +2 -0
  158. package/dist/polyfills/unenv-runtime/node/internal/timers/set-interval.mjs +8 -0
  159. package/dist/polyfills/unenv-runtime/node/internal/timers/set-timeout.d.mts +3 -0
  160. package/dist/polyfills/unenv-runtime/node/internal/timers/set-timeout.mjs +11 -0
  161. package/dist/polyfills/unenv-runtime/node/internal/timers/timeout.d.mts +11 -0
  162. package/dist/polyfills/unenv-runtime/node/internal/timers/timeout.mjs +30 -0
  163. package/dist/polyfills/unenv-runtime/node/internal/tls/constants.d.mts +7 -0
  164. package/dist/polyfills/unenv-runtime/node/internal/tls/constants.mjs +7 -0
  165. package/dist/polyfills/unenv-runtime/node/internal/tls/secure-context.d.mts +4 -0
  166. package/dist/polyfills/unenv-runtime/node/internal/tls/secure-context.mjs +3 -0
  167. package/dist/polyfills/unenv-runtime/node/internal/tls/server.d.mts +9 -0
  168. package/dist/polyfills/unenv-runtime/node/internal/tls/server.mjs +15 -0
  169. package/dist/polyfills/unenv-runtime/node/internal/tls/tls-socket.d.mts +31 -0
  170. package/dist/polyfills/unenv-runtime/node/internal/tls/tls-socket.mjs +48 -0
  171. package/dist/polyfills/unenv-runtime/node/internal/trace_events/tracing.d.mts +7 -0
  172. package/dist/polyfills/unenv-runtime/node/internal/trace_events/tracing.mjs +10 -0
  173. package/dist/polyfills/unenv-runtime/node/internal/tty/read-stream.d.mts +8 -0
  174. package/dist/polyfills/unenv-runtime/node/internal/tty/read-stream.mjs +12 -0
  175. package/dist/polyfills/unenv-runtime/node/internal/tty/write-stream.d.mts +20 -0
  176. package/dist/polyfills/unenv-runtime/node/internal/tty/write-stream.mjs +44 -0
  177. package/dist/polyfills/unenv-runtime/node/internal/url/constants.d.mts +44 -0
  178. package/dist/polyfills/unenv-runtime/node/internal/url/constants.mjs +44 -0
  179. package/dist/polyfills/unenv-runtime/node/internal/url/errors.d.mts +26 -0
  180. package/dist/polyfills/unenv-runtime/node/internal/url/errors.mjs +54 -0
  181. package/dist/polyfills/unenv-runtime/node/internal/url/url.d.mts +22 -0
  182. package/dist/polyfills/unenv-runtime/node/internal/url/url.mjs +181 -0
  183. package/dist/polyfills/unenv-runtime/node/internal/url/util.d.mts +4 -0
  184. package/dist/polyfills/unenv-runtime/node/internal/url/util.mjs +7 -0
  185. package/dist/polyfills/unenv-runtime/node/internal/util/inherits.d.mts +1 -0
  186. package/dist/polyfills/unenv-runtime/node/internal/util/inherits.mjs +12 -0
  187. package/dist/polyfills/unenv-runtime/node/internal/util/legacy-types.d.mts +19 -0
  188. package/dist/polyfills/unenv-runtime/node/internal/util/legacy-types.mjs +25 -0
  189. package/dist/polyfills/unenv-runtime/node/internal/util/log.d.mts +8 -0
  190. package/dist/polyfills/unenv-runtime/node/internal/util/log.mjs +55 -0
  191. package/dist/polyfills/unenv-runtime/node/internal/util/mime.d.mts +19 -0
  192. package/dist/polyfills/unenv-runtime/node/internal/util/mime.mjs +35 -0
  193. package/dist/polyfills/unenv-runtime/node/internal/util/promisify.d.mts +3 -0
  194. package/dist/polyfills/unenv-runtime/node/internal/util/promisify.mjs +23 -0
  195. package/dist/polyfills/unenv-runtime/node/internal/util/types.d.mts +45 -0
  196. package/dist/polyfills/unenv-runtime/node/internal/util/types.mjs +45 -0
  197. package/dist/polyfills/unenv-runtime/node/internal/v8/deserializer.d.mts +12 -0
  198. package/dist/polyfills/unenv-runtime/node/internal/v8/deserializer.mjs +23 -0
  199. package/dist/polyfills/unenv-runtime/node/internal/v8/profiler.d.mts +10 -0
  200. package/dist/polyfills/unenv-runtime/node/internal/v8/profiler.mjs +11 -0
  201. package/dist/polyfills/unenv-runtime/node/internal/v8/serializer.d.mts +12 -0
  202. package/dist/polyfills/unenv-runtime/node/internal/v8/serializer.mjs +15 -0
  203. package/dist/polyfills/unenv-runtime/node/internal/vm/constants.d.mts +2 -0
  204. package/dist/polyfills/unenv-runtime/node/internal/vm/constants.mjs +2 -0
  205. package/dist/polyfills/unenv-runtime/node/internal/vm/script.d.mts +7 -0
  206. package/dist/polyfills/unenv-runtime/node/internal/vm/script.mjs +15 -0
  207. package/dist/polyfills/unenv-runtime/node/internal/worker_threads/broadcast-channel.d.mts +10 -0
  208. package/dist/polyfills/unenv-runtime/node/internal/worker_threads/broadcast-channel.mjs +13 -0
  209. package/dist/polyfills/unenv-runtime/node/internal/worker_threads/message-channel.d.mts +5 -0
  210. package/dist/polyfills/unenv-runtime/node/internal/worker_threads/message-channel.mjs +5 -0
  211. package/dist/polyfills/unenv-runtime/node/internal/worker_threads/message-port.d.mts +12 -0
  212. package/dist/polyfills/unenv-runtime/node/internal/worker_threads/message-port.mjs +17 -0
  213. package/dist/polyfills/unenv-runtime/node/internal/worker_threads/worker.d.mts +21 -0
  214. package/dist/polyfills/unenv-runtime/node/internal/worker_threads/worker.mjs +25 -0
  215. package/dist/polyfills/unenv-runtime/node/internal/zlib/codes.d.mts +21 -0
  216. package/dist/polyfills/unenv-runtime/node/internal/zlib/codes.mjs +21 -0
  217. package/dist/polyfills/unenv-runtime/node/internal/zlib/constants.d.mts +108 -0
  218. package/dist/polyfills/unenv-runtime/node/internal/zlib/constants.mjs +108 -0
  219. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/_shared.d.mts +22 -0
  220. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/_shared.mjs +40 -0
  221. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/brotli.d.mts +16 -0
  222. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/brotli.mjs +16 -0
  223. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/deflate.d.mts +29 -0
  224. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/deflate.mjs +36 -0
  225. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/gzip.d.mts +16 -0
  226. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/gzip.mjs +16 -0
  227. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/zip.d.mts +9 -0
  228. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/zip.mjs +9 -0
  229. package/dist/polyfills/unenv-runtime/node/module.d.mts +54 -0
  230. package/dist/polyfills/unenv-runtime/node/module.mjs +191 -0
  231. package/dist/polyfills/unenv-runtime/node/net.d.mts +22 -0
  232. package/dist/polyfills/unenv-runtime/node/net.mjs +52 -0
  233. package/dist/polyfills/unenv-runtime/node/os.d.mts +26 -0
  234. package/dist/polyfills/unenv-runtime/node/os.mjs +118 -0
  235. package/dist/polyfills/unenv-runtime/node/path/posix.d.mts +2 -0
  236. package/dist/polyfills/unenv-runtime/node/path/posix.mjs +2 -0
  237. package/dist/polyfills/unenv-runtime/node/path/win32.d.mts +2 -0
  238. package/dist/polyfills/unenv-runtime/node/path/win32.mjs +2 -0
  239. package/dist/polyfills/unenv-runtime/node/path.d.mts +12 -0
  240. package/dist/polyfills/unenv-runtime/node/path.mjs +31 -0
  241. package/dist/polyfills/unenv-runtime/node/perf_hooks.d.mts +8 -0
  242. package/dist/polyfills/unenv-runtime/node/perf_hooks.mjs +51 -0
  243. package/dist/polyfills/unenv-runtime/node/process.d.mts +3 -0
  244. package/dist/polyfills/unenv-runtime/node/process.mjs +12 -0
  245. package/dist/polyfills/unenv-runtime/node/punycode.d.mts +3 -0
  246. package/dist/polyfills/unenv-runtime/node/punycode.mjs +3 -0
  247. package/dist/polyfills/unenv-runtime/node/querystring.d.mts +49 -0
  248. package/dist/polyfills/unenv-runtime/node/querystring.mjs +766 -0
  249. package/dist/polyfills/unenv-runtime/node/readline/promises.d.mts +6 -0
  250. package/dist/polyfills/unenv-runtime/node/readline/promises.mjs +10 -0
  251. package/dist/polyfills/unenv-runtime/node/readline.d.mts +13 -0
  252. package/dist/polyfills/unenv-runtime/node/readline.mjs +21 -0
  253. package/dist/polyfills/unenv-runtime/node/repl.d.mts +10 -0
  254. package/dist/polyfills/unenv-runtime/node/repl.mjs +20 -0
  255. package/dist/polyfills/unenv-runtime/node/sqlite.d.mts +6 -0
  256. package/dist/polyfills/unenv-runtime/node/sqlite.mjs +9 -0
  257. package/dist/polyfills/unenv-runtime/node/stream/consumers.d.mts +7 -0
  258. package/dist/polyfills/unenv-runtime/node/stream/consumers.mjs +13 -0
  259. package/dist/polyfills/unenv-runtime/node/stream/promises.d.mts +4 -0
  260. package/dist/polyfills/unenv-runtime/node/stream/promises.mjs +7 -0
  261. package/dist/polyfills/unenv-runtime/node/stream/web.d.mts +24 -0
  262. package/dist/polyfills/unenv-runtime/node/stream/web.mjs +41 -0
  263. package/dist/polyfills/unenv-runtime/node/stream.d.mts +42 -0
  264. package/dist/polyfills/unenv-runtime/node/stream.mjs +54 -0
  265. package/dist/polyfills/unenv-runtime/node/string_decoder.d.mts +5 -0
  266. package/dist/polyfills/unenv-runtime/node/string_decoder.mjs +3 -0
  267. package/dist/polyfills/unenv-runtime/node/sys.d.mts +2 -0
  268. package/dist/polyfills/unenv-runtime/node/sys.mjs +2 -0
  269. package/dist/polyfills/unenv-runtime/node/timers/promises.d.mts +6 -0
  270. package/dist/polyfills/unenv-runtime/node/timers/promises.mjs +14 -0
  271. package/dist/polyfills/unenv-runtime/node/timers.d.mts +15 -0
  272. package/dist/polyfills/unenv-runtime/node/timers.mjs +32 -0
  273. package/dist/polyfills/unenv-runtime/node/tls.d.mts +15 -0
  274. package/dist/polyfills/unenv-runtime/node/tls.mjs +41 -0
  275. package/dist/polyfills/unenv-runtime/node/trace_events.d.mts +5 -0
  276. package/dist/polyfills/unenv-runtime/node/trace_events.mjs +9 -0
  277. package/dist/polyfills/unenv-runtime/node/tty.d.mts +9 -0
  278. package/dist/polyfills/unenv-runtime/node/tty.mjs +12 -0
  279. package/dist/polyfills/unenv-runtime/node/url.d.mts +61 -0
  280. package/dist/polyfills/unenv-runtime/node/url.mjs +1044 -0
  281. package/dist/polyfills/unenv-runtime/node/util/types.d.mts +3 -0
  282. package/dist/polyfills/unenv-runtime/node/util/types.mjs +3 -0
  283. package/dist/polyfills/unenv-runtime/node/util.d.mts +32 -0
  284. package/dist/polyfills/unenv-runtime/node/util.mjs +84 -0
  285. package/dist/polyfills/unenv-runtime/node/v8.d.mts +29 -0
  286. package/dist/polyfills/unenv-runtime/node/v8.mjs +108 -0
  287. package/dist/polyfills/unenv-runtime/node/vm.d.mts +15 -0
  288. package/dist/polyfills/unenv-runtime/node/vm.mjs +41 -0
  289. package/dist/polyfills/unenv-runtime/node/wasi.d.mts +4 -0
  290. package/dist/polyfills/unenv-runtime/node/wasi.mjs +3 -0
  291. package/dist/polyfills/unenv-runtime/node/worker_threads.d.mts +23 -0
  292. package/dist/polyfills/unenv-runtime/node/worker_threads.mjs +55 -0
  293. package/dist/polyfills/unenv-runtime/node/zlib.d.mts +16 -0
  294. package/dist/polyfills/unenv-runtime/node/zlib.mjs +212 -0
  295. package/dist/polyfills/unenv-runtime/npm/cross-fetch.d.mts +6 -0
  296. package/dist/polyfills/unenv-runtime/npm/cross-fetch.mjs +6 -0
  297. package/dist/polyfills/unenv-runtime/npm/debug.d.mts +15 -0
  298. package/dist/polyfills/unenv-runtime/npm/debug.mjs +43 -0
  299. package/dist/polyfills/unenv-runtime/npm/fsevents.d.mts +16 -0
  300. package/dist/polyfills/unenv-runtime/npm/fsevents.mjs +20 -0
  301. package/dist/polyfills/unenv-runtime/npm/inherits.d.mts +2 -0
  302. package/dist/polyfills/unenv-runtime/npm/inherits.mjs +2 -0
  303. package/dist/polyfills/unenv-runtime/npm/node-fetch.d.mts +12 -0
  304. package/dist/polyfills/unenv-runtime/npm/node-fetch.mjs +23 -0
  305. package/dist/polyfills/unenv-runtime/npm/whatwg-url/index.d.mts +13 -0
  306. package/dist/polyfills/unenv-runtime/npm/whatwg-url/index.mjs +15 -0
  307. package/dist/polyfills/unenv-runtime/npm/whatwg-url/webidl2js-wrapper.d.mts +2 -0
  308. package/dist/polyfills/unenv-runtime/npm/whatwg-url/webidl2js-wrapper.mjs +2 -0
  309. package/dist/polyfills/unenv-runtime/polyfill/buffer.d.mts +1 -0
  310. package/dist/polyfills/unenv-runtime/polyfill/buffer.mjs +4 -0
  311. package/dist/polyfills/unenv-runtime/polyfill/globalthis-global.d.mts +1 -0
  312. package/dist/polyfills/unenv-runtime/polyfill/globalthis-global.mjs +5 -0
  313. package/dist/polyfills/unenv-runtime/polyfill/globalthis.d.mts +2 -0
  314. package/dist/polyfills/unenv-runtime/polyfill/globalthis.mjs +2 -0
  315. package/dist/polyfills/unenv-runtime/polyfill/package.json +3 -0
  316. package/dist/polyfills/unenv-runtime/polyfill/performance.d.mts +2 -0
  317. package/dist/polyfills/unenv-runtime/polyfill/performance.mjs +10 -0
  318. package/dist/polyfills/unenv-runtime/polyfill/process.d.mts +2 -0
  319. package/dist/polyfills/unenv-runtime/polyfill/process.mjs +10 -0
  320. package/dist/polyfills/unenv-runtime/polyfill/source-maps.mjs +15 -0
  321. package/dist/polyfills/unenv-runtime/polyfill/timers.d.mts +1 -0
  322. package/dist/polyfills/unenv-runtime/polyfill/timers.mjs +7 -0
  323. package/dist/polyfills/unenv-runtime/web/performance/_polyfills.d.mts +100 -0
  324. package/dist/polyfills/unenv-runtime/web/performance/_polyfills.mjs +184 -0
  325. package/dist/polyfills/unenv-runtime/web/performance/index.d.mts +12 -0
  326. package/dist/polyfills/unenv-runtime/web/performance/index.mjs +14 -0
  327. package/dist/run.d.ts.map +1 -1
  328. package/dist/run.js +39 -10
  329. package/dist/run.js.map +1 -1
  330. package/package.json +2 -2
  331. package/src/polyfills/fs.ts +5 -3
  332. package/src/polyfills/process.ts +10 -8
  333. package/src/run.ts +41 -11
@@ -0,0 +1,1044 @@
1
+ import * as querystring from "node:querystring";
2
+ import * as punnycode from "./punycode.mjs";
3
+ import { encodeStr, hexTable } from "./internal/querystring/querystring.mjs";
4
+ import { spliceOne } from "./internal/url/util.mjs";
5
+ import { ERR_INVALID_ARG_TYPE, ERR_INVALID_URL } from "./internal/url/errors.mjs";
6
+ import { pathToFileURL as _pathToFileURL, fileURLToPath, unsafeProtocol, hostlessProtocol, slashedProtocol, urlToHttpOptions } from "./internal/url/url.mjs";
7
+ import { CHAR_SPACE, CHAR_TAB, CHAR_CARRIAGE_RETURN, CHAR_LINE_FEED, CHAR_NO_BREAK_SPACE, CHAR_ZERO_WIDTH_NOBREAK_SPACE, CHAR_HASH, CHAR_FORWARD_SLASH, CHAR_LEFT_SQUARE_BRACKET, CHAR_RIGHT_SQUARE_BRACKET, CHAR_LEFT_ANGLE_BRACKET, CHAR_RIGHT_ANGLE_BRACKET, CHAR_LEFT_CURLY_BRACKET, CHAR_RIGHT_CURLY_BRACKET, CHAR_QUESTION_MARK, CHAR_DOUBLE_QUOTE, CHAR_SINGLE_QUOTE, CHAR_PERCENT, CHAR_SEMICOLON, CHAR_BACKWARD_SLASH, CHAR_CIRCUMFLEX_ACCENT, CHAR_GRAVE_ACCENT, CHAR_VERTICAL_LINE, CHAR_AT, CHAR_COLON } from "./internal/url/constants.mjs";
8
+ class Url {
9
+ auth = null;
10
+ hash = null;
11
+ host = null;
12
+ hostname = null;
13
+ href = null;
14
+ path = null;
15
+ pathname = null;
16
+ protocol = null;
17
+ search = null;
18
+ slashes = null;
19
+ port = null;
20
+ query = null;
21
+ parse(url, parseQueryString, slashesDenoteHost) {
22
+ // validateString(url, "url");
23
+ if (typeof url !== "string") {
24
+ throw new ERR_INVALID_ARG_TYPE("url", "string", url);
25
+ }
26
+ // Copy chrome, IE, opera backslash-handling behavior.
27
+ // Back slashes before the query string get converted to forward slashes
28
+ // See: https://code.google.com/p/chromium/issues/detail?id=25916
29
+ let hasHash = false;
30
+ let hasAt = false;
31
+ let start = -1;
32
+ let end = -1;
33
+ let rest = "";
34
+ let lastPos = 0;
35
+ for (let i = 0, inWs = false, split = false; i < url.length; ++i) {
36
+ const code = url.charCodeAt(i);
37
+ // Find first and last non-whitespace characters for trimming
38
+ const isWs = code < 33 || code === CHAR_NO_BREAK_SPACE || code === CHAR_ZERO_WIDTH_NOBREAK_SPACE;
39
+ if (start === -1) {
40
+ if (isWs) continue;
41
+ lastPos = start = i;
42
+ } else if (inWs) {
43
+ if (!isWs) {
44
+ end = -1;
45
+ inWs = false;
46
+ }
47
+ } else if (isWs) {
48
+ end = i;
49
+ inWs = true;
50
+ }
51
+ // Only convert backslashes while we haven't seen a split character
52
+ if (!split) {
53
+ switch (code) {
54
+ case CHAR_AT:
55
+ hasAt = true;
56
+ break;
57
+ case CHAR_HASH: hasHash = true;
58
+ case CHAR_QUESTION_MARK:
59
+ split = true;
60
+ break;
61
+ case CHAR_BACKWARD_SLASH:
62
+ if (i - lastPos > 0) rest += url.slice(lastPos, i);
63
+ rest += "/";
64
+ lastPos = i + 1;
65
+ break;
66
+ }
67
+ } else if (!hasHash && code === CHAR_HASH) {
68
+ hasHash = true;
69
+ }
70
+ }
71
+ // Check if string was non-empty (including strings with only whitespace)
72
+ if (start !== -1) {
73
+ if (lastPos === start) {
74
+ // We didn't convert any backslashes
75
+ if (end === -1) {
76
+ if (start === 0) rest = url;
77
+ else rest = url.slice(start);
78
+ } else {
79
+ rest = url.slice(start, end);
80
+ }
81
+ } else if (end === -1 && lastPos < url.length) {
82
+ // We converted some backslashes and have only part of the entire string
83
+ rest += url.slice(lastPos);
84
+ } else if (end !== -1 && lastPos < end) {
85
+ // We converted some backslashes and have only part of the entire string
86
+ rest += url.slice(lastPos, end);
87
+ }
88
+ }
89
+ if (!slashesDenoteHost && !hasHash && !hasAt) {
90
+ // Try fast path regexp
91
+ const simplePath = simplePathPattern.exec(rest);
92
+ if (simplePath) {
93
+ this.path = rest;
94
+ this.href = rest;
95
+ this.pathname = simplePath[1];
96
+ if (simplePath[2]) {
97
+ this.search = simplePath[2];
98
+ if (parseQueryString) {
99
+ this.query = querystring.parse(this.search.slice(1));
100
+ } else {
101
+ this.query = this.search.slice(1);
102
+ }
103
+ } else if (parseQueryString) {
104
+ this.search = null;
105
+ // @ts-expect-error
106
+ this.query = { __proto__: null };
107
+ }
108
+ return this;
109
+ }
110
+ }
111
+ const protoMatch = protocolPattern.exec(rest);
112
+ let proto, lowerProto;
113
+ if (protoMatch) {
114
+ proto = protoMatch[0];
115
+ lowerProto = proto.toLowerCase();
116
+ this.protocol = lowerProto;
117
+ rest = rest.slice(proto.length);
118
+ }
119
+ // Figure out if it's got a host
120
+ // user@server is *always* interpreted as a hostname, and url
121
+ // resolution will treat //foo/bar as host=foo,path=bar because that's
122
+ // how the browser resolves relative URLs.
123
+ let slashes;
124
+ if (slashesDenoteHost || proto || hostPattern.test(rest)) {
125
+ slashes = rest.charCodeAt(0) === CHAR_FORWARD_SLASH && rest.charCodeAt(1) === CHAR_FORWARD_SLASH;
126
+ if (slashes && !(proto && hostlessProtocol.has(lowerProto))) {
127
+ rest = rest.slice(2);
128
+ this.slashes = true;
129
+ }
130
+ }
131
+ if (!hostlessProtocol.has(lowerProto) && (slashes || proto && !slashedProtocol.has(proto))) {
132
+ // there's a hostname.
133
+ // the first instance of /, ?, ;, or # ends the host.
134
+ //
135
+ // If there is an @ in the hostname, then non-host chars *are* allowed
136
+ // to the left of the last @ sign, unless some host-ending character
137
+ // comes *before* the @-sign.
138
+ // URLs are obnoxious.
139
+ //
140
+ // ex:
141
+ // http://a@b@c/ => user:a@b host:c
142
+ // http://a@b?@c => user:a host:b path:/?@c
143
+ let hostEnd = -1;
144
+ let atSign = -1;
145
+ let nonHost = -1;
146
+ for (let i = 0; i < rest.length; ++i) {
147
+ switch (rest.charCodeAt(i)) {
148
+ case CHAR_TAB:
149
+ case CHAR_LINE_FEED:
150
+ case CHAR_CARRIAGE_RETURN:
151
+ // WHATWG URL removes tabs, newlines, and carriage returns. Let's do that too.
152
+ rest = rest.slice(0, i) + rest.slice(i + 1);
153
+ i -= 1;
154
+ break;
155
+ case CHAR_SPACE:
156
+ case CHAR_DOUBLE_QUOTE:
157
+ case CHAR_PERCENT:
158
+ case CHAR_SINGLE_QUOTE:
159
+ case CHAR_SEMICOLON:
160
+ case CHAR_LEFT_ANGLE_BRACKET:
161
+ case CHAR_RIGHT_ANGLE_BRACKET:
162
+ case CHAR_BACKWARD_SLASH:
163
+ case CHAR_CIRCUMFLEX_ACCENT:
164
+ case CHAR_GRAVE_ACCENT:
165
+ case CHAR_LEFT_CURLY_BRACKET:
166
+ case CHAR_VERTICAL_LINE:
167
+ case CHAR_RIGHT_CURLY_BRACKET:
168
+ // Characters that are never ever allowed in a hostname from RFC 2396
169
+ if (nonHost === -1) nonHost = i;
170
+ break;
171
+ case CHAR_HASH:
172
+ case CHAR_FORWARD_SLASH:
173
+ case CHAR_QUESTION_MARK:
174
+ // Find the first instance of any host-ending characters
175
+ if (nonHost === -1) nonHost = i;
176
+ hostEnd = i;
177
+ break;
178
+ case CHAR_AT:
179
+ // At this point, either we have an explicit point where the
180
+ // auth portion cannot go past, or the last @ char is the decider.
181
+ atSign = i;
182
+ nonHost = -1;
183
+ break;
184
+ }
185
+ if (hostEnd !== -1) break;
186
+ }
187
+ start = 0;
188
+ if (atSign !== -1) {
189
+ this.auth = decodeURIComponent(rest.slice(0, atSign));
190
+ start = atSign + 1;
191
+ }
192
+ if (nonHost === -1) {
193
+ this.host = rest.slice(start);
194
+ rest = "";
195
+ } else {
196
+ this.host = rest.slice(start, nonHost);
197
+ rest = rest.slice(nonHost);
198
+ }
199
+ // pull out port.
200
+ this.parseHost();
201
+ // We've indicated that there is a hostname,
202
+ // so even if it's empty, it has to be present.
203
+ if (typeof this.hostname !== "string") this.hostname = "";
204
+ const hostname = this.hostname;
205
+ // If hostname begins with [ and ends with ]
206
+ // assume that it's an IPv6 address.
207
+ const ipv6Hostname = isIpv6Hostname(hostname);
208
+ // validate a little.
209
+ if (!ipv6Hostname) {
210
+ rest = getHostname(this, rest, hostname, url);
211
+ }
212
+ if (this.hostname.length > hostnameMaxLen) {
213
+ this.hostname = "";
214
+ } else {
215
+ // Hostnames are always lower case.
216
+ this.hostname = this.hostname.toLowerCase();
217
+ }
218
+ if (this.hostname !== "") {
219
+ if (ipv6Hostname) {
220
+ if (forbiddenHostCharsIpv6.test(this.hostname)) {
221
+ throw new ERR_INVALID_URL(url);
222
+ }
223
+ } else {
224
+ // IDNA Support: Returns a punycoded representation of "domain".
225
+ // It only converts parts of the domain name that
226
+ // have non-ASCII characters, i.e. it doesn't matter if
227
+ // you call it with a domain that already is ASCII-only.
228
+ this.hostname = punnycode.toASCII(this.hostname);
229
+ // Prevent two potential routes of hostname spoofing.
230
+ // 1. If this.hostname is empty, it must have become empty due to toASCII
231
+ // since we checked this.hostname above.
232
+ // 2. If any of forbiddenHostChars appears in this.hostname, it must have
233
+ // also gotten in due to toASCII. This is since getHostname would have
234
+ // filtered them out otherwise.
235
+ // Rather than trying to correct this by moving the non-host part into
236
+ // the pathname as we've done in getHostname, throw an exception to
237
+ // convey the severity of this issue.
238
+ if (this.hostname === "" || forbiddenHostChars.test(this.hostname)) {
239
+ throw new ERR_INVALID_URL(url);
240
+ }
241
+ }
242
+ }
243
+ const p = this.port ? ":" + this.port : "";
244
+ const h = this.hostname || "";
245
+ this.host = h + p;
246
+ // strip [ and ] from the hostname
247
+ // the host field still retains them, though
248
+ if (ipv6Hostname) {
249
+ this.hostname = this.hostname.slice(1, -1);
250
+ if (rest[0] !== "/") {
251
+ rest = "/" + rest;
252
+ }
253
+ }
254
+ }
255
+ // Now rest is set to the post-host stuff.
256
+ // Chop off any delim chars.
257
+ if (!unsafeProtocol.has(lowerProto)) {
258
+ // First, make 100% sure that any "autoEscape" chars get
259
+ // escaped, even if encodeURIComponent doesn't think they
260
+ // need to be.
261
+ rest = autoEscapeStr(rest);
262
+ }
263
+ let questionIdx = -1;
264
+ let hashIdx = -1;
265
+ for (let i = 0; i < rest.length; ++i) {
266
+ const code = rest.charCodeAt(i);
267
+ if (code === CHAR_HASH) {
268
+ this.hash = rest.slice(i);
269
+ hashIdx = i;
270
+ break;
271
+ } else if (code === CHAR_QUESTION_MARK && questionIdx === -1) {
272
+ questionIdx = i;
273
+ }
274
+ }
275
+ if (questionIdx !== -1) {
276
+ if (hashIdx === -1) {
277
+ this.search = rest.slice(questionIdx);
278
+ this.query = rest.slice(questionIdx + 1);
279
+ } else {
280
+ this.search = rest.slice(questionIdx, hashIdx);
281
+ this.query = rest.slice(questionIdx + 1, hashIdx);
282
+ }
283
+ if (parseQueryString) {
284
+ this.query = querystring.parse(this.query);
285
+ }
286
+ } else if (parseQueryString) {
287
+ // No query string, but parseQueryString still requested
288
+ this.search = null;
289
+ // @ts-expect-error
290
+ this.query = { __proto__: null };
291
+ }
292
+ const useQuestionIdx = questionIdx !== -1 && (hashIdx === -1 || questionIdx < hashIdx);
293
+ const firstIdx = useQuestionIdx ? questionIdx : hashIdx;
294
+ if (firstIdx === -1) {
295
+ if (rest.length > 0) this.pathname = rest;
296
+ } else if (firstIdx > 0) {
297
+ this.pathname = rest.slice(0, firstIdx);
298
+ }
299
+ if (slashedProtocol.has(lowerProto) && this.hostname && !this.pathname) {
300
+ this.pathname = "/";
301
+ }
302
+ // To support http.request
303
+ if (this.pathname || this.search) {
304
+ const p = this.pathname || "";
305
+ const s = this.search || "";
306
+ this.path = p + s;
307
+ }
308
+ // Finally, reconstruct the href based on what has been validated.
309
+ this.href = this.format();
310
+ return this;
311
+ }
312
+ format() {
313
+ let auth = this.auth || "";
314
+ if (auth) {
315
+ auth = encodeStr(auth, noEscapeAuth, hexTable);
316
+ auth += "@";
317
+ }
318
+ let protocol = this.protocol || "";
319
+ let pathname = this.pathname || "";
320
+ let hash = this.hash || "";
321
+ let host = "";
322
+ let query = "";
323
+ if (this.host) {
324
+ host = auth + this.host;
325
+ } else if (this.hostname) {
326
+ host = auth + (this.hostname.includes(":") && !isIpv6Hostname(this.hostname) ? "[" + this.hostname + "]" : this.hostname);
327
+ if (this.port) {
328
+ host += ":" + this.port;
329
+ }
330
+ }
331
+ if (this.query !== null && typeof this.query === "object") {
332
+ query = querystring.stringify(this.query);
333
+ }
334
+ let search = this.search || query && "?" + query || "";
335
+ if (protocol && protocol.charCodeAt(protocol.length - 1) !== 58) protocol += ":";
336
+ let newPathname = "";
337
+ let lastPos = 0;
338
+ for (let i = 0; i < pathname.length; ++i) {
339
+ switch (pathname.charCodeAt(i)) {
340
+ case CHAR_HASH:
341
+ if (i - lastPos > 0) newPathname += pathname.slice(lastPos, i);
342
+ newPathname += "%23";
343
+ lastPos = i + 1;
344
+ break;
345
+ case CHAR_QUESTION_MARK:
346
+ if (i - lastPos > 0) newPathname += pathname.slice(lastPos, i);
347
+ newPathname += "%3F";
348
+ lastPos = i + 1;
349
+ break;
350
+ }
351
+ }
352
+ if (lastPos > 0) {
353
+ if (lastPos === pathname.length) {
354
+ pathname = newPathname;
355
+ } else {
356
+ pathname = newPathname + pathname.slice(lastPos);
357
+ }
358
+ }
359
+ // Only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
360
+ // unless they had them to begin with.
361
+ if (this.slashes || slashedProtocol.has(protocol)) {
362
+ if (this.slashes || host) {
363
+ if (pathname && pathname.charCodeAt(0) !== CHAR_FORWARD_SLASH) pathname = "/" + pathname;
364
+ host = "//" + host;
365
+ } else if (protocol.length >= 4 && protocol.charCodeAt(0) === 102 && protocol.charCodeAt(1) === 105 && protocol.charCodeAt(2) === 108 && protocol.charCodeAt(3) === 101) {
366
+ host = "//";
367
+ }
368
+ }
369
+ search = search.replace(/#/g, "%23");
370
+ if (hash && hash.charCodeAt(0) !== CHAR_HASH) hash = "#" + hash;
371
+ if (search && search.charCodeAt(0) !== CHAR_QUESTION_MARK) search = "?" + search;
372
+ return protocol + host + pathname + search + hash;
373
+ }
374
+ resolve(relative) {
375
+ return this.resolveObject(urlParse(relative, false, true)).format();
376
+ }
377
+ resolveObject(relative) {
378
+ if (typeof relative === "string") {
379
+ const rel = new Url();
380
+ rel.parse(relative, false, true);
381
+ relative = rel;
382
+ }
383
+ const result = new Url();
384
+ Object.assign(result, this);
385
+ // Hash is always overridden, no matter what.
386
+ // even href="" will remove it.
387
+ result.hash = relative.hash;
388
+ // If the relative url is empty, then there's nothing left to do here.
389
+ if (relative.href === "") {
390
+ result.href = result.format();
391
+ return result;
392
+ }
393
+ // Hrefs like //foo/bar always cut to the protocol.
394
+ if (relative.slashes && !relative.protocol) {
395
+ // Take everything except the protocol from relative
396
+ // eslint-disable-next-line unicorn/no-array-reduce
397
+ const relativeWithoutProtocol = Object.keys(relative).reduce((acc, key) => {
398
+ if (key !== "protocol") {
399
+ acc[key] = relative[key];
400
+ }
401
+ return acc;
402
+ }, {});
403
+ Object.assign(result, relativeWithoutProtocol);
404
+ // urlParse appends trailing / to urls like http://www.example.com
405
+ if (slashedProtocol.has(result.protocol) && result.hostname && !result.pathname) {
406
+ result.path = result.pathname = "/";
407
+ }
408
+ result.href = result.format();
409
+ return result;
410
+ }
411
+ if (relative.protocol && relative.protocol !== result.protocol) {
412
+ // If it's a known url protocol, then changing
413
+ // the protocol does weird things
414
+ // first, if it's not file:, then we MUST have a host,
415
+ // and if there was a path
416
+ // to begin with, then we MUST have a path.
417
+ // if it is file:, then the host is dropped,
418
+ // because that's known to be hostless.
419
+ // anything else is assumed to be absolute.
420
+ if (!slashedProtocol.has(relative.protocol)) {
421
+ Object.assign(result, relative);
422
+ result.href = result.format();
423
+ return result;
424
+ }
425
+ result.protocol = relative.protocol;
426
+ if (!relative.host && !/^file:?$/.test(relative.protocol) && !hostlessProtocol.has(relative.protocol)) {
427
+ const relPath = (relative.pathname || "").split("/");
428
+ while (relPath.length > 0 && !(relative.host = relPath.shift()));
429
+ if (!relative.host) relative.host = "";
430
+ if (!relative.hostname) relative.hostname = "";
431
+ if (relPath[0] !== "") relPath.unshift("");
432
+ if (relPath.length < 2) relPath.unshift("");
433
+ result.pathname = relPath.join("/");
434
+ } else {
435
+ result.pathname = relative.pathname;
436
+ }
437
+ result.search = relative.search;
438
+ result.query = relative.query;
439
+ result.host = relative.host || "";
440
+ result.auth = relative.auth;
441
+ result.hostname = relative.hostname || relative.host;
442
+ result.port = relative.port;
443
+ // To support http.request
444
+ if (result.pathname || result.search) {
445
+ const p = result.pathname || "";
446
+ const s = result.search || "";
447
+ result.path = p + s;
448
+ }
449
+ result.slashes = result.slashes || relative.slashes;
450
+ result.href = result.format();
451
+ return result;
452
+ }
453
+ const isSourceAbs = result.pathname && result.pathname.charAt(0) === "/";
454
+ const isRelAbs = relative.host || relative.pathname && relative.pathname.charAt(0) === "/";
455
+ let mustEndAbs = isRelAbs || isSourceAbs || result.host && relative.pathname;
456
+ const removeAllDots = mustEndAbs;
457
+ let srcPath = result.pathname && result.pathname.split("/") || [];
458
+ const relPath = relative.pathname && relative.pathname.split("/") || [];
459
+ const noLeadingSlashes = result.protocol && !slashedProtocol.has(result.protocol);
460
+ // If the url is a non-slashed url, then relative
461
+ // links like ../.. should be able
462
+ // to crawl up to the hostname, as well. This is strange.
463
+ // result.protocol has already been set by now.
464
+ // Later on, put the first path part into the host field.
465
+ if (noLeadingSlashes) {
466
+ result.hostname = "";
467
+ result.port = null;
468
+ if (result.host) {
469
+ if (srcPath[0] === "") srcPath[0] = result.host;
470
+ else srcPath.unshift(result.host);
471
+ }
472
+ result.host = "";
473
+ if (relative.protocol) {
474
+ relative.hostname = null;
475
+ relative.port = null;
476
+ result.auth = null;
477
+ if (relative.host) {
478
+ if (relPath[0] === "") relPath[0] = relative.host;
479
+ else relPath.unshift(relative.host);
480
+ }
481
+ relative.host = null;
482
+ }
483
+ mustEndAbs = mustEndAbs && (relPath[0] === "" || srcPath[0] === "");
484
+ }
485
+ if (isRelAbs) {
486
+ // it's absolute.
487
+ if (relative.host || relative.host === "") {
488
+ if (result.host !== relative.host) result.auth = null;
489
+ result.host = relative.host;
490
+ result.port = relative.port;
491
+ }
492
+ if (relative.hostname || relative.hostname === "") {
493
+ if (result.hostname !== relative.hostname) result.auth = null;
494
+ result.hostname = relative.hostname;
495
+ }
496
+ result.search = relative.search;
497
+ result.query = relative.query;
498
+ srcPath = relPath;
499
+ } else if (relPath.length > 0) {
500
+ // it's relative
501
+ // throw away the existing file, and take the new path instead.
502
+ if (!srcPath) srcPath = [];
503
+ srcPath.pop();
504
+ // eslint-disable-next-line unicorn/prefer-spread
505
+ srcPath = srcPath.concat(relPath);
506
+ result.search = relative.search;
507
+ result.query = relative.query;
508
+ } else if (relative.search !== null && relative.search !== undefined) {
509
+ // Just pull out the search.
510
+ // like href='?foo'.
511
+ // Put this after the other two cases because it simplifies the booleans
512
+ if (noLeadingSlashes) {
513
+ result.hostname = result.host = srcPath.shift();
514
+ // Occasionally the auth can get stuck only in host.
515
+ // This especially happens in cases like
516
+ // url.resolveObject('mailto:local1@domain1', 'local2@domain2')
517
+ const authInHost = result.host && result.host.indexOf("@") > 0 && result.host.split("@");
518
+ if (authInHost) {
519
+ result.auth = authInHost.shift();
520
+ result.host = result.hostname = authInHost.shift();
521
+ }
522
+ }
523
+ result.search = relative.search;
524
+ result.query = relative.query;
525
+ // To support http.request
526
+ if (result.pathname !== null || result.search !== null) {
527
+ result.path = (result.pathname ? result.pathname : "") + (result.search ? result.search : "");
528
+ }
529
+ result.href = result.format();
530
+ return result;
531
+ }
532
+ if (srcPath.length === 0) {
533
+ // No path at all. All other things were already handled above.
534
+ result.pathname = null;
535
+ // To support http.request
536
+ if (result.search) {
537
+ result.path = "/" + result.search;
538
+ } else {
539
+ result.path = null;
540
+ }
541
+ result.href = result.format();
542
+ return result;
543
+ }
544
+ // If a url ENDs in . or .., then it must get a trailing slash.
545
+ // however, if it ends in anything else non-slashy,
546
+ // then it must NOT get a trailing slash.
547
+ let last = srcPath.at(-1);
548
+ const hasTrailingSlash = (result.host || relative.host || srcPath.length > 1) && (last === "." || last === "..") || last === "";
549
+ // Strip single dots, resolve double dots to parent dir
550
+ // if the path tries to go above the root, `up` ends up > 0
551
+ let up = 0;
552
+ for (let i = srcPath.length - 1; i >= 0; i--) {
553
+ last = srcPath[i];
554
+ if (last === ".") {
555
+ spliceOne(srcPath, i);
556
+ } else if (last === "..") {
557
+ spliceOne(srcPath, i);
558
+ up++;
559
+ } else if (up) {
560
+ spliceOne(srcPath, i);
561
+ up--;
562
+ }
563
+ }
564
+ // If the path is allowed to go above the root, restore leading ..s
565
+ if (!mustEndAbs && !removeAllDots) {
566
+ while (up--) {
567
+ srcPath.unshift("..");
568
+ }
569
+ }
570
+ if (mustEndAbs && srcPath[0] !== "" && (!srcPath[0] || srcPath[0].charAt(0) !== "/")) {
571
+ srcPath.unshift("");
572
+ }
573
+ if (hasTrailingSlash && srcPath.join("/").slice(-1) !== "/") {
574
+ srcPath.push("");
575
+ }
576
+ const isAbsolute = srcPath[0] === "" || srcPath[0] && srcPath[0].charAt(0) === "/";
577
+ // put the host back
578
+ if (noLeadingSlashes) {
579
+ result.hostname = result.host = isAbsolute ? "" : srcPath.length > 0 ? srcPath.shift() : "";
580
+ // Occasionally the auth can get stuck only in host.
581
+ // This especially happens in cases like
582
+ // url.resolveObject('mailto:local1@domain1', 'local2@domain2')
583
+ const authInHost = result.host && result.host.indexOf("@") > 0 ? result.host.split("@") : false;
584
+ if (authInHost) {
585
+ result.auth = authInHost.shift();
586
+ result.host = result.hostname = authInHost.shift();
587
+ }
588
+ }
589
+ // eslint-disable-next-line unicorn/explicit-length-check
590
+ mustEndAbs = mustEndAbs || result.host && srcPath.length;
591
+ if (mustEndAbs && !isAbsolute) {
592
+ srcPath.unshift("");
593
+ }
594
+ if (srcPath.length === 0) {
595
+ result.pathname = null;
596
+ result.path = null;
597
+ } else {
598
+ result.pathname = srcPath.join("/");
599
+ }
600
+ // To support request.http
601
+ if (result.pathname !== null || result.search !== null) {
602
+ result.path = (result.pathname ? result.pathname : "") + (result.search ? result.search : "");
603
+ }
604
+ result.auth = relative.auth || result.auth;
605
+ result.slashes = result.slashes || relative.slashes;
606
+ result.href = result.format();
607
+ return result;
608
+ }
609
+ parseHost() {
610
+ let host = this.host;
611
+ const portMatch = portPattern.exec(host);
612
+ if (portMatch) {
613
+ const port = portMatch[0];
614
+ if (port !== ":") {
615
+ this.port = port.slice(1);
616
+ }
617
+ host = host.slice(0, host.length - port.length);
618
+ }
619
+ if (host) this.hostname = host;
620
+ }
621
+ }
622
+ // define these here so at least they only have to be
623
+ // compiled once on the first module load.
624
+ const protocolPattern = /^[\d+.a-z-]+:/i;
625
+ const portPattern = /:\d*$/;
626
+ const hostPattern = /^\/\/[^/@]+@[^/@]+/;
627
+ // Special case for a simple path URL
628
+ const simplePathPattern = /^(\/\/?(?!\/)[^\s?]*)(\?\S*)?$/;
629
+ // This prevents some common spoofing bugs due to our use of IDNA toASCII. For
630
+ // compatibility, the set of characters we use here is the *intersection* of
631
+ // "forbidden host code point" in the WHATWG URL Standard [1] and the
632
+ // characters in the host parsing loop in Url.prototype.parse, with the
633
+ // following additions:
634
+ //
635
+ // - ':' since this could cause a "protocol spoofing" bug
636
+ // - '@' since this could cause parts of the hostname to be confused with auth
637
+ // - '[' and ']' since this could cause a non-IPv6 hostname to be interpreted
638
+ // as IPv6 by isIpv6Hostname above
639
+ //
640
+ // [1]: https://url.spec.whatwg.org/#forbidden-host-code-point
641
+ const forbiddenHostChars = /[\0\t\n\r #%/:<>?@[\\\]^|]/;
642
+ // For IPv6, permit '[', ']', and ':'.
643
+ const forbiddenHostCharsIpv6 = /[\0\t\n\r #%/<>?@\\^|]/;
644
+ // These characters do not need escaping:
645
+ // ! - . _ ~
646
+ // ' ( ) * :
647
+ // digits
648
+ // alpha (uppercase)
649
+ // alpha (lowercase)
650
+ // prettier-ignore
651
+ const noEscapeAuth = new Int8Array([
652
+ 0,
653
+ 0,
654
+ 0,
655
+ 0,
656
+ 0,
657
+ 0,
658
+ 0,
659
+ 0,
660
+ 0,
661
+ 0,
662
+ 0,
663
+ 0,
664
+ 0,
665
+ 0,
666
+ 0,
667
+ 0,
668
+ 0,
669
+ 0,
670
+ 0,
671
+ 0,
672
+ 0,
673
+ 0,
674
+ 0,
675
+ 0,
676
+ 0,
677
+ 0,
678
+ 0,
679
+ 0,
680
+ 0,
681
+ 0,
682
+ 0,
683
+ 0,
684
+ 0,
685
+ 1,
686
+ 0,
687
+ 0,
688
+ 0,
689
+ 0,
690
+ 0,
691
+ 1,
692
+ 1,
693
+ 1,
694
+ 1,
695
+ 0,
696
+ 0,
697
+ 1,
698
+ 1,
699
+ 0,
700
+ 1,
701
+ 1,
702
+ 1,
703
+ 1,
704
+ 1,
705
+ 1,
706
+ 1,
707
+ 1,
708
+ 1,
709
+ 1,
710
+ 1,
711
+ 0,
712
+ 0,
713
+ 0,
714
+ 0,
715
+ 0,
716
+ 0,
717
+ 1,
718
+ 1,
719
+ 1,
720
+ 1,
721
+ 1,
722
+ 1,
723
+ 1,
724
+ 1,
725
+ 1,
726
+ 1,
727
+ 1,
728
+ 1,
729
+ 1,
730
+ 1,
731
+ 1,
732
+ 1,
733
+ 1,
734
+ 1,
735
+ 1,
736
+ 1,
737
+ 1,
738
+ 1,
739
+ 1,
740
+ 1,
741
+ 1,
742
+ 1,
743
+ 0,
744
+ 0,
745
+ 0,
746
+ 0,
747
+ 1,
748
+ 0,
749
+ 1,
750
+ 1,
751
+ 1,
752
+ 1,
753
+ 1,
754
+ 1,
755
+ 1,
756
+ 1,
757
+ 1,
758
+ 1,
759
+ 1,
760
+ 1,
761
+ 1,
762
+ 1,
763
+ 1,
764
+ 1,
765
+ 1,
766
+ 1,
767
+ 1,
768
+ 1,
769
+ 1,
770
+ 1,
771
+ 1,
772
+ 1,
773
+ 1,
774
+ 1,
775
+ 0,
776
+ 0,
777
+ 0,
778
+ 1,
779
+ 0
780
+ ]);
781
+ // Escaped characters. Use empty strings to fill up unused entries.
782
+ // Using Array is faster than Object/Map
783
+ // prettier-ignore
784
+ const escapedCodes = [
785
+ "",
786
+ "",
787
+ "",
788
+ "",
789
+ "",
790
+ "",
791
+ "",
792
+ "",
793
+ "",
794
+ "%09",
795
+ "%0A",
796
+ "",
797
+ "",
798
+ "%0D",
799
+ "",
800
+ "",
801
+ "",
802
+ "",
803
+ "",
804
+ "",
805
+ "",
806
+ "",
807
+ "",
808
+ "",
809
+ "",
810
+ "",
811
+ "",
812
+ "",
813
+ "",
814
+ "",
815
+ "",
816
+ "",
817
+ "%20",
818
+ "",
819
+ "%22",
820
+ "",
821
+ "",
822
+ "",
823
+ "",
824
+ "%27",
825
+ "",
826
+ "",
827
+ "",
828
+ "",
829
+ "",
830
+ "",
831
+ "",
832
+ "",
833
+ "",
834
+ "",
835
+ "",
836
+ "",
837
+ "",
838
+ "",
839
+ "",
840
+ "",
841
+ "",
842
+ "",
843
+ "",
844
+ "",
845
+ "%3C",
846
+ "",
847
+ "%3E",
848
+ "",
849
+ "",
850
+ "",
851
+ "",
852
+ "",
853
+ "",
854
+ "",
855
+ "",
856
+ "",
857
+ "",
858
+ "",
859
+ "",
860
+ "",
861
+ "",
862
+ "",
863
+ "",
864
+ "",
865
+ "",
866
+ "",
867
+ "",
868
+ "",
869
+ "",
870
+ "",
871
+ "",
872
+ "",
873
+ "",
874
+ "",
875
+ "",
876
+ "",
877
+ "%5C",
878
+ "",
879
+ "%5E",
880
+ "",
881
+ "%60",
882
+ "",
883
+ "",
884
+ "",
885
+ "",
886
+ "",
887
+ "",
888
+ "",
889
+ "",
890
+ "",
891
+ "",
892
+ "",
893
+ "",
894
+ "",
895
+ "",
896
+ "",
897
+ "",
898
+ "",
899
+ "",
900
+ "",
901
+ "",
902
+ "",
903
+ "",
904
+ "",
905
+ "",
906
+ "",
907
+ "",
908
+ "%7B",
909
+ "%7C",
910
+ "%7D"
911
+ ];
912
+ const hostnameMaxLen = 255;
913
+ let urlParseWarned = false;
914
+ function urlParse(url, parseQueryString, slashesDenoteHost) {
915
+ if (!urlParseWarned) {
916
+ urlParseWarned = true;
917
+ console.warn("[DeprecationWarning] [unenv] [node:url] DEP0169: `url.parse()` behavior is not standardized and prone to " + "errors that have security implications. Use the WHATWG URL API " + "instead. CVEs are not issued for `url.parse()` vulnerabilities.");
918
+ }
919
+ if (url instanceof Url) return url;
920
+ const urlObject = new Url();
921
+ urlObject.parse(url, parseQueryString, slashesDenoteHost);
922
+ return urlObject;
923
+ }
924
+ function isIpv6Hostname(hostname) {
925
+ return String.prototype.charCodeAt.call(hostname, 0) === CHAR_LEFT_SQUARE_BRACKET && String.prototype.charCodeAt.call(hostname, hostname.length - 1) === CHAR_RIGHT_SQUARE_BRACKET;
926
+ }
927
+ let warnInvalidPort = true;
928
+ function getHostname(self, rest, hostname, url) {
929
+ for (let i = 0; i < hostname.length; ++i) {
930
+ const code = hostname.charCodeAt(i);
931
+ const isValid = code !== CHAR_FORWARD_SLASH && code !== CHAR_BACKWARD_SLASH && code !== CHAR_HASH && code !== CHAR_QUESTION_MARK && code !== CHAR_COLON;
932
+ if (!isValid) {
933
+ // If leftover starts with :, then it represents an invalid port.
934
+ // But url.parse() is lenient about it for now.
935
+ // Issue a warning and continue.
936
+ if (warnInvalidPort && code === CHAR_COLON) {
937
+ console.warn(`[DeprecationWarning] [unenv] [node:url] DEP0170: The URL ${url} is invalid. Future versions of Node.js will throw an error.`);
938
+ warnInvalidPort = false;
939
+ }
940
+ self.hostname = hostname.slice(0, i);
941
+ return `/${hostname.slice(i)}${rest}`;
942
+ }
943
+ }
944
+ return rest;
945
+ }
946
+ // Automatically escape all delimiters and unwise characters from RFC 2396.
947
+ // Also escape single quotes in case of an XSS attack.
948
+ // Return the escaped string.
949
+ function autoEscapeStr(rest) {
950
+ let escaped = "";
951
+ let lastEscapedPos = 0;
952
+ for (let i = 0; i < rest.length; ++i) {
953
+ // `escaped` contains substring up to the last escaped character.
954
+ const escapedChar = escapedCodes[rest.charCodeAt(i)];
955
+ if (escapedChar) {
956
+ // Concat if there are ordinary characters in the middle.
957
+ if (i > lastEscapedPos) escaped += rest.slice(lastEscapedPos, i);
958
+ escaped += escapedChar;
959
+ lastEscapedPos = i + 1;
960
+ }
961
+ }
962
+ if (lastEscapedPos === 0)
963
+ // Nothing has been escaped.
964
+ return rest;
965
+ // There are ordinary characters at the end.
966
+ if (lastEscapedPos < rest.length) escaped += rest.slice(lastEscapedPos);
967
+ return escaped;
968
+ }
969
+ // Format a parsed object into a url string
970
+ function urlFormat(urlObject, options) {
971
+ // Ensure it's an object, and not a string url.
972
+ // If it's an object, this is a no-op.
973
+ // this way, you can call urlParse() on strings
974
+ // to clean up potentially wonky urls.
975
+ if (typeof urlObject === "string") {
976
+ urlObject = urlParse(urlObject);
977
+ } else if (typeof urlObject !== "object" || urlObject === null) {
978
+ throw new ERR_INVALID_ARG_TYPE("urlObject", ["Object", "string"], urlObject);
979
+ } else if (urlObject instanceof URL) {
980
+ let fragment = true;
981
+ let unicode = false;
982
+ let search = true;
983
+ let auth = true;
984
+ if (options) {
985
+ // validateObject(options, "options");
986
+ if (options.fragment != null) {
987
+ fragment = Boolean(options.fragment);
988
+ }
989
+ if (options.unicode != null) {
990
+ unicode = Boolean(options.unicode);
991
+ }
992
+ if (options.search != null) {
993
+ search = Boolean(options.search);
994
+ }
995
+ if (options.auth != null) {
996
+ auth = Boolean(options.auth);
997
+ }
998
+ }
999
+ // TODO: CHECK ME! Alternative by unenv
1000
+ // return bindingUrl.format(urlObject.href, fragment, unicode, search, auth);
1001
+ const _url = new URL(urlObject.href);
1002
+ if (!fragment) _url.hash = "";
1003
+ if (!search) _url.search = "";
1004
+ if (!auth) _url.username = _url.password = "";
1005
+ if (unicode) {
1006
+ return Url.prototype.format.call(_url);
1007
+ }
1008
+ return _url.href;
1009
+ }
1010
+ return Url.prototype.format.call(urlObject);
1011
+ }
1012
+ function urlResolve(source, relative) {
1013
+ return urlParse(source, false, true).resolve(relative);
1014
+ }
1015
+ function urlResolveObject(source, relative) {
1016
+ if (!source) return relative;
1017
+ return urlParse(source, false, true).resolveObject(relative);
1018
+ }
1019
+ // When used internally, we are not obligated to associate TypeError with
1020
+ // this function, so non-strings can be rejected by underlying implementation.
1021
+ // Public API has to validate input and throw appropriate error.
1022
+ function pathToFileURL(path, options) {
1023
+ // validateString(path, "path");
1024
+ return _pathToFileURL(path, options);
1025
+ }
1026
+ const URL = globalThis.URL;
1027
+ const URLSearchParams = globalThis.URLSearchParams;
1028
+ const domainToASCII = punnycode.toASCII;
1029
+ const domainToUnicode = punnycode.toUnicode;
1030
+ export { Url, urlParse as parse, urlResolve as resolve, urlResolveObject as resolveObject, urlFormat as format, URL, URLSearchParams, domainToASCII, domainToUnicode, pathToFileURL, fileURLToPath, urlToHttpOptions };
1031
+ export default {
1032
+ Url,
1033
+ parse: urlParse,
1034
+ resolve: urlResolve,
1035
+ resolveObject: urlResolveObject,
1036
+ format: urlFormat,
1037
+ URL,
1038
+ URLSearchParams,
1039
+ domainToASCII,
1040
+ domainToUnicode,
1041
+ pathToFileURL,
1042
+ fileURLToPath,
1043
+ urlToHttpOptions
1044
+ };