@tamagui/use-async 2.7.7 → 3.0.0-beta.637.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/dist/cjs/errors.cjs +20 -23
- package/dist/cjs/errors.native.cjs +138 -0
- package/dist/cjs/errors.native.js +102 -110
- package/dist/cjs/errors.native.js.map +1 -1
- package/dist/cjs/idle.cjs +46 -53
- package/dist/cjs/idle.native.cjs +66 -0
- package/dist/cjs/idle.native.js +49 -55
- package/dist/cjs/idle.native.js.map +1 -1
- package/dist/cjs/index.cjs +10 -11
- package/dist/cjs/index.native.cjs +24 -0
- package/dist/cjs/index.native.js +10 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/sleep.cjs +19 -22
- package/dist/cjs/sleep.native.cjs +35 -0
- package/dist/cjs/sleep.native.js +22 -24
- package/dist/cjs/sleep.native.js.map +1 -1
- package/dist/cjs/useAsyncEffect.cjs +50 -51
- package/dist/cjs/useAsyncEffect.native.cjs +86 -0
- package/dist/cjs/useAsyncEffect.native.js +60 -61
- package/dist/cjs/useAsyncEffect.native.js.map +1 -1
- package/dist/esm/errors.mjs +7 -6
- package/dist/esm/errors.mjs.map +1 -1
- package/dist/esm/errors.native.js +88 -93
- package/dist/esm/errors.native.js.map +1 -1
- package/dist/esm/idle.mjs +33 -35
- package/dist/esm/idle.mjs.map +1 -1
- package/dist/esm/idle.native.js +36 -38
- package/dist/esm/idle.native.js.map +1 -1
- package/dist/esm/index.mjs +7 -5
- package/dist/esm/index.native.js +7 -5
- package/dist/esm/sleep.mjs +6 -4
- package/dist/esm/sleep.mjs.map +1 -1
- package/dist/esm/sleep.native.js +9 -7
- package/dist/esm/sleep.native.js.map +1 -1
- package/dist/esm/useAsyncEffect.mjs +35 -33
- package/dist/esm/useAsyncEffect.mjs.map +1 -1
- package/dist/esm/useAsyncEffect.native.js +45 -44
- package/dist/esm/useAsyncEffect.native.js.map +1 -1
- package/package.json +8 -8
- package/types/errors.d.ts +5 -0
- package/types/idle.d.ts +7 -0
- package/types/index.d.ts +6 -0
- package/types/sleep.d.ts +3 -0
- package/types/useAsyncEffect.d.ts +8 -0
- package/dist/esm/index.js +0 -5
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
package/dist/cjs/errors.cjs
CHANGED
|
@@ -1,33 +1,30 @@
|
|
|
1
|
+
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
6
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
10
11
|
};
|
|
11
12
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
19
20
|
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: true
|
|
22
|
-
}), mod);
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
22
|
var errors_exports = {};
|
|
24
|
-
__export(errors_exports, {
|
|
25
|
-
AbortError: () => AbortError
|
|
26
|
-
});
|
|
23
|
+
__export(errors_exports, { AbortError: () => AbortError });
|
|
27
24
|
module.exports = __toCommonJS(errors_exports);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
25
|
+
var AbortError = class extends Error {
|
|
26
|
+
constructor(message = "") {
|
|
27
|
+
super(message);
|
|
28
|
+
this.name = "AbortError";
|
|
29
|
+
}
|
|
30
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var errors_exports = {};
|
|
25
|
+
__export(errors_exports, { AbortError: () => AbortError });
|
|
26
|
+
module.exports = __toCommonJS(errors_exports);
|
|
27
|
+
function _assert_this_initialized(self) {
|
|
28
|
+
if (self === void 0) {
|
|
29
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
30
|
+
}
|
|
31
|
+
return self;
|
|
32
|
+
}
|
|
33
|
+
function _call_super(_this, derived, args) {
|
|
34
|
+
derived = _get_prototype_of(derived);
|
|
35
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
36
|
+
}
|
|
37
|
+
function _class_call_check(instance, Constructor) {
|
|
38
|
+
if (!(instance instanceof Constructor)) {
|
|
39
|
+
throw new TypeError("Cannot call a class as a function");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function _construct(Parent, args, Class) {
|
|
43
|
+
if (_is_native_reflect_construct()) {
|
|
44
|
+
_construct = Reflect.construct;
|
|
45
|
+
} else {
|
|
46
|
+
_construct = function construct(Parent2, args2, Class2) {
|
|
47
|
+
var a = [null];
|
|
48
|
+
a.push.apply(a, args2);
|
|
49
|
+
var Constructor = Function.bind.apply(Parent2, a);
|
|
50
|
+
var instance = new Constructor();
|
|
51
|
+
if (Class2) _set_prototype_of(instance, Class2.prototype);
|
|
52
|
+
return instance;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return _construct.apply(null, arguments);
|
|
56
|
+
}
|
|
57
|
+
function _get_prototype_of(o) {
|
|
58
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {
|
|
59
|
+
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
60
|
+
};
|
|
61
|
+
return _get_prototype_of(o);
|
|
62
|
+
}
|
|
63
|
+
function _inherits(subClass, superClass) {
|
|
64
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
65
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
66
|
+
}
|
|
67
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: {
|
|
68
|
+
value: subClass,
|
|
69
|
+
writable: true,
|
|
70
|
+
configurable: true
|
|
71
|
+
} });
|
|
72
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
73
|
+
}
|
|
74
|
+
function _is_native_function(fn) {
|
|
75
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
76
|
+
}
|
|
77
|
+
function _possible_constructor_return(self, call) {
|
|
78
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
79
|
+
return call;
|
|
80
|
+
}
|
|
81
|
+
return _assert_this_initialized(self);
|
|
82
|
+
}
|
|
83
|
+
function _set_prototype_of(o, p) {
|
|
84
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {
|
|
85
|
+
o2.__proto__ = p2;
|
|
86
|
+
return o2;
|
|
87
|
+
};
|
|
88
|
+
return _set_prototype_of(o, p);
|
|
89
|
+
}
|
|
90
|
+
function _type_of(obj) {
|
|
91
|
+
"@swc/helpers - typeof";
|
|
92
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
93
|
+
}
|
|
94
|
+
function _wrap_native_super(Class) {
|
|
95
|
+
var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
|
|
96
|
+
_wrap_native_super = function wrapNativeSuper(Class2) {
|
|
97
|
+
if (Class2 === null || !_is_native_function(Class2)) return Class2;
|
|
98
|
+
if (typeof Class2 !== "function") {
|
|
99
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
100
|
+
}
|
|
101
|
+
if (typeof _cache !== "undefined") {
|
|
102
|
+
if (_cache.has(Class2)) return _cache.get(Class2);
|
|
103
|
+
_cache.set(Class2, Wrapper);
|
|
104
|
+
}
|
|
105
|
+
function Wrapper() {
|
|
106
|
+
return _construct(Class2, arguments, _get_prototype_of(this).constructor);
|
|
107
|
+
}
|
|
108
|
+
Wrapper.prototype = Object.create(Class2.prototype, { constructor: {
|
|
109
|
+
value: Wrapper,
|
|
110
|
+
enumerable: false,
|
|
111
|
+
writable: true,
|
|
112
|
+
configurable: true
|
|
113
|
+
} });
|
|
114
|
+
return _set_prototype_of(Wrapper, Class2);
|
|
115
|
+
};
|
|
116
|
+
return _wrap_native_super(Class);
|
|
117
|
+
}
|
|
118
|
+
function _is_native_reflect_construct() {
|
|
119
|
+
try {
|
|
120
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
121
|
+
} catch (_) {}
|
|
122
|
+
return (_is_native_reflect_construct = function() {
|
|
123
|
+
return !!result;
|
|
124
|
+
})();
|
|
125
|
+
}
|
|
126
|
+
var AbortError = /* @__PURE__ */ (function(Error1) {
|
|
127
|
+
"use strict";
|
|
128
|
+
_inherits(AbortError2, Error1);
|
|
129
|
+
function AbortError2() {
|
|
130
|
+
var message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
|
|
131
|
+
_class_call_check(this, AbortError2);
|
|
132
|
+
var _this;
|
|
133
|
+
_this = _call_super(this, AbortError2, [message]);
|
|
134
|
+
_this.name = "AbortError";
|
|
135
|
+
return _this;
|
|
136
|
+
}
|
|
137
|
+
return AbortError2;
|
|
138
|
+
})(_wrap_native_super(Error));
|
|
@@ -1,148 +1,140 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
21
22
|
};
|
|
22
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
-
value: true
|
|
24
|
-
}), mod);
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
24
|
var errors_exports = {};
|
|
26
|
-
__export(errors_exports, {
|
|
27
|
-
AbortError: () => AbortError
|
|
28
|
-
});
|
|
25
|
+
__export(errors_exports, { AbortError: () => AbortError });
|
|
29
26
|
module.exports = __toCommonJS(errors_exports);
|
|
30
27
|
function _assert_this_initialized(self) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
if (self === void 0) {
|
|
29
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
30
|
+
}
|
|
31
|
+
return self;
|
|
35
32
|
}
|
|
36
33
|
function _call_super(_this, derived, args) {
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
derived = _get_prototype_of(derived);
|
|
35
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
39
36
|
}
|
|
40
37
|
function _class_call_check(instance, Constructor) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
if (!(instance instanceof Constructor)) {
|
|
39
|
+
throw new TypeError("Cannot call a class as a function");
|
|
40
|
+
}
|
|
44
41
|
}
|
|
45
42
|
function _construct(Parent, args, Class) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
43
|
+
if (_is_native_reflect_construct()) {
|
|
44
|
+
_construct = Reflect.construct;
|
|
45
|
+
} else {
|
|
46
|
+
_construct = function construct(Parent2, args2, Class2) {
|
|
47
|
+
var a = [null];
|
|
48
|
+
a.push.apply(a, args2);
|
|
49
|
+
var Constructor = Function.bind.apply(Parent2, a);
|
|
50
|
+
var instance = new Constructor();
|
|
51
|
+
if (Class2) _set_prototype_of(instance, Class2.prototype);
|
|
52
|
+
return instance;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return _construct.apply(null, arguments);
|
|
59
56
|
}
|
|
60
57
|
function _get_prototype_of(o) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {
|
|
59
|
+
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
60
|
+
};
|
|
61
|
+
return _get_prototype_of(o);
|
|
65
62
|
}
|
|
66
63
|
function _inherits(subClass, superClass) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
if (superClass) _set_prototype_of(subClass, superClass);
|
|
64
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
65
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
66
|
+
}
|
|
67
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: {
|
|
68
|
+
value: subClass,
|
|
69
|
+
writable: true,
|
|
70
|
+
configurable: true
|
|
71
|
+
} });
|
|
72
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
78
73
|
}
|
|
79
74
|
function _is_native_function(fn) {
|
|
80
|
-
|
|
75
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
81
76
|
}
|
|
82
77
|
function _possible_constructor_return(self, call) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
79
|
+
return call;
|
|
80
|
+
}
|
|
81
|
+
return _assert_this_initialized(self);
|
|
87
82
|
}
|
|
88
83
|
function _set_prototype_of(o, p) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {
|
|
85
|
+
o2.__proto__ = p2;
|
|
86
|
+
return o2;
|
|
87
|
+
};
|
|
88
|
+
return _set_prototype_of(o, p);
|
|
94
89
|
}
|
|
95
90
|
function _type_of(obj) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
91
|
+
"@swc/helpers - typeof";
|
|
92
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
99
93
|
}
|
|
100
94
|
function _wrap_native_super(Class) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
};
|
|
124
|
-
return _wrap_native_super(Class);
|
|
95
|
+
var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
|
|
96
|
+
_wrap_native_super = function wrapNativeSuper(Class2) {
|
|
97
|
+
if (Class2 === null || !_is_native_function(Class2)) return Class2;
|
|
98
|
+
if (typeof Class2 !== "function") {
|
|
99
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
100
|
+
}
|
|
101
|
+
if (typeof _cache !== "undefined") {
|
|
102
|
+
if (_cache.has(Class2)) return _cache.get(Class2);
|
|
103
|
+
_cache.set(Class2, Wrapper);
|
|
104
|
+
}
|
|
105
|
+
function Wrapper() {
|
|
106
|
+
return _construct(Class2, arguments, _get_prototype_of(this).constructor);
|
|
107
|
+
}
|
|
108
|
+
Wrapper.prototype = Object.create(Class2.prototype, { constructor: {
|
|
109
|
+
value: Wrapper,
|
|
110
|
+
enumerable: false,
|
|
111
|
+
writable: true,
|
|
112
|
+
configurable: true
|
|
113
|
+
} });
|
|
114
|
+
return _set_prototype_of(Wrapper, Class2);
|
|
115
|
+
};
|
|
116
|
+
return _wrap_native_super(Class);
|
|
125
117
|
}
|
|
126
118
|
function _is_native_reflect_construct() {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
119
|
+
try {
|
|
120
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
121
|
+
} catch (_) {}
|
|
122
|
+
return (_is_native_reflect_construct = function() {
|
|
123
|
+
return !!result;
|
|
124
|
+
})();
|
|
133
125
|
}
|
|
134
|
-
var AbortError = /* @__PURE__ */
|
|
135
|
-
|
|
126
|
+
var AbortError = /* @__PURE__ */ (function(Error1) {
|
|
127
|
+
"use strict";
|
|
128
|
+
_inherits(AbortError2, Error1);
|
|
129
|
+
function AbortError2() {
|
|
130
|
+
var message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
|
|
131
|
+
_class_call_check(this, AbortError2);
|
|
132
|
+
var _this;
|
|
133
|
+
_this = _call_super(this, AbortError2, [message]);
|
|
134
|
+
_this.name = "AbortError";
|
|
135
|
+
return _this;
|
|
136
|
+
}
|
|
137
|
+
return AbortError2;
|
|
138
|
+
})(_wrap_native_super(Error));
|
|
136
139
|
|
|
137
|
-
_inherits(AbortError2, Error1);
|
|
138
|
-
function AbortError2() {
|
|
139
|
-
var message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
|
|
140
|
-
_class_call_check(this, AbortError2);
|
|
141
|
-
var _this;
|
|
142
|
-
_this = _call_super(this, AbortError2, [message]);
|
|
143
|
-
_this.name = "AbortError";
|
|
144
|
-
return _this;
|
|
145
|
-
}
|
|
146
|
-
return AbortError2;
|
|
147
|
-
}(_wrap_native_super(Error));
|
|
148
140
|
//# sourceMappingURL=errors.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"errors.native.js","names":[],"sources":["cjs/errors.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar errors_exports = {};\n__export(errors_exports, {\n AbortError: () => AbortError\n});\nmodule.exports = __toCommonJS(errors_exports);\nfunction _assert_this_initialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n return self;\n}\nfunction _call_super(_this, derived, args) {\n derived = _get_prototype_of(derived);\n return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));\n}\nfunction _class_call_check(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\nfunction _construct(Parent, args, Class) {\n if (_is_native_reflect_construct()) {\n _construct = Reflect.construct;\n } else {\n _construct = function construct(Parent2, args2, Class2) {\n var a = [\n null\n ];\n a.push.apply(a, args2);\n var Constructor = Function.bind.apply(Parent2, a);\n var instance = new Constructor();\n if (Class2) _set_prototype_of(instance, Class2.prototype);\n return instance;\n };\n }\n return _construct.apply(null, arguments);\n}\nfunction _get_prototype_of(o) {\n _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {\n return o2.__proto__ || Object.getPrototypeOf(o2);\n };\n return _get_prototype_of(o);\n}\nfunction _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n if (superClass) _set_prototype_of(subClass, superClass);\n}\nfunction _is_native_function(fn) {\n return Function.toString.call(fn).indexOf(\"[native code]\") !== -1;\n}\nfunction _possible_constructor_return(self, call) {\n if (call && (_type_of(call) === \"object\" || typeof call === \"function\")) {\n return call;\n }\n return _assert_this_initialized(self);\n}\nfunction _set_prototype_of(o, p) {\n _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {\n o2.__proto__ = p2;\n return o2;\n };\n return _set_prototype_of(o, p);\n}\nfunction _type_of(obj) {\n \"@swc/helpers - typeof\";\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\nfunction _wrap_native_super(Class) {\n var _cache = typeof Map === \"function\" ? /* @__PURE__ */ new Map() : void 0;\n _wrap_native_super = function wrapNativeSuper(Class2) {\n if (Class2 === null || !_is_native_function(Class2)) return Class2;\n if (typeof Class2 !== \"function\") {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n if (typeof _cache !== \"undefined\") {\n if (_cache.has(Class2)) return _cache.get(Class2);\n _cache.set(Class2, Wrapper);\n }\n function Wrapper() {\n return _construct(Class2, arguments, _get_prototype_of(this).constructor);\n }\n Wrapper.prototype = Object.create(Class2.prototype, {\n constructor: {\n value: Wrapper,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n return _set_prototype_of(Wrapper, Class2);\n };\n return _wrap_native_super(Class);\n}\nfunction _is_native_reflect_construct() {\n try {\n var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {\n }));\n } catch (_) {\n }\n return (_is_native_reflect_construct = function() {\n return !!result;\n })();\n}\nvar AbortError = /* @__PURE__ */ (function(Error1) {\n \"use strict\";\n _inherits(AbortError2, Error1);\n function AbortError2() {\n var message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : \"\";\n _class_call_check(this, AbortError2);\n var _this;\n _this = _call_super(this, AbortError2, [\n message\n ]);\n _this.name = \"AbortError\";\n return _this;\n }\n return AbortError2;\n})(_wrap_native_super(Error));\n//# sourceMappingURL=errors.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,iBAAiB,CA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B,KAAK;AACjC;AACA,SAAS,+BAA+B;CACtC,IAAI;EACF,IAAI,SAAS,CAAC,QAAQ,UAAU,QAAQ,KAAK,QAAQ,UAAU,SAAS,CAAC,GAAG,WAAW,CACvF,CAAC,CAAC;CACJ,SAAS,GAAG,CACZ;CACA,QAAQ,+BAA+B,WAAW;EAChD,OAAO,CAAC,CAAC;CACX,GAAG;AACL;AACA,IAAI,aAA6B,iBAAC,SAAS,QAAQ;CACjD;CACA,UAAU,aAAa,MAAM;CAC7B,SAAS,cAAc;EACrB,IAAI,UAAU,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK;EAC/E,kBAAkB,MAAM,WAAW;EACnC,IAAI;EACJ,QAAQ,YAAY,MAAM,aAAa,CACrC,OACF,CAAC;EACD,MAAM,OAAO;EACb,OAAO;CACT;CACA,OAAO;AACT,GAAG,mBAAmB,KAAK,CAAC"}
|
package/dist/cjs/idle.cjs
CHANGED
|
@@ -1,69 +1,62 @@
|
|
|
1
|
+
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
6
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
10
11
|
};
|
|
11
12
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
19
20
|
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: true
|
|
22
|
-
}), mod);
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
22
|
var idle_exports = {};
|
|
24
|
-
__export(idle_exports, {
|
|
25
|
-
idle: () => idle
|
|
26
|
-
});
|
|
23
|
+
__export(idle_exports, { idle: () => idle });
|
|
27
24
|
module.exports = __toCommonJS(idle_exports);
|
|
28
25
|
var import_errors = require("./errors.cjs");
|
|
29
26
|
var import_sleep = require("./sleep.cjs");
|
|
30
|
-
const idleCb = typeof requestIdleCallback === "undefined" ? cb => setTimeout(cb, 1) : requestIdleCallback;
|
|
27
|
+
const idleCb = typeof requestIdleCallback === "undefined" ? (cb) => setTimeout(cb, 1) : requestIdleCallback;
|
|
31
28
|
const idleAsync = () => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
return new Promise((res) => {
|
|
30
|
+
idleCb(res);
|
|
31
|
+
});
|
|
35
32
|
};
|
|
36
33
|
const idle = async (signal, options) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
34
|
+
const { max, min, fully } = options || {};
|
|
35
|
+
const idleFn = fully ? fullyIdle : idleAsync;
|
|
36
|
+
if (max && min && min < max) {
|
|
37
|
+
await Promise.race([Promise.all([idleFn(), (0, import_sleep.sleep)(min)]), (0, import_sleep.sleep)(max)]);
|
|
38
|
+
} else if (max) {
|
|
39
|
+
await Promise.race([idleFn(), (0, import_sleep.sleep)(max)]);
|
|
40
|
+
} else if (min) {
|
|
41
|
+
await Promise.all([idleFn(), (0, import_sleep.sleep)(min)]);
|
|
42
|
+
} else {
|
|
43
|
+
await idleFn();
|
|
44
|
+
}
|
|
45
|
+
if (signal?.aborted) {
|
|
46
|
+
throw new import_errors.AbortError();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const fullyIdle = async (signal) => {
|
|
50
|
+
while (true) {
|
|
51
|
+
const startTime = Date.now();
|
|
52
|
+
await idle(signal);
|
|
53
|
+
const endTime = Date.now();
|
|
54
|
+
const duration = endTime - startTime;
|
|
55
|
+
if (duration < 15) {
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
if (signal?.aborted) {
|
|
59
|
+
throw new import_errors.AbortError();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
55
62
|
};
|
|
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();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var idle_exports = {};
|
|
25
|
+
__export(idle_exports, { idle: () => idle });
|
|
26
|
+
module.exports = __toCommonJS(idle_exports);
|
|
27
|
+
var import_errors = require("./errors.native.js");
|
|
28
|
+
var import_sleep = require("./sleep.native.js");
|
|
29
|
+
var idleCb = typeof requestIdleCallback === "undefined" ? function(cb) {
|
|
30
|
+
return setTimeout(cb, 1);
|
|
31
|
+
} : requestIdleCallback;
|
|
32
|
+
var idleAsync = function() {
|
|
33
|
+
return new Promise(function(res) {
|
|
34
|
+
idleCb(res);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var idle = async function(signal, options) {
|
|
38
|
+
var { max, min, fully } = options || {};
|
|
39
|
+
var idleFn = fully ? fullyIdle : idleAsync;
|
|
40
|
+
if (max && min && min < max) {
|
|
41
|
+
await Promise.race([Promise.all([idleFn(), (0, import_sleep.sleep)(min)]), (0, import_sleep.sleep)(max)]);
|
|
42
|
+
} else if (max) {
|
|
43
|
+
await Promise.race([idleFn(), (0, import_sleep.sleep)(max)]);
|
|
44
|
+
} else if (min) {
|
|
45
|
+
await Promise.all([idleFn(), (0, import_sleep.sleep)(min)]);
|
|
46
|
+
} else {
|
|
47
|
+
await idleFn();
|
|
48
|
+
}
|
|
49
|
+
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
50
|
+
throw new import_errors.AbortError();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var fullyIdle = async function(signal) {
|
|
54
|
+
while (true) {
|
|
55
|
+
var startTime = Date.now();
|
|
56
|
+
await idle(signal);
|
|
57
|
+
var endTime = Date.now();
|
|
58
|
+
var duration = endTime - startTime;
|
|
59
|
+
if (duration < 15) {
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
63
|
+
throw new import_errors.AbortError();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|