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