@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/idle.native.js
CHANGED
|
@@ -1,74 +1,68 @@
|
|
|
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 idle_exports = {};
|
|
26
|
-
__export(idle_exports, {
|
|
27
|
-
idle: () => idle
|
|
28
|
-
});
|
|
25
|
+
__export(idle_exports, { idle: () => idle });
|
|
29
26
|
module.exports = __toCommonJS(idle_exports);
|
|
30
27
|
var import_errors = require("./errors.native.js");
|
|
31
28
|
var import_sleep = require("./sleep.native.js");
|
|
32
|
-
var idleCb = typeof requestIdleCallback === "undefined" ? function
|
|
33
|
-
|
|
29
|
+
var idleCb = typeof requestIdleCallback === "undefined" ? function(cb) {
|
|
30
|
+
return setTimeout(cb, 1);
|
|
34
31
|
} : requestIdleCallback;
|
|
35
|
-
var idleAsync = function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
var idleAsync = function() {
|
|
33
|
+
return new Promise(function(res) {
|
|
34
|
+
idleCb(res);
|
|
35
|
+
});
|
|
39
36
|
};
|
|
40
|
-
var idle = async function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
57
|
-
throw new import_errors.AbortError();
|
|
58
|
-
}
|
|
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
|
+
}
|
|
59
52
|
};
|
|
60
|
-
var fullyIdle = async function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
+
}
|
|
73
66
|
};
|
|
67
|
+
|
|
74
68
|
//# sourceMappingURL=idle.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"idle.native.js","names":[],"sources":["cjs/idle.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 idle_exports = {};\n__export(idle_exports, {\n idle: () => idle\n});\nmodule.exports = __toCommonJS(idle_exports);\nvar import_errors = require(\"./errors\");\nvar import_sleep = require(\"./sleep\");\nvar idleCb = typeof requestIdleCallback === \"undefined\" ? function(cb) {\n return setTimeout(cb, 1);\n} : requestIdleCallback;\nvar idleAsync = function() {\n return new Promise(function(res) {\n idleCb(res);\n });\n};\nvar idle = async function(signal, options) {\n var { max, min, fully } = options || {};\n var idleFn = fully ? fullyIdle : idleAsync;\n if (max && min && min < max) {\n await Promise.race([\n Promise.all([\n idleFn(),\n (0, import_sleep.sleep)(min)\n ]),\n (0, import_sleep.sleep)(max)\n ]);\n } else if (max) {\n await Promise.race([\n idleFn(),\n (0, import_sleep.sleep)(max)\n ]);\n } else if (min) {\n await Promise.all([\n idleFn(),\n (0, import_sleep.sleep)(min)\n ]);\n } else {\n await idleFn();\n }\n if (signal === null || signal === void 0 ? void 0 : signal.aborted) {\n throw new import_errors.AbortError();\n }\n};\nvar fullyIdle = async function(signal) {\n while (true) {\n var startTime = Date.now();\n await idle(signal);\n var endTime = Date.now();\n var duration = endTime - startTime;\n if (duration < 15) {\n break;\n }\n if (signal === null || signal === void 0 ? void 0 : signal.aborted) {\n throw new import_errors.AbortError();\n }\n }\n};\n//# sourceMappingURL=idle.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,eAAe,CAAC;AACpB,SAAS,cAAc,EACrB,YAAY,KACd,CAAC;AACD,OAAO,UAAU,aAAa,YAAY;AAC1C,IAAI,gBAAgB,QAAQ,oBAAU;AACtC,IAAI,eAAe,QAAQ,mBAAS;AACpC,IAAI,SAAS,OAAO,wBAAwB,cAAc,SAAS,IAAI;CACrE,OAAO,WAAW,IAAI,CAAC;AACzB,IAAI;AACJ,IAAI,YAAY,WAAW;CACzB,OAAO,IAAI,QAAQ,SAAS,KAAK;EAC/B,OAAO,GAAG;CACZ,CAAC;AACH;AACA,IAAI,OAAO,eAAe,QAAQ,SAAS;CACzC,IAAI,EAAE,KAAK,KAAK,UAAU,WAAW,CAAC;CACtC,IAAI,SAAS,QAAQ,YAAY;CACjC,IAAI,OAAO,OAAO,MAAM,KAAK;EAC3B,MAAM,QAAQ,KAAK,CACjB,QAAQ,IAAI,CACV,OAAO,IACN,GAAG,aAAa,OAAO,GAAG,CAC7B,CAAC,IACA,GAAG,aAAa,OAAO,GAAG,CAC7B,CAAC;CACH,OAAO,IAAI,KAAK;EACd,MAAM,QAAQ,KAAK,CACjB,OAAO,IACN,GAAG,aAAa,OAAO,GAAG,CAC7B,CAAC;CACH,OAAO,IAAI,KAAK;EACd,MAAM,QAAQ,IAAI,CAChB,OAAO,IACN,GAAG,aAAa,OAAO,GAAG,CAC7B,CAAC;CACH,OAAO;EACL,MAAM,OAAO;CACf;CACA,IAAI,WAAW,QAAQ,WAAW,KAAK,IAAI,KAAK,IAAI,OAAO,SAAS;EAClE,MAAM,IAAI,cAAc,WAAW;CACrC;AACF;AACA,IAAI,YAAY,eAAe,QAAQ;CACrC,OAAO,MAAM;EACX,IAAI,YAAY,KAAK,IAAI;EACzB,MAAM,KAAK,MAAM;EACjB,IAAI,UAAU,KAAK,IAAI;EACvB,IAAI,WAAW,UAAU;EACzB,IAAI,WAAW,IAAI;GACjB;EACF;EACA,IAAI,WAAW,QAAQ,WAAW,KAAK,IAAI,KAAK,IAAI,OAAO,SAAS;GAClE,MAAM,IAAI,cAAc,WAAW;EACrC;CACF;AACF"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
9
|
+
get: () => from[key],
|
|
10
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
13
14
|
};
|
|
14
15
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
16
|
-
value: true
|
|
17
|
-
}), mod);
|
|
16
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
17
|
var index_exports = {};
|
|
19
18
|
module.exports = __toCommonJS(index_exports);
|
|
20
19
|
__reExport(index_exports, require("./useAsyncEffect.cjs"), module.exports);
|
|
21
20
|
__reExport(index_exports, require("./sleep.cjs"), module.exports);
|
|
22
21
|
__reExport(index_exports, require("./idle.cjs"), module.exports);
|
|
23
|
-
__reExport(index_exports, require("./errors.cjs"), module.exports);
|
|
22
|
+
__reExport(index_exports, require("./errors.cjs"), module.exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var index_exports = {};
|
|
20
|
+
module.exports = __toCommonJS(index_exports);
|
|
21
|
+
__reExport(index_exports, require("./useAsyncEffect.native.js"), module.exports);
|
|
22
|
+
__reExport(index_exports, require("./sleep.native.js"), module.exports);
|
|
23
|
+
__reExport(index_exports, require("./idle.native.js"), module.exports);
|
|
24
|
+
__reExport(index_exports, require("./errors.native.js"), module.exports);
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
15
16
|
};
|
|
16
17
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
18
|
-
value: true
|
|
19
|
-
}), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
19
|
var index_exports = {};
|
|
21
20
|
module.exports = __toCommonJS(index_exports);
|
|
22
21
|
__reExport(index_exports, require("./useAsyncEffect.native.js"), module.exports);
|
|
23
22
|
__reExport(index_exports, require("./sleep.native.js"), module.exports);
|
|
24
23
|
__reExport(index_exports, require("./idle.native.js"), module.exports);
|
|
25
24
|
__reExport(index_exports, require("./errors.native.js"), module.exports);
|
|
25
|
+
|
|
26
26
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["cjs/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, \"default\"), secondTarget && __copyProps(secondTarget, mod, \"default\"));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\nmodule.exports = __toCommonJS(index_exports);\n__reExport(index_exports, require(\"./useAsyncEffect\"), module.exports);\n__reExport(index_exports, require(\"./sleep\"), module.exports);\n__reExport(index_exports, require(\"./idle\"), module.exports);\n__reExport(index_exports, require(\"./errors\"), module.exports);\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,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,cAAc,QAAQ,KAAK,kBAAkB,YAAY,QAAQ,KAAK,SAAS,GAAG,gBAAgB,YAAY,cAAc,KAAK,SAAS;AAC9I,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,OAAO,UAAU,aAAa,aAAa;AAC3C,WAAW,eAAe,QAAQ,4BAAkB,GAAG,OAAO,OAAO;AACrE,WAAW,eAAe,QAAQ,mBAAS,GAAG,OAAO,OAAO;AAC5D,WAAW,eAAe,QAAQ,kBAAQ,GAAG,OAAO,OAAO;AAC3D,WAAW,eAAe,QAAQ,oBAAU,GAAG,OAAO,OAAO"}
|
package/dist/cjs/sleep.cjs
CHANGED
|
@@ -1,34 +1,31 @@
|
|
|
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 sleep_exports = {};
|
|
24
|
-
__export(sleep_exports, {
|
|
25
|
-
sleep: () => sleep
|
|
26
|
-
});
|
|
23
|
+
__export(sleep_exports, { sleep: () => sleep });
|
|
27
24
|
module.exports = __toCommonJS(sleep_exports);
|
|
28
25
|
var import_errors = require("./errors.cjs");
|
|
29
26
|
const sleep = async (ms, signal) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
27
|
+
await new Promise((res) => setTimeout(res, ms));
|
|
28
|
+
if (signal?.aborted) {
|
|
29
|
+
throw new import_errors.AbortError();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
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 sleep_exports = {};
|
|
25
|
+
__export(sleep_exports, { sleep: () => sleep });
|
|
26
|
+
module.exports = __toCommonJS(sleep_exports);
|
|
27
|
+
var import_errors = require("./errors.native.js");
|
|
28
|
+
var sleep = async function(ms, signal) {
|
|
29
|
+
await new Promise(function(res) {
|
|
30
|
+
return setTimeout(res, ms);
|
|
31
|
+
});
|
|
32
|
+
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
33
|
+
throw new import_errors.AbortError();
|
|
34
|
+
}
|
|
35
|
+
};
|
package/dist/cjs/sleep.native.js
CHANGED
|
@@ -1,39 +1,37 @@
|
|
|
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 sleep_exports = {};
|
|
26
|
-
__export(sleep_exports, {
|
|
27
|
-
sleep: () => sleep
|
|
28
|
-
});
|
|
25
|
+
__export(sleep_exports, { sleep: () => sleep });
|
|
29
26
|
module.exports = __toCommonJS(sleep_exports);
|
|
30
27
|
var import_errors = require("./errors.native.js");
|
|
31
|
-
var sleep = async function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
var sleep = async function(ms, signal) {
|
|
29
|
+
await new Promise(function(res) {
|
|
30
|
+
return setTimeout(res, ms);
|
|
31
|
+
});
|
|
32
|
+
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
33
|
+
throw new import_errors.AbortError();
|
|
34
|
+
}
|
|
38
35
|
};
|
|
36
|
+
|
|
39
37
|
//# sourceMappingURL=sleep.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"sleep.native.js","names":[],"sources":["cjs/sleep.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 sleep_exports = {};\n__export(sleep_exports, {\n sleep: () => sleep\n});\nmodule.exports = __toCommonJS(sleep_exports);\nvar import_errors = require(\"./errors\");\nvar sleep = async function(ms, signal) {\n await new Promise(function(res) {\n return setTimeout(res, ms);\n });\n if (signal === null || signal === void 0 ? void 0 : signal.aborted) {\n throw new import_errors.AbortError();\n }\n};\n//# sourceMappingURL=sleep.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,gBAAgB,CAAC;AACrB,SAAS,eAAe,EACtB,aAAa,MACf,CAAC;AACD,OAAO,UAAU,aAAa,aAAa;AAC3C,IAAI,gBAAgB,QAAQ,oBAAU;AACtC,IAAI,QAAQ,eAAe,IAAI,QAAQ;CACrC,MAAM,IAAI,QAAQ,SAAS,KAAK;EAC9B,OAAO,WAAW,KAAK,EAAE;CAC3B,CAAC;CACD,IAAI,WAAW,QAAQ,WAAW,KAAK,IAAI,KAAK,IAAI,OAAO,SAAS;EAClE,MAAM,IAAI,cAAc,WAAW;CACrC;AACF"}
|
|
@@ -1,71 +1,70 @@
|
|
|
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 useAsyncEffect_exports = {};
|
|
24
23
|
__export(useAsyncEffect_exports, {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
useAsyncEffect: () => useAsyncEffect,
|
|
25
|
+
useAsyncEffectOfType: () => useAsyncEffectOfType,
|
|
26
|
+
useAsyncLayoutEffect: () => useAsyncLayoutEffect
|
|
28
27
|
});
|
|
29
28
|
module.exports = __toCommonJS(useAsyncEffect_exports);
|
|
30
29
|
var import_react = require("react");
|
|
31
30
|
var import_errors = require("./errors.cjs");
|
|
32
31
|
const DEBUG_LEVEL = 0;
|
|
33
32
|
function useAsyncEffect(cb, deps = []) {
|
|
34
|
-
|
|
33
|
+
useAsyncEffectOfType(import_react.useEffect, cb, deps);
|
|
35
34
|
}
|
|
36
35
|
function useAsyncLayoutEffect(cb, deps = []) {
|
|
37
|
-
|
|
36
|
+
useAsyncEffectOfType(import_react.useLayoutEffect, cb, deps);
|
|
38
37
|
}
|
|
39
38
|
function useAsyncEffectOfType(type, cb, deps = []) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
39
|
+
type(() => {
|
|
40
|
+
const controller = new AbortController();
|
|
41
|
+
const signal = controller.signal;
|
|
42
|
+
try {
|
|
43
|
+
const value = cb(signal, ...deps);
|
|
44
|
+
Promise.resolve(value).then(async (res) => {
|
|
45
|
+
if (res && typeof res === "function") {
|
|
46
|
+
if (signal.aborted) return res();
|
|
47
|
+
signal.addEventListener("abort", res);
|
|
48
|
+
}
|
|
49
|
+
}).catch(handleError);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
handleError(error);
|
|
52
|
+
}
|
|
53
|
+
function handleError(error) {
|
|
54
|
+
if (error instanceof import_errors.AbortError) {
|
|
55
|
+
if (DEBUG_LEVEL > 2) {
|
|
56
|
+
console.info(`\u{1F41B} useAsyncEffect aborted: ${error.message}`);
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
if (typeof error === "object" && error.name === "AbortError") {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
return () => {
|
|
66
|
+
if (signal.aborted) return;
|
|
67
|
+
controller.abort();
|
|
68
|
+
};
|
|
69
|
+
}, deps);
|
|
70
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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 useAsyncEffect_exports = {};
|
|
25
|
+
__export(useAsyncEffect_exports, {
|
|
26
|
+
useAsyncEffect: () => useAsyncEffect,
|
|
27
|
+
useAsyncEffectOfType: () => useAsyncEffectOfType,
|
|
28
|
+
useAsyncLayoutEffect: () => useAsyncLayoutEffect
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(useAsyncEffect_exports);
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
var import_errors = require("./errors.native.js");
|
|
33
|
+
function _instanceof(left, right) {
|
|
34
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
35
|
+
return !!right[Symbol.hasInstance](left);
|
|
36
|
+
} else {
|
|
37
|
+
return left instanceof right;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function _type_of(obj) {
|
|
41
|
+
"@swc/helpers - typeof";
|
|
42
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
43
|
+
}
|
|
44
|
+
var DEBUG_LEVEL = 0;
|
|
45
|
+
function useAsyncEffect(cb) {
|
|
46
|
+
var deps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
47
|
+
useAsyncEffectOfType(import_react.useEffect, cb, deps);
|
|
48
|
+
}
|
|
49
|
+
function useAsyncLayoutEffect(cb) {
|
|
50
|
+
var deps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
51
|
+
useAsyncEffectOfType(import_react.useLayoutEffect, cb, deps);
|
|
52
|
+
}
|
|
53
|
+
function useAsyncEffectOfType(type, cb) {
|
|
54
|
+
var deps = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
|
|
55
|
+
type(function() {
|
|
56
|
+
var controller = new AbortController();
|
|
57
|
+
var signal = controller.signal;
|
|
58
|
+
try {
|
|
59
|
+
var value = cb(signal, ...deps);
|
|
60
|
+
Promise.resolve(value).then(async function(res) {
|
|
61
|
+
if (res && typeof res === "function") {
|
|
62
|
+
if (signal.aborted) return res();
|
|
63
|
+
signal.addEventListener("abort", res);
|
|
64
|
+
}
|
|
65
|
+
}).catch(handleError);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
handleError(error);
|
|
68
|
+
}
|
|
69
|
+
function handleError(error) {
|
|
70
|
+
if (_instanceof(error, import_errors.AbortError)) {
|
|
71
|
+
if (DEBUG_LEVEL > 2) {
|
|
72
|
+
console.info(`\u{1F41B} useAsyncEffect aborted: ${error.message}`);
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
if ((typeof error === "undefined" ? "undefined" : _type_of(error)) === "object" && error.name === "AbortError") {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
return function() {
|
|
82
|
+
if (signal.aborted) return;
|
|
83
|
+
controller.abort();
|
|
84
|
+
};
|
|
85
|
+
}, deps);
|
|
86
|
+
}
|