@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.
Files changed (48) hide show
  1. package/dist/cjs/errors.cjs +20 -23
  2. package/dist/cjs/errors.native.cjs +138 -0
  3. package/dist/cjs/errors.native.js +102 -110
  4. package/dist/cjs/errors.native.js.map +1 -1
  5. package/dist/cjs/idle.cjs +46 -53
  6. package/dist/cjs/idle.native.cjs +66 -0
  7. package/dist/cjs/idle.native.js +49 -55
  8. package/dist/cjs/idle.native.js.map +1 -1
  9. package/dist/cjs/index.cjs +10 -11
  10. package/dist/cjs/index.native.cjs +24 -0
  11. package/dist/cjs/index.native.js +10 -10
  12. package/dist/cjs/index.native.js.map +1 -1
  13. package/dist/cjs/sleep.cjs +19 -22
  14. package/dist/cjs/sleep.native.cjs +35 -0
  15. package/dist/cjs/sleep.native.js +22 -24
  16. package/dist/cjs/sleep.native.js.map +1 -1
  17. package/dist/cjs/useAsyncEffect.cjs +50 -51
  18. package/dist/cjs/useAsyncEffect.native.cjs +86 -0
  19. package/dist/cjs/useAsyncEffect.native.js +60 -61
  20. package/dist/cjs/useAsyncEffect.native.js.map +1 -1
  21. package/dist/esm/errors.mjs +7 -6
  22. package/dist/esm/errors.mjs.map +1 -1
  23. package/dist/esm/errors.native.js +88 -93
  24. package/dist/esm/errors.native.js.map +1 -1
  25. package/dist/esm/idle.mjs +33 -35
  26. package/dist/esm/idle.mjs.map +1 -1
  27. package/dist/esm/idle.native.js +36 -38
  28. package/dist/esm/idle.native.js.map +1 -1
  29. package/dist/esm/index.mjs +7 -5
  30. package/dist/esm/index.native.js +7 -5
  31. package/dist/esm/sleep.mjs +6 -4
  32. package/dist/esm/sleep.mjs.map +1 -1
  33. package/dist/esm/sleep.native.js +9 -7
  34. package/dist/esm/sleep.native.js.map +1 -1
  35. package/dist/esm/useAsyncEffect.mjs +35 -33
  36. package/dist/esm/useAsyncEffect.mjs.map +1 -1
  37. package/dist/esm/useAsyncEffect.native.js +45 -44
  38. package/dist/esm/useAsyncEffect.native.js.map +1 -1
  39. package/package.json +8 -8
  40. package/types/errors.d.ts +5 -0
  41. package/types/idle.d.ts +7 -0
  42. package/types/index.d.ts +6 -0
  43. package/types/sleep.d.ts +3 -0
  44. package/types/useAsyncEffect.d.ts +8 -0
  45. package/dist/esm/index.js +0 -5
  46. package/dist/esm/index.js.map +0 -1
  47. package/dist/esm/index.mjs.map +0 -1
  48. package/dist/esm/index.native.js.map +0 -1
@@ -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
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
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
- 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, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
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 (cb) {
33
- return setTimeout(cb, 1);
29
+ var idleCb = typeof requestIdleCallback === "undefined" ? function(cb) {
30
+ return setTimeout(cb, 1);
34
31
  } : requestIdleCallback;
35
- var idleAsync = function () {
36
- return new Promise(function (res) {
37
- idleCb(res);
38
- });
32
+ var idleAsync = function() {
33
+ return new Promise(function(res) {
34
+ idleCb(res);
35
+ });
39
36
  };
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
- }
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 (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();
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,"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":[]}
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"}
@@ -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
- 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, {
8
- get: () => from[key],
9
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
10
- });
11
- }
12
- return to;
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);
@@ -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
- 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, {
10
- get: () => from[key],
11
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
12
- });
13
- }
14
- return to;
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,"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,"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"}
@@ -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
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
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
- 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, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
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
- await new Promise(res => setTimeout(res, ms));
31
- if (signal?.aborted) {
32
- throw new import_errors.AbortError();
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
+ };
@@ -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
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
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
- 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, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
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 (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
- }
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,"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":[]}
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
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
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
- 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, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
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
- useAsyncEffect: () => useAsyncEffect,
26
- useAsyncEffectOfType: () => useAsyncEffectOfType,
27
- useAsyncLayoutEffect: () => useAsyncLayoutEffect
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
- useAsyncEffectOfType(import_react.useEffect, cb, deps);
33
+ useAsyncEffectOfType(import_react.useEffect, cb, deps);
35
34
  }
36
35
  function useAsyncLayoutEffect(cb, deps = []) {
37
- useAsyncEffectOfType(import_react.useLayoutEffect, cb, deps);
36
+ useAsyncEffectOfType(import_react.useLayoutEffect, cb, deps);
38
37
  }
39
38
  function useAsyncEffectOfType(type, cb, deps = []) {
40
- type(() => {
41
- const controller = new AbortController();
42
- const signal = controller.signal;
43
- try {
44
- const value = cb(signal, ...deps);
45
- Promise.resolve(value).then(async res => {
46
- if (res && typeof res === "function") {
47
- if (signal.aborted) return res();
48
- signal.addEventListener("abort", res);
49
- }
50
- }).catch(handleError);
51
- } catch (error) {
52
- handleError(error);
53
- }
54
- function handleError(error) {
55
- if (error instanceof import_errors.AbortError) {
56
- if (DEBUG_LEVEL > 2) {
57
- console.info(`\u{1F41B} useAsyncEffect aborted: ${error.message}`);
58
- }
59
- return null;
60
- }
61
- if (typeof error === "object" && error.name === "AbortError") {
62
- return null;
63
- }
64
- throw error;
65
- }
66
- return () => {
67
- if (signal.aborted) return;
68
- controller.abort();
69
- };
70
- }, deps);
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
+ }