@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/dist/index.mjs CHANGED
@@ -1,33 +1,25 @@
1
1
  /*!
2
- * @yoltra/react v0.6.0
2
+ * @yoltra/react v0.7.0
3
3
  * (c) 2026 Manu Ramirez <@pixerael>
4
- * License: MIT
5
- * Homepage: https://yoltra.dev
6
- *
7
- * This source code is licensed under the MIT license found in the
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 ae;
18
- function ke() {
19
- if (ae) return z;
20
- ae = 1;
21
- var t = /* @__PURE__ */ Symbol.for("react.transitional.element"), e = /* @__PURE__ */ Symbol.for("react.fragment");
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 m in s)
27
- m !== "key" && (c[m] = s[m]);
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: t,
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 ie;
41
- function xe() {
42
- return ie || (ie = 1, process.env.NODE_ENV !== "production" && (function() {
43
- function t(r) {
44
- if (r == null) return null;
45
- if (typeof r == "function")
46
- return r.$$typeof === B ? null : r.displayName || r.name || null;
47
- if (typeof r == "string") return r;
48
- switch (r) {
49
- case h:
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 b:
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 r == "object")
63
- switch (typeof r.tag == "number" && console.error(
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
- ), r.$$typeof) {
57
+ ), t.$$typeof) {
66
58
  case y:
67
59
  return "Portal";
68
- case g:
69
- return (r.displayName || "Context") + ".Provider";
60
+ case R:
61
+ return (t.displayName || "Context") + ".Provider";
70
62
  case w:
71
- return (r._context.displayName || "Context") + ".Consumer";
63
+ return (t._context.displayName || "Context") + ".Consumer";
72
64
  case O:
73
- var a = r.render;
74
- return r = r.displayName, r || (r = a.displayName || a.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
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 = r.displayName || null, a !== null ? a : t(r.type) || "Memo";
77
- case R:
78
- a = r._payload, r = r._init;
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(r(a));
72
+ return r(t(a));
81
73
  } catch {
82
74
  }
83
75
  }
84
76
  return null;
85
77
  }
86
- function e(r) {
87
- return "" + r;
78
+ function e(t) {
79
+ return "" + t;
88
80
  }
89
- function n(r) {
81
+ function n(t) {
90
82
  try {
91
- e(r);
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, S = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
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
- S
103
- ), e(r);
94
+ b
95
+ ), e(t);
104
96
  }
105
97
  }
106
- function o(r) {
107
- if (r === h) return "<>";
108
- if (typeof r == "object" && r !== null && r.$$typeof === R)
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(r);
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 r = T.A;
119
- return r === null ? null : r.getOwner();
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(r) {
125
- if (X.call(r, "key")) {
126
- var a = Object.getOwnPropertyDescriptor(r, "key").get;
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 r.key !== void 0;
121
+ return t.key !== void 0;
130
122
  }
131
- function m(r, a) {
123
+ function d(t, a) {
132
124
  function f() {
133
- re || (re = !0, console.error(
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(r, "key", {
130
+ f.isReactWarning = !0, Object.defineProperty(t, "key", {
139
131
  get: f,
140
132
  configurable: !0
141
133
  });
142
134
  }
143
- function v() {
144
- var r = t(this.type);
145
- return ne[r] || (ne[r] = !0, console.error(
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
- )), r = this.props.ref, r !== void 0 ? r : null;
139
+ )), t = this.props.ref, t !== void 0 ? t : null;
148
140
  }
149
- function _(r, a, f, S, C, k, Z, K) {
150
- return f = k.ref, r = {
141
+ function _(t, a, f, b, C, k, Z, K) {
142
+ return f = k.ref, t = {
151
143
  $$typeof: l,
152
- type: r,
144
+ type: t,
153
145
  key: a,
154
146
  props: k,
155
147
  _owner: C
156
- }, (f !== void 0 ? f : null) !== null ? Object.defineProperty(r, "ref", {
148
+ }, (f !== void 0 ? f : null) !== null ? Object.defineProperty(t, "ref", {
157
149
  enumerable: !1,
158
- get: v
159
- }) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
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(r, "_debugInfo", {
156
+ }), Object.defineProperty(t, "_debugInfo", {
165
157
  configurable: !1,
166
158
  enumerable: !1,
167
159
  writable: !0,
168
160
  value: null
169
- }), Object.defineProperty(r, "_debugStack", {
161
+ }), Object.defineProperty(t, "_debugStack", {
170
162
  configurable: !1,
171
163
  enumerable: !1,
172
164
  writable: !0,
173
165
  value: Z
174
- }), Object.defineProperty(r, "_debugTask", {
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(r.props), Object.freeze(r)), r;
171
+ }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
180
172
  }
181
- function p(r, a, f, S, C, k, Z, K) {
182
- var E = a.children;
183
- if (E !== void 0)
184
- if (S)
185
- if (q(E)) {
186
- for (S = 0; S < E.length; S++)
187
- i(E[S]);
188
- Object.freeze && Object.freeze(E);
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(E);
194
- if (X.call(a, "key")) {
195
- E = t(r);
196
- var M = Object.keys(a).filter(function(ge) {
197
- return ge !== "key";
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
- S = 0 < M.length ? "{key: someKey, " + M.join(": ..., ") + ": ...}" : "{key: someKey}", ce[E + S] || (M = 0 < M.length ? "{" + M.join(": ..., ") + ": ...}" : "{}", console.error(
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
- E
210
- ), ce[E + S] = !0);
201
+ S
202
+ ), ce[S + b] = !0);
211
203
  }
212
- if (E = null, f !== void 0 && (n(f), E = "" + f), u(a) && (n(a.key), E = "" + a.key), "key" in a) {
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 E && m(
209
+ return S && d(
218
210
  f,
219
- typeof r == "function" ? r.displayName || r.name || "Unknown" : r
211
+ typeof t == "function" ? t.displayName || t.name || "Unknown" : t
220
212
  ), _(
221
- r,
222
- E,
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(r) {
232
- typeof r == "object" && r !== null && r.$$typeof === l && r._store && (r._store.validated = 1);
223
+ function i(t) {
224
+ typeof t == "object" && t !== null && t.$$typeof === l && t._store && (t._store.validated = 1);
233
225
  }
234
- var d = we, l = /* @__PURE__ */ Symbol.for("react.transitional.element"), y = /* @__PURE__ */ Symbol.for("react.portal"), h = /* @__PURE__ */ Symbol.for("react.fragment"), b = /* @__PURE__ */ Symbol.for("react.strict_mode"), j = /* @__PURE__ */ Symbol.for("react.profiler"), w = /* @__PURE__ */ Symbol.for("react.consumer"), g = /* @__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"), R = /* @__PURE__ */ Symbol.for("react.lazy"), N = /* @__PURE__ */ Symbol.for("react.activity"), B = /* @__PURE__ */ Symbol.for("react.client.reference"), T = d.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, X = Object.prototype.hasOwnProperty, q = Array.isArray, H = console.createTask ? console.createTask : function() {
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
- d = {
238
- react_stack_bottom_frame: function(r) {
239
- return r();
229
+ v = {
230
+ react_stack_bottom_frame: function(t) {
231
+ return t();
240
232
  }
241
233
  };
242
- var re, ne = {}, oe = d.react_stack_bottom_frame.bind(
243
- d,
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 = h, W.jsx = function(r, a, f, S, C) {
238
+ W.Fragment = m, W.jsx = function(t, a, f, b, C) {
247
239
  var k = 1e4 > T.recentlyCreatedOwnerStacks++;
248
240
  return p(
249
- r,
241
+ t,
250
242
  a,
251
243
  f,
252
244
  !1,
253
- S,
245
+ b,
254
246
  C,
255
247
  k ? Error("react-stack-top-frame") : oe,
256
- k ? H(o(r)) : se
248
+ k ? H(o(t)) : se
257
249
  );
258
- }, W.jsxs = function(r, a, f, S, C) {
250
+ }, W.jsxs = function(t, a, f, b, C) {
259
251
  var k = 1e4 > T.recentlyCreatedOwnerStacks++;
260
252
  return p(
261
- r,
253
+ t,
262
254
  a,
263
255
  f,
264
256
  !0,
265
- S,
257
+ b,
266
258
  C,
267
259
  k ? Error("react-stack-top-frame") : oe,
268
- k ? H(o(r)) : se
260
+ k ? H(o(t)) : se
269
261
  );
270
262
  };
271
263
  })()), W;
272
264
  }
273
- var le;
274
- function je() {
275
- return le || (le = 1, process.env.NODE_ENV === "production" ? G.exports = ke() : G.exports = xe()), G.exports;
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 Se = je();
278
- const qe = ({ store: t, children: e }) => /* @__PURE__ */ Se.jsx(be.Provider, { value: t, children: e }), fe = /* @__PURE__ */ new Set();
279
- function Oe(t, e) {
280
- process.env.NODE_ENV !== "production" && (fe.has(t) || (fe.add(t), console.warn(e)));
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(t) {
283
- return t.includes("*");
274
+ function L(r) {
275
+ return r.includes("*");
284
276
  }
285
- function x(t) {
286
- return t.replace(/^\./, "");
277
+ function x(r) {
278
+ return r.replace(/^\./, "");
287
279
  }
288
- function Ne(t) {
289
- return x(t).split(".").filter(Boolean);
280
+ function xe(r) {
281
+ return x(r).split(".").filter(Boolean);
290
282
  }
291
- function Ce(t) {
283
+ function je(r) {
292
284
  const e = (n) => `${n.length}:${n}`;
293
- return t.map((n) => {
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 Ee = /* @__PURE__ */ Symbol("yoltra.pathSegments");
299
- function Ae(t) {
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 === Ee) return t;
296
+ if (o === Se) return r;
305
297
  if (typeof o != "symbol")
306
- return Ae([...t, String(o)]);
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 "${t.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.`
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 $e(t) {
316
- const e = t(Ae([])), n = e != null ? e[Ee] : void 0, s = (Array.isArray(n) ? n : []).join(".");
317
- return s === "" && Oe(
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(t, e) {
323
- if (!e) return t;
324
- let n = t;
325
- for (const o of Ne(e)) {
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(t, e, n) {
332
- const o = P(t);
333
- o.current = t;
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 = A(
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 he(() => {
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 Ie(t, e) {
347
- if (Object.is(t, e)) return !0;
348
- if (!t || !e) return !1;
349
- const n = Object.keys(t), o = Object.keys(e);
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(t[s], e[s])) return !1;
344
+ if (!Object.is(r[s], e[s])) return !1;
353
345
  return !0;
354
346
  }
355
- function J() {
356
- const t = ye(be);
357
- if (!t) throw new Error("useStore must be used inside <StoreProvider>");
358
- return t;
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 He() {
361
- return J().emit;
352
+ function qe() {
353
+ return q().emit;
362
354
  }
363
- function Ze(t, e = Object.is) {
364
- const n = J(), o = A(() => (c) => n.subscribe(c), [n]), s = V(
365
- () => t(n.getState()),
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 Ye(t, e, n = Object.is) {
372
- const o = J(), s = A(() => {
373
- const v = x(t.property);
374
- return { reducer: t.reducer, property: v };
375
- }, [t.reducer, t.property]), c = A(
376
- () => (v) => o.connect(
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
- () => v()
370
+ () => h()
379
371
  ),
380
372
  [o, s]
381
- ), u = L(s.property), m = V(
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, m, m);
381
+ return I(c, d, d);
390
382
  }
391
- function ee(t, e, n = Object.is) {
392
- return Ye(t, e, n);
383
+ function ee(r, e, n = Object.is) {
384
+ return Ce(r, e, n);
393
385
  }
394
- function Ke(t, e, n, o = "committed") {
395
- const s = J(), c = P(n);
396
- c.current = n, ve(() => s.onEvent(
397
- t,
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, m, v, _) => {
400
- c.current(u, m, v, _);
391
+ (u, d, h, _) => {
392
+ c.current(u, d, h, _);
401
393
  },
402
394
  o
403
- ), [s, t, e, o]);
395
+ ), [s, r, e, o]);
404
396
  }
405
- function De(t) {
406
- return t == null || t <= 0 ? null : Date.now() + t;
397
+ function $e(r) {
398
+ return r == null || r <= 0 ? null : Date.now() + r;
407
399
  }
408
- function Fe(t) {
409
- return t === null ? null : t === void 0 || t <= 0 ? 0 : Date.now() + t;
400
+ function Ie(r) {
401
+ return r === null ? null : r === void 0 || r <= 0 ? 0 : Date.now() + r;
410
402
  }
411
- const Me = 2e3;
412
- class ze {
413
- constructor() {
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 > Me; ) {
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 ((n == null ? void 0 : n.status) === "pending") {
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 m = Promise.resolve().then(n).then((v) => {
459
- this.store.set(e, { status: "ready", value: v, expiresAt: De(o) });
460
- }).catch((v) => {
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: v,
464
- expiresAt: Fe(s)
453
+ error: h,
454
+ expiresAt: Ie(s)
465
455
  });
466
456
  });
467
- throw this.store.set(e, { status: "pending", promise: m, expiresAt: null }), this.evict(), m;
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
- de(n) === e && this.store.delete(n);
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
- de(o).split("||").some((s) => s.startsWith(n)) && this.store.delete(o);
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 ze(), pe = /* @__PURE__ */ new WeakMap();
507
- let We = 0;
508
- function Re(t) {
509
- let e = pe.get(t);
510
- return e === void 0 && (e = `s${++We}`, pe.set(t, e)), e;
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 de(t) {
513
- return t.slice(t.indexOf("::") + 2);
502
+ function pe(r) {
503
+ return r.slice(r.indexOf("::") + 2);
514
504
  }
515
- function te(t, e, n) {
505
+ function re(r, e, n) {
516
506
  const o = Array.isArray(e) ? e.map(x).sort().join("|") : x(e);
517
- return n ? `${t}::${o}::${n}` : `${t}::${o}`;
507
+ return n ? `${r}::${o}::${n}` : `${r}::${o}`;
518
508
  }
519
- function Ge(t, e, n) {
520
- const o = t(), s = e.reducer, c = x(e.property), u = `${Re(o)}::${te(s, c, n.key)}`, m = A(() => (i) => o.connect({ reducer: s, property: c }, () => {
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]), v = P(n);
523
- v.current = n;
524
- const _ = A(() => {
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
- var b;
528
- const l = o.getState()[s], y = i ? l : U(l, c), h = v.current;
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 = A(() => {
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(m, _, p);
527
+ return I(d, _, p);
539
528
  }
540
- function Le(t, e, n) {
541
- const o = t(), s = A(
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 = A(() => {
551
- const p = s.map((i) => te(i.reducer, i.property)).sort().join("||");
552
- return `${Re(o)}::${n.key ? `${p}::${n.key}` : p}`;
553
- }, [o, s, n.key]), u = A(() => (p) => {
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
- }, d = s.map((l) => o.connect(l, i));
545
+ }, v = s.map((l) => o.connect(l, i));
557
546
  return () => {
558
- for (const l of d) l();
547
+ for (const l of v) l();
559
548
  };
560
- }, [o, s, c]), m = P(n);
561
- m.current = n;
562
- const v = A(() => () => {
563
- var d;
564
- const p = o.getState(), i = m.current;
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, v, () => {
568
- const p = m.current.load(o.getState());
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 Qe(t, e, n) {
573
- Y.invalidatePathKey(te(t, e, n));
560
+ function Xe(r, e, n) {
561
+ Y.invalidatePathKey(re(r, e, n));
574
562
  }
575
- function et(t) {
576
- Y.invalidateReducer(t);
563
+ function He(r) {
564
+ Y.invalidateReducer(r);
577
565
  }
578
- function tt() {
566
+ function Ze() {
579
567
  Y.clear();
580
568
  }
581
- function Ue(t) {
569
+ function We(r) {
582
570
  return {
583
- useSuspenseAtomicProp: (o, s) => Ge(t, o, s),
584
- useSuspenseAtomicProps: (o, s) => Le(t, o, s)
571
+ useSuspenseAtomicProp: (o, s) => Me(r, o, s),
572
+ useSuspenseAtomicProps: (o, s) => ze(r, o, s)
585
573
  };
586
574
  }
587
- function Ve(t) {
575
+ function Ge(r) {
588
576
  function e() {
589
- const i = ye(t);
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, d = Object.is) {
600
- const l = e(), y = A(() => (b) => l.subscribe(b), [l]), h = V(() => i(l.getState()), d, [l]);
601
- return I(y, h, h);
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, d, l) => {
604
- const y = e(), h = typeof i == "string", b = h ? i : i.reducer, j = h ? $e(d) : i.property, w = h ? void 0 : d, g = A(() => ({ reducer: b, property: x(j) }), [b, j]), O = A(
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: g.reducer, property: g.property },
594
+ { reducer: R.reducer, property: R.property },
607
595
  () => $()
608
596
  ),
609
- [y, g]
610
- ), D = L(g.property), F = V(
597
+ [y, R]
598
+ ), D = L(R.property), F = V(
611
599
  () => {
612
- const R = y.getState()[g.reducer], N = D ? R : U(R, g.property);
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 != null ? l : Object.is,
616
- [y, g]
603
+ l ?? Object.is,
604
+ [y, R]
617
605
  );
618
606
  return I(O, F, F);
619
- }, m = (i, d, l = Object.is) => {
620
- const y = e(), h = P(0), b = P(void 0), j = P(-1), w = P(!1), g = P(d);
621
- g.current = d;
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 = A(() => i.map((R) => ({
625
- reducer: R.reducer,
626
- property: Array.isArray(R.property) ? R.property.map((N) => x(N)) : x(R.property)
627
- })), [Ce(i)]), F = A(
628
- () => (R) => {
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
- h.current++, R();
631
- }, B = D.flatMap((T) => (Array.isArray(T.property) ? T.property : [T.property]).map((q) => y.connect({ reducer: T.reducer, property: q }, N)));
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 B) T();
621
+ for (const T of J) T();
634
622
  };
635
623
  },
636
624
  [y, D]
637
- ), $ = he(() => {
638
- if (j.current !== h.current || !w.current) {
639
- const R = g.current(y.getState());
640
- (!w.current || !O.current(b.current, R)) && (b.current = R, w.current = !0), j.current = h.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 b.current;
630
+ return g.current;
643
631
  }, [y]);
644
632
  return I(F, $, $);
645
- }, v = (i, d, l, y = "committed") => {
646
- const h = e(), b = P(l);
647
- b.current = l, ve(() => h.onEvent(
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
- d,
650
- (j, w, g, O) => {
651
- b.current(
637
+ v,
638
+ (j, w, R, O) => {
639
+ g.current(
652
640
  j,
653
641
  w,
654
- g,
642
+ R,
655
643
  O
656
644
  );
657
645
  },
658
646
  y
659
- ), [h, i, d, y]);
660
- }, { useSuspenseAtomicProp: _, useSuspenseAtomicProps: p } = Ue(e);
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: m,
667
- useEvent: v,
654
+ useAtomicProps: d,
655
+ useEvent: h,
668
656
  useSuspenseAtomicProp: _,
669
657
  useSuspenseAtomicProps: p,
670
- shallowEqual: Ie
658
+ shallowEqual: Ne
671
659
  };
672
660
  }
673
- function rt(t) {
674
- const e = Te(t), n = me(e), o = Ve(n);
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__ */ Se.jsx(n.Provider, { value: c != null ? c : e, children: u }), ...o };
666
+ }) => /* @__PURE__ */ be.jsx(n.Provider, { value: c ?? e, children: u }), ...o };
679
667
  }
680
- function nt(t, e) {
668
+ function Qe(r, e) {
681
669
  return ee({
682
- reducer: t,
670
+ reducer: r,
683
671
  property: e.idsPath
684
672
  });
685
673
  }
686
- function ot(t, e, n) {
674
+ function er(r, e, n) {
687
675
  return ee({
688
- reducer: t,
676
+ reducer: r,
689
677
  property: e.pathTo(n)
690
678
  });
691
679
  }
692
- function st(t, e, n, o) {
680
+ function rr(r, e, n, o) {
693
681
  return ee({
694
- reducer: t,
682
+ reducer: r,
695
683
  property: e.pathTo(n, o)
696
684
  });
697
685
  }
698
686
  export {
699
- be as StoreContext,
700
- qe as StoreProvider,
701
- tt as clearSuspenseCache,
702
- Ve as createHooks,
703
- rt as createYoltra,
704
- Qe as invalidateAtomicProp,
705
- et as invalidateAtomicPropsByReducer,
706
- Ie as shallowEqual,
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
- He as useEmit,
709
- ot as useEntity,
710
- st as useEntityField,
711
- nt as useEntityIds,
712
- Ke as useEvent,
713
- Ze as useSelector,
714
- J as useStore
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