react-shared-states 1.0.8 → 1.0.12
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 +155 -91
- package/dist/{SharedData.d.ts → SharedValuesManager.d.ts} +28 -17
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/use-shared-function.d.ts +37 -12
- package/dist/hooks/use-shared-state.d.ts +22 -3
- package/dist/hooks/use-shared-subscription.d.ts +44 -16
- package/dist/main.esm.js +480 -395
- package/dist/main.min.js +5 -5
- package/dist/types.d.ts +2 -1
- package/package.json +9 -2
- package/tests/index.test.tsx +309 -5
- package/pnpm-workspace.yaml +0 -2
package/dist/main.esm.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* react-shared-states v1.0.
|
|
2
|
+
* react-shared-states v1.0.12
|
|
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
|
-
|
|
8
|
+
import ve, { createContext as be, useMemo as T, useContext as xe, useEffect as ne, useSyncExternalStore as N, useRef as Ee } from "react";
|
|
9
|
+
function me(i) {
|
|
10
|
+
return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
|
|
11
|
+
}
|
|
12
|
+
var F = { exports: {} }, C = {};
|
|
10
13
|
/**
|
|
11
14
|
* @license React
|
|
12
15
|
* react-jsx-runtime.production.js
|
|
@@ -16,29 +19,29 @@ var y = { exports: {} }, V = {};
|
|
|
16
19
|
* This source code is licensed under the MIT license found in the
|
|
17
20
|
* LICENSE file in the root directory of this source tree.
|
|
18
21
|
*/
|
|
19
|
-
var
|
|
20
|
-
function
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
var
|
|
24
|
-
function r(t,
|
|
25
|
-
var
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
for (var
|
|
29
|
-
|
|
30
|
-
} else
|
|
31
|
-
return
|
|
32
|
-
$$typeof:
|
|
22
|
+
var Q;
|
|
23
|
+
function Re() {
|
|
24
|
+
if (Q) return C;
|
|
25
|
+
Q = 1;
|
|
26
|
+
var i = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
27
|
+
function r(t, o, a) {
|
|
28
|
+
var n = null;
|
|
29
|
+
if (a !== void 0 && (n = "" + a), o.key !== void 0 && (n = "" + o.key), "key" in o) {
|
|
30
|
+
a = {};
|
|
31
|
+
for (var f in o)
|
|
32
|
+
f !== "key" && (a[f] = o[f]);
|
|
33
|
+
} else a = o;
|
|
34
|
+
return o = a.ref, {
|
|
35
|
+
$$typeof: i,
|
|
33
36
|
type: t,
|
|
34
|
-
key:
|
|
35
|
-
ref:
|
|
36
|
-
props:
|
|
37
|
+
key: n,
|
|
38
|
+
ref: o !== void 0 ? o : null,
|
|
39
|
+
props: a
|
|
37
40
|
};
|
|
38
41
|
}
|
|
39
|
-
return
|
|
42
|
+
return C.Fragment = e, C.jsx = r, C.jsxs = r, C;
|
|
40
43
|
}
|
|
41
|
-
var
|
|
44
|
+
var D = {};
|
|
42
45
|
/**
|
|
43
46
|
* @license React
|
|
44
47
|
* react-jsx-runtime.development.js
|
|
@@ -48,290 +51,311 @@ var C = {};
|
|
|
48
51
|
* This source code is licensed under the MIT license found in the
|
|
49
52
|
* LICENSE file in the root directory of this source tree.
|
|
50
53
|
*/
|
|
51
|
-
var
|
|
52
|
-
function
|
|
53
|
-
return
|
|
54
|
-
function
|
|
55
|
-
if (
|
|
56
|
-
if (typeof
|
|
57
|
-
return
|
|
58
|
-
if (typeof
|
|
59
|
-
switch (
|
|
60
|
-
case
|
|
54
|
+
var K;
|
|
55
|
+
function _e() {
|
|
56
|
+
return K || (K = 1, process.env.NODE_ENV !== "production" && function() {
|
|
57
|
+
function i(s) {
|
|
58
|
+
if (s == null) return null;
|
|
59
|
+
if (typeof s == "function")
|
|
60
|
+
return s.$$typeof === he ? null : s.displayName || s.name || null;
|
|
61
|
+
if (typeof s == "string") return s;
|
|
62
|
+
switch (s) {
|
|
63
|
+
case x:
|
|
61
64
|
return "Fragment";
|
|
62
|
-
case
|
|
65
|
+
case P:
|
|
63
66
|
return "Profiler";
|
|
64
|
-
case
|
|
67
|
+
case O:
|
|
65
68
|
return "StrictMode";
|
|
66
|
-
case
|
|
69
|
+
case fe:
|
|
67
70
|
return "Suspense";
|
|
68
71
|
case le:
|
|
69
72
|
return "SuspenseList";
|
|
70
|
-
case
|
|
73
|
+
case pe:
|
|
71
74
|
return "Activity";
|
|
72
75
|
}
|
|
73
|
-
if (typeof
|
|
74
|
-
switch (typeof
|
|
76
|
+
if (typeof s == "object")
|
|
77
|
+
switch (typeof s.tag == "number" && console.error(
|
|
75
78
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
76
|
-
),
|
|
77
|
-
case
|
|
79
|
+
), s.$$typeof) {
|
|
80
|
+
case v:
|
|
78
81
|
return "Portal";
|
|
79
|
-
case ae:
|
|
80
|
-
return (n.displayName || "Context") + ".Provider";
|
|
81
|
-
case se:
|
|
82
|
-
return (n._context.displayName || "Context") + ".Consumer";
|
|
83
|
-
case oe:
|
|
84
|
-
var i = n.render;
|
|
85
|
-
return n = n.displayName, n || (n = i.displayName || i.name || "", n = n !== "" ? "ForwardRef(" + n + ")" : "ForwardRef"), n;
|
|
86
82
|
case ce:
|
|
87
|
-
return
|
|
88
|
-
case
|
|
89
|
-
|
|
83
|
+
return (s.displayName || "Context") + ".Provider";
|
|
84
|
+
case ie:
|
|
85
|
+
return (s._context.displayName || "Context") + ".Consumer";
|
|
86
|
+
case ue:
|
|
87
|
+
var u = s.render;
|
|
88
|
+
return s = s.displayName, s || (s = u.displayName || u.name || "", s = s !== "" ? "ForwardRef(" + s + ")" : "ForwardRef"), s;
|
|
89
|
+
case de:
|
|
90
|
+
return u = s.displayName || null, u !== null ? u : i(s.type) || "Memo";
|
|
91
|
+
case U:
|
|
92
|
+
u = s._payload, s = s._init;
|
|
90
93
|
try {
|
|
91
|
-
return
|
|
94
|
+
return i(s(u));
|
|
92
95
|
} catch {
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
98
|
return null;
|
|
96
99
|
}
|
|
97
|
-
function e(
|
|
98
|
-
return "" +
|
|
100
|
+
function e(s) {
|
|
101
|
+
return "" + s;
|
|
99
102
|
}
|
|
100
|
-
function r(
|
|
103
|
+
function r(s) {
|
|
101
104
|
try {
|
|
102
|
-
e(
|
|
103
|
-
var
|
|
105
|
+
e(s);
|
|
106
|
+
var u = !1;
|
|
104
107
|
} catch {
|
|
105
|
-
|
|
108
|
+
u = !0;
|
|
106
109
|
}
|
|
107
|
-
if (
|
|
108
|
-
|
|
109
|
-
var
|
|
110
|
-
return
|
|
111
|
-
|
|
110
|
+
if (u) {
|
|
111
|
+
u = console;
|
|
112
|
+
var h = u.error, E = typeof Symbol == "function" && Symbol.toStringTag && s[Symbol.toStringTag] || s.constructor.name || "Object";
|
|
113
|
+
return h.call(
|
|
114
|
+
u,
|
|
112
115
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
113
|
-
|
|
114
|
-
), e(
|
|
116
|
+
E
|
|
117
|
+
), e(s);
|
|
115
118
|
}
|
|
116
119
|
}
|
|
117
|
-
function t(
|
|
118
|
-
if (
|
|
119
|
-
if (typeof
|
|
120
|
+
function t(s) {
|
|
121
|
+
if (s === x) return "<>";
|
|
122
|
+
if (typeof s == "object" && s !== null && s.$$typeof === U)
|
|
120
123
|
return "<...>";
|
|
121
124
|
try {
|
|
122
|
-
var
|
|
123
|
-
return
|
|
125
|
+
var u = i(s);
|
|
126
|
+
return u ? "<" + u + ">" : "<...>";
|
|
124
127
|
} catch {
|
|
125
128
|
return "<...>";
|
|
126
129
|
}
|
|
127
130
|
}
|
|
128
|
-
function
|
|
129
|
-
var
|
|
130
|
-
return
|
|
131
|
+
function o() {
|
|
132
|
+
var s = $.A;
|
|
133
|
+
return s === null ? null : s.getOwner();
|
|
131
134
|
}
|
|
132
|
-
function
|
|
135
|
+
function a() {
|
|
133
136
|
return Error("react-stack-top-frame");
|
|
134
137
|
}
|
|
135
|
-
function
|
|
136
|
-
if (
|
|
137
|
-
var
|
|
138
|
-
if (
|
|
138
|
+
function n(s) {
|
|
139
|
+
if (B.call(s, "key")) {
|
|
140
|
+
var u = Object.getOwnPropertyDescriptor(s, "key").get;
|
|
141
|
+
if (u && u.isReactWarning) return !1;
|
|
139
142
|
}
|
|
140
|
-
return
|
|
143
|
+
return s.key !== void 0;
|
|
141
144
|
}
|
|
142
|
-
function
|
|
143
|
-
function
|
|
145
|
+
function f(s, u) {
|
|
146
|
+
function h() {
|
|
144
147
|
J || (J = !0, console.error(
|
|
145
148
|
"%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
|
-
|
|
149
|
+
u
|
|
147
150
|
));
|
|
148
151
|
}
|
|
149
|
-
|
|
150
|
-
get:
|
|
152
|
+
h.isReactWarning = !0, Object.defineProperty(s, "key", {
|
|
153
|
+
get: h,
|
|
151
154
|
configurable: !0
|
|
152
155
|
});
|
|
153
156
|
}
|
|
154
|
-
function
|
|
155
|
-
var
|
|
156
|
-
return
|
|
157
|
+
function c() {
|
|
158
|
+
var s = i(this.type);
|
|
159
|
+
return M[s] || (M[s] = !0, console.error(
|
|
157
160
|
"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
|
-
)),
|
|
161
|
+
)), s = this.props.ref, s !== void 0 ? s : null;
|
|
159
162
|
}
|
|
160
|
-
function
|
|
161
|
-
return
|
|
162
|
-
$$typeof:
|
|
163
|
-
type:
|
|
164
|
-
key:
|
|
165
|
-
props:
|
|
166
|
-
_owner:
|
|
167
|
-
}, (
|
|
163
|
+
function g(s, u, h, E, A, w, Y, I) {
|
|
164
|
+
return h = w.ref, s = {
|
|
165
|
+
$$typeof: b,
|
|
166
|
+
type: s,
|
|
167
|
+
key: u,
|
|
168
|
+
props: w,
|
|
169
|
+
_owner: A
|
|
170
|
+
}, (h !== void 0 ? h : null) !== null ? Object.defineProperty(s, "ref", {
|
|
168
171
|
enumerable: !1,
|
|
169
|
-
get:
|
|
170
|
-
}) : Object.defineProperty(
|
|
172
|
+
get: c
|
|
173
|
+
}) : Object.defineProperty(s, "ref", { enumerable: !1, value: null }), s._store = {}, Object.defineProperty(s._store, "validated", {
|
|
171
174
|
configurable: !1,
|
|
172
175
|
enumerable: !1,
|
|
173
176
|
writable: !0,
|
|
174
177
|
value: 0
|
|
175
|
-
}), Object.defineProperty(
|
|
178
|
+
}), Object.defineProperty(s, "_debugInfo", {
|
|
176
179
|
configurable: !1,
|
|
177
180
|
enumerable: !1,
|
|
178
181
|
writable: !0,
|
|
179
182
|
value: null
|
|
180
|
-
}), Object.defineProperty(
|
|
183
|
+
}), Object.defineProperty(s, "_debugStack", {
|
|
181
184
|
configurable: !1,
|
|
182
185
|
enumerable: !1,
|
|
183
186
|
writable: !0,
|
|
184
|
-
value:
|
|
185
|
-
}), Object.defineProperty(
|
|
187
|
+
value: Y
|
|
188
|
+
}), Object.defineProperty(s, "_debugTask", {
|
|
186
189
|
configurable: !1,
|
|
187
190
|
enumerable: !1,
|
|
188
191
|
writable: !0,
|
|
189
|
-
value:
|
|
190
|
-
}), Object.freeze && (Object.freeze(
|
|
192
|
+
value: I
|
|
193
|
+
}), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s;
|
|
191
194
|
}
|
|
192
|
-
function
|
|
193
|
-
var
|
|
194
|
-
if (
|
|
195
|
-
if (
|
|
196
|
-
if (
|
|
197
|
-
for (
|
|
198
|
-
|
|
199
|
-
Object.freeze && Object.freeze(
|
|
195
|
+
function p(s, u, h, E, A, w, Y, I) {
|
|
196
|
+
var m = u.children;
|
|
197
|
+
if (m !== void 0)
|
|
198
|
+
if (E)
|
|
199
|
+
if (Se(m)) {
|
|
200
|
+
for (E = 0; E < m.length; E++)
|
|
201
|
+
l(m[E]);
|
|
202
|
+
Object.freeze && Object.freeze(m);
|
|
200
203
|
} else
|
|
201
204
|
console.error(
|
|
202
205
|
"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
206
|
);
|
|
204
|
-
else
|
|
205
|
-
if (
|
|
206
|
-
|
|
207
|
-
var
|
|
208
|
-
return
|
|
207
|
+
else l(m);
|
|
208
|
+
if (B.call(u, "key")) {
|
|
209
|
+
m = i(s);
|
|
210
|
+
var L = Object.keys(u).filter(function(ge) {
|
|
211
|
+
return ge !== "key";
|
|
209
212
|
});
|
|
210
|
-
|
|
213
|
+
E = 0 < L.length ? "{key: someKey, " + L.join(": ..., ") + ": ...}" : "{key: someKey}", Z[m + E] || (L = 0 < L.length ? "{" + L.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
211
214
|
`A props object containing a "key" prop is being spread into JSX:
|
|
212
215
|
let props = %s;
|
|
213
216
|
<%s {...props} />
|
|
214
217
|
React keys must be passed directly to JSX without using spread:
|
|
215
218
|
let props = %s;
|
|
216
219
|
<%s key={someKey} {...props} />`,
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
),
|
|
220
|
+
E,
|
|
221
|
+
m,
|
|
222
|
+
L,
|
|
223
|
+
m
|
|
224
|
+
), Z[m + E] = !0);
|
|
222
225
|
}
|
|
223
|
-
if (
|
|
224
|
-
|
|
225
|
-
for (var
|
|
226
|
-
|
|
227
|
-
} else
|
|
228
|
-
return
|
|
229
|
-
|
|
230
|
-
typeof
|
|
231
|
-
),
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
226
|
+
if (m = null, h !== void 0 && (r(h), m = "" + h), n(u) && (r(u.key), m = "" + u.key), "key" in u) {
|
|
227
|
+
h = {};
|
|
228
|
+
for (var q in u)
|
|
229
|
+
q !== "key" && (h[q] = u[q]);
|
|
230
|
+
} else h = u;
|
|
231
|
+
return m && f(
|
|
232
|
+
h,
|
|
233
|
+
typeof s == "function" ? s.displayName || s.name || "Unknown" : s
|
|
234
|
+
), g(
|
|
235
|
+
s,
|
|
236
|
+
m,
|
|
237
|
+
w,
|
|
238
|
+
A,
|
|
239
|
+
o(),
|
|
240
|
+
h,
|
|
241
|
+
Y,
|
|
242
|
+
I
|
|
240
243
|
);
|
|
241
244
|
}
|
|
242
|
-
function
|
|
243
|
-
typeof
|
|
245
|
+
function l(s) {
|
|
246
|
+
typeof s == "object" && s !== null && s.$$typeof === b && s._store && (s._store.validated = 1);
|
|
244
247
|
}
|
|
245
|
-
var
|
|
248
|
+
var R = ve, b = Symbol.for("react.transitional.element"), v = Symbol.for("react.portal"), x = Symbol.for("react.fragment"), O = Symbol.for("react.strict_mode"), P = Symbol.for("react.profiler"), ie = Symbol.for("react.consumer"), ce = Symbol.for("react.context"), ue = Symbol.for("react.forward_ref"), fe = Symbol.for("react.suspense"), le = Symbol.for("react.suspense_list"), de = Symbol.for("react.memo"), U = Symbol.for("react.lazy"), pe = Symbol.for("react.activity"), he = Symbol.for("react.client.reference"), $ = R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, B = Object.prototype.hasOwnProperty, Se = Array.isArray, V = console.createTask ? console.createTask : function() {
|
|
246
249
|
return null;
|
|
247
250
|
};
|
|
248
|
-
|
|
249
|
-
react_stack_bottom_frame: function(
|
|
250
|
-
return
|
|
251
|
+
R = {
|
|
252
|
+
react_stack_bottom_frame: function(s) {
|
|
253
|
+
return s();
|
|
251
254
|
}
|
|
252
255
|
};
|
|
253
|
-
var J,
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
)(),
|
|
257
|
-
|
|
258
|
-
var
|
|
259
|
-
return
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
256
|
+
var J, M = {}, X = R.react_stack_bottom_frame.bind(
|
|
257
|
+
R,
|
|
258
|
+
a
|
|
259
|
+
)(), H = V(t(a)), Z = {};
|
|
260
|
+
D.Fragment = x, D.jsx = function(s, u, h, E, A) {
|
|
261
|
+
var w = 1e4 > $.recentlyCreatedOwnerStacks++;
|
|
262
|
+
return p(
|
|
263
|
+
s,
|
|
264
|
+
u,
|
|
265
|
+
h,
|
|
263
266
|
!1,
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
267
|
+
E,
|
|
268
|
+
A,
|
|
269
|
+
w ? Error("react-stack-top-frame") : X,
|
|
270
|
+
w ? V(t(s)) : H
|
|
268
271
|
);
|
|
269
|
-
},
|
|
270
|
-
var
|
|
271
|
-
return
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
272
|
+
}, D.jsxs = function(s, u, h, E, A) {
|
|
273
|
+
var w = 1e4 > $.recentlyCreatedOwnerStacks++;
|
|
274
|
+
return p(
|
|
275
|
+
s,
|
|
276
|
+
u,
|
|
277
|
+
h,
|
|
275
278
|
!0,
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
279
|
+
E,
|
|
280
|
+
A,
|
|
281
|
+
w ? Error("react-stack-top-frame") : X,
|
|
282
|
+
w ? V(t(s)) : H
|
|
280
283
|
);
|
|
281
284
|
};
|
|
282
|
-
}()),
|
|
285
|
+
}()), D;
|
|
283
286
|
}
|
|
284
|
-
var
|
|
285
|
-
function
|
|
286
|
-
return
|
|
287
|
+
var ee;
|
|
288
|
+
function ye() {
|
|
289
|
+
return ee || (ee = 1, process.env.NODE_ENV === "production" ? F.exports = Re() : F.exports = _e()), F.exports;
|
|
287
290
|
}
|
|
288
|
-
var
|
|
289
|
-
let
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
},
|
|
293
|
-
|
|
291
|
+
var we = ye();
|
|
292
|
+
let se = !1;
|
|
293
|
+
const $e = (i) => {
|
|
294
|
+
se = i;
|
|
295
|
+
}, z = (...i) => {
|
|
296
|
+
se && console.log(
|
|
294
297
|
"%c[react-shared-states]",
|
|
295
298
|
"color: #007acc; font-weight: bold",
|
|
296
|
-
...
|
|
299
|
+
...i
|
|
297
300
|
);
|
|
298
|
-
},
|
|
299
|
-
if (!
|
|
300
|
-
return
|
|
301
|
-
},
|
|
301
|
+
}, j = (i) => {
|
|
302
|
+
if (!i) throw new Error("Value is empty");
|
|
303
|
+
return i;
|
|
304
|
+
}, ae = () => Math.random().toString(36).substring(2, 15), oe = be(void 0), Ve = ({ children: i, scopeName: e }) => {
|
|
302
305
|
if (e && e.includes("//")) throw new Error("scopeName cannot contain '//'");
|
|
303
|
-
return e || (e =
|
|
304
|
-
},
|
|
305
|
-
class
|
|
306
|
+
return e || (e = T(() => ae(), [])), /* @__PURE__ */ we.jsx(oe.Provider, { value: { scopeName: e }, children: i });
|
|
307
|
+
}, Te = () => xe(oe), te = [];
|
|
308
|
+
class d {
|
|
306
309
|
data = /* @__PURE__ */ new Map();
|
|
307
310
|
defaultValue() {
|
|
308
311
|
return {};
|
|
309
312
|
}
|
|
310
313
|
addListener(e, r, t) {
|
|
311
|
-
this.data.has(
|
|
312
|
-
...this.defaultValue,
|
|
314
|
+
this.data.has(d.prefix(e, r)) || this.data.set(d.prefix(e, r), {
|
|
315
|
+
...this.defaultValue(),
|
|
313
316
|
listeners: []
|
|
314
|
-
}), this.data.get(
|
|
317
|
+
}), this.data.get(d.prefix(e, r)).listeners.push(t);
|
|
315
318
|
}
|
|
316
319
|
removeListener(e, r, t) {
|
|
317
|
-
this.data.has(
|
|
320
|
+
this.data.has(d.prefix(e, r)) && (this.data.get(d.prefix(e, r)).listeners = this.data.get(d.prefix(e, r)).listeners.filter((o) => o !== t));
|
|
318
321
|
}
|
|
319
322
|
callListeners(e, r) {
|
|
320
|
-
this.data.has(
|
|
323
|
+
this.data.has(d.prefix(e, r)) && this.data.get(d.prefix(e, r)).listeners.forEach((t) => t());
|
|
321
324
|
}
|
|
322
|
-
init(e, r, t) {
|
|
323
|
-
this.data.has(
|
|
325
|
+
init(e, r, t, o = !1) {
|
|
326
|
+
this.data.has(d.prefix(e, r)) || this.data.set(d.prefix(e, r), {
|
|
324
327
|
...t,
|
|
328
|
+
isStatic: o,
|
|
325
329
|
listeners: []
|
|
326
330
|
});
|
|
327
331
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
+
createStatic(e, r) {
|
|
333
|
+
const t = r ?? r ?? "_global", o = {
|
|
334
|
+
key: ae(),
|
|
335
|
+
prefix: t,
|
|
336
|
+
...e
|
|
337
|
+
};
|
|
338
|
+
return te.push(o), this.initStatic(o), o;
|
|
339
|
+
}
|
|
340
|
+
initStatic(e) {
|
|
341
|
+
const { key: r, prefix: t } = e;
|
|
342
|
+
this.init(r, t, this.defaultValue(), !0);
|
|
343
|
+
}
|
|
344
|
+
clearAll(e = !1, r = !1) {
|
|
345
|
+
this.data.forEach((t, o) => {
|
|
346
|
+
const [a, n] = d.extractPrefix(o);
|
|
347
|
+
this.clear(n, a, e, r);
|
|
348
|
+
});
|
|
332
349
|
}
|
|
333
|
-
clear(e, r, t = !1) {
|
|
334
|
-
t || this.callListeners(e, r)
|
|
350
|
+
clear(e, r, t = !1, o = !1) {
|
|
351
|
+
t || this.callListeners(e, r);
|
|
352
|
+
const a = this.data.get(d.prefix(e, r));
|
|
353
|
+
if (!a) return;
|
|
354
|
+
const n = { ...a };
|
|
355
|
+
if (this.data.delete(d.prefix(e, r)), n.isStatic && !o) {
|
|
356
|
+
const f = te.find((c) => c.key === e && c.prefix === r);
|
|
357
|
+
f && this.initStatic(f);
|
|
358
|
+
}
|
|
335
359
|
}
|
|
336
360
|
get(e, r) {
|
|
337
361
|
let t = this.has(e, r);
|
|
@@ -339,13 +363,13 @@ class u {
|
|
|
339
363
|
return this.data.get(t);
|
|
340
364
|
}
|
|
341
365
|
setValue(e, r, t) {
|
|
342
|
-
this.data.has(
|
|
343
|
-
...this.data.get(
|
|
366
|
+
this.data.has(d.prefix(e, r)) && this.data.set(d.prefix(e, r), {
|
|
367
|
+
...this.data.get(d.prefix(e, r)),
|
|
344
368
|
...t
|
|
345
369
|
});
|
|
346
370
|
}
|
|
347
371
|
has(e, r) {
|
|
348
|
-
return this.data.has(
|
|
372
|
+
return this.data.has(d.prefix(e, r)) ? d.prefix(e, r) : this.data.has(d.prefix(e, "_global")) ? d.prefix(e, "_global") : void 0;
|
|
349
373
|
}
|
|
350
374
|
static prefix(e, r) {
|
|
351
375
|
if (e.includes("//")) throw new Error("key cannot contain '//'");
|
|
@@ -355,35 +379,34 @@ class u {
|
|
|
355
379
|
return e.split("//");
|
|
356
380
|
}
|
|
357
381
|
useEffect(e, r, t = null) {
|
|
358
|
-
|
|
359
|
-
t?.(),
|
|
382
|
+
ne(() => () => {
|
|
383
|
+
t?.(), z(`[${d.prefix(e, r)}]`, "unmount effect"), this.data.get(d.prefix(e, r)).listeners?.length === 0 && this.clear(e, r);
|
|
360
384
|
}, []);
|
|
361
385
|
}
|
|
362
386
|
}
|
|
363
|
-
class
|
|
387
|
+
class G {
|
|
364
388
|
constructor(e) {
|
|
365
389
|
this.sharedData = e;
|
|
366
390
|
}
|
|
367
|
-
/**
|
|
368
|
-
* get a value from the shared data
|
|
369
|
-
* @param key
|
|
370
|
-
* @param scopeName
|
|
371
|
-
*/
|
|
372
391
|
get(e, r) {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
392
|
+
let t, o = r;
|
|
393
|
+
if (typeof e != "string") {
|
|
394
|
+
const { key: f, prefix: c } = e;
|
|
395
|
+
t = f, o = c;
|
|
396
|
+
} else
|
|
397
|
+
t = j(e);
|
|
398
|
+
const a = o || "_global";
|
|
399
|
+
return this.sharedData.get(t, a);
|
|
376
400
|
}
|
|
377
|
-
/**
|
|
378
|
-
* set a value in the shared data
|
|
379
|
-
* @param key
|
|
380
|
-
* @param value
|
|
381
|
-
* @param scopeName
|
|
382
|
-
*/
|
|
383
401
|
set(e, r, t) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
402
|
+
let o, a = t;
|
|
403
|
+
if (typeof e != "string") {
|
|
404
|
+
const { key: f, prefix: c } = e;
|
|
405
|
+
o = f, a = c;
|
|
406
|
+
} else
|
|
407
|
+
o = j(e);
|
|
408
|
+
const n = a || "_global";
|
|
409
|
+
this.sharedData.init(o, n, r), this.sharedData.setValue(o, n, r), this.sharedData.callListeners(o, n);
|
|
387
410
|
}
|
|
388
411
|
/**
|
|
389
412
|
* clear all values from the shared data
|
|
@@ -397,10 +420,10 @@ class W {
|
|
|
397
420
|
*/
|
|
398
421
|
clearScope(e) {
|
|
399
422
|
const r = e || "_global";
|
|
400
|
-
this.sharedData.data.forEach((t,
|
|
401
|
-
const [
|
|
402
|
-
if (
|
|
403
|
-
this.sharedData.clear(
|
|
423
|
+
this.sharedData.data.forEach((t, o) => {
|
|
424
|
+
const [a, n] = d.extractPrefix(o);
|
|
425
|
+
if (a === r) {
|
|
426
|
+
this.sharedData.clear(n, a), this.sharedData.callListeners(n, a);
|
|
404
427
|
return;
|
|
405
428
|
}
|
|
406
429
|
});
|
|
@@ -413,14 +436,9 @@ class W {
|
|
|
413
436
|
const { key: r, prefix: t } = e;
|
|
414
437
|
return this.get(r, t);
|
|
415
438
|
}
|
|
416
|
-
/**
|
|
417
|
-
* clear a value from the shared data
|
|
418
|
-
* @param key
|
|
419
|
-
* @param scopeName
|
|
420
|
-
*/
|
|
421
439
|
clear(e, r) {
|
|
422
|
-
let t,
|
|
423
|
-
typeof e == "string" ? (t = e,
|
|
440
|
+
let t, o;
|
|
441
|
+
typeof e == "string" ? (t = e, o = r || "_global") : (t = e.key, o = e.prefix), this.sharedData.clear(t, o);
|
|
424
442
|
}
|
|
425
443
|
/**
|
|
426
444
|
* check if a value exists in the shared data
|
|
@@ -437,72 +455,144 @@ class W {
|
|
|
437
455
|
getAll() {
|
|
438
456
|
const e = {};
|
|
439
457
|
return this.sharedData.data.forEach((r, t) => {
|
|
440
|
-
const [
|
|
441
|
-
e[
|
|
458
|
+
const [o, a] = d.extractPrefix(t);
|
|
459
|
+
e[o] = e[o] || {}, e[o][a] = r;
|
|
442
460
|
}), e;
|
|
443
461
|
}
|
|
444
462
|
}
|
|
445
|
-
const
|
|
446
|
-
const e =
|
|
463
|
+
const k = (i) => {
|
|
464
|
+
const e = Te();
|
|
447
465
|
return {
|
|
448
|
-
prefix:
|
|
466
|
+
prefix: i ?? e?.scopeName ?? "_global"
|
|
449
467
|
};
|
|
450
468
|
};
|
|
451
|
-
|
|
469
|
+
var W, re;
|
|
470
|
+
function Ae() {
|
|
471
|
+
if (re) return W;
|
|
472
|
+
re = 1;
|
|
473
|
+
var i = typeof Element < "u", e = typeof Map == "function", r = typeof Set == "function", t = typeof ArrayBuffer == "function" && !!ArrayBuffer.isView;
|
|
474
|
+
function o(a, n) {
|
|
475
|
+
if (a === n) return !0;
|
|
476
|
+
if (a && n && typeof a == "object" && typeof n == "object") {
|
|
477
|
+
if (a.constructor !== n.constructor) return !1;
|
|
478
|
+
var f, c, g;
|
|
479
|
+
if (Array.isArray(a)) {
|
|
480
|
+
if (f = a.length, f != n.length) return !1;
|
|
481
|
+
for (c = f; c-- !== 0; )
|
|
482
|
+
if (!o(a[c], n[c])) return !1;
|
|
483
|
+
return !0;
|
|
484
|
+
}
|
|
485
|
+
var p;
|
|
486
|
+
if (e && a instanceof Map && n instanceof Map) {
|
|
487
|
+
if (a.size !== n.size) return !1;
|
|
488
|
+
for (p = a.entries(); !(c = p.next()).done; )
|
|
489
|
+
if (!n.has(c.value[0])) return !1;
|
|
490
|
+
for (p = a.entries(); !(c = p.next()).done; )
|
|
491
|
+
if (!o(c.value[1], n.get(c.value[0]))) return !1;
|
|
492
|
+
return !0;
|
|
493
|
+
}
|
|
494
|
+
if (r && a instanceof Set && n instanceof Set) {
|
|
495
|
+
if (a.size !== n.size) return !1;
|
|
496
|
+
for (p = a.entries(); !(c = p.next()).done; )
|
|
497
|
+
if (!n.has(c.value[0])) return !1;
|
|
498
|
+
return !0;
|
|
499
|
+
}
|
|
500
|
+
if (t && ArrayBuffer.isView(a) && ArrayBuffer.isView(n)) {
|
|
501
|
+
if (f = a.length, f != n.length) return !1;
|
|
502
|
+
for (c = f; c-- !== 0; )
|
|
503
|
+
if (a[c] !== n[c]) return !1;
|
|
504
|
+
return !0;
|
|
505
|
+
}
|
|
506
|
+
if (a.constructor === RegExp) return a.source === n.source && a.flags === n.flags;
|
|
507
|
+
if (a.valueOf !== Object.prototype.valueOf && typeof a.valueOf == "function" && typeof n.valueOf == "function") return a.valueOf() === n.valueOf();
|
|
508
|
+
if (a.toString !== Object.prototype.toString && typeof a.toString == "function" && typeof n.toString == "function") return a.toString() === n.toString();
|
|
509
|
+
if (g = Object.keys(a), f = g.length, f !== Object.keys(n).length) return !1;
|
|
510
|
+
for (c = f; c-- !== 0; )
|
|
511
|
+
if (!Object.prototype.hasOwnProperty.call(n, g[c])) return !1;
|
|
512
|
+
if (i && a instanceof Element) return !1;
|
|
513
|
+
for (c = f; c-- !== 0; )
|
|
514
|
+
if (!((g[c] === "_owner" || g[c] === "__v" || g[c] === "__o") && a.$$typeof) && !o(a[g[c]], n[g[c]]))
|
|
515
|
+
return !1;
|
|
516
|
+
return !0;
|
|
517
|
+
}
|
|
518
|
+
return a !== a && n !== n;
|
|
519
|
+
}
|
|
520
|
+
return W = function(n, f) {
|
|
521
|
+
try {
|
|
522
|
+
return o(n, f);
|
|
523
|
+
} catch (c) {
|
|
524
|
+
if ((c.message || "").match(/stack|recursion/i))
|
|
525
|
+
return console.warn("react-fast-compare cannot handle circular refs"), !1;
|
|
526
|
+
throw c;
|
|
527
|
+
}
|
|
528
|
+
}, W;
|
|
529
|
+
}
|
|
530
|
+
var Oe = Ae();
|
|
531
|
+
const Pe = /* @__PURE__ */ me(Oe);
|
|
532
|
+
class Le extends d {
|
|
452
533
|
defaultValue() {
|
|
453
534
|
return { value: void 0 };
|
|
454
535
|
}
|
|
455
|
-
|
|
456
|
-
super.init(e, r, { value: t });
|
|
457
|
-
}
|
|
458
|
-
setValue(e, r, t) {
|
|
459
|
-
super.setValue(e, r, { value: t });
|
|
536
|
+
initValue(e, r, t, o = !1) {
|
|
537
|
+
super.init(e, r, { value: t }, o);
|
|
460
538
|
}
|
|
461
|
-
|
|
462
|
-
|
|
539
|
+
initStatic(e) {
|
|
540
|
+
const { key: r, prefix: t, initialValue: o } = e;
|
|
541
|
+
this.initValue(r, t, o, !0);
|
|
463
542
|
}
|
|
464
543
|
}
|
|
465
|
-
class
|
|
544
|
+
class je extends G {
|
|
545
|
+
constructor(e) {
|
|
546
|
+
super(e);
|
|
547
|
+
}
|
|
466
548
|
get(e, r = "_global") {
|
|
467
|
-
e
|
|
468
|
-
const t = r || "_global";
|
|
469
|
-
return m.get(e, t)?.value;
|
|
549
|
+
return typeof e != "string" ? super.get(e)?.value : super.get(e, r)?.value;
|
|
470
550
|
}
|
|
471
551
|
set(e, r, t = "_global") {
|
|
472
|
-
e
|
|
473
|
-
|
|
474
|
-
|
|
552
|
+
if (typeof e != "string") {
|
|
553
|
+
super.set(e, { value: r });
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
super.set(e, { value: r }, t);
|
|
475
557
|
}
|
|
476
558
|
}
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
prefix:
|
|
482
|
-
|
|
483
|
-
};
|
|
484
|
-
};
|
|
485
|
-
function ye(a, e, r) {
|
|
486
|
-
let t, s, f = r;
|
|
487
|
-
if (typeof a != "string") {
|
|
488
|
-
const { key: c, initialValue: S, prefix: h } = a;
|
|
489
|
-
t = c, s = S, f = h;
|
|
559
|
+
const _ = new Le(), Ye = new je(_), Ie = (i, e) => _.createStatic({ initialValue: i }, e);
|
|
560
|
+
function qe(i, e, r) {
|
|
561
|
+
let t, o, a = r;
|
|
562
|
+
if (typeof i != "string") {
|
|
563
|
+
const { key: l, initialValue: R, prefix: b } = i;
|
|
564
|
+
t = l, o = R, a = b;
|
|
490
565
|
} else
|
|
491
|
-
t =
|
|
492
|
-
const { prefix:
|
|
493
|
-
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
}), []),
|
|
497
|
-
const
|
|
498
|
-
|
|
566
|
+
t = j(i), o = e;
|
|
567
|
+
const { prefix: n } = k(a);
|
|
568
|
+
_.initValue(t, n, o);
|
|
569
|
+
const f = T(() => (l) => (_.initValue(t, n, e), _.addListener(t, n, l), () => {
|
|
570
|
+
_.removeListener(t, n, l);
|
|
571
|
+
}), []), c = T(() => () => _.get(t, n)?.value, []), g = N(f, c), p = (l) => {
|
|
572
|
+
const R = typeof l == "function" ? l(_.get(t, n)?.value) : l;
|
|
573
|
+
R !== g && (_.setValue(t, n, { value: R }), _.callListeners(t, n));
|
|
499
574
|
};
|
|
500
|
-
return
|
|
501
|
-
|
|
502
|
-
|
|
575
|
+
return _.useEffect(t, n), [
|
|
576
|
+
g,
|
|
577
|
+
p
|
|
503
578
|
];
|
|
504
579
|
}
|
|
505
|
-
|
|
580
|
+
function We(i, e, r) {
|
|
581
|
+
let t, o = r;
|
|
582
|
+
if (typeof i != "string") {
|
|
583
|
+
const { key: p, prefix: l } = i;
|
|
584
|
+
t = p, o = l;
|
|
585
|
+
} else
|
|
586
|
+
t = j(i);
|
|
587
|
+
const { prefix: a } = k(o), n = Ee(void 0), f = T(() => (p) => (_.addListener(t, a, p), () => {
|
|
588
|
+
_.removeListener(t, a, p);
|
|
589
|
+
}), []), c = T(() => () => {
|
|
590
|
+
const p = _.get(t, a)?.value, l = e(p);
|
|
591
|
+
return Pe(n.current, l) ? n.current : l;
|
|
592
|
+
}, []), g = N(f, c);
|
|
593
|
+
return _.useEffect(t, a), g;
|
|
594
|
+
}
|
|
595
|
+
class Ce extends d {
|
|
506
596
|
defaultValue() {
|
|
507
597
|
return {
|
|
508
598
|
fnState: {
|
|
@@ -512,77 +602,73 @@ class Te extends u {
|
|
|
512
602
|
}
|
|
513
603
|
};
|
|
514
604
|
}
|
|
515
|
-
|
|
516
|
-
super.init(e, r, this.defaultValue());
|
|
605
|
+
initValue(e, r, t = !1) {
|
|
606
|
+
super.init(e, r, this.defaultValue(), t);
|
|
517
607
|
}
|
|
518
608
|
setValue(e, r, t) {
|
|
519
609
|
super.setValue(e, r, t);
|
|
520
610
|
}
|
|
521
611
|
}
|
|
522
|
-
class
|
|
612
|
+
class De extends G {
|
|
613
|
+
constructor(e) {
|
|
614
|
+
super(e);
|
|
615
|
+
}
|
|
523
616
|
get(e, r = "_global") {
|
|
524
|
-
e
|
|
525
|
-
const t = r || "_global";
|
|
526
|
-
return x.get(e, t)?.fnState;
|
|
617
|
+
return typeof e != "string" ? super.get(e)?.fnState : super.get(e, r)?.fnState;
|
|
527
618
|
}
|
|
528
619
|
set(e, r, t = "_global") {
|
|
529
|
-
e
|
|
530
|
-
|
|
531
|
-
|
|
620
|
+
if (typeof e != "string") {
|
|
621
|
+
super.set(e, r);
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
super.set(e, r, t);
|
|
532
625
|
}
|
|
533
626
|
}
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
prefix:
|
|
539
|
-
|
|
540
|
-
};
|
|
541
|
-
};
|
|
542
|
-
function Ye(a, e, r) {
|
|
543
|
-
let t, s, f = r;
|
|
544
|
-
if (typeof a != "string") {
|
|
545
|
-
const { key: c, fn: S, prefix: h } = a;
|
|
546
|
-
t = c, s = S, f = h;
|
|
627
|
+
const y = new Ce(), ze = new De(y), Ge = (i, e) => y.createStatic({ fn: i }, e);
|
|
628
|
+
function Ue(i, e, r) {
|
|
629
|
+
let t, o, a = r;
|
|
630
|
+
if (typeof i != "string") {
|
|
631
|
+
const { key: l, fn: R, prefix: b } = i;
|
|
632
|
+
t = l, o = R, a = b;
|
|
547
633
|
} else
|
|
548
|
-
t =
|
|
549
|
-
const { prefix:
|
|
550
|
-
|
|
551
|
-
const
|
|
552
|
-
() => (
|
|
553
|
-
|
|
634
|
+
t = j(i), o = e;
|
|
635
|
+
const { prefix: n } = k(a);
|
|
636
|
+
y.initValue(t, n);
|
|
637
|
+
const f = T(
|
|
638
|
+
() => (l) => (y.initValue(t, n), y.addListener(t, n, l), () => {
|
|
639
|
+
y.removeListener(t, n, l);
|
|
554
640
|
}),
|
|
555
641
|
[]
|
|
556
|
-
),
|
|
557
|
-
() => () =>
|
|
642
|
+
), c = T(
|
|
643
|
+
() => () => y.get(t, n).fnState,
|
|
558
644
|
[]
|
|
559
|
-
),
|
|
560
|
-
const
|
|
561
|
-
if (!
|
|
562
|
-
|
|
645
|
+
), g = N(f, c), p = async (l, ...R) => {
|
|
646
|
+
const b = y.get(t, n);
|
|
647
|
+
if (!l && (b.fnState.isLoading || b.fnState.results !== void 0)) return b.fnState;
|
|
648
|
+
b.fnState = { ...b.fnState, isLoading: !0, error: void 0 }, y.callListeners(t, n);
|
|
563
649
|
try {
|
|
564
|
-
const
|
|
565
|
-
|
|
566
|
-
} catch (
|
|
567
|
-
|
|
650
|
+
const v = await o(...R);
|
|
651
|
+
b.fnState = { results: v, isLoading: !1, error: void 0 };
|
|
652
|
+
} catch (v) {
|
|
653
|
+
b.fnState = { ...b.fnState, isLoading: !1, error: v };
|
|
568
654
|
}
|
|
569
|
-
|
|
655
|
+
y.callListeners(t, n);
|
|
570
656
|
};
|
|
571
|
-
return
|
|
572
|
-
state:
|
|
573
|
-
trigger: (...
|
|
574
|
-
|
|
657
|
+
return y.useEffect(t, n), {
|
|
658
|
+
state: g,
|
|
659
|
+
trigger: (...l) => {
|
|
660
|
+
p(!1, ...l);
|
|
575
661
|
},
|
|
576
|
-
forceTrigger: (...
|
|
577
|
-
|
|
662
|
+
forceTrigger: (...l) => {
|
|
663
|
+
p(!0, ...l);
|
|
578
664
|
},
|
|
579
665
|
clear: () => {
|
|
580
|
-
const
|
|
581
|
-
|
|
666
|
+
const l = y.get(t, n);
|
|
667
|
+
l && (l.fnState = y.defaultValue().fnState, y.callListeners(t, n));
|
|
582
668
|
}
|
|
583
669
|
};
|
|
584
670
|
}
|
|
585
|
-
class
|
|
671
|
+
class Fe extends d {
|
|
586
672
|
defaultValue() {
|
|
587
673
|
return {
|
|
588
674
|
fnState: {
|
|
@@ -593,15 +679,15 @@ class we extends u {
|
|
|
593
679
|
}
|
|
594
680
|
};
|
|
595
681
|
}
|
|
596
|
-
|
|
597
|
-
super.init(e, r, this.defaultValue());
|
|
682
|
+
initValue(e, r, t = !1) {
|
|
683
|
+
super.init(e, r, this.defaultValue(), t);
|
|
598
684
|
}
|
|
599
685
|
setValue(e, r, t) {
|
|
600
686
|
super.setValue(e, r, t);
|
|
601
687
|
}
|
|
602
688
|
useEffect(e, r) {
|
|
603
|
-
|
|
604
|
-
|
|
689
|
+
ne(() => () => {
|
|
690
|
+
z(`[${d.prefix(e, r)}]`, "unmount effect2"), this.get(e, r)?.listeners.length === 0 && this.unsubscribe(e, r);
|
|
605
691
|
}, []), super.useEffect(e, r);
|
|
606
692
|
}
|
|
607
693
|
async unsubscribe(e, r) {
|
|
@@ -609,90 +695,89 @@ class we extends u {
|
|
|
609
695
|
t && (t.unsubscribe && (t.unsubscribe(), t.unsubscribe = void 0), t.fnState = { ...t.fnState, subscribed: !1 }, this.callListeners(e, r));
|
|
610
696
|
}
|
|
611
697
|
}
|
|
612
|
-
class
|
|
698
|
+
class Ne extends G {
|
|
699
|
+
constructor(e) {
|
|
700
|
+
super(e);
|
|
701
|
+
}
|
|
613
702
|
get(e, r = "_global") {
|
|
614
|
-
e
|
|
615
|
-
const t = r || "_global";
|
|
616
|
-
return E.get(e, t)?.fnState;
|
|
703
|
+
return typeof e != "string" ? super.get(e)?.fnState : super.get(e, r)?.fnState;
|
|
617
704
|
}
|
|
618
705
|
set(e, r, t = "_global") {
|
|
619
|
-
e
|
|
620
|
-
|
|
621
|
-
|
|
706
|
+
if (typeof e != "string") {
|
|
707
|
+
super.set(e, r);
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
super.set(e, r, t);
|
|
622
711
|
}
|
|
623
712
|
}
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
prefix:
|
|
629
|
-
|
|
630
|
-
};
|
|
631
|
-
};
|
|
632
|
-
function Me(a, e, r) {
|
|
633
|
-
let t, s, f = r;
|
|
634
|
-
if (typeof a != "string") {
|
|
635
|
-
const { key: d, subscriber: l, prefix: v } = a;
|
|
636
|
-
t = d, s = l, f = v;
|
|
713
|
+
const S = new Fe(), Be = new Ne(S), Je = (i, e) => S.createStatic({ subscriber: i }, e);
|
|
714
|
+
function Me(i, e, r) {
|
|
715
|
+
let t, o, a = r;
|
|
716
|
+
if (typeof i != "string") {
|
|
717
|
+
const { key: v, subscriber: x, prefix: O } = i;
|
|
718
|
+
t = v, o = x, a = O;
|
|
637
719
|
} else
|
|
638
|
-
t =
|
|
639
|
-
const { prefix:
|
|
640
|
-
|
|
641
|
-
const
|
|
642
|
-
() => (
|
|
643
|
-
|
|
720
|
+
t = j(i), o = e;
|
|
721
|
+
const { prefix: n } = k(a);
|
|
722
|
+
S.initValue(t, n);
|
|
723
|
+
const f = T(
|
|
724
|
+
() => (v) => (S.initValue(t, n), S.addListener(t, n, v), () => {
|
|
725
|
+
S.removeListener(t, n, v);
|
|
644
726
|
}),
|
|
645
727
|
[]
|
|
646
|
-
),
|
|
647
|
-
() => () =>
|
|
728
|
+
), c = T(
|
|
729
|
+
() => () => S.get(t, n).fnState,
|
|
648
730
|
[]
|
|
649
|
-
),
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
},
|
|
653
|
-
const
|
|
654
|
-
|
|
655
|
-
},
|
|
656
|
-
const
|
|
657
|
-
|
|
658
|
-
},
|
|
659
|
-
const
|
|
660
|
-
if (
|
|
661
|
-
|
|
731
|
+
), g = N(f, c), p = (v) => {
|
|
732
|
+
const x = S.get(t, n);
|
|
733
|
+
x.fnState = { ...x.fnState, data: v }, S.callListeners(t, n);
|
|
734
|
+
}, l = (v) => {
|
|
735
|
+
const x = S.get(t, n);
|
|
736
|
+
x.fnState = { ...x.fnState, isLoading: !1, data: void 0, error: v }, S.callListeners(t, n);
|
|
737
|
+
}, R = () => {
|
|
738
|
+
const v = S.get(t, n);
|
|
739
|
+
v.fnState = { ...v.fnState, isLoading: !1 }, S.callListeners(t, n);
|
|
740
|
+
}, b = async (v) => {
|
|
741
|
+
const x = S.get(t, n);
|
|
742
|
+
if (v && (await S.unsubscribe(t, n), x.fnState = { ...x.fnState, isLoading: !1, data: void 0, error: void 0, subscribed: !1 }), x.fnState.subscribed) return x.fnState;
|
|
743
|
+
z("triggered !!"), x.fnState = { ...x.fnState, isLoading: !0, error: void 0 }, S.callListeners(t, n);
|
|
662
744
|
try {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
745
|
+
const O = await o(p, l, R), P = S.get(t, n);
|
|
746
|
+
P.unsubscribe = O, P.fnState.subscribed = !0;
|
|
747
|
+
} catch (O) {
|
|
748
|
+
const P = S.get(t, n);
|
|
749
|
+
P.fnState = { ...P.fnState, isLoading: !1, error: O };
|
|
666
750
|
}
|
|
667
|
-
|
|
751
|
+
S.callListeners(t, n);
|
|
668
752
|
};
|
|
669
|
-
return
|
|
670
|
-
state:
|
|
753
|
+
return S.useEffect(t, n), {
|
|
754
|
+
state: g,
|
|
671
755
|
trigger: () => {
|
|
672
|
-
|
|
756
|
+
b(!1);
|
|
673
757
|
},
|
|
674
758
|
forceTrigger: () => {
|
|
675
|
-
|
|
759
|
+
b(!0);
|
|
676
760
|
},
|
|
677
761
|
unsubscribe: () => {
|
|
678
|
-
|
|
762
|
+
S.unsubscribe(t, n);
|
|
679
763
|
}
|
|
680
764
|
};
|
|
681
765
|
}
|
|
682
766
|
export {
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
767
|
+
De as SharedFunctionsApi,
|
|
768
|
+
je as SharedStatesApi,
|
|
769
|
+
Ve as SharedStatesProvider,
|
|
770
|
+
Ne as SharedSubscriptionsApi,
|
|
771
|
+
Ge as createSharedFunction,
|
|
772
|
+
Ie as createSharedState,
|
|
773
|
+
Je as createSharedSubscription,
|
|
774
|
+
se as isDevMode,
|
|
775
|
+
$e as setDevMode,
|
|
776
|
+
ze as sharedFunctionsApi,
|
|
777
|
+
Ye as sharedStatesApi,
|
|
778
|
+
Be as sharedSubscriptionsApi,
|
|
779
|
+
Ue as useSharedFunction,
|
|
780
|
+
qe as useSharedState,
|
|
781
|
+
We as useSharedStateSelector,
|
|
697
782
|
Me as useSharedSubscription
|
|
698
783
|
};
|