react-shared-states 2.1.0 → 2.1.2
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/SharedValuesManager.d.ts +2 -0
- package/dist/main.esm.js +239 -226
- package/dist/main.min.js +2 -2
- package/package.json +12 -12
|
@@ -3,7 +3,9 @@ export declare const staticStores: SharedCreated[];
|
|
|
3
3
|
export declare class SharedValuesManager<T> {
|
|
4
4
|
protected defaultValue: () => T;
|
|
5
5
|
data: Map<string, SharedValue<T>>;
|
|
6
|
+
static INSTANCES: Map<string, SharedValuesManager<any>>;
|
|
6
7
|
constructor(defaultValue?: () => T);
|
|
8
|
+
static getInstance<T>(instanceKey: string, defaultValue?: () => T): SharedValuesManager<T>;
|
|
7
9
|
addListener(key: string, prefix: Prefix, listener: AFunction): void;
|
|
8
10
|
removeListener(key: string, prefix: Prefix, listener: AFunction): void;
|
|
9
11
|
callListeners(key: string, prefix: Prefix): void;
|
package/dist/main.esm.js
CHANGED
|
@@ -1,323 +1,336 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* react-shared-states v2.1.
|
|
2
|
+
* react-shared-states v2.1.2
|
|
3
3
|
* (c) Hichem Taboukouyout
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
* Github: github.com/HichemTab-tech/react-shared-states
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { jsx as
|
|
9
|
-
import { createContext as
|
|
10
|
-
let
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
}, K = (...
|
|
14
|
-
|
|
8
|
+
import { jsx as V } from "react/jsx-runtime";
|
|
9
|
+
import { createContext as W, useMemo as b, useContext as Y, useEffect as I, useSyncExternalStore as j, useRef as k } from "react";
|
|
10
|
+
let B = !1;
|
|
11
|
+
const ee = (a) => {
|
|
12
|
+
B = a;
|
|
13
|
+
}, K = (...a) => {
|
|
14
|
+
B && console.log(
|
|
15
15
|
"%c[react-shared-states]",
|
|
16
16
|
"color: #007acc; font-weight: bold",
|
|
17
|
-
...
|
|
17
|
+
...a
|
|
18
18
|
);
|
|
19
|
-
},
|
|
20
|
-
if (!
|
|
21
|
-
return
|
|
22
|
-
}, G = () => Math.random().toString(36).substring(2, 15),
|
|
19
|
+
}, w = (a) => {
|
|
20
|
+
if (!a) throw new Error("Value is empty");
|
|
21
|
+
return a;
|
|
22
|
+
}, G = () => Math.random().toString(36).substring(2, 15), z = W(void 0), te = ({ children: a, scopeName: t }) => {
|
|
23
23
|
if (t && t.includes("//")) throw new Error("scopeName cannot contain '//'");
|
|
24
|
-
return t || (t = b(() => G(), [])), /* @__PURE__ */
|
|
25
|
-
}, H = () =>
|
|
24
|
+
return t || (t = b(() => G(), [])), /* @__PURE__ */ V(z.Provider, { value: { scopeName: t }, children: a });
|
|
25
|
+
}, H = () => Y(z), $ = [], D = /* @__PURE__ */ Symbol.for("react-shared-states.manager");
|
|
26
|
+
function J(a, t = () => null) {
|
|
27
|
+
const s = globalThis;
|
|
28
|
+
return s[D] || (s[D] = {}), s[D][a] || (s[D][a] = new l(t)), s[D][a];
|
|
29
|
+
}
|
|
26
30
|
class l {
|
|
27
31
|
constructor(t = () => null) {
|
|
28
32
|
this.defaultValue = t;
|
|
29
33
|
}
|
|
30
34
|
data = /* @__PURE__ */ new Map();
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
static INSTANCES = /* @__PURE__ */ new Map();
|
|
36
|
+
static getInstance(t, s = () => null) {
|
|
37
|
+
return J(t, s);
|
|
38
|
+
}
|
|
39
|
+
addListener(t, s, e) {
|
|
40
|
+
const i = l.prefix(t, s), r = this.data.get(i);
|
|
33
41
|
r && r.listeners.push(e);
|
|
34
42
|
}
|
|
35
|
-
removeListener(t,
|
|
36
|
-
const i = l.prefix(t,
|
|
37
|
-
r && (r.listeners = r.listeners.filter((
|
|
43
|
+
removeListener(t, s, e) {
|
|
44
|
+
const i = l.prefix(t, s), r = this.data.get(i);
|
|
45
|
+
r && (r.listeners = r.listeners.filter((n) => n !== e));
|
|
38
46
|
}
|
|
39
|
-
callListeners(t,
|
|
40
|
-
const e = l.prefix(t,
|
|
47
|
+
callListeners(t, s) {
|
|
48
|
+
const e = l.prefix(t, s), i = this.data.get(e);
|
|
41
49
|
i && i.listeners.forEach((r) => r());
|
|
42
50
|
}
|
|
43
|
-
init(t,
|
|
44
|
-
const r = l.prefix(t,
|
|
51
|
+
init(t, s, e, i = !1) {
|
|
52
|
+
const r = l.prefix(t, s);
|
|
45
53
|
this.data.has(r) || this.data.set(r, {
|
|
46
54
|
value: e,
|
|
47
55
|
isStatic: i || void 0,
|
|
48
56
|
listeners: []
|
|
49
57
|
});
|
|
50
58
|
}
|
|
51
|
-
createStatic(t,
|
|
59
|
+
createStatic(t, s, e) {
|
|
52
60
|
const i = e ?? "_global", r = {
|
|
53
61
|
key: G(),
|
|
54
62
|
prefix: i,
|
|
55
63
|
...t
|
|
56
64
|
};
|
|
57
|
-
return
|
|
65
|
+
return $.push(r), this.init(r.key, r.prefix, s, !0), this.defaultValue = () => s, r;
|
|
58
66
|
}
|
|
59
67
|
initStatic(t) {
|
|
60
|
-
const { key:
|
|
61
|
-
this.init(
|
|
68
|
+
const { key: s, prefix: e } = t;
|
|
69
|
+
this.init(s, e, this.defaultValue(), !0);
|
|
62
70
|
}
|
|
63
|
-
clearAll(t = !1,
|
|
71
|
+
clearAll(t = !1, s = !1) {
|
|
64
72
|
this.data.forEach((e, i) => {
|
|
65
|
-
const [r,
|
|
66
|
-
this.clear(
|
|
73
|
+
const [r, n] = l.extractPrefix(i);
|
|
74
|
+
this.clear(n, r, t, s);
|
|
67
75
|
});
|
|
68
76
|
}
|
|
69
|
-
clear(t,
|
|
70
|
-
const r = l.prefix(t,
|
|
71
|
-
e || this.callListeners(t,
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
75
|
-
|
|
77
|
+
clear(t, s, e = !1, i = !1) {
|
|
78
|
+
const r = l.prefix(t, s);
|
|
79
|
+
e || this.callListeners(t, s);
|
|
80
|
+
const n = this.data.get(r);
|
|
81
|
+
if (n && (this.data.delete(r), n.isStatic && !i)) {
|
|
82
|
+
const o = $.find((c) => c.key === t && c.prefix === s);
|
|
83
|
+
o && this.initStatic(o);
|
|
76
84
|
}
|
|
77
85
|
}
|
|
78
|
-
get(t,
|
|
79
|
-
let e = this.has(t,
|
|
86
|
+
get(t, s) {
|
|
87
|
+
let e = this.has(t, s);
|
|
80
88
|
if (e)
|
|
81
89
|
return this.data.get(e);
|
|
82
90
|
}
|
|
83
|
-
setValue(t,
|
|
84
|
-
const i = l.prefix(t,
|
|
91
|
+
setValue(t, s, e) {
|
|
92
|
+
const i = l.prefix(t, s), r = this.data.get(i);
|
|
85
93
|
r && (r.value = e, this.data.set(i, r));
|
|
86
94
|
}
|
|
87
|
-
has(t,
|
|
88
|
-
return this.data.has(l.prefix(t,
|
|
95
|
+
has(t, s) {
|
|
96
|
+
return this.data.has(l.prefix(t, s)) ? l.prefix(t, s) : this.data.has(l.prefix(t, "_global")) ? l.prefix(t, "_global") : void 0;
|
|
89
97
|
}
|
|
90
|
-
static prefix(t,
|
|
98
|
+
static prefix(t, s) {
|
|
91
99
|
if (t.includes("//")) throw new Error("key cannot contain '//'");
|
|
92
|
-
return `${
|
|
100
|
+
return `${s}//${t}`;
|
|
93
101
|
}
|
|
94
102
|
static extractPrefix(t) {
|
|
95
|
-
const
|
|
96
|
-
return [
|
|
103
|
+
const s = t.split("//");
|
|
104
|
+
return [s[0], s.slice(1).join("//")];
|
|
97
105
|
}
|
|
98
|
-
useEffect(t,
|
|
99
|
-
|
|
100
|
-
e?.(), K(`[${l.prefix(t,
|
|
101
|
-
const i = this.get(t,
|
|
102
|
-
i && i.listeners?.length === 0 && this.clear(t,
|
|
103
|
-
}, [t,
|
|
106
|
+
useEffect(t, s, e = null) {
|
|
107
|
+
I(() => () => {
|
|
108
|
+
e?.(), K(`[${l.prefix(t, s)}]`, "unmount effect");
|
|
109
|
+
const i = this.get(t, s);
|
|
110
|
+
i && i.listeners?.length === 0 && this.clear(t, s);
|
|
111
|
+
}, [t, s]);
|
|
104
112
|
}
|
|
105
113
|
}
|
|
106
|
-
class
|
|
114
|
+
class R {
|
|
107
115
|
constructor(t) {
|
|
108
116
|
this.sharedData = t;
|
|
109
117
|
}
|
|
110
|
-
_get(t,
|
|
111
|
-
let e, i =
|
|
118
|
+
_get(t, s) {
|
|
119
|
+
let e, i = s;
|
|
112
120
|
if (typeof t != "string") {
|
|
113
|
-
const { key:
|
|
114
|
-
e =
|
|
121
|
+
const { key: o, prefix: c } = t;
|
|
122
|
+
e = o, i = c;
|
|
115
123
|
} else
|
|
116
|
-
e =
|
|
117
|
-
const r = i || "_global",
|
|
118
|
-
return
|
|
124
|
+
e = w(t);
|
|
125
|
+
const r = i || "_global", n = this.sharedData.get(e, r);
|
|
126
|
+
return n ? { value: n.value, key: e, prefix: r } : {
|
|
119
127
|
key: e,
|
|
120
128
|
prefix: r,
|
|
121
129
|
value: void 0
|
|
122
130
|
};
|
|
123
131
|
}
|
|
124
|
-
get(t,
|
|
125
|
-
return this._get(t,
|
|
132
|
+
get(t, s) {
|
|
133
|
+
return this._get(t, s).value;
|
|
126
134
|
}
|
|
127
|
-
set(t,
|
|
135
|
+
set(t, s, e) {
|
|
128
136
|
let i, r = e;
|
|
129
137
|
if (typeof t != "string") {
|
|
130
|
-
const { key:
|
|
131
|
-
i =
|
|
138
|
+
const { key: o, prefix: c } = t;
|
|
139
|
+
i = o, r = c;
|
|
132
140
|
} else
|
|
133
|
-
i =
|
|
134
|
-
const
|
|
135
|
-
this.sharedData.init(i,
|
|
141
|
+
i = w(t);
|
|
142
|
+
const n = r || "_global";
|
|
143
|
+
this.sharedData.init(i, n, s), this.sharedData.setValue(i, n, s), this.sharedData.callListeners(i, n);
|
|
136
144
|
}
|
|
137
|
-
update(t,
|
|
145
|
+
update(t, s, e) {
|
|
138
146
|
const i = this._get(t, e);
|
|
139
147
|
if (i) {
|
|
140
|
-
const r =
|
|
148
|
+
const r = s(i.value);
|
|
141
149
|
this.set(i.key, r, i.prefix);
|
|
142
150
|
}
|
|
143
151
|
}
|
|
152
|
+
// noinspection JSUnusedGlobalSymbols
|
|
144
153
|
clearAll() {
|
|
145
154
|
this.sharedData.clearAll();
|
|
146
155
|
}
|
|
156
|
+
// noinspection JSUnusedGlobalSymbols
|
|
147
157
|
clearScope(t) {
|
|
148
|
-
const
|
|
158
|
+
const s = t || "_global";
|
|
149
159
|
this.sharedData.data.forEach((e, i) => {
|
|
150
|
-
const [r,
|
|
151
|
-
r ===
|
|
160
|
+
const [r, n] = l.extractPrefix(i);
|
|
161
|
+
r === s && (this.sharedData.clear(n, r), this.sharedData.callListeners(n, r));
|
|
152
162
|
});
|
|
153
163
|
}
|
|
164
|
+
// noinspection JSUnusedGlobalSymbols
|
|
154
165
|
resolve(t) {
|
|
155
|
-
const { key:
|
|
156
|
-
return this.get(
|
|
166
|
+
const { key: s, prefix: e } = t;
|
|
167
|
+
return this.get(s, e);
|
|
157
168
|
}
|
|
158
|
-
clear(t,
|
|
169
|
+
clear(t, s) {
|
|
159
170
|
let e, i;
|
|
160
|
-
typeof t == "string" ? (e = t, i =
|
|
171
|
+
typeof t == "string" ? (e = t, i = s || "_global") : (e = t.key, i = t.prefix), this.sharedData.clear(e, i);
|
|
161
172
|
}
|
|
162
|
-
|
|
163
|
-
|
|
173
|
+
// noinspection JSUnusedGlobalSymbols
|
|
174
|
+
has(t, s = "_global") {
|
|
175
|
+
const e = s || "_global";
|
|
164
176
|
return !!this.sharedData.has(t, e);
|
|
165
177
|
}
|
|
178
|
+
// noinspection JSUnusedGlobalSymbols
|
|
166
179
|
getAll() {
|
|
167
180
|
const t = {};
|
|
168
|
-
return this.sharedData.data.forEach((
|
|
181
|
+
return this.sharedData.data.forEach((s, e) => {
|
|
169
182
|
const [i, r] = l.extractPrefix(e);
|
|
170
|
-
t[i] = t[i] || {}, t[i][r] =
|
|
183
|
+
t[i] = t[i] || {}, t[i][r] = s.value;
|
|
171
184
|
}), t;
|
|
172
185
|
}
|
|
173
|
-
subscribe(t,
|
|
186
|
+
subscribe(t, s, e) {
|
|
174
187
|
let i, r;
|
|
175
|
-
return typeof t == "string" ? (i = t, r = e || "_global") : (i = t.key, r = t.prefix), this.sharedData.addListener(i, r,
|
|
176
|
-
this.sharedData.removeListener(i, r,
|
|
188
|
+
return typeof t == "string" ? (i = t, r = e || "_global") : (i = t.key, r = t.prefix), this.sharedData.addListener(i, r, s), () => {
|
|
189
|
+
this.sharedData.removeListener(i, r, s);
|
|
177
190
|
};
|
|
178
191
|
}
|
|
179
192
|
}
|
|
180
|
-
const
|
|
193
|
+
const C = (a) => {
|
|
181
194
|
const t = H();
|
|
182
195
|
return {
|
|
183
|
-
prefix:
|
|
196
|
+
prefix: a ?? t?.scopeName ?? "_global"
|
|
184
197
|
};
|
|
185
198
|
};
|
|
186
|
-
function
|
|
187
|
-
return
|
|
199
|
+
function N(a) {
|
|
200
|
+
return a && a.__esModule && Object.prototype.hasOwnProperty.call(a, "default") ? a.default : a;
|
|
188
201
|
}
|
|
189
|
-
var
|
|
202
|
+
var F, q;
|
|
190
203
|
function Q() {
|
|
191
|
-
if (
|
|
192
|
-
|
|
193
|
-
var
|
|
194
|
-
function i(r,
|
|
195
|
-
if (r ===
|
|
196
|
-
if (r &&
|
|
197
|
-
if (r.constructor !==
|
|
198
|
-
var
|
|
204
|
+
if (q) return F;
|
|
205
|
+
q = 1;
|
|
206
|
+
var a = typeof Element < "u", t = typeof Map == "function", s = typeof Set == "function", e = typeof ArrayBuffer == "function" && !!ArrayBuffer.isView;
|
|
207
|
+
function i(r, n) {
|
|
208
|
+
if (r === n) return !0;
|
|
209
|
+
if (r && n && typeof r == "object" && typeof n == "object") {
|
|
210
|
+
if (r.constructor !== n.constructor) return !1;
|
|
211
|
+
var o, c, d;
|
|
199
212
|
if (Array.isArray(r)) {
|
|
200
|
-
if (
|
|
201
|
-
for (c =
|
|
202
|
-
if (!i(r[c],
|
|
213
|
+
if (o = r.length, o != n.length) return !1;
|
|
214
|
+
for (c = o; c-- !== 0; )
|
|
215
|
+
if (!i(r[c], n[c])) return !1;
|
|
203
216
|
return !0;
|
|
204
217
|
}
|
|
205
218
|
var u;
|
|
206
|
-
if (t && r instanceof Map &&
|
|
207
|
-
if (r.size !==
|
|
219
|
+
if (t && r instanceof Map && n instanceof Map) {
|
|
220
|
+
if (r.size !== n.size) return !1;
|
|
208
221
|
for (u = r.entries(); !(c = u.next()).done; )
|
|
209
|
-
if (!
|
|
222
|
+
if (!n.has(c.value[0])) return !1;
|
|
210
223
|
for (u = r.entries(); !(c = u.next()).done; )
|
|
211
|
-
if (!i(c.value[1],
|
|
224
|
+
if (!i(c.value[1], n.get(c.value[0]))) return !1;
|
|
212
225
|
return !0;
|
|
213
226
|
}
|
|
214
|
-
if (
|
|
215
|
-
if (r.size !==
|
|
227
|
+
if (s && r instanceof Set && n instanceof Set) {
|
|
228
|
+
if (r.size !== n.size) return !1;
|
|
216
229
|
for (u = r.entries(); !(c = u.next()).done; )
|
|
217
|
-
if (!
|
|
230
|
+
if (!n.has(c.value[0])) return !1;
|
|
218
231
|
return !0;
|
|
219
232
|
}
|
|
220
|
-
if (e && ArrayBuffer.isView(r) && ArrayBuffer.isView(
|
|
221
|
-
if (
|
|
222
|
-
for (c =
|
|
223
|
-
if (r[c] !==
|
|
233
|
+
if (e && ArrayBuffer.isView(r) && ArrayBuffer.isView(n)) {
|
|
234
|
+
if (o = r.length, o != n.length) return !1;
|
|
235
|
+
for (c = o; c-- !== 0; )
|
|
236
|
+
if (r[c] !== n[c]) return !1;
|
|
224
237
|
return !0;
|
|
225
238
|
}
|
|
226
|
-
if (r.constructor === RegExp) return r.source ===
|
|
227
|
-
if (r.valueOf !== Object.prototype.valueOf && typeof r.valueOf == "function" && typeof
|
|
228
|
-
if (r.toString !== Object.prototype.toString && typeof r.toString == "function" && typeof
|
|
229
|
-
if (d = Object.keys(r),
|
|
230
|
-
for (c =
|
|
231
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
232
|
-
if (
|
|
233
|
-
for (c =
|
|
234
|
-
if (!((d[c] === "_owner" || d[c] === "__v" || d[c] === "__o") && r.$$typeof) && !i(r[d[c]],
|
|
239
|
+
if (r.constructor === RegExp) return r.source === n.source && r.flags === n.flags;
|
|
240
|
+
if (r.valueOf !== Object.prototype.valueOf && typeof r.valueOf == "function" && typeof n.valueOf == "function") return r.valueOf() === n.valueOf();
|
|
241
|
+
if (r.toString !== Object.prototype.toString && typeof r.toString == "function" && typeof n.toString == "function") return r.toString() === n.toString();
|
|
242
|
+
if (d = Object.keys(r), o = d.length, o !== Object.keys(n).length) return !1;
|
|
243
|
+
for (c = o; c-- !== 0; )
|
|
244
|
+
if (!Object.prototype.hasOwnProperty.call(n, d[c])) return !1;
|
|
245
|
+
if (a && r instanceof Element) return !1;
|
|
246
|
+
for (c = o; c-- !== 0; )
|
|
247
|
+
if (!((d[c] === "_owner" || d[c] === "__v" || d[c] === "__o") && r.$$typeof) && !i(r[d[c]], n[d[c]]))
|
|
235
248
|
return !1;
|
|
236
249
|
return !0;
|
|
237
250
|
}
|
|
238
|
-
return r !== r &&
|
|
251
|
+
return r !== r && n !== n;
|
|
239
252
|
}
|
|
240
|
-
return
|
|
253
|
+
return F = function(n, o) {
|
|
241
254
|
try {
|
|
242
|
-
return i(
|
|
255
|
+
return i(n, o);
|
|
243
256
|
} catch (c) {
|
|
244
257
|
if ((c.message || "").match(/stack|recursion/i))
|
|
245
258
|
return console.warn("react-fast-compare cannot handle circular refs"), !1;
|
|
246
259
|
throw c;
|
|
247
260
|
}
|
|
248
|
-
},
|
|
261
|
+
}, F;
|
|
249
262
|
}
|
|
250
263
|
var U = Q();
|
|
251
|
-
const
|
|
252
|
-
function
|
|
253
|
-
let e, i, r =
|
|
254
|
-
if (typeof
|
|
255
|
-
const { key: f, initialValue: v, prefix:
|
|
256
|
-
e = f, i = v, r =
|
|
264
|
+
const T = /* @__PURE__ */ N(U), h = l.getInstance("sharedStatesManager"), re = new R(h), se = (a, t) => h.createStatic({ initialValue: a }, a, t);
|
|
265
|
+
function ne(a, t, s) {
|
|
266
|
+
let e, i, r = s;
|
|
267
|
+
if (typeof a != "string") {
|
|
268
|
+
const { key: f, initialValue: v, prefix: S } = a;
|
|
269
|
+
e = f, i = v, r = S;
|
|
257
270
|
} else
|
|
258
|
-
e =
|
|
259
|
-
const { prefix:
|
|
260
|
-
h.init(e,
|
|
261
|
-
const
|
|
262
|
-
h.removeListener(e,
|
|
263
|
-
}), [e,
|
|
264
|
-
const v = typeof f == "function" ? f(h.get(e,
|
|
265
|
-
|
|
271
|
+
e = w(a), i = t;
|
|
272
|
+
const { prefix: n } = C(r);
|
|
273
|
+
h.init(e, n, i);
|
|
274
|
+
const o = b(() => (f) => (h.init(e, n, t), h.addListener(e, n, f), () => {
|
|
275
|
+
h.removeListener(e, n, f);
|
|
276
|
+
}), [e, n, t]), c = b(() => () => h.get(e, n)?.value, [e, n]), d = j(o, c), u = (f) => {
|
|
277
|
+
const v = typeof f == "function" ? f(h.get(e, n)?.value) : f;
|
|
278
|
+
T(v, d) || (h.setValue(e, n, v), h.callListeners(e, n));
|
|
266
279
|
};
|
|
267
|
-
return h.useEffect(e,
|
|
280
|
+
return h.useEffect(e, n), [
|
|
268
281
|
d,
|
|
269
282
|
u
|
|
270
283
|
];
|
|
271
284
|
}
|
|
272
|
-
function
|
|
273
|
-
let e, i =
|
|
274
|
-
if (typeof
|
|
275
|
-
const { key: u, prefix: f } =
|
|
285
|
+
function ie(a, t, s) {
|
|
286
|
+
let e, i = s;
|
|
287
|
+
if (typeof a != "string") {
|
|
288
|
+
const { key: u, prefix: f } = a;
|
|
276
289
|
e = u, i = f;
|
|
277
290
|
} else
|
|
278
|
-
e =
|
|
279
|
-
const { prefix: r } =
|
|
291
|
+
e = w(a);
|
|
292
|
+
const { prefix: r } = C(i), n = k(void 0), o = b(() => (u) => (h.init(e, r, void 0), h.addListener(e, r, u), () => {
|
|
280
293
|
h.removeListener(e, r, u);
|
|
281
294
|
}), [e, r]), c = b(() => () => {
|
|
282
295
|
const u = h.get(e, r)?.value, f = t(u);
|
|
283
|
-
return
|
|
284
|
-
}, [e, r, t]), d =
|
|
296
|
+
return T(n.current, f) ? n.current : (n.current = f, f);
|
|
297
|
+
}, [e, r, t]), d = j(o, c);
|
|
285
298
|
return h.useEffect(e, r), d;
|
|
286
299
|
}
|
|
287
|
-
const y =
|
|
300
|
+
const y = l.getInstance("SharedFunctionValue"), _ = new R(y), O = {
|
|
288
301
|
results: void 0,
|
|
289
302
|
isLoading: !1,
|
|
290
303
|
error: void 0
|
|
291
|
-
},
|
|
292
|
-
function
|
|
293
|
-
let e, i, r =
|
|
294
|
-
if (typeof
|
|
295
|
-
const { key: f, fn: v, prefix:
|
|
296
|
-
e = f, i = v, r =
|
|
304
|
+
}, ae = (a, t) => y.createStatic({ fn: a }, O, t);
|
|
305
|
+
function oe(a, t, s) {
|
|
306
|
+
let e, i, r = s;
|
|
307
|
+
if (typeof a != "string") {
|
|
308
|
+
const { key: f, fn: v, prefix: S } = a;
|
|
309
|
+
e = f, i = v, r = S;
|
|
297
310
|
} else
|
|
298
|
-
e =
|
|
299
|
-
const { prefix:
|
|
300
|
-
y.init(e,
|
|
301
|
-
const
|
|
302
|
-
() => (f) => (y.init(e,
|
|
303
|
-
y.removeListener(e,
|
|
311
|
+
e = w(a), i = t;
|
|
312
|
+
const { prefix: n } = C(r);
|
|
313
|
+
y.init(e, n, O);
|
|
314
|
+
const o = b(
|
|
315
|
+
() => (f) => (y.init(e, n, O), y.addListener(e, n, f), () => {
|
|
316
|
+
y.removeListener(e, n, f);
|
|
304
317
|
}),
|
|
305
|
-
[e,
|
|
318
|
+
[e, n]
|
|
306
319
|
), c = b(
|
|
307
|
-
() => () => y.get(e,
|
|
308
|
-
[e,
|
|
309
|
-
), d =
|
|
310
|
-
const
|
|
311
|
-
if (!f && (
|
|
312
|
-
|
|
320
|
+
() => () => y.get(e, n).value,
|
|
321
|
+
[e, n]
|
|
322
|
+
), d = j(o, c), u = async (f, ...v) => {
|
|
323
|
+
const S = y.get(e, n);
|
|
324
|
+
if (!f && (S.value.isLoading || S.value.results !== void 0)) return S.value;
|
|
325
|
+
_.update(e, (x) => ({ ...x, isLoading: !0, error: void 0 }), n);
|
|
313
326
|
try {
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
} catch (
|
|
317
|
-
|
|
327
|
+
const x = await i(...v);
|
|
328
|
+
_.set(e, { results: x, isLoading: !1, error: void 0 }, n);
|
|
329
|
+
} catch (x) {
|
|
330
|
+
_.update(e, (p) => ({ ...p, isLoading: !1, error: x }), n);
|
|
318
331
|
}
|
|
319
332
|
};
|
|
320
|
-
return y.useEffect(e,
|
|
333
|
+
return y.useEffect(e, n), {
|
|
321
334
|
state: d,
|
|
322
335
|
trigger: (...f) => {
|
|
323
336
|
u(!1, ...f);
|
|
@@ -326,85 +339,85 @@ function ie(o, t, n) {
|
|
|
326
339
|
u(!0, ...f);
|
|
327
340
|
},
|
|
328
341
|
clear: () => {
|
|
329
|
-
|
|
342
|
+
_.set(e, O, n);
|
|
330
343
|
}
|
|
331
344
|
};
|
|
332
345
|
}
|
|
333
|
-
const g =
|
|
346
|
+
const g = l.getInstance("SharedSubscription"), E = new R(g), M = {
|
|
334
347
|
data: void 0,
|
|
335
348
|
isLoading: !1,
|
|
336
349
|
error: void 0,
|
|
337
350
|
subscribed: !1,
|
|
338
351
|
unsubscribe: void 0
|
|
339
|
-
},
|
|
340
|
-
async function
|
|
341
|
-
const
|
|
342
|
-
|
|
352
|
+
}, ce = (a, t, s) => g.createStatic({ subscriber: a }, { ...M, data: t?.initialValue }, s);
|
|
353
|
+
async function P(a, t) {
|
|
354
|
+
const s = g.get(a, t);
|
|
355
|
+
s?.value.unsubscribe && (s.value.unsubscribe(), E.update(a, (e) => ({ ...e, unsubscribe: void 0, subscribed: !1 }), t));
|
|
343
356
|
}
|
|
344
|
-
function
|
|
345
|
-
let e, i, r =
|
|
346
|
-
if (typeof
|
|
347
|
-
const { key: p, subscriber: m, prefix: L, triggerImmediately:
|
|
348
|
-
e = p, i = m, r = L,
|
|
357
|
+
function fe(a, t, s) {
|
|
358
|
+
let e, i, r = s, n = !1;
|
|
359
|
+
if (typeof a != "string") {
|
|
360
|
+
const { key: p, subscriber: m, prefix: L, triggerImmediately: A } = a;
|
|
361
|
+
e = p, i = m, r = L, n = A ?? !1;
|
|
349
362
|
} else
|
|
350
|
-
e =
|
|
351
|
-
const { prefix:
|
|
352
|
-
g.init(e,
|
|
363
|
+
e = w(a), i = t;
|
|
364
|
+
const { prefix: o } = C(r);
|
|
365
|
+
g.init(e, o, M);
|
|
353
366
|
const c = b(
|
|
354
|
-
() => (p) => (g.init(e,
|
|
355
|
-
g.removeListener(e,
|
|
367
|
+
() => (p) => (g.init(e, o, M), g.addListener(e, o, p), () => {
|
|
368
|
+
g.removeListener(e, o, p);
|
|
356
369
|
}),
|
|
357
|
-
[e,
|
|
370
|
+
[e, o]
|
|
358
371
|
), d = b(
|
|
359
|
-
() => () => g.get(e,
|
|
360
|
-
[e,
|
|
361
|
-
), u =
|
|
362
|
-
|
|
372
|
+
() => () => g.get(e, o).value,
|
|
373
|
+
[e, o]
|
|
374
|
+
), u = j(c, d), f = (p) => {
|
|
375
|
+
E.update(e, (m) => ({ ...m, data: p }), o);
|
|
363
376
|
}, v = (p) => {
|
|
364
|
-
|
|
365
|
-
},
|
|
366
|
-
|
|
367
|
-
},
|
|
368
|
-
const m = g.get(e,
|
|
369
|
-
if (p && await
|
|
370
|
-
K("triggered !!"),
|
|
377
|
+
E.update(e, (m) => ({ ...m, isLoading: !1, data: void 0, error: p }), o);
|
|
378
|
+
}, S = () => {
|
|
379
|
+
E.update(e, (p) => ({ ...p, isLoading: !1 }), o);
|
|
380
|
+
}, x = async (p) => {
|
|
381
|
+
const m = g.get(e, o);
|
|
382
|
+
if (p && await P(e, o), m.value.subscribed && !p) return m.value;
|
|
383
|
+
K("triggered !!"), E.update(e, (L) => ({ ...L, isLoading: !0, error: void 0 }), o);
|
|
371
384
|
try {
|
|
372
|
-
const L = await i(f, v,
|
|
373
|
-
|
|
385
|
+
const L = await i(f, v, S);
|
|
386
|
+
E.update(e, (A) => ({ ...A, unsubscribe: L, subscribed: !0, isLoading: !1 }), o);
|
|
374
387
|
} catch (L) {
|
|
375
|
-
|
|
388
|
+
E.update(e, (A) => ({ ...A, isLoading: !1, error: L }), o);
|
|
376
389
|
}
|
|
377
390
|
};
|
|
378
|
-
return
|
|
379
|
-
K(`[${l.prefix(e,
|
|
380
|
-
}, [e,
|
|
381
|
-
|
|
391
|
+
return I(() => () => {
|
|
392
|
+
K(`[${l.prefix(e, o)}]`, "unmount effect2"), g.get(e, o)?.listeners.length === 0 && P(e, o);
|
|
393
|
+
}, [e, o]), g.useEffect(e, o), I(() => {
|
|
394
|
+
n && x(!1);
|
|
382
395
|
}, []), {
|
|
383
396
|
state: u,
|
|
384
397
|
trigger: () => {
|
|
385
|
-
|
|
398
|
+
x(!1);
|
|
386
399
|
},
|
|
387
400
|
forceTrigger: () => {
|
|
388
|
-
|
|
401
|
+
x(!0);
|
|
389
402
|
},
|
|
390
403
|
unsubscribe: () => {
|
|
391
|
-
|
|
404
|
+
P(e, o);
|
|
392
405
|
}
|
|
393
406
|
};
|
|
394
407
|
}
|
|
395
408
|
export {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
409
|
+
te as SharedStatesProvider,
|
|
410
|
+
ae as createSharedFunction,
|
|
411
|
+
se as createSharedState,
|
|
412
|
+
ce as createSharedSubscription,
|
|
413
|
+
B as isDevMode,
|
|
414
|
+
ee as setDevMode,
|
|
415
|
+
_ as sharedFunctionsApi,
|
|
416
|
+
re as sharedStatesApi,
|
|
417
|
+
E as sharedSubscriptionsApi,
|
|
418
|
+
C as useSharedContext,
|
|
419
|
+
oe as useSharedFunction,
|
|
420
|
+
ne as useSharedState,
|
|
421
|
+
ie as useSharedStateSelector,
|
|
422
|
+
fe as useSharedSubscription
|
|
410
423
|
};
|
package/dist/main.min.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* react-shared-states v2.1.
|
|
2
|
+
* react-shared-states v2.1.2
|
|
3
3
|
* (c) Hichem Taboukouyout
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
* Github: github.com/HichemTab-tech/react-shared-states
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
(function(
|
|
8
|
+
(function(f,D){typeof exports=="object"&&typeof module<"u"?D(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],D):(f=typeof globalThis<"u"?globalThis:f||self,D(f.ReactSharedStates={},f.jsxRuntime,f.React))})(this,(function(f,D,h){"use strict";f.isDevMode=!1;const z=a=>{f.isDevMode=a},P=(...a)=>{f.isDevMode&&console.log("%c[react-shared-states]","color: #007acc; font-weight: bold",...a)},A=a=>{if(!a)throw new Error("Value is empty");return a},T=()=>Math.random().toString(36).substring(2,15),K=h.createContext(void 0),V=({children:a,scopeName:t})=>{if(t&&t.includes("//"))throw new Error("scopeName cannot contain '//'");return t||(t=h.useMemo(()=>T(),[])),D.jsx(K.Provider,{value:{scopeName:t},children:a})},W=()=>h.useContext(K),$=[],M=Symbol.for("react-shared-states.manager");function Y(a,t=()=>null){const s=globalThis;return s[M]||(s[M]={}),s[M][a]||(s[M][a]=new l(t)),s[M][a]}class l{constructor(t=()=>null){this.defaultValue=t}data=new Map;static INSTANCES=new Map;static getInstance(t,s=()=>null){return Y(t,s)}addListener(t,s,e){const i=l.prefix(t,s),r=this.data.get(i);r&&r.listeners.push(e)}removeListener(t,s,e){const i=l.prefix(t,s),r=this.data.get(i);r&&(r.listeners=r.listeners.filter(n=>n!==e))}callListeners(t,s){const e=l.prefix(t,s),i=this.data.get(e);i&&i.listeners.forEach(r=>r())}init(t,s,e,i=!1){const r=l.prefix(t,s);this.data.has(r)||this.data.set(r,{value:e,isStatic:i||void 0,listeners:[]})}createStatic(t,s,e){const i=e??"_global",r={key:T(),prefix:i,...t};return $.push(r),this.init(r.key,r.prefix,s,!0),this.defaultValue=()=>s,r}initStatic(t){const{key:s,prefix:e}=t;this.init(s,e,this.defaultValue(),!0)}clearAll(t=!1,s=!1){this.data.forEach((e,i)=>{const[r,n]=l.extractPrefix(i);this.clear(n,r,t,s)})}clear(t,s,e=!1,i=!1){const r=l.prefix(t,s);e||this.callListeners(t,s);const n=this.data.get(r);if(n&&(this.data.delete(r),n.isStatic&&!i)){const o=$.find(u=>u.key===t&&u.prefix===s);o&&this.initStatic(o)}}get(t,s){let e=this.has(t,s);if(e)return this.data.get(e)}setValue(t,s,e){const i=l.prefix(t,s),r=this.data.get(i);r&&(r.value=e,this.data.set(i,r))}has(t,s){return this.data.has(l.prefix(t,s))?l.prefix(t,s):this.data.has(l.prefix(t,"_global"))?l.prefix(t,"_global"):void 0}static prefix(t,s){if(t.includes("//"))throw new Error("key cannot contain '//'");return`${s}//${t}`}static extractPrefix(t){const s=t.split("//");return[s[0],s.slice(1).join("//")]}useEffect(t,s,e=null){h.useEffect(()=>()=>{e?.(),P(`[${l.prefix(t,s)}]`,"unmount effect");const i=this.get(t,s);i&&i.listeners?.length===0&&this.clear(t,s)},[t,s])}}class C{constructor(t){this.sharedData=t}_get(t,s){let e,i=s;if(typeof t!="string"){const{key:o,prefix:u}=t;e=o,i=u}else e=A(t);const r=i||"_global",n=this.sharedData.get(e,r);return n?{value:n.value,key:e,prefix:r}:{key:e,prefix:r,value:void 0}}get(t,s){return this._get(t,s).value}set(t,s,e){let i,r=e;if(typeof t!="string"){const{key:o,prefix:u}=t;i=o,r=u}else i=A(t);const n=r||"_global";this.sharedData.init(i,n,s),this.sharedData.setValue(i,n,s),this.sharedData.callListeners(i,n)}update(t,s,e){const i=this._get(t,e);if(i){const r=s(i.value);this.set(i.key,r,i.prefix)}}clearAll(){this.sharedData.clearAll()}clearScope(t){const s=t||"_global";this.sharedData.data.forEach((e,i)=>{const[r,n]=l.extractPrefix(i);r===s&&(this.sharedData.clear(n,r),this.sharedData.callListeners(n,r))})}resolve(t){const{key:s,prefix:e}=t;return this.get(s,e)}clear(t,s){let e,i;typeof t=="string"?(e=t,i=s||"_global"):(e=t.key,i=t.prefix),this.sharedData.clear(e,i)}has(t,s="_global"){const e=s||"_global";return!!this.sharedData.has(t,e)}getAll(){const t={};return this.sharedData.data.forEach((s,e)=>{const[i,r]=l.extractPrefix(e);t[i]=t[i]||{},t[i][r]=s.value}),t}subscribe(t,s,e){let i,r;return typeof t=="string"?(i=t,r=e||"_global"):(i=t.key,r=t.prefix),this.sharedData.addListener(i,r,s),()=>{this.sharedData.removeListener(i,r,s)}}}const j=a=>{const t=W();return{prefix:a??t?.scopeName??"_global"}};function k(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var I,B;function H(){if(B)return I;B=1;var a=typeof Element<"u",t=typeof Map=="function",s=typeof Set=="function",e=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function i(r,n){if(r===n)return!0;if(r&&n&&typeof r=="object"&&typeof n=="object"){if(r.constructor!==n.constructor)return!1;var o,u,p;if(Array.isArray(r)){if(o=r.length,o!=n.length)return!1;for(u=o;u--!==0;)if(!i(r[u],n[u]))return!1;return!0}var d;if(t&&r instanceof Map&&n instanceof Map){if(r.size!==n.size)return!1;for(d=r.entries();!(u=d.next()).done;)if(!n.has(u.value[0]))return!1;for(d=r.entries();!(u=d.next()).done;)if(!i(u.value[1],n.get(u.value[0])))return!1;return!0}if(s&&r instanceof Set&&n instanceof Set){if(r.size!==n.size)return!1;for(d=r.entries();!(u=d.next()).done;)if(!n.has(u.value[0]))return!1;return!0}if(e&&ArrayBuffer.isView(r)&&ArrayBuffer.isView(n)){if(o=r.length,o!=n.length)return!1;for(u=o;u--!==0;)if(r[u]!==n[u])return!1;return!0}if(r.constructor===RegExp)return r.source===n.source&&r.flags===n.flags;if(r.valueOf!==Object.prototype.valueOf&&typeof r.valueOf=="function"&&typeof n.valueOf=="function")return r.valueOf()===n.valueOf();if(r.toString!==Object.prototype.toString&&typeof r.toString=="function"&&typeof n.toString=="function")return r.toString()===n.toString();if(p=Object.keys(r),o=p.length,o!==Object.keys(n).length)return!1;for(u=o;u--!==0;)if(!Object.prototype.hasOwnProperty.call(n,p[u]))return!1;if(a&&r instanceof Element)return!1;for(u=o;u--!==0;)if(!((p[u]==="_owner"||p[u]==="__v"||p[u]==="__o")&&r.$$typeof)&&!i(r[p[u]],n[p[u]]))return!1;return!0}return r!==r&&n!==n}return I=function(n,o){try{return i(n,o)}catch(u){if((u.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw u}},I}var J=H();const G=k(J),g=l.getInstance("sharedStatesManager"),N=new C(g),Q=(a,t)=>g.createStatic({initialValue:a},a,t);function U(a,t,s){let e,i,r=s;if(typeof a!="string"){const{key:c,initialValue:y,prefix:m}=a;e=c,i=y,r=m}else e=A(a),i=t;const{prefix:n}=j(r);g.init(e,n,i);const o=h.useMemo(()=>c=>(g.init(e,n,t),g.addListener(e,n,c),()=>{g.removeListener(e,n,c)}),[e,n,t]),u=h.useMemo(()=>()=>g.get(e,n)?.value,[e,n]),p=h.useSyncExternalStore(o,u),d=c=>{const y=typeof c=="function"?c(g.get(e,n)?.value):c;G(y,p)||(g.setValue(e,n,y),g.callListeners(e,n))};return g.useEffect(e,n),[p,d]}function X(a,t,s){let e,i=s;if(typeof a!="string"){const{key:d,prefix:c}=a;e=d,i=c}else e=A(a);const{prefix:r}=j(i),n=h.useRef(void 0),o=h.useMemo(()=>d=>(g.init(e,r,void 0),g.addListener(e,r,d),()=>{g.removeListener(e,r,d)}),[e,r]),u=h.useMemo(()=>()=>{const d=g.get(e,r)?.value,c=t(d);return G(n.current,c)?n.current:(n.current=c,c)},[e,r,t]),p=h.useSyncExternalStore(o,u);return g.useEffect(e,r),p}const x=l.getInstance("SharedFunctionValue"),F=new C(x),_={results:void 0,isLoading:!1,error:void 0},Z=(a,t)=>x.createStatic({fn:a},_,t);function ee(a,t,s){let e,i,r=s;if(typeof a!="string"){const{key:c,fn:y,prefix:m}=a;e=c,i=y,r=m}else e=A(a),i=t;const{prefix:n}=j(r);x.init(e,n,_);const o=h.useMemo(()=>c=>(x.init(e,n,_),x.addListener(e,n,c),()=>{x.removeListener(e,n,c)}),[e,n]),u=h.useMemo(()=>()=>x.get(e,n).value,[e,n]),p=h.useSyncExternalStore(o,u),d=async(c,...y)=>{const m=x.get(e,n);if(!c&&(m.value.isLoading||m.value.results!==void 0))return m.value;F.update(e,b=>({...b,isLoading:!0,error:void 0}),n);try{const b=await i(...y);F.set(e,{results:b,isLoading:!1,error:void 0},n)}catch(b){F.update(e,S=>({...S,isLoading:!1,error:b}),n)}};return x.useEffect(e,n),{state:p,trigger:(...c)=>{d(!1,...c)},forceTrigger:(...c)=>{d(!0,...c)},clear:()=>{F.set(e,_,n)}}}const v=l.getInstance("SharedSubscription"),E=new C(v),R={data:void 0,isLoading:!1,error:void 0,subscribed:!1,unsubscribe:void 0},te=(a,t,s)=>v.createStatic({subscriber:a},{...R,data:t?.initialValue},s);async function q(a,t){const s=v.get(a,t);s?.value.unsubscribe&&(s.value.unsubscribe(),E.update(a,e=>({...e,unsubscribe:void 0,subscribed:!1}),t))}function re(a,t,s){let e,i,r=s,n=!1;if(typeof a!="string"){const{key:S,subscriber:L,prefix:w,triggerImmediately:O}=a;e=S,i=L,r=w,n=O??!1}else e=A(a),i=t;const{prefix:o}=j(r);v.init(e,o,R);const u=h.useMemo(()=>S=>(v.init(e,o,R),v.addListener(e,o,S),()=>{v.removeListener(e,o,S)}),[e,o]),p=h.useMemo(()=>()=>v.get(e,o).value,[e,o]),d=h.useSyncExternalStore(u,p),c=S=>{E.update(e,L=>({...L,data:S}),o)},y=S=>{E.update(e,L=>({...L,isLoading:!1,data:void 0,error:S}),o)},m=()=>{E.update(e,S=>({...S,isLoading:!1}),o)},b=async S=>{const L=v.get(e,o);if(S&&await q(e,o),L.value.subscribed&&!S)return L.value;P("triggered !!"),E.update(e,w=>({...w,isLoading:!0,error:void 0}),o);try{const w=await i(c,y,m);E.update(e,O=>({...O,unsubscribe:w,subscribed:!0,isLoading:!1}),o)}catch(w){E.update(e,O=>({...O,isLoading:!1,error:w}),o)}};return h.useEffect(()=>()=>{P(`[${l.prefix(e,o)}]`,"unmount effect2"),v.get(e,o)?.listeners.length===0&&q(e,o)},[e,o]),v.useEffect(e,o),h.useEffect(()=>{n&&b(!1)},[]),{state:d,trigger:()=>{b(!1)},forceTrigger:()=>{b(!0)},unsubscribe:()=>{q(e,o)}}}f.SharedStatesProvider=V,f.createSharedFunction=Z,f.createSharedState=Q,f.createSharedSubscription=te,f.setDevMode=z,f.sharedFunctionsApi=F,f.sharedStatesApi=N,f.sharedSubscriptionsApi=E,f.useSharedContext=j,f.useSharedFunction=ee,f.useSharedState=U,f.useSharedStateSelector=X,f.useSharedSubscription=re,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-shared-states",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Global state made as simple as useState, with zero config, built-in async caching, and automatic scoping.",
|
|
6
6
|
"keywords": [
|
|
@@ -38,19 +38,19 @@
|
|
|
38
38
|
"homepage": "https://github.com/HichemTab-tech/react-shared-states#readme",
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@testing-library/dom": "^10.4.1",
|
|
41
|
-
"@testing-library/react": "^16.3.
|
|
42
|
-
"@types/node": "^
|
|
43
|
-
"@types/react": "^19.
|
|
44
|
-
"@types/react-dom": "^19.
|
|
45
|
-
"@vitejs/plugin-react": "^5.
|
|
46
|
-
"jsdom": "^27.
|
|
47
|
-
"react": "^19.
|
|
48
|
-
"react-dom": "^19.
|
|
49
|
-
"typescript": "^5.9.
|
|
50
|
-
"vite": "7.
|
|
41
|
+
"@testing-library/react": "^16.3.1",
|
|
42
|
+
"@types/node": "^25.0.3",
|
|
43
|
+
"@types/react": "^19.2.7",
|
|
44
|
+
"@types/react-dom": "^19.2.3",
|
|
45
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
46
|
+
"jsdom": "^27.4.0",
|
|
47
|
+
"react": "^19.2.3",
|
|
48
|
+
"react-dom": "^19.2.3",
|
|
49
|
+
"typescript": "^5.9.3",
|
|
50
|
+
"vite": "7.3.0",
|
|
51
51
|
"vite-plugin-banner": "^0.8.1",
|
|
52
52
|
"vite-plugin-dts": "^4.5.4",
|
|
53
|
-
"vitest": "^
|
|
53
|
+
"vitest": "^4.0.16"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"react-fast-compare": "^3.2.2"
|