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
@@ -0,0 +1,291 @@
1
+ import { AsyncResource } from 'node:async_hooks';
2
+ const DEFAULT_MAX_PENDING = 1000;
3
+ // setTimeout fires after 1 ms for anything above this
4
+ const MAX_TIMER_MS = 2 ** 31 - 1;
5
+ /**
6
+ * Promise-based mutex keyed by string. Tasks with the same key run one at a time, in FIFO order.
7
+ *
8
+ * Each task runs in the async context (`AsyncLocalStorage`) of the code that called
9
+ * {@link AsyncLock.acquire}, not in the context of the task that held the lock before it.
10
+ */
11
+ export class AsyncLock {
12
+ queues = new Map();
13
+ defaults;
14
+ constructor(opts = {}) {
15
+ validateOptions(opts);
16
+ this.defaults = {
17
+ timeout: 0,
18
+ maxOccupationTime: 0,
19
+ maxExecutionTime: 0,
20
+ maxPending: DEFAULT_MAX_PENDING,
21
+ ...stripUndefined(opts),
22
+ };
23
+ }
24
+ /**
25
+ * Run `fn` once the lock for `key` is free and release the lock when it settles.
26
+ *
27
+ * Multiple keys are held together. They are acquired one by one in sorted order, whatever order
28
+ * they are given in, so that overlapping calls cannot deadlock; duplicates are ignored. Keys that
29
+ * are already held stay held while a later one is awaited. `timeout` and `maxOccupationTime` are
30
+ * budgets for the whole call, while `maxExecutionTime` counts from the moment all the keys are
31
+ * held and releases all of them.
32
+ *
33
+ * @param key - Resource key, or a non-empty array of keys
34
+ * @param fn - Task to run while holding the lock; may be sync or async
35
+ * @param opts - Per-call options
36
+ * @returns The result of `fn`
37
+ * @throws {TypeError} Synchronously, if an argument is invalid
38
+ */
39
+ acquire(key, fn, opts = {}) {
40
+ if (typeof fn !== 'function') {
41
+ throw new TypeError('You must pass a function to execute');
42
+ }
43
+ if (typeof key !== 'string' &&
44
+ !(Array.isArray(key) && key.length > 0 && [...key].every((k) => typeof k === 'string'))) {
45
+ throw new TypeError('The key must be a string or a non-empty array of strings');
46
+ }
47
+ validateOptions(opts);
48
+ // A canonical order keeps overlapping multi-key calls, e.g. ['a', 'b'] and ['b', 'a'], from deadlocking
49
+ const keys = typeof key === 'string' ? [key] : [...new Set(key)].sort();
50
+ const acquisition = new Acquisition(this.queues, keys, fn, { ...this.defaults, ...stripUndefined(opts) });
51
+ acquisition.enqueue();
52
+ return acquisition.promise;
53
+ }
54
+ /**
55
+ * Number of tasks waiting for `key`, not counting the running one.
56
+ *
57
+ * @param key - Resource key
58
+ */
59
+ getQueueLength(key) {
60
+ return this.queues.get(key)?.length ?? 0;
61
+ }
62
+ /**
63
+ * Whether `key` has a running or pending task. Without a key, whether any key does.
64
+ *
65
+ * @param key - Resource key
66
+ */
67
+ isBusy(key) {
68
+ return key === undefined ? this.queues.size > 0 : this.queues.has(key);
69
+ }
70
+ }
71
+ /** The place of one acquisition in the queue of one key; once granted, it holds the key. */
72
+ class KeyClaim {
73
+ queues;
74
+ key;
75
+ opts;
76
+ onGranted;
77
+ onDenied;
78
+ holding = false;
79
+ dropped = false;
80
+ queueTimer;
81
+ constructor(queues, key, opts, onGranted, onDenied) {
82
+ this.queues = queues;
83
+ this.key = key;
84
+ this.opts = opts;
85
+ this.onGranted = onGranted;
86
+ this.onDenied = onDenied;
87
+ }
88
+ /**
89
+ * Take the key right away if it is free, otherwise wait in its queue.
90
+ *
91
+ * @returns Whether the key is held. If not, `onGranted` is called once it is, unless the claim
92
+ * is denied.
93
+ */
94
+ join() {
95
+ const { timeout, maxPending, skipQueue } = this.opts;
96
+ const queue = this.queues.get(this.key);
97
+ if (!queue) {
98
+ this.queues.set(this.key, []);
99
+ this.holding = true;
100
+ return true;
101
+ }
102
+ if (queue.length >= maxPending) {
103
+ this.onDenied(new Error(`Too many pending tasks in queue ${this.key}`));
104
+ }
105
+ else {
106
+ if (skipQueue) {
107
+ queue.unshift(this.grant);
108
+ }
109
+ else {
110
+ queue.push(this.grant);
111
+ }
112
+ if (timeout) {
113
+ this.queueTimer = setTimeout(() => this.onDenied(new Error(`async-lock timed out in queue ${this.key}`)), timeout);
114
+ }
115
+ }
116
+ return false;
117
+ }
118
+ /**
119
+ * Leave the queue, or release the key if it is held. Idempotent.
120
+ *
121
+ * @returns The handover of the key to its next waiter. The caller must run it only after it
122
+ * has released all of its keys, so that no waiter starts while a batch is partially released.
123
+ */
124
+ drop() {
125
+ if (this.dropped) {
126
+ return undefined;
127
+ }
128
+ this.dropped = true;
129
+ clearTimeout(this.queueTimer);
130
+ if (this.holding) {
131
+ return this.releaseKey();
132
+ }
133
+ const queue = this.queues.get(this.key);
134
+ const idx = queue?.indexOf(this.grant) ?? -1;
135
+ if (idx >= 0) {
136
+ queue?.splice(idx, 1);
137
+ }
138
+ return undefined;
139
+ }
140
+ releaseKey() {
141
+ const next = this.queues.get(this.key)?.shift();
142
+ if (!next) {
143
+ this.queues.delete(this.key);
144
+ }
145
+ return next;
146
+ }
147
+ // An arrow function, because this exact reference sits in the queue and is removed by drop()
148
+ grant = () => {
149
+ clearTimeout(this.queueTimer);
150
+ this.holding = true;
151
+ if (this.dropped) {
152
+ // Dropped while the key was being handed over to it: pass the key on instead of using it
153
+ this.releaseKey()?.();
154
+ return;
155
+ }
156
+ this.onGranted();
157
+ };
158
+ }
159
+ /**
160
+ * One `acquire` call: its promise, its timers and its claims on all of its keys. The keys are
161
+ * claimed one by one, the task runs once all of them are held and they are released together.
162
+ */
163
+ class Acquisition {
164
+ queues;
165
+ keys;
166
+ opts;
167
+ promise;
168
+ resolve;
169
+ reject;
170
+ task;
171
+ claims = [];
172
+ running = false;
173
+ settled = false;
174
+ queueDeadline = 0;
175
+ occupationTimer;
176
+ executionTimer;
177
+ constructor(queues, keys, task, opts) {
178
+ this.queues = queues;
179
+ this.keys = keys;
180
+ this.opts = opts;
181
+ // Queued tasks are started from the previous task's promise chain; bind to keep our context
182
+ this.task = AsyncResource.bind(task);
183
+ this.promise = new Promise((resolve, reject) => {
184
+ this.resolve = resolve;
185
+ this.reject = reject;
186
+ });
187
+ }
188
+ /** Start the task right away if all the keys are free, otherwise wait for them. */
189
+ enqueue() {
190
+ const { timeout, maxOccupationTime } = this.opts;
191
+ if (timeout) {
192
+ this.queueDeadline = performance.now() + timeout;
193
+ }
194
+ if (maxOccupationTime) {
195
+ this.occupationTimer = setTimeout(() => this.expire(), maxOccupationTime);
196
+ }
197
+ this.claimKeys(0);
198
+ }
199
+ // Free keys are claimed in a loop, not recursively, so that a large batch cannot overflow the stack
200
+ claimKeys(from) {
201
+ const { maxPending, skipQueue } = this.opts;
202
+ try {
203
+ for (let index = from; index < this.keys.length; index++) {
204
+ // The queue timeout is a budget for waiting for all the keys, not for each one
205
+ const timeout = this.queueDeadline ? Math.max(this.queueDeadline - performance.now(), 1) : 0;
206
+ const claim = new KeyClaim(this.queues, this.keys[index], { timeout, maxPending, skipQueue }, () => this.claimKeys(index + 1), (error) => this.abort(error));
207
+ this.claims.push(claim);
208
+ if (!claim.join()) {
209
+ return;
210
+ }
211
+ }
212
+ this.execute();
213
+ }
214
+ catch (error) {
215
+ this.abort(error);
216
+ }
217
+ }
218
+ execute() {
219
+ const { maxExecutionTime } = this.opts;
220
+ this.running = true;
221
+ if (maxExecutionTime) {
222
+ this.executionTimer = setTimeout(() => this.abort(new Error(`Maximum execution time is exceeded ${this.keys.join(', ')}`)), maxExecutionTime);
223
+ }
224
+ new Promise((resolve) => resolve(this.task())).then((value) => this.finish({ value }), (error) => this.finish({ error }));
225
+ }
226
+ finish(outcome) {
227
+ this.settle(outcome);
228
+ this.release();
229
+ }
230
+ // Reject and release all the keys; a running task is left to finish on its own
231
+ abort(error) {
232
+ this.settle({ error });
233
+ this.release();
234
+ }
235
+ // A running task keeps its keys until it finishes, an unstarted one gives them up
236
+ expire() {
237
+ const keys = this.keys.join(', ');
238
+ if (this.running) {
239
+ this.settle({ error: new Error(`Maximum occupation time is exceeded while executing ${keys}`) });
240
+ }
241
+ else {
242
+ this.abort(new Error(`Maximum occupation time is exceeded in queue ${keys}`));
243
+ }
244
+ }
245
+ settle(outcome) {
246
+ if (this.settled) {
247
+ return;
248
+ }
249
+ this.settled = true;
250
+ clearTimeout(this.occupationTimer);
251
+ if ('error' in outcome) {
252
+ this.reject(outcome.error);
253
+ }
254
+ else {
255
+ this.resolve(outcome.value);
256
+ }
257
+ }
258
+ // Idempotent, so a task that outlives its execution timeout cannot release the keys twice
259
+ release() {
260
+ clearTimeout(this.executionTimer);
261
+ const handovers = this.claims
262
+ .splice(0)
263
+ .reverse()
264
+ .map((claim) => claim.drop());
265
+ for (const handover of handovers) {
266
+ handover?.();
267
+ }
268
+ }
269
+ }
270
+ function validateOptions(opts) {
271
+ if (opts === null || typeof opts !== 'object') {
272
+ throw new TypeError('The options must be an object');
273
+ }
274
+ for (const name of ['timeout', 'maxOccupationTime', 'maxExecutionTime']) {
275
+ const value = opts[name];
276
+ if (value !== undefined && !(Number.isFinite(value) && value >= 0 && value <= MAX_TIMER_MS)) {
277
+ throw new TypeError(`${name} must be a number of milliseconds between 0 and ${MAX_TIMER_MS}`);
278
+ }
279
+ }
280
+ if (opts.skipQueue !== undefined && typeof opts.skipQueue !== 'boolean') {
281
+ throw new TypeError('skipQueue must be a boolean');
282
+ }
283
+ const { maxPending } = opts;
284
+ if (maxPending !== undefined && maxPending !== Infinity && !(Number.isInteger(maxPending) && maxPending >= 0)) {
285
+ throw new TypeError('maxPending must be a non-negative integer or Infinity');
286
+ }
287
+ }
288
+ function stripUndefined(obj) {
289
+ return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined));
290
+ }
291
+ //# sourceMappingURL=lock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lock.js","sourceRoot":"","sources":["../../../lib/lock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,sDAAsD;AACtD,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AA0CjC;;;;;GAKG;AACH,MAAM,OAAO,SAAS;IACH,MAAM,GAAW,IAAI,GAAG,EAAE,CAAC;IAC3B,QAAQ,CAA6B;IAEtD,YAAY,OAAyB,EAAE;QACrC,eAAe,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG;YACd,OAAO,EAAE,CAAC;YACV,iBAAiB,EAAE,CAAC;YACpB,gBAAgB,EAAE,CAAC;YACnB,UAAU,EAAE,mBAAmB;YAC/B,GAAG,cAAc,CAAC,IAAI,CAAC;SACxB,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAI,GAA+B,EAAE,EAAW,EAAE,OAAuB,EAAE;QAChF,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE,CAAC;YAC7B,MAAM,IAAI,SAAS,CAAC,qCAAqC,CAAC,CAAC;QAC7D,CAAC;QACD,IACE,OAAO,GAAG,KAAK,QAAQ;YACvB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC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AAC,GAAG,IAAI,CAAC;IAC1B,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,UAAU,IAAI,CAAC,CAAC,EAAE,CAAC;QAC9G,MAAM,IAAI,SAAS,CAAC,uDAAuD,CAAC,CAAC;IAC/E,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAmB,GAAM;IAC9C,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAe,CAAC;AAClG,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { LongSleepOptions } from './types.js';
2
+ /**
3
+ * Sometimes `Promise.delay` or `setTimeout` are inaccurate for large wait
4
+ * times. To safely wait for these long times (e.g. in the 5+ minute range), you
5
+ * can use `longSleep`.
6
+ *
7
+ * You can also pass a `progressCb` option which is a callback function that
8
+ * receives an object with the properties `elapsedMs`, `timeLeft`, and
9
+ * `progress`. This will be called on every wait interval so you can do your
10
+ * wait logging or whatever.
11
+ * @param ms - The number of milliseconds to wait
12
+ * @param options - Options for controlling the long sleep behavior
13
+ */
14
+ export declare function longSleep(ms: number, { thresholdMs, intervalMs, progressCb }?: LongSleepOptions): Promise<void>;
15
+ //# sourceMappingURL=long-sleep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"long-sleep.d.ts","sourceRoot":"","sources":["../../../lib/long-sleep.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,YAAY,CAAC;AAIjD;;;;;;;;;;;GAWG;AACH,wBAAsB,SAAS,CAC7B,EAAE,EAAE,MAAM,EACV,EAAC,WAAkC,EAAE,UAAiB,EAAE,UAAiB,EAAC,GAAE,gBAAqB,GAChG,OAAO,CAAC,IAAI,CAAC,CAiBf"}
@@ -0,0 +1,33 @@
1
+ import { sleep } from './sleep.js';
2
+ const LONG_SLEEP_THRESHOLD = 5000; // anything over 5000ms will turn into a spin
3
+ /**
4
+ * Sometimes `Promise.delay` or `setTimeout` are inaccurate for large wait
5
+ * times. To safely wait for these long times (e.g. in the 5+ minute range), you
6
+ * can use `longSleep`.
7
+ *
8
+ * You can also pass a `progressCb` option which is a callback function that
9
+ * receives an object with the properties `elapsedMs`, `timeLeft`, and
10
+ * `progress`. This will be called on every wait interval so you can do your
11
+ * wait logging or whatever.
12
+ * @param ms - The number of milliseconds to wait
13
+ * @param options - Options for controlling the long sleep behavior
14
+ */
15
+ export async function longSleep(ms, { thresholdMs = LONG_SLEEP_THRESHOLD, intervalMs = 1000, progressCb = null } = {}) {
16
+ if (ms < thresholdMs) {
17
+ return await sleep(ms);
18
+ }
19
+ const endAt = performance.now() + ms;
20
+ let timeLeft;
21
+ let elapsedMs = 0;
22
+ do {
23
+ const pre = performance.now();
24
+ await sleep(intervalMs);
25
+ const post = performance.now();
26
+ timeLeft = endAt - post;
27
+ elapsedMs = elapsedMs + (post - pre);
28
+ if (typeof progressCb === 'function') {
29
+ progressCb({ elapsedMs: Math.round(elapsedMs), timeLeft: Math.round(timeLeft), progress: elapsedMs / ms });
30
+ }
31
+ } while (timeLeft > 0);
32
+ }
33
+ //# sourceMappingURL=long-sleep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"long-sleep.js","sourceRoot":"","sources":["../../../lib/long-sleep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAGjC,MAAM,oBAAoB,GAAG,IAAI,CAAC,CAAC,6CAA6C;AAEhF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,EAAU,EACV,EAAC,WAAW,GAAG,oBAAoB,EAAE,UAAU,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,KAAsB,EAAE;IAEjG,IAAI,EAAE,GAAG,WAAW,EAAE,CAAC;QACrB,OAAO,MAAM,KAAK,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;IACD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC;IACrC,IAAI,QAAgB,CAAC;IACrB,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,GAAG,CAAC;QACF,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAC9B,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC;QACxB,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAC/B,QAAQ,GAAG,KAAK,GAAG,IAAI,CAAC;QACxB,SAAS,GAAG,SAAS,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;QACrC,IAAI,OAAO,UAAU,KAAK,UAAU,EAAE,CAAC;YACrC,UAAU,CAAC,EAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,SAAS,GAAG,EAAE,EAAC,CAAC,CAAC;QAC3G,CAAC;IACH,CAAC,QAAQ,QAAQ,GAAG,CAAC,EAAE;AACzB,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * An async/await way of running a method until it doesn't throw an error
3
+ * @param times - The maximum number of times to retry the function
4
+ * @param fn - The async function to retry
5
+ * @param args - Arguments to pass to the function
6
+ */
7
+ export declare function retry<T = any>(times: number, fn: (...args: any[]) => Promise<T>, ...args: any[]): Promise<T | null>;
8
+ /**
9
+ * You can also use `retryInterval` to add a sleep in between retries. This can
10
+ * be useful if you want to throttle how fast we retry.
11
+ * @param times - The maximum number of times to retry the function
12
+ * @param sleepMs - The number of milliseconds to wait between retries
13
+ * @param fn - The async function to retry
14
+ * @param args - Arguments to pass to the function
15
+ */
16
+ export declare function retryInterval<T = any>(times: number, sleepMs: number, fn: (...args: any[]) => Promise<T>, ...args: any[]): Promise<T | null>;
17
+ //# sourceMappingURL=retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../../lib/retry.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAsB,KAAK,CAAC,CAAC,GAAG,GAAG,EACjC,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,EAClC,GAAG,IAAI,EAAE,GAAG,EAAE,GACb,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAgBnB;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,CAAC,GAAG,GAAG,EACzC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,EAClC,GAAG,IAAI,EAAE,GAAG,EAAE,GACb,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAiBnB"}
@@ -0,0 +1,53 @@
1
+ import { sleep } from './sleep.js';
2
+ /**
3
+ * An async/await way of running a method until it doesn't throw an error
4
+ * @param times - The maximum number of times to retry the function
5
+ * @param fn - The async function to retry
6
+ * @param args - Arguments to pass to the function
7
+ */
8
+ export async function retry(times, fn, ...args) {
9
+ let tries = 0;
10
+ let done = false;
11
+ let res = null;
12
+ while (!done && tries < times) {
13
+ tries++;
14
+ try {
15
+ res = await fn(...args);
16
+ done = true;
17
+ }
18
+ catch (err) {
19
+ if (tries >= times) {
20
+ throw err;
21
+ }
22
+ }
23
+ }
24
+ return res;
25
+ }
26
+ /**
27
+ * You can also use `retryInterval` to add a sleep in between retries. This can
28
+ * be useful if you want to throttle how fast we retry.
29
+ * @param times - The maximum number of times to retry the function
30
+ * @param sleepMs - The number of milliseconds to wait between retries
31
+ * @param fn - The async function to retry
32
+ * @param args - Arguments to pass to the function
33
+ */
34
+ export async function retryInterval(times, sleepMs, fn, ...args) {
35
+ let count = 0;
36
+ const wrapped = async () => {
37
+ count++;
38
+ let res;
39
+ try {
40
+ res = await fn(...args);
41
+ }
42
+ catch (e) {
43
+ // do not pause when finished the last retry
44
+ if (count !== times) {
45
+ await sleep(sleepMs);
46
+ }
47
+ throw e;
48
+ }
49
+ return res;
50
+ };
51
+ return await retry(times, wrapped);
52
+ }
53
+ //# sourceMappingURL=retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.js","sourceRoot":"","sources":["../../../lib/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,KAAa,EACb,EAAkC,EAClC,GAAG,IAAW;IAEd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,IAAI,GAAG,GAAa,IAAI,CAAC;IACzB,OAAO,CAAC,IAAI,IAAI,KAAK,GAAG,KAAK,EAAE,CAAC;QAC9B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC;YACH,GAAG,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YACxB,IAAI,GAAG,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;gBACnB,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,KAAa,EACb,OAAe,EACf,EAAkC,EAClC,GAAG,IAAW;IAEd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,OAAO,GAAG,KAAK,IAAgB,EAAE;QACrC,KAAK,EAAE,CAAC;QACR,IAAI,GAAM,CAAC;QACX,IAAI,CAAC;YACH,GAAG,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QAC1B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,4CAA4C;YAC5C,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;gBACpB,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;YACD,MAAM,CAAC,CAAC;QACV,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;IACF,OAAO,MAAM,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { CancellablePromise, SleepOptions } from './types.js';
2
+ /**
3
+ * An async/await version of `setTimeout`. The returned promise has a `cancel()` method that clears
4
+ * the timer and usually rejects with {@link PromiseCancellationError} unless you use the object form with
5
+ * `cancelError: null` to resolve on cancel.
6
+ *
7
+ * @param ms - Milliseconds to wait
8
+ * @returns A thenable you can `await`; call `.cancel()` to abort early.
9
+ */
10
+ export declare function sleep(ms: number): CancellablePromise<void>;
11
+ /**
12
+ * Object form: `ms` plus optional `cancelError` (non-empty string or `Error`, `null` to resolve on
13
+ * cancel, or omitted / `undefined` / `''` for default {@link PromiseCancellationError}). Any non-array
14
+ * object with a finite `ms` is accepted at runtime (including class instances), matching structural typing.
15
+ *
16
+ * @param options - Duration and optional cancellation behavior
17
+ * @returns A thenable you can `await`; call `.cancel()` to abort early.
18
+ */
19
+ export declare function sleep(options: SleepOptions): CancellablePromise<void>;
20
+ //# sourceMappingURL=sleep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../../lib/sleep.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAY,YAAY,EAAC,MAAM,YAAY,CAAC;AAE3E;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;AAC5D;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { PromiseCancellationError } from './errors.js';
2
+ export function sleep(arg) {
3
+ const { ms, cancelError } = parseSleepArg(arg);
4
+ let timeoutId;
5
+ let resolveFn;
6
+ let rejectFn;
7
+ const promise = new Promise((resolve, reject) => {
8
+ resolveFn = resolve;
9
+ rejectFn = reject;
10
+ timeoutId = setTimeout(resolve, ms);
11
+ });
12
+ promise.cancel = () => {
13
+ if (timeoutId) {
14
+ clearTimeout(timeoutId);
15
+ timeoutId = undefined;
16
+ }
17
+ if (cancelError === null) {
18
+ resolveFn?.(undefined);
19
+ }
20
+ else {
21
+ let err;
22
+ if (typeof cancelError === 'string' && cancelError) {
23
+ err = new PromiseCancellationError(cancelError);
24
+ }
25
+ else if (cancelError instanceof Error) {
26
+ err = cancelError;
27
+ }
28
+ else {
29
+ err = new PromiseCancellationError();
30
+ }
31
+ rejectFn?.(err);
32
+ }
33
+ resolveFn = undefined;
34
+ rejectFn = undefined;
35
+ };
36
+ return promise;
37
+ }
38
+ /** Non-array object values (including class instances); excludes `null` and arrays. */
39
+ function isSleepArgObject(value) {
40
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
41
+ }
42
+ function parseSleepArg(arg) {
43
+ if (typeof arg === 'number') {
44
+ if (!Number.isFinite(arg)) {
45
+ throw new TypeError('sleep: expected a finite number or an object with ms');
46
+ }
47
+ return { ms: arg };
48
+ }
49
+ if (isSleepArgObject(arg)) {
50
+ const ms = arg.ms;
51
+ if (typeof ms !== 'number' || !Number.isFinite(ms)) {
52
+ throw new TypeError('sleep: options.ms must be a finite number');
53
+ }
54
+ return { ms, cancelError: arg.cancelError };
55
+ }
56
+ throw new TypeError('sleep: expected a finite number or an object with ms');
57
+ }
58
+ //# sourceMappingURL=sleep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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AO,OAAO,CAAC;AACjB,CAAC;AAED,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"}
@@ -0,0 +1,18 @@
1
+ import type { WaitForConditionOptions } from './types.js';
2
+ /**
3
+ * Takes a condition (a function returning a boolean or boolean promise), and
4
+ * waits until the condition is true.
5
+ *
6
+ * Throws a `/Condition unmet/` error if the condition has not been satisfied
7
+ * within the allocated time, unless an error is provided in the options, as the
8
+ * `error` property, which is either thrown itself, or used as the message.
9
+ *
10
+ * The condition result is returned if it is not falsy. If the condition throws an
11
+ * error then this exception will be immediately passed through.
12
+ *
13
+ * The default options are: `{ waitMs: 5000, intervalMs: 500 }`
14
+ * @param condFn - The condition function to evaluate
15
+ * @param options - Options for controlling the wait behavior
16
+ */
17
+ export declare function waitForCondition<T>(condFn: () => Promise<T> | T, options?: WaitForConditionOptions): Promise<T>;
18
+ //# sourceMappingURL=wait-for-condition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wait-for-condition.d.ts","sourceRoot":"","sources":["../../../lib/wait-for-condition.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,YAAY,CAAC;AAExD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAC5B,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,CAAC,CAAC,CA8BZ"}
@@ -0,0 +1,48 @@
1
+ import { sleep } from './sleep.js';
2
+ /**
3
+ * Takes a condition (a function returning a boolean or boolean promise), and
4
+ * waits until the condition is true.
5
+ *
6
+ * Throws a `/Condition unmet/` error if the condition has not been satisfied
7
+ * within the allocated time, unless an error is provided in the options, as the
8
+ * `error` property, which is either thrown itself, or used as the message.
9
+ *
10
+ * The condition result is returned if it is not falsy. If the condition throws an
11
+ * error then this exception will be immediately passed through.
12
+ *
13
+ * The default options are: `{ waitMs: 5000, intervalMs: 500 }`
14
+ * @param condFn - The condition function to evaluate
15
+ * @param options - Options for controlling the wait behavior
16
+ */
17
+ export async function waitForCondition(condFn, options = {}) {
18
+ const opts = {
19
+ ...options,
20
+ waitMs: typeof options.waitMs === 'number' ? options.waitMs : 5000,
21
+ intervalMs: typeof options.intervalMs === 'number' ? options.intervalMs : 500,
22
+ };
23
+ const debug = opts.logger ? opts.logger.debug.bind(opts.logger) : () => undefined;
24
+ const error = opts.error;
25
+ const begunAt = performance.now();
26
+ const endAt = begunAt + opts.waitMs;
27
+ const spin = async function spin() {
28
+ const result = await condFn();
29
+ if (result) {
30
+ return result;
31
+ }
32
+ const now = performance.now();
33
+ const waited = Math.round(now - begunAt);
34
+ const remainingTime = endAt - now;
35
+ if (now < endAt) {
36
+ debug(`Waited for ${waited} ms so far`);
37
+ await sleep(Math.min(opts.intervalMs, remainingTime));
38
+ return await spin();
39
+ }
40
+ // if there is an error option, it is either a string message or an error itself
41
+ if (error) {
42
+ throw typeof error === 'string' ? new Error(error) : error;
43
+ }
44
+ throw new Error(`Condition unmet after ${waited} ms. Timing out.`);
45
+ };
46
+ return await spin();
47
+ }
48
+ //# sourceMappingURL=wait-for-condition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wait-for-condition.js","sourceRoot":"","sources":["../../../lib/wait-for-condition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAGjC;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAA4B,EAC5B,UAAmC,EAAE;IAErC,MAAM,IAAI,GAAmE;QAC3E,GAAG,OAAO;QACV,MAAM,EAAE,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI;QAClE,UAAU,EAAE,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG;KAC9E,CAAC;IACF,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;IAClF,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IACzB,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAClC,MAAM,KAAK,GAAG,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;IACpC,MAAM,IAAI,GAAG,KAAK,UAAU,IAAI;QAC9B,MAAM,MAAM,GAAG,MAAM,MAAM,EAAE,CAAC;QAC9B,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,OAAO,CAAC,CAAC;QACzC,MAAM,aAAa,GAAG,KAAK,GAAG,GAAG,CAAC;QAClC,IAAI,GAAG,GAAG,KAAK,EAAE,CAAC;YAChB,KAAK,CAAC,cAAc,MAAM,YAAY,CAAC,CAAC;YACxC,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;YACtD,OAAO,MAAM,IAAI,EAAE,CAAC;QACtB,CAAC;QACD,gFAAgF;QAChF,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAC7D,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,MAAM,kBAAkB,CAAC,CAAC;IACrE,CAAC,CAAC;IACF,OAAO,MAAM,IAAI,EAAE,CAAC;AACtB,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Resolves with `promise` or rejects if it does not settle before `timeoutMs`.
3
+ *
4
+ * If the deadline passes first: with no third argument (or a falsy non-error value), rejects
5
+ * with {@link TimeoutError} whose message includes `timeoutMs`; with a non-empty string,
6
+ * rejects with {@link TimeoutError} using that message; with an `Error` instance, rejects
7
+ * with that same instance.
8
+ *
9
+ * @param promise - Promise to race against the timeout.
10
+ * @param timeoutMs - Maximum time in milliseconds before rejecting if `promise` has not settled.
11
+ * @param messageOrError - Optional override for the timeout rejection: custom {@link TimeoutError}
12
+ * message when the string is non-empty, or an existing `Error` to reject with verbatim.
13
+ * Omitted, `undefined`, or other falsy non-error values use the default timeout message (includes `timeoutMs`).
14
+ */
15
+ export declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, messageOrError?: string | Error): Promise<T>;
16
+ //# sourceMappingURL=with-timeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-timeout.d.ts","sourceRoot":"","sources":["../../../lib/with-timeout.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAsB,WAAW,CAAC,CAAC,EACjC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,SAAS,EAAE,MAAM,EACjB,cAAc,CAAC,EAAE,MAAM,GAAG,KAAK,GAC9B,OAAO,CAAC,CAAC,CAAC,CAsBZ"}