appium-mac2-driver 4.4.0 → 4.5.1

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 (350) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/WebDriverAgentMac/IntegrationTests/AMWindowTests.m +427 -0
  3. package/WebDriverAgentMac/WebDriverAgentLib/Commands/AMWindowCommands.m +63 -0
  4. package/WebDriverAgentMac/WebDriverAgentLib/Commands/FBDebugCommands.m +2 -0
  5. package/WebDriverAgentMac/WebDriverAgentLib/Routing/FBCommandStatus.h +3 -0
  6. package/WebDriverAgentMac/WebDriverAgentLib/Routing/FBCommandStatus.m +13 -0
  7. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMScreenUtils.h +4 -0
  8. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMScreenUtils.m +23 -0
  9. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMSnapshotUtils.h +18 -0
  10. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMSnapshotUtils.m +43 -28
  11. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMWindowUtils.h +111 -0
  12. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMWindowUtils.m +780 -0
  13. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMXCTAccessibility.h +61 -0
  14. package/WebDriverAgentMac/WebDriverAgentLib/Utilities/AMXCTAccessibility.m +108 -0
  15. package/WebDriverAgentMac/WebDriverAgentMac.xcodeproj/project.pbxproj +20 -0
  16. package/build/lib/commands/native-record-screen.d.ts +2 -0
  17. package/build/lib/commands/native-record-screen.d.ts.map +1 -1
  18. package/build/lib/commands/native-record-screen.js.map +1 -1
  19. package/build/lib/commands/windows.d.ts +22 -0
  20. package/build/lib/commands/windows.d.ts.map +1 -0
  21. package/build/lib/commands/windows.js +32 -0
  22. package/build/lib/commands/windows.js.map +1 -0
  23. package/build/lib/driver.d.ts +12 -0
  24. package/build/lib/driver.d.ts.map +1 -1
  25. package/build/lib/driver.js +3 -0
  26. package/build/lib/driver.js.map +1 -1
  27. package/build/lib/execute-method-map.d.ts +9 -0
  28. package/build/lib/execute-method-map.d.ts.map +1 -1
  29. package/build/lib/execute-method-map.js +9 -0
  30. package/build/lib/execute-method-map.js.map +1 -1
  31. package/build/lib/session-claim-handler.d.ts.map +1 -1
  32. package/build/lib/session-claim-handler.js +1 -2
  33. package/build/lib/session-claim-handler.js.map +1 -1
  34. package/build/lib/types.d.ts +26 -0
  35. package/build/lib/types.d.ts.map +1 -1
  36. package/build/lib/wda-mac.d.ts +0 -1
  37. package/build/lib/wda-mac.d.ts.map +1 -1
  38. package/build/lib/wda-mac.js +1 -1
  39. package/lib/commands/native-record-screen.ts +2 -0
  40. package/lib/commands/windows.ts +44 -0
  41. package/lib/driver.ts +4 -0
  42. package/lib/execute-method-map.ts +9 -0
  43. package/lib/session-claim-handler.ts +1 -2
  44. package/lib/types.ts +28 -0
  45. package/lib/wda-mac.ts +1 -2
  46. package/node_modules/@appium/support/build/lib/npm.d.ts.map +1 -1
  47. package/node_modules/@appium/support/build/lib/npm.js +2 -1
  48. package/node_modules/@appium/support/build/lib/npm.js.map +1 -1
  49. package/node_modules/@appium/support/build/lib/util.d.ts.map +1 -1
  50. package/node_modules/@appium/support/build/lib/util.js +13 -1
  51. package/node_modules/@appium/support/build/lib/util.js.map +1 -1
  52. package/node_modules/@appium/support/build/lib/zip.d.ts +2 -1
  53. package/node_modules/@appium/support/build/lib/zip.d.ts.map +1 -1
  54. package/node_modules/@appium/support/build/lib/zip.js +193 -64
  55. package/node_modules/@appium/support/build/lib/zip.js.map +1 -1
  56. package/node_modules/@appium/support/lib/npm.ts +2 -1
  57. package/node_modules/@appium/support/lib/util.ts +13 -1
  58. package/node_modules/@appium/support/lib/zip.ts +231 -71
  59. package/node_modules/@appium/support/node_modules/axios/CHANGELOG.md +1934 -0
  60. package/node_modules/@appium/support/node_modules/axios/LICENSE +7 -0
  61. package/node_modules/@appium/support/node_modules/axios/MIGRATION_GUIDE.md +877 -0
  62. package/node_modules/@appium/support/node_modules/axios/README.md +2851 -0
  63. package/node_modules/@appium/support/node_modules/axios/dist/axios.js +5807 -0
  64. package/node_modules/@appium/support/node_modules/axios/dist/axios.min.js +5 -0
  65. package/node_modules/@appium/support/node_modules/axios/dist/axios.min.js.map +1 -0
  66. package/node_modules/@appium/support/node_modules/axios/dist/browser/axios.cjs +5829 -0
  67. package/node_modules/@appium/support/node_modules/axios/dist/esm/axios.js +5850 -0
  68. package/node_modules/@appium/support/node_modules/axios/dist/esm/axios.min.js +3 -0
  69. package/node_modules/@appium/support/node_modules/axios/dist/esm/axios.min.js.map +1 -0
  70. package/node_modules/@appium/support/node_modules/axios/dist/node/axios.cjs +6808 -0
  71. package/node_modules/@appium/support/node_modules/axios/index.d.cts +766 -0
  72. package/node_modules/@appium/support/node_modules/axios/index.d.ts +787 -0
  73. package/node_modules/@appium/support/node_modules/axios/index.js +45 -0
  74. package/node_modules/@appium/support/node_modules/axios/lib/adapters/README.md +36 -0
  75. package/node_modules/@appium/support/node_modules/axios/lib/adapters/adapters.js +132 -0
  76. package/node_modules/@appium/support/node_modules/axios/lib/adapters/fetch.js +696 -0
  77. package/node_modules/@appium/support/node_modules/axios/lib/adapters/http.js +1490 -0
  78. package/node_modules/@appium/support/node_modules/axios/lib/adapters/xhr.js +277 -0
  79. package/node_modules/@appium/support/node_modules/axios/lib/axios.js +89 -0
  80. package/node_modules/@appium/support/node_modules/axios/lib/cancel/CancelToken.js +135 -0
  81. package/node_modules/@appium/support/node_modules/axios/lib/cancel/CanceledError.js +22 -0
  82. package/node_modules/@appium/support/node_modules/axios/lib/cancel/isCancel.js +5 -0
  83. package/node_modules/@appium/support/node_modules/axios/lib/core/Axios.js +306 -0
  84. package/node_modules/@appium/support/node_modules/axios/lib/core/AxiosError.js +219 -0
  85. package/node_modules/@appium/support/node_modules/axios/lib/core/AxiosHeaders.js +474 -0
  86. package/node_modules/@appium/support/node_modules/axios/lib/core/InterceptorManager.js +171 -0
  87. package/node_modules/@appium/support/node_modules/axios/lib/core/README.md +8 -0
  88. package/node_modules/@appium/support/node_modules/axios/lib/core/buildFullPath.js +76 -0
  89. package/node_modules/@appium/support/node_modules/axios/lib/core/dispatchRequest.js +95 -0
  90. package/node_modules/@appium/support/node_modules/axios/lib/core/mergeConfig.js +174 -0
  91. package/node_modules/@appium/support/node_modules/axios/lib/core/methodList.js +17 -0
  92. package/node_modules/@appium/support/node_modules/axios/lib/core/setFormDataHeaders.js +27 -0
  93. package/node_modules/@appium/support/node_modules/axios/lib/core/settle.js +27 -0
  94. package/node_modules/@appium/support/node_modules/axios/lib/core/transformData.js +28 -0
  95. package/node_modules/@appium/support/node_modules/axios/lib/defaults/index.js +178 -0
  96. package/node_modules/@appium/support/node_modules/axios/lib/defaults/transitional.js +10 -0
  97. package/node_modules/@appium/support/node_modules/axios/lib/env/README.md +3 -0
  98. package/node_modules/@appium/support/node_modules/axios/lib/env/classes/FormData.js +2 -0
  99. package/node_modules/@appium/support/node_modules/axios/lib/env/data.js +1 -0
  100. package/node_modules/@appium/support/node_modules/axios/lib/helpers/AxiosTransformStream.js +156 -0
  101. package/node_modules/@appium/support/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +59 -0
  102. package/node_modules/@appium/support/node_modules/axios/lib/helpers/Http2Sessions.js +121 -0
  103. package/node_modules/@appium/support/node_modules/axios/lib/helpers/HttpStatusCode.js +88 -0
  104. package/node_modules/@appium/support/node_modules/axios/lib/helpers/README.md +7 -0
  105. package/node_modules/@appium/support/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +29 -0
  106. package/node_modules/@appium/support/node_modules/axios/lib/helpers/bind.js +14 -0
  107. package/node_modules/@appium/support/node_modules/axios/lib/helpers/buildURL.js +69 -0
  108. package/node_modules/@appium/support/node_modules/axios/lib/helpers/callbackify.js +18 -0
  109. package/node_modules/@appium/support/node_modules/axios/lib/helpers/combineURLs.js +23 -0
  110. package/node_modules/@appium/support/node_modules/axios/lib/helpers/composeSignals.js +68 -0
  111. package/node_modules/@appium/support/node_modules/axios/lib/helpers/cookies.js +64 -0
  112. package/node_modules/@appium/support/node_modules/axios/lib/helpers/deprecatedMethod.js +31 -0
  113. package/node_modules/@appium/support/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +166 -0
  114. package/node_modules/@appium/support/node_modules/axios/lib/helpers/formDataToJSON.js +125 -0
  115. package/node_modules/@appium/support/node_modules/axios/lib/helpers/formDataToStream.js +119 -0
  116. package/node_modules/@appium/support/node_modules/axios/lib/helpers/fromDataURI.js +69 -0
  117. package/node_modules/@appium/support/node_modules/axios/lib/helpers/isAbsoluteURL.js +19 -0
  118. package/node_modules/@appium/support/node_modules/axios/lib/helpers/isAxiosError.js +14 -0
  119. package/node_modules/@appium/support/node_modules/axios/lib/helpers/isURLSameOrigin.js +16 -0
  120. package/node_modules/@appium/support/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
  121. package/node_modules/@appium/support/node_modules/axios/lib/helpers/null.js +2 -0
  122. package/node_modules/@appium/support/node_modules/axios/lib/helpers/parseHeaders.js +71 -0
  123. package/node_modules/@appium/support/node_modules/axios/lib/helpers/parseProtocol.js +6 -0
  124. package/node_modules/@appium/support/node_modules/axios/lib/helpers/progressEventReducer.js +54 -0
  125. package/node_modules/@appium/support/node_modules/axios/lib/helpers/readBlob.js +15 -0
  126. package/node_modules/@appium/support/node_modules/axios/lib/helpers/resolveConfig.js +107 -0
  127. package/node_modules/@appium/support/node_modules/axios/lib/helpers/sanitizeHeaderValue.js +60 -0
  128. package/node_modules/@appium/support/node_modules/axios/lib/helpers/shouldBypassProxy.js +505 -0
  129. package/node_modules/@appium/support/node_modules/axios/lib/helpers/speedometer.js +55 -0
  130. package/node_modules/@appium/support/node_modules/axios/lib/helpers/spread.js +28 -0
  131. package/node_modules/@appium/support/node_modules/axios/lib/helpers/throttle.js +45 -0
  132. package/node_modules/@appium/support/node_modules/axios/lib/helpers/toFormData.js +279 -0
  133. package/node_modules/@appium/support/node_modules/axios/lib/helpers/toURLEncodedForm.js +19 -0
  134. package/node_modules/@appium/support/node_modules/axios/lib/helpers/trackStream.js +89 -0
  135. package/node_modules/@appium/support/node_modules/axios/lib/helpers/validator.js +112 -0
  136. package/node_modules/@appium/support/node_modules/axios/lib/platform/browser/classes/Blob.js +3 -0
  137. package/node_modules/@appium/support/node_modules/axios/lib/platform/browser/classes/FormData.js +3 -0
  138. package/node_modules/@appium/support/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +4 -0
  139. package/node_modules/@appium/support/node_modules/axios/lib/platform/browser/index.js +13 -0
  140. package/node_modules/@appium/support/node_modules/axios/lib/platform/common/utils.js +52 -0
  141. package/node_modules/@appium/support/node_modules/axios/lib/platform/index.js +7 -0
  142. package/node_modules/@appium/support/node_modules/axios/lib/platform/node/classes/Buffer.js +11 -0
  143. package/node_modules/@appium/support/node_modules/axios/lib/platform/node/classes/FormData.js +3 -0
  144. package/node_modules/@appium/support/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +4 -0
  145. package/node_modules/@appium/support/node_modules/axios/lib/platform/node/index.js +37 -0
  146. package/node_modules/@appium/support/node_modules/axios/lib/utils.js +1150 -0
  147. package/node_modules/@appium/support/node_modules/axios/package.json +203 -0
  148. package/node_modules/@appium/support/package.json +6 -6
  149. package/node_modules/@appium/types/build/lib/commands/basedriver.d.ts +6 -4
  150. package/node_modules/@appium/types/build/lib/commands/basedriver.d.ts.map +1 -1
  151. package/node_modules/@appium/types/lib/commands/basedriver.ts +4 -4
  152. package/node_modules/@appium/types/package.json +2 -2
  153. package/node_modules/appium-xcode/CHANGELOG.md +7 -0
  154. package/node_modules/appium-xcode/package.json +4 -4
  155. package/node_modules/asyncbox/README.md +43 -0
  156. package/node_modules/asyncbox/build/cjs/lib/asyncfilter.d.ts +9 -0
  157. package/node_modules/asyncbox/build/cjs/lib/asyncfilter.d.ts.map +1 -0
  158. package/node_modules/asyncbox/build/cjs/lib/asyncfilter.js +35 -0
  159. package/node_modules/asyncbox/build/cjs/lib/asyncfilter.js.map +1 -0
  160. package/node_modules/asyncbox/build/cjs/lib/asyncmap.d.ts +9 -0
  161. package/node_modules/asyncbox/build/cjs/lib/asyncmap.d.ts.map +1 -0
  162. package/node_modules/asyncbox/build/cjs/lib/asyncmap.js +23 -0
  163. package/node_modules/asyncbox/build/cjs/lib/asyncmap.js.map +1 -0
  164. package/node_modules/asyncbox/build/cjs/lib/errors.d.ts +9 -0
  165. package/node_modules/asyncbox/build/cjs/lib/errors.d.ts.map +1 -0
  166. package/node_modules/asyncbox/build/cjs/lib/errors.js +20 -0
  167. package/node_modules/asyncbox/build/cjs/lib/errors.js.map +1 -0
  168. package/node_modules/asyncbox/build/cjs/lib/index.d.ts +12 -0
  169. package/node_modules/asyncbox/build/cjs/lib/index.d.ts.map +1 -0
  170. package/node_modules/asyncbox/build/cjs/lib/index.js +24 -0
  171. package/node_modules/asyncbox/build/cjs/lib/index.js.map +1 -0
  172. package/node_modules/asyncbox/build/cjs/lib/limit-function.d.ts +3 -0
  173. package/node_modules/asyncbox/build/cjs/lib/limit-function.d.ts.map +1 -0
  174. package/node_modules/asyncbox/build/cjs/lib/limit-function.js +15 -0
  175. package/node_modules/asyncbox/build/cjs/lib/limit-function.js.map +1 -0
  176. package/node_modules/asyncbox/build/cjs/lib/lock.d.ts +74 -0
  177. package/node_modules/asyncbox/build/cjs/lib/lock.d.ts.map +1 -0
  178. package/node_modules/asyncbox/build/cjs/lib/lock.js +295 -0
  179. package/node_modules/asyncbox/build/cjs/lib/lock.js.map +1 -0
  180. package/node_modules/asyncbox/build/cjs/lib/long-sleep.d.ts +15 -0
  181. package/node_modules/asyncbox/build/cjs/lib/long-sleep.d.ts.map +1 -0
  182. package/node_modules/asyncbox/build/cjs/lib/long-sleep.js +36 -0
  183. package/node_modules/asyncbox/build/cjs/lib/long-sleep.js.map +1 -0
  184. package/node_modules/asyncbox/build/cjs/lib/retry.d.ts +17 -0
  185. package/node_modules/asyncbox/build/cjs/lib/retry.d.ts.map +1 -0
  186. package/node_modules/asyncbox/build/cjs/lib/retry.js +57 -0
  187. package/node_modules/asyncbox/build/cjs/lib/retry.js.map +1 -0
  188. package/node_modules/asyncbox/build/cjs/lib/sleep.d.ts +20 -0
  189. package/node_modules/asyncbox/build/cjs/lib/sleep.d.ts.map +1 -0
  190. package/node_modules/asyncbox/build/cjs/lib/sleep.js +61 -0
  191. package/node_modules/asyncbox/build/cjs/lib/sleep.js.map +1 -0
  192. package/node_modules/asyncbox/build/cjs/lib/wait-for-condition.d.ts +18 -0
  193. package/node_modules/asyncbox/build/cjs/lib/wait-for-condition.d.ts.map +1 -0
  194. package/node_modules/asyncbox/build/cjs/lib/wait-for-condition.js +51 -0
  195. package/node_modules/asyncbox/build/cjs/lib/wait-for-condition.js.map +1 -0
  196. package/node_modules/asyncbox/build/cjs/lib/with-timeout.d.ts +16 -0
  197. package/node_modules/asyncbox/build/cjs/lib/with-timeout.d.ts.map +1 -0
  198. package/node_modules/asyncbox/build/cjs/lib/with-timeout.js +45 -0
  199. package/node_modules/asyncbox/build/cjs/lib/with-timeout.js.map +1 -0
  200. package/node_modules/asyncbox/build/esm/lib/asyncfilter.d.ts +9 -0
  201. package/node_modules/asyncbox/build/esm/lib/asyncfilter.d.ts.map +1 -0
  202. package/node_modules/asyncbox/build/esm/lib/asyncfilter.js +32 -0
  203. package/node_modules/asyncbox/build/esm/lib/asyncfilter.js.map +1 -0
  204. package/node_modules/asyncbox/build/esm/lib/asyncmap.d.ts +9 -0
  205. package/node_modules/asyncbox/build/esm/lib/asyncmap.d.ts.map +1 -0
  206. package/node_modules/asyncbox/build/esm/lib/asyncmap.js +20 -0
  207. package/node_modules/asyncbox/build/esm/lib/asyncmap.js.map +1 -0
  208. package/node_modules/asyncbox/build/esm/lib/errors.d.ts +9 -0
  209. package/node_modules/asyncbox/build/esm/lib/errors.d.ts.map +1 -0
  210. package/node_modules/asyncbox/build/esm/lib/errors.js +15 -0
  211. package/node_modules/asyncbox/build/esm/lib/errors.js.map +1 -0
  212. package/node_modules/asyncbox/build/esm/lib/index.d.ts +12 -0
  213. package/node_modules/asyncbox/build/esm/lib/index.d.ts.map +1 -0
  214. package/node_modules/asyncbox/build/esm/lib/index.js +10 -0
  215. package/node_modules/asyncbox/build/esm/lib/index.js.map +1 -0
  216. package/node_modules/asyncbox/build/esm/lib/limit-function.d.ts +3 -0
  217. package/node_modules/asyncbox/build/esm/lib/limit-function.d.ts.map +1 -0
  218. package/node_modules/asyncbox/build/esm/lib/limit-function.js +12 -0
  219. package/node_modules/asyncbox/build/esm/lib/limit-function.js.map +1 -0
  220. package/node_modules/asyncbox/build/esm/lib/lock.d.ts +74 -0
  221. package/node_modules/asyncbox/build/esm/lib/lock.d.ts.map +1 -0
  222. package/node_modules/asyncbox/build/esm/lib/lock.js +291 -0
  223. package/node_modules/asyncbox/build/esm/lib/lock.js.map +1 -0
  224. package/node_modules/asyncbox/build/esm/lib/long-sleep.d.ts +15 -0
  225. package/node_modules/asyncbox/build/esm/lib/long-sleep.d.ts.map +1 -0
  226. package/node_modules/asyncbox/build/esm/lib/long-sleep.js +33 -0
  227. package/node_modules/asyncbox/build/esm/lib/long-sleep.js.map +1 -0
  228. package/node_modules/asyncbox/build/esm/lib/retry.d.ts +17 -0
  229. package/node_modules/asyncbox/build/esm/lib/retry.d.ts.map +1 -0
  230. package/node_modules/asyncbox/build/esm/lib/retry.js +53 -0
  231. package/node_modules/asyncbox/build/esm/lib/retry.js.map +1 -0
  232. package/node_modules/asyncbox/build/esm/lib/sleep.d.ts +20 -0
  233. package/node_modules/asyncbox/build/esm/lib/sleep.d.ts.map +1 -0
  234. package/node_modules/asyncbox/build/esm/lib/sleep.js +58 -0
  235. package/node_modules/asyncbox/build/esm/lib/sleep.js.map +1 -0
  236. package/node_modules/asyncbox/build/esm/lib/wait-for-condition.d.ts +18 -0
  237. package/node_modules/asyncbox/build/esm/lib/wait-for-condition.d.ts.map +1 -0
  238. package/node_modules/asyncbox/build/esm/lib/wait-for-condition.js +48 -0
  239. package/node_modules/asyncbox/build/esm/lib/wait-for-condition.js.map +1 -0
  240. package/node_modules/asyncbox/build/esm/lib/with-timeout.d.ts +16 -0
  241. package/node_modules/asyncbox/build/esm/lib/with-timeout.d.ts.map +1 -0
  242. package/node_modules/asyncbox/build/esm/lib/with-timeout.js +42 -0
  243. package/node_modules/asyncbox/build/esm/lib/with-timeout.js.map +1 -0
  244. package/node_modules/asyncbox/lib/asyncfilter.ts +38 -0
  245. package/node_modules/asyncbox/lib/asyncmap.ts +29 -0
  246. package/node_modules/asyncbox/lib/errors.ts +15 -0
  247. package/node_modules/asyncbox/lib/index.ts +21 -0
  248. package/node_modules/asyncbox/lib/limit-function.ts +18 -0
  249. package/node_modules/asyncbox/lib/lock.ts +360 -0
  250. package/node_modules/asyncbox/lib/long-sleep.ts +38 -0
  251. package/node_modules/asyncbox/lib/retry.ts +61 -0
  252. package/node_modules/asyncbox/lib/sleep.ts +79 -0
  253. package/node_modules/asyncbox/lib/wait-for-condition.ts +52 -0
  254. package/node_modules/asyncbox/lib/with-timeout.ts +43 -0
  255. package/node_modules/asyncbox/package.json +8 -8
  256. package/node_modules/axios/README.md +41 -106
  257. package/node_modules/axios/dist/axios.js +931 -278
  258. package/node_modules/axios/dist/axios.min.js +2 -2
  259. package/node_modules/axios/dist/axios.min.js.map +1 -1
  260. package/node_modules/axios/dist/browser/axios.cjs +948 -268
  261. package/node_modules/axios/dist/esm/axios.js +948 -268
  262. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  263. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  264. package/node_modules/axios/dist/node/axios.cjs +925 -242
  265. package/node_modules/axios/index.d.cts +20 -1
  266. package/node_modules/axios/index.d.ts +18 -1
  267. package/node_modules/axios/lib/adapters/fetch.js +73 -20
  268. package/node_modules/axios/lib/adapters/http.js +145 -26
  269. package/node_modules/axios/lib/adapters/xhr.js +120 -13
  270. package/node_modules/axios/lib/core/Axios.js +67 -12
  271. package/node_modules/axios/lib/core/AxiosError.js +59 -0
  272. package/node_modules/axios/lib/core/AxiosHeaders.js +17 -4
  273. package/node_modules/axios/lib/core/InterceptorManager.js +13 -2
  274. package/node_modules/axios/lib/core/assertParamsAcyclic.js +49 -0
  275. package/node_modules/axios/lib/core/createMultipartBody.js +37 -0
  276. package/node_modules/axios/lib/core/dispatchRequest.js +20 -0
  277. package/node_modules/axios/lib/core/mergeConfig.js +183 -120
  278. package/node_modules/axios/lib/defaults/transitional.js +1 -0
  279. package/node_modules/axios/lib/env/data.js +1 -1
  280. package/node_modules/axios/lib/helpers/AxiosTransformStream.js +11 -2
  281. package/node_modules/axios/lib/helpers/Http2Sessions.js +2 -1
  282. package/node_modules/axios/lib/helpers/composeSignals.js +6 -3
  283. package/node_modules/axios/lib/helpers/cookies.js +30 -6
  284. package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +34 -7
  285. package/node_modules/axios/lib/helpers/formDataToBlob.js +113 -0
  286. package/node_modules/axios/lib/helpers/formDataToJSON.js +25 -1
  287. package/node_modules/axios/lib/helpers/fromDataURI.js +8 -2
  288. package/node_modules/axios/lib/helpers/isURLSameOrigin.js +4 -9
  289. package/node_modules/axios/lib/helpers/parseHeaders.js +2 -1
  290. package/node_modules/axios/lib/helpers/parseProtocol.js +1 -1
  291. package/node_modules/axios/lib/helpers/resolveConfig.js +16 -3
  292. package/node_modules/axios/lib/helpers/shouldBypassProxy.js +16 -1
  293. package/node_modules/axios/lib/utils.js +61 -10
  294. package/node_modules/axios/package.json +1 -2
  295. package/node_modules/bare-url/README.md +4 -0
  296. package/node_modules/bare-url/index.d.ts +3 -0
  297. package/node_modules/bare-url/index.js +42 -18
  298. package/node_modules/bare-url/lib/errors.js +4 -0
  299. package/node_modules/bare-url/package.json +1 -1
  300. package/node_modules/bare-url/prebuilds/android-arm/bare-url.bare +0 -0
  301. package/node_modules/bare-url/prebuilds/android-arm64/bare-url.bare +0 -0
  302. package/node_modules/bare-url/prebuilds/android-ia32/bare-url.bare +0 -0
  303. package/node_modules/bare-url/prebuilds/android-x64/bare-url.bare +0 -0
  304. package/node_modules/bare-url/prebuilds/darwin-arm64/bare-url.bare +0 -0
  305. package/node_modules/bare-url/prebuilds/darwin-x64/bare-url.bare +0 -0
  306. package/node_modules/bare-url/prebuilds/ios-arm64/bare-url.bare +0 -0
  307. package/node_modules/bare-url/prebuilds/ios-arm64-simulator/bare-url.bare +0 -0
  308. package/node_modules/bare-url/prebuilds/ios-x64-simulator/bare-url.bare +0 -0
  309. package/node_modules/bare-url/prebuilds/linux-arm64/bare-url.bare +0 -0
  310. package/node_modules/bare-url/prebuilds/linux-x64/bare-url.bare +0 -0
  311. package/node_modules/bare-url/prebuilds/win32-arm64/bare-url.bare +0 -0
  312. package/node_modules/bare-url/prebuilds/win32-x64/bare-url.bare +0 -0
  313. package/node_modules/follow-redirects/README.md +27 -1
  314. package/node_modules/follow-redirects/index.js +1 -5
  315. package/node_modules/follow-redirects/package.json +1 -1
  316. package/node_modules/shell-quote/README.md +37 -4
  317. package/node_modules/shell-quote/package.json +10 -6
  318. package/node_modules/shell-quote/parse.d.ts +1 -1
  319. package/node_modules/shell-quote/parse.js +63 -11
  320. package/node_modules/shell-quote/quote.d.ts +2 -1
  321. package/node_modules/shell-quote/quote.js +23 -3
  322. package/node_modules/uuid/package.json +17 -17
  323. package/package.json +6 -7
  324. package/scripts/setup-accessibility.mjs +175 -0
  325. package/node_modules/async-lock/AUTHORS +0 -21
  326. package/node_modules/async-lock/History.md +0 -132
  327. package/node_modules/async-lock/LICENSE +0 -22
  328. package/node_modules/async-lock/README.md +0 -177
  329. package/node_modules/async-lock/index.js +0 -2
  330. package/node_modules/async-lock/lib/index.js +0 -312
  331. package/node_modules/async-lock/package.json +0 -48
  332. package/node_modules/asyncbox/build/cjs/lib/asyncbox.d.ts +0 -103
  333. package/node_modules/asyncbox/build/cjs/lib/asyncbox.d.ts.map +0 -1
  334. package/node_modules/asyncbox/build/cjs/lib/asyncbox.js +0 -311
  335. package/node_modules/asyncbox/build/cjs/lib/asyncbox.js.map +0 -1
  336. package/node_modules/asyncbox/build/esm/lib/asyncbox.d.ts +0 -103
  337. package/node_modules/asyncbox/build/esm/lib/asyncbox.d.ts.map +0 -1
  338. package/node_modules/asyncbox/build/esm/lib/asyncbox.js +0 -298
  339. package/node_modules/asyncbox/build/esm/lib/asyncbox.js.map +0 -1
  340. package/node_modules/asyncbox/lib/asyncbox.ts +0 -382
  341. package/node_modules/shell-quote/.nycrc +0 -14
  342. package/node_modules/shell-quote/eslint.config.mjs +0 -29
  343. package/node_modules/shell-quote/security.md +0 -11
  344. package/node_modules/shell-quote/test/comment.js +0 -16
  345. package/node_modules/shell-quote/test/env.js +0 -52
  346. package/node_modules/shell-quote/test/env_fn.js +0 -21
  347. package/node_modules/shell-quote/test/op.js +0 -102
  348. package/node_modules/shell-quote/test/parse.js +0 -149
  349. package/node_modules/shell-quote/test/quote.js +0 -145
  350. package/node_modules/shell-quote/test/set.js +0 -31
@@ -1,298 +0,0 @@
1
- const LONG_SLEEP_THRESHOLD = 5000; // anything over 5000ms will turn into a spin
2
- // p-limit is ESM-only. tsc downlevels a plain `import()` in CommonJS output into a
3
- // require()-in-a-microtask, which still hits Node's require(esm) interop and can race with a
4
- // concurrent dynamic import() of the same module elsewhere in the process
5
- // (ERR_REQUIRE_ESM_RACE_CONDITION). Route through `new Function` so tsc can't see or rewrite the
6
- // import() call, keeping it a genuine native dynamic import in both the ESM and CJS builds.
7
- const dynamicImport = new Function('specifier', 'return import(specifier)');
8
- /** Error thrown by {@link withTimeout} when the deadline is exceeded. */
9
- export class TimeoutError extends Error {
10
- constructor(message) {
11
- super(message ?? 'Operation timed out');
12
- this.name = 'TimeoutError';
13
- }
14
- }
15
- /** Thrown when a promise is cancelled via `cancel`. */
16
- export class PromiseCancellationError extends Error {
17
- constructor(message = 'Promise cancelled') {
18
- super(message);
19
- this.name = 'PromiseCancellationError';
20
- }
21
- }
22
- export function sleep(arg) {
23
- const { ms, cancelError } = parseSleepArg(arg);
24
- let timeoutId;
25
- let resolveFn;
26
- let rejectFn;
27
- const promise = new Promise((resolve, reject) => {
28
- resolveFn = resolve;
29
- rejectFn = reject;
30
- timeoutId = setTimeout(resolve, ms);
31
- });
32
- promise.cancel = () => {
33
- if (timeoutId) {
34
- clearTimeout(timeoutId);
35
- timeoutId = undefined;
36
- }
37
- if (cancelError === null) {
38
- resolveFn?.(undefined);
39
- }
40
- else {
41
- let err;
42
- if (typeof cancelError === 'string' && cancelError) {
43
- err = new PromiseCancellationError(cancelError);
44
- }
45
- else if (cancelError instanceof Error) {
46
- err = cancelError;
47
- }
48
- else {
49
- err = new PromiseCancellationError();
50
- }
51
- rejectFn?.(err);
52
- }
53
- resolveFn = undefined;
54
- rejectFn = undefined;
55
- };
56
- return promise;
57
- }
58
- /**
59
- * Resolves with `promise` or rejects if it does not settle before `timeoutMs`.
60
- *
61
- * If the deadline passes first: with no third argument (or a falsy non-error value), rejects
62
- * with {@link TimeoutError} whose message includes `timeoutMs`; with a non-empty string,
63
- * rejects with {@link TimeoutError} using that message; with an `Error` instance, rejects
64
- * with that same instance.
65
- *
66
- * @param promise - Promise to race against the timeout.
67
- * @param timeoutMs - Maximum time in milliseconds before rejecting if `promise` has not settled.
68
- * @param messageOrError - Optional override for the timeout rejection: custom {@link TimeoutError}
69
- * message when the string is non-empty, or an existing `Error` to reject with verbatim.
70
- * Omitted, `undefined`, or other falsy non-error values use the default timeout message (includes `timeoutMs`).
71
- */
72
- export async function withTimeout(promise, timeoutMs, messageOrError) {
73
- let timer = null;
74
- try {
75
- return await Promise.race([
76
- promise,
77
- new Promise((_resolve, reject) => {
78
- timer = setTimeout(() => {
79
- if (typeof messageOrError === 'string' && messageOrError) {
80
- reject(new TimeoutError(messageOrError));
81
- }
82
- else if (!messageOrError) {
83
- reject(new TimeoutError(`Operation timed out after ${timeoutMs}ms`));
84
- }
85
- else {
86
- reject(messageOrError);
87
- }
88
- }, timeoutMs);
89
- }),
90
- ]);
91
- }
92
- finally {
93
- if (timer) {
94
- clearTimeout(timer);
95
- }
96
- }
97
- }
98
- /**
99
- * Sometimes `Promise.delay` or `setTimeout` are inaccurate for large wait
100
- * times. To safely wait for these long times (e.g. in the 5+ minute range), you
101
- * can use `longSleep`.
102
- *
103
- * You can also pass a `progressCb` option which is a callback function that
104
- * receives an object with the properties `elapsedMs`, `timeLeft`, and
105
- * `progress`. This will be called on every wait interval so you can do your
106
- * wait logging or whatever.
107
- * @param ms - The number of milliseconds to wait
108
- * @param options - Options for controlling the long sleep behavior
109
- */
110
- export async function longSleep(ms, { thresholdMs = LONG_SLEEP_THRESHOLD, intervalMs = 1000, progressCb = null } = {}) {
111
- if (ms < thresholdMs) {
112
- return await sleep(ms);
113
- }
114
- const endAt = Date.now() + ms;
115
- let timeLeft;
116
- let elapsedMs = 0;
117
- do {
118
- const pre = Date.now();
119
- await sleep(intervalMs);
120
- const post = Date.now();
121
- timeLeft = endAt - post;
122
- elapsedMs = elapsedMs + (post - pre);
123
- if (typeof progressCb === 'function') {
124
- progressCb({ elapsedMs, timeLeft, progress: elapsedMs / ms });
125
- }
126
- } while (timeLeft > 0);
127
- }
128
- /**
129
- * An async/await way of running a method until it doesn't throw an error
130
- * @param times - The maximum number of times to retry the function
131
- * @param fn - The async function to retry
132
- * @param args - Arguments to pass to the function
133
- */
134
- export async function retry(times, fn, ...args) {
135
- let tries = 0;
136
- let done = false;
137
- let res = null;
138
- while (!done && tries < times) {
139
- tries++;
140
- try {
141
- res = await fn(...args);
142
- done = true;
143
- }
144
- catch (err) {
145
- if (tries >= times) {
146
- throw err;
147
- }
148
- }
149
- }
150
- return res;
151
- }
152
- /**
153
- * You can also use `retryInterval` to add a sleep in between retries. This can
154
- * be useful if you want to throttle how fast we retry.
155
- * @param times - The maximum number of times to retry the function
156
- * @param sleepMs - The number of milliseconds to wait between retries
157
- * @param fn - The async function to retry
158
- * @param args - Arguments to pass to the function
159
- */
160
- export async function retryInterval(times, sleepMs, fn, ...args) {
161
- let count = 0;
162
- const wrapped = async () => {
163
- count++;
164
- let res;
165
- try {
166
- res = await fn(...args);
167
- }
168
- catch (e) {
169
- // do not pause when finished the last retry
170
- if (count !== times) {
171
- await sleep(sleepMs);
172
- }
173
- throw e;
174
- }
175
- return res;
176
- };
177
- return await retry(times, wrapped);
178
- }
179
- /**
180
- * Similar to `Array.prototype.map`; runs in parallel, serial, or with custom concurrency pool
181
- * @param coll - The collection to map over
182
- * @param mapper - The function to apply to each element
183
- * @param options - Options for controlling parallelism (default: true - fully parallel)
184
- */
185
- export async function asyncmap(coll, mapper, options = true) {
186
- if (options === null) {
187
- throw new Error('Options cannot be null');
188
- }
189
- // limitFunction requires the mapper to always return a promise
190
- const mapperAsync = async (value) => mapper(value);
191
- if (options === false) {
192
- return coll.reduce(async (acc, item) => [...(await acc), await mapperAsync(item)], Promise.resolve([]));
193
- }
194
- const adjustedMapper = options === true ? mapperAsync : (await getLimitFunction())(mapperAsync, { concurrency: options.concurrency });
195
- return Promise.all(coll.map(adjustedMapper));
196
- }
197
- /**
198
- * Similar to `Array.prototype.filter`; runs in parallel, serial, or with custom concurrency pool
199
- * @param coll - The collection to filter
200
- * @param filter - The function to test each element
201
- * @param options - Options for controlling parallelism (default: true - fully parallel)
202
- */
203
- export async function asyncfilter(coll, filter, options = true) {
204
- if (options === null) {
205
- throw new Error('Options cannot be null');
206
- }
207
- // limitFunction requires the filter to always return a promise
208
- const filterAsync = async (value) => filter(value);
209
- if (options === false) {
210
- return coll.reduce(async (accP, item) => {
211
- const acc = await accP;
212
- if (await filterAsync(item)) {
213
- acc.push(item);
214
- }
215
- return acc;
216
- }, Promise.resolve([]));
217
- }
218
- const adjustedFilter = options === true ? filterAsync : (await getLimitFunction())(filterAsync, { concurrency: options.concurrency });
219
- const bools = await Promise.all(coll.map(adjustedFilter));
220
- return coll.reduce((acc, item, i) => {
221
- if (bools[i]) {
222
- acc.push(item);
223
- }
224
- return acc;
225
- }, []);
226
- }
227
- /**
228
- * Takes a condition (a function returning a boolean or boolean promise), and
229
- * waits until the condition is true.
230
- *
231
- * Throws a `/Condition unmet/` error if the condition has not been satisfied
232
- * within the allocated time, unless an error is provided in the options, as the
233
- * `error` property, which is either thrown itself, or used as the message.
234
- *
235
- * The condition result is returned if it is not falsy. If the condition throws an
236
- * error then this exception will be immediately passed through.
237
- *
238
- * The default options are: `{ waitMs: 5000, intervalMs: 500 }`
239
- * @param condFn - The condition function to evaluate
240
- * @param options - Options for controlling the wait behavior
241
- */
242
- export async function waitForCondition(condFn, options = {}) {
243
- const opts = {
244
- ...options,
245
- waitMs: typeof options.waitMs === 'number' ? options.waitMs : 5000,
246
- intervalMs: typeof options.intervalMs === 'number' ? options.intervalMs : 500,
247
- };
248
- const debug = opts.logger ? opts.logger.debug.bind(opts.logger) : () => undefined;
249
- const error = opts.error;
250
- const begunAt = Date.now();
251
- const endAt = begunAt + opts.waitMs;
252
- const spin = async function spin() {
253
- const result = await condFn();
254
- if (result) {
255
- return result;
256
- }
257
- const now = Date.now();
258
- const waited = now - begunAt;
259
- const remainingTime = endAt - now;
260
- if (now < endAt) {
261
- debug(`Waited for ${waited} ms so far`);
262
- await sleep(Math.min(opts.intervalMs, remainingTime));
263
- return await spin();
264
- }
265
- // if there is an error option, it is either a string message or an error itself
266
- if (error) {
267
- throw typeof error === 'string' ? new Error(error) : error;
268
- }
269
- throw new Error(`Condition unmet after ${waited} ms. Timing out.`);
270
- };
271
- return await spin();
272
- }
273
- /** Non-array object values (including class instances); excludes `null` and arrays. */
274
- function isSleepArgObject(value) {
275
- return value !== null && typeof value === 'object' && !Array.isArray(value);
276
- }
277
- function parseSleepArg(arg) {
278
- if (typeof arg === 'number') {
279
- if (!Number.isFinite(arg)) {
280
- throw new TypeError('sleep: expected a finite number or an object with ms');
281
- }
282
- return { ms: arg };
283
- }
284
- if (isSleepArgObject(arg)) {
285
- const ms = arg.ms;
286
- if (typeof ms !== 'number' || !Number.isFinite(ms)) {
287
- throw new TypeError('sleep: options.ms must be a finite number');
288
- }
289
- return { ms, cancelError: arg.cancelError };
290
- }
291
- throw new TypeError('sleep: expected a finite number or an object with ms');
292
- }
293
- let limitFunctionPromise;
294
- async function getLimitFunction() {
295
- limitFunctionPromise ??= dynamicImport('p-limit');
296
- return (await limitFunctionPromise).limitFunction;
297
- }
298
- //# sourceMappingURL=asyncbox.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"asyncbox.js","sourceRoot":"","sources":["../../../lib/asyncbox.ts"],"names":[],"mappings":"AAWA,MAAM,oBAAoB,GAAG,IAAI,CAAC,CAAC,6CAA6C;AAIhF,mFAAmF;AACnF,6FAA6F;AAC7F,0EAA0E;AAC1E,iGAAiG;AACjG,4FAA4F;AAC5F,MAAM,aAAa,GAAG,IAAI,QAAQ,CAAC,WAAW,EAAE,0BAA0B,CAEhD,CAAC;AAE3B,yEAAyE;AACzE,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,IAAI,qBAAqB,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED,uDAAuD;AACvD,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD,YAAY,UAAkB,mBAAmB;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AAoBD,MAAM,UAAU,KAAK,CAAC,GAAa;IACjC,MAAM,EAAC,EAAE,EAAE,WAAW,EAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAC7C,IAAI,SAAqC,CAAC;IAC1C,IAAI,SAA8C,CAAC;IACnD,IAAI,QAA8C,CAAC;IAEnD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACpD,SAAS,GAAG,OAAO,CAAC;QACpB,QAAQ,GAAG,MAAM,CAAC;Q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AaD,uFAAuF;AACvF,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,aAAa,CAAC,GAAa;IAClC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,SAAS,CAAC,sDAAsD,CAAC,CAAC;QAC9E,CAAC;QACD,OAAO,EAAC,EAAE,EAAE,GAAG,EAAC,CAAC;IACnB,CAAC;IACD,IAAI,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC;QAClB,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;YACnD,MAAM,IAAI,SAAS,CAAC,2CAA2C,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,EAAC,EAAE,EAAE,WAAW,EAAE,GAAG,CAAC,WAAgD,EAAC,CAAC;IACjF,CAAC;IACD,MAAM,IAAI,SAAS,CAAC,sDAAsD,CAAC,CAAC;AAC9E,CAAC;AAED,IAAI,oBAAuD,CAAC;AAC5D,KAAK,UAAU,gBAAgB;IAC7B,oBAAoB,KAAK,aAAa,CAAC,SAAS,CAAC,CAAC;IAClD,OAAO,CAAC,MAAM,oBAAoB,CAAC,CAAC,aAAa,CAAC;AACpD,CAAC"}
@@ -1,382 +0,0 @@
1
- import type {limitFunction} from 'p-limit';
2
-
3
- import type {
4
- CancellablePromise,
5
- LongSleepOptions,
6
- MapFilterOptions,
7
- SleepArg,
8
- SleepOptions,
9
- WaitForConditionOptions,
10
- } from './types.js';
11
-
12
- const LONG_SLEEP_THRESHOLD = 5000; // anything over 5000ms will turn into a spin
13
-
14
- type PLimitModule = {limitFunction: typeof limitFunction};
15
-
16
- // p-limit is ESM-only. tsc downlevels a plain `import()` in CommonJS output into a
17
- // require()-in-a-microtask, which still hits Node's require(esm) interop and can race with a
18
- // concurrent dynamic import() of the same module elsewhere in the process
19
- // (ERR_REQUIRE_ESM_RACE_CONDITION). Route through `new Function` so tsc can't see or rewrite the
20
- // import() call, keeping it a genuine native dynamic import in both the ESM and CJS builds.
21
- const dynamicImport = new Function('specifier', 'return import(specifier)') as (
22
- specifier: string,
23
- ) => Promise<PLimitModule>;
24
-
25
- /** Error thrown by {@link withTimeout} when the deadline is exceeded. */
26
- export class TimeoutError extends Error {
27
- constructor(message?: string) {
28
- super(message ?? 'Operation timed out');
29
- this.name = 'TimeoutError';
30
- }
31
- }
32
-
33
- /** Thrown when a promise is cancelled via `cancel`. */
34
- export class PromiseCancellationError extends Error {
35
- constructor(message: string = 'Promise cancelled') {
36
- super(message);
37
- this.name = 'PromiseCancellationError';
38
- }
39
- }
40
-
41
- /**
42
- * An async/await version of `setTimeout`. The returned promise has a `cancel()` method that clears
43
- * the timer and usually rejects with {@link PromiseCancellationError} unless you use the object form with
44
- * `cancelError: null` to resolve on cancel.
45
- *
46
- * @param ms - Milliseconds to wait
47
- * @returns A thenable you can `await`; call `.cancel()` to abort early.
48
- */
49
- export function sleep(ms: number): CancellablePromise<void>;
50
- /**
51
- * Object form: `ms` plus optional `cancelError` (non-empty string or `Error`, `null` to resolve on
52
- * cancel, or omitted / `undefined` / `''` for default {@link PromiseCancellationError}). Any non-array
53
- * object with a finite `ms` is accepted at runtime (including class instances), matching structural typing.
54
- *
55
- * @param options - Duration and optional cancellation behavior
56
- * @returns A thenable you can `await`; call `.cancel()` to abort early.
57
- */
58
- export function sleep(options: SleepOptions): CancellablePromise<void>;
59
- export function sleep(arg: SleepArg): CancellablePromise<void> {
60
- const {ms, cancelError} = parseSleepArg(arg);
61
- let timeoutId: NodeJS.Timeout | undefined;
62
- let resolveFn: ((value: void) => void) | undefined;
63
- let rejectFn: ((error: Error) => void) | undefined;
64
-
65
- const promise = new Promise<void>((resolve, reject) => {
66
- resolveFn = resolve;
67
- rejectFn = reject;
68
- timeoutId = setTimeout(resolve, ms);
69
- }) as CancellablePromise<void>;
70
-
71
- promise.cancel = () => {
72
- if (timeoutId) {
73
- clearTimeout(timeoutId);
74
- timeoutId = undefined;
75
- }
76
- if (cancelError === null) {
77
- resolveFn?.(undefined);
78
- } else {
79
- let err: Error;
80
- if (typeof cancelError === 'string' && cancelError) {
81
- err = new PromiseCancellationError(cancelError);
82
- } else if (cancelError instanceof Error) {
83
- err = cancelError;
84
- } else {
85
- err = new PromiseCancellationError();
86
- }
87
- rejectFn?.(err);
88
- }
89
- resolveFn = undefined;
90
- rejectFn = undefined;
91
- };
92
-
93
- return promise;
94
- }
95
-
96
- /**
97
- * Resolves with `promise` or rejects if it does not settle before `timeoutMs`.
98
- *
99
- * If the deadline passes first: with no third argument (or a falsy non-error value), rejects
100
- * with {@link TimeoutError} whose message includes `timeoutMs`; with a non-empty string,
101
- * rejects with {@link TimeoutError} using that message; with an `Error` instance, rejects
102
- * with that same instance.
103
- *
104
- * @param promise - Promise to race against the timeout.
105
- * @param timeoutMs - Maximum time in milliseconds before rejecting if `promise` has not settled.
106
- * @param messageOrError - Optional override for the timeout rejection: custom {@link TimeoutError}
107
- * message when the string is non-empty, or an existing `Error` to reject with verbatim.
108
- * Omitted, `undefined`, or other falsy non-error values use the default timeout message (includes `timeoutMs`).
109
- */
110
- export async function withTimeout<T>(
111
- promise: Promise<T>,
112
- timeoutMs: number,
113
- messageOrError?: string | Error,
114
- ): Promise<T> {
115
- let timer: NodeJS.Timeout | null = null;
116
- try {
117
- return await Promise.race([
118
- promise,
119
- new Promise<T>((_resolve, reject) => {
120
- timer = setTimeout(() => {
121
- if (typeof messageOrError === 'string' && messageOrError) {
122
- reject(new TimeoutError(messageOrError));
123
- } else if (!messageOrError) {
124
- reject(new TimeoutError(`Operation timed out after ${timeoutMs}ms`));
125
- } else {
126
- reject(messageOrError);
127
- }
128
- }, timeoutMs);
129
- }),
130
- ]);
131
- } finally {
132
- if (timer) {
133
- clearTimeout(timer);
134
- }
135
- }
136
- }
137
-
138
- /**
139
- * Sometimes `Promise.delay` or `setTimeout` are inaccurate for large wait
140
- * times. To safely wait for these long times (e.g. in the 5+ minute range), you
141
- * can use `longSleep`.
142
- *
143
- * You can also pass a `progressCb` option which is a callback function that
144
- * receives an object with the properties `elapsedMs`, `timeLeft`, and
145
- * `progress`. This will be called on every wait interval so you can do your
146
- * wait logging or whatever.
147
- * @param ms - The number of milliseconds to wait
148
- * @param options - Options for controlling the long sleep behavior
149
- */
150
- export async function longSleep(
151
- ms: number,
152
- {thresholdMs = LONG_SLEEP_THRESHOLD, intervalMs = 1000, progressCb = null}: LongSleepOptions = {},
153
- ): Promise<void> {
154
- if (ms < thresholdMs) {
155
- return await sleep(ms);
156
- }
157
- const endAt = Date.now() + ms;
158
- let timeLeft: number;
159
- let elapsedMs = 0;
160
- do {
161
- const pre = Date.now();
162
- await sleep(intervalMs);
163
- const post = Date.now();
164
- timeLeft = endAt - post;
165
- elapsedMs = elapsedMs + (post - pre);
166
- if (typeof progressCb === 'function') {
167
- progressCb({elapsedMs, timeLeft, progress: elapsedMs / ms});
168
- }
169
- } while (timeLeft > 0);
170
- }
171
-
172
- /**
173
- * An async/await way of running a method until it doesn't throw an error
174
- * @param times - The maximum number of times to retry the function
175
- * @param fn - The async function to retry
176
- * @param args - Arguments to pass to the function
177
- */
178
- export async function retry<T = any>(
179
- times: number,
180
- fn: (...args: any[]) => Promise<T>,
181
- ...args: any[]
182
- ): Promise<T | null> {
183
- let tries = 0;
184
- let done = false;
185
- let res: T | null = null;
186
- while (!done && tries < times) {
187
- tries++;
188
- try {
189
- res = await fn(...args);
190
- done = true;
191
- } catch (err) {
192
- if (tries >= times) {
193
- throw err;
194
- }
195
- }
196
- }
197
- return res;
198
- }
199
-
200
- /**
201
- * You can also use `retryInterval` to add a sleep in between retries. This can
202
- * be useful if you want to throttle how fast we retry.
203
- * @param times - The maximum number of times to retry the function
204
- * @param sleepMs - The number of milliseconds to wait between retries
205
- * @param fn - The async function to retry
206
- * @param args - Arguments to pass to the function
207
- */
208
- export async function retryInterval<T = any>(
209
- times: number,
210
- sleepMs: number,
211
- fn: (...args: any[]) => Promise<T>,
212
- ...args: any[]
213
- ): Promise<T | null> {
214
- let count = 0;
215
- const wrapped = async (): Promise<T> => {
216
- count++;
217
- let res: T;
218
- try {
219
- res = await fn(...args);
220
- } catch (e) {
221
- // do not pause when finished the last retry
222
- if (count !== times) {
223
- await sleep(sleepMs);
224
- }
225
- throw e;
226
- }
227
- return res;
228
- };
229
- return await retry(times, wrapped);
230
- }
231
-
232
- /**
233
- * Similar to `Array.prototype.map`; runs in parallel, serial, or with custom concurrency pool
234
- * @param coll - The collection to map over
235
- * @param mapper - The function to apply to each element
236
- * @param options - Options for controlling parallelism (default: true - fully parallel)
237
- */
238
- export async function asyncmap<T, R>(
239
- coll: T[],
240
- mapper: (value: T) => R | Promise<R>,
241
- options: MapFilterOptions = true,
242
- ): Promise<R[]> {
243
- if (options === null) {
244
- throw new Error('Options cannot be null');
245
- }
246
- // limitFunction requires the mapper to always return a promise
247
- const mapperAsync = async (value: T): Promise<R> => mapper(value);
248
- if (options === false) {
249
- return coll.reduce<Promise<R[]>>(
250
- async (acc, item) => [...(await acc), await mapperAsync(item)],
251
- Promise.resolve([]),
252
- );
253
- }
254
- const adjustedMapper =
255
- options === true ? mapperAsync : (await getLimitFunction())(mapperAsync, {concurrency: options.concurrency});
256
- return Promise.all(coll.map(adjustedMapper));
257
- }
258
-
259
- /**
260
- * Similar to `Array.prototype.filter`; runs in parallel, serial, or with custom concurrency pool
261
- * @param coll - The collection to filter
262
- * @param filter - The function to test each element
263
- * @param options - Options for controlling parallelism (default: true - fully parallel)
264
- */
265
- export async function asyncfilter<T>(
266
- coll: T[],
267
- filter: (value: T) => boolean | Promise<boolean>,
268
- options: MapFilterOptions = true,
269
- ): Promise<T[]> {
270
- if (options === null) {
271
- throw new Error('Options cannot be null');
272
- }
273
- // limitFunction requires the filter to always return a promise
274
- const filterAsync = async (value: T): Promise<boolean> => filter(value);
275
- if (options === false) {
276
- return coll.reduce<Promise<T[]>>(async (accP, item) => {
277
- const acc = await accP;
278
- if (await filterAsync(item)) {
279
- acc.push(item);
280
- }
281
- return acc;
282
- }, Promise.resolve([]));
283
- }
284
- const adjustedFilter =
285
- options === true ? filterAsync : (await getLimitFunction())(filterAsync, {concurrency: options.concurrency});
286
- const bools = await Promise.all(coll.map(adjustedFilter));
287
- return coll.reduce<T[]>((acc, item, i) => {
288
- if (bools[i]) {
289
- acc.push(item);
290
- }
291
- return acc;
292
- }, []);
293
- }
294
-
295
- /**
296
- * Takes a condition (a function returning a boolean or boolean promise), and
297
- * waits until the condition is true.
298
- *
299
- * Throws a `/Condition unmet/` error if the condition has not been satisfied
300
- * within the allocated time, unless an error is provided in the options, as the
301
- * `error` property, which is either thrown itself, or used as the message.
302
- *
303
- * The condition result is returned if it is not falsy. If the condition throws an
304
- * error then this exception will be immediately passed through.
305
- *
306
- * The default options are: `{ waitMs: 5000, intervalMs: 500 }`
307
- * @param condFn - The condition function to evaluate
308
- * @param options - Options for controlling the wait behavior
309
- */
310
- export async function waitForCondition<T>(
311
- condFn: () => Promise<T> | T,
312
- options: WaitForConditionOptions = {},
313
- ): Promise<T> {
314
- const opts: WaitForConditionOptions & {waitMs: number; intervalMs: number} = {
315
- ...options,
316
- waitMs: typeof options.waitMs === 'number' ? options.waitMs : 5000,
317
- intervalMs: typeof options.intervalMs === 'number' ? options.intervalMs : 500,
318
- };
319
- const debug = opts.logger ? opts.logger.debug.bind(opts.logger) : () => undefined;
320
- const error = opts.error;
321
- const begunAt = Date.now();
322
- const endAt = begunAt + opts.waitMs;
323
- const spin = async function spin(): Promise<T> {
324
- const result = await condFn();
325
- if (result) {
326
- return result;
327
- }
328
- const now = Date.now();
329
- const waited = now - begunAt;
330
- const remainingTime = endAt - now;
331
- if (now < endAt) {
332
- debug(`Waited for ${waited} ms so far`);
333
- await sleep(Math.min(opts.intervalMs, remainingTime));
334
- return await spin();
335
- }
336
- // if there is an error option, it is either a string message or an error itself
337
- if (error) {
338
- throw typeof error === 'string' ? new Error(error) : error;
339
- }
340
- throw new Error(`Condition unmet after ${waited} ms. Timing out.`);
341
- };
342
- return await spin();
343
- }
344
-
345
- // Re-export types
346
- export type {
347
- CancellablePromise,
348
- Progress,
349
- ProgressCallback,
350
- LongSleepOptions,
351
- SleepArg,
352
- SleepOptions,
353
- WaitForConditionOptions,
354
- } from './types.js';
355
-
356
- /** Non-array object values (including class instances); excludes `null` and arrays. */
357
- function isSleepArgObject(value: unknown): value is Record<PropertyKey, unknown> {
358
- return value !== null && typeof value === 'object' && !Array.isArray(value);
359
- }
360
-
361
- function parseSleepArg(arg: SleepArg): {ms: number; cancelError?: string | Error | null} {
362
- if (typeof arg === 'number') {
363
- if (!Number.isFinite(arg)) {
364
- throw new TypeError('sleep: expected a finite number or an object with ms');
365
- }
366
- return {ms: arg};
367
- }
368
- if (isSleepArgObject(arg)) {
369
- const ms = arg.ms;
370
- if (typeof ms !== 'number' || !Number.isFinite(ms)) {
371
- throw new TypeError('sleep: options.ms must be a finite number');
372
- }
373
- return {ms, cancelError: arg.cancelError as string | Error | null | undefined};
374
- }
375
- throw new TypeError('sleep: expected a finite number or an object with ms');
376
- }
377
-
378
- let limitFunctionPromise: Promise<PLimitModule> | undefined;
379
- async function getLimitFunction() {
380
- limitFunctionPromise ??= dynamicImport('p-limit');
381
- return (await limitFunctionPromise).limitFunction;
382
- }