react-shared-states 1.0.5 → 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/dist/config/index.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/main.esm.js +74 -68
- package/dist/main.min.js +5 -5
- package/package.json +1 -1
- package/vite.config.ts +4 -1
package/dist/index.d.ts
CHANGED
package/dist/main.esm.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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
|
|
8
|
+
import de, { createContext as be, useMemo as w, useContext as ge, useEffect as Q, useSyncExternalStore as M } from "react";
|
|
9
9
|
var L = { exports: {} }, P = {};
|
|
10
10
|
/**
|
|
11
11
|
* @license React
|
|
@@ -17,7 +17,7 @@ var L = { exports: {} }, P = {};
|
|
|
17
17
|
* LICENSE file in the root directory of this source tree.
|
|
18
18
|
*/
|
|
19
19
|
var D;
|
|
20
|
-
function
|
|
20
|
+
function pe() {
|
|
21
21
|
if (D) return P;
|
|
22
22
|
D = 1;
|
|
23
23
|
var s = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
@@ -49,41 +49,41 @@ var j = {};
|
|
|
49
49
|
* LICENSE file in the root directory of this source tree.
|
|
50
50
|
*/
|
|
51
51
|
var H;
|
|
52
|
-
function
|
|
52
|
+
function he() {
|
|
53
53
|
return H || (H = 1, process.env.NODE_ENV !== "production" && function() {
|
|
54
54
|
function s(n) {
|
|
55
55
|
if (n == null) return null;
|
|
56
56
|
if (typeof n == "function")
|
|
57
|
-
return n.$$typeof ===
|
|
57
|
+
return n.$$typeof === ce ? null : n.displayName || n.name || null;
|
|
58
58
|
if (typeof n == "string") return n;
|
|
59
59
|
switch (n) {
|
|
60
|
-
case
|
|
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 se:
|
|
67
|
-
return "Suspense";
|
|
68
66
|
case ae:
|
|
67
|
+
return "Suspense";
|
|
68
|
+
case oe:
|
|
69
69
|
return "SuspenseList";
|
|
70
|
-
case
|
|
70
|
+
case le:
|
|
71
71
|
return "Activity";
|
|
72
72
|
}
|
|
73
73
|
if (typeof n == "object")
|
|
74
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
76
|
), n.$$typeof) {
|
|
77
|
-
case
|
|
77
|
+
case k:
|
|
78
78
|
return "Portal";
|
|
79
|
-
case
|
|
79
|
+
case ne:
|
|
80
80
|
return (n.displayName || "Context") + ".Provider";
|
|
81
|
-
case
|
|
81
|
+
case re:
|
|
82
82
|
return (n._context.displayName || "Context") + ".Consumer";
|
|
83
|
-
case
|
|
83
|
+
case se:
|
|
84
84
|
var a = n.render;
|
|
85
85
|
return n = n.displayName, n || (n = a.displayName || a.name || "", n = n !== "" ? "ForwardRef(" + n + ")" : "ForwardRef"), n;
|
|
86
|
-
case
|
|
86
|
+
case ie:
|
|
87
87
|
return a = n.displayName || null, a !== null ? a : s(n.type) || "Memo";
|
|
88
88
|
case U:
|
|
89
89
|
a = n._payload, n = n._init;
|
|
@@ -115,7 +115,7 @@ function pe() {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
function t(n) {
|
|
118
|
-
if (n ===
|
|
118
|
+
if (n === C) return "<>";
|
|
119
119
|
if (typeof n == "object" && n !== null && n.$$typeof === U)
|
|
120
120
|
return "<...>";
|
|
121
121
|
try {
|
|
@@ -126,7 +126,7 @@ function pe() {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
function i() {
|
|
129
|
-
var n =
|
|
129
|
+
var n = N.A;
|
|
130
130
|
return n === null ? null : n.getOwner();
|
|
131
131
|
}
|
|
132
132
|
function b() {
|
|
@@ -157,12 +157,12 @@ function pe() {
|
|
|
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 T(n, a, u, p, A,
|
|
161
|
-
return u =
|
|
162
|
-
$$typeof:
|
|
160
|
+
function T(n, a, u, p, A, _, Y, F) {
|
|
161
|
+
return u = _.ref, n = {
|
|
162
|
+
$$typeof: x,
|
|
163
163
|
type: n,
|
|
164
164
|
key: a,
|
|
165
|
-
props:
|
|
165
|
+
props: _,
|
|
166
166
|
_owner: A
|
|
167
167
|
}, (u !== void 0 ? u : null) !== null ? Object.defineProperty(n, "ref", {
|
|
168
168
|
enumerable: !1,
|
|
@@ -189,11 +189,11 @@ function pe() {
|
|
|
189
189
|
value: F
|
|
190
190
|
}), Object.freeze && (Object.freeze(n.props), Object.freeze(n)), n;
|
|
191
191
|
}
|
|
192
|
-
function g(n, a, u, p, A,
|
|
192
|
+
function g(n, a, u, p, A, _, Y, F) {
|
|
193
193
|
var h = a.children;
|
|
194
194
|
if (h !== void 0)
|
|
195
195
|
if (p)
|
|
196
|
-
if (
|
|
196
|
+
if (ue(h)) {
|
|
197
197
|
for (p = 0; p < h.length; p++)
|
|
198
198
|
c(h[p]);
|
|
199
199
|
Object.freeze && Object.freeze(h);
|
|
@@ -204,8 +204,8 @@ function pe() {
|
|
|
204
204
|
else c(h);
|
|
205
205
|
if (G.call(a, "key")) {
|
|
206
206
|
h = s(n);
|
|
207
|
-
var O = Object.keys(a).filter(function(
|
|
208
|
-
return
|
|
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:
|
|
@@ -231,7 +231,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
231
231
|
), T(
|
|
232
232
|
n,
|
|
233
233
|
h,
|
|
234
|
-
|
|
234
|
+
_,
|
|
235
235
|
A,
|
|
236
236
|
i(),
|
|
237
237
|
u,
|
|
@@ -240,9 +240,9 @@ React keys must be passed directly to JSX without using spread:
|
|
|
240
240
|
);
|
|
241
241
|
}
|
|
242
242
|
function c(n) {
|
|
243
|
-
typeof n == "object" && n !== null && n.$$typeof ===
|
|
243
|
+
typeof n == "object" && n !== null && n.$$typeof === x && n._store && (n._store.validated = 1);
|
|
244
244
|
}
|
|
245
|
-
var o =
|
|
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
248
|
o = {
|
|
@@ -254,8 +254,8 @@ React keys must be passed directly to JSX without using spread:
|
|
|
254
254
|
o,
|
|
255
255
|
b
|
|
256
256
|
)(), B = V(t(b)), X = {};
|
|
257
|
-
j.Fragment =
|
|
258
|
-
var
|
|
257
|
+
j.Fragment = C, j.jsx = function(n, a, u, p, A) {
|
|
258
|
+
var _ = 1e4 > N.recentlyCreatedOwnerStacks++;
|
|
259
259
|
return g(
|
|
260
260
|
n,
|
|
261
261
|
a,
|
|
@@ -263,11 +263,11 @@ React keys must be passed directly to JSX without using spread:
|
|
|
263
263
|
!1,
|
|
264
264
|
p,
|
|
265
265
|
A,
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
_ ? Error("react-stack-top-frame") : z,
|
|
267
|
+
_ ? V(t(n)) : B
|
|
268
268
|
);
|
|
269
269
|
}, j.jsxs = function(n, a, u, p, A) {
|
|
270
|
-
var
|
|
270
|
+
var _ = 1e4 > N.recentlyCreatedOwnerStacks++;
|
|
271
271
|
return g(
|
|
272
272
|
n,
|
|
273
273
|
a,
|
|
@@ -275,19 +275,23 @@ React keys must be passed directly to JSX without using spread:
|
|
|
275
275
|
!0,
|
|
276
276
|
p,
|
|
277
277
|
A,
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
_ ? Error("react-stack-top-frame") : z,
|
|
279
|
+
_ ? V(t(n)) : B
|
|
280
280
|
);
|
|
281
281
|
};
|
|
282
282
|
}()), j;
|
|
283
283
|
}
|
|
284
284
|
var Z;
|
|
285
|
-
function
|
|
286
|
-
return Z || (Z = 1, process.env.NODE_ENV === "production" ? L.exports =
|
|
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 K =
|
|
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(
|
|
291
295
|
"%c[react-shared-states]",
|
|
292
296
|
"color: #007acc; font-weight: bold",
|
|
293
297
|
...s
|
|
@@ -346,17 +350,17 @@ class l {
|
|
|
346
350
|
}
|
|
347
351
|
useEffect(e, r, t = null) {
|
|
348
352
|
Q(() => () => {
|
|
349
|
-
t?.(),
|
|
353
|
+
t?.(), I(`[${l.prefix(e, r)}]`, "unmount effect"), this.data.get(l.prefix(e, r)).listeners?.length === 0 && this.clear(e, r);
|
|
350
354
|
}, []);
|
|
351
355
|
}
|
|
352
356
|
}
|
|
353
357
|
const W = (s) => {
|
|
354
|
-
const e =
|
|
358
|
+
const e = Se();
|
|
355
359
|
return {
|
|
356
360
|
prefix: s ?? e?.scopeName ?? "_global"
|
|
357
361
|
};
|
|
358
362
|
};
|
|
359
|
-
class
|
|
363
|
+
class me extends l {
|
|
360
364
|
defaultValue() {
|
|
361
365
|
return { value: void 0 };
|
|
362
366
|
}
|
|
@@ -370,7 +374,7 @@ class Se extends l {
|
|
|
370
374
|
super.removeListener(e, r, t);
|
|
371
375
|
}
|
|
372
376
|
}
|
|
373
|
-
class
|
|
377
|
+
class xe {
|
|
374
378
|
get(e, r = "_global") {
|
|
375
379
|
e = R(e);
|
|
376
380
|
const t = r || "_global";
|
|
@@ -396,13 +400,13 @@ class me {
|
|
|
396
400
|
return E.data;
|
|
397
401
|
}
|
|
398
402
|
}
|
|
399
|
-
const
|
|
403
|
+
const je = new xe(), E = new me(), Le = (s, e, r) => {
|
|
400
404
|
s = R(s);
|
|
401
405
|
const { prefix: t } = W(r);
|
|
402
406
|
E.init(s, t, e);
|
|
403
407
|
const i = w(() => (f) => (E.init(s, t, e), E.addListener(s, t, f), () => {
|
|
404
408
|
E.removeListener(s, t, f);
|
|
405
|
-
}), []), b = w(() => () => E.get(s, t)?.value, []), S =
|
|
409
|
+
}), []), b = w(() => () => E.get(s, t)?.value, []), S = M(i, b), m = (f) => {
|
|
406
410
|
const T = typeof f == "function" ? f(E.get(s, t)?.value) : f;
|
|
407
411
|
T !== S && (E.setValue(s, t, T), E.callListeners(s, t));
|
|
408
412
|
};
|
|
@@ -428,7 +432,7 @@ class _e extends l {
|
|
|
428
432
|
super.setValue(e, r, t);
|
|
429
433
|
}
|
|
430
434
|
}
|
|
431
|
-
class
|
|
435
|
+
class Re {
|
|
432
436
|
get(e, r = "_global") {
|
|
433
437
|
e = R(e);
|
|
434
438
|
const t = r || "_global";
|
|
@@ -454,7 +458,7 @@ class xe {
|
|
|
454
458
|
return v.data;
|
|
455
459
|
}
|
|
456
460
|
}
|
|
457
|
-
const
|
|
461
|
+
const Ce = new Re(), v = new _e(), Ne = (s, e, r) => {
|
|
458
462
|
s = R(s);
|
|
459
463
|
const { prefix: t } = W(r);
|
|
460
464
|
v.init(s, t);
|
|
@@ -466,7 +470,7 @@ const je = new xe(), v = new _e(), Le = (s, e, r) => {
|
|
|
466
470
|
), b = w(
|
|
467
471
|
() => () => v.get(s, t).fnState,
|
|
468
472
|
[]
|
|
469
|
-
), S =
|
|
473
|
+
), S = M(i, b), m = async (f, ...T) => {
|
|
470
474
|
const g = v.get(s, t);
|
|
471
475
|
if (!f && (g.fnState.isLoading || g.fnState.results !== void 0)) return g.fnState;
|
|
472
476
|
g.fnState = { ...g.fnState, isLoading: !0, error: void 0 }, g.listeners.forEach((c) => c());
|
|
@@ -491,7 +495,7 @@ const je = new xe(), v = new _e(), Le = (s, e, r) => {
|
|
|
491
495
|
}
|
|
492
496
|
};
|
|
493
497
|
};
|
|
494
|
-
class
|
|
498
|
+
class Te extends l {
|
|
495
499
|
defaultValue() {
|
|
496
500
|
return {
|
|
497
501
|
fnState: {
|
|
@@ -510,7 +514,7 @@ class Re extends l {
|
|
|
510
514
|
}
|
|
511
515
|
useEffect(e, r) {
|
|
512
516
|
Q(() => () => {
|
|
513
|
-
|
|
517
|
+
I(`[${l.prefix(e, r)}]`, "unmount effect2"), this.get(e, r)?.listeners.length === 0 && this.unsubscribe(e, r);
|
|
514
518
|
}, []), super.useEffect(e, r);
|
|
515
519
|
}
|
|
516
520
|
async unsubscribe(e, r) {
|
|
@@ -518,7 +522,7 @@ class Re extends l {
|
|
|
518
522
|
t && (t.unsubscribe && (t.unsubscribe(), t.unsubscribe = void 0), t.fnState.subscribed = !1);
|
|
519
523
|
}
|
|
520
524
|
}
|
|
521
|
-
class
|
|
525
|
+
class Ae {
|
|
522
526
|
get(e, r = "_global") {
|
|
523
527
|
e = R(e);
|
|
524
528
|
const t = r || "_global";
|
|
@@ -544,7 +548,7 @@ class Te {
|
|
|
544
548
|
return d.data;
|
|
545
549
|
}
|
|
546
550
|
}
|
|
547
|
-
const
|
|
551
|
+
const Ve = new Ae(), d = new Te(), Ye = (s, e, r) => {
|
|
548
552
|
s = R(s);
|
|
549
553
|
const { prefix: t } = W(r);
|
|
550
554
|
d.init(s, t);
|
|
@@ -556,25 +560,25 @@ const Ne = new Te(), d = new Re(), Ce = (s, e, r) => {
|
|
|
556
560
|
), b = w(
|
|
557
561
|
() => () => d.get(s, t).fnState,
|
|
558
562
|
[]
|
|
559
|
-
), S =
|
|
563
|
+
), S = M(i, b), m = (c) => {
|
|
560
564
|
const o = d.get(s, t);
|
|
561
|
-
o.fnState = { ...o.fnState, data: c }, o.listeners.forEach((
|
|
565
|
+
o.fnState = { ...o.fnState, data: c }, o.listeners.forEach((x) => x());
|
|
562
566
|
}, f = (c) => {
|
|
563
567
|
const o = d.get(s, t);
|
|
564
|
-
o.fnState = { ...o.fnState, isLoading: !1, data: void 0, error: c }, o.listeners.forEach((
|
|
568
|
+
o.fnState = { ...o.fnState, isLoading: !1, data: void 0, error: c }, o.listeners.forEach((x) => x());
|
|
565
569
|
}, T = () => {
|
|
566
570
|
const c = d.get(s, t);
|
|
567
571
|
c.fnState = { ...c.fnState, isLoading: !1 }, c.listeners.forEach((o) => o());
|
|
568
572
|
}, g = async (c) => {
|
|
569
573
|
const o = d.get(s, t);
|
|
570
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;
|
|
571
|
-
|
|
575
|
+
I("triggered !!"), o.fnState = { ...o.fnState, isLoading: !0, error: void 0 }, o.listeners.forEach((x) => x());
|
|
572
576
|
try {
|
|
573
577
|
o.unsubscribe = await e(m, f, T), o.fnState.subscribed = !0;
|
|
574
|
-
} catch (
|
|
575
|
-
o.fnState = { ...o.fnState, isLoading: !1, error:
|
|
578
|
+
} catch (x) {
|
|
579
|
+
o.fnState = { ...o.fnState, isLoading: !1, error: x };
|
|
576
580
|
}
|
|
577
|
-
o.listeners.forEach((
|
|
581
|
+
o.listeners.forEach((x) => x());
|
|
578
582
|
};
|
|
579
583
|
return d.useEffect(s, t), {
|
|
580
584
|
state: S,
|
|
@@ -590,11 +594,13 @@ const Ne = new Te(), d = new Re(), Ce = (s, e, r) => {
|
|
|
590
594
|
};
|
|
591
595
|
};
|
|
592
596
|
export {
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
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
|
|
600
606
|
};
|
package/dist/main.min.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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
|
-
(function(
|
|
8
|
+
(function(g,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],f):(g=typeof globalThis<"u"?globalThis:g||self,f(g.ReactSharedStates={},g.React))})(this,function(g,f){"use strict";var C={exports:{}},j={};/**
|
|
9
9
|
* @license React
|
|
10
10
|
* react-jsx-runtime.production.js
|
|
11
11
|
*
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the MIT license found in the
|
|
15
15
|
* LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/var G;function y(){if(G)return j;G=1;var s=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function r(t,l,
|
|
16
|
+
*/var G;function y(){if(G)return j;G=1;var s=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function r(t,l,h){var _=null;if(h!==void 0&&(_=""+h),l.key!==void 0&&(_=""+l.key),"key"in l){h={};for(var x in l)x!=="key"&&(h[x]=l[x])}else h=l;return l=h.ref,{$$typeof:s,type:t,key:_,ref:l!==void 0?l:null,props:h}}return j.Fragment=e,j.jsx=r,j.jsxs=r,j}var L={};/**
|
|
17
17
|
* @license React
|
|
18
18
|
* react-jsx-runtime.development.js
|
|
19
19
|
*
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
*
|
|
22
22
|
* This source code is licensed under the MIT license found in the
|
|
23
23
|
* LICENSE file in the root directory of this source tree.
|
|
24
|
-
*/var J;function $(){return J||(J=1,process.env.NODE_ENV!=="production"&&function(){function s(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===
|
|
24
|
+
*/var J;function $(){return J||(J=1,process.env.NODE_ENV!=="production"&&function(){function s(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===we?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case V:return"Fragment";case ve:return"Profiler";case pe:return"StrictMode";case xe:return"Suspense";case Re:return"SuspenseList";case Ae:return"Activity"}if(typeof n=="object")switch(typeof n.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),n.$$typeof){case Se:return"Portal";case me:return(n.displayName||"Context")+".Provider";case Ee:return(n._context.displayName||"Context")+".Consumer";case _e:var a=n.render;return n=n.displayName,n||(n=a.displayName||a.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case Te:return a=n.displayName||null,a!==null?a:s(n.type)||"Memo";case B:a=n._payload,n=n._init;try{return s(n(a))}catch{}}return null}function e(n){return""+n}function r(n){try{e(n);var a=!1}catch{a=!0}if(a){a=console;var u=a.error,p=typeof Symbol=="function"&&Symbol.toStringTag&&n[Symbol.toStringTag]||n.constructor.name||"Object";return u.call(a,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",p),e(n)}}function t(n){if(n===V)return"<>";if(typeof n=="object"&&n!==null&&n.$$typeof===B)return"<...>";try{var a=s(n);return a?"<"+a+">":"<...>"}catch{return"<...>"}}function l(){var n=F.A;return n===null?null:n.getOwner()}function h(){return Error("react-stack-top-frame")}function _(n){if(X.call(n,"key")){var a=Object.getOwnPropertyDescriptor(n,"key").get;if(a&&a.isReactWarning)return!1}return n.key!==void 0}function x(n,a){function u(){H||(H=!0,console.error("%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)",a))}u.isReactWarning=!0,Object.defineProperty(n,"key",{get:u,configurable:!0})}function d(){var n=s(this.type);return Z[n]||(Z[n]=!0,console.error("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.")),n=this.props.ref,n!==void 0?n:null}function w(n,a,u,p,P,T,I,W){return u=T.ref,n={$$typeof:R,type:n,key:a,props:T,_owner:P},(u!==void 0?u:null)!==null?Object.defineProperty(n,"ref",{enumerable:!1,get:d}):Object.defineProperty(n,"ref",{enumerable:!1,value:null}),n._store={},Object.defineProperty(n._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(n,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(n,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:I}),Object.defineProperty(n,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:W}),Object.freeze&&(Object.freeze(n.props),Object.freeze(n)),n}function S(n,a,u,p,P,T,I,W){var v=a.children;if(v!==void 0)if(p)if(Pe(v)){for(p=0;p<v.length;p++)c(v[p]);Object.freeze&&Object.freeze(v)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else c(v);if(X.call(a,"key")){v=s(n);var O=Object.keys(a).filter(function(Oe){return Oe!=="key"});p=0<O.length?"{key: someKey, "+O.join(": ..., ")+": ...}":"{key: someKey}",q[v+p]||(O=0<O.length?"{"+O.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
25
25
|
let props = %s;
|
|
26
26
|
<%s {...props} />
|
|
27
27
|
React keys must be passed directly to JSX without using spread:
|
|
28
28
|
let props = %s;
|
|
29
|
-
<%s key={someKey} {...props} />`,
|
|
29
|
+
<%s key={someKey} {...props} />`,p,v,O,v),q[v+p]=!0)}if(v=null,u!==void 0&&(r(u),v=""+u),_(a)&&(r(a.key),v=""+a.key),"key"in a){u={};for(var U in a)U!=="key"&&(u[U]=a[U])}else u=a;return v&&x(u,typeof n=="function"?n.displayName||n.name||"Unknown":n),w(n,v,T,P,l(),u,I,W)}function c(n){typeof n=="object"&&n!==null&&n.$$typeof===R&&n._store&&(n._store.validated=1)}var o=f,R=Symbol.for("react.transitional.element"),Se=Symbol.for("react.portal"),V=Symbol.for("react.fragment"),pe=Symbol.for("react.strict_mode"),ve=Symbol.for("react.profiler"),Ee=Symbol.for("react.consumer"),me=Symbol.for("react.context"),_e=Symbol.for("react.forward_ref"),xe=Symbol.for("react.suspense"),Re=Symbol.for("react.suspense_list"),Te=Symbol.for("react.memo"),B=Symbol.for("react.lazy"),Ae=Symbol.for("react.activity"),we=Symbol.for("react.client.reference"),F=o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X=Object.prototype.hasOwnProperty,Pe=Array.isArray,Y=console.createTask?console.createTask:function(){return null};o={react_stack_bottom_frame:function(n){return n()}};var H,Z={},Q=o.react_stack_bottom_frame.bind(o,h)(),K=Y(t(h)),q={};L.Fragment=V,L.jsx=function(n,a,u,p,P){var T=1e4>F.recentlyCreatedOwnerStacks++;return S(n,a,u,!1,p,P,T?Error("react-stack-top-frame"):Q,T?Y(t(n)):K)},L.jsxs=function(n,a,u,p,P){var T=1e4>F.recentlyCreatedOwnerStacks++;return S(n,a,u,!0,p,P,T?Error("react-stack-top-frame"):Q,T?Y(t(n)):K)}}()),L}var z;function k(){return z||(z=1,process.env.NODE_ENV==="production"?C.exports=y():C.exports=$()),C.exports}var ee=k();const D=f.createContext(void 0),te=({children:s,scopeName:e})=>(e||(e=f.useMemo(()=>Math.random().toString(36).substring(2,15),[])),ee.jsx(D.Provider,{value:{scopeName:e},children:s})),re=()=>f.useContext(D);g.isDevMode=!1;const ne=s=>{g.isDevMode=s},N=(...s)=>{g.isDevMode&&console.log("%c[react-shared-states]","color: #007acc; font-weight: bold",...s)},A=s=>{if(!s)throw new Error("Value is empty");return s};class i{data=new Map;defaultValue(){return{}}addListener(e,r,t){this.data.has(i.prefix(e,r))||this.data.set(i.prefix(e,r),{...this.defaultValue,listeners:[]}),this.data.get(i.prefix(e,r)).listeners.push(t)}removeListener(e,r,t){this.data.has(i.prefix(e,r))&&(this.data.get(i.prefix(e,r)).listeners=this.data.get(i.prefix(e,r)).listeners.filter(l=>l!==t))}callListeners(e,r){this.data.has(i.prefix(e,r))&&this.data.get(i.prefix(e,r)).listeners.forEach(t=>t())}init(e,r,t){this.data.has(i.prefix(e,r))||this.data.set(i.prefix(e,r),{...t,listeners:[]})}clearAll(e=!1){e||this.data.forEach(r=>{r.listeners.forEach(t=>t())}),this.data.clear()}clear(e,r,t=!1){t||this.callListeners(e,r),this.data.delete(i.prefix(e,r))}get(e,r){let t=this.has(e,r);if(t)return this.data.get(t)}setValue(e,r,t){this.data.has(i.prefix(e,r))&&this.data.set(i.prefix(e,r),{...this.data.get(i.prefix(e,r)),...t})}has(e,r){return this.data.has(i.prefix(e,r))?i.prefix(e,r):this.data.has(i.prefix(e,"_global"))?i.prefix(e,"_global"):void 0}static prefix(e,r){return`${r}_${e}`}useEffect(e,r,t=null){f.useEffect(()=>()=>{t?.(),N(`[${i.prefix(e,r)}]`,"unmount effect"),this.data.get(i.prefix(e,r)).listeners?.length===0&&this.clear(e,r)},[])}}const M=s=>{const e=re();return{prefix:s??e?.scopeName??"_global"}};class se extends i{defaultValue(){return{value:void 0}}init(e,r,t){super.init(e,r,{value:t})}setValue(e,r,t){super.setValue(e,r,{value:t})}removeListener(e,r,t){super.removeListener(e,r,t)}}class ae{get(e,r="_global"){e=A(e);const t=r||"_global";return E.get(e,t)?.value}set(e,r,t="_global"){e=A(e);const l=t||"_global";E.setValue(e,l,{value:r})}clearAll(){E.clearAll()}clear(e,r="_global"){const t=r||"_global";E.clear(e,t)}has(e,r="_global"){const t=r||"_global";return!!E.has(e,t)}getAll(){return E.data}}const oe=new ae,E=new se,ie=(s,e,r)=>{s=A(s);const{prefix:t}=M(r);E.init(s,t,e);const l=f.useMemo(()=>d=>(E.init(s,t,e),E.addListener(s,t,d),()=>{E.removeListener(s,t,d)}),[]),h=f.useMemo(()=>()=>E.get(s,t)?.value,[]),_=f.useSyncExternalStore(l,h),x=d=>{const w=typeof d=="function"?d(E.get(s,t)?.value):d;w!==_&&(E.setValue(s,t,w),E.callListeners(s,t))};return E.useEffect(s,t),[_,x]};class le extends i{defaultValue(){return{fnState:{results:void 0,isLoading:!1,error:void 0}}}init(e,r){super.init(e,r,this.defaultValue())}setValue(e,r,t){super.setValue(e,r,t)}}class ce{get(e,r="_global"){e=A(e);const t=r||"_global";return m.get(e,t)?.fnState}set(e,r,t="_global"){e=A(e);const l=t||"_global";m.setValue(e,l,r)}clearAll(){m.clearAll()}clear(e,r="_global"){const t=r||"_global";m.clear(e,t)}has(e,r="_global"){const t=r||"_global";return!!m.has(e,t)}getAll(){return m.data}}const ue=new ce,m=new le,fe=(s,e,r)=>{s=A(s);const{prefix:t}=M(r);m.init(s,t);const l=f.useMemo(()=>d=>(m.init(s,t),m.addListener(s,t,d),()=>{m.removeListener(s,t,d)}),[]),h=f.useMemo(()=>()=>m.get(s,t).fnState,[]),_=f.useSyncExternalStore(l,h),x=async(d,...w)=>{const S=m.get(s,t);if(!d&&(S.fnState.isLoading||S.fnState.results!==void 0))return S.fnState;S.fnState={...S.fnState,isLoading:!0,error:void 0},S.listeners.forEach(c=>c());try{const c=await e(...w);S.fnState={results:c,isLoading:!1,error:void 0}}catch(c){S.fnState={...S.fnState,isLoading:!1,error:c}}S.listeners.forEach(c=>c())};return m.useEffect(s,t),{state:_,trigger:(...d)=>{x(!1,...d)},forceTrigger:(...d)=>{x(!0,...d)},clear:()=>{m.clear(s,t),m.init(s,t)}}};class de extends i{defaultValue(){return{fnState:{data:void 0,isLoading:!1,error:void 0,subscribed:!1}}}init(e,r){super.init(e,r,this.defaultValue())}setValue(e,r,t){super.setValue(e,r,t)}useEffect(e,r){f.useEffect(()=>()=>{N(`[${i.prefix(e,r)}]`,"unmount effect2"),this.get(e,r)?.listeners.length===0&&this.unsubscribe(e,r)},[]),super.useEffect(e,r)}async unsubscribe(e,r){const t=this.get(e,r);t&&(t.unsubscribe&&(t.unsubscribe(),t.unsubscribe=void 0),t.fnState.subscribed=!1)}}class be{get(e,r="_global"){e=A(e);const t=r||"_global";return b.get(e,t)?.fnState}set(e,r,t="_global"){e=A(e);const l=t||"_global";b.setValue(e,l,r)}clearAll(){b.clearAll()}clear(e,r="_global"){const t=r||"_global";b.clear(e,t)}has(e,r="_global"){const t=r||"_global";return!!b.has(e,t)}getAll(){return b.data}}const ge=new be,b=new de,he=(s,e,r)=>{s=A(s);const{prefix:t}=M(r);b.init(s,t);const l=f.useMemo(()=>c=>(b.init(s,t),b.addListener(s,t,c),()=>{b.removeListener(s,t,c)}),[]),h=f.useMemo(()=>()=>b.get(s,t).fnState,[]),_=f.useSyncExternalStore(l,h),x=c=>{const o=b.get(s,t);o.fnState={...o.fnState,data:c},o.listeners.forEach(R=>R())},d=c=>{const o=b.get(s,t);o.fnState={...o.fnState,isLoading:!1,data:void 0,error:c},o.listeners.forEach(R=>R())},w=()=>{const c=b.get(s,t);c.fnState={...c.fnState,isLoading:!1},c.listeners.forEach(o=>o())},S=async c=>{const o=b.get(s,t);if(c&&(await b.unsubscribe(s,t),o.fnState={...o.fnState,isLoading:!1,data:void 0,error:void 0,subscribed:!1}),o.fnState.subscribed)return o.fnState;N("triggered !!"),o.fnState={...o.fnState,isLoading:!0,error:void 0},o.listeners.forEach(R=>R());try{o.unsubscribe=await e(x,d,w),o.fnState.subscribed=!0}catch(R){o.fnState={...o.fnState,isLoading:!1,error:R}}o.listeners.forEach(R=>R())};return b.useEffect(s,t),{state:_,trigger:()=>{S(!1)},forceTrigger:()=>{S(!0)},unsubscribe:()=>{b.unsubscribe(s,t)}}};g.SharedStatesProvider=te,g.setDevMode=ne,g.sharedFunctionsApi=ue,g.sharedStatesApi=oe,g.sharedSubscriptionsApi=ge,g.useSharedFunction=fe,g.useSharedState=ie,g.useSharedSubscription=he,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
package/vite.config.ts
CHANGED