valdres 0.2.0-alpha.34 → 0.2.0-alpha.36
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/index.js +100 -23
- package/package.json +2 -5
package/dist/index.js
CHANGED
|
@@ -1,8 +1,93 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
// src/lib/equal.ts
|
|
2
|
+
var hasElementType = typeof Element !== "undefined";
|
|
3
|
+
var hasMap = typeof Map === "function";
|
|
4
|
+
var hasSet = typeof Set === "function";
|
|
5
|
+
var hasArrayBuffer = typeof ArrayBuffer === "function" && !!ArrayBuffer.isView;
|
|
6
|
+
var deepEqualFn = (a, b) => {
|
|
7
|
+
if (a === b)
|
|
8
|
+
return true;
|
|
9
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
10
|
+
if (a.constructor !== b.constructor)
|
|
11
|
+
return false;
|
|
12
|
+
var length, i, keys;
|
|
13
|
+
if (Array.isArray(a)) {
|
|
14
|
+
length = a.length;
|
|
15
|
+
if (length != b.length)
|
|
16
|
+
return false;
|
|
17
|
+
for (i = length;i-- !== 0; )
|
|
18
|
+
if (!deepEqualFn(a[i], b[i]))
|
|
19
|
+
return false;
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
var it;
|
|
23
|
+
if (hasMap && a instanceof Map && b instanceof Map) {
|
|
24
|
+
if (a.size !== b.size)
|
|
25
|
+
return false;
|
|
26
|
+
it = a.entries();
|
|
27
|
+
while (!(i = it.next()).done)
|
|
28
|
+
if (!b.has(i.value[0]))
|
|
29
|
+
return false;
|
|
30
|
+
it = a.entries();
|
|
31
|
+
while (!(i = it.next()).done)
|
|
32
|
+
if (!deepEqualFn(i.value[1], b.get(i.value[0])))
|
|
33
|
+
return false;
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
if (hasSet && a instanceof Set && b instanceof Set) {
|
|
37
|
+
if (a.size !== b.size)
|
|
38
|
+
return false;
|
|
39
|
+
it = a.entries();
|
|
40
|
+
while (!(i = it.next()).done)
|
|
41
|
+
if (!b.has(i.value[0]))
|
|
42
|
+
return false;
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
if (hasArrayBuffer && ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
|
|
46
|
+
length = a.length;
|
|
47
|
+
if (length != b.length)
|
|
48
|
+
return false;
|
|
49
|
+
for (i = length;i-- !== 0; )
|
|
50
|
+
if (a[i] !== b[i])
|
|
51
|
+
return false;
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
if (a.constructor === RegExp)
|
|
55
|
+
return a.source === b.source && a.flags === b.flags;
|
|
56
|
+
if (a.valueOf !== Object.prototype.valueOf && typeof a.valueOf === "function" && typeof b.valueOf === "function")
|
|
57
|
+
return a.valueOf() === b.valueOf();
|
|
58
|
+
if (a.toString !== Object.prototype.toString && typeof a.toString === "function" && typeof b.toString === "function")
|
|
59
|
+
return a.toString() === b.toString();
|
|
60
|
+
keys = Object.keys(a);
|
|
61
|
+
length = keys.length;
|
|
62
|
+
if (length !== Object.keys(b).length)
|
|
63
|
+
return false;
|
|
64
|
+
for (i = length;i-- !== 0; )
|
|
65
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
|
|
66
|
+
return false;
|
|
67
|
+
if (hasElementType && a instanceof Element)
|
|
68
|
+
return false;
|
|
69
|
+
for (i = length;i-- !== 0; ) {
|
|
70
|
+
if ((keys[i] === "_owner" || keys[i] === "__v" || keys[i] === "__o") && a.$$typeof) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (!deepEqualFn(a[keys[i]], b[keys[i]]))
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return a !== a && b !== b;
|
|
79
|
+
};
|
|
80
|
+
var equal = (a, b) => {
|
|
81
|
+
try {
|
|
82
|
+
return deepEqualFn(a, b);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
if ((error.message || "").match(/stack|recursion/i)) {
|
|
85
|
+
console.warn("react-fast-compare cannot handle circular refs");
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
6
91
|
|
|
7
92
|
// src/utils/isAtom.ts
|
|
8
93
|
var isAtom = (state) => Object.hasOwn(state, "defaultValue");
|
|
@@ -36,9 +121,6 @@ var isPromiseLike = (object) => {
|
|
|
36
121
|
return object && object.then && typeof object.then === "function";
|
|
37
122
|
};
|
|
38
123
|
|
|
39
|
-
// src/lib/getState.ts
|
|
40
|
-
import equal from "fast-deep-equal/es6";
|
|
41
|
-
|
|
42
124
|
// src/utils/isAtomFamily.ts
|
|
43
125
|
var isAtomFamily = (state) => state && Object.hasOwn(state, "__valdresAtomFamilyMap");
|
|
44
126
|
|
|
@@ -611,7 +693,7 @@ var store = (id) => {
|
|
|
611
693
|
return storeFromStoreData(data);
|
|
612
694
|
};
|
|
613
695
|
// package.json
|
|
614
|
-
var version = "0.2.0-alpha.
|
|
696
|
+
var version = "0.2.0-alpha.36";
|
|
615
697
|
|
|
616
698
|
// src/globalStore.ts
|
|
617
699
|
if (globalThis.__valdres__) {
|
|
@@ -670,7 +752,7 @@ var globalAtom = (defaultValue, options) => {
|
|
|
670
752
|
}
|
|
671
753
|
};
|
|
672
754
|
const atom = {
|
|
673
|
-
equal
|
|
755
|
+
equal,
|
|
674
756
|
...options,
|
|
675
757
|
defaultValue,
|
|
676
758
|
name: options?.name,
|
|
@@ -689,19 +771,16 @@ var globalAtom = (defaultValue, options) => {
|
|
|
689
771
|
// src/atom.ts
|
|
690
772
|
function atom(defaultValue, options) {
|
|
691
773
|
if (!options)
|
|
692
|
-
return { equal
|
|
774
|
+
return { equal, defaultValue };
|
|
693
775
|
if (options.global) {
|
|
694
776
|
return globalAtom(defaultValue, options);
|
|
695
777
|
}
|
|
696
778
|
return {
|
|
697
|
-
equal
|
|
779
|
+
equal,
|
|
698
780
|
defaultValue,
|
|
699
781
|
...options
|
|
700
782
|
};
|
|
701
783
|
}
|
|
702
|
-
// src/lib/createAtomFamily.ts
|
|
703
|
-
import equal5 from "fast-deep-equal/es6";
|
|
704
|
-
|
|
705
784
|
// src/lib/atomFamilyAtom.ts
|
|
706
785
|
function atomFamilyAtom(defaultValue, options) {
|
|
707
786
|
if (options.global) {
|
|
@@ -768,25 +847,24 @@ var stableStringify = (x) => {
|
|
|
768
847
|
};
|
|
769
848
|
|
|
770
849
|
// src/selector.ts
|
|
771
|
-
import equal4 from "fast-deep-equal/es6";
|
|
772
850
|
var selector = (get, options) => {
|
|
773
851
|
if (!options)
|
|
774
|
-
return { equal
|
|
775
|
-
return { equal
|
|
852
|
+
return { equal, get };
|
|
853
|
+
return { equal, ...options, get };
|
|
776
854
|
};
|
|
777
855
|
|
|
778
856
|
// src/lib/createAtomFamily.ts
|
|
779
857
|
var createOptions = (options = {}, family, familyKey, keyStringified) => {
|
|
780
858
|
if (options.name) {
|
|
781
859
|
return {
|
|
782
|
-
equal
|
|
860
|
+
equal,
|
|
783
861
|
...options,
|
|
784
862
|
name: options?.name + "_" + keyStringified,
|
|
785
863
|
family,
|
|
786
864
|
familyKey
|
|
787
865
|
};
|
|
788
866
|
} else {
|
|
789
|
-
return { equal
|
|
867
|
+
return { equal, ...options, family, familyKey };
|
|
790
868
|
}
|
|
791
869
|
};
|
|
792
870
|
var handleDefaultValue = (defaultValue, key) => {
|
|
@@ -857,18 +935,17 @@ var createStoreWithSelectorSet = (id) => {
|
|
|
857
935
|
return store2;
|
|
858
936
|
};
|
|
859
937
|
// src/selectorFamily.ts
|
|
860
|
-
import equal6 from "fast-deep-equal/es6";
|
|
861
938
|
var createOptions2 = (options = {}, family, familyKey, keyStringified) => {
|
|
862
939
|
if (options.name) {
|
|
863
940
|
return {
|
|
864
|
-
equal
|
|
941
|
+
equal,
|
|
865
942
|
...options,
|
|
866
943
|
name: options?.name + "_" + keyStringified,
|
|
867
944
|
family,
|
|
868
945
|
familyKey
|
|
869
946
|
};
|
|
870
947
|
} else {
|
|
871
|
-
return { equal
|
|
948
|
+
return { equal, ...options, family, familyKey };
|
|
872
949
|
}
|
|
873
950
|
};
|
|
874
951
|
var selectorFamily = (get, options) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valdres",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.36",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Eigil Sagafos"
|
|
@@ -23,9 +23,6 @@
|
|
|
23
23
|
"build:types": "rm -rf dist/types && tsc",
|
|
24
24
|
"test": "bun test"
|
|
25
25
|
},
|
|
26
|
-
"dependencies": {
|
|
27
|
-
"fast-deep-equal": ">=3"
|
|
28
|
-
},
|
|
29
26
|
"devDependencies": {
|
|
30
27
|
"@testing-library/react-hooks": "8.0.1",
|
|
31
28
|
"jotai": "2.10.0",
|
|
@@ -39,5 +36,5 @@
|
|
|
39
36
|
"access": "public",
|
|
40
37
|
"registry": "https://registry.npmjs.org/"
|
|
41
38
|
},
|
|
42
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "3932f7880514b5be9ae47edd4009e9f9b886d139"
|
|
43
40
|
}
|