appium-mac2-driver 4.5.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 (295) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/build/lib/session-claim-handler.d.ts.map +1 -1
  3. package/build/lib/session-claim-handler.js +1 -2
  4. package/build/lib/session-claim-handler.js.map +1 -1
  5. package/build/lib/wda-mac.d.ts +0 -1
  6. package/build/lib/wda-mac.d.ts.map +1 -1
  7. package/build/lib/wda-mac.js +1 -1
  8. package/lib/session-claim-handler.ts +1 -2
  9. package/lib/wda-mac.ts +1 -2
  10. package/node_modules/@appium/support/build/lib/npm.d.ts.map +1 -1
  11. package/node_modules/@appium/support/build/lib/npm.js +2 -1
  12. package/node_modules/@appium/support/build/lib/npm.js.map +1 -1
  13. package/node_modules/@appium/support/build/lib/util.d.ts.map +1 -1
  14. package/node_modules/@appium/support/build/lib/util.js +13 -1
  15. package/node_modules/@appium/support/build/lib/util.js.map +1 -1
  16. package/node_modules/@appium/support/build/lib/zip.d.ts +2 -1
  17. package/node_modules/@appium/support/build/lib/zip.d.ts.map +1 -1
  18. package/node_modules/@appium/support/build/lib/zip.js +193 -64
  19. package/node_modules/@appium/support/build/lib/zip.js.map +1 -1
  20. package/node_modules/@appium/support/lib/npm.ts +2 -1
  21. package/node_modules/@appium/support/lib/util.ts +13 -1
  22. package/node_modules/@appium/support/lib/zip.ts +231 -71
  23. package/node_modules/@appium/support/node_modules/axios/CHANGELOG.md +1934 -0
  24. package/node_modules/@appium/support/node_modules/axios/LICENSE +7 -0
  25. package/node_modules/@appium/support/node_modules/axios/MIGRATION_GUIDE.md +877 -0
  26. package/node_modules/@appium/support/node_modules/axios/README.md +2851 -0
  27. package/node_modules/@appium/support/node_modules/axios/dist/axios.js +5807 -0
  28. package/node_modules/@appium/support/node_modules/axios/dist/axios.min.js +5 -0
  29. package/node_modules/@appium/support/node_modules/axios/dist/axios.min.js.map +1 -0
  30. package/node_modules/@appium/support/node_modules/axios/dist/browser/axios.cjs +5829 -0
  31. package/node_modules/@appium/support/node_modules/axios/dist/esm/axios.js +5850 -0
  32. package/node_modules/@appium/support/node_modules/axios/dist/esm/axios.min.js +3 -0
  33. package/node_modules/@appium/support/node_modules/axios/dist/esm/axios.min.js.map +1 -0
  34. package/node_modules/@appium/support/node_modules/axios/dist/node/axios.cjs +6808 -0
  35. package/node_modules/@appium/support/node_modules/axios/index.d.cts +766 -0
  36. package/node_modules/@appium/support/node_modules/axios/index.d.ts +787 -0
  37. package/node_modules/@appium/support/node_modules/axios/index.js +45 -0
  38. package/node_modules/@appium/support/node_modules/axios/lib/adapters/README.md +36 -0
  39. package/node_modules/@appium/support/node_modules/axios/lib/adapters/adapters.js +132 -0
  40. package/node_modules/@appium/support/node_modules/axios/lib/adapters/fetch.js +696 -0
  41. package/node_modules/@appium/support/node_modules/axios/lib/adapters/http.js +1490 -0
  42. package/node_modules/@appium/support/node_modules/axios/lib/adapters/xhr.js +277 -0
  43. package/node_modules/@appium/support/node_modules/axios/lib/axios.js +89 -0
  44. package/node_modules/@appium/support/node_modules/axios/lib/cancel/CancelToken.js +135 -0
  45. package/node_modules/@appium/support/node_modules/axios/lib/cancel/CanceledError.js +22 -0
  46. package/node_modules/@appium/support/node_modules/axios/lib/cancel/isCancel.js +5 -0
  47. package/node_modules/@appium/support/node_modules/axios/lib/core/Axios.js +306 -0
  48. package/node_modules/@appium/support/node_modules/axios/lib/core/AxiosError.js +219 -0
  49. package/node_modules/@appium/support/node_modules/axios/lib/core/AxiosHeaders.js +474 -0
  50. package/node_modules/@appium/support/node_modules/axios/lib/core/InterceptorManager.js +171 -0
  51. package/node_modules/@appium/support/node_modules/axios/lib/core/README.md +8 -0
  52. package/node_modules/@appium/support/node_modules/axios/lib/core/buildFullPath.js +76 -0
  53. package/node_modules/@appium/support/node_modules/axios/lib/core/dispatchRequest.js +95 -0
  54. package/node_modules/@appium/support/node_modules/axios/lib/core/mergeConfig.js +174 -0
  55. package/node_modules/@appium/support/node_modules/axios/lib/core/methodList.js +17 -0
  56. package/node_modules/@appium/support/node_modules/axios/lib/core/setFormDataHeaders.js +27 -0
  57. package/node_modules/@appium/support/node_modules/axios/lib/core/settle.js +27 -0
  58. package/node_modules/@appium/support/node_modules/axios/lib/core/transformData.js +28 -0
  59. package/node_modules/@appium/support/node_modules/axios/lib/defaults/index.js +178 -0
  60. package/node_modules/@appium/support/node_modules/axios/lib/defaults/transitional.js +10 -0
  61. package/node_modules/@appium/support/node_modules/axios/lib/env/README.md +3 -0
  62. package/node_modules/@appium/support/node_modules/axios/lib/env/classes/FormData.js +2 -0
  63. package/node_modules/@appium/support/node_modules/axios/lib/env/data.js +1 -0
  64. package/node_modules/@appium/support/node_modules/axios/lib/helpers/AxiosTransformStream.js +156 -0
  65. package/node_modules/@appium/support/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +59 -0
  66. package/node_modules/@appium/support/node_modules/axios/lib/helpers/Http2Sessions.js +121 -0
  67. package/node_modules/@appium/support/node_modules/axios/lib/helpers/HttpStatusCode.js +88 -0
  68. package/node_modules/@appium/support/node_modules/axios/lib/helpers/README.md +7 -0
  69. package/node_modules/@appium/support/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +29 -0
  70. package/node_modules/@appium/support/node_modules/axios/lib/helpers/bind.js +14 -0
  71. package/node_modules/@appium/support/node_modules/axios/lib/helpers/buildURL.js +69 -0
  72. package/node_modules/@appium/support/node_modules/axios/lib/helpers/callbackify.js +18 -0
  73. package/node_modules/@appium/support/node_modules/axios/lib/helpers/combineURLs.js +23 -0
  74. package/node_modules/@appium/support/node_modules/axios/lib/helpers/composeSignals.js +68 -0
  75. package/node_modules/@appium/support/node_modules/axios/lib/helpers/cookies.js +64 -0
  76. package/node_modules/@appium/support/node_modules/axios/lib/helpers/deprecatedMethod.js +31 -0
  77. package/node_modules/@appium/support/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +166 -0
  78. package/node_modules/@appium/support/node_modules/axios/lib/helpers/formDataToJSON.js +125 -0
  79. package/node_modules/@appium/support/node_modules/axios/lib/helpers/formDataToStream.js +119 -0
  80. package/node_modules/@appium/support/node_modules/axios/lib/helpers/fromDataURI.js +69 -0
  81. package/node_modules/@appium/support/node_modules/axios/lib/helpers/isAbsoluteURL.js +19 -0
  82. package/node_modules/@appium/support/node_modules/axios/lib/helpers/isAxiosError.js +14 -0
  83. package/node_modules/@appium/support/node_modules/axios/lib/helpers/isURLSameOrigin.js +16 -0
  84. package/node_modules/@appium/support/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
  85. package/node_modules/@appium/support/node_modules/axios/lib/helpers/null.js +2 -0
  86. package/node_modules/@appium/support/node_modules/axios/lib/helpers/parseHeaders.js +71 -0
  87. package/node_modules/@appium/support/node_modules/axios/lib/helpers/parseProtocol.js +6 -0
  88. package/node_modules/@appium/support/node_modules/axios/lib/helpers/progressEventReducer.js +54 -0
  89. package/node_modules/@appium/support/node_modules/axios/lib/helpers/readBlob.js +15 -0
  90. package/node_modules/@appium/support/node_modules/axios/lib/helpers/resolveConfig.js +107 -0
  91. package/node_modules/@appium/support/node_modules/axios/lib/helpers/sanitizeHeaderValue.js +60 -0
  92. package/node_modules/@appium/support/node_modules/axios/lib/helpers/shouldBypassProxy.js +505 -0
  93. package/node_modules/@appium/support/node_modules/axios/lib/helpers/speedometer.js +55 -0
  94. package/node_modules/@appium/support/node_modules/axios/lib/helpers/spread.js +28 -0
  95. package/node_modules/@appium/support/node_modules/axios/lib/helpers/throttle.js +45 -0
  96. package/node_modules/@appium/support/node_modules/axios/lib/helpers/toFormData.js +279 -0
  97. package/node_modules/@appium/support/node_modules/axios/lib/helpers/toURLEncodedForm.js +19 -0
  98. package/node_modules/@appium/support/node_modules/axios/lib/helpers/trackStream.js +89 -0
  99. package/node_modules/@appium/support/node_modules/axios/lib/helpers/validator.js +112 -0
  100. package/node_modules/@appium/support/node_modules/axios/lib/platform/browser/classes/Blob.js +3 -0
  101. package/node_modules/@appium/support/node_modules/axios/lib/platform/browser/classes/FormData.js +3 -0
  102. package/node_modules/@appium/support/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +4 -0
  103. package/node_modules/@appium/support/node_modules/axios/lib/platform/browser/index.js +13 -0
  104. package/node_modules/@appium/support/node_modules/axios/lib/platform/common/utils.js +52 -0
  105. package/node_modules/@appium/support/node_modules/axios/lib/platform/index.js +7 -0
  106. package/node_modules/@appium/support/node_modules/axios/lib/platform/node/classes/Buffer.js +11 -0
  107. package/node_modules/@appium/support/node_modules/axios/lib/platform/node/classes/FormData.js +3 -0
  108. package/node_modules/@appium/support/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +4 -0
  109. package/node_modules/@appium/support/node_modules/axios/lib/platform/node/index.js +37 -0
  110. package/node_modules/@appium/support/node_modules/axios/lib/utils.js +1150 -0
  111. package/node_modules/@appium/support/node_modules/axios/package.json +203 -0
  112. package/node_modules/@appium/support/package.json +6 -6
  113. package/node_modules/@appium/types/build/lib/commands/basedriver.d.ts +6 -4
  114. package/node_modules/@appium/types/build/lib/commands/basedriver.d.ts.map +1 -1
  115. package/node_modules/@appium/types/lib/commands/basedriver.ts +4 -4
  116. package/node_modules/@appium/types/package.json +2 -2
  117. package/node_modules/appium-xcode/CHANGELOG.md +7 -0
  118. package/node_modules/appium-xcode/package.json +4 -4
  119. package/node_modules/asyncbox/README.md +43 -0
  120. package/node_modules/asyncbox/build/cjs/lib/asyncfilter.d.ts +9 -0
  121. package/node_modules/asyncbox/build/cjs/lib/asyncfilter.d.ts.map +1 -0
  122. package/node_modules/asyncbox/build/cjs/lib/asyncfilter.js +35 -0
  123. package/node_modules/asyncbox/build/cjs/lib/asyncfilter.js.map +1 -0
  124. package/node_modules/asyncbox/build/cjs/lib/asyncmap.d.ts +9 -0
  125. package/node_modules/asyncbox/build/cjs/lib/asyncmap.d.ts.map +1 -0
  126. package/node_modules/asyncbox/build/cjs/lib/asyncmap.js +23 -0
  127. package/node_modules/asyncbox/build/cjs/lib/asyncmap.js.map +1 -0
  128. package/node_modules/asyncbox/build/cjs/lib/errors.d.ts +9 -0
  129. package/node_modules/asyncbox/build/cjs/lib/errors.d.ts.map +1 -0
  130. package/node_modules/asyncbox/build/cjs/lib/errors.js +20 -0
  131. package/node_modules/asyncbox/build/cjs/lib/errors.js.map +1 -0
  132. package/node_modules/asyncbox/build/cjs/lib/index.d.ts +12 -0
  133. package/node_modules/asyncbox/build/cjs/lib/index.d.ts.map +1 -0
  134. package/node_modules/asyncbox/build/cjs/lib/index.js +24 -0
  135. package/node_modules/asyncbox/build/cjs/lib/index.js.map +1 -0
  136. package/node_modules/asyncbox/build/cjs/lib/limit-function.d.ts +3 -0
  137. package/node_modules/asyncbox/build/cjs/lib/limit-function.d.ts.map +1 -0
  138. package/node_modules/asyncbox/build/cjs/lib/limit-function.js +15 -0
  139. package/node_modules/asyncbox/build/cjs/lib/limit-function.js.map +1 -0
  140. package/node_modules/asyncbox/build/cjs/lib/lock.d.ts +74 -0
  141. package/node_modules/asyncbox/build/cjs/lib/lock.d.ts.map +1 -0
  142. package/node_modules/asyncbox/build/cjs/lib/lock.js +295 -0
  143. package/node_modules/asyncbox/build/cjs/lib/lock.js.map +1 -0
  144. package/node_modules/asyncbox/build/cjs/lib/long-sleep.d.ts +15 -0
  145. package/node_modules/asyncbox/build/cjs/lib/long-sleep.d.ts.map +1 -0
  146. package/node_modules/asyncbox/build/cjs/lib/long-sleep.js +36 -0
  147. package/node_modules/asyncbox/build/cjs/lib/long-sleep.js.map +1 -0
  148. package/node_modules/asyncbox/build/cjs/lib/retry.d.ts +17 -0
  149. package/node_modules/asyncbox/build/cjs/lib/retry.d.ts.map +1 -0
  150. package/node_modules/asyncbox/build/cjs/lib/retry.js +57 -0
  151. package/node_modules/asyncbox/build/cjs/lib/retry.js.map +1 -0
  152. package/node_modules/asyncbox/build/cjs/lib/sleep.d.ts +20 -0
  153. package/node_modules/asyncbox/build/cjs/lib/sleep.d.ts.map +1 -0
  154. package/node_modules/asyncbox/build/cjs/lib/sleep.js +61 -0
  155. package/node_modules/asyncbox/build/cjs/lib/sleep.js.map +1 -0
  156. package/node_modules/asyncbox/build/cjs/lib/wait-for-condition.d.ts +18 -0
  157. package/node_modules/asyncbox/build/cjs/lib/wait-for-condition.d.ts.map +1 -0
  158. package/node_modules/asyncbox/build/cjs/lib/wait-for-condition.js +51 -0
  159. package/node_modules/asyncbox/build/cjs/lib/wait-for-condition.js.map +1 -0
  160. package/node_modules/asyncbox/build/cjs/lib/with-timeout.d.ts +16 -0
  161. package/node_modules/asyncbox/build/cjs/lib/with-timeout.d.ts.map +1 -0
  162. package/node_modules/asyncbox/build/cjs/lib/with-timeout.js +45 -0
  163. package/node_modules/asyncbox/build/cjs/lib/with-timeout.js.map +1 -0
  164. package/node_modules/asyncbox/build/esm/lib/asyncfilter.d.ts +9 -0
  165. package/node_modules/asyncbox/build/esm/lib/asyncfilter.d.ts.map +1 -0
  166. package/node_modules/asyncbox/build/esm/lib/asyncfilter.js +32 -0
  167. package/node_modules/asyncbox/build/esm/lib/asyncfilter.js.map +1 -0
  168. package/node_modules/asyncbox/build/esm/lib/asyncmap.d.ts +9 -0
  169. package/node_modules/asyncbox/build/esm/lib/asyncmap.d.ts.map +1 -0
  170. package/node_modules/asyncbox/build/esm/lib/asyncmap.js +20 -0
  171. package/node_modules/asyncbox/build/esm/lib/asyncmap.js.map +1 -0
  172. package/node_modules/asyncbox/build/esm/lib/errors.d.ts +9 -0
  173. package/node_modules/asyncbox/build/esm/lib/errors.d.ts.map +1 -0
  174. package/node_modules/asyncbox/build/esm/lib/errors.js +15 -0
  175. package/node_modules/asyncbox/build/esm/lib/errors.js.map +1 -0
  176. package/node_modules/asyncbox/build/esm/lib/index.d.ts +12 -0
  177. package/node_modules/asyncbox/build/esm/lib/index.d.ts.map +1 -0
  178. package/node_modules/asyncbox/build/esm/lib/index.js +10 -0
  179. package/node_modules/asyncbox/build/esm/lib/index.js.map +1 -0
  180. package/node_modules/asyncbox/build/esm/lib/limit-function.d.ts +3 -0
  181. package/node_modules/asyncbox/build/esm/lib/limit-function.d.ts.map +1 -0
  182. package/node_modules/asyncbox/build/esm/lib/limit-function.js +12 -0
  183. package/node_modules/asyncbox/build/esm/lib/limit-function.js.map +1 -0
  184. package/node_modules/asyncbox/build/esm/lib/lock.d.ts +74 -0
  185. package/node_modules/asyncbox/build/esm/lib/lock.d.ts.map +1 -0
  186. package/node_modules/asyncbox/build/esm/lib/lock.js +291 -0
  187. package/node_modules/asyncbox/build/esm/lib/lock.js.map +1 -0
  188. package/node_modules/asyncbox/build/esm/lib/long-sleep.d.ts +15 -0
  189. package/node_modules/asyncbox/build/esm/lib/long-sleep.d.ts.map +1 -0
  190. package/node_modules/asyncbox/build/esm/lib/long-sleep.js +33 -0
  191. package/node_modules/asyncbox/build/esm/lib/long-sleep.js.map +1 -0
  192. package/node_modules/asyncbox/build/esm/lib/retry.d.ts +17 -0
  193. package/node_modules/asyncbox/build/esm/lib/retry.d.ts.map +1 -0
  194. package/node_modules/asyncbox/build/esm/lib/retry.js +53 -0
  195. package/node_modules/asyncbox/build/esm/lib/retry.js.map +1 -0
  196. package/node_modules/asyncbox/build/esm/lib/sleep.d.ts +20 -0
  197. package/node_modules/asyncbox/build/esm/lib/sleep.d.ts.map +1 -0
  198. package/node_modules/asyncbox/build/esm/lib/sleep.js +58 -0
  199. package/node_modules/asyncbox/build/esm/lib/sleep.js.map +1 -0
  200. package/node_modules/asyncbox/build/esm/lib/wait-for-condition.d.ts +18 -0
  201. package/node_modules/asyncbox/build/esm/lib/wait-for-condition.d.ts.map +1 -0
  202. package/node_modules/asyncbox/build/esm/lib/wait-for-condition.js +48 -0
  203. package/node_modules/asyncbox/build/esm/lib/wait-for-condition.js.map +1 -0
  204. package/node_modules/asyncbox/build/esm/lib/with-timeout.d.ts +16 -0
  205. package/node_modules/asyncbox/build/esm/lib/with-timeout.d.ts.map +1 -0
  206. package/node_modules/asyncbox/build/esm/lib/with-timeout.js +42 -0
  207. package/node_modules/asyncbox/build/esm/lib/with-timeout.js.map +1 -0
  208. package/node_modules/asyncbox/lib/asyncfilter.ts +38 -0
  209. package/node_modules/asyncbox/lib/asyncmap.ts +29 -0
  210. package/node_modules/asyncbox/lib/errors.ts +15 -0
  211. package/node_modules/asyncbox/lib/index.ts +21 -0
  212. package/node_modules/asyncbox/lib/limit-function.ts +18 -0
  213. package/node_modules/asyncbox/lib/lock.ts +360 -0
  214. package/node_modules/asyncbox/lib/long-sleep.ts +38 -0
  215. package/node_modules/asyncbox/lib/retry.ts +61 -0
  216. package/node_modules/asyncbox/lib/sleep.ts +79 -0
  217. package/node_modules/asyncbox/lib/wait-for-condition.ts +52 -0
  218. package/node_modules/asyncbox/lib/with-timeout.ts +43 -0
  219. package/node_modules/asyncbox/package.json +8 -8
  220. package/node_modules/axios/README.md +41 -106
  221. package/node_modules/axios/dist/axios.js +931 -278
  222. package/node_modules/axios/dist/axios.min.js +2 -2
  223. package/node_modules/axios/dist/axios.min.js.map +1 -1
  224. package/node_modules/axios/dist/browser/axios.cjs +948 -268
  225. package/node_modules/axios/dist/esm/axios.js +948 -268
  226. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  227. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  228. package/node_modules/axios/dist/node/axios.cjs +925 -242
  229. package/node_modules/axios/index.d.cts +20 -1
  230. package/node_modules/axios/index.d.ts +18 -1
  231. package/node_modules/axios/lib/adapters/fetch.js +73 -20
  232. package/node_modules/axios/lib/adapters/http.js +145 -26
  233. package/node_modules/axios/lib/adapters/xhr.js +120 -13
  234. package/node_modules/axios/lib/core/Axios.js +67 -12
  235. package/node_modules/axios/lib/core/AxiosError.js +59 -0
  236. package/node_modules/axios/lib/core/AxiosHeaders.js +17 -4
  237. package/node_modules/axios/lib/core/InterceptorManager.js +13 -2
  238. package/node_modules/axios/lib/core/assertParamsAcyclic.js +49 -0
  239. package/node_modules/axios/lib/core/createMultipartBody.js +37 -0
  240. package/node_modules/axios/lib/core/dispatchRequest.js +20 -0
  241. package/node_modules/axios/lib/core/mergeConfig.js +183 -120
  242. package/node_modules/axios/lib/defaults/transitional.js +1 -0
  243. package/node_modules/axios/lib/env/data.js +1 -1
  244. package/node_modules/axios/lib/helpers/AxiosTransformStream.js +11 -2
  245. package/node_modules/axios/lib/helpers/Http2Sessions.js +2 -1
  246. package/node_modules/axios/lib/helpers/composeSignals.js +6 -3
  247. package/node_modules/axios/lib/helpers/cookies.js +30 -6
  248. package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +34 -7
  249. package/node_modules/axios/lib/helpers/formDataToBlob.js +113 -0
  250. package/node_modules/axios/lib/helpers/formDataToJSON.js +25 -1
  251. package/node_modules/axios/lib/helpers/fromDataURI.js +8 -2
  252. package/node_modules/axios/lib/helpers/isURLSameOrigin.js +4 -9
  253. package/node_modules/axios/lib/helpers/parseHeaders.js +2 -1
  254. package/node_modules/axios/lib/helpers/parseProtocol.js +1 -1
  255. package/node_modules/axios/lib/helpers/resolveConfig.js +16 -3
  256. package/node_modules/axios/lib/helpers/shouldBypassProxy.js +16 -1
  257. package/node_modules/axios/lib/utils.js +61 -10
  258. package/node_modules/axios/package.json +1 -2
  259. package/node_modules/follow-redirects/README.md +27 -1
  260. package/node_modules/follow-redirects/index.js +1 -5
  261. package/node_modules/follow-redirects/package.json +1 -1
  262. package/node_modules/shell-quote/README.md +37 -4
  263. package/node_modules/shell-quote/package.json +10 -6
  264. package/node_modules/shell-quote/parse.d.ts +1 -1
  265. package/node_modules/shell-quote/parse.js +63 -11
  266. package/node_modules/shell-quote/quote.d.ts +2 -1
  267. package/node_modules/shell-quote/quote.js +23 -3
  268. package/node_modules/uuid/package.json +17 -17
  269. package/package.json +4 -6
  270. package/node_modules/async-lock/AUTHORS +0 -21
  271. package/node_modules/async-lock/History.md +0 -132
  272. package/node_modules/async-lock/LICENSE +0 -22
  273. package/node_modules/async-lock/README.md +0 -177
  274. package/node_modules/async-lock/index.js +0 -2
  275. package/node_modules/async-lock/lib/index.js +0 -312
  276. package/node_modules/async-lock/package.json +0 -48
  277. package/node_modules/asyncbox/build/cjs/lib/asyncbox.d.ts +0 -103
  278. package/node_modules/asyncbox/build/cjs/lib/asyncbox.d.ts.map +0 -1
  279. package/node_modules/asyncbox/build/cjs/lib/asyncbox.js +0 -311
  280. package/node_modules/asyncbox/build/cjs/lib/asyncbox.js.map +0 -1
  281. package/node_modules/asyncbox/build/esm/lib/asyncbox.d.ts +0 -103
  282. package/node_modules/asyncbox/build/esm/lib/asyncbox.d.ts.map +0 -1
  283. package/node_modules/asyncbox/build/esm/lib/asyncbox.js +0 -298
  284. package/node_modules/asyncbox/build/esm/lib/asyncbox.js.map +0 -1
  285. package/node_modules/asyncbox/lib/asyncbox.ts +0 -382
  286. package/node_modules/shell-quote/.nycrc +0 -14
  287. package/node_modules/shell-quote/eslint.config.mjs +0 -29
  288. package/node_modules/shell-quote/security.md +0 -11
  289. package/node_modules/shell-quote/test/comment.js +0 -16
  290. package/node_modules/shell-quote/test/env.js +0 -52
  291. package/node_modules/shell-quote/test/env_fn.js +0 -21
  292. package/node_modules/shell-quote/test/op.js +0 -102
  293. package/node_modules/shell-quote/test/parse.js +0 -149
  294. package/node_modules/shell-quote/test/quote.js +0 -145
  295. package/node_modules/shell-quote/test/set.js +0 -31
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLimitFunction = getLimitFunction;
4
+ // p-limit is ESM-only. tsc downlevels a plain `import()` in CommonJS output into a
5
+ // require()-in-a-microtask, which still hits Node's require(esm) interop and can race with a
6
+ // concurrent dynamic import() of the same module elsewhere in the process
7
+ // (ERR_REQUIRE_ESM_RACE_CONDITION). Route through `new Function` so tsc can't see or rewrite the
8
+ // import() call, keeping it a genuine native dynamic import in both the ESM and CJS builds.
9
+ const dynamicImport = new Function('specifier', 'return import(specifier)');
10
+ let limitFunctionPromise;
11
+ async function getLimitFunction() {
12
+ limitFunctionPromise ??= dynamicImport('p-limit');
13
+ return (await limitFunctionPromise).limitFunction;
14
+ }
15
+ //# sourceMappingURL=limit-function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limit-function.js","sourceRoot":"","sources":["../../../lib/limit-function.ts"],"names":[],"mappings":";;AAcA,4CAGC;AAbD,mFAAmF;AACnF,6FAA6F;AAC7F,0EAA0E;AAC1E,iGAAiG;AACjG,4FAA4F;AAC5F,MAAM,aAAa,GAAG,IAAI,QAAQ,CAAC,WAAW,EAAE,0BAA0B,CAEhD,CAAC;AAE3B,IAAI,oBAAuD,CAAC;AACrD,KAAK,UAAU,gBAAgB;IACpC,oBAAoB,KAAK,aAAa,CAAC,SAAS,CAAC,CAAC;IAClD,OAAO,CAAC,MAAM,oBAAoB,CAAC,CAAC,aAAa,CAAC;AACpD,CAAC"}
@@ -0,0 +1,74 @@
1
+ /** Options shared by the {@link AsyncLock} constructor and {@link AsyncLock.acquire}. */
2
+ export interface AsyncLockOptions {
3
+ /**
4
+ * Max ms a task may wait in the queue before failing. `0` means never.
5
+ * @default 0
6
+ */
7
+ timeout?: number;
8
+ /**
9
+ * Max ms between calling `acquire` and the task finishing (queue wait included). `0` means never.
10
+ * @default 0
11
+ */
12
+ maxOccupationTime?: number;
13
+ /**
14
+ * Max ms the task may run once it holds the lock; the lock is then released. `0` means never.
15
+ * @default 0
16
+ */
17
+ maxExecutionTime?: number;
18
+ /**
19
+ * Max number of tasks waiting per key; further ones are rejected right away. `0` rejects every
20
+ * task that would have to wait.
21
+ * @default 1000
22
+ */
23
+ maxPending?: number;
24
+ }
25
+ /** Per-call options of {@link AsyncLock.acquire}; override the constructor ones. */
26
+ export interface AcquireOptions extends AsyncLockOptions {
27
+ /**
28
+ * Put the task at the front of the queue instead of the back.
29
+ * @default false
30
+ */
31
+ skipQueue?: boolean;
32
+ }
33
+ type Task<T> = () => T | PromiseLike<T>;
34
+ /**
35
+ * Promise-based mutex keyed by string. Tasks with the same key run one at a time, in FIFO order.
36
+ *
37
+ * Each task runs in the async context (`AsyncLocalStorage`) of the code that called
38
+ * {@link AsyncLock.acquire}, not in the context of the task that held the lock before it.
39
+ */
40
+ export declare class AsyncLock {
41
+ private readonly queues;
42
+ private readonly defaults;
43
+ constructor(opts?: AsyncLockOptions);
44
+ /**
45
+ * Run `fn` once the lock for `key` is free and release the lock when it settles.
46
+ *
47
+ * Multiple keys are held together. They are acquired one by one in sorted order, whatever order
48
+ * they are given in, so that overlapping calls cannot deadlock; duplicates are ignored. Keys that
49
+ * are already held stay held while a later one is awaited. `timeout` and `maxOccupationTime` are
50
+ * budgets for the whole call, while `maxExecutionTime` counts from the moment all the keys are
51
+ * held and releases all of them.
52
+ *
53
+ * @param key - Resource key, or a non-empty array of keys
54
+ * @param fn - Task to run while holding the lock; may be sync or async
55
+ * @param opts - Per-call options
56
+ * @returns The result of `fn`
57
+ * @throws {TypeError} Synchronously, if an argument is invalid
58
+ */
59
+ acquire<T>(key: string | readonly string[], fn: Task<T>, opts?: AcquireOptions): Promise<T>;
60
+ /**
61
+ * Number of tasks waiting for `key`, not counting the running one.
62
+ *
63
+ * @param key - Resource key
64
+ */
65
+ getQueueLength(key: string): number;
66
+ /**
67
+ * Whether `key` has a running or pending task. Without a key, whether any key does.
68
+ *
69
+ * @param key - Resource key
70
+ */
71
+ isBusy(key?: string): boolean;
72
+ }
73
+ export {};
74
+ //# sourceMappingURL=lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lock.d.ts","sourceRoot":"","sources":["../../../lib/lock.ts"],"names":[],"mappings":"AAMA,yFAAyF;AACzF,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,oFAAoF;AACpF,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACtD;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,KAAK,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAMxC;;;;;GAKG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;gBAE1C,IAAI,GAAE,gBAAqB;IAWvC;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,CAAC,CAAC;IAkB/F;;;;OAIG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAInC;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO;CAG9B"}
@@ -0,0 +1,295 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AsyncLock = void 0;
4
+ const node_async_hooks_1 = require("node:async_hooks");
5
+ const DEFAULT_MAX_PENDING = 1000;
6
+ // setTimeout fires after 1 ms for anything above this
7
+ const MAX_TIMER_MS = 2 ** 31 - 1;
8
+ /**
9
+ * Promise-based mutex keyed by string. Tasks with the same key run one at a time, in FIFO order.
10
+ *
11
+ * Each task runs in the async context (`AsyncLocalStorage`) of the code that called
12
+ * {@link AsyncLock.acquire}, not in the context of the task that held the lock before it.
13
+ */
14
+ class AsyncLock {
15
+ queues = new Map();
16
+ defaults;
17
+ constructor(opts = {}) {
18
+ validateOptions(opts);
19
+ this.defaults = {
20
+ timeout: 0,
21
+ maxOccupationTime: 0,
22
+ maxExecutionTime: 0,
23
+ maxPending: DEFAULT_MAX_PENDING,
24
+ ...stripUndefined(opts),
25
+ };
26
+ }
27
+ /**
28
+ * Run `fn` once the lock for `key` is free and release the lock when it settles.
29
+ *
30
+ * Multiple keys are held together. They are acquired one by one in sorted order, whatever order
31
+ * they are given in, so that overlapping calls cannot deadlock; duplicates are ignored. Keys that
32
+ * are already held stay held while a later one is awaited. `timeout` and `maxOccupationTime` are
33
+ * budgets for the whole call, while `maxExecutionTime` counts from the moment all the keys are
34
+ * held and releases all of them.
35
+ *
36
+ * @param key - Resource key, or a non-empty array of keys
37
+ * @param fn - Task to run while holding the lock; may be sync or async
38
+ * @param opts - Per-call options
39
+ * @returns The result of `fn`
40
+ * @throws {TypeError} Synchronously, if an argument is invalid
41
+ */
42
+ acquire(key, fn, opts = {}) {
43
+ if (typeof fn !== 'function') {
44
+ throw new TypeError('You must pass a function to execute');
45
+ }
46
+ if (typeof key !== 'string' &&
47
+ !(Array.isArray(key) && key.length > 0 && [...key].every((k) => typeof k === 'string'))) {
48
+ throw new TypeError('The key must be a string or a non-empty array of strings');
49
+ }
50
+ validateOptions(opts);
51
+ // A canonical order keeps overlapping multi-key calls, e.g. ['a', 'b'] and ['b', 'a'], from deadlocking
52
+ const keys = typeof key === 'string' ? [key] : [...new Set(key)].sort();
53
+ const acquisition = new Acquisition(this.queues, keys, fn, { ...this.defaults, ...stripUndefined(opts) });
54
+ acquisition.enqueue();
55
+ return acquisition.promise;
56
+ }
57
+ /**
58
+ * Number of tasks waiting for `key`, not counting the running one.
59
+ *
60
+ * @param key - Resource key
61
+ */
62
+ getQueueLength(key) {
63
+ return this.queues.get(key)?.length ?? 0;
64
+ }
65
+ /**
66
+ * Whether `key` has a running or pending task. Without a key, whether any key does.
67
+ *
68
+ * @param key - Resource key
69
+ */
70
+ isBusy(key) {
71
+ return key === undefined ? this.queues.size > 0 : this.queues.has(key);
72
+ }
73
+ }
74
+ exports.AsyncLock = AsyncLock;
75
+ /** The place of one acquisition in the queue of one key; once granted, it holds the key. */
76
+ class KeyClaim {
77
+ queues;
78
+ key;
79
+ opts;
80
+ onGranted;
81
+ onDenied;
82
+ holding = false;
83
+ dropped = false;
84
+ queueTimer;
85
+ constructor(queues, key, opts, onGranted, onDenied) {
86
+ this.queues = queues;
87
+ this.key = key;
88
+ this.opts = opts;
89
+ this.onGranted = onGranted;
90
+ this.onDenied = onDenied;
91
+ }
92
+ /**
93
+ * Take the key right away if it is free, otherwise wait in its queue.
94
+ *
95
+ * @returns Whether the key is held. If not, `onGranted` is called once it is, unless the claim
96
+ * is denied.
97
+ */
98
+ join() {
99
+ const { timeout, maxPending, skipQueue } = this.opts;
100
+ const queue = this.queues.get(this.key);
101
+ if (!queue) {
102
+ this.queues.set(this.key, []);
103
+ this.holding = true;
104
+ return true;
105
+ }
106
+ if (queue.length >= maxPending) {
107
+ this.onDenied(new Error(`Too many pending tasks in queue ${this.key}`));
108
+ }
109
+ else {
110
+ if (skipQueue) {
111
+ queue.unshift(this.grant);
112
+ }
113
+ else {
114
+ queue.push(this.grant);
115
+ }
116
+ if (timeout) {
117
+ this.queueTimer = setTimeout(() => this.onDenied(new Error(`async-lock timed out in queue ${this.key}`)), timeout);
118
+ }
119
+ }
120
+ return false;
121
+ }
122
+ /**
123
+ * Leave the queue, or release the key if it is held. Idempotent.
124
+ *
125
+ * @returns The handover of the key to its next waiter. The caller must run it only after it
126
+ * has released all of its keys, so that no waiter starts while a batch is partially released.
127
+ */
128
+ drop() {
129
+ if (this.dropped) {
130
+ return undefined;
131
+ }
132
+ this.dropped = true;
133
+ clearTimeout(this.queueTimer);
134
+ if (this.holding) {
135
+ return this.releaseKey();
136
+ }
137
+ const queue = this.queues.get(this.key);
138
+ const idx = queue?.indexOf(this.grant) ?? -1;
139
+ if (idx >= 0) {
140
+ queue?.splice(idx, 1);
141
+ }
142
+ return undefined;
143
+ }
144
+ releaseKey() {
145
+ const next = this.queues.get(this.key)?.shift();
146
+ if (!next) {
147
+ this.queues.delete(this.key);
148
+ }
149
+ return next;
150
+ }
151
+ // An arrow function, because this exact reference sits in the queue and is removed by drop()
152
+ grant = () => {
153
+ clearTimeout(this.queueTimer);
154
+ this.holding = true;
155
+ if (this.dropped) {
156
+ // Dropped while the key was being handed over to it: pass the key on instead of using it
157
+ this.releaseKey()?.();
158
+ return;
159
+ }
160
+ this.onGranted();
161
+ };
162
+ }
163
+ /**
164
+ * One `acquire` call: its promise, its timers and its claims on all of its keys. The keys are
165
+ * claimed one by one, the task runs once all of them are held and they are released together.
166
+ */
167
+ class Acquisition {
168
+ queues;
169
+ keys;
170
+ opts;
171
+ promise;
172
+ resolve;
173
+ reject;
174
+ task;
175
+ claims = [];
176
+ running = false;
177
+ settled = false;
178
+ queueDeadline = 0;
179
+ occupationTimer;
180
+ executionTimer;
181
+ constructor(queues, keys, task, opts) {
182
+ this.queues = queues;
183
+ this.keys = keys;
184
+ this.opts = opts;
185
+ // Queued tasks are started from the previous task's promise chain; bind to keep our context
186
+ this.task = node_async_hooks_1.AsyncResource.bind(task);
187
+ this.promise = new Promise((resolve, reject) => {
188
+ this.resolve = resolve;
189
+ this.reject = reject;
190
+ });
191
+ }
192
+ /** Start the task right away if all the keys are free, otherwise wait for them. */
193
+ enqueue() {
194
+ const { timeout, maxOccupationTime } = this.opts;
195
+ if (timeout) {
196
+ this.queueDeadline = performance.now() + timeout;
197
+ }
198
+ if (maxOccupationTime) {
199
+ this.occupationTimer = setTimeout(() => this.expire(), maxOccupationTime);
200
+ }
201
+ this.claimKeys(0);
202
+ }
203
+ // Free keys are claimed in a loop, not recursively, so that a large batch cannot overflow the stack
204
+ claimKeys(from) {
205
+ const { maxPending, skipQueue } = this.opts;
206
+ try {
207
+ for (let index = from; index < this.keys.length; index++) {
208
+ // The queue timeout is a budget for waiting for all the keys, not for each one
209
+ const timeout = this.queueDeadline ? Math.max(this.queueDeadline - performance.now(), 1) : 0;
210
+ const claim = new KeyClaim(this.queues, this.keys[index], { timeout, maxPending, skipQueue }, () => this.claimKeys(index + 1), (error) => this.abort(error));
211
+ this.claims.push(claim);
212
+ if (!claim.join()) {
213
+ return;
214
+ }
215
+ }
216
+ this.execute();
217
+ }
218
+ catch (error) {
219
+ this.abort(error);
220
+ }
221
+ }
222
+ execute() {
223
+ const { maxExecutionTime } = this.opts;
224
+ this.running = true;
225
+ if (maxExecutionTime) {
226
+ this.executionTimer = setTimeout(() => this.abort(new Error(`Maximum execution time is exceeded ${this.keys.join(', ')}`)), maxExecutionTime);
227
+ }
228
+ new Promise((resolve) => resolve(this.task())).then((value) => this.finish({ value }), (error) => this.finish({ error }));
229
+ }
230
+ finish(outcome) {
231
+ this.settle(outcome);
232
+ this.release();
233
+ }
234
+ // Reject and release all the keys; a running task is left to finish on its own
235
+ abort(error) {
236
+ this.settle({ error });
237
+ this.release();
238
+ }
239
+ // A running task keeps its keys until it finishes, an unstarted one gives them up
240
+ expire() {
241
+ const keys = this.keys.join(', ');
242
+ if (this.running) {
243
+ this.settle({ error: new Error(`Maximum occupation time is exceeded while executing ${keys}`) });
244
+ }
245
+ else {
246
+ this.abort(new Error(`Maximum occupation time is exceeded in queue ${keys}`));
247
+ }
248
+ }
249
+ settle(outcome) {
250
+ if (this.settled) {
251
+ return;
252
+ }
253
+ this.settled = true;
254
+ clearTimeout(this.occupationTimer);
255
+ if ('error' in outcome) {
256
+ this.reject(outcome.error);
257
+ }
258
+ else {
259
+ this.resolve(outcome.value);
260
+ }
261
+ }
262
+ // Idempotent, so a task that outlives its execution timeout cannot release the keys twice
263
+ release() {
264
+ clearTimeout(this.executionTimer);
265
+ const handovers = this.claims
266
+ .splice(0)
267
+ .reverse()
268
+ .map((claim) => claim.drop());
269
+ for (const handover of handovers) {
270
+ handover?.();
271
+ }
272
+ }
273
+ }
274
+ function validateOptions(opts) {
275
+ if (opts === null || typeof opts !== 'object') {
276
+ throw new TypeError('The options must be an object');
277
+ }
278
+ for (const name of ['timeout', 'maxOccupationTime', 'maxExecutionTime']) {
279
+ const value = opts[name];
280
+ if (value !== undefined && !(Number.isFinite(value) && value >= 0 && value <= MAX_TIMER_MS)) {
281
+ throw new TypeError(`${name} must be a number of milliseconds between 0 and ${MAX_TIMER_MS}`);
282
+ }
283
+ }
284
+ if (opts.skipQueue !== undefined && typeof opts.skipQueue !== 'boolean') {
285
+ throw new TypeError('skipQueue must be a boolean');
286
+ }
287
+ const { maxPending } = opts;
288
+ if (maxPending !== undefined && maxPending !== Infinity && !(Number.isInteger(maxPending) && maxPending >= 0)) {
289
+ throw new TypeError('maxPending must be a non-negative integer or Infinity');
290
+ }
291
+ }
292
+ function stripUndefined(obj) {
293
+ return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined));
294
+ }
295
+ //# sourceMappingURL=lock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lock.js","sourceRoot":"","sources":["../../../lib/lock.ts"],"names":[],"mappings":";;;AAAA,uDAA+C;AAE/C,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,sDAAsD;AACtD,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AA0CjC;;;;;GAKG;AACH,MAAa,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,CA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AI,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACxE,MAAM,IAAI,SAAS,CAAC,6BAA6B,CAAC,CAAC;IACrD,CAAC;IACD,MAAM,EAAC,UAAU,EAAC,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,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.longSleep = longSleep;
4
+ const sleep_js_1 = require("./sleep.js");
5
+ const LONG_SLEEP_THRESHOLD = 5000; // anything over 5000ms will turn into a spin
6
+ /**
7
+ * Sometimes `Promise.delay` or `setTimeout` are inaccurate for large wait
8
+ * times. To safely wait for these long times (e.g. in the 5+ minute range), you
9
+ * can use `longSleep`.
10
+ *
11
+ * You can also pass a `progressCb` option which is a callback function that
12
+ * receives an object with the properties `elapsedMs`, `timeLeft`, and
13
+ * `progress`. This will be called on every wait interval so you can do your
14
+ * wait logging or whatever.
15
+ * @param ms - The number of milliseconds to wait
16
+ * @param options - Options for controlling the long sleep behavior
17
+ */
18
+ async function longSleep(ms, { thresholdMs = LONG_SLEEP_THRESHOLD, intervalMs = 1000, progressCb = null } = {}) {
19
+ if (ms < thresholdMs) {
20
+ return await (0, sleep_js_1.sleep)(ms);
21
+ }
22
+ const endAt = performance.now() + ms;
23
+ let timeLeft;
24
+ let elapsedMs = 0;
25
+ do {
26
+ const pre = performance.now();
27
+ await (0, sleep_js_1.sleep)(intervalMs);
28
+ const post = performance.now();
29
+ timeLeft = endAt - post;
30
+ elapsedMs = elapsedMs + (post - pre);
31
+ if (typeof progressCb === 'function') {
32
+ progressCb({ elapsedMs: Math.round(elapsedMs), timeLeft: Math.round(timeLeft), progress: elapsedMs / ms });
33
+ }
34
+ } while (timeLeft > 0);
35
+ }
36
+ //# sourceMappingURL=long-sleep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"long-sleep.js","sourceRoot":"","sources":["../../../lib/long-sleep.ts"],"names":[],"mappings":";;AAiBA,8BAoBC;AArCD,yCAAiC;AAGjC,MAAM,oBAAoB,GAAG,IAAI,CAAC,CAAC,6CAA6C;AAEhF;;;;;;;;;;;GAWG;AACI,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,IAAA,gBAAK,EAAC,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,IAAA,gBAAK,EAAC,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,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.retry = retry;
4
+ exports.retryInterval = retryInterval;
5
+ const sleep_js_1 = require("./sleep.js");
6
+ /**
7
+ * An async/await way of running a method until it doesn't throw an error
8
+ * @param times - The maximum number of times to retry the function
9
+ * @param fn - The async function to retry
10
+ * @param args - Arguments to pass to the function
11
+ */
12
+ async function retry(times, fn, ...args) {
13
+ let tries = 0;
14
+ let done = false;
15
+ let res = null;
16
+ while (!done && tries < times) {
17
+ tries++;
18
+ try {
19
+ res = await fn(...args);
20
+ done = true;
21
+ }
22
+ catch (err) {
23
+ if (tries >= times) {
24
+ throw err;
25
+ }
26
+ }
27
+ }
28
+ return res;
29
+ }
30
+ /**
31
+ * You can also use `retryInterval` to add a sleep in between retries. This can
32
+ * be useful if you want to throttle how fast we retry.
33
+ * @param times - The maximum number of times to retry the function
34
+ * @param sleepMs - The number of milliseconds to wait between retries
35
+ * @param fn - The async function to retry
36
+ * @param args - Arguments to pass to the function
37
+ */
38
+ async function retryInterval(times, sleepMs, fn, ...args) {
39
+ let count = 0;
40
+ const wrapped = async () => {
41
+ count++;
42
+ let res;
43
+ try {
44
+ res = await fn(...args);
45
+ }
46
+ catch (e) {
47
+ // do not pause when finished the last retry
48
+ if (count !== times) {
49
+ await (0, sleep_js_1.sleep)(sleepMs);
50
+ }
51
+ throw e;
52
+ }
53
+ return res;
54
+ };
55
+ return await retry(times, wrapped);
56
+ }
57
+ //# sourceMappingURL=retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.js","sourceRoot":"","sources":["../../../lib/retry.ts"],"names":[],"mappings":";;AAQA,sBAoBC;AAUD,sCAsBC;AA5DD,yCAAiC;AAEjC;;;;;GAKG;AACI,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;AACI,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,IAAA,gBAAK,EAAC,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,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sleep = sleep;
4
+ const errors_js_1 = require("./errors.js");
5
+ function sleep(arg) {
6
+ const { ms, cancelError } = parseSleepArg(arg);
7
+ let timeoutId;
8
+ let resolveFn;
9
+ let rejectFn;
10
+ const promise = new Promise((resolve, reject) => {
11
+ resolveFn = resolve;
12
+ rejectFn = reject;
13
+ timeoutId = setTimeout(resolve, ms);
14
+ });
15
+ promise.cancel = () => {
16
+ if (timeoutId) {
17
+ clearTimeout(timeoutId);
18
+ timeoutId = undefined;
19
+ }
20
+ if (cancelError === null) {
21
+ resolveFn?.(undefined);
22
+ }
23
+ else {
24
+ let err;
25
+ if (typeof cancelError === 'string' && cancelError) {
26
+ err = new errors_js_1.PromiseCancellationError(cancelError);
27
+ }
28
+ else if (cancelError instanceof Error) {
29
+ err = cancelError;
30
+ }
31
+ else {
32
+ err = new errors_js_1.PromiseCancellationError();
33
+ }
34
+ rejectFn?.(err);
35
+ }
36
+ resolveFn = undefined;
37
+ rejectFn = undefined;
38
+ };
39
+ return promise;
40
+ }
41
+ /** Non-array object values (including class instances); excludes `null` and arrays. */
42
+ function isSleepArgObject(value) {
43
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
44
+ }
45
+ function parseSleepArg(arg) {
46
+ if (typeof arg === 'number') {
47
+ if (!Number.isFinite(arg)) {
48
+ throw new TypeError('sleep: expected a finite number or an object with ms');
49
+ }
50
+ return { ms: arg };
51
+ }
52
+ if (isSleepArgObject(arg)) {
53
+ const ms = arg.ms;
54
+ if (typeof ms !== 'number' || !Number.isFinite(ms)) {
55
+ throw new TypeError('sleep: options.ms must be a finite number');
56
+ }
57
+ return { ms, cancelError: arg.cancelError };
58
+ }
59
+ throw new TypeError('sleep: expected a finite number or an object with ms');
60
+ }
61
+ //# sourceMappingURL=sleep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../../lib/sleep.ts"],"names":[],"mappings":";;AAqBA,sBAmCC;AAxDD,2CAAqD;AAqBrD,SAAgB,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;QAClB,SAAS,GAAG,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACtC,CAAC,CAA6B,CAAC;IAE/B,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE;QACpB,IAAI,SAAS,EAAE,CAAC;YACd,YAAY,CAAC,SAAS,CAAC,CAAC;YACxB,SAAS,GAAG,SAAS,CAAC;QACxB,CAAC;QACD,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;YACzB,SAAS,EAAE,CAAC,SAAS,CAAC,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,IAAI,GAAU,CAAC;YACf,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,EAAE,CAAC;gBACnD,GAAG,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