@yoltra/react 0.6.0 → 0.7.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/README.es.md +70 -71
- package/README.md +34 -34
- package/dist/index.cjs +4 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +295 -307
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
package/dist/index.mjs
CHANGED
|
@@ -1,33 +1,25 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @yoltra/react v0.
|
|
2
|
+
* @yoltra/react v0.7.0
|
|
3
3
|
* (c) 2026 Manu Ramirez <@pixerael>
|
|
4
|
-
* License: MIT
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* LICENSE file in the root directory of this source tree
|
|
9
|
-
*/
|
|
10
|
-
var Pe = Object.defineProperty;
|
|
11
|
-
var _e = (t, e, n) => e in t ? Pe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
12
|
-
var ue = (t, e, n) => _e(t, typeof e != "symbol" ? e + "" : e, n);
|
|
13
|
-
import we, { createContext as me, useRef as P, useMemo as A, useCallback as he, useEffect as ve, useSyncExternalStore as I, useContext as ye } from "react";
|
|
14
|
-
import { createStore as Te } from "@yoltra/core";
|
|
15
|
-
const be = me(null);
|
|
4
|
+
* License: MIT */
|
|
5
|
+
import ge, { createContext as de, useRef as P, useMemo as E, useCallback as me, useEffect as he, useSyncExternalStore as I, useContext as ve } from "react";
|
|
6
|
+
import { createStore as Pe } from "@yoltra/core";
|
|
7
|
+
const ye = de(null);
|
|
16
8
|
var G = { exports: {} }, z = {};
|
|
17
|
-
var
|
|
18
|
-
function
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
var
|
|
9
|
+
var ue;
|
|
10
|
+
function _e() {
|
|
11
|
+
if (ue) return z;
|
|
12
|
+
ue = 1;
|
|
13
|
+
var r = /* @__PURE__ */ Symbol.for("react.transitional.element"), e = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
22
14
|
function n(o, s, c) {
|
|
23
15
|
var u = null;
|
|
24
16
|
if (c !== void 0 && (u = "" + c), s.key !== void 0 && (u = "" + s.key), "key" in s) {
|
|
25
17
|
c = {};
|
|
26
|
-
for (var
|
|
27
|
-
|
|
18
|
+
for (var d in s)
|
|
19
|
+
d !== "key" && (c[d] = s[d]);
|
|
28
20
|
} else c = s;
|
|
29
21
|
return s = c.ref, {
|
|
30
|
-
$$typeof:
|
|
22
|
+
$$typeof: r,
|
|
31
23
|
type: o,
|
|
32
24
|
key: u,
|
|
33
25
|
ref: s !== void 0 ? s : null,
|
|
@@ -37,20 +29,20 @@ function ke() {
|
|
|
37
29
|
return z.Fragment = e, z.jsx = n, z.jsxs = n, z;
|
|
38
30
|
}
|
|
39
31
|
var W = {};
|
|
40
|
-
var
|
|
41
|
-
function
|
|
42
|
-
return
|
|
43
|
-
function t
|
|
44
|
-
if (
|
|
45
|
-
if (typeof
|
|
46
|
-
return
|
|
47
|
-
if (typeof
|
|
48
|
-
switch (
|
|
49
|
-
case
|
|
32
|
+
var ae;
|
|
33
|
+
function we() {
|
|
34
|
+
return ae || (ae = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
35
|
+
function r(t) {
|
|
36
|
+
if (t == null) return null;
|
|
37
|
+
if (typeof t == "function")
|
|
38
|
+
return t.$$typeof === J ? null : t.displayName || t.name || null;
|
|
39
|
+
if (typeof t == "string") return t;
|
|
40
|
+
switch (t) {
|
|
41
|
+
case m:
|
|
50
42
|
return "Fragment";
|
|
51
43
|
case j:
|
|
52
44
|
return "Profiler";
|
|
53
|
-
case
|
|
45
|
+
case g:
|
|
54
46
|
return "StrictMode";
|
|
55
47
|
case D:
|
|
56
48
|
return "Suspense";
|
|
@@ -59,167 +51,167 @@ function xe() {
|
|
|
59
51
|
case N:
|
|
60
52
|
return "Activity";
|
|
61
53
|
}
|
|
62
|
-
if (typeof
|
|
63
|
-
switch (typeof
|
|
54
|
+
if (typeof t == "object")
|
|
55
|
+
switch (typeof t.tag == "number" && console.error(
|
|
64
56
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
65
|
-
),
|
|
57
|
+
), t.$$typeof) {
|
|
66
58
|
case y:
|
|
67
59
|
return "Portal";
|
|
68
|
-
case
|
|
69
|
-
return (
|
|
60
|
+
case R:
|
|
61
|
+
return (t.displayName || "Context") + ".Provider";
|
|
70
62
|
case w:
|
|
71
|
-
return (
|
|
63
|
+
return (t._context.displayName || "Context") + ".Consumer";
|
|
72
64
|
case O:
|
|
73
|
-
var a =
|
|
74
|
-
return
|
|
65
|
+
var a = t.render;
|
|
66
|
+
return t = t.displayName, t || (t = a.displayName || a.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
|
|
75
67
|
case $:
|
|
76
|
-
return a =
|
|
77
|
-
case
|
|
78
|
-
a =
|
|
68
|
+
return a = t.displayName || null, a !== null ? a : r(t.type) || "Memo";
|
|
69
|
+
case A:
|
|
70
|
+
a = t._payload, t = t._init;
|
|
79
71
|
try {
|
|
80
|
-
return t(
|
|
72
|
+
return r(t(a));
|
|
81
73
|
} catch {
|
|
82
74
|
}
|
|
83
75
|
}
|
|
84
76
|
return null;
|
|
85
77
|
}
|
|
86
|
-
function e(
|
|
87
|
-
return "" +
|
|
78
|
+
function e(t) {
|
|
79
|
+
return "" + t;
|
|
88
80
|
}
|
|
89
|
-
function n(
|
|
81
|
+
function n(t) {
|
|
90
82
|
try {
|
|
91
|
-
e(
|
|
83
|
+
e(t);
|
|
92
84
|
var a = !1;
|
|
93
85
|
} catch {
|
|
94
86
|
a = !0;
|
|
95
87
|
}
|
|
96
88
|
if (a) {
|
|
97
89
|
a = console;
|
|
98
|
-
var f = a.error,
|
|
90
|
+
var f = a.error, b = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
|
|
99
91
|
return f.call(
|
|
100
92
|
a,
|
|
101
93
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
102
|
-
|
|
103
|
-
), e(
|
|
94
|
+
b
|
|
95
|
+
), e(t);
|
|
104
96
|
}
|
|
105
97
|
}
|
|
106
|
-
function o(
|
|
107
|
-
if (
|
|
108
|
-
if (typeof
|
|
98
|
+
function o(t) {
|
|
99
|
+
if (t === m) return "<>";
|
|
100
|
+
if (typeof t == "object" && t !== null && t.$$typeof === A)
|
|
109
101
|
return "<...>";
|
|
110
102
|
try {
|
|
111
|
-
var a = t
|
|
103
|
+
var a = r(t);
|
|
112
104
|
return a ? "<" + a + ">" : "<...>";
|
|
113
105
|
} catch {
|
|
114
106
|
return "<...>";
|
|
115
107
|
}
|
|
116
108
|
}
|
|
117
109
|
function s() {
|
|
118
|
-
var
|
|
119
|
-
return
|
|
110
|
+
var t = T.A;
|
|
111
|
+
return t === null ? null : t.getOwner();
|
|
120
112
|
}
|
|
121
113
|
function c() {
|
|
122
114
|
return Error("react-stack-top-frame");
|
|
123
115
|
}
|
|
124
|
-
function u(
|
|
125
|
-
if (
|
|
126
|
-
var a = Object.getOwnPropertyDescriptor(
|
|
116
|
+
function u(t) {
|
|
117
|
+
if (B.call(t, "key")) {
|
|
118
|
+
var a = Object.getOwnPropertyDescriptor(t, "key").get;
|
|
127
119
|
if (a && a.isReactWarning) return !1;
|
|
128
120
|
}
|
|
129
|
-
return
|
|
121
|
+
return t.key !== void 0;
|
|
130
122
|
}
|
|
131
|
-
function
|
|
123
|
+
function d(t, a) {
|
|
132
124
|
function f() {
|
|
133
|
-
|
|
125
|
+
te || (te = !0, console.error(
|
|
134
126
|
"%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)",
|
|
135
127
|
a
|
|
136
128
|
));
|
|
137
129
|
}
|
|
138
|
-
f.isReactWarning = !0, Object.defineProperty(
|
|
130
|
+
f.isReactWarning = !0, Object.defineProperty(t, "key", {
|
|
139
131
|
get: f,
|
|
140
132
|
configurable: !0
|
|
141
133
|
});
|
|
142
134
|
}
|
|
143
|
-
function
|
|
144
|
-
var
|
|
145
|
-
return ne[
|
|
135
|
+
function h() {
|
|
136
|
+
var t = r(this.type);
|
|
137
|
+
return ne[t] || (ne[t] = !0, console.error(
|
|
146
138
|
"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."
|
|
147
|
-
)),
|
|
139
|
+
)), t = this.props.ref, t !== void 0 ? t : null;
|
|
148
140
|
}
|
|
149
|
-
function _(
|
|
150
|
-
return f = k.ref,
|
|
141
|
+
function _(t, a, f, b, C, k, Z, K) {
|
|
142
|
+
return f = k.ref, t = {
|
|
151
143
|
$$typeof: l,
|
|
152
|
-
type:
|
|
144
|
+
type: t,
|
|
153
145
|
key: a,
|
|
154
146
|
props: k,
|
|
155
147
|
_owner: C
|
|
156
|
-
}, (f !== void 0 ? f : null) !== null ? Object.defineProperty(
|
|
148
|
+
}, (f !== void 0 ? f : null) !== null ? Object.defineProperty(t, "ref", {
|
|
157
149
|
enumerable: !1,
|
|
158
|
-
get:
|
|
159
|
-
}) : Object.defineProperty(
|
|
150
|
+
get: h
|
|
151
|
+
}) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
|
|
160
152
|
configurable: !1,
|
|
161
153
|
enumerable: !1,
|
|
162
154
|
writable: !0,
|
|
163
155
|
value: 0
|
|
164
|
-
}), Object.defineProperty(
|
|
156
|
+
}), Object.defineProperty(t, "_debugInfo", {
|
|
165
157
|
configurable: !1,
|
|
166
158
|
enumerable: !1,
|
|
167
159
|
writable: !0,
|
|
168
160
|
value: null
|
|
169
|
-
}), Object.defineProperty(
|
|
161
|
+
}), Object.defineProperty(t, "_debugStack", {
|
|
170
162
|
configurable: !1,
|
|
171
163
|
enumerable: !1,
|
|
172
164
|
writable: !0,
|
|
173
165
|
value: Z
|
|
174
|
-
}), Object.defineProperty(
|
|
166
|
+
}), Object.defineProperty(t, "_debugTask", {
|
|
175
167
|
configurable: !1,
|
|
176
168
|
enumerable: !1,
|
|
177
169
|
writable: !0,
|
|
178
170
|
value: K
|
|
179
|
-
}), Object.freeze && (Object.freeze(
|
|
171
|
+
}), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
|
|
180
172
|
}
|
|
181
|
-
function p(
|
|
182
|
-
var
|
|
183
|
-
if (
|
|
184
|
-
if (
|
|
185
|
-
if (
|
|
186
|
-
for (
|
|
187
|
-
i(
|
|
188
|
-
Object.freeze && Object.freeze(
|
|
173
|
+
function p(t, a, f, b, C, k, Z, K) {
|
|
174
|
+
var S = a.children;
|
|
175
|
+
if (S !== void 0)
|
|
176
|
+
if (b)
|
|
177
|
+
if (X(S)) {
|
|
178
|
+
for (b = 0; b < S.length; b++)
|
|
179
|
+
i(S[b]);
|
|
180
|
+
Object.freeze && Object.freeze(S);
|
|
189
181
|
} else
|
|
190
182
|
console.error(
|
|
191
183
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
192
184
|
);
|
|
193
|
-
else i(
|
|
194
|
-
if (
|
|
195
|
-
|
|
196
|
-
var M = Object.keys(a).filter(function(
|
|
197
|
-
return
|
|
185
|
+
else i(S);
|
|
186
|
+
if (B.call(a, "key")) {
|
|
187
|
+
S = r(t);
|
|
188
|
+
var M = Object.keys(a).filter(function(Re) {
|
|
189
|
+
return Re !== "key";
|
|
198
190
|
});
|
|
199
|
-
|
|
191
|
+
b = 0 < M.length ? "{key: someKey, " + M.join(": ..., ") + ": ...}" : "{key: someKey}", ce[S + b] || (M = 0 < M.length ? "{" + M.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
200
192
|
`A props object containing a "key" prop is being spread into JSX:
|
|
201
193
|
let props = %s;
|
|
202
194
|
<%s {...props} />
|
|
203
195
|
React keys must be passed directly to JSX without using spread:
|
|
204
196
|
let props = %s;
|
|
205
197
|
<%s key={someKey} {...props} />`,
|
|
198
|
+
b,
|
|
206
199
|
S,
|
|
207
|
-
E,
|
|
208
200
|
M,
|
|
209
|
-
|
|
210
|
-
), ce[
|
|
201
|
+
S
|
|
202
|
+
), ce[S + b] = !0);
|
|
211
203
|
}
|
|
212
|
-
if (
|
|
204
|
+
if (S = null, f !== void 0 && (n(f), S = "" + f), u(a) && (n(a.key), S = "" + a.key), "key" in a) {
|
|
213
205
|
f = {};
|
|
214
206
|
for (var Q in a)
|
|
215
207
|
Q !== "key" && (f[Q] = a[Q]);
|
|
216
208
|
} else f = a;
|
|
217
|
-
return
|
|
209
|
+
return S && d(
|
|
218
210
|
f,
|
|
219
|
-
typeof
|
|
211
|
+
typeof t == "function" ? t.displayName || t.name || "Unknown" : t
|
|
220
212
|
), _(
|
|
221
|
-
|
|
222
|
-
|
|
213
|
+
t,
|
|
214
|
+
S,
|
|
223
215
|
k,
|
|
224
216
|
C,
|
|
225
217
|
s(),
|
|
@@ -228,157 +220,157 @@ React keys must be passed directly to JSX without using spread:
|
|
|
228
220
|
K
|
|
229
221
|
);
|
|
230
222
|
}
|
|
231
|
-
function i(
|
|
232
|
-
typeof
|
|
223
|
+
function i(t) {
|
|
224
|
+
typeof t == "object" && t !== null && t.$$typeof === l && t._store && (t._store.validated = 1);
|
|
233
225
|
}
|
|
234
|
-
var
|
|
226
|
+
var v = ge, l = /* @__PURE__ */ Symbol.for("react.transitional.element"), y = /* @__PURE__ */ Symbol.for("react.portal"), m = /* @__PURE__ */ Symbol.for("react.fragment"), g = /* @__PURE__ */ Symbol.for("react.strict_mode"), j = /* @__PURE__ */ Symbol.for("react.profiler"), w = /* @__PURE__ */ Symbol.for("react.consumer"), R = /* @__PURE__ */ Symbol.for("react.context"), O = /* @__PURE__ */ Symbol.for("react.forward_ref"), D = /* @__PURE__ */ Symbol.for("react.suspense"), F = /* @__PURE__ */ Symbol.for("react.suspense_list"), $ = /* @__PURE__ */ Symbol.for("react.memo"), A = /* @__PURE__ */ Symbol.for("react.lazy"), N = /* @__PURE__ */ Symbol.for("react.activity"), J = /* @__PURE__ */ Symbol.for("react.client.reference"), T = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, B = Object.prototype.hasOwnProperty, X = Array.isArray, H = console.createTask ? console.createTask : function() {
|
|
235
227
|
return null;
|
|
236
228
|
};
|
|
237
|
-
|
|
238
|
-
react_stack_bottom_frame: function(
|
|
239
|
-
return
|
|
229
|
+
v = {
|
|
230
|
+
react_stack_bottom_frame: function(t) {
|
|
231
|
+
return t();
|
|
240
232
|
}
|
|
241
233
|
};
|
|
242
|
-
var
|
|
243
|
-
|
|
234
|
+
var te, ne = {}, oe = v.react_stack_bottom_frame.bind(
|
|
235
|
+
v,
|
|
244
236
|
c
|
|
245
237
|
)(), se = H(o(c)), ce = {};
|
|
246
|
-
W.Fragment =
|
|
238
|
+
W.Fragment = m, W.jsx = function(t, a, f, b, C) {
|
|
247
239
|
var k = 1e4 > T.recentlyCreatedOwnerStacks++;
|
|
248
240
|
return p(
|
|
249
|
-
|
|
241
|
+
t,
|
|
250
242
|
a,
|
|
251
243
|
f,
|
|
252
244
|
!1,
|
|
253
|
-
|
|
245
|
+
b,
|
|
254
246
|
C,
|
|
255
247
|
k ? Error("react-stack-top-frame") : oe,
|
|
256
|
-
k ? H(o(
|
|
248
|
+
k ? H(o(t)) : se
|
|
257
249
|
);
|
|
258
|
-
}, W.jsxs = function(
|
|
250
|
+
}, W.jsxs = function(t, a, f, b, C) {
|
|
259
251
|
var k = 1e4 > T.recentlyCreatedOwnerStacks++;
|
|
260
252
|
return p(
|
|
261
|
-
|
|
253
|
+
t,
|
|
262
254
|
a,
|
|
263
255
|
f,
|
|
264
256
|
!0,
|
|
265
|
-
|
|
257
|
+
b,
|
|
266
258
|
C,
|
|
267
259
|
k ? Error("react-stack-top-frame") : oe,
|
|
268
|
-
k ? H(o(
|
|
260
|
+
k ? H(o(t)) : se
|
|
269
261
|
);
|
|
270
262
|
};
|
|
271
263
|
})()), W;
|
|
272
264
|
}
|
|
273
|
-
var
|
|
274
|
-
function
|
|
275
|
-
return
|
|
265
|
+
var ie;
|
|
266
|
+
function Te() {
|
|
267
|
+
return ie || (ie = 1, process.env.NODE_ENV === "production" ? G.exports = _e() : G.exports = we()), G.exports;
|
|
276
268
|
}
|
|
277
|
-
var
|
|
278
|
-
const
|
|
279
|
-
function
|
|
280
|
-
process.env.NODE_ENV !== "production" && (
|
|
269
|
+
var be = Te();
|
|
270
|
+
const Ve = ({ store: r, children: e }) => /* @__PURE__ */ be.jsx(ye.Provider, { value: r, children: e }), le = /* @__PURE__ */ new Set();
|
|
271
|
+
function ke(r, e) {
|
|
272
|
+
process.env.NODE_ENV !== "production" && (le.has(r) || (le.add(r), console.warn(e)));
|
|
281
273
|
}
|
|
282
|
-
function L(
|
|
283
|
-
return
|
|
274
|
+
function L(r) {
|
|
275
|
+
return r.includes("*");
|
|
284
276
|
}
|
|
285
|
-
function x(
|
|
286
|
-
return
|
|
277
|
+
function x(r) {
|
|
278
|
+
return r.replace(/^\./, "");
|
|
287
279
|
}
|
|
288
|
-
function
|
|
289
|
-
return x(
|
|
280
|
+
function xe(r) {
|
|
281
|
+
return x(r).split(".").filter(Boolean);
|
|
290
282
|
}
|
|
291
|
-
function
|
|
283
|
+
function je(r) {
|
|
292
284
|
const e = (n) => `${n.length}:${n}`;
|
|
293
|
-
return
|
|
285
|
+
return r.map((n) => {
|
|
294
286
|
const o = Array.isArray(n.property) ? n.property : [n.property];
|
|
295
287
|
return e(n.reducer) + e(String(o.length)) + o.map(e).join("");
|
|
296
288
|
}).join("");
|
|
297
289
|
}
|
|
298
|
-
const
|
|
299
|
-
function
|
|
290
|
+
const Se = /* @__PURE__ */ Symbol("yoltra.pathSegments");
|
|
291
|
+
function Ee(r) {
|
|
300
292
|
const e = () => {
|
|
301
293
|
};
|
|
302
294
|
return new Proxy(e, {
|
|
303
295
|
get(n, o) {
|
|
304
|
-
if (o ===
|
|
296
|
+
if (o === Se) return r;
|
|
305
297
|
if (typeof o != "symbol")
|
|
306
|
-
return
|
|
298
|
+
return Ee([...r, String(o)]);
|
|
307
299
|
},
|
|
308
300
|
apply() {
|
|
309
301
|
throw new Error(
|
|
310
|
-
`[yoltra] A typed path accessor called a method (near "${
|
|
302
|
+
`[yoltra] A typed path accessor called a method (near "${r.join(".")}"). The accessor must be a plain member chain like \`p => p.items[0].title\` — it cannot call functions such as \`.map()\` or \`.toString()\`. Compute derived values in the component or a selector, or use the \`{ reducer, property }\` string form.`
|
|
311
303
|
);
|
|
312
304
|
}
|
|
313
305
|
});
|
|
314
306
|
}
|
|
315
|
-
function
|
|
316
|
-
const e =
|
|
317
|
-
return s === "" &&
|
|
307
|
+
function Oe(r) {
|
|
308
|
+
const e = r(Ee([])), n = e?.[Se], s = (Array.isArray(n) ? n : []).join(".");
|
|
309
|
+
return s === "" && ke(
|
|
318
310
|
"yoltra.toDottedPath.empty",
|
|
319
311
|
"[yoltra] A typed path accessor recorded no property access, so it subscribed to the slice root. That fires only when the slice's whole value is replaced — which for a slice holding an object means never, since its changes are reported at their leaves. The accessor must be a plain member chain like `p => p.items[0].title` and cannot return a computed value or a default. For a dynamic subscription, or for a slice whose state is a single value, use the `{ reducer, property }` string form instead."
|
|
320
312
|
), s;
|
|
321
313
|
}
|
|
322
|
-
function U(
|
|
323
|
-
if (!e) return
|
|
324
|
-
let n =
|
|
325
|
-
for (const o of
|
|
314
|
+
function U(r, e) {
|
|
315
|
+
if (!e) return r;
|
|
316
|
+
let n = r;
|
|
317
|
+
for (const o of xe(e)) {
|
|
326
318
|
if (n == null) return;
|
|
327
319
|
n = n[o];
|
|
328
320
|
}
|
|
329
321
|
return n;
|
|
330
322
|
}
|
|
331
|
-
function V(
|
|
332
|
-
const o = P(
|
|
333
|
-
o.current =
|
|
323
|
+
function V(r, e, n) {
|
|
324
|
+
const o = P(r);
|
|
325
|
+
o.current = r;
|
|
334
326
|
const s = P(e);
|
|
335
327
|
s.current = e;
|
|
336
|
-
const c =
|
|
328
|
+
const c = E(
|
|
337
329
|
() => ({ has: !1, value: void 0 }),
|
|
338
330
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
339
331
|
n
|
|
340
332
|
);
|
|
341
|
-
return
|
|
333
|
+
return me(() => {
|
|
342
334
|
const u = o.current();
|
|
343
335
|
return (!c.has || !s.current(c.value, u)) && (c.has = !0, c.value = u), c.value;
|
|
344
336
|
}, [c]);
|
|
345
337
|
}
|
|
346
|
-
function
|
|
347
|
-
if (Object.is(
|
|
348
|
-
if (!
|
|
349
|
-
const n = Object.keys(
|
|
338
|
+
function Ne(r, e) {
|
|
339
|
+
if (Object.is(r, e)) return !0;
|
|
340
|
+
if (!r || !e) return !1;
|
|
341
|
+
const n = Object.keys(r), o = Object.keys(e);
|
|
350
342
|
if (n.length !== o.length) return !1;
|
|
351
343
|
for (const s of n)
|
|
352
|
-
if (!Object.is(
|
|
344
|
+
if (!Object.is(r[s], e[s])) return !1;
|
|
353
345
|
return !0;
|
|
354
346
|
}
|
|
355
|
-
function
|
|
356
|
-
const
|
|
357
|
-
if (!
|
|
358
|
-
return
|
|
347
|
+
function q() {
|
|
348
|
+
const r = ve(ye);
|
|
349
|
+
if (!r) throw new Error("useStore must be used inside <StoreProvider>");
|
|
350
|
+
return r;
|
|
359
351
|
}
|
|
360
|
-
function
|
|
361
|
-
return
|
|
352
|
+
function qe() {
|
|
353
|
+
return q().emit;
|
|
362
354
|
}
|
|
363
|
-
function
|
|
364
|
-
const n =
|
|
365
|
-
() =>
|
|
355
|
+
function Je(r, e = Object.is) {
|
|
356
|
+
const n = q(), o = E(() => (c) => n.subscribe(c), [n]), s = V(
|
|
357
|
+
() => r(n.getState()),
|
|
366
358
|
e,
|
|
367
359
|
[n]
|
|
368
360
|
);
|
|
369
361
|
return I(o, s, s);
|
|
370
362
|
}
|
|
371
|
-
function
|
|
372
|
-
const o =
|
|
373
|
-
const
|
|
374
|
-
return { reducer:
|
|
375
|
-
}, [
|
|
376
|
-
() => (
|
|
363
|
+
function Ce(r, e, n = Object.is) {
|
|
364
|
+
const o = q(), s = E(() => {
|
|
365
|
+
const h = x(r.property);
|
|
366
|
+
return { reducer: r.reducer, property: h };
|
|
367
|
+
}, [r.reducer, r.property]), c = E(
|
|
368
|
+
() => (h) => o.connect(
|
|
377
369
|
{ reducer: s.reducer, property: s.property },
|
|
378
|
-
() =>
|
|
370
|
+
() => h()
|
|
379
371
|
),
|
|
380
372
|
[o, s]
|
|
381
|
-
), u = L(s.property),
|
|
373
|
+
), u = L(s.property), d = V(
|
|
382
374
|
() => {
|
|
383
375
|
const _ = o.getState()[s.reducer];
|
|
384
376
|
return u ? _ : U(_, s.property);
|
|
@@ -386,33 +378,31 @@ function Ye(t, e, n = Object.is) {
|
|
|
386
378
|
n,
|
|
387
379
|
[o, s]
|
|
388
380
|
);
|
|
389
|
-
return I(c,
|
|
381
|
+
return I(c, d, d);
|
|
390
382
|
}
|
|
391
|
-
function ee(
|
|
392
|
-
return
|
|
383
|
+
function ee(r, e, n = Object.is) {
|
|
384
|
+
return Ce(r, e, n);
|
|
393
385
|
}
|
|
394
|
-
function
|
|
395
|
-
const s =
|
|
396
|
-
c.current = n,
|
|
397
|
-
|
|
386
|
+
function Be(r, e, n, o = "committed") {
|
|
387
|
+
const s = q(), c = P(n);
|
|
388
|
+
c.current = n, he(() => s.onEvent(
|
|
389
|
+
r,
|
|
398
390
|
e,
|
|
399
|
-
(u,
|
|
400
|
-
c.current(u,
|
|
391
|
+
(u, d, h, _) => {
|
|
392
|
+
c.current(u, d, h, _);
|
|
401
393
|
},
|
|
402
394
|
o
|
|
403
|
-
), [s,
|
|
395
|
+
), [s, r, e, o]);
|
|
404
396
|
}
|
|
405
|
-
function
|
|
406
|
-
return
|
|
397
|
+
function $e(r) {
|
|
398
|
+
return r == null || r <= 0 ? null : Date.now() + r;
|
|
407
399
|
}
|
|
408
|
-
function
|
|
409
|
-
return
|
|
400
|
+
function Ie(r) {
|
|
401
|
+
return r === null ? null : r === void 0 || r <= 0 ? 0 : Date.now() + r;
|
|
410
402
|
}
|
|
411
|
-
const
|
|
412
|
-
class
|
|
413
|
-
|
|
414
|
-
ue(this, "store", /* @__PURE__ */ new Map());
|
|
415
|
-
}
|
|
403
|
+
const Ye = 2e3;
|
|
404
|
+
class De {
|
|
405
|
+
store = /* @__PURE__ */ new Map();
|
|
416
406
|
/**
|
|
417
407
|
* Marks a key as most recently used, and evicts the coldest entries past the cap.
|
|
418
408
|
*
|
|
@@ -428,11 +418,11 @@ class ze {
|
|
|
428
418
|
}
|
|
429
419
|
/** @internal */
|
|
430
420
|
evict() {
|
|
431
|
-
for (; this.store.size >
|
|
421
|
+
for (; this.store.size > Ye; ) {
|
|
432
422
|
const e = this.store.keys().next();
|
|
433
423
|
if (e.done === !0) return;
|
|
434
424
|
const n = this.store.get(e.value);
|
|
435
|
-
if (
|
|
425
|
+
if (n?.status === "pending") {
|
|
436
426
|
this.store.delete(e.value), this.store.set(e.value, n);
|
|
437
427
|
continue;
|
|
438
428
|
}
|
|
@@ -455,16 +445,16 @@ class ze {
|
|
|
455
445
|
if (u.expiresAt === null || u.expiresAt > c) throw u.error;
|
|
456
446
|
this.store.delete(e);
|
|
457
447
|
}
|
|
458
|
-
const
|
|
459
|
-
this.store.set(e, { status: "ready", value:
|
|
460
|
-
}).catch((
|
|
448
|
+
const d = Promise.resolve().then(n).then((h) => {
|
|
449
|
+
this.store.set(e, { status: "ready", value: h, expiresAt: $e(o) });
|
|
450
|
+
}).catch((h) => {
|
|
461
451
|
this.store.set(e, {
|
|
462
452
|
status: "error",
|
|
463
|
-
error:
|
|
464
|
-
expiresAt:
|
|
453
|
+
error: h,
|
|
454
|
+
expiresAt: Ie(s)
|
|
465
455
|
});
|
|
466
456
|
});
|
|
467
|
-
throw this.store.set(e, { status: "pending", promise:
|
|
457
|
+
throw this.store.set(e, { status: "pending", promise: d, expiresAt: null }), this.evict(), d;
|
|
468
458
|
}
|
|
469
459
|
invalidate(e) {
|
|
470
460
|
this.store.delete(e);
|
|
@@ -482,7 +472,7 @@ class ze {
|
|
|
482
472
|
*/
|
|
483
473
|
invalidatePathKey(e) {
|
|
484
474
|
for (const n of this.store.keys())
|
|
485
|
-
|
|
475
|
+
pe(n) === e && this.store.delete(n);
|
|
486
476
|
}
|
|
487
477
|
/**
|
|
488
478
|
* Drops every entry that reads from `reducer`, in any store.
|
|
@@ -497,48 +487,47 @@ class ze {
|
|
|
497
487
|
invalidateReducer(e) {
|
|
498
488
|
const n = `${e}::`;
|
|
499
489
|
for (const o of this.store.keys())
|
|
500
|
-
|
|
490
|
+
pe(o).split("||").some((s) => s.startsWith(n)) && this.store.delete(o);
|
|
501
491
|
}
|
|
502
492
|
clear() {
|
|
503
493
|
this.store.clear();
|
|
504
494
|
}
|
|
505
495
|
}
|
|
506
|
-
const Y = new
|
|
507
|
-
let
|
|
508
|
-
function
|
|
509
|
-
let e =
|
|
510
|
-
return e === void 0 && (e = `s${++
|
|
496
|
+
const Y = new De(), fe = /* @__PURE__ */ new WeakMap();
|
|
497
|
+
let Fe = 0;
|
|
498
|
+
function Ae(r) {
|
|
499
|
+
let e = fe.get(r);
|
|
500
|
+
return e === void 0 && (e = `s${++Fe}`, fe.set(r, e)), e;
|
|
511
501
|
}
|
|
512
|
-
function
|
|
513
|
-
return
|
|
502
|
+
function pe(r) {
|
|
503
|
+
return r.slice(r.indexOf("::") + 2);
|
|
514
504
|
}
|
|
515
|
-
function
|
|
505
|
+
function re(r, e, n) {
|
|
516
506
|
const o = Array.isArray(e) ? e.map(x).sort().join("|") : x(e);
|
|
517
|
-
return n ? `${
|
|
507
|
+
return n ? `${r}::${o}::${n}` : `${r}::${o}`;
|
|
518
508
|
}
|
|
519
|
-
function
|
|
520
|
-
const o =
|
|
509
|
+
function Me(r, e, n) {
|
|
510
|
+
const o = r(), s = e.reducer, c = x(e.property), u = `${Ae(o)}::${re(s, c, n.key)}`, d = E(() => (i) => o.connect({ reducer: s, property: c }, () => {
|
|
521
511
|
Y.invalidate(u), i();
|
|
522
|
-
}), [o, s, c, u]),
|
|
523
|
-
|
|
524
|
-
const _ =
|
|
512
|
+
}), [o, s, c, u]), h = P(n);
|
|
513
|
+
h.current = n;
|
|
514
|
+
const _ = E(() => {
|
|
525
515
|
const i = L(c);
|
|
526
516
|
return () => {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
return Y.read(u, () => h.load(y, l), (b = h.staleTime) != null ? b : 0, h.errorTtlMs);
|
|
517
|
+
const l = o.getState()[s], y = i ? l : U(l, c), m = h.current;
|
|
518
|
+
return Y.read(u, () => m.load(y, l), m.staleTime ?? 0, m.errorTtlMs);
|
|
530
519
|
};
|
|
531
|
-
}, [o, s, c, u]), p =
|
|
520
|
+
}, [o, s, c, u]), p = E(() => {
|
|
532
521
|
const i = L(c);
|
|
533
522
|
return () => {
|
|
534
523
|
const l = o.getState()[s];
|
|
535
524
|
return i ? l : U(l, c);
|
|
536
525
|
};
|
|
537
526
|
}, [o, s, c]);
|
|
538
|
-
return I(
|
|
527
|
+
return I(d, _, p);
|
|
539
528
|
}
|
|
540
|
-
function
|
|
541
|
-
const o =
|
|
529
|
+
function ze(r, e, n) {
|
|
530
|
+
const o = r(), s = E(
|
|
542
531
|
() => e.map((p) => ({
|
|
543
532
|
reducer: p.reducer,
|
|
544
533
|
property: Array.isArray(p.property) ? p.property.map((i) => x(i)) : x(p.property)
|
|
@@ -547,46 +536,45 @@ function Le(t, e, n) {
|
|
|
547
536
|
// signature is intentional and already covers `specs`.
|
|
548
537
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
549
538
|
[JSON.stringify(e)]
|
|
550
|
-
), c =
|
|
551
|
-
const p = s.map((i) =>
|
|
552
|
-
return `${
|
|
553
|
-
}, [o, s, n.key]), u =
|
|
539
|
+
), c = E(() => {
|
|
540
|
+
const p = s.map((i) => re(i.reducer, i.property)).sort().join("||");
|
|
541
|
+
return `${Ae(o)}::${n.key ? `${p}::${n.key}` : p}`;
|
|
542
|
+
}, [o, s, n.key]), u = E(() => (p) => {
|
|
554
543
|
const i = () => {
|
|
555
544
|
Y.invalidate(c), p();
|
|
556
|
-
},
|
|
545
|
+
}, v = s.map((l) => o.connect(l, i));
|
|
557
546
|
return () => {
|
|
558
|
-
for (const l of
|
|
547
|
+
for (const l of v) l();
|
|
559
548
|
};
|
|
560
|
-
}, [o, s, c]),
|
|
561
|
-
|
|
562
|
-
const
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
return Y.read(c, () => i.load(p), (d = i.staleTime) != null ? d : 0, i.errorTtlMs);
|
|
549
|
+
}, [o, s, c]), d = P(n);
|
|
550
|
+
d.current = n;
|
|
551
|
+
const h = E(() => () => {
|
|
552
|
+
const p = o.getState(), i = d.current;
|
|
553
|
+
return Y.read(c, () => i.load(p), i.staleTime ?? 0, i.errorTtlMs);
|
|
566
554
|
}, [o, c]);
|
|
567
|
-
return I(u,
|
|
568
|
-
const p =
|
|
555
|
+
return I(u, h, () => {
|
|
556
|
+
const p = d.current.load(o.getState());
|
|
569
557
|
return p instanceof Promise ? void 0 : p;
|
|
570
558
|
});
|
|
571
559
|
}
|
|
572
|
-
function
|
|
573
|
-
Y.invalidatePathKey(
|
|
560
|
+
function Xe(r, e, n) {
|
|
561
|
+
Y.invalidatePathKey(re(r, e, n));
|
|
574
562
|
}
|
|
575
|
-
function
|
|
576
|
-
Y.invalidateReducer(
|
|
563
|
+
function He(r) {
|
|
564
|
+
Y.invalidateReducer(r);
|
|
577
565
|
}
|
|
578
|
-
function
|
|
566
|
+
function Ze() {
|
|
579
567
|
Y.clear();
|
|
580
568
|
}
|
|
581
|
-
function
|
|
569
|
+
function We(r) {
|
|
582
570
|
return {
|
|
583
|
-
useSuspenseAtomicProp: (o, s) =>
|
|
584
|
-
useSuspenseAtomicProps: (o, s) =>
|
|
571
|
+
useSuspenseAtomicProp: (o, s) => Me(r, o, s),
|
|
572
|
+
useSuspenseAtomicProps: (o, s) => ze(r, o, s)
|
|
585
573
|
};
|
|
586
574
|
}
|
|
587
|
-
function
|
|
575
|
+
function Ge(r) {
|
|
588
576
|
function e() {
|
|
589
|
-
const i =
|
|
577
|
+
const i = ve(r);
|
|
590
578
|
if (!i)
|
|
591
579
|
throw new Error(
|
|
592
580
|
"[yoltra] No store in context. Wrap your tree in <StoreProvider store={...}>, or use the hooks returned by createYoltra (which default to their own store)."
|
|
@@ -596,121 +584,121 @@ function Ve(t) {
|
|
|
596
584
|
function n() {
|
|
597
585
|
return e().emit;
|
|
598
586
|
}
|
|
599
|
-
function o(i,
|
|
600
|
-
const l = e(), y =
|
|
601
|
-
return I(y,
|
|
587
|
+
function o(i, v = Object.is) {
|
|
588
|
+
const l = e(), y = E(() => (g) => l.subscribe(g), [l]), m = V(() => i(l.getState()), v, [l]);
|
|
589
|
+
return I(y, m, m);
|
|
602
590
|
}
|
|
603
|
-
const c = (i,
|
|
604
|
-
const y = e(),
|
|
591
|
+
const c = (i, v, l) => {
|
|
592
|
+
const y = e(), m = typeof i == "string", g = m ? i : i.reducer, j = m ? Oe(v) : i.property, w = m ? void 0 : v, R = E(() => ({ reducer: g, property: x(j) }), [g, j]), O = E(
|
|
605
593
|
() => ($) => y.connect(
|
|
606
|
-
{ reducer:
|
|
594
|
+
{ reducer: R.reducer, property: R.property },
|
|
607
595
|
() => $()
|
|
608
596
|
),
|
|
609
|
-
[y,
|
|
610
|
-
), D = L(
|
|
597
|
+
[y, R]
|
|
598
|
+
), D = L(R.property), F = V(
|
|
611
599
|
() => {
|
|
612
|
-
const
|
|
600
|
+
const A = y.getState()[R.reducer], N = D ? A : U(A, R.property);
|
|
613
601
|
return w ? w(N) : N;
|
|
614
602
|
},
|
|
615
|
-
l
|
|
616
|
-
[y,
|
|
603
|
+
l ?? Object.is,
|
|
604
|
+
[y, R]
|
|
617
605
|
);
|
|
618
606
|
return I(O, F, F);
|
|
619
|
-
},
|
|
620
|
-
const y = e(),
|
|
621
|
-
|
|
607
|
+
}, d = (i, v, l = Object.is) => {
|
|
608
|
+
const y = e(), m = P(0), g = P(void 0), j = P(-1), w = P(!1), R = P(v);
|
|
609
|
+
R.current = v;
|
|
622
610
|
const O = P(l);
|
|
623
611
|
O.current = l;
|
|
624
|
-
const D =
|
|
625
|
-
reducer:
|
|
626
|
-
property: Array.isArray(
|
|
627
|
-
})), [
|
|
628
|
-
() => (
|
|
612
|
+
const D = E(() => i.map((A) => ({
|
|
613
|
+
reducer: A.reducer,
|
|
614
|
+
property: Array.isArray(A.property) ? A.property.map((N) => x(N)) : x(A.property)
|
|
615
|
+
})), [je(i)]), F = E(
|
|
616
|
+
() => (A) => {
|
|
629
617
|
const N = () => {
|
|
630
|
-
|
|
631
|
-
},
|
|
618
|
+
m.current++, A();
|
|
619
|
+
}, J = D.flatMap((T) => (Array.isArray(T.property) ? T.property : [T.property]).map((X) => y.connect({ reducer: T.reducer, property: X }, N)));
|
|
632
620
|
return () => {
|
|
633
|
-
for (const T of
|
|
621
|
+
for (const T of J) T();
|
|
634
622
|
};
|
|
635
623
|
},
|
|
636
624
|
[y, D]
|
|
637
|
-
), $ =
|
|
638
|
-
if (j.current !==
|
|
639
|
-
const
|
|
640
|
-
(!w.current || !O.current(
|
|
625
|
+
), $ = me(() => {
|
|
626
|
+
if (j.current !== m.current || !w.current) {
|
|
627
|
+
const A = R.current(y.getState());
|
|
628
|
+
(!w.current || !O.current(g.current, A)) && (g.current = A, w.current = !0), j.current = m.current;
|
|
641
629
|
}
|
|
642
|
-
return
|
|
630
|
+
return g.current;
|
|
643
631
|
}, [y]);
|
|
644
632
|
return I(F, $, $);
|
|
645
|
-
},
|
|
646
|
-
const
|
|
647
|
-
|
|
633
|
+
}, h = (i, v, l, y = "committed") => {
|
|
634
|
+
const m = e(), g = P(l);
|
|
635
|
+
g.current = l, he(() => m.onEvent(
|
|
648
636
|
i,
|
|
649
|
-
|
|
650
|
-
(j, w,
|
|
651
|
-
|
|
637
|
+
v,
|
|
638
|
+
(j, w, R, O) => {
|
|
639
|
+
g.current(
|
|
652
640
|
j,
|
|
653
641
|
w,
|
|
654
|
-
|
|
642
|
+
R,
|
|
655
643
|
O
|
|
656
644
|
);
|
|
657
645
|
},
|
|
658
646
|
y
|
|
659
|
-
), [
|
|
660
|
-
}, { useSuspenseAtomicProp: _, useSuspenseAtomicProps: p } =
|
|
647
|
+
), [m, i, v, y]);
|
|
648
|
+
}, { useSuspenseAtomicProp: _, useSuspenseAtomicProps: p } = We(e);
|
|
661
649
|
return {
|
|
662
650
|
useStore: e,
|
|
663
651
|
useEmit: n,
|
|
664
652
|
useSelector: o,
|
|
665
653
|
useAtomicProp: c,
|
|
666
|
-
useAtomicProps:
|
|
667
|
-
useEvent:
|
|
654
|
+
useAtomicProps: d,
|
|
655
|
+
useEvent: h,
|
|
668
656
|
useSuspenseAtomicProp: _,
|
|
669
657
|
useSuspenseAtomicProps: p,
|
|
670
|
-
shallowEqual:
|
|
658
|
+
shallowEqual: Ne
|
|
671
659
|
};
|
|
672
660
|
}
|
|
673
|
-
function
|
|
674
|
-
const e =
|
|
661
|
+
function Ke(r) {
|
|
662
|
+
const e = Pe(r), n = de(e), o = Ge(n);
|
|
675
663
|
return { store: e, StoreContext: n, StoreProvider: ({
|
|
676
664
|
store: c,
|
|
677
665
|
children: u
|
|
678
|
-
}) => /* @__PURE__ */
|
|
666
|
+
}) => /* @__PURE__ */ be.jsx(n.Provider, { value: c ?? e, children: u }), ...o };
|
|
679
667
|
}
|
|
680
|
-
function
|
|
668
|
+
function Qe(r, e) {
|
|
681
669
|
return ee({
|
|
682
|
-
reducer:
|
|
670
|
+
reducer: r,
|
|
683
671
|
property: e.idsPath
|
|
684
672
|
});
|
|
685
673
|
}
|
|
686
|
-
function
|
|
674
|
+
function er(r, e, n) {
|
|
687
675
|
return ee({
|
|
688
|
-
reducer:
|
|
676
|
+
reducer: r,
|
|
689
677
|
property: e.pathTo(n)
|
|
690
678
|
});
|
|
691
679
|
}
|
|
692
|
-
function
|
|
680
|
+
function rr(r, e, n, o) {
|
|
693
681
|
return ee({
|
|
694
|
-
reducer:
|
|
682
|
+
reducer: r,
|
|
695
683
|
property: e.pathTo(n, o)
|
|
696
684
|
});
|
|
697
685
|
}
|
|
698
686
|
export {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
687
|
+
ye as StoreContext,
|
|
688
|
+
Ve as StoreProvider,
|
|
689
|
+
Ze as clearSuspenseCache,
|
|
690
|
+
Ge as createHooks,
|
|
691
|
+
Ke as createYoltra,
|
|
692
|
+
Xe as invalidateAtomicProp,
|
|
693
|
+
He as invalidateAtomicPropsByReducer,
|
|
694
|
+
Ne as shallowEqual,
|
|
707
695
|
Y as suspenseCache,
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
696
|
+
qe as useEmit,
|
|
697
|
+
er as useEntity,
|
|
698
|
+
rr as useEntityField,
|
|
699
|
+
Qe as useEntityIds,
|
|
700
|
+
Be as useEvent,
|
|
701
|
+
Je as useSelector,
|
|
702
|
+
q as useStore
|
|
715
703
|
};
|
|
716
704
|
//# sourceMappingURL=index.mjs.map
|