@tamagui/use-async 2.0.0-rc.4 → 2.0.0-rc.40

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 (52) hide show
  1. package/dist/cjs/errors.cjs +14 -11
  2. package/dist/cjs/errors.native.js +71 -43
  3. package/dist/cjs/errors.native.js.map +1 -1
  4. package/dist/cjs/idle.cjs +52 -30
  5. package/dist/cjs/idle.native.js +55 -38
  6. package/dist/cjs/idle.native.js.map +1 -1
  7. package/dist/cjs/index.cjs +7 -5
  8. package/dist/cjs/index.native.js +7 -5
  9. package/dist/cjs/index.native.js.map +1 -1
  10. package/dist/cjs/sleep.cjs +16 -11
  11. package/dist/cjs/sleep.native.js +21 -16
  12. package/dist/cjs/sleep.native.js.map +1 -1
  13. package/dist/cjs/useAsyncEffect.cjs +28 -18
  14. package/dist/cjs/useAsyncEffect.native.js +34 -20
  15. package/dist/cjs/useAsyncEffect.native.js.map +1 -1
  16. package/dist/esm/errors.mjs +2 -1
  17. package/dist/esm/errors.mjs.map +1 -1
  18. package/dist/esm/errors.native.js +59 -33
  19. package/dist/esm/errors.native.js.map +1 -1
  20. package/dist/esm/idle.mjs +38 -18
  21. package/dist/esm/idle.mjs.map +1 -1
  22. package/dist/esm/idle.native.js +41 -26
  23. package/dist/esm/idle.native.js.map +1 -1
  24. package/dist/esm/index.js +4 -4
  25. package/dist/esm/index.js.map +1 -6
  26. package/dist/esm/sleep.mjs +4 -1
  27. package/dist/esm/sleep.mjs.map +1 -1
  28. package/dist/esm/sleep.native.js +5 -2
  29. package/dist/esm/sleep.native.js.map +1 -1
  30. package/dist/esm/useAsyncEffect.mjs +14 -6
  31. package/dist/esm/useAsyncEffect.mjs.map +1 -1
  32. package/dist/esm/useAsyncEffect.native.js +20 -8
  33. package/dist/esm/useAsyncEffect.native.js.map +1 -1
  34. package/package.json +5 -8
  35. package/dist/cjs/errors.js +0 -25
  36. package/dist/cjs/errors.js.map +0 -6
  37. package/dist/cjs/idle.js +0 -36
  38. package/dist/cjs/idle.js.map +0 -6
  39. package/dist/cjs/index.js +0 -18
  40. package/dist/cjs/index.js.map +0 -6
  41. package/dist/cjs/sleep.js +0 -25
  42. package/dist/cjs/sleep.js.map +0 -6
  43. package/dist/cjs/useAsyncEffect.js +0 -56
  44. package/dist/cjs/useAsyncEffect.js.map +0 -6
  45. package/dist/esm/errors.js +0 -9
  46. package/dist/esm/errors.js.map +0 -6
  47. package/dist/esm/idle.js +0 -21
  48. package/dist/esm/idle.js.map +0 -6
  49. package/dist/esm/sleep.js +0 -9
  50. package/dist/esm/sleep.js.map +0 -6
  51. package/dist/esm/useAsyncEffect.js +0 -41
  52. package/dist/esm/useAsyncEffect.js.map +0 -6
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var errors_exports = {};
22
24
  __export(errors_exports, {
@@ -25,6 +27,7 @@ __export(errors_exports, {
25
27
  module.exports = __toCommonJS(errors_exports);
26
28
  class AbortError extends Error {
27
29
  constructor(message = "") {
28
- super(message), this.name = "AbortError";
30
+ super(message);
31
+ this.name = "AbortError";
29
32
  }
30
33
  }
@@ -5,20 +5,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: !0
23
+ value: true
22
24
  }), mod);
23
25
  var errors_exports = {};
24
26
  __export(errors_exports, {
@@ -26,81 +28,105 @@ __export(errors_exports, {
26
28
  });
27
29
  module.exports = __toCommonJS(errors_exports);
28
30
  function _assert_this_initialized(self) {
29
- if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
31
+ if (self === void 0) {
32
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
33
+ }
30
34
  return self;
31
35
  }
32
36
  function _call_super(_this, derived, args) {
33
- return derived = _get_prototype_of(derived), _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
37
+ derived = _get_prototype_of(derived);
38
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
34
39
  }
35
40
  function _class_call_check(instance, Constructor) {
36
- if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
41
+ if (!(instance instanceof Constructor)) {
42
+ throw new TypeError("Cannot call a class as a function");
43
+ }
37
44
  }
38
45
  function _construct(Parent, args, Class) {
39
- return _is_native_reflect_construct() ? _construct = Reflect.construct : _construct = function (Parent2, args2, Class2) {
40
- var a = [null];
41
- a.push.apply(a, args2);
42
- var Constructor = Function.bind.apply(Parent2, a),
43
- instance = new Constructor();
44
- return Class2 && _set_prototype_of(instance, Class2.prototype), instance;
45
- }, _construct.apply(null, arguments);
46
+ if (_is_native_reflect_construct()) {
47
+ _construct = Reflect.construct;
48
+ } else {
49
+ _construct = function construct(Parent2, args2, Class2) {
50
+ var a = [null];
51
+ a.push.apply(a, args2);
52
+ var Constructor = Function.bind.apply(Parent2, a);
53
+ var instance = new Constructor();
54
+ if (Class2) _set_prototype_of(instance, Class2.prototype);
55
+ return instance;
56
+ };
57
+ }
58
+ return _construct.apply(null, arguments);
46
59
  }
47
60
  function _get_prototype_of(o) {
48
- return _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function (o2) {
61
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {
49
62
  return o2.__proto__ || Object.getPrototypeOf(o2);
50
- }, _get_prototype_of(o);
63
+ };
64
+ return _get_prototype_of(o);
51
65
  }
52
66
  function _inherits(subClass, superClass) {
53
- if (typeof superClass != "function" && superClass !== null) throw new TypeError("Super expression must either be null or a function");
67
+ if (typeof superClass !== "function" && superClass !== null) {
68
+ throw new TypeError("Super expression must either be null or a function");
69
+ }
54
70
  subClass.prototype = Object.create(superClass && superClass.prototype, {
55
71
  constructor: {
56
72
  value: subClass,
57
- writable: !0,
58
- configurable: !0
73
+ writable: true,
74
+ configurable: true
59
75
  }
60
- }), superClass && _set_prototype_of(subClass, superClass);
76
+ });
77
+ if (superClass) _set_prototype_of(subClass, superClass);
61
78
  }
62
79
  function _is_native_function(fn) {
63
80
  return Function.toString.call(fn).indexOf("[native code]") !== -1;
64
81
  }
65
82
  function _possible_constructor_return(self, call) {
66
- return call && (_type_of(call) === "object" || typeof call == "function") ? call : _assert_this_initialized(self);
83
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
84
+ return call;
85
+ }
86
+ return _assert_this_initialized(self);
67
87
  }
68
88
  function _set_prototype_of(o, p) {
69
- return _set_prototype_of = Object.setPrototypeOf || function (o2, p2) {
70
- return o2.__proto__ = p2, o2;
71
- }, _set_prototype_of(o, p);
89
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {
90
+ o2.__proto__ = p2;
91
+ return o2;
92
+ };
93
+ return _set_prototype_of(o, p);
72
94
  }
73
95
  function _type_of(obj) {
74
96
  "@swc/helpers - typeof";
75
97
 
76
- return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
98
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
77
99
  }
78
100
  function _wrap_native_super(Class) {
79
- var _cache = typeof Map == "function" ? /* @__PURE__ */new Map() : void 0;
80
- return _wrap_native_super = function (Class2) {
101
+ var _cache = typeof Map === "function" ? /* @__PURE__ */new Map() : void 0;
102
+ _wrap_native_super = function wrapNativeSuper(Class2) {
81
103
  if (Class2 === null || !_is_native_function(Class2)) return Class2;
82
- if (typeof Class2 != "function") throw new TypeError("Super expression must either be null or a function");
83
- if (typeof _cache < "u") {
104
+ if (typeof Class2 !== "function") {
105
+ throw new TypeError("Super expression must either be null or a function");
106
+ }
107
+ if (typeof _cache !== "undefined") {
84
108
  if (_cache.has(Class2)) return _cache.get(Class2);
85
109
  _cache.set(Class2, Wrapper);
86
110
  }
87
111
  function Wrapper() {
88
112
  return _construct(Class2, arguments, _get_prototype_of(this).constructor);
89
113
  }
90
- return Wrapper.prototype = Object.create(Class2.prototype, {
114
+ Wrapper.prototype = Object.create(Class2.prototype, {
91
115
  constructor: {
92
116
  value: Wrapper,
93
- enumerable: !1,
94
- writable: !0,
95
- configurable: !0
117
+ enumerable: false,
118
+ writable: true,
119
+ configurable: true
96
120
  }
97
- }), _set_prototype_of(Wrapper, Class2);
98
- }, _wrap_native_super(Class);
121
+ });
122
+ return _set_prototype_of(Wrapper, Class2);
123
+ };
124
+ return _wrap_native_super(Class);
99
125
  }
100
126
  function _is_native_reflect_construct() {
101
127
  try {
102
128
  var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
103
- } catch {}
129
+ } catch (_) {}
104
130
  return (_is_native_reflect_construct = function () {
105
131
  return !!result;
106
132
  })();
@@ -113,7 +139,9 @@ var AbortError = /* @__PURE__ */function (Error1) {
113
139
  var message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
114
140
  _class_call_check(this, AbortError2);
115
141
  var _this;
116
- return _this = _call_super(this, AbortError2, [message]), _this.name = "AbortError", _this;
142
+ _this = _call_super(this, AbortError2, [message]);
143
+ _this.name = "AbortError";
144
+ return _this;
117
145
  }
118
146
  return AbortError2;
119
147
  }(_wrap_native_super(Error));
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","errors_exports","__export","AbortError","module","exports","_assert_this_initialized","self","ReferenceError"],"sources":["../../src/errors.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,cAAA;AAAAC,QAAA,CAAAD,cAAA;EAAAE,UAAA,EAAAA,CAAA,KAAAA;AAAA;AAAOC,MAAM,CAAAC,OAAA,GAAAT,YAAmB,CAAAK,cAAM;AAAA,SACpCK,wBAA0BA,CAAAC,IAAA;EACxB,IAAAA,IAAM,UACN,GACF,UAAAC,cAAA;EACF,OAAAD,IAAA","ignoreList":[]}
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","errors_exports","__export","AbortError","module","exports","_assert_this_initialized","self","ReferenceError"],"sources":["../../src/errors.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,cAAA;AAAAC,QAAA,CAAAD,cAAA;EAAAE,UAAA,EAAAA,CAAA,KAAAA;AAAA;AAAOC,MAAM,CAAAC,OAAA,GAAAT,YAAmB,CAAAK,cAAM;AAAA,SACpCK,wBAA0BA,CAAAC,IAAA;EACxB,IAAAA,IAAM,UAAO;IACb,MAAK,IAAAC,cAAO;EACd;EACF,OAAAD,IAAA","ignoreList":[]}
package/dist/cjs/idle.cjs CHANGED
@@ -3,45 +3,67 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var idle_exports = {};
22
24
  __export(idle_exports, {
23
25
  idle: () => idle
24
26
  });
25
27
  module.exports = __toCommonJS(idle_exports);
26
- var import_errors = require("./errors.cjs"),
27
- import_sleep = require("./sleep.cjs");
28
- const idleCb = typeof requestIdleCallback > "u" ? cb => setTimeout(cb, 1) : requestIdleCallback,
29
- idleAsync = () => new Promise(res => {
28
+ var import_errors = require("./errors.cjs");
29
+ var import_sleep = require("./sleep.cjs");
30
+ const idleCb = typeof requestIdleCallback === "undefined" ? cb => setTimeout(cb, 1) : requestIdleCallback;
31
+ const idleAsync = () => {
32
+ return new Promise(res => {
30
33
  idleCb(res);
31
- }),
32
- idle = async (signal, options) => {
33
- const {
34
- max,
35
- min,
36
- fully
37
- } = options || {},
38
- idleFn = fully ? fullyIdle : idleAsync;
39
- if (max && min && min < max ? await Promise.race([Promise.all([idleFn(), (0, import_sleep.sleep)(min)]), (0, import_sleep.sleep)(max)]) : max ? await Promise.race([idleFn(), (0, import_sleep.sleep)(max)]) : min ? await Promise.all([idleFn(), (0, import_sleep.sleep)(min)]) : await idleFn(), signal?.aborted) throw new import_errors.AbortError();
40
- },
41
- fullyIdle = async signal => {
42
- for (;;) {
43
- const startTime = Date.now();
44
- if (await idle(signal), Date.now() - startTime < 15) break;
45
- if (signal?.aborted) throw new import_errors.AbortError();
34
+ });
35
+ };
36
+ const idle = async (signal, options) => {
37
+ const {
38
+ max,
39
+ min,
40
+ fully
41
+ } = options || {};
42
+ const idleFn = fully ? fullyIdle : idleAsync;
43
+ if (max && min && min < max) {
44
+ await Promise.race([Promise.all([idleFn(), (0, import_sleep.sleep)(min)]), (0, import_sleep.sleep)(max)]);
45
+ } else if (max) {
46
+ await Promise.race([idleFn(), (0, import_sleep.sleep)(max)]);
47
+ } else if (min) {
48
+ await Promise.all([idleFn(), (0, import_sleep.sleep)(min)]);
49
+ } else {
50
+ await idleFn();
51
+ }
52
+ if (signal?.aborted) {
53
+ throw new import_errors.AbortError();
54
+ }
55
+ };
56
+ const fullyIdle = async signal => {
57
+ while (true) {
58
+ const startTime = Date.now();
59
+ await idle(signal);
60
+ const endTime = Date.now();
61
+ const duration = endTime - startTime;
62
+ if (duration < 15) {
63
+ break;
64
+ }
65
+ if (signal?.aborted) {
66
+ throw new import_errors.AbortError();
46
67
  }
47
- };
68
+ }
69
+ };
@@ -5,53 +5,70 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: !0
23
+ value: true
22
24
  }), mod);
23
25
  var idle_exports = {};
24
26
  __export(idle_exports, {
25
27
  idle: () => idle
26
28
  });
27
29
  module.exports = __toCommonJS(idle_exports);
28
- var import_errors = require("./errors.native.js"),
29
- import_sleep = require("./sleep.native.js"),
30
- idleCb = typeof requestIdleCallback > "u" ? function (cb) {
31
- return setTimeout(cb, 1);
32
- } : requestIdleCallback,
33
- idleAsync = function () {
34
- return new Promise(function (res) {
35
- idleCb(res);
36
- });
37
- },
38
- idle = async function (signal, options) {
39
- var {
40
- max,
41
- min,
42
- fully
43
- } = options || {},
44
- idleFn = fully ? fullyIdle : idleAsync;
45
- if (max && min && min < max ? await Promise.race([Promise.all([idleFn(), (0, import_sleep.sleep)(min)]), (0, import_sleep.sleep)(max)]) : max ? await Promise.race([idleFn(), (0, import_sleep.sleep)(max)]) : min ? await Promise.all([idleFn(), (0, import_sleep.sleep)(min)]) : await idleFn(), signal?.aborted) throw new import_errors.AbortError();
46
- },
47
- fullyIdle = async function (signal) {
48
- for (;;) {
49
- var startTime = Date.now();
50
- await idle(signal);
51
- var endTime = Date.now(),
52
- duration = endTime - startTime;
53
- if (duration < 15) break;
54
- if (signal?.aborted) throw new import_errors.AbortError();
30
+ var import_errors = require("./errors.native.js");
31
+ var import_sleep = require("./sleep.native.js");
32
+ var idleCb = typeof requestIdleCallback === "undefined" ? function (cb) {
33
+ return setTimeout(cb, 1);
34
+ } : requestIdleCallback;
35
+ var idleAsync = function () {
36
+ return new Promise(function (res) {
37
+ idleCb(res);
38
+ });
39
+ };
40
+ var idle = async function (signal, options) {
41
+ var {
42
+ max,
43
+ min,
44
+ fully
45
+ } = options || {};
46
+ var idleFn = fully ? fullyIdle : idleAsync;
47
+ if (max && min && min < max) {
48
+ await Promise.race([Promise.all([idleFn(), (0, import_sleep.sleep)(min)]), (0, import_sleep.sleep)(max)]);
49
+ } else if (max) {
50
+ await Promise.race([idleFn(), (0, import_sleep.sleep)(max)]);
51
+ } else if (min) {
52
+ await Promise.all([idleFn(), (0, import_sleep.sleep)(min)]);
53
+ } else {
54
+ await idleFn();
55
+ }
56
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
57
+ throw new import_errors.AbortError();
58
+ }
59
+ };
60
+ var fullyIdle = async function (signal) {
61
+ while (true) {
62
+ var startTime = Date.now();
63
+ await idle(signal);
64
+ var endTime = Date.now();
65
+ var duration = endTime - startTime;
66
+ if (duration < 15) {
67
+ break;
68
+ }
69
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
70
+ throw new import_errors.AbortError();
55
71
  }
56
- };
72
+ }
73
+ };
57
74
  //# sourceMappingURL=idle.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","idle_exports","__export","idle","module","exports","import_errors","require","import_sleep","idleCb","requestIdleCallback","cb","setTimeout","idleAsync","Promise","res","signal","options","max","min","fully","idleFn","fullyIdle","race","all","sleep"],"sources":["../../src/idle.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,YAAA;AAAAC,QAAA,CAAAD,YAAA;EAAAE,IAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAA2B,CAAAK,YAC3B;AASA,IAAAK,aACE,GAAAC,OAAO;EAAAC,YACF,GAAAD,OAAmB,oBAAe,CAAC;EAAAE,MACpC,UAAAC,mBAEY,MACT,aAAYC,EAAC;IAClB,OAAOC,UAAG,CAAAD,EAAA;EACZ,CAAC,GAGUD,mBACX;EAAAG,SACA,YAAAA,CAAA,EAKkB;IAClB,OAAM,IAAEC,OAAU,WAAUC,GAAA;MAc5BN,MAVI,CAAAM,GAAO;IAWT;EAEJ;EAEMZ,IAAA,kBAAAA,CAAmBa,MAAA,EAAwCC,OAAA;IAC/D;QAAAC,GAAA;QAAaC,GAAA;QAAAC;MAAA,IAAAH,OAAA;MAAAI,MAAA,GAAAD,KAAA,GAAAE,SAAA,GAAAT,SAAA;IACX,IAAAK,GAAA,IAAMC,GAAA,IAAAA,GAAY,GAAAD,GAAK,GAAI,MAAAJ,OAAA,CAAAS,IAAA,EAM3BT,OALA,CAAAU,GAAM,EAMJH,MAAA,IAIF,EAAI,EAAAb,YAAQ,CAAAiB,KAAA,EAAAN,GAAA,EACV,GAEJ,IAAAX,YAAA,CAAAiB,KAAA,EAAAP,GAAA,EACF,IAAAA,GAAA,SAAAJ,OAAA,CAAAS,IAAA,E","ignoreList":[]}
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","idle_exports","__export","idle","module","exports","import_errors","require","import_sleep","idleCb","requestIdleCallback","cb","setTimeout","idleAsync","Promise","res","signal","options","max","min","fully","idleFn","fullyIdle","race","all","sleep","aborted","AbortError"],"sources":["../../src/idle.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,YAAA;AAAAC,QAAA,CAAAD,YAAA;EAAAE,IAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAA2B,CAAAK,YAAA;AAC3B,IAAAK,aAAA,GAAsBC,OAAA;AAStB,IAAAC,YACE,GAAAD,OAAO;AAIT,IAAAE,MAAM,UAAYC,mBAAM,6BAAAC,EAAA;EACtB,OAAOC,UAAI,CAAAD,EAAS;AAClB,IAAAD,mBAAU;AAAA,IACXG,SAAA,YAAAA,CAAA;EACH,WAAAC,OAAA,WAAAC,GAAA;IAEON,MAAM,CAAAM,GAAO;EAQlB;AAEA;AAEA,IAAAZ,IAAI,kBAAAA,CAAoBa,MAAK,EAAAC,OAAA;EAC3B;IAAAC,GAAM;IAAAC,GAAA;IAAQC;EAAM,IAAAH,OAAQ,IAAK;EACnC,IAAAI,MAAA,GAAWD,KAAK,GAAAE,SAAA,GAAAT,SAAA;EACd,IAAAK,GAAA,IAAMC,GAAA,IAAQA,GAAK,GAACD,GAAA,EAAO;IAC7B,MAAAJ,OAAW,CAAKS,IAAA,EACdT,OAAM,CAAAU,GAAA,CAAQ,CAChBH,MAAO,IACL,EAAM,EAAAb,YAAO,CAAAiB,KAAA,EAAAN,GAAA,EACf,GAEI,IAAAX,YAAQ,CAASiB,KAAA,EAAAP,GAAA,EACnB;EACF,WAAAA,GAAA;IACF,MAAAJ,OAAA,CAAAS,IAAA,EAEMF,MAAA,IACJ,IAAOb,YAAM,CAAAiB,KAAA,EAAAP,GAAA,EACX;EACA,WAAMC,GAAK;IACX,MAAML,OAAA,CAAAU,GAAU,EAChBH,MAAM,IAGN,EAAI,EAAAb,YAAW,CAAIiB,KAAA,EAAAN,GAAA,EACjB;EAAA,OACF;IAGA,MAAIE,MAAQ;EACV;EAAqB,IACvBL,MAAA,aAAAA,MAAA,uBAAAA,MAAA,CAAAU,OAAA;IACF,UAAApB,aAAA,CAAAqB,UAAA;EACF","ignoreList":[]}
@@ -3,15 +3,17 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
7
8
  get: () => from[key],
8
9
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
10
  });
10
- return to;
11
- },
12
- __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
15
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
- value: !0
16
+ value: true
15
17
  }), mod);
16
18
  var index_exports = {};
17
19
  module.exports = __toCommonJS(index_exports);
@@ -5,15 +5,17 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __copyProps = (to, from, except, desc) => {
8
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
9
10
  get: () => from[key],
10
11
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
11
12
  });
12
- return to;
13
- },
14
- __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
+ }
14
+ return to;
15
+ };
16
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
17
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
16
- value: !0
18
+ value: true
17
19
  }), mod);
18
20
  var index_exports = {};
19
21
  module.exports = __toCommonJS(index_exports);
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports","__reExport","require"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA;AACdG,UAAA,CAAAH,aAAA,EAAcI,OAAA,6BADd,GAAAH,MAAA,CAAAC,OAAA;AAEAC,UAAA,CAAAH,aAAA,EAAcI,OAAA,uBAFdH,MAAA,CAAAC,OAAA;AAGAC,UAAA,CAAAH,aAAA,EAAcI,OAAA,sBAAAH,MAHd,CAAAC,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports","__reExport","require"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA;AACdG,UAAA,CAAAH,aAAA,EAAcI,OAAA,6BADd,GAAAH,MAAA,CAAAC,OAAA;AAEAC,UAAA,CAAAH,aAAA,EAAcI,OAAA,uBAFdH,MAAA,CAAAC,OAAA;AAGAC,UAAA,CAAAH,aAAA,EAAcI,OAAA,sBAAAH,MAHd,CAAAC,OAAA","ignoreList":[]}
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var sleep_exports = {};
22
24
  __export(sleep_exports, {
@@ -25,5 +27,8 @@ __export(sleep_exports, {
25
27
  module.exports = __toCommonJS(sleep_exports);
26
28
  var import_errors = require("./errors.cjs");
27
29
  const sleep = async (ms, signal) => {
28
- if (await new Promise(res => setTimeout(res, ms)), signal?.aborted) throw new import_errors.AbortError();
30
+ await new Promise(res => setTimeout(res, ms));
31
+ if (signal?.aborted) {
32
+ throw new import_errors.AbortError();
33
+ }
29
34
  };
@@ -5,30 +5,35 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: !0
23
+ value: true
22
24
  }), mod);
23
25
  var sleep_exports = {};
24
26
  __export(sleep_exports, {
25
27
  sleep: () => sleep
26
28
  });
27
29
  module.exports = __toCommonJS(sleep_exports);
28
- var import_errors = require("./errors.native.js"),
29
- sleep = async function (ms, signal) {
30
- if (await new Promise(function (res) {
31
- return setTimeout(res, ms);
32
- }), signal?.aborted) throw new import_errors.AbortError();
33
- };
30
+ var import_errors = require("./errors.native.js");
31
+ var sleep = async function (ms, signal) {
32
+ await new Promise(function (res) {
33
+ return setTimeout(res, ms);
34
+ });
35
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
36
+ throw new import_errors.AbortError();
37
+ }
38
+ };
34
39
  //# sourceMappingURL=sleep.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","sleep_exports","__export","sleep","module","exports","import_errors","require","ms","signal","Promise","res","setTimeout","aborted"],"sources":["../../src/sleep.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,KAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAA2B,CAAAK,aAAA;AAEpB,IAAAK,aAAc,GAAAC,OAAmB,qBAAwC;EAAAJ,KAAA,kBAAAA,CAAAK,EAAA,EAAAC,MAAA;IAE9E,IADA,MAAM,IAAIC,OAAA,CAAQ,UAASC,GAAA;MAEzB,OAAMC,UAAI,CAAAD,GAAA,EAAAH,EAAA;IAEd,IAAAC,MAAA,EAAAI,OAAA,E","ignoreList":[]}
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","sleep_exports","__export","sleep","module","exports","import_errors","require","ms","signal","Promise","res","setTimeout","aborted"],"sources":["../../src/sleep.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,KAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAA2B,CAAAK,aAAA;AAEpB,IAAAK,aAAc,GAAAC,OAAmB,qBAAwC;AAC9E,IAAAJ,KAAM,GAAI,eAAAA,CAASK,EAAQ,EAAAC,MAAA;EAC3B,MAAI,IAAAC,OAAQ,WAASC,GAAA;IACnB,OAAMC,UAAI,CAAAD,GAAA,EAAAH,EAAA;EACZ;EACF,IAAAC,MAAA,aAAAA,MAAA,uBAAAA,MAAA,CAAAI,OAAA","ignoreList":[]}