@tamagui/use-debounce 1.89.26 → 1.89.27-1708112217600
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/index.native.js
CHANGED
|
@@ -21,37 +21,113 @@ __export(src_exports, {
|
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(src_exports);
|
|
23
23
|
var import_react = require("react");
|
|
24
|
+
function _array_like_to_array(arr, len) {
|
|
25
|
+
(len == null || len > arr.length) && (len = arr.length);
|
|
26
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
27
|
+
arr2[i] = arr[i];
|
|
28
|
+
return arr2;
|
|
29
|
+
}
|
|
30
|
+
function _array_with_holes(arr) {
|
|
31
|
+
if (Array.isArray(arr))
|
|
32
|
+
return arr;
|
|
33
|
+
}
|
|
34
|
+
function _array_without_holes(arr) {
|
|
35
|
+
if (Array.isArray(arr))
|
|
36
|
+
return _array_like_to_array(arr);
|
|
37
|
+
}
|
|
38
|
+
function _iterable_to_array(iter) {
|
|
39
|
+
if (typeof Symbol < "u" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
40
|
+
return Array.from(iter);
|
|
41
|
+
}
|
|
42
|
+
function _iterable_to_array_limit(arr, i) {
|
|
43
|
+
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
44
|
+
if (_i != null) {
|
|
45
|
+
var _arr = [], _n = !0, _d = !1, _s, _e;
|
|
46
|
+
try {
|
|
47
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
|
48
|
+
;
|
|
49
|
+
} catch (err) {
|
|
50
|
+
_d = !0, _e = err;
|
|
51
|
+
} finally {
|
|
52
|
+
try {
|
|
53
|
+
!_n && _i.return != null && _i.return();
|
|
54
|
+
} finally {
|
|
55
|
+
if (_d)
|
|
56
|
+
throw _e;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return _arr;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function _non_iterable_rest() {
|
|
63
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
64
|
+
}
|
|
65
|
+
function _non_iterable_spread() {
|
|
66
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
67
|
+
}
|
|
68
|
+
function _sliced_to_array(arr, i) {
|
|
69
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
70
|
+
}
|
|
71
|
+
function _to_consumable_array(arr) {
|
|
72
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
73
|
+
}
|
|
74
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
75
|
+
if (o) {
|
|
76
|
+
if (typeof o == "string")
|
|
77
|
+
return _array_like_to_array(o, minLen);
|
|
78
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
79
|
+
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set")
|
|
80
|
+
return Array.from(n);
|
|
81
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
82
|
+
return _array_like_to_array(o, minLen);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
24
85
|
function debounce(func, wait, leading) {
|
|
25
|
-
|
|
86
|
+
var timeout, isCancelled = !1;
|
|
26
87
|
function debounced() {
|
|
88
|
+
var _this = this;
|
|
27
89
|
isCancelled = !1;
|
|
28
|
-
|
|
29
|
-
leading && !timeout && func.apply(this, args), clearTimeout(timeout), timeout = setTimeout(()
|
|
30
|
-
timeout = null, leading || isCancelled || func.apply(
|
|
90
|
+
var args = arguments;
|
|
91
|
+
leading && !timeout && func.apply(this, args), clearTimeout(timeout), timeout = setTimeout(function() {
|
|
92
|
+
timeout = null, leading || isCancelled || func.apply(_this, args), isCancelled = !1;
|
|
31
93
|
}, wait);
|
|
32
94
|
}
|
|
33
|
-
return debounced.cancel = ()
|
|
95
|
+
return debounced.cancel = function() {
|
|
34
96
|
isCancelled = !0;
|
|
35
97
|
}, debounced;
|
|
36
98
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
99
|
+
var defaultOpts = {
|
|
100
|
+
leading: !1
|
|
101
|
+
};
|
|
102
|
+
function useDebounce(fn, wait) {
|
|
103
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : defaultOpts, mountArgs = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : [
|
|
104
|
+
fn
|
|
105
|
+
], dbEffect = (0, import_react.useRef)(null);
|
|
106
|
+
return (0, import_react.useEffect)(function() {
|
|
107
|
+
return function() {
|
|
108
|
+
var _dbEffect_current;
|
|
109
|
+
(_dbEffect_current = dbEffect.current) === null || _dbEffect_current === void 0 || _dbEffect_current.cancel();
|
|
110
|
+
};
|
|
111
|
+
}, []), (0, import_react.useMemo)(function() {
|
|
112
|
+
return dbEffect.current = debounce(fn, wait, options.leading), dbEffect.current;
|
|
113
|
+
}, [
|
|
114
|
+
options.leading
|
|
115
|
+
].concat(_to_consumable_array(mountArgs)));
|
|
116
|
+
}
|
|
117
|
+
function useDebounceValue(val) {
|
|
118
|
+
var amt = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, _useState = _sliced_to_array((0, import_react.useState)(val), 2), state = _useState[0], setState = _useState[1];
|
|
119
|
+
return (0, import_react.useEffect)(function() {
|
|
120
|
+
var tm = setTimeout(function() {
|
|
121
|
+
setState(function(prev) {
|
|
122
|
+
return prev === val ? prev : val;
|
|
123
|
+
});
|
|
50
124
|
}, amt);
|
|
51
|
-
return ()
|
|
125
|
+
return function() {
|
|
52
126
|
clearTimeout(tm);
|
|
53
127
|
};
|
|
54
|
-
}, [
|
|
128
|
+
}, [
|
|
129
|
+
val
|
|
130
|
+
]), state;
|
|
55
131
|
}
|
|
56
132
|
// Annotate the CommonJS export names for ESM import in node:
|
|
57
133
|
0 && (module.exports = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "
|
|
5
|
-
"names": []
|
|
3
|
+
"sources": ["../../src/Users/n8/tamagui/packages/use-debounce/src/index.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA,mBAAqD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAM9C,SAASA,SACdC,MACAC,MACAC,SAAiB;AAIjB,MAAIC,SACAC,cAAc;AAElB,WAASC,YAAAA;;AACPD,kBAAc;AACd,QAAME,OAAOC;AACb,IAAIL,WAAW,CAACC,WACdH,KAAKQ,MAAM,MAAMF,IAAAA,GAEnBG,aAAaN,OAAAA,GACbA,UAAUO,WAAW,WAAA;AACnBP,gBAAU,MACJD,WAAWE,eACfJ,KAAKQ,MAAK,OAAOF,IAAAA,GAEnBF,cAAc;IAChB,GAAGH,IAAAA;EACL;AAEAI,mBAAUM,SAAS,WAAA;AACjBP,kBAAc;EAChB,GAEOC;AACT;AAEA,IAAMO,cAAc;EAAEV,SAAS;AAAM;AAE9B,SAASW,YAMdC,IACAb,MAAY;MACZc,UAAAA,UAAAA,SAAAA,KAAAA,UAAAA,CAAAA,MAAAA,SAAAA,UAAAA,CAAAA,IAA4BH,aAC5BI,YAAAA,UAAAA,SAAAA,KAAAA,UAAAA,CAAAA,MAAAA,SAAAA,UAAAA,CAAAA,IAAmB;IAACF;KAEdG,eAAWC,qBAA2B,IAAA;AAE5CC,qCAAU,WAAA;AACR,WAAO,WAAA;UACLF;OAAAA,oBAAAA,SAASG,aAAO,QAAhBH,sBAAAA,UAAAA,kBAAkBN,OAAM;IAC1B;EACF,GAAG,CAAA,CAAE,OAEEU,sBAAQ,WAAA;AACbJ,oBAASG,UAAUrB,SAASe,IAAIb,MAAMc,QAAQb,OAAO,GAC9Ce,SAASG;EAClB,GAAG;IAACL,QAAQb;IAAT,OAAkB,qBAAGc,SAAAA,CAAAA,CAAAA;AAC1B;AAMO,SAASM,iBAAoBC,KAAM;MAAEC,MAAAA,UAAAA,SAAAA,KAAAA,UAAAA,CAAAA,MAAAA,SAAAA,UAAAA,CAAAA,IAAM,GACtBC,YAAAA,qBAAAA,uBAASF,GAAAA,GAAAA,CAAAA,GAA5BG,QAAmBD,UAAAA,CAAAA,GAAZE,WAAYF,UAAAA,CAAAA;AAE1BN,qCAAU,WAAA;AACR,QAAMS,KAAKlB,WAAW,WAAA;AACpBiB,eAAS,SAACE,MAAAA;AACR,eAAIA,SAASN,MAAYM,OAClBN;MACT,CAAA;IACF,GAAGC,GAAAA;AAEH,WAAO,WAAA;AACLf,mBAAamB,EAAAA;IACf;EACF,GAAG;IAACL;GAAI,GAEDG;AACT;",
|
|
5
|
+
"names": ["debounce", "func", "wait", "leading", "timeout", "isCancelled", "debounced", "args", "arguments", "apply", "clearTimeout", "setTimeout", "cancel", "defaultOpts", "useDebounce", "fn", "options", "mountArgs", "dbEffect", "useRef", "useEffect", "current", "useMemo", "useDebounceValue", "val", "amt", "useState", "state", "setState", "tm", "prev"]
|
|
6
6
|
}
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1,35 +1,111 @@
|
|
|
1
1
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
(len == null || len > arr.length) && (len = arr.length);
|
|
4
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
5
|
+
arr2[i] = arr[i];
|
|
6
|
+
return arr2;
|
|
7
|
+
}
|
|
8
|
+
function _array_with_holes(arr) {
|
|
9
|
+
if (Array.isArray(arr))
|
|
10
|
+
return arr;
|
|
11
|
+
}
|
|
12
|
+
function _array_without_holes(arr) {
|
|
13
|
+
if (Array.isArray(arr))
|
|
14
|
+
return _array_like_to_array(arr);
|
|
15
|
+
}
|
|
16
|
+
function _iterable_to_array(iter) {
|
|
17
|
+
if (typeof Symbol < "u" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
18
|
+
return Array.from(iter);
|
|
19
|
+
}
|
|
20
|
+
function _iterable_to_array_limit(arr, i) {
|
|
21
|
+
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
22
|
+
if (_i != null) {
|
|
23
|
+
var _arr = [], _n = !0, _d = !1, _s, _e;
|
|
24
|
+
try {
|
|
25
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
|
26
|
+
;
|
|
27
|
+
} catch (err) {
|
|
28
|
+
_d = !0, _e = err;
|
|
29
|
+
} finally {
|
|
30
|
+
try {
|
|
31
|
+
!_n && _i.return != null && _i.return();
|
|
32
|
+
} finally {
|
|
33
|
+
if (_d)
|
|
34
|
+
throw _e;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return _arr;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function _non_iterable_rest() {
|
|
41
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
42
|
+
}
|
|
43
|
+
function _non_iterable_spread() {
|
|
44
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
45
|
+
}
|
|
46
|
+
function _sliced_to_array(arr, i) {
|
|
47
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
48
|
+
}
|
|
49
|
+
function _to_consumable_array(arr) {
|
|
50
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
51
|
+
}
|
|
52
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
53
|
+
if (o) {
|
|
54
|
+
if (typeof o == "string")
|
|
55
|
+
return _array_like_to_array(o, minLen);
|
|
56
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
57
|
+
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set")
|
|
58
|
+
return Array.from(n);
|
|
59
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
60
|
+
return _array_like_to_array(o, minLen);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
2
63
|
function debounce(func, wait, leading) {
|
|
3
|
-
|
|
64
|
+
var timeout, isCancelled = !1;
|
|
4
65
|
function debounced() {
|
|
66
|
+
var _this = this;
|
|
5
67
|
isCancelled = !1;
|
|
6
|
-
|
|
7
|
-
leading && !timeout && func.apply(this, args), clearTimeout(timeout), timeout = setTimeout(()
|
|
8
|
-
timeout = null, leading || isCancelled || func.apply(
|
|
68
|
+
var args = arguments;
|
|
69
|
+
leading && !timeout && func.apply(this, args), clearTimeout(timeout), timeout = setTimeout(function() {
|
|
70
|
+
timeout = null, leading || isCancelled || func.apply(_this, args), isCancelled = !1;
|
|
9
71
|
}, wait);
|
|
10
72
|
}
|
|
11
|
-
return debounced.cancel = ()
|
|
73
|
+
return debounced.cancel = function() {
|
|
12
74
|
isCancelled = !0;
|
|
13
75
|
}, debounced;
|
|
14
76
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
77
|
+
var defaultOpts = {
|
|
78
|
+
leading: !1
|
|
79
|
+
};
|
|
80
|
+
function useDebounce(fn, wait) {
|
|
81
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : defaultOpts, mountArgs = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : [
|
|
82
|
+
fn
|
|
83
|
+
], dbEffect = useRef(null);
|
|
84
|
+
return useEffect(function() {
|
|
85
|
+
return function() {
|
|
86
|
+
var _dbEffect_current;
|
|
87
|
+
(_dbEffect_current = dbEffect.current) === null || _dbEffect_current === void 0 || _dbEffect_current.cancel();
|
|
88
|
+
};
|
|
89
|
+
}, []), useMemo(function() {
|
|
90
|
+
return dbEffect.current = debounce(fn, wait, options.leading), dbEffect.current;
|
|
91
|
+
}, [
|
|
92
|
+
options.leading
|
|
93
|
+
].concat(_to_consumable_array(mountArgs)));
|
|
94
|
+
}
|
|
95
|
+
function useDebounceValue(val) {
|
|
96
|
+
var amt = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, _useState = _sliced_to_array(useState(val), 2), state = _useState[0], setState = _useState[1];
|
|
97
|
+
return useEffect(function() {
|
|
98
|
+
var tm = setTimeout(function() {
|
|
99
|
+
setState(function(prev) {
|
|
100
|
+
return prev === val ? prev : val;
|
|
101
|
+
});
|
|
28
102
|
}, amt);
|
|
29
|
-
return ()
|
|
103
|
+
return function() {
|
|
30
104
|
clearTimeout(tm);
|
|
31
105
|
};
|
|
32
|
-
}, [
|
|
106
|
+
}, [
|
|
107
|
+
val
|
|
108
|
+
]), state;
|
|
33
109
|
}
|
|
34
110
|
export {
|
|
35
111
|
debounce,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "AAAA,
|
|
5
|
-
"names": []
|
|
3
|
+
"sources": ["../../src/Users/n8/tamagui/packages/use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AAA,IAAM,GACtBvB,YAAAA,iBAAAA,SAASsB,GAAAA,GAAAA,CAAAA,GAA5BE,QAAmBxB,UAAAA,CAAAA,GAAZyB,WAAYzB,UAAAA,CAAAA;AAE1BH,mBAAU,WAAA;AACR,QAAM6B,KAAKd,WAAW,WAAA;AACpBa,eAAS,SAACE,MAAAA;AACR,eAAIA,SAASL,MAAYK,OAClBL;MACT,CAAA;IACF,GAAGC,GAAAA;AAEH,WAAO,WAAA;AACLZ,mBAAae,EAAAA;IACf;EACF,GAAG;IAACJ;GAAI,GAEDE;AACT;",
|
|
5
|
+
"names": ["useEffect", "useMemo", "useRef", "useState", "debounce", "func", "wait", "leading", "timeout", "isCancelled", "debounced", "args", "arguments", "apply", "clearTimeout", "setTimeout", "cancel", "defaultOpts", "useDebounce", "fn", "options", "mountArgs", "dbEffect", "current", "useDebounceValue", "val", "amt", "state", "setState", "tm", "prev"]
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/use-debounce",
|
|
3
|
-
"version": "1.89.
|
|
3
|
+
"version": "1.89.27-1708112217600",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@tamagui/build": "1.89.
|
|
30
|
+
"@tamagui/build": "1.89.27-1708112217600",
|
|
31
31
|
"react": "^18.2.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|