react-shared-states 1.0.4 → 1.0.6
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/README.md +174 -17
- package/dist/SharedData.d.ts +4 -3
- package/dist/config/index.d.ts +2 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/use-shared-function.d.ts +4 -4
- package/dist/hooks/use-shared-state.d.ts +4 -4
- package/dist/hooks/use-shared-subscription.d.ts +39 -0
- package/dist/index.d.ts +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/main.esm.js +405 -270
- package/dist/main.min.js +5 -5
- package/dist/types.d.ts +2 -1
- package/package.json +1 -1
- package/vite.config.ts +4 -1
package/dist/main.esm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* react-shared-states v1.0.
|
|
2
|
+
* react-shared-states v1.0.6
|
|
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
|
|
9
|
-
var
|
|
8
|
+
import de, { createContext as be, useMemo as w, useContext as ge, useEffect as Q, useSyncExternalStore as M } from "react";
|
|
9
|
+
var L = { exports: {} }, P = {};
|
|
10
10
|
/**
|
|
11
11
|
* @license React
|
|
12
12
|
* react-jsx-runtime.production.js
|
|
@@ -16,29 +16,29 @@ var S = { exports: {} }, R = {};
|
|
|
16
16
|
* This source code is licensed under the MIT license found in the
|
|
17
17
|
* LICENSE file in the root directory of this source tree.
|
|
18
18
|
*/
|
|
19
|
-
var
|
|
20
|
-
function
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
var s = Symbol.for("react.transitional.element"),
|
|
24
|
-
function t
|
|
25
|
-
var
|
|
26
|
-
if (
|
|
27
|
-
|
|
19
|
+
var D;
|
|
20
|
+
function pe() {
|
|
21
|
+
if (D) return P;
|
|
22
|
+
D = 1;
|
|
23
|
+
var s = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
24
|
+
function r(t, i, b) {
|
|
25
|
+
var S = null;
|
|
26
|
+
if (b !== void 0 && (S = "" + b), i.key !== void 0 && (S = "" + i.key), "key" in i) {
|
|
27
|
+
b = {};
|
|
28
28
|
for (var m in i)
|
|
29
|
-
m !== "key" && (
|
|
30
|
-
} else
|
|
31
|
-
return i =
|
|
29
|
+
m !== "key" && (b[m] = i[m]);
|
|
30
|
+
} else b = i;
|
|
31
|
+
return i = b.ref, {
|
|
32
32
|
$$typeof: s,
|
|
33
|
-
type:
|
|
34
|
-
key:
|
|
33
|
+
type: t,
|
|
34
|
+
key: S,
|
|
35
35
|
ref: i !== void 0 ? i : null,
|
|
36
|
-
props:
|
|
36
|
+
props: b
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
return
|
|
39
|
+
return P.Fragment = e, P.jsx = r, P.jsxs = r, P;
|
|
40
40
|
}
|
|
41
|
-
var
|
|
41
|
+
var j = {};
|
|
42
42
|
/**
|
|
43
43
|
* @license React
|
|
44
44
|
* react-jsx-runtime.development.js
|
|
@@ -48,350 +48,374 @@ var x = {};
|
|
|
48
48
|
* This source code is licensed under the MIT license found in the
|
|
49
49
|
* LICENSE file in the root directory of this source tree.
|
|
50
50
|
*/
|
|
51
|
-
var
|
|
52
|
-
function
|
|
53
|
-
return
|
|
54
|
-
function s(
|
|
55
|
-
if (
|
|
56
|
-
if (typeof
|
|
57
|
-
return
|
|
58
|
-
if (typeof
|
|
59
|
-
switch (
|
|
60
|
-
case
|
|
51
|
+
var H;
|
|
52
|
+
function he() {
|
|
53
|
+
return H || (H = 1, process.env.NODE_ENV !== "production" && function() {
|
|
54
|
+
function s(n) {
|
|
55
|
+
if (n == null) return null;
|
|
56
|
+
if (typeof n == "function")
|
|
57
|
+
return n.$$typeof === ce ? null : n.displayName || n.name || null;
|
|
58
|
+
if (typeof n == "string") return n;
|
|
59
|
+
switch (n) {
|
|
60
|
+
case C:
|
|
61
61
|
return "Fragment";
|
|
62
|
-
case
|
|
62
|
+
case te:
|
|
63
63
|
return "Profiler";
|
|
64
|
-
case
|
|
64
|
+
case ee:
|
|
65
65
|
return "StrictMode";
|
|
66
|
-
case
|
|
66
|
+
case ae:
|
|
67
67
|
return "Suspense";
|
|
68
|
-
case
|
|
68
|
+
case oe:
|
|
69
69
|
return "SuspenseList";
|
|
70
|
-
case
|
|
70
|
+
case le:
|
|
71
71
|
return "Activity";
|
|
72
72
|
}
|
|
73
|
-
if (typeof
|
|
74
|
-
switch (typeof
|
|
73
|
+
if (typeof n == "object")
|
|
74
|
+
switch (typeof n.tag == "number" && console.error(
|
|
75
75
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
76
|
-
),
|
|
77
|
-
case
|
|
76
|
+
), n.$$typeof) {
|
|
77
|
+
case k:
|
|
78
78
|
return "Portal";
|
|
79
|
-
case
|
|
80
|
-
return (
|
|
81
|
-
case H:
|
|
82
|
-
return (e._context.displayName || "Context") + ".Consumer";
|
|
83
|
-
case Q:
|
|
84
|
-
var a = e.render;
|
|
85
|
-
return e = e.displayName, e || (e = a.displayName || a.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
|
+
case ne:
|
|
80
|
+
return (n.displayName || "Context") + ".Provider";
|
|
86
81
|
case re:
|
|
87
|
-
return
|
|
88
|
-
case
|
|
89
|
-
a =
|
|
82
|
+
return (n._context.displayName || "Context") + ".Consumer";
|
|
83
|
+
case se:
|
|
84
|
+
var a = n.render;
|
|
85
|
+
return n = n.displayName, n || (n = a.displayName || a.name || "", n = n !== "" ? "ForwardRef(" + n + ")" : "ForwardRef"), n;
|
|
86
|
+
case ie:
|
|
87
|
+
return a = n.displayName || null, a !== null ? a : s(n.type) || "Memo";
|
|
88
|
+
case U:
|
|
89
|
+
a = n._payload, n = n._init;
|
|
90
90
|
try {
|
|
91
|
-
return s(
|
|
91
|
+
return s(n(a));
|
|
92
92
|
} catch {
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
return null;
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
return "" +
|
|
97
|
+
function e(n) {
|
|
98
|
+
return "" + n;
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function r(n) {
|
|
101
101
|
try {
|
|
102
|
-
|
|
102
|
+
e(n);
|
|
103
103
|
var a = !1;
|
|
104
104
|
} catch {
|
|
105
105
|
a = !0;
|
|
106
106
|
}
|
|
107
107
|
if (a) {
|
|
108
108
|
a = console;
|
|
109
|
-
var
|
|
110
|
-
return
|
|
109
|
+
var u = a.error, p = typeof Symbol == "function" && Symbol.toStringTag && n[Symbol.toStringTag] || n.constructor.name || "Object";
|
|
110
|
+
return u.call(
|
|
111
111
|
a,
|
|
112
112
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
113
|
-
|
|
114
|
-
),
|
|
113
|
+
p
|
|
114
|
+
), e(n);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
function n
|
|
118
|
-
if (
|
|
119
|
-
if (typeof
|
|
117
|
+
function t(n) {
|
|
118
|
+
if (n === C) return "<>";
|
|
119
|
+
if (typeof n == "object" && n !== null && n.$$typeof === U)
|
|
120
120
|
return "<...>";
|
|
121
121
|
try {
|
|
122
|
-
var a = s(
|
|
122
|
+
var a = s(n);
|
|
123
123
|
return a ? "<" + a + ">" : "<...>";
|
|
124
124
|
} catch {
|
|
125
125
|
return "<...>";
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
function i() {
|
|
129
|
-
var
|
|
130
|
-
return
|
|
129
|
+
var n = N.A;
|
|
130
|
+
return n === null ? null : n.getOwner();
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function b() {
|
|
133
133
|
return Error("react-stack-top-frame");
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
if (
|
|
137
|
-
var a = Object.getOwnPropertyDescriptor(
|
|
135
|
+
function S(n) {
|
|
136
|
+
if (G.call(n, "key")) {
|
|
137
|
+
var a = Object.getOwnPropertyDescriptor(n, "key").get;
|
|
138
138
|
if (a && a.isReactWarning) return !1;
|
|
139
139
|
}
|
|
140
|
-
return
|
|
140
|
+
return n.key !== void 0;
|
|
141
141
|
}
|
|
142
|
-
function m(
|
|
143
|
-
function
|
|
144
|
-
|
|
142
|
+
function m(n, a) {
|
|
143
|
+
function u() {
|
|
144
|
+
q || (q = !0, console.error(
|
|
145
145
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
146
146
|
a
|
|
147
147
|
));
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
get:
|
|
149
|
+
u.isReactWarning = !0, Object.defineProperty(n, "key", {
|
|
150
|
+
get: u,
|
|
151
151
|
configurable: !0
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
|
-
function
|
|
155
|
-
var
|
|
156
|
-
return
|
|
154
|
+
function f() {
|
|
155
|
+
var n = s(this.type);
|
|
156
|
+
return J[n] || (J[n] = !0, console.error(
|
|
157
157
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
158
|
-
)),
|
|
158
|
+
)), n = this.props.ref, n !== void 0 ? n : null;
|
|
159
159
|
}
|
|
160
|
-
function
|
|
161
|
-
return
|
|
162
|
-
$$typeof:
|
|
163
|
-
type:
|
|
160
|
+
function T(n, a, u, p, A, _, Y, F) {
|
|
161
|
+
return u = _.ref, n = {
|
|
162
|
+
$$typeof: x,
|
|
163
|
+
type: n,
|
|
164
164
|
key: a,
|
|
165
|
-
props:
|
|
166
|
-
_owner:
|
|
167
|
-
}, (
|
|
165
|
+
props: _,
|
|
166
|
+
_owner: A
|
|
167
|
+
}, (u !== void 0 ? u : null) !== null ? Object.defineProperty(n, "ref", {
|
|
168
168
|
enumerable: !1,
|
|
169
|
-
get:
|
|
170
|
-
}) : Object.defineProperty(
|
|
169
|
+
get: f
|
|
170
|
+
}) : Object.defineProperty(n, "ref", { enumerable: !1, value: null }), n._store = {}, Object.defineProperty(n._store, "validated", {
|
|
171
171
|
configurable: !1,
|
|
172
172
|
enumerable: !1,
|
|
173
173
|
writable: !0,
|
|
174
174
|
value: 0
|
|
175
|
-
}), Object.defineProperty(
|
|
175
|
+
}), Object.defineProperty(n, "_debugInfo", {
|
|
176
176
|
configurable: !1,
|
|
177
177
|
enumerable: !1,
|
|
178
178
|
writable: !0,
|
|
179
179
|
value: null
|
|
180
|
-
}), Object.defineProperty(
|
|
180
|
+
}), Object.defineProperty(n, "_debugStack", {
|
|
181
181
|
configurable: !1,
|
|
182
182
|
enumerable: !1,
|
|
183
183
|
writable: !0,
|
|
184
|
-
value:
|
|
185
|
-
}), Object.defineProperty(
|
|
184
|
+
value: Y
|
|
185
|
+
}), Object.defineProperty(n, "_debugTask", {
|
|
186
186
|
configurable: !1,
|
|
187
187
|
enumerable: !1,
|
|
188
188
|
writable: !0,
|
|
189
|
-
value:
|
|
190
|
-
}), Object.freeze && (Object.freeze(
|
|
189
|
+
value: F
|
|
190
|
+
}), Object.freeze && (Object.freeze(n.props), Object.freeze(n)), n;
|
|
191
191
|
}
|
|
192
|
-
function
|
|
193
|
-
var
|
|
194
|
-
if (
|
|
195
|
-
if (
|
|
196
|
-
if (
|
|
197
|
-
for (
|
|
198
|
-
|
|
199
|
-
Object.freeze && Object.freeze(
|
|
192
|
+
function g(n, a, u, p, A, _, Y, F) {
|
|
193
|
+
var h = a.children;
|
|
194
|
+
if (h !== void 0)
|
|
195
|
+
if (p)
|
|
196
|
+
if (ue(h)) {
|
|
197
|
+
for (p = 0; p < h.length; p++)
|
|
198
|
+
c(h[p]);
|
|
199
|
+
Object.freeze && Object.freeze(h);
|
|
200
200
|
} else
|
|
201
201
|
console.error(
|
|
202
202
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
203
203
|
);
|
|
204
|
-
else
|
|
205
|
-
if (
|
|
206
|
-
|
|
207
|
-
var
|
|
208
|
-
return
|
|
204
|
+
else c(h);
|
|
205
|
+
if (G.call(a, "key")) {
|
|
206
|
+
h = s(n);
|
|
207
|
+
var O = Object.keys(a).filter(function(fe) {
|
|
208
|
+
return fe !== "key";
|
|
209
209
|
});
|
|
210
|
-
|
|
210
|
+
p = 0 < O.length ? "{key: someKey, " + O.join(": ..., ") + ": ...}" : "{key: someKey}", X[h + p] || (O = 0 < O.length ? "{" + O.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
211
211
|
`A props object containing a "key" prop is being spread into JSX:
|
|
212
212
|
let props = %s;
|
|
213
213
|
<%s {...props} />
|
|
214
214
|
React keys must be passed directly to JSX without using spread:
|
|
215
215
|
let props = %s;
|
|
216
216
|
<%s key={someKey} {...props} />`,
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
),
|
|
217
|
+
p,
|
|
218
|
+
h,
|
|
219
|
+
O,
|
|
220
|
+
h
|
|
221
|
+
), X[h + p] = !0);
|
|
222
222
|
}
|
|
223
|
-
if (
|
|
224
|
-
|
|
225
|
-
for (var
|
|
226
|
-
|
|
227
|
-
} else
|
|
228
|
-
return
|
|
229
|
-
|
|
230
|
-
typeof
|
|
231
|
-
),
|
|
232
|
-
|
|
233
|
-
f,
|
|
234
|
-
E,
|
|
223
|
+
if (h = null, u !== void 0 && (r(u), h = "" + u), S(a) && (r(a.key), h = "" + a.key), "key" in a) {
|
|
224
|
+
u = {};
|
|
225
|
+
for (var $ in a)
|
|
226
|
+
$ !== "key" && (u[$] = a[$]);
|
|
227
|
+
} else u = a;
|
|
228
|
+
return h && m(
|
|
229
|
+
u,
|
|
230
|
+
typeof n == "function" ? n.displayName || n.name || "Unknown" : n
|
|
231
|
+
), T(
|
|
232
|
+
n,
|
|
235
233
|
h,
|
|
234
|
+
_,
|
|
235
|
+
A,
|
|
236
236
|
i(),
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
u,
|
|
238
|
+
Y,
|
|
239
|
+
F
|
|
240
240
|
);
|
|
241
241
|
}
|
|
242
|
-
function
|
|
243
|
-
typeof
|
|
242
|
+
function c(n) {
|
|
243
|
+
typeof n == "object" && n !== null && n.$$typeof === x && n._store && (n._store.validated = 1);
|
|
244
244
|
}
|
|
245
|
-
var
|
|
245
|
+
var o = de, x = Symbol.for("react.transitional.element"), k = Symbol.for("react.portal"), C = Symbol.for("react.fragment"), ee = Symbol.for("react.strict_mode"), te = Symbol.for("react.profiler"), re = Symbol.for("react.consumer"), ne = Symbol.for("react.context"), se = Symbol.for("react.forward_ref"), ae = Symbol.for("react.suspense"), oe = Symbol.for("react.suspense_list"), ie = Symbol.for("react.memo"), U = Symbol.for("react.lazy"), le = Symbol.for("react.activity"), ce = Symbol.for("react.client.reference"), N = o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, G = Object.prototype.hasOwnProperty, ue = Array.isArray, V = console.createTask ? console.createTask : function() {
|
|
246
246
|
return null;
|
|
247
247
|
};
|
|
248
|
-
|
|
249
|
-
react_stack_bottom_frame: function(
|
|
250
|
-
return
|
|
248
|
+
o = {
|
|
249
|
+
react_stack_bottom_frame: function(n) {
|
|
250
|
+
return n();
|
|
251
251
|
}
|
|
252
252
|
};
|
|
253
|
-
var
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
)(),
|
|
257
|
-
|
|
258
|
-
var
|
|
259
|
-
return
|
|
260
|
-
|
|
253
|
+
var q, J = {}, z = o.react_stack_bottom_frame.bind(
|
|
254
|
+
o,
|
|
255
|
+
b
|
|
256
|
+
)(), B = V(t(b)), X = {};
|
|
257
|
+
j.Fragment = C, j.jsx = function(n, a, u, p, A) {
|
|
258
|
+
var _ = 1e4 > N.recentlyCreatedOwnerStacks++;
|
|
259
|
+
return g(
|
|
260
|
+
n,
|
|
261
261
|
a,
|
|
262
|
-
|
|
262
|
+
u,
|
|
263
263
|
!1,
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
264
|
+
p,
|
|
265
|
+
A,
|
|
266
|
+
_ ? Error("react-stack-top-frame") : z,
|
|
267
|
+
_ ? V(t(n)) : B
|
|
268
268
|
);
|
|
269
|
-
},
|
|
270
|
-
var
|
|
271
|
-
return
|
|
272
|
-
|
|
269
|
+
}, j.jsxs = function(n, a, u, p, A) {
|
|
270
|
+
var _ = 1e4 > N.recentlyCreatedOwnerStacks++;
|
|
271
|
+
return g(
|
|
272
|
+
n,
|
|
273
273
|
a,
|
|
274
|
-
|
|
274
|
+
u,
|
|
275
275
|
!0,
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
276
|
+
p,
|
|
277
|
+
A,
|
|
278
|
+
_ ? Error("react-stack-top-frame") : z,
|
|
279
|
+
_ ? V(t(n)) : B
|
|
280
280
|
);
|
|
281
281
|
};
|
|
282
|
-
}()),
|
|
282
|
+
}()), j;
|
|
283
283
|
}
|
|
284
|
-
var
|
|
285
|
-
function
|
|
286
|
-
return
|
|
284
|
+
var Z;
|
|
285
|
+
function Ee() {
|
|
286
|
+
return Z || (Z = 1, process.env.NODE_ENV === "production" ? L.exports = pe() : L.exports = he()), L.exports;
|
|
287
287
|
}
|
|
288
|
-
var
|
|
289
|
-
const
|
|
290
|
-
|
|
288
|
+
var ve = Ee();
|
|
289
|
+
const K = be(void 0), Oe = ({ children: s, scopeName: e }) => (e || (e = w(() => Math.random().toString(36).substring(2, 15), [])), /* @__PURE__ */ ve.jsx(K.Provider, { value: { scopeName: e }, children: s })), Se = () => ge(K);
|
|
290
|
+
let y = !1;
|
|
291
|
+
const Pe = (s) => {
|
|
292
|
+
y = s;
|
|
293
|
+
}, I = (...s) => {
|
|
294
|
+
y && console.log(
|
|
295
|
+
"%c[react-shared-states]",
|
|
296
|
+
"color: #007acc; font-weight: bold",
|
|
297
|
+
...s
|
|
298
|
+
);
|
|
299
|
+
}, R = (s) => {
|
|
300
|
+
if (!s) throw new Error("Value is empty");
|
|
301
|
+
return s;
|
|
302
|
+
};
|
|
303
|
+
class l {
|
|
291
304
|
data = /* @__PURE__ */ new Map();
|
|
292
305
|
defaultValue() {
|
|
293
306
|
return {};
|
|
294
307
|
}
|
|
295
|
-
addListener(r, t
|
|
296
|
-
this.data.has(
|
|
308
|
+
addListener(e, r, t) {
|
|
309
|
+
this.data.has(l.prefix(e, r)) || this.data.set(l.prefix(e, r), {
|
|
297
310
|
...this.defaultValue,
|
|
298
311
|
listeners: []
|
|
299
|
-
}), this.data.get(
|
|
312
|
+
}), this.data.get(l.prefix(e, r)).listeners.push(t);
|
|
300
313
|
}
|
|
301
|
-
removeListener(r, t
|
|
302
|
-
this.data.has(
|
|
314
|
+
removeListener(e, r, t) {
|
|
315
|
+
this.data.has(l.prefix(e, r)) && (this.data.get(l.prefix(e, r)).listeners = this.data.get(l.prefix(e, r)).listeners.filter((i) => i !== t));
|
|
303
316
|
}
|
|
304
|
-
callListeners(
|
|
305
|
-
this.data.has(
|
|
317
|
+
callListeners(e, r) {
|
|
318
|
+
this.data.has(l.prefix(e, r)) && this.data.get(l.prefix(e, r)).listeners.forEach((t) => t());
|
|
306
319
|
}
|
|
307
|
-
init(r, t
|
|
308
|
-
this.data.has(
|
|
309
|
-
...
|
|
320
|
+
init(e, r, t) {
|
|
321
|
+
this.data.has(l.prefix(e, r)) || this.data.set(l.prefix(e, r), {
|
|
322
|
+
...t,
|
|
310
323
|
listeners: []
|
|
311
324
|
});
|
|
312
325
|
}
|
|
313
|
-
clearAll(
|
|
314
|
-
|
|
315
|
-
|
|
326
|
+
clearAll(e = !1) {
|
|
327
|
+
e || this.data.forEach((r) => {
|
|
328
|
+
r.listeners.forEach((t) => t());
|
|
316
329
|
}), this.data.clear();
|
|
317
330
|
}
|
|
318
|
-
clear(r, t
|
|
319
|
-
|
|
331
|
+
clear(e, r, t = !1) {
|
|
332
|
+
t || this.callListeners(e, r), this.data.delete(l.prefix(e, r));
|
|
320
333
|
}
|
|
321
|
-
get(
|
|
322
|
-
let
|
|
323
|
-
if (
|
|
324
|
-
return this.data.get(
|
|
334
|
+
get(e, r) {
|
|
335
|
+
let t = this.has(e, r);
|
|
336
|
+
if (t)
|
|
337
|
+
return this.data.get(t);
|
|
325
338
|
}
|
|
326
|
-
setValue(r, t
|
|
327
|
-
this.data.has(
|
|
328
|
-
...this.data.get(
|
|
329
|
-
...
|
|
339
|
+
setValue(e, r, t) {
|
|
340
|
+
this.data.has(l.prefix(e, r)) && this.data.set(l.prefix(e, r), {
|
|
341
|
+
...this.data.get(l.prefix(e, r)),
|
|
342
|
+
...t
|
|
330
343
|
});
|
|
331
344
|
}
|
|
332
|
-
has(
|
|
333
|
-
return this.data.has(
|
|
345
|
+
has(e, r) {
|
|
346
|
+
return this.data.has(l.prefix(e, r)) ? l.prefix(e, r) : this.data.has(l.prefix(e, "_global")) ? l.prefix(e, "_global") : void 0;
|
|
347
|
+
}
|
|
348
|
+
static prefix(e, r) {
|
|
349
|
+
return `${r}_${e}`;
|
|
334
350
|
}
|
|
335
|
-
|
|
336
|
-
|
|
351
|
+
useEffect(e, r, t = null) {
|
|
352
|
+
Q(() => () => {
|
|
353
|
+
t?.(), I(`[${l.prefix(e, r)}]`, "unmount effect"), this.data.get(l.prefix(e, r)).listeners?.length === 0 && this.clear(e, r);
|
|
354
|
+
}, []);
|
|
337
355
|
}
|
|
338
356
|
}
|
|
339
|
-
const
|
|
340
|
-
const
|
|
357
|
+
const W = (s) => {
|
|
358
|
+
const e = Se();
|
|
341
359
|
return {
|
|
342
|
-
prefix: s ??
|
|
360
|
+
prefix: s ?? e?.scopeName ?? "_global"
|
|
343
361
|
};
|
|
344
362
|
};
|
|
345
|
-
class
|
|
363
|
+
class me extends l {
|
|
346
364
|
defaultValue() {
|
|
347
365
|
return { value: void 0 };
|
|
348
366
|
}
|
|
349
|
-
init(r, t
|
|
350
|
-
super.init(
|
|
367
|
+
init(e, r, t) {
|
|
368
|
+
super.init(e, r, { value: t });
|
|
369
|
+
}
|
|
370
|
+
setValue(e, r, t) {
|
|
371
|
+
super.setValue(e, r, { value: t });
|
|
351
372
|
}
|
|
352
|
-
|
|
353
|
-
super.
|
|
373
|
+
removeListener(e, r, t) {
|
|
374
|
+
super.removeListener(e, r, t);
|
|
354
375
|
}
|
|
355
376
|
}
|
|
356
|
-
class
|
|
357
|
-
get(
|
|
358
|
-
|
|
359
|
-
|
|
377
|
+
class xe {
|
|
378
|
+
get(e, r = "_global") {
|
|
379
|
+
e = R(e);
|
|
380
|
+
const t = r || "_global";
|
|
381
|
+
return E.get(e, t)?.value;
|
|
360
382
|
}
|
|
361
|
-
set(r, t
|
|
362
|
-
|
|
363
|
-
|
|
383
|
+
set(e, r, t = "_global") {
|
|
384
|
+
e = R(e);
|
|
385
|
+
const i = t || "_global";
|
|
386
|
+
E.setValue(e, i, { value: r });
|
|
364
387
|
}
|
|
365
388
|
clearAll() {
|
|
366
|
-
|
|
389
|
+
E.clearAll();
|
|
367
390
|
}
|
|
368
|
-
clear(
|
|
369
|
-
const
|
|
370
|
-
|
|
391
|
+
clear(e, r = "_global") {
|
|
392
|
+
const t = r || "_global";
|
|
393
|
+
E.clear(e, t);
|
|
371
394
|
}
|
|
372
|
-
has(
|
|
373
|
-
const
|
|
374
|
-
return !!
|
|
395
|
+
has(e, r = "_global") {
|
|
396
|
+
const t = r || "_global";
|
|
397
|
+
return !!E.has(e, t);
|
|
375
398
|
}
|
|
376
399
|
getAll() {
|
|
377
|
-
return
|
|
400
|
+
return E.data;
|
|
378
401
|
}
|
|
379
402
|
}
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
(
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
403
|
+
const je = new xe(), E = new me(), Le = (s, e, r) => {
|
|
404
|
+
s = R(s);
|
|
405
|
+
const { prefix: t } = W(r);
|
|
406
|
+
E.init(s, t, e);
|
|
407
|
+
const i = w(() => (f) => (E.init(s, t, e), E.addListener(s, t, f), () => {
|
|
408
|
+
E.removeListener(s, t, f);
|
|
409
|
+
}), []), b = w(() => () => E.get(s, t)?.value, []), S = M(i, b), m = (f) => {
|
|
410
|
+
const T = typeof f == "function" ? f(E.get(s, t)?.value) : f;
|
|
411
|
+
T !== S && (E.setValue(s, t, T), E.callListeners(s, t));
|
|
412
|
+
};
|
|
413
|
+
return E.useEffect(s, t), [
|
|
414
|
+
S,
|
|
415
|
+
m
|
|
392
416
|
];
|
|
393
417
|
};
|
|
394
|
-
class
|
|
418
|
+
class _e extends l {
|
|
395
419
|
defaultValue() {
|
|
396
420
|
return {
|
|
397
421
|
fnState: {
|
|
@@ -401,71 +425,182 @@ class Ee extends u {
|
|
|
401
425
|
}
|
|
402
426
|
};
|
|
403
427
|
}
|
|
404
|
-
init(
|
|
405
|
-
super.init(
|
|
428
|
+
init(e, r) {
|
|
429
|
+
super.init(e, r, this.defaultValue());
|
|
406
430
|
}
|
|
407
|
-
setValue(r, t
|
|
408
|
-
super.setValue(r, t
|
|
431
|
+
setValue(e, r, t) {
|
|
432
|
+
super.setValue(e, r, t);
|
|
409
433
|
}
|
|
410
434
|
}
|
|
411
|
-
class
|
|
412
|
-
get(
|
|
413
|
-
|
|
414
|
-
|
|
435
|
+
class Re {
|
|
436
|
+
get(e, r = "_global") {
|
|
437
|
+
e = R(e);
|
|
438
|
+
const t = r || "_global";
|
|
439
|
+
return v.get(e, t)?.fnState;
|
|
415
440
|
}
|
|
416
|
-
set(r, t
|
|
417
|
-
|
|
418
|
-
|
|
441
|
+
set(e, r, t = "_global") {
|
|
442
|
+
e = R(e);
|
|
443
|
+
const i = t || "_global";
|
|
444
|
+
v.setValue(e, i, r);
|
|
419
445
|
}
|
|
420
446
|
clearAll() {
|
|
421
|
-
|
|
447
|
+
v.clearAll();
|
|
422
448
|
}
|
|
423
|
-
clear(
|
|
424
|
-
const
|
|
425
|
-
|
|
449
|
+
clear(e, r = "_global") {
|
|
450
|
+
const t = r || "_global";
|
|
451
|
+
v.clear(e, t);
|
|
426
452
|
}
|
|
427
|
-
has(
|
|
428
|
-
const
|
|
429
|
-
return !!
|
|
453
|
+
has(e, r = "_global") {
|
|
454
|
+
const t = r || "_global";
|
|
455
|
+
return !!v.has(e, t);
|
|
430
456
|
}
|
|
431
457
|
getAll() {
|
|
432
|
-
return
|
|
458
|
+
return v.data;
|
|
433
459
|
}
|
|
434
460
|
}
|
|
435
|
-
const
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
461
|
+
const Ce = new Re(), v = new _e(), Ne = (s, e, r) => {
|
|
462
|
+
s = R(s);
|
|
463
|
+
const { prefix: t } = W(r);
|
|
464
|
+
v.init(s, t);
|
|
465
|
+
const i = w(
|
|
466
|
+
() => (f) => (v.init(s, t), v.addListener(s, t, f), () => {
|
|
467
|
+
v.removeListener(s, t, f);
|
|
468
|
+
}),
|
|
469
|
+
[]
|
|
470
|
+
), b = w(
|
|
471
|
+
() => () => v.get(s, t).fnState,
|
|
472
|
+
[]
|
|
473
|
+
), S = M(i, b), m = async (f, ...T) => {
|
|
474
|
+
const g = v.get(s, t);
|
|
475
|
+
if (!f && (g.fnState.isLoading || g.fnState.results !== void 0)) return g.fnState;
|
|
476
|
+
g.fnState = { ...g.fnState, isLoading: !0, error: void 0 }, g.listeners.forEach((c) => c());
|
|
444
477
|
try {
|
|
445
|
-
const
|
|
446
|
-
g.fnState = { results:
|
|
447
|
-
} catch (
|
|
448
|
-
g.fnState = { ...g.fnState, isLoading: !1, error:
|
|
478
|
+
const c = await e(...T);
|
|
479
|
+
g.fnState = { results: c, isLoading: !1, error: void 0 };
|
|
480
|
+
} catch (c) {
|
|
481
|
+
g.fnState = { ...g.fnState, isLoading: !1, error: c };
|
|
449
482
|
}
|
|
450
|
-
g.listeners.forEach((
|
|
483
|
+
g.listeners.forEach((c) => c());
|
|
451
484
|
};
|
|
452
|
-
return {
|
|
453
|
-
state:
|
|
454
|
-
trigger: (...
|
|
455
|
-
|
|
485
|
+
return v.useEffect(s, t), {
|
|
486
|
+
state: S,
|
|
487
|
+
trigger: (...f) => {
|
|
488
|
+
m(!1, ...f);
|
|
456
489
|
},
|
|
457
|
-
forceTrigger: (...
|
|
458
|
-
|
|
490
|
+
forceTrigger: (...f) => {
|
|
491
|
+
m(!0, ...f);
|
|
459
492
|
},
|
|
460
493
|
clear: () => {
|
|
461
|
-
|
|
494
|
+
v.clear(s, t), v.init(s, t);
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
};
|
|
498
|
+
class Te extends l {
|
|
499
|
+
defaultValue() {
|
|
500
|
+
return {
|
|
501
|
+
fnState: {
|
|
502
|
+
data: void 0,
|
|
503
|
+
isLoading: !1,
|
|
504
|
+
error: void 0,
|
|
505
|
+
subscribed: !1
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
init(e, r) {
|
|
510
|
+
super.init(e, r, this.defaultValue());
|
|
511
|
+
}
|
|
512
|
+
setValue(e, r, t) {
|
|
513
|
+
super.setValue(e, r, t);
|
|
514
|
+
}
|
|
515
|
+
useEffect(e, r) {
|
|
516
|
+
Q(() => () => {
|
|
517
|
+
I(`[${l.prefix(e, r)}]`, "unmount effect2"), this.get(e, r)?.listeners.length === 0 && this.unsubscribe(e, r);
|
|
518
|
+
}, []), super.useEffect(e, r);
|
|
519
|
+
}
|
|
520
|
+
async unsubscribe(e, r) {
|
|
521
|
+
const t = this.get(e, r);
|
|
522
|
+
t && (t.unsubscribe && (t.unsubscribe(), t.unsubscribe = void 0), t.fnState.subscribed = !1);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
class Ae {
|
|
526
|
+
get(e, r = "_global") {
|
|
527
|
+
e = R(e);
|
|
528
|
+
const t = r || "_global";
|
|
529
|
+
return d.get(e, t)?.fnState;
|
|
530
|
+
}
|
|
531
|
+
set(e, r, t = "_global") {
|
|
532
|
+
e = R(e);
|
|
533
|
+
const i = t || "_global";
|
|
534
|
+
d.setValue(e, i, r);
|
|
535
|
+
}
|
|
536
|
+
clearAll() {
|
|
537
|
+
d.clearAll();
|
|
538
|
+
}
|
|
539
|
+
clear(e, r = "_global") {
|
|
540
|
+
const t = r || "_global";
|
|
541
|
+
d.clear(e, t);
|
|
542
|
+
}
|
|
543
|
+
has(e, r = "_global") {
|
|
544
|
+
const t = r || "_global";
|
|
545
|
+
return !!d.has(e, t);
|
|
546
|
+
}
|
|
547
|
+
getAll() {
|
|
548
|
+
return d.data;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
const Ve = new Ae(), d = new Te(), Ye = (s, e, r) => {
|
|
552
|
+
s = R(s);
|
|
553
|
+
const { prefix: t } = W(r);
|
|
554
|
+
d.init(s, t);
|
|
555
|
+
const i = w(
|
|
556
|
+
() => (c) => (d.init(s, t), d.addListener(s, t, c), () => {
|
|
557
|
+
d.removeListener(s, t, c);
|
|
558
|
+
}),
|
|
559
|
+
[]
|
|
560
|
+
), b = w(
|
|
561
|
+
() => () => d.get(s, t).fnState,
|
|
562
|
+
[]
|
|
563
|
+
), S = M(i, b), m = (c) => {
|
|
564
|
+
const o = d.get(s, t);
|
|
565
|
+
o.fnState = { ...o.fnState, data: c }, o.listeners.forEach((x) => x());
|
|
566
|
+
}, f = (c) => {
|
|
567
|
+
const o = d.get(s, t);
|
|
568
|
+
o.fnState = { ...o.fnState, isLoading: !1, data: void 0, error: c }, o.listeners.forEach((x) => x());
|
|
569
|
+
}, T = () => {
|
|
570
|
+
const c = d.get(s, t);
|
|
571
|
+
c.fnState = { ...c.fnState, isLoading: !1 }, c.listeners.forEach((o) => o());
|
|
572
|
+
}, g = async (c) => {
|
|
573
|
+
const o = d.get(s, t);
|
|
574
|
+
if (c && (await d.unsubscribe(s, t), o.fnState = { ...o.fnState, isLoading: !1, data: void 0, error: void 0, subscribed: !1 }), o.fnState.subscribed) return o.fnState;
|
|
575
|
+
I("triggered !!"), o.fnState = { ...o.fnState, isLoading: !0, error: void 0 }, o.listeners.forEach((x) => x());
|
|
576
|
+
try {
|
|
577
|
+
o.unsubscribe = await e(m, f, T), o.fnState.subscribed = !0;
|
|
578
|
+
} catch (x) {
|
|
579
|
+
o.fnState = { ...o.fnState, isLoading: !1, error: x };
|
|
580
|
+
}
|
|
581
|
+
o.listeners.forEach((x) => x());
|
|
582
|
+
};
|
|
583
|
+
return d.useEffect(s, t), {
|
|
584
|
+
state: S,
|
|
585
|
+
trigger: () => {
|
|
586
|
+
g(!1);
|
|
587
|
+
},
|
|
588
|
+
forceTrigger: () => {
|
|
589
|
+
g(!0);
|
|
590
|
+
},
|
|
591
|
+
unsubscribe: () => {
|
|
592
|
+
d.unsubscribe(s, t);
|
|
462
593
|
}
|
|
463
594
|
};
|
|
464
595
|
};
|
|
465
596
|
export {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
597
|
+
Oe as SharedStatesProvider,
|
|
598
|
+
y as isDevMode,
|
|
599
|
+
Pe as setDevMode,
|
|
600
|
+
Ce as sharedFunctionsApi,
|
|
601
|
+
je as sharedStatesApi,
|
|
602
|
+
Ve as sharedSubscriptionsApi,
|
|
603
|
+
Ne as useSharedFunction,
|
|
604
|
+
Le as useSharedState,
|
|
605
|
+
Ye as useSharedSubscription
|
|
471
606
|
};
|