appium-mac2-driver 4.6.0 → 4.6.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.
- package/CHANGELOG.md +6 -0
- package/WebDriverAgentMac/WebDriverAgentRunner/WebDriverAgentRunner.m +3 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/LICENSE +203 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/README.md +258 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/asyncfilter.d.ts +9 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/asyncfilter.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/asyncfilter.js +35 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/asyncfilter.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/asyncmap.d.ts +9 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/asyncmap.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/asyncmap.js +23 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/asyncmap.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/errors.d.ts +9 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/errors.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/errors.js +20 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/errors.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/index.d.ts +12 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/index.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/index.js +24 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/index.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/limit-function.d.ts +3 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/limit-function.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/limit-function.js +15 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/limit-function.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/lock.d.ts +74 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/lock.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/lock.js +295 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/lock.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/long-sleep.d.ts +15 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/long-sleep.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/long-sleep.js +36 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/long-sleep.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/retry.d.ts +17 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/retry.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/retry.js +57 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/retry.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/sleep.d.ts +20 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/sleep.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/sleep.js +61 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/sleep.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/types.d.ts +84 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/types.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/types.js +3 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/types.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/wait-for-condition.d.ts +18 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/wait-for-condition.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/wait-for-condition.js +51 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/wait-for-condition.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/with-timeout.d.ts +16 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/with-timeout.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/with-timeout.js +45 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/lib/with-timeout.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/cjs/package.json +3 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/asyncfilter.d.ts +9 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/asyncfilter.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/asyncfilter.js +32 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/asyncfilter.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/asyncmap.d.ts +9 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/asyncmap.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/asyncmap.js +20 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/asyncmap.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/errors.d.ts +9 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/errors.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/errors.js +15 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/errors.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/index.d.ts +12 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/index.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/index.js +10 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/index.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/limit-function.d.ts +3 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/limit-function.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/limit-function.js +12 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/limit-function.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/lock.d.ts +74 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/lock.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/lock.js +291 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/lock.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/long-sleep.d.ts +15 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/long-sleep.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/long-sleep.js +33 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/long-sleep.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/retry.d.ts +17 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/retry.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/retry.js +53 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/retry.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/sleep.d.ts +20 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/sleep.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/sleep.js +58 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/sleep.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/types.d.ts +84 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/types.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/types.js +2 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/types.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/wait-for-condition.d.ts +18 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/wait-for-condition.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/wait-for-condition.js +48 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/wait-for-condition.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/with-timeout.d.ts +16 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/with-timeout.d.ts.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/with-timeout.js +42 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/lib/with-timeout.js.map +1 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/build/esm/package.json +3 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/lib/asyncfilter.ts +38 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/lib/asyncmap.ts +29 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/lib/errors.ts +15 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/lib/index.ts +21 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/lib/limit-function.ts +18 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/lib/lock.ts +360 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/lib/long-sleep.ts +38 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/lib/retry.ts +61 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/lib/sleep.ts +79 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/lib/types.ts +88 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/lib/wait-for-condition.ts +52 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/lib/with-timeout.ts +43 -0
- package/node_modules/@appium/base-driver/node_modules/asyncbox/package.json +74 -0
- package/node_modules/@appium/support/node_modules/asyncbox/LICENSE +203 -0
- package/node_modules/@appium/support/node_modules/asyncbox/README.md +258 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/asyncfilter.d.ts +9 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/asyncfilter.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/asyncfilter.js +35 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/asyncfilter.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/asyncmap.d.ts +9 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/asyncmap.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/asyncmap.js +23 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/asyncmap.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/errors.d.ts +9 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/errors.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/errors.js +20 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/errors.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/index.d.ts +12 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/index.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/index.js +24 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/index.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/limit-function.d.ts +3 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/limit-function.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/limit-function.js +15 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/limit-function.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/lock.d.ts +74 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/lock.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/lock.js +295 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/lock.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/long-sleep.d.ts +15 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/long-sleep.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/long-sleep.js +36 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/long-sleep.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/retry.d.ts +17 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/retry.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/retry.js +57 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/retry.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/sleep.d.ts +20 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/sleep.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/sleep.js +61 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/sleep.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/types.d.ts +84 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/types.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/types.js +3 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/types.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/wait-for-condition.d.ts +18 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/wait-for-condition.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/wait-for-condition.js +51 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/wait-for-condition.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/with-timeout.d.ts +16 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/with-timeout.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/with-timeout.js +45 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/lib/with-timeout.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/cjs/package.json +3 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/asyncfilter.d.ts +9 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/asyncfilter.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/asyncfilter.js +32 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/asyncfilter.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/asyncmap.d.ts +9 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/asyncmap.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/asyncmap.js +20 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/asyncmap.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/errors.d.ts +9 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/errors.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/errors.js +15 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/errors.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/index.d.ts +12 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/index.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/index.js +10 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/index.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/limit-function.d.ts +3 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/limit-function.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/limit-function.js +12 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/limit-function.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/lock.d.ts +74 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/lock.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/lock.js +291 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/lock.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/long-sleep.d.ts +15 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/long-sleep.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/long-sleep.js +33 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/long-sleep.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/retry.d.ts +17 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/retry.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/retry.js +53 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/retry.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/sleep.d.ts +20 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/sleep.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/sleep.js +58 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/sleep.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/types.d.ts +84 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/types.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/types.js +2 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/types.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/wait-for-condition.d.ts +18 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/wait-for-condition.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/wait-for-condition.js +48 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/wait-for-condition.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/with-timeout.d.ts +16 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/with-timeout.d.ts.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/with-timeout.js +42 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/with-timeout.js.map +1 -0
- package/node_modules/@appium/support/node_modules/asyncbox/build/esm/package.json +3 -0
- package/node_modules/@appium/support/node_modules/asyncbox/lib/asyncfilter.ts +38 -0
- package/node_modules/@appium/support/node_modules/asyncbox/lib/asyncmap.ts +29 -0
- package/node_modules/@appium/support/node_modules/asyncbox/lib/errors.ts +15 -0
- package/node_modules/@appium/support/node_modules/asyncbox/lib/index.ts +21 -0
- package/node_modules/@appium/support/node_modules/asyncbox/lib/limit-function.ts +18 -0
- package/node_modules/@appium/support/node_modules/asyncbox/lib/lock.ts +360 -0
- package/node_modules/@appium/support/node_modules/asyncbox/lib/long-sleep.ts +38 -0
- package/node_modules/@appium/support/node_modules/asyncbox/lib/retry.ts +61 -0
- package/node_modules/@appium/support/node_modules/asyncbox/lib/sleep.ts +79 -0
- package/node_modules/@appium/support/node_modules/asyncbox/lib/types.ts +88 -0
- package/node_modules/@appium/support/node_modules/asyncbox/lib/wait-for-condition.ts +52 -0
- package/node_modules/@appium/support/node_modules/asyncbox/lib/with-timeout.ts +43 -0
- package/node_modules/@appium/support/node_modules/asyncbox/package.json +74 -0
- package/node_modules/asyncbox/README.md +18 -4
- package/node_modules/asyncbox/build/cjs/lib/errors.d.ts +20 -2
- package/node_modules/asyncbox/build/cjs/lib/errors.d.ts.map +1 -1
- package/node_modules/asyncbox/build/cjs/lib/errors.js +41 -6
- package/node_modules/asyncbox/build/cjs/lib/errors.js.map +1 -1
- package/node_modules/asyncbox/build/cjs/lib/index.d.ts +1 -1
- package/node_modules/asyncbox/build/cjs/lib/index.d.ts.map +1 -1
- package/node_modules/asyncbox/build/cjs/lib/index.js +5 -1
- package/node_modules/asyncbox/build/cjs/lib/index.js.map +1 -1
- package/node_modules/asyncbox/build/cjs/lib/lock.d.ts.map +1 -1
- package/node_modules/asyncbox/build/cjs/lib/lock.js +6 -5
- package/node_modules/asyncbox/build/cjs/lib/lock.js.map +1 -1
- package/node_modules/asyncbox/build/cjs/lib/wait-for-condition.d.ts +1 -1
- package/node_modules/asyncbox/build/cjs/lib/wait-for-condition.d.ts.map +1 -1
- package/node_modules/asyncbox/build/cjs/lib/wait-for-condition.js +4 -3
- package/node_modules/asyncbox/build/cjs/lib/wait-for-condition.js.map +1 -1
- package/node_modules/asyncbox/build/esm/lib/errors.d.ts +20 -2
- package/node_modules/asyncbox/build/esm/lib/errors.d.ts.map +1 -1
- package/node_modules/asyncbox/build/esm/lib/errors.js +36 -5
- package/node_modules/asyncbox/build/esm/lib/errors.js.map +1 -1
- package/node_modules/asyncbox/build/esm/lib/index.d.ts +1 -1
- package/node_modules/asyncbox/build/esm/lib/index.d.ts.map +1 -1
- package/node_modules/asyncbox/build/esm/lib/index.js +1 -1
- package/node_modules/asyncbox/build/esm/lib/index.js.map +1 -1
- package/node_modules/asyncbox/build/esm/lib/lock.d.ts.map +1 -1
- package/node_modules/asyncbox/build/esm/lib/lock.js +6 -5
- package/node_modules/asyncbox/build/esm/lib/lock.js.map +1 -1
- package/node_modules/asyncbox/build/esm/lib/wait-for-condition.d.ts +1 -1
- package/node_modules/asyncbox/build/esm/lib/wait-for-condition.d.ts.map +1 -1
- package/node_modules/asyncbox/build/esm/lib/wait-for-condition.js +4 -3
- package/node_modules/asyncbox/build/esm/lib/wait-for-condition.js.map +1 -1
- package/node_modules/asyncbox/lib/errors.ts +41 -5
- package/node_modules/asyncbox/lib/index.ts +8 -1
- package/node_modules/asyncbox/lib/lock.ts +7 -5
- package/node_modules/asyncbox/lib/wait-for-condition.ts +4 -3
- package/node_modules/asyncbox/package.json +1 -1
- package/package.json +2 -2
package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/wait-for-condition.js
ADDED
|
@@ -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
|
package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/wait-for-condition.js.map
ADDED
|
@@ -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
|
package/node_modules/@appium/support/node_modules/asyncbox/build/esm/lib/with-timeout.d.ts.map
ADDED
|
@@ -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"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { TimeoutError } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves with `promise` or rejects if it does not settle before `timeoutMs`.
|
|
4
|
+
*
|
|
5
|
+
* If the deadline passes first: with no third argument (or a falsy non-error value), rejects
|
|
6
|
+
* with {@link TimeoutError} whose message includes `timeoutMs`; with a non-empty string,
|
|
7
|
+
* rejects with {@link TimeoutError} using that message; with an `Error` instance, rejects
|
|
8
|
+
* with that same instance.
|
|
9
|
+
*
|
|
10
|
+
* @param promise - Promise to race against the timeout.
|
|
11
|
+
* @param timeoutMs - Maximum time in milliseconds before rejecting if `promise` has not settled.
|
|
12
|
+
* @param messageOrError - Optional override for the timeout rejection: custom {@link TimeoutError}
|
|
13
|
+
* message when the string is non-empty, or an existing `Error` to reject with verbatim.
|
|
14
|
+
* Omitted, `undefined`, or other falsy non-error values use the default timeout message (includes `timeoutMs`).
|
|
15
|
+
*/
|
|
16
|
+
export async function withTimeout(promise, timeoutMs, messageOrError) {
|
|
17
|
+
let timer = null;
|
|
18
|
+
try {
|
|
19
|
+
return await Promise.race([
|
|
20
|
+
promise,
|
|
21
|
+
new Promise((_resolve, reject) => {
|
|
22
|
+
timer = setTimeout(() => {
|
|
23
|
+
if (typeof messageOrError === 'string' && messageOrError) {
|
|
24
|
+
reject(new TimeoutError(messageOrError));
|
|
25
|
+
}
|
|
26
|
+
else if (!messageOrError) {
|
|
27
|
+
reject(new TimeoutError(`Operation timed out after ${timeoutMs}ms`));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
reject(messageOrError);
|
|
31
|
+
}
|
|
32
|
+
}, timeoutMs);
|
|
33
|
+
}),
|
|
34
|
+
]);
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
if (timer) {
|
|
38
|
+
clearTimeout(timer);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=with-timeout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-timeout.js","sourceRoot":"","sources":["../../../lib/with-timeout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAmB,EACnB,SAAiB,EACjB,cAA+B;IAE/B,IAAI,KAAK,GAA0B,IAAI,CAAC;IACxC,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC;YACxB,OAAO;YACP,IAAI,OAAO,CAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE;gBAClC,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;oBACtB,IAAI,OAAO,cAAc,KAAK,QAAQ,IAAI,cAAc,EAAE,CAAC;wBACzD,MAAM,CAAC,IAAI,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC;oBAC3C,CAAC;yBAAM,IAAI,CAAC,cAAc,EAAE,CAAC;wBAC3B,MAAM,CAAC,IAAI,YAAY,CAAC,6BAA6B,SAAS,IAAI,CAAC,CAAC,CAAC;oBACvE,CAAC;yBAAM,CAAC;wBACN,MAAM,CAAC,cAAc,CAAC,CAAC;oBACzB,CAAC;gBACH,CAAC,EAAE,SAAS,CAAC,CAAC;YAChB,CAAC,CAAC;SACH,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,IAAI,KAAK,EAAE,CAAC;YACV,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {getLimitFunction} from './limit-function.js';
|
|
2
|
+
import type {MapFilterOptions} from './types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Similar to `Array.prototype.filter`; runs in parallel, serial, or with custom concurrency pool
|
|
6
|
+
* @param coll - The collection to filter
|
|
7
|
+
* @param filter - The function to test each element
|
|
8
|
+
* @param options - Options for controlling parallelism (default: true - fully parallel)
|
|
9
|
+
*/
|
|
10
|
+
export async function asyncfilter<T>(
|
|
11
|
+
coll: T[],
|
|
12
|
+
filter: (value: T) => boolean | Promise<boolean>,
|
|
13
|
+
options: MapFilterOptions = true,
|
|
14
|
+
): Promise<T[]> {
|
|
15
|
+
if (options === null) {
|
|
16
|
+
throw new Error('Options cannot be null');
|
|
17
|
+
}
|
|
18
|
+
// limitFunction requires the filter to always return a promise
|
|
19
|
+
const filterAsync = async (value: T): Promise<boolean> => filter(value);
|
|
20
|
+
if (options === false) {
|
|
21
|
+
return coll.reduce<Promise<T[]>>(async (accP, item) => {
|
|
22
|
+
const acc = await accP;
|
|
23
|
+
if (await filterAsync(item)) {
|
|
24
|
+
acc.push(item);
|
|
25
|
+
}
|
|
26
|
+
return acc;
|
|
27
|
+
}, Promise.resolve([]));
|
|
28
|
+
}
|
|
29
|
+
const adjustedFilter =
|
|
30
|
+
options === true ? filterAsync : (await getLimitFunction())(filterAsync, {concurrency: options.concurrency});
|
|
31
|
+
const bools = await Promise.all(coll.map(adjustedFilter));
|
|
32
|
+
return coll.reduce<T[]>((acc, item, i) => {
|
|
33
|
+
if (bools[i]) {
|
|
34
|
+
acc.push(item);
|
|
35
|
+
}
|
|
36
|
+
return acc;
|
|
37
|
+
}, []);
|
|
38
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {getLimitFunction} from './limit-function.js';
|
|
2
|
+
import type {MapFilterOptions} from './types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Similar to `Array.prototype.map`; runs in parallel, serial, or with custom concurrency pool
|
|
6
|
+
* @param coll - The collection to map over
|
|
7
|
+
* @param mapper - The function to apply to each element
|
|
8
|
+
* @param options - Options for controlling parallelism (default: true - fully parallel)
|
|
9
|
+
*/
|
|
10
|
+
export async function asyncmap<T, R>(
|
|
11
|
+
coll: T[],
|
|
12
|
+
mapper: (value: T) => R | Promise<R>,
|
|
13
|
+
options: MapFilterOptions = true,
|
|
14
|
+
): Promise<R[]> {
|
|
15
|
+
if (options === null) {
|
|
16
|
+
throw new Error('Options cannot be null');
|
|
17
|
+
}
|
|
18
|
+
// limitFunction requires the mapper to always return a promise
|
|
19
|
+
const mapperAsync = async (value: T): Promise<R> => mapper(value);
|
|
20
|
+
if (options === false) {
|
|
21
|
+
return coll.reduce<Promise<R[]>>(
|
|
22
|
+
async (acc, item) => [...(await acc), await mapperAsync(item)],
|
|
23
|
+
Promise.resolve([]),
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
const adjustedMapper =
|
|
27
|
+
options === true ? mapperAsync : (await getLimitFunction())(mapperAsync, {concurrency: options.concurrency});
|
|
28
|
+
return Promise.all(coll.map(adjustedMapper));
|
|
29
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Error thrown by {@link withTimeout} when the deadline is exceeded. */
|
|
2
|
+
export class TimeoutError extends Error {
|
|
3
|
+
constructor(message?: string) {
|
|
4
|
+
super(message ?? 'Operation timed out');
|
|
5
|
+
this.name = 'TimeoutError';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Thrown when a promise is cancelled via `cancel`. */
|
|
10
|
+
export class PromiseCancellationError extends Error {
|
|
11
|
+
constructor(message: string = 'Promise cancelled') {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = 'PromiseCancellationError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export {TimeoutError, PromiseCancellationError} from './errors.js';
|
|
2
|
+
export {sleep} from './sleep.js';
|
|
3
|
+
export {withTimeout} from './with-timeout.js';
|
|
4
|
+
export {longSleep} from './long-sleep.js';
|
|
5
|
+
export {retry, retryInterval} from './retry.js';
|
|
6
|
+
export {asyncmap} from './asyncmap.js';
|
|
7
|
+
export {asyncfilter} from './asyncfilter.js';
|
|
8
|
+
export {waitForCondition} from './wait-for-condition.js';
|
|
9
|
+
export {AsyncLock} from './lock.js';
|
|
10
|
+
|
|
11
|
+
export type {AsyncLockOptions, AcquireOptions} from './lock.js';
|
|
12
|
+
export type {
|
|
13
|
+
CancellablePromise,
|
|
14
|
+
Progress,
|
|
15
|
+
ProgressCallback,
|
|
16
|
+
LongSleepOptions,
|
|
17
|
+
MapFilterOptions,
|
|
18
|
+
SleepArg,
|
|
19
|
+
SleepOptions,
|
|
20
|
+
WaitForConditionOptions,
|
|
21
|
+
} from './types.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type {limitFunction} from 'p-limit';
|
|
2
|
+
|
|
3
|
+
type PLimitModule = {limitFunction: typeof limitFunction};
|
|
4
|
+
|
|
5
|
+
// p-limit is ESM-only. tsc downlevels a plain `import()` in CommonJS output into a
|
|
6
|
+
// require()-in-a-microtask, which still hits Node's require(esm) interop and can race with a
|
|
7
|
+
// concurrent dynamic import() of the same module elsewhere in the process
|
|
8
|
+
// (ERR_REQUIRE_ESM_RACE_CONDITION). Route through `new Function` so tsc can't see or rewrite the
|
|
9
|
+
// import() call, keeping it a genuine native dynamic import in both the ESM and CJS builds.
|
|
10
|
+
const dynamicImport = new Function('specifier', 'return import(specifier)') as (
|
|
11
|
+
specifier: string,
|
|
12
|
+
) => Promise<PLimitModule>;
|
|
13
|
+
|
|
14
|
+
let limitFunctionPromise: Promise<PLimitModule> | undefined;
|
|
15
|
+
export async function getLimitFunction() {
|
|
16
|
+
limitFunctionPromise ??= dynamicImport('p-limit');
|
|
17
|
+
return (await limitFunctionPromise).limitFunction;
|
|
18
|
+
}
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import {AsyncResource} from 'node:async_hooks';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_MAX_PENDING = 1000;
|
|
4
|
+
// setTimeout fires after 1 ms for anything above this
|
|
5
|
+
const MAX_TIMER_MS = 2 ** 31 - 1;
|
|
6
|
+
|
|
7
|
+
/** Options shared by the {@link AsyncLock} constructor and {@link AsyncLock.acquire}. */
|
|
8
|
+
export interface AsyncLockOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Max ms a task may wait in the queue before failing. `0` means never.
|
|
11
|
+
* @default 0
|
|
12
|
+
*/
|
|
13
|
+
timeout?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Max ms between calling `acquire` and the task finishing (queue wait included). `0` means never.
|
|
16
|
+
* @default 0
|
|
17
|
+
*/
|
|
18
|
+
maxOccupationTime?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Max ms the task may run once it holds the lock; the lock is then released. `0` means never.
|
|
21
|
+
* @default 0
|
|
22
|
+
*/
|
|
23
|
+
maxExecutionTime?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Max number of tasks waiting per key; further ones are rejected right away. `0` rejects every
|
|
26
|
+
* task that would have to wait.
|
|
27
|
+
* @default 1000
|
|
28
|
+
*/
|
|
29
|
+
maxPending?: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Per-call options of {@link AsyncLock.acquire}; override the constructor ones. */
|
|
33
|
+
export interface AcquireOptions extends AsyncLockOptions {
|
|
34
|
+
/**
|
|
35
|
+
* Put the task at the front of the queue instead of the back.
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
skipQueue?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type Task<T> = () => T | PromiseLike<T>;
|
|
42
|
+
type Outcome<T> = {value: T} | {error: unknown};
|
|
43
|
+
type Queues = Map<string, Array<() => void>>;
|
|
44
|
+
type ResolvedOptions = Required<AsyncLockOptions> & {skipQueue?: boolean};
|
|
45
|
+
type ClaimOptions = Pick<ResolvedOptions, 'timeout' | 'maxPending' | 'skipQueue'>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Promise-based mutex keyed by string. Tasks with the same key run one at a time, in FIFO order.
|
|
49
|
+
*
|
|
50
|
+
* Each task runs in the async context (`AsyncLocalStorage`) of the code that called
|
|
51
|
+
* {@link AsyncLock.acquire}, not in the context of the task that held the lock before it.
|
|
52
|
+
*/
|
|
53
|
+
export class AsyncLock {
|
|
54
|
+
private readonly queues: Queues = new Map();
|
|
55
|
+
private readonly defaults: Required<AsyncLockOptions>;
|
|
56
|
+
|
|
57
|
+
constructor(opts: AsyncLockOptions = {}) {
|
|
58
|
+
validateOptions(opts);
|
|
59
|
+
this.defaults = {
|
|
60
|
+
timeout: 0,
|
|
61
|
+
maxOccupationTime: 0,
|
|
62
|
+
maxExecutionTime: 0,
|
|
63
|
+
maxPending: DEFAULT_MAX_PENDING,
|
|
64
|
+
...stripUndefined(opts),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Run `fn` once the lock for `key` is free and release the lock when it settles.
|
|
70
|
+
*
|
|
71
|
+
* Multiple keys are held together. They are acquired one by one in sorted order, whatever order
|
|
72
|
+
* they are given in, so that overlapping calls cannot deadlock; duplicates are ignored. Keys that
|
|
73
|
+
* are already held stay held while a later one is awaited. `timeout` and `maxOccupationTime` are
|
|
74
|
+
* budgets for the whole call, while `maxExecutionTime` counts from the moment all the keys are
|
|
75
|
+
* held and releases all of them.
|
|
76
|
+
*
|
|
77
|
+
* @param key - Resource key, or a non-empty array of keys
|
|
78
|
+
* @param fn - Task to run while holding the lock; may be sync or async
|
|
79
|
+
* @param opts - Per-call options
|
|
80
|
+
* @returns The result of `fn`
|
|
81
|
+
* @throws {TypeError} Synchronously, if an argument is invalid
|
|
82
|
+
*/
|
|
83
|
+
acquire<T>(key: string | readonly string[], fn: Task<T>, opts: AcquireOptions = {}): Promise<T> {
|
|
84
|
+
if (typeof fn !== 'function') {
|
|
85
|
+
throw new TypeError('You must pass a function to execute');
|
|
86
|
+
}
|
|
87
|
+
if (
|
|
88
|
+
typeof key !== 'string' &&
|
|
89
|
+
!(Array.isArray(key) && key.length > 0 && [...key].every((k) => typeof k === 'string'))
|
|
90
|
+
) {
|
|
91
|
+
throw new TypeError('The key must be a string or a non-empty array of strings');
|
|
92
|
+
}
|
|
93
|
+
validateOptions(opts);
|
|
94
|
+
// A canonical order keeps overlapping multi-key calls, e.g. ['a', 'b'] and ['b', 'a'], from deadlocking
|
|
95
|
+
const keys = typeof key === 'string' ? [key] : [...new Set(key)].sort();
|
|
96
|
+
const acquisition = new Acquisition(this.queues, keys, fn, {...this.defaults, ...stripUndefined(opts)});
|
|
97
|
+
acquisition.enqueue();
|
|
98
|
+
return acquisition.promise;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Number of tasks waiting for `key`, not counting the running one.
|
|
103
|
+
*
|
|
104
|
+
* @param key - Resource key
|
|
105
|
+
*/
|
|
106
|
+
getQueueLength(key: string): number {
|
|
107
|
+
return this.queues.get(key)?.length ?? 0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Whether `key` has a running or pending task. Without a key, whether any key does.
|
|
112
|
+
*
|
|
113
|
+
* @param key - Resource key
|
|
114
|
+
*/
|
|
115
|
+
isBusy(key?: string): boolean {
|
|
116
|
+
return key === undefined ? this.queues.size > 0 : this.queues.has(key);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The place of one acquisition in the queue of one key; once granted, it holds the key. */
|
|
121
|
+
class KeyClaim {
|
|
122
|
+
private holding = false;
|
|
123
|
+
private dropped = false;
|
|
124
|
+
private queueTimer?: NodeJS.Timeout;
|
|
125
|
+
|
|
126
|
+
constructor(
|
|
127
|
+
private readonly queues: Queues,
|
|
128
|
+
private readonly key: string,
|
|
129
|
+
private readonly opts: ClaimOptions,
|
|
130
|
+
private readonly onGranted: () => void,
|
|
131
|
+
private readonly onDenied: (error: Error) => void,
|
|
132
|
+
) {}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Take the key right away if it is free, otherwise wait in its queue.
|
|
136
|
+
*
|
|
137
|
+
* @returns Whether the key is held. If not, `onGranted` is called once it is, unless the claim
|
|
138
|
+
* is denied.
|
|
139
|
+
*/
|
|
140
|
+
join(): boolean {
|
|
141
|
+
const {timeout, maxPending, skipQueue} = this.opts;
|
|
142
|
+
const queue = this.queues.get(this.key);
|
|
143
|
+
if (!queue) {
|
|
144
|
+
this.queues.set(this.key, []);
|
|
145
|
+
this.holding = true;
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
if (queue.length >= maxPending) {
|
|
149
|
+
this.onDenied(new Error(`Too many pending tasks in queue ${this.key}`));
|
|
150
|
+
} else {
|
|
151
|
+
if (skipQueue) {
|
|
152
|
+
queue.unshift(this.grant);
|
|
153
|
+
} else {
|
|
154
|
+
queue.push(this.grant);
|
|
155
|
+
}
|
|
156
|
+
if (timeout) {
|
|
157
|
+
this.queueTimer = setTimeout(
|
|
158
|
+
() => this.onDenied(new Error(`async-lock timed out in queue ${this.key}`)),
|
|
159
|
+
timeout,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Leave the queue, or release the key if it is held. Idempotent.
|
|
168
|
+
*
|
|
169
|
+
* @returns The handover of the key to its next waiter. The caller must run it only after it
|
|
170
|
+
* has released all of its keys, so that no waiter starts while a batch is partially released.
|
|
171
|
+
*/
|
|
172
|
+
drop(): (() => void) | undefined {
|
|
173
|
+
if (this.dropped) {
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
this.dropped = true;
|
|
177
|
+
clearTimeout(this.queueTimer);
|
|
178
|
+
if (this.holding) {
|
|
179
|
+
return this.releaseKey();
|
|
180
|
+
}
|
|
181
|
+
const queue = this.queues.get(this.key);
|
|
182
|
+
const idx = queue?.indexOf(this.grant) ?? -1;
|
|
183
|
+
if (idx >= 0) {
|
|
184
|
+
queue?.splice(idx, 1);
|
|
185
|
+
}
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
private releaseKey(): (() => void) | undefined {
|
|
190
|
+
const next = this.queues.get(this.key)?.shift();
|
|
191
|
+
if (!next) {
|
|
192
|
+
this.queues.delete(this.key);
|
|
193
|
+
}
|
|
194
|
+
return next;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// An arrow function, because this exact reference sits in the queue and is removed by drop()
|
|
198
|
+
private readonly grant = (): void => {
|
|
199
|
+
clearTimeout(this.queueTimer);
|
|
200
|
+
this.holding = true;
|
|
201
|
+
if (this.dropped) {
|
|
202
|
+
// Dropped while the key was being handed over to it: pass the key on instead of using it
|
|
203
|
+
this.releaseKey()?.();
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
this.onGranted();
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* One `acquire` call: its promise, its timers and its claims on all of its keys. The keys are
|
|
212
|
+
* claimed one by one, the task runs once all of them are held and they are released together.
|
|
213
|
+
*/
|
|
214
|
+
class Acquisition<T> {
|
|
215
|
+
readonly promise: Promise<T>;
|
|
216
|
+
private resolve!: (value: T) => void;
|
|
217
|
+
private reject!: (error: unknown) => void;
|
|
218
|
+
private readonly task: Task<T>;
|
|
219
|
+
private readonly claims: KeyClaim[] = [];
|
|
220
|
+
private running = false;
|
|
221
|
+
private settled = false;
|
|
222
|
+
private queueDeadline = 0;
|
|
223
|
+
private occupationTimer?: NodeJS.Timeout;
|
|
224
|
+
private executionTimer?: NodeJS.Timeout;
|
|
225
|
+
|
|
226
|
+
constructor(
|
|
227
|
+
private readonly queues: Queues,
|
|
228
|
+
private readonly keys: string[],
|
|
229
|
+
task: Task<T>,
|
|
230
|
+
private readonly opts: ResolvedOptions,
|
|
231
|
+
) {
|
|
232
|
+
// Queued tasks are started from the previous task's promise chain; bind to keep our context
|
|
233
|
+
this.task = AsyncResource.bind(task);
|
|
234
|
+
this.promise = new Promise<T>((resolve, reject) => {
|
|
235
|
+
this.resolve = resolve;
|
|
236
|
+
this.reject = reject;
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** Start the task right away if all the keys are free, otherwise wait for them. */
|
|
241
|
+
enqueue(): void {
|
|
242
|
+
const {timeout, maxOccupationTime} = this.opts;
|
|
243
|
+
if (timeout) {
|
|
244
|
+
this.queueDeadline = performance.now() + timeout;
|
|
245
|
+
}
|
|
246
|
+
if (maxOccupationTime) {
|
|
247
|
+
this.occupationTimer = setTimeout(() => this.expire(), maxOccupationTime);
|
|
248
|
+
}
|
|
249
|
+
this.claimKeys(0);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Free keys are claimed in a loop, not recursively, so that a large batch cannot overflow the stack
|
|
253
|
+
private claimKeys(from: number): void {
|
|
254
|
+
const {maxPending, skipQueue} = this.opts;
|
|
255
|
+
try {
|
|
256
|
+
for (let index = from; index < this.keys.length; index++) {
|
|
257
|
+
// The queue timeout is a budget for waiting for all the keys, not for each one
|
|
258
|
+
const timeout = this.queueDeadline ? Math.max(this.queueDeadline - performance.now(), 1) : 0;
|
|
259
|
+
const claim = new KeyClaim(
|
|
260
|
+
this.queues,
|
|
261
|
+
this.keys[index],
|
|
262
|
+
{timeout, maxPending, skipQueue},
|
|
263
|
+
() => this.claimKeys(index + 1),
|
|
264
|
+
(error) => this.abort(error),
|
|
265
|
+
);
|
|
266
|
+
this.claims.push(claim);
|
|
267
|
+
if (!claim.join()) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
this.execute();
|
|
272
|
+
} catch (error) {
|
|
273
|
+
this.abort(error);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
private execute(): void {
|
|
278
|
+
const {maxExecutionTime} = this.opts;
|
|
279
|
+
this.running = true;
|
|
280
|
+
if (maxExecutionTime) {
|
|
281
|
+
this.executionTimer = setTimeout(
|
|
282
|
+
() => this.abort(new Error(`Maximum execution time is exceeded ${this.keys.join(', ')}`)),
|
|
283
|
+
maxExecutionTime,
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
new Promise<T>((resolve) => resolve(this.task())).then(
|
|
287
|
+
(value) => this.finish({value}),
|
|
288
|
+
(error) => this.finish({error}),
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
private finish(outcome: Outcome<T>): void {
|
|
293
|
+
this.settle(outcome);
|
|
294
|
+
this.release();
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Reject and release all the keys; a running task is left to finish on its own
|
|
298
|
+
private abort(error: unknown): void {
|
|
299
|
+
this.settle({error});
|
|
300
|
+
this.release();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// A running task keeps its keys until it finishes, an unstarted one gives them up
|
|
304
|
+
private expire(): void {
|
|
305
|
+
const keys = this.keys.join(', ');
|
|
306
|
+
if (this.running) {
|
|
307
|
+
this.settle({error: new Error(`Maximum occupation time is exceeded while executing ${keys}`)});
|
|
308
|
+
} else {
|
|
309
|
+
this.abort(new Error(`Maximum occupation time is exceeded in queue ${keys}`));
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
private settle(outcome: Outcome<T>): void {
|
|
314
|
+
if (this.settled) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
this.settled = true;
|
|
318
|
+
clearTimeout(this.occupationTimer);
|
|
319
|
+
if ('error' in outcome) {
|
|
320
|
+
this.reject(outcome.error);
|
|
321
|
+
} else {
|
|
322
|
+
this.resolve(outcome.value);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Idempotent, so a task that outlives its execution timeout cannot release the keys twice
|
|
327
|
+
private release(): void {
|
|
328
|
+
clearTimeout(this.executionTimer);
|
|
329
|
+
const handovers = this.claims
|
|
330
|
+
.splice(0)
|
|
331
|
+
.reverse()
|
|
332
|
+
.map((claim) => claim.drop());
|
|
333
|
+
for (const handover of handovers) {
|
|
334
|
+
handover?.();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function validateOptions(opts: AcquireOptions): void {
|
|
340
|
+
if (opts === null || typeof opts !== 'object') {
|
|
341
|
+
throw new TypeError('The options must be an object');
|
|
342
|
+
}
|
|
343
|
+
for (const name of ['timeout', 'maxOccupationTime', 'maxExecutionTime'] as const) {
|
|
344
|
+
const value = opts[name];
|
|
345
|
+
if (value !== undefined && !(Number.isFinite(value) && value >= 0 && value <= MAX_TIMER_MS)) {
|
|
346
|
+
throw new TypeError(`${name} must be a number of milliseconds between 0 and ${MAX_TIMER_MS}`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
if (opts.skipQueue !== undefined && typeof opts.skipQueue !== 'boolean') {
|
|
350
|
+
throw new TypeError('skipQueue must be a boolean');
|
|
351
|
+
}
|
|
352
|
+
const {maxPending} = opts;
|
|
353
|
+
if (maxPending !== undefined && maxPending !== Infinity && !(Number.isInteger(maxPending) && maxPending >= 0)) {
|
|
354
|
+
throw new TypeError('maxPending must be a non-negative integer or Infinity');
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function stripUndefined<T extends object>(obj: T): Partial<T> {
|
|
359
|
+
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined)) as Partial<T>;
|
|
360
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {sleep} from './sleep.js';
|
|
2
|
+
import type {LongSleepOptions} from './types.js';
|
|
3
|
+
|
|
4
|
+
const LONG_SLEEP_THRESHOLD = 5000; // anything over 5000ms will turn into a spin
|
|
5
|
+
|
|
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
|
+
export async function longSleep(
|
|
19
|
+
ms: number,
|
|
20
|
+
{thresholdMs = LONG_SLEEP_THRESHOLD, intervalMs = 1000, progressCb = null}: LongSleepOptions = {},
|
|
21
|
+
): Promise<void> {
|
|
22
|
+
if (ms < thresholdMs) {
|
|
23
|
+
return await sleep(ms);
|
|
24
|
+
}
|
|
25
|
+
const endAt = performance.now() + ms;
|
|
26
|
+
let timeLeft: number;
|
|
27
|
+
let elapsedMs = 0;
|
|
28
|
+
do {
|
|
29
|
+
const pre = performance.now();
|
|
30
|
+
await sleep(intervalMs);
|
|
31
|
+
const post = performance.now();
|
|
32
|
+
timeLeft = endAt - post;
|
|
33
|
+
elapsedMs = elapsedMs + (post - pre);
|
|
34
|
+
if (typeof progressCb === 'function') {
|
|
35
|
+
progressCb({elapsedMs: Math.round(elapsedMs), timeLeft: Math.round(timeLeft), progress: elapsedMs / ms});
|
|
36
|
+
}
|
|
37
|
+
} while (timeLeft > 0);
|
|
38
|
+
}
|