@take-out/hooks 0.0.28
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/LICENSE +21 -0
- package/README.md +120 -0
- package/dist/cjs/index.cjs +30 -0
- package/dist/cjs/index.js +27 -0
- package/dist/cjs/index.js.map +6 -0
- package/dist/cjs/index.native.js +33 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/useClickOutside.cjs +43 -0
- package/dist/cjs/useClickOutside.js +37 -0
- package/dist/cjs/useClickOutside.js.map +6 -0
- package/dist/cjs/useClickOutside.native.js +51 -0
- package/dist/cjs/useClickOutside.native.js.map +1 -0
- package/dist/cjs/useDebouncePrepend.cjs +46 -0
- package/dist/cjs/useDebouncePrepend.js +40 -0
- package/dist/cjs/useDebouncePrepend.js.map +6 -0
- package/dist/cjs/useDebouncePrepend.native.js +54 -0
- package/dist/cjs/useDebouncePrepend.native.js.map +1 -0
- package/dist/cjs/useDeepMemoizedObject.cjs +148 -0
- package/dist/cjs/useDeepMemoizedObject.js +122 -0
- package/dist/cjs/useDeepMemoizedObject.js.map +6 -0
- package/dist/cjs/useDeepMemoizedObject.native.js +192 -0
- package/dist/cjs/useDeepMemoizedObject.native.js.map +1 -0
- package/dist/cjs/useDeepMemoizedObject.test.cjs +251 -0
- package/dist/cjs/useDeepMemoizedObject.test.js +187 -0
- package/dist/cjs/useDeepMemoizedObject.test.js.map +6 -0
- package/dist/cjs/useDeepMemoizedObject.test.native.js +261 -0
- package/dist/cjs/useDeepMemoizedObject.test.native.js.map +1 -0
- package/dist/cjs/useDeferredBoolean.cjs +34 -0
- package/dist/cjs/useDeferredBoolean.js +29 -0
- package/dist/cjs/useDeferredBoolean.js.map +6 -0
- package/dist/cjs/useDeferredBoolean.native.js +37 -0
- package/dist/cjs/useDeferredBoolean.native.js.map +1 -0
- package/dist/cjs/useEffectOnceGlobally.cjs +33 -0
- package/dist/cjs/useEffectOnceGlobally.js +28 -0
- package/dist/cjs/useEffectOnceGlobally.js.map +6 -0
- package/dist/cjs/useEffectOnceGlobally.native.js +38 -0
- package/dist/cjs/useEffectOnceGlobally.native.js.map +1 -0
- package/dist/cjs/useIsMounted.cjs +32 -0
- package/dist/cjs/useIsMounted.js +27 -0
- package/dist/cjs/useIsMounted.js.map +6 -0
- package/dist/cjs/useIsMounted.native.js +35 -0
- package/dist/cjs/useIsMounted.native.js.map +1 -0
- package/dist/cjs/useLastValue.cjs +29 -0
- package/dist/cjs/useLastValue.js +24 -0
- package/dist/cjs/useLastValue.js.map +6 -0
- package/dist/cjs/useLastValue.native.js +32 -0
- package/dist/cjs/useLastValue.native.js.map +1 -0
- package/dist/cjs/useLastValueIf.cjs +31 -0
- package/dist/cjs/useLastValueIf.js +25 -0
- package/dist/cjs/useLastValueIf.js.map +6 -0
- package/dist/cjs/useLastValueIf.native.js +35 -0
- package/dist/cjs/useLastValueIf.native.js.map +1 -0
- package/dist/cjs/useMemoStable.cjs +32 -0
- package/dist/cjs/useMemoStable.js +26 -0
- package/dist/cjs/useMemoStable.js.map +6 -0
- package/dist/cjs/useMemoStable.native.js +36 -0
- package/dist/cjs/useMemoStable.native.js.map +1 -0
- package/dist/cjs/useMemoizedObjectList.cjs +48 -0
- package/dist/cjs/useMemoizedObjectList.js +36 -0
- package/dist/cjs/useMemoizedObjectList.js.map +6 -0
- package/dist/cjs/useMemoizedObjectList.native.js +65 -0
- package/dist/cjs/useMemoizedObjectList.native.js.map +1 -0
- package/dist/cjs/useThrottle.cjs +39 -0
- package/dist/cjs/useThrottle.js +30 -0
- package/dist/cjs/useThrottle.js.map +6 -0
- package/dist/cjs/useThrottle.native.js +45 -0
- package/dist/cjs/useThrottle.native.js.map +1 -0
- package/dist/cjs/useWarnIfDepsChange.cjs +54 -0
- package/dist/cjs/useWarnIfDepsChange.js +46 -0
- package/dist/cjs/useWarnIfDepsChange.js.map +6 -0
- package/dist/cjs/useWarnIfDepsChange.native.js +58 -0
- package/dist/cjs/useWarnIfDepsChange.native.js.map +1 -0
- package/dist/cjs/useWarnIfMemoChangesOften.cjs +34 -0
- package/dist/cjs/useWarnIfMemoChangesOften.js +29 -0
- package/dist/cjs/useWarnIfMemoChangesOften.js.map +6 -0
- package/dist/cjs/useWarnIfMemoChangesOften.native.js +42 -0
- package/dist/cjs/useWarnIfMemoChangesOften.native.js.map +1 -0
- package/dist/esm/index.js +14 -0
- package/dist/esm/index.js.map +6 -0
- package/dist/esm/index.mjs +14 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +14 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/useClickOutside.js +22 -0
- package/dist/esm/useClickOutside.js.map +6 -0
- package/dist/esm/useClickOutside.mjs +20 -0
- package/dist/esm/useClickOutside.mjs.map +1 -0
- package/dist/esm/useClickOutside.native.js +25 -0
- package/dist/esm/useClickOutside.native.js.map +1 -0
- package/dist/esm/useDebouncePrepend.js +25 -0
- package/dist/esm/useDebouncePrepend.js.map +6 -0
- package/dist/esm/useDebouncePrepend.mjs +23 -0
- package/dist/esm/useDebouncePrepend.mjs.map +1 -0
- package/dist/esm/useDebouncePrepend.native.js +28 -0
- package/dist/esm/useDebouncePrepend.native.js.map +1 -0
- package/dist/esm/useDeepMemoizedObject.js +106 -0
- package/dist/esm/useDeepMemoizedObject.js.map +6 -0
- package/dist/esm/useDeepMemoizedObject.mjs +123 -0
- package/dist/esm/useDeepMemoizedObject.mjs.map +1 -0
- package/dist/esm/useDeepMemoizedObject.native.js +164 -0
- package/dist/esm/useDeepMemoizedObject.native.js.map +1 -0
- package/dist/esm/useDeepMemoizedObject.test.js +188 -0
- package/dist/esm/useDeepMemoizedObject.test.js.map +6 -0
- package/dist/esm/useDeepMemoizedObject.test.mjs +252 -0
- package/dist/esm/useDeepMemoizedObject.test.mjs.map +1 -0
- package/dist/esm/useDeepMemoizedObject.test.native.js +259 -0
- package/dist/esm/useDeepMemoizedObject.test.native.js.map +1 -0
- package/dist/esm/useDeferredBoolean.js +13 -0
- package/dist/esm/useDeferredBoolean.js.map +6 -0
- package/dist/esm/useDeferredBoolean.mjs +11 -0
- package/dist/esm/useDeferredBoolean.mjs.map +1 -0
- package/dist/esm/useDeferredBoolean.native.js +11 -0
- package/dist/esm/useDeferredBoolean.native.js.map +1 -0
- package/dist/esm/useEffectOnceGlobally.js +12 -0
- package/dist/esm/useEffectOnceGlobally.js.map +6 -0
- package/dist/esm/useEffectOnceGlobally.mjs +10 -0
- package/dist/esm/useEffectOnceGlobally.mjs.map +1 -0
- package/dist/esm/useEffectOnceGlobally.native.js +12 -0
- package/dist/esm/useEffectOnceGlobally.native.js.map +1 -0
- package/dist/esm/useIsMounted.js +11 -0
- package/dist/esm/useIsMounted.js.map +6 -0
- package/dist/esm/useIsMounted.mjs +9 -0
- package/dist/esm/useIsMounted.mjs.map +1 -0
- package/dist/esm/useIsMounted.native.js +9 -0
- package/dist/esm/useIsMounted.native.js.map +1 -0
- package/dist/esm/useLastValue.js +8 -0
- package/dist/esm/useLastValue.js.map +6 -0
- package/dist/esm/useLastValue.mjs +6 -0
- package/dist/esm/useLastValue.mjs.map +1 -0
- package/dist/esm/useLastValue.native.js +6 -0
- package/dist/esm/useLastValue.native.js.map +1 -0
- package/dist/esm/useLastValueIf.js +9 -0
- package/dist/esm/useLastValueIf.js.map +6 -0
- package/dist/esm/useLastValueIf.mjs +8 -0
- package/dist/esm/useLastValueIf.mjs.map +1 -0
- package/dist/esm/useLastValueIf.native.js +9 -0
- package/dist/esm/useLastValueIf.native.js.map +1 -0
- package/dist/esm/useMemoStable.js +11 -0
- package/dist/esm/useMemoStable.js.map +6 -0
- package/dist/esm/useMemoStable.mjs +9 -0
- package/dist/esm/useMemoStable.mjs.map +1 -0
- package/dist/esm/useMemoStable.native.js +10 -0
- package/dist/esm/useMemoStable.native.js.map +1 -0
- package/dist/esm/useMemoizedObjectList.js +21 -0
- package/dist/esm/useMemoizedObjectList.js.map +6 -0
- package/dist/esm/useMemoizedObjectList.mjs +25 -0
- package/dist/esm/useMemoizedObjectList.mjs.map +1 -0
- package/dist/esm/useMemoizedObjectList.native.js +39 -0
- package/dist/esm/useMemoizedObjectList.native.js.map +1 -0
- package/dist/esm/useThrottle.js +15 -0
- package/dist/esm/useThrottle.js.map +6 -0
- package/dist/esm/useThrottle.mjs +16 -0
- package/dist/esm/useThrottle.mjs.map +1 -0
- package/dist/esm/useThrottle.native.js +19 -0
- package/dist/esm/useThrottle.native.js.map +1 -0
- package/dist/esm/useWarnIfDepsChange.js +31 -0
- package/dist/esm/useWarnIfDepsChange.js.map +6 -0
- package/dist/esm/useWarnIfDepsChange.mjs +31 -0
- package/dist/esm/useWarnIfDepsChange.mjs.map +1 -0
- package/dist/esm/useWarnIfDepsChange.native.js +32 -0
- package/dist/esm/useWarnIfDepsChange.native.js.map +1 -0
- package/dist/esm/useWarnIfMemoChangesOften.js +14 -0
- package/dist/esm/useWarnIfMemoChangesOften.js.map +6 -0
- package/dist/esm/useWarnIfMemoChangesOften.mjs +11 -0
- package/dist/esm/useWarnIfMemoChangesOften.mjs.map +1 -0
- package/dist/esm/useWarnIfMemoChangesOften.native.js +16 -0
- package/dist/esm/useWarnIfMemoChangesOften.native.js.map +1 -0
- package/package.json +54 -0
- package/src/index.ts +13 -0
- package/src/useClickOutside.ts +34 -0
- package/src/useDebouncePrepend.ts +63 -0
- package/src/useDeepMemoizedObject.test.ts +343 -0
- package/src/useDeepMemoizedObject.ts +231 -0
- package/src/useDeferredBoolean.tsx +15 -0
- package/src/useEffectOnceGlobally.ts +41 -0
- package/src/useIsMounted.ts +11 -0
- package/src/useLastValue.ts +5 -0
- package/src/useLastValueIf.ts +15 -0
- package/src/useMemoStable.ts +24 -0
- package/src/useMemoizedObjectList.ts +74 -0
- package/src/useThrottle.ts +35 -0
- package/src/useWarnIfDepsChange.ts +61 -0
- package/src/useWarnIfMemoChangesOften.ts +24 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
21
|
+
var useDeepMemoizedObject_exports = {};
|
|
22
|
+
__export(useDeepMemoizedObject_exports, {
|
|
23
|
+
deepMemoize: () => deepMemoize,
|
|
24
|
+
shouldBeImmutable: () => shouldBeImmutable,
|
|
25
|
+
useDeepMemoizedObject: () => useDeepMemoizedObject
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(useDeepMemoizedObject_exports);
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
function shouldBeImmutable(path, immutableToNestedChanges) {
|
|
30
|
+
if (!immutableToNestedChanges) return !1;
|
|
31
|
+
const currentPath = path.join(".");
|
|
32
|
+
for (const pattern in immutableToNestedChanges) if (immutableToNestedChanges[pattern] && currentPath === pattern) return !0;
|
|
33
|
+
return !1;
|
|
34
|
+
}
|
|
35
|
+
function deepMutateInPlace(target, source) {
|
|
36
|
+
if (!(typeof target != "object" || target === null || typeof source != "object" || source === null)) {
|
|
37
|
+
if (Array.isArray(target) && Array.isArray(source)) {
|
|
38
|
+
target.length = 0, target.push(...source);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
for (const key in source) {
|
|
42
|
+
const targetValue = target[key],
|
|
43
|
+
sourceValue = source[key];
|
|
44
|
+
typeof sourceValue == "object" && sourceValue !== null && typeof targetValue == "object" && targetValue !== null ? deepMutateInPlace(targetValue, sourceValue) : target[key] = sourceValue;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function deepMemoizeWithTracking(current, previous, path, immutableToNestedChanges, parentIsImmutable = !1) {
|
|
49
|
+
if (current === previous) return {
|
|
50
|
+
value: previous,
|
|
51
|
+
hasChanges: !1,
|
|
52
|
+
hasImmutableMutation: !1
|
|
53
|
+
};
|
|
54
|
+
if (typeof current != "object" || current === null) return {
|
|
55
|
+
value: current,
|
|
56
|
+
hasChanges: !0,
|
|
57
|
+
hasImmutableMutation: !1
|
|
58
|
+
};
|
|
59
|
+
if (typeof previous != "object" || previous === null) return {
|
|
60
|
+
value: current,
|
|
61
|
+
hasChanges: !0,
|
|
62
|
+
hasImmutableMutation: !1
|
|
63
|
+
};
|
|
64
|
+
const shouldMutateInPlace = shouldBeImmutable(path, immutableToNestedChanges) || parentIsImmutable;
|
|
65
|
+
if (Array.isArray(current)) {
|
|
66
|
+
if (!Array.isArray(previous)) return {
|
|
67
|
+
value: current,
|
|
68
|
+
hasChanges: !0,
|
|
69
|
+
hasImmutableMutation: !1
|
|
70
|
+
};
|
|
71
|
+
if (current.length !== previous.length) return {
|
|
72
|
+
value: current,
|
|
73
|
+
hasChanges: !0,
|
|
74
|
+
hasImmutableMutation: !1
|
|
75
|
+
};
|
|
76
|
+
let hasChanges2 = !1,
|
|
77
|
+
hasImmutableMutation2 = !1;
|
|
78
|
+
const memoizedArray = [];
|
|
79
|
+
for (let i = 0; i < current.length; i++) {
|
|
80
|
+
const itemPath = [...path, String(i)],
|
|
81
|
+
result = deepMemoizeWithTracking(current[i], previous[i], itemPath, immutableToNestedChanges, !1);
|
|
82
|
+
memoizedArray[i] = result.value, result.hasChanges && (hasChanges2 = !0), result.hasImmutableMutation && (hasImmutableMutation2 = !0);
|
|
83
|
+
}
|
|
84
|
+
return hasChanges2 || hasImmutableMutation2 ? {
|
|
85
|
+
value: memoizedArray,
|
|
86
|
+
hasChanges: !0,
|
|
87
|
+
hasImmutableMutation: !1
|
|
88
|
+
} : {
|
|
89
|
+
value: previous,
|
|
90
|
+
hasChanges: !1,
|
|
91
|
+
hasImmutableMutation: !1
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const currentKeys = Object.keys(current),
|
|
95
|
+
previousKeys = Object.keys(previous);
|
|
96
|
+
if (currentKeys.length !== previousKeys.length) return {
|
|
97
|
+
value: current,
|
|
98
|
+
hasChanges: !0,
|
|
99
|
+
hasImmutableMutation: !1
|
|
100
|
+
};
|
|
101
|
+
if (!currentKeys.every(key => key in previous)) return {
|
|
102
|
+
value: current,
|
|
103
|
+
hasChanges: !0,
|
|
104
|
+
hasImmutableMutation: !1
|
|
105
|
+
};
|
|
106
|
+
let hasChanges = !1,
|
|
107
|
+
hasImmutableMutation = !1;
|
|
108
|
+
const memoizedObject = {};
|
|
109
|
+
for (const key of currentKeys) {
|
|
110
|
+
const propPath = [...path, key],
|
|
111
|
+
currentValue = current[key],
|
|
112
|
+
previousValue = previous[key],
|
|
113
|
+
result = deepMemoizeWithTracking(currentValue, previousValue, propPath, immutableToNestedChanges, shouldMutateInPlace);
|
|
114
|
+
memoizedObject[key] = result.value, result.hasChanges && (hasChanges = !0), result.hasImmutableMutation && (hasImmutableMutation = !0);
|
|
115
|
+
}
|
|
116
|
+
if (shouldMutateInPlace && (hasChanges || hasImmutableMutation)) {
|
|
117
|
+
if (parentIsImmutable) deepMutateInPlace(previous, current);else for (const key of currentKeys) previous[key] = memoizedObject[key];
|
|
118
|
+
return {
|
|
119
|
+
value: previous,
|
|
120
|
+
hasChanges: !1,
|
|
121
|
+
hasImmutableMutation: !0
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return hasChanges || hasImmutableMutation ? {
|
|
125
|
+
value: memoizedObject,
|
|
126
|
+
hasChanges: !0,
|
|
127
|
+
hasImmutableMutation: !1
|
|
128
|
+
} : {
|
|
129
|
+
value: previous,
|
|
130
|
+
hasChanges: !1,
|
|
131
|
+
hasImmutableMutation: !1
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function deepMemoize(current, previous, path = [], immutableToNestedChanges) {
|
|
135
|
+
const result = deepMemoizeWithTracking(current, previous, path, immutableToNestedChanges, !1);
|
|
136
|
+
if (path.length === 0 && result.hasImmutableMutation && !result.hasChanges) {
|
|
137
|
+
if (Array.isArray(result.value)) return [...result.value];
|
|
138
|
+
if (typeof result.value == "object" && result.value !== null) return {
|
|
139
|
+
...result.value
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return result.value;
|
|
143
|
+
}
|
|
144
|
+
function useDeepMemoizedObject(value, options) {
|
|
145
|
+
const previousValueRef = (0, import_react.useRef)(value),
|
|
146
|
+
memoizedValue = deepMemoize(value, previousValueRef.current, [], options?.immutableToNestedChanges);
|
|
147
|
+
return previousValueRef.current = memoizedValue, memoizedValue;
|
|
148
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var useDeepMemoizedObject_exports = {};
|
|
16
|
+
__export(useDeepMemoizedObject_exports, {
|
|
17
|
+
deepMemoize: () => deepMemoize,
|
|
18
|
+
shouldBeImmutable: () => shouldBeImmutable,
|
|
19
|
+
useDeepMemoizedObject: () => useDeepMemoizedObject
|
|
20
|
+
});
|
|
21
|
+
module.exports = __toCommonJS(useDeepMemoizedObject_exports);
|
|
22
|
+
var import_react = require("react");
|
|
23
|
+
function shouldBeImmutable(path, immutableToNestedChanges) {
|
|
24
|
+
if (!immutableToNestedChanges) return !1;
|
|
25
|
+
const currentPath = path.join(".");
|
|
26
|
+
for (const pattern in immutableToNestedChanges)
|
|
27
|
+
if (immutableToNestedChanges[pattern] && currentPath === pattern)
|
|
28
|
+
return !0;
|
|
29
|
+
return !1;
|
|
30
|
+
}
|
|
31
|
+
function deepMutateInPlace(target, source) {
|
|
32
|
+
if (!(typeof target != "object" || target === null || typeof source != "object" || source === null)) {
|
|
33
|
+
if (Array.isArray(target) && Array.isArray(source)) {
|
|
34
|
+
target.length = 0, target.push(...source);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
for (const key in source) {
|
|
38
|
+
const targetValue = target[key], sourceValue = source[key];
|
|
39
|
+
typeof sourceValue == "object" && sourceValue !== null && typeof targetValue == "object" && targetValue !== null ? deepMutateInPlace(targetValue, sourceValue) : target[key] = sourceValue;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function deepMemoizeWithTracking(current, previous, path, immutableToNestedChanges, parentIsImmutable = !1) {
|
|
44
|
+
if (current === previous)
|
|
45
|
+
return { value: previous, hasChanges: !1, hasImmutableMutation: !1 };
|
|
46
|
+
if (typeof current != "object" || current === null)
|
|
47
|
+
return { value: current, hasChanges: !0, hasImmutableMutation: !1 };
|
|
48
|
+
if (typeof previous != "object" || previous === null)
|
|
49
|
+
return { value: current, hasChanges: !0, hasImmutableMutation: !1 };
|
|
50
|
+
const shouldMutateInPlace = shouldBeImmutable(path, immutableToNestedChanges) || parentIsImmutable;
|
|
51
|
+
if (Array.isArray(current)) {
|
|
52
|
+
if (!Array.isArray(previous))
|
|
53
|
+
return { value: current, hasChanges: !0, hasImmutableMutation: !1 };
|
|
54
|
+
if (current.length !== previous.length)
|
|
55
|
+
return { value: current, hasChanges: !0, hasImmutableMutation: !1 };
|
|
56
|
+
let hasChanges2 = !1, hasImmutableMutation2 = !1;
|
|
57
|
+
const memoizedArray = [];
|
|
58
|
+
for (let i = 0; i < current.length; i++) {
|
|
59
|
+
const itemPath = [...path, String(i)], result = deepMemoizeWithTracking(
|
|
60
|
+
current[i],
|
|
61
|
+
previous[i],
|
|
62
|
+
itemPath,
|
|
63
|
+
immutableToNestedChanges,
|
|
64
|
+
!1
|
|
65
|
+
);
|
|
66
|
+
memoizedArray[i] = result.value, result.hasChanges && (hasChanges2 = !0), result.hasImmutableMutation && (hasImmutableMutation2 = !0);
|
|
67
|
+
}
|
|
68
|
+
return hasChanges2 || hasImmutableMutation2 ? { value: memoizedArray, hasChanges: !0, hasImmutableMutation: !1 } : { value: previous, hasChanges: !1, hasImmutableMutation: !1 };
|
|
69
|
+
}
|
|
70
|
+
const currentKeys = Object.keys(current), previousKeys = Object.keys(previous);
|
|
71
|
+
if (currentKeys.length !== previousKeys.length)
|
|
72
|
+
return { value: current, hasChanges: !0, hasImmutableMutation: !1 };
|
|
73
|
+
if (!currentKeys.every((key) => key in previous))
|
|
74
|
+
return { value: current, hasChanges: !0, hasImmutableMutation: !1 };
|
|
75
|
+
let hasChanges = !1, hasImmutableMutation = !1;
|
|
76
|
+
const memoizedObject = {};
|
|
77
|
+
for (const key of currentKeys) {
|
|
78
|
+
const propPath = [...path, key], currentValue = current[key], previousValue = previous[key], result = deepMemoizeWithTracking(
|
|
79
|
+
currentValue,
|
|
80
|
+
previousValue,
|
|
81
|
+
propPath,
|
|
82
|
+
immutableToNestedChanges,
|
|
83
|
+
shouldMutateInPlace
|
|
84
|
+
);
|
|
85
|
+
memoizedObject[key] = result.value, result.hasChanges && (hasChanges = !0), result.hasImmutableMutation && (hasImmutableMutation = !0);
|
|
86
|
+
}
|
|
87
|
+
if (shouldMutateInPlace && (hasChanges || hasImmutableMutation)) {
|
|
88
|
+
if (parentIsImmutable)
|
|
89
|
+
deepMutateInPlace(previous, current);
|
|
90
|
+
else
|
|
91
|
+
for (const key of currentKeys)
|
|
92
|
+
previous[key] = memoizedObject[key];
|
|
93
|
+
return { value: previous, hasChanges: !1, hasImmutableMutation: !0 };
|
|
94
|
+
}
|
|
95
|
+
return hasChanges || hasImmutableMutation ? { value: memoizedObject, hasChanges: !0, hasImmutableMutation: !1 } : { value: previous, hasChanges: !1, hasImmutableMutation: !1 };
|
|
96
|
+
}
|
|
97
|
+
function deepMemoize(current, previous, path = [], immutableToNestedChanges) {
|
|
98
|
+
const result = deepMemoizeWithTracking(
|
|
99
|
+
current,
|
|
100
|
+
previous,
|
|
101
|
+
path,
|
|
102
|
+
immutableToNestedChanges,
|
|
103
|
+
!1
|
|
104
|
+
);
|
|
105
|
+
if (path.length === 0 && result.hasImmutableMutation && !result.hasChanges) {
|
|
106
|
+
if (Array.isArray(result.value))
|
|
107
|
+
return [...result.value];
|
|
108
|
+
if (typeof result.value == "object" && result.value !== null)
|
|
109
|
+
return { ...result.value };
|
|
110
|
+
}
|
|
111
|
+
return result.value;
|
|
112
|
+
}
|
|
113
|
+
function useDeepMemoizedObject(value, options) {
|
|
114
|
+
const previousValueRef = (0, import_react.useRef)(value), memoizedValue = deepMemoize(
|
|
115
|
+
value,
|
|
116
|
+
previousValueRef.current,
|
|
117
|
+
[],
|
|
118
|
+
options?.immutableToNestedChanges
|
|
119
|
+
);
|
|
120
|
+
return previousValueRef.current = memoizedValue, memoizedValue;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=useDeepMemoizedObject.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AAA,MACA;AAAA,IACF;AAEA,mBAAe,GAAG,IAAI,OAAO,OACzB,OAAO,eACT,aAAa,KAEX,OAAO,yBACT,uBAAuB;AAAA,EAE3B;AAEA,MAAI,wBAAwB,cAAc,uBAAuB;AAG/D,QAAI;AAEF,wBAAkB,UAAU,OAAO;AAAA;AAGnC,iBAAW,OAAO;AACf,QAAC,SAAiB,GAAG,IAAI,eAAe,GAAG;AAIhD,WAAO,EAAE,OAAO,UAAU,YAAY,IAAO,sBAAsB,GAAK;AAAA,EAC1E;AAEA,SAAI,cAAc,uBACT,EAAE,OAAO,gBAAgB,YAAY,IAAM,sBAAsB,GAAM,IAGzE,EAAE,OAAO,UAAU,YAAY,IAAO,sBAAsB,GAAM;AAC3E;AAEO,SAAS,YACd,SACA,UACA,OAAiB,CAAC,GAClB,0BACG;AACH,QAAM,SAAS;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAGA,MAAI,KAAK,WAAW,KAAK,OAAO,wBAAwB,CAAC,OAAO,YAAY;AAG1E,QAAI,MAAM,QAAQ,OAAO,KAAK;AAC5B,aAAO,CAAC,GAAG,OAAO,KAAK;AAClB,QAAI,OAAO,OAAO,SAAU,YAAY,OAAO,UAAU;AAC9D,aAAO,EAAE,GAAG,OAAO,MAAM;AAAA,EAE7B;AAEA,SAAO,OAAO;AAChB;AAEO,SAAS,sBAAyB,OAAU,SAAsB;AACvE,QAAM,uBAAmB,qBAAU,KAAK,GAElC,gBAAgB;AAAA,IACpB;AAAA,IACA,iBAAiB;AAAA,IACjB,CAAC;AAAA,IACD,SAAS;AAAA,EACX;AAEA,0BAAiB,UAAU,eAEpB;AACT;",
|
|
5
|
+
"names": ["hasChanges", "hasImmutableMutation"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: !0
|
|
22
|
+
}), mod);
|
|
23
|
+
var useDeepMemoizedObject_exports = {};
|
|
24
|
+
__export(useDeepMemoizedObject_exports, {
|
|
25
|
+
deepMemoize: () => deepMemoize,
|
|
26
|
+
shouldBeImmutable: () => shouldBeImmutable,
|
|
27
|
+
useDeepMemoizedObject: () => useDeepMemoizedObject
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(useDeepMemoizedObject_exports);
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
function _type_of(obj) {
|
|
32
|
+
"@swc/helpers - typeof";
|
|
33
|
+
|
|
34
|
+
return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
35
|
+
}
|
|
36
|
+
function shouldBeImmutable(path, immutableToNestedChanges) {
|
|
37
|
+
if (!immutableToNestedChanges) return !1;
|
|
38
|
+
var currentPath = path.join(".");
|
|
39
|
+
for (var pattern in immutableToNestedChanges) if (immutableToNestedChanges[pattern] && currentPath === pattern) return !0;
|
|
40
|
+
return !1;
|
|
41
|
+
}
|
|
42
|
+
function deepMutateInPlace(target, source) {
|
|
43
|
+
if (!((typeof target > "u" ? "undefined" : _type_of(target)) !== "object" || target === null || (typeof source > "u" ? "undefined" : _type_of(source)) !== "object" || source === null)) {
|
|
44
|
+
if (Array.isArray(target) && Array.isArray(source)) {
|
|
45
|
+
target.length = 0, target.push(...source);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
for (var key in source) {
|
|
49
|
+
var targetValue = target[key],
|
|
50
|
+
sourceValue = source[key];
|
|
51
|
+
(typeof sourceValue > "u" ? "undefined" : _type_of(sourceValue)) === "object" && sourceValue !== null && (typeof targetValue > "u" ? "undefined" : _type_of(targetValue)) === "object" && targetValue !== null ? deepMutateInPlace(targetValue, sourceValue) : target[key] = sourceValue;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function deepMemoizeWithTracking(current, previous, path, immutableToNestedChanges) {
|
|
56
|
+
var parentIsImmutable = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !1;
|
|
57
|
+
if (current === previous) return {
|
|
58
|
+
value: previous,
|
|
59
|
+
hasChanges: !1,
|
|
60
|
+
hasImmutableMutation: !1
|
|
61
|
+
};
|
|
62
|
+
if ((typeof current > "u" ? "undefined" : _type_of(current)) !== "object" || current === null) return {
|
|
63
|
+
value: current,
|
|
64
|
+
hasChanges: !0,
|
|
65
|
+
hasImmutableMutation: !1
|
|
66
|
+
};
|
|
67
|
+
if ((typeof previous > "u" ? "undefined" : _type_of(previous)) !== "object" || previous === null) return {
|
|
68
|
+
value: current,
|
|
69
|
+
hasChanges: !0,
|
|
70
|
+
hasImmutableMutation: !1
|
|
71
|
+
};
|
|
72
|
+
var isCurrentImmutable = shouldBeImmutable(path, immutableToNestedChanges),
|
|
73
|
+
shouldMutateInPlace = isCurrentImmutable || parentIsImmutable;
|
|
74
|
+
if (Array.isArray(current)) {
|
|
75
|
+
if (!Array.isArray(previous)) return {
|
|
76
|
+
value: current,
|
|
77
|
+
hasChanges: !0,
|
|
78
|
+
hasImmutableMutation: !1
|
|
79
|
+
};
|
|
80
|
+
if (current.length !== previous.length) return {
|
|
81
|
+
value: current,
|
|
82
|
+
hasChanges: !0,
|
|
83
|
+
hasImmutableMutation: !1
|
|
84
|
+
};
|
|
85
|
+
for (var hasChanges = !1, hasImmutableMutation = !1, memoizedArray = [], i = 0; i < current.length; i++) {
|
|
86
|
+
var itemPath = [...path, String(i)],
|
|
87
|
+
result = deepMemoizeWithTracking(current[i], previous[i], itemPath, immutableToNestedChanges, !1);
|
|
88
|
+
memoizedArray[i] = result.value, result.hasChanges && (hasChanges = !0), result.hasImmutableMutation && (hasImmutableMutation = !0);
|
|
89
|
+
}
|
|
90
|
+
return hasChanges || hasImmutableMutation ? {
|
|
91
|
+
value: memoizedArray,
|
|
92
|
+
hasChanges: !0,
|
|
93
|
+
hasImmutableMutation: !1
|
|
94
|
+
} : {
|
|
95
|
+
value: previous,
|
|
96
|
+
hasChanges: !1,
|
|
97
|
+
hasImmutableMutation: !1
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
var currentKeys = Object.keys(current),
|
|
101
|
+
previousKeys = Object.keys(previous);
|
|
102
|
+
if (currentKeys.length !== previousKeys.length) return {
|
|
103
|
+
value: current,
|
|
104
|
+
hasChanges: !0,
|
|
105
|
+
hasImmutableMutation: !1
|
|
106
|
+
};
|
|
107
|
+
var keysMatch = currentKeys.every(function (key2) {
|
|
108
|
+
return key2 in previous;
|
|
109
|
+
});
|
|
110
|
+
if (!keysMatch) return {
|
|
111
|
+
value: current,
|
|
112
|
+
hasChanges: !0,
|
|
113
|
+
hasImmutableMutation: !1
|
|
114
|
+
};
|
|
115
|
+
var hasChanges1 = !1,
|
|
116
|
+
hasImmutableMutation1 = !1,
|
|
117
|
+
memoizedObject = {},
|
|
118
|
+
_iteratorNormalCompletion = !0,
|
|
119
|
+
_didIteratorError = !1,
|
|
120
|
+
_iteratorError = void 0;
|
|
121
|
+
try {
|
|
122
|
+
for (var _iterator = currentKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
123
|
+
var key = _step.value,
|
|
124
|
+
propPath = [...path, key],
|
|
125
|
+
currentValue = current[key],
|
|
126
|
+
previousValue = previous[key],
|
|
127
|
+
result1 = deepMemoizeWithTracking(currentValue, previousValue, propPath, immutableToNestedChanges, shouldMutateInPlace);
|
|
128
|
+
memoizedObject[key] = result1.value, result1.hasChanges && (hasChanges1 = !0), result1.hasImmutableMutation && (hasImmutableMutation1 = !0);
|
|
129
|
+
}
|
|
130
|
+
} catch (err) {
|
|
131
|
+
_didIteratorError = !0, _iteratorError = err;
|
|
132
|
+
} finally {
|
|
133
|
+
try {
|
|
134
|
+
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
135
|
+
} finally {
|
|
136
|
+
if (_didIteratorError) throw _iteratorError;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (shouldMutateInPlace && (hasChanges1 || hasImmutableMutation1)) {
|
|
140
|
+
if (parentIsImmutable) deepMutateInPlace(previous, current);else {
|
|
141
|
+
var _iteratorNormalCompletion1 = !0,
|
|
142
|
+
_didIteratorError1 = !1,
|
|
143
|
+
_iteratorError1 = void 0;
|
|
144
|
+
try {
|
|
145
|
+
for (var _iterator1 = currentKeys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
|
|
146
|
+
var key1 = _step1.value;
|
|
147
|
+
previous[key1] = memoizedObject[key1];
|
|
148
|
+
}
|
|
149
|
+
} catch (err) {
|
|
150
|
+
_didIteratorError1 = !0, _iteratorError1 = err;
|
|
151
|
+
} finally {
|
|
152
|
+
try {
|
|
153
|
+
!_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return();
|
|
154
|
+
} finally {
|
|
155
|
+
if (_didIteratorError1) throw _iteratorError1;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
value: previous,
|
|
161
|
+
hasChanges: !1,
|
|
162
|
+
hasImmutableMutation: !0
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
return hasChanges1 || hasImmutableMutation1 ? {
|
|
166
|
+
value: memoizedObject,
|
|
167
|
+
hasChanges: !0,
|
|
168
|
+
hasImmutableMutation: !1
|
|
169
|
+
} : {
|
|
170
|
+
value: previous,
|
|
171
|
+
hasChanges: !1,
|
|
172
|
+
hasImmutableMutation: !1
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function deepMemoize(current, previous) {
|
|
176
|
+
var path = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [],
|
|
177
|
+
immutableToNestedChanges = arguments.length > 3 ? arguments[3] : void 0,
|
|
178
|
+
result = deepMemoizeWithTracking(current, previous, path, immutableToNestedChanges, !1);
|
|
179
|
+
if (path.length === 0 && result.hasImmutableMutation && !result.hasChanges) {
|
|
180
|
+
if (Array.isArray(result.value)) return [...result.value];
|
|
181
|
+
if (_type_of(result.value) === "object" && result.value !== null) return {
|
|
182
|
+
...result.value
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return result.value;
|
|
186
|
+
}
|
|
187
|
+
function useDeepMemoizedObject(value, options) {
|
|
188
|
+
var previousValueRef = (0, import_react.useRef)(value),
|
|
189
|
+
memoizedValue = deepMemoize(value, previousValueRef.current, [], options?.immutableToNestedChanges);
|
|
190
|
+
return previousValueRef.current = memoizedValue, memoizedValue;
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=useDeepMemoizedObject.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","useDeepMemoizedObject_exports","__export","deepMemoize","shouldBeImmutable","useDeepMemoizedObject","module","exports","import_react","require","_type_of","obj","Symbol","constructor","path","immutableToNestedChanges","currentPath","join","pattern","deepMutateInPlace","target","source","Array","isArray","length","push","key","targetValue","sourceValue","deepMemoizeWithTracking","current","previous","parentIsImmutable","arguments","hasChanges","hasImmutableMutation","isCurrentImmutable","shouldMutateInPlace","memoizedArray","i","itemPath","String","result","currentKeys","Object","keys","previousKeys","keysMatch","every","key2","hasChanges1","hasImmutableMutation1","memoizedObject","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","iterator","_step","next","done","propPath","currentValue","previousValue","result1"],"sources":["../../src/useDeepMemoizedObject.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,6BAAA;AAAAC,QAAA,CAAAD,6BAAA;EAAAE,WAAA,EAAAA,CAAA,KAAAA,WAAA;EAAAC,iBAAA,EAAAA,CAAA,KAAAA,iBAAA;EAAAC,qBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAX,YAAuB,CAAAK,6BAAA;AAQhB,IAAAO,YAAS,GAAAC,OAAA,CACd,OACA;AAEA,SAAKC,SAAAC,GAAA;EAEL,uBAAoB;;EACpB,OAAAA,GAAA,IAAW,OAAAC,MAAW,UAAAD,GAAA,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AACpB;AACE,SAAAP,iBAAOA,CAAAU,IAAA,EAAAC,wBAAA;EAGX,KAAAA,wBAAO;EACT,IAAAC,WAAA,GAAAF,IAAA,CAAAG,IAAA;EAQA,SAASC,OAAA,IAAAH,wBAAiD,EACxD,IACEA,wBAAkB,CAAAG,OAClB,KAAAF,WACA,KAAAE,OAAO,EAMT,OAAI,CAAM;EAEP,OAAC;AAEF;AAAA,SACFC,kBAAAC,MAAA,EAAAC,MAAA;EAGA,cAAWD,MAAO,SAAe,cAAAV,QAAA,CAAAU,MAAA,mBAAAA,MAAA,qBAAAC,MAAA,uBAAAX,QAAA,CAAAW,MAAA,mBAAAA,MAAA;IAC/B,IAAAC,KAAM,CA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