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