reflex-quant 1.3.0 → 1.3.1

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.md CHANGED
@@ -28,12 +28,12 @@ workload set, not a claim that Quant wins every benchmark. The separate
28
28
  [project CI suite](#performance) measures Quant 1.2.0.
29
29
 
30
30
  ```ts
31
- import { signal, computed, effect, get, set } from "reflex-quant";
31
+ import { signal, computed, effect, read, set } from "reflex-quant";
32
32
 
33
33
  const count = signal(0);
34
- const doubled = computed(() => get(count) * 2);
34
+ const doubled = computed(() => read(count) * 2);
35
35
 
36
- effect(() => console.log(`count=${get(count)} doubled=${get(doubled)}`));
36
+ effect(() => console.log(`count=${read(count)} doubled=${read(doubled)}`));
37
37
  // count=0 doubled=0
38
38
 
39
39
  set(count, 1); // count=1 doubled=2
@@ -78,11 +78,11 @@ ESM and CommonJS builds are included, along with type declarations. It needs Nod
78
78
  ### 1. Signals hold values
79
79
 
80
80
  ```ts
81
- import { signal, get, set, update } from "reflex-quant";
81
+ import { signal, read, set, update } from "reflex-quant";
82
82
 
83
83
  const name = signal("Ada");
84
84
 
85
- get(name); // "Ada"
85
+ read(name); // "Ada"
86
86
  set(name, "Grace"); // replace
87
87
  update(name, (n) => n.toUpperCase()); // derive from current: "GRACE"
88
88
  ```
@@ -99,14 +99,14 @@ const qty = signal(2);
99
99
  let runs = 0;
100
100
  const total = computed(() => {
101
101
  runs++;
102
- return get(price) * get(qty);
102
+ return read(price) * read(qty);
103
103
  });
104
104
 
105
105
  set(qty, 3);
106
106
  set(qty, 5); // runs === 0: nobody asked yet
107
107
 
108
- get(total); // 20, runs === 1
109
- get(total); // 20, runs === 1: cached
108
+ read(total); // 20, runs === 1
109
+ read(total); // 20, runs === 1: cached
110
110
  ```
111
111
 
112
112
  ### 3. Effects react to changes
@@ -121,7 +121,7 @@ import { effect, dispose } from "reflex-quant";
121
121
  const room = signal("general");
122
122
 
123
123
  const chat = effect(() => {
124
- const r = get(room);
124
+ const r = read(room);
125
125
  console.log("join", r);
126
126
  return () => console.log("leave", r);
127
127
  });
@@ -146,10 +146,10 @@ const first = signal("Ada");
146
146
  const last = signal("Lovelace");
147
147
 
148
148
  const displayName = computed(() =>
149
- get(showFull) ? `${get(first)} ${get(last)}` : get(first),
149
+ read(showFull) ? `${read(first)} ${read(last)}` : read(first),
150
150
  );
151
151
 
152
- effect(() => console.log(get(displayName))); // "Ada"
152
+ effect(() => console.log(read(displayName))); // "Ada"
153
153
 
154
154
  set(last, "Byron"); // (nothing: `last` isn't being read right now)
155
155
  set(showFull, true); // "Ada Byron"
@@ -165,10 +165,10 @@ never sees a half-updated state:
165
165
  ```ts
166
166
  const first = signal("Ada");
167
167
  const last = signal("Lovelace");
168
- const upper = computed(() => get(first).toUpperCase());
169
- const initials = computed(() => get(first)[0] + get(last)[0]);
168
+ const upper = computed(() => read(first).toUpperCase());
169
+ const initials = computed(() => read(first)[0] + read(last)[0]);
170
170
 
171
- effect(() => console.log(`${get(upper)} (${get(initials)})`));
171
+ effect(() => console.log(`${read(upper)} (${read(initials)})`));
172
172
  // ADA (AL)
173
173
 
174
174
  set(first, "Grace");
@@ -182,9 +182,9 @@ put:
182
182
 
183
183
  ```ts
184
184
  const n = signal(1);
185
- const parity = computed(() => (get(n) % 2 === 0 ? "even" : "odd"));
185
+ const parity = computed(() => (read(n) % 2 === 0 ? "even" : "odd"));
186
186
 
187
- effect(() => console.log(get(parity))); // "odd"
187
+ effect(() => console.log(read(parity))); // "odd"
188
188
 
189
189
  set(n, 3); // (nothing: still "odd")
190
190
  set(n, 4); // "even"
@@ -199,7 +199,7 @@ import { batch } from "reflex-quant";
199
199
 
200
200
  const x = signal(0);
201
201
  const y = signal(0);
202
- effect(() => console.log(`(${get(x)}, ${get(y)})`)); // (0, 0)
202
+ effect(() => console.log(`(${read(x)}, ${read(y)})`)); // (0, 0)
203
203
 
204
204
  batch(() => {
205
205
  set(x, 10);
@@ -218,7 +218,7 @@ import { peek, untracked } from "reflex-quant";
218
218
  const query = signal("cats");
219
219
  const page = signal(1);
220
220
 
221
- effect(() => console.log(`search "${get(query)}" page ${peek(page)}`));
221
+ effect(() => console.log(`search "${read(query)}" page ${peek(page)}`));
222
222
  // search "cats" page 1
223
223
 
224
224
  set(page, 2); // (nothing: page was only peeked)
@@ -240,11 +240,11 @@ const items = signal([
240
240
  const discount = signal(0);
241
241
 
242
242
  const subtotal = computed(() =>
243
- get(items).reduce((sum, i) => sum + i.price * i.qty, 0),
243
+ read(items).reduce((sum, i) => sum + i.price * i.qty, 0),
244
244
  );
245
- const total = computed(() => get(subtotal) * (1 - get(discount)));
245
+ const total = computed(() => read(subtotal) * (1 - read(discount)));
246
246
 
247
- effect(() => console.log(`Total: $${get(total).toFixed(2)}`));
247
+ effect(() => console.log(`Total: $${read(total).toFixed(2)}`));
248
248
  // Total: $11.00
249
249
 
250
250
  update(items, (list) => [...list, { name: "Juice", price: 5, qty: 1 }]);
@@ -267,14 +267,14 @@ const todos = signal([
267
267
  const filter = signal<"all" | "open" | "done">("all");
268
268
 
269
269
  const visible = computed(() => {
270
- const f = get(filter);
271
- if (f === "all") return get(todos);
272
- return get(todos).filter((t) => t.done === (f === "done"));
270
+ const f = read(filter);
271
+ if (f === "all") return read(todos);
272
+ return read(todos).filter((t) => t.done === (f === "done"));
273
273
  });
274
- const left = computed(() => get(todos).filter((t) => !t.done).length);
274
+ const left = computed(() => read(todos).filter((t) => !t.done).length);
275
275
 
276
276
  effect(() =>
277
- console.log(`${get(visible).map((t) => t.text).join(", ")} | ${get(left)} left`),
277
+ console.log(`${read(visible).map((t) => t.text).join(", ")} | ${read(left)} left`),
278
278
  );
279
279
  // Write README, Ship 1.2.0 | 1 left
280
280
 
@@ -294,7 +294,7 @@ update(todos, (list) => list.map((t) => ({ ...t, done: true })));
294
294
  const query = signal("");
295
295
 
296
296
  effect(() => {
297
- const q = get(query);
297
+ const q = read(query);
298
298
  const id = setTimeout(() => fetchResults(q), 300);
299
299
  return () => clearTimeout(id); // a new keystroke cancels the previous timer
300
300
  });
@@ -316,7 +316,7 @@ const button = document.querySelector("button")!;
316
316
  button.addEventListener("click", () => update(count, (n) => n + 1));
317
317
 
318
318
  effect(() => {
319
- button.textContent = `Clicked ${get(count)} times`;
319
+ button.textContent = `Clicked ${read(count)} times`;
320
320
  });
321
321
  ```
322
322
 
@@ -328,7 +328,7 @@ effect(() => {
328
328
  ```ts
329
329
  const theme = signal(localStorage.getItem("theme") ?? "light");
330
330
 
331
- effect(() => localStorage.setItem("theme", get(theme)));
331
+ effect(() => localStorage.setItem("theme", read(theme)));
332
332
 
333
333
  set(theme, "dark"); // saved
334
334
  ```
@@ -347,12 +347,12 @@ type Cell = { col: number; row: number };
347
347
  const mouse = signal({ x: 0, y: 0 });
348
348
 
349
349
  const cell = computed((prev: Cell | undefined) => {
350
- const { x, y } = get(mouse);
350
+ const { x, y } = read(mouse);
351
351
  const next = { col: Math.floor(x / 100), row: Math.floor(y / 100) };
352
352
  return prev && prev.col === next.col && prev.row === next.row ? prev : next;
353
353
  });
354
354
 
355
- effect(() => console.log(get(cell))); // { col: 0, row: 0 }
355
+ effect(() => console.log(read(cell))); // { col: 0, row: 0 }
356
356
 
357
357
  set(mouse, { x: 10, y: 20 }); // (nothing: same cell)
358
358
  set(mouse, { x: 150, y: 20 }); // { col: 1, row: 0 }
@@ -369,7 +369,9 @@ set(mouse, { x: 150, y: 20 }); // { col: 1, row: 0 }
369
369
  | `signal(value)` | Create a writable value. |
370
370
  | `computed(fn, initial?)` | Create a lazy, cached derived value. `fn(prev)` receives the last committed value. |
371
371
  | `effect(fn)` | Run `fn` now and again on every change it read. `fn` may return a cleanup function. Returns a handle. |
372
- | `get(x)` | Read a signal or computed and **subscribe** the current computation to it. |
372
+ | `read(x)` | Read a signal or computed and **subscribe** the current computation to it. `get(x)` is the same function (its 1.x name). |
373
+ | `readSignal(s)` | `read` for a signal only, without the computed path: faster in loops that read many signals. |
374
+ | `compute(c)` | `read` for a computed only (the same function, narrowed by type). |
373
375
  | `peek(x)` | Read the up-to-date value **without** subscribing. |
374
376
  | `set(s, value)` | Write a signal. Ignored if `Object.is(old, value)`. |
375
377
  | `update(s, fn)` | `set(s, fn(current))`. `fn` runs untracked. If it throws, nothing is written. |
@@ -378,9 +380,19 @@ set(mouse, { x: 150, y: 20 }); // { col: 1, row: 0 }
378
380
  | `dispose(x)` | Stop an effect (running its cleanup) or detach a computed (its last committed value stays readable). |
379
381
  | `typeOf(x)` | `"signal"`, `"computed"` or `"effect"`, without evaluating anything. |
380
382
 
381
- > **Why `get(count)` and not `count()` or `count.value`?** Here the handle *is*
383
+ > **Why `read(count)` and not `count()` or `count.value`?** Here the handle *is*
382
384
  > the reactive node. Quant allocates no wrapper object or getter closure, so
383
385
  > each signal costs one object.
386
+ > Handles are opaque: their fields are internal and can differ between builds.
387
+ > Access values through `read`, `readSignal`, `compute` or `peek`.
388
+ >
389
+ > **Why `readSignal`?** A signal never needs to be brought up to date; a
390
+ > computed may have to run first. `read` serves both, so the computed path is
391
+ > part of every read, and in loops that read many signals the engine pays for
392
+ > it (`track.duplicate-64`, `stable.wide-8`). `readSignal` takes only a
393
+ > `Signal` and has no computed path. Its type keeps computeds out; past the
394
+ > types (plain JS or a cast), development builds throw, and production builds
395
+ > would return a computed's last value without bringing it up to date.
384
396
 
385
397
  ## Good to know
386
398
 
@@ -398,21 +410,33 @@ several writes made before anyone reads collapse into a single run:
398
410
 
399
411
  ```ts
400
412
  const clicks = signal(0);
401
- const history = computed((prev) => [...prev, get(clicks)], [] as number[]);
413
+ const history = computed((prev) => [...prev, read(clicks)], [] as number[]);
402
414
 
403
415
  set(clicks, 1);
404
416
  set(clicks, 2);
405
- get(history); // [2] (1 was never observed)
417
+ read(history); // [2] (1 was never observed)
406
418
  ```
407
419
 
408
420
  If you need every write, append to the log in the code that does the writing,
409
421
  not in a computed.
410
422
 
411
- **Errors don't break the graph.** If a computed throws, `get` rethrows the error
423
+ **Errors don't break the graph.** If a computed throws, `read` rethrows the error
412
424
  and the computed keeps its last good value as `prev`. Once its inputs are fixed,
413
425
  it recovers on the next read. If an effect throws during creation, it leaves
414
426
  nothing running.
415
427
 
428
+ Two edges of error recovery are worth knowing. When a computed throws while an
429
+ effect is checking whether it must rerun, that check stops there. The effect
430
+ does not rerun until another change reaches it, even if a source the check
431
+ never got to changes in the meantime; `read` still returns current values.
432
+ And an effect whose first run throws can run once more before `effect()`
433
+ throws, if that run triggered an update; side effects such as a request are
434
+ not undone by the rollback.
435
+
436
+ **Writes from inside a computation take effect afterwards.** If a callback
437
+ writes a signal while a read is already checking its dependencies, that read
438
+ may still answer from before the write. The next read sees it.
439
+
416
440
  The stack-safety guarantee covers Quant's graph walks: a chain of 100,000
417
441
  computeds is fine. It does not cover callbacks that call each other until
418
442
  the native JavaScript stack runs out. That is a resource failure of the
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- /* reflex-quant 1.3.0 | MIT */
2
- "use strict";var V=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var De=Object.prototype.hasOwnProperty;var Se=(e,n)=>{for(var t in n)V(e,t,{get:n[t],enumerable:!0})},Te=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of _e(n))!De.call(e,l)&&l!==t&&V(e,l,{get:()=>n[l],enumerable:!(o=ve(n,l))||o.enumerable});return e};var Ee=e=>Te(V({},"__esModule",{value:!0}),e);var Ke={};Se(Ke,{batch:()=>ce,computed:()=>Me,dispose:()=>Be,effect:()=>Ie,get:()=>Oe,peek:()=>qe,set:()=>ge,signal:()=>Ve,typeOf:()=>Re,untracked:()=>D,update:()=>Ue});module.exports=Ee(Ke);var v=-1,b=-2,G=-3,X=536870911,N=8,z=2,S=256,h=512;function T(e,n,t){return{flags:t,value:n,ver:0,fn:e,firstDep:null,lastDep:null,firstSub:null,slot:null,gen:0}}function E(e,n,t,o){let l=n.prevDep,r=n.nextDep;l.nextDep=r,r!==null?r.prevDep=l:e.lastDep=l,n.prevDep=t,n.nextDep=o,t!==null?t.nextDep=n:e.firstDep=n,o.prevDep=n}function j(e,n,t,o){let l=t.nextDep,r=e.lastDep;n!==null?n.nextDep=l:e.firstDep=l,l.prevDep=n,t.prevDep=r,t.nextDep=null,r.nextDep=t,e.lastDep=t,r.ver===v&&(t.ver=v),o!==l&&E(e,o,n,l)}function M(e,n){let t=n===null?e.firstDep:n.nextDep;if(t!==null)for(n===null?e.firstDep=null:n.nextDep=null,e.lastDep=n,t.prevDep=null;t!==null;t=t.nextDep)y(t)}function H(e){let n=e.gen;for(let t=e.firstDep;t!==null;t=t.nextDep)t.gen=n}function y(e){let n=e.from,t=e.prevSub,o=e.nextSub;e===n.firstSub?n.firstSub=o:t.nextSub=o,o!==null?o.prevSub=t:n.firstSub!==null&&(n.firstSub.prevSub=t),e.prevSub=null,e.nextSub=null}var Y=Object.is,c=null,f=null,s=new Array(256).fill(null),i=0;var A=()=>{};function Z(e){A=e}function w(){s.length>h&&i===0&&(s.length=S)}function $(e,n){let t=e.value;if(!(t===n?n!==0||1/t===1/n:t!==t&&n!==n)){e.value=n,O(e);for(let o=e.firstSub;o!==null;o=o.nextSub){let l=o.to,r=l.flags;if((r&4)!==0){if((r&1)===0)if(l.flags=r|1,(r&16)!==0)A(l);else{let u=l.firstSub;u!==null&&I(u)}}else if((r&16)!==0)l.flags=r|2|32,A(l);else if((r&1)!==0)l.flags=r|2;else{l.flags=r|2|1;let u=l.firstSub;u!==null&&I(u)}}}}function O(e){let n=e.ver+1&1073741823;n===0&&me(e),e.ver=n}function me(e){for(let n=e.firstSub;n!==null;n=n.nextSub)n.ver>=0&&(n.ver=G)}function I(e){let n=i,t=e;for(;;){for(;t!==null;){let o=t.to,l=o.flags;if((l&16)!==0)o.flags=l|1,A(o);else if((l&1)===0){o.flags=l|1;let r=o.firstSub;if(r!==null){let u=t.nextSub;u!==null&&(s[i++]=u),t=r;continue}}t=t.nextSub}if(i===n){w();return}t=s[--i],s[i]=null}}function F(e){(e.flags&47)!==0&&P(e);let n=c;if(n===null)return e.value;let t=f,o=t===null?n.firstDep:t.nextDep;if(o!==null&&o.from===e)return f=o,o.ver=e.ver,e.value;if(t!==null){if(t.from===e)return e.value;J(n,e,t,o)}else o!==null?J(n,e,t,o):m(n,e,null,null);return e.value}function ee(e){return(e.flags&47)!==0&&P(e),e.value}function P(e){let n=e.flags;if((n&36)!==0)throw new Error("Cycle detected");if((n&2)!==0)return _(e);ke(e,n)}function ke(e,n){e.flags=n&-10;let t=i,o=e,l=e.firstDep;try{for(;;){e:for(;l!==null;){let r=l.from,u=r.flags;if((u&11)===0){if(r.ver===l.ver){l=l.nextDep;continue}}else{if((u&36)!==0)throw new Error("Cycle detected");if((u&2)===0){r.flags=u&-10,s[i++]=l,o=r,l=r.firstDep;continue}if(_(r),r.ver===l.ver){l=l.nextDep;continue}}o.fn!==null&&_(o);break e}for(;;){if(i===t){w();return}let r=s[--i];if(s[i]=null,o=r.to,r.from.ver===r.ver){l=r.nextDep;break}o.fn!==null&&_(o)}}}catch(r){for(;;){if(o.fn!==null){let u=o.flags&-42;o.flags=(u&2)===0?u|8:u}if(i===t)break;o=s[--i].to,s[i]=null}throw w(),r}}function ne(e,n){let t=e.gen+1&1073741823;for(;;){let o=e.firstDep;if((n&2)===0)for(;o!==null;){let l=o.from;if((l.flags&11)===0){if(l.ver===o.ver){o=o.nextDep;continue}}else if(P(l),l.ver===o.ver){o=o.nextDep;continue}e.flags|=2,o=o.nextDep;break}for(;o!==null;){let l=o.from;if((l.flags&11)===0||o.gen===t){o=o.nextDep;continue}P(l),o=o.nextDep}if(e.fn===null)return 0;if(n=e.flags,(n&1)===0)return n;e.flags=n&-2}}function D(e){let n=c;c=null;try{return e()}finally{c=n}}function _(e){let n=c,t=f,o=i;e.flags=e.flags&-44|4,c=e,f=null;let l;try{l=e.fn(e.value)}catch(W){let R=f;throw c=n,f=t,e.flags=e.flags&-5|(e.fn!==null?2:0),Ne(e,o,R),W}let r=f;c=n,f=t;let u=e.flags;if(r!==null&&r.from.slot===r&&le(e,o),e.flags=u&-5,e.fn===null)return be(e,l);(r===null?e.firstDep:r.nextDep)!==null&&M(e,r),e.gen=e.gen+1&1073741823,(e.gen&X)===0&&H(e),Y(l,e.value)===!1&&(e.value=l,O(e))}function be(e,n){q(e),(e.flags&16)===0&&Y(n,e.value)===!1&&(e.value=n,O(e))}function Ne(e,n,t){if(t!==null&&t.from.slot===t&&le(e,n),e.fn===null)return q(e);let o=e.gen+1&1073741823;for(let l=t===null?e.firstDep:t.nextDep;l!==null;){let r=l.nextDep;if(l.gen===o){let u=l.prevDep;u!==null?u.nextDep=r:e.firstDep=r,r!==null?r.prevDep=u:e.lastDep=u,y(l),l.prevDep=null,l.nextDep=null}l=r}}function C(e){e.fn!==null&&(e.fn=null,(e.flags&4)===0&&q(e))}function q(e){if((e.flags&16)===0)M(e,null);else{let n=e.firstDep;for(e.firstDep=e.lastDep=null;n!==null;){let t=n.nextDep;y(n),n.prevDep=n.nextDep=null,n=t}}e.flags&=-44}function te(e,n){let t=!1;for(let o=e.firstDep;o!==null;o=o.nextDep)o===n&&(t=!0),t&&(o.ver=v),oe(o.from,o)}function oe(e,n){let t=e.slot;t!==null&&(s[i++]=t),e.slot=n}function le(e,n){for(let t=e.firstDep;t!==null;t=t.nextDep)t.from.slot=null;for(;i>n;){let t=s[--i];s[i]=null,t.from.slot=t}w()}function m(e,n,t,o){let l=n.firstSub,r=l!==null?l.prevSub:null,u={from:n,ver:n.ver,nextDep:o,to:e,nextSub:null,gen:e.gen+1&1073741823,prevDep:t,prevSub:r};t!==null?t.nextDep=u:e.firstDep=u,o!==null?o.prevDep=u:e.lastDep=u,l!==null?(r.nextSub=u,l.prevSub=u):(n.firstSub=u,u.prevSub=u),f=u,(n.flags&1)!==0&&I(u)}function J(e,n,t,o){if(t!==null&&t.from.slot===t)return ie(e,n,t,o);let l=n.firstSub;if(l===null||Ae(l,e))return m(e,n,t,o);if(o!==null&&o.ver===v)return ue(e,n,t,o,fe(l,e));if(o!==null){let r=o.nextDep;if(r!==null&&r.from===n)return re(e,n,t,o,r);let u=z;for(r=e.lastDep;r!==o&&r.from!==n&&--u!==0;)r=r.prevDep;if(r.from===n)return r.ver=n.ver,f=r,E(e,r,t,o)}he(e,n,t,o,l)}function he(e,n,t,o,l){let r=null;if(o!==null){let R=N;for(r=o.nextDep;r!==null&&r.from!==n&&--R!==0;)r=r.nextDep;if(r!==null&&r.from===n)return re(e,n,t,o,r)}let u=t!==null?t.prevDep:null,W=N;for(;u!==null&&u.from!==n&&--W!==0;)u=u.prevDep;if(!(u!==null&&u.from===n)){if(r===null&&u===null)return m(e,n,t,o);ye(e,n,t,o,l)}}function re(e,n,t,o,l){if(l.ver=n.ver,f=l,o.ver===b)return j(e,t,o,l);o.ver=b,E(e,l,t,o)}function ye(e,n,t,o,l){let r=fe(l,e);if(r!=null){if(r.ver===b)return r.ver=n.ver,f=r,E(e,r,t,o);we(e,r,l,o)}ue(e,n,t,o,r)}function ue(e,n,t,o,l){if(l===null)return m(e,n,t,o);if(l!==void 0)return se(e,l,n,t,o);te(e,o),ie(e,n,t,o)}function ie(e,n,t,o){let l=n.slot;if(l!==null&&l.to===e)return se(e,l,n,t,o);m(e,n,t,o),oe(n,f)}function Ae(e,n){let t=e.prevSub;return e.to!==n&&t.to!==n&&(t===e||e.nextSub===t)}function fe(e,n){let t=N;for(let o=e;o!==null;o=o.nextSub){if(o.to===n)return o;if(--t===0)return}return null}function we(e,n,t,o){if(o!==null){if(n!==t)return te(e,o);for(let l=o;l!==null;l=l.nextDep)l.ver=v}}function se(e,n,t,o,l){n.ver===v&&(n.ver=t.ver,E(e,n,o,l),f=n)}var x=new Array(S).fill(null),p=S-1,g=0,U=0,k=0,d=0,a=0;function de(e){let n=e.flags;(n&192)===64&&(d>p&&Pe(),x[g+d++&p]=e,e.flags=n|128)}Z(de);function Pe(){let e=new Array(d+d).fill(null);for(let n=0;n<d;n++)e[n]=x[g+n&p];x=e,p=d+d-1,g=0}function ae(e,n){return T(e,void 0,19|(n?64:0))}function Ce(e,n){if(e.fn===null||(n&33)===0){e.flags=n;return}if(e.flags=n&-34,(n&1)!==0)try{if((ne(e,n)&2)===0)return}catch(o){throw e.flags|=1,o}let t=e.value;typeof t=="function"&&(e.value=void 0,D(t),e.fn===null)||_(e)}function L(e){if(e.fn===null)return;let n=e.value;e.value=void 0,C(e),typeof n=="function"&&D(n)}function B(){d===0||a!==0||Q()}function Q(){a=1,K(!1,void 0)}function pe(e){if(a!==0||d!==0)return de(e),B();a=1;try{_(e)}catch(n){return K(!0,n)}K(!1,void 0)}function K(e,n){let t=0;for(;d!==0;t++){let o=x[g];x[g]=null,g=g+1&p,d--;let l=o.flags&-129;o.flags=l;try{Ce(o,l)}catch(r){e||(n=r),e=!0}}if(g=0,p>=h&&(t+t<p>>1?(t>k&&(k=t),(U+=t)>p&&We(k)):U=k=0),a=0,e)throw n}function We(e){let n=S;for(;n<e+e;)n+=n;x.length=n,p=n-1,U=k=0}function ce(e){a++;let n;try{n=e()}catch(t){if(--a===0)try{B()}catch{}throw t}return--a===0&&B(),n}function Re(e){let n=e;return(n.flags&16)!==0?"effect":n.fn===null?"signal":"computed"}function Ve(e){return T(null,e,0)}function Me(e,n){return T(e,n,2)}function Ie(e){let n=ae(e,!0);try{pe(n)}catch(t){try{L(n)}catch{}throw t}return n}var Oe=F,qe=ee;function ge(e,n){$(e,n),d!==0&&a===0&&Q()}function Ue(e,n){ge(e,D(()=>n(e.value)))}function Be(e){let n=e;(n.flags&16)!==0?L(n):C(n)}
1
+ /* reflex-quant 1.3.1 | MIT */
2
+ "use strict";var M=Object.defineProperty;var ge=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var Se=Object.prototype.hasOwnProperty;var Ne=(e,n)=>{for(var t in n)M(e,t,{get:n[t],enumerable:!0})},he=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of ke(n))!Se.call(e,l)&&l!==t&&M(e,l,{get:()=>n[l],enumerable:!(o=ge(n,l))||o.enumerable});return e};var me=e=>he(M({},"__esModule",{value:!0}),e);var Xe={};Ne(Xe,{batch:()=>Te,compute:()=>Ke,computed:()=>Oe,dispose:()=>Ge,effect:()=>qe,get:()=>Be,peek:()=>Le,read:()=>X,readSignal:()=>Ue,set:()=>Ee,signal:()=>Ie,typeOf:()=>Me,untracked:()=>g,update:()=>Qe});module.exports=me(Xe);var T=-1,y=-2,z=-3,j=536870911,x=8,H=2,k=256,b=512;function S(e,n,t){return{e:t,l:n,n:0,r:e,u:null,c:null,f:null,a:null,d:0}}function N(e,n,t,o){let l=n.i,u=n.t;l.t=u,u!==null?u.i=l:e.c=l,n.i=t,n.t=o,t!==null?t.t=n:e.u=n,o.i=n}function F(e,n,t,o){let l=t.t,u=e.c;n!==null?n.t=l:e.u=l,l.i=n,t.i=u,t.t=null,u.t=t,e.c=t,u.n===T&&(t.n=T),o!==l&&N(e,o,n,l)}function I(e,n){let t=n===null?e.u:n.t;if(t!==null)for(n===null?e.u=null:n.t=null,e.c=n,t.i=null;t!==null;t=t.t)A(t)}function J(e){let n=e.d;for(let t=e.u;t!==null;t=t.t)t.d=n}function A(e){let n=e.o,t=e.p,o=e.s;e===n.f?n.f=o:t.s=o,o!==null?o.p=t:n.f!==null&&(n.f.p=t),e.p=null,e.s=null}var Y=Object.is,a=null,f=null,d=new Array(256).fill(null),i=0;var D=()=>{};function Z(e){D=e}function w(){d.length>b&&i===0&&(d.length=k)}function $(e,n){let t=e.l;if(t===n?n!==0||1/t===1/n:t!==t&&n!==n)return!1;e.l=n;let o=e.f;if(o===null)return!1;for(q(e);o!==null;o=o.s){let l=o._,u=l.e;if((u&5)===4)if(l.e=u|1,(u&16)!==0)D(l);else{let r=l.f;r!==null&&O(r)}else if((u&16)!==0)l.e=u|2|32,D(l);else if((u&1)!==0)l.e=u|2;else{l.e=u|2|1;let r=l.f;r!==null&&O(r)}}return!0}function q(e){let n=e.n+1&1073741823;n===0&&ye(e),e.n=n}function ye(e){for(let n=e.f;n!==null;n=n.s)n.n>=0&&(n.n=z)}function O(e){let n=i,t=e;for(;;){for(;t!==null;){let o=t._,l=o.e;if((l&16)!==0)o.e=l|1,D(o);else if((l&1)===0){o.e=l|1;let u=o.f;if(u!==null){let r=t.s;r!==null&&(d[i++]=r),t=u;continue}}t=t.s}if(i===n){w();return}t=d[--i],d[i]=null}}function ee(e){(e.e&47)!==0&&P(e);let n=a;if(n===null)return e.l;let t=f,o=t===null?n.u:t.t;if(o!==null&&o.o===e)return f=o,o.n=e.n,e.l;if(t!==null){if(t.o===e)return e.l;C(n,e,t,o)}else o!==null?C(n,e,t,o):h(n,e,null,null);return e.l}function ne(e){let n=a;if(n===null)return e.l;let t=f,o=t===null?n.u:t.t;if(o!==null&&o.o===e)return f=o,o.n=e.n,e.l;if(t!==null){if(t.o===e)return e.l;C(n,e,t,o)}else o!==null?C(n,e,t,o):h(n,e,null,null);return e.l}function te(e){return(e.e&47)!==0&&P(e),e.l}function P(e){let n=e.e;if((n&2)!==0)return E(e);xe(e,n)}function xe(e,n){e.e=n&-10;let t=i,o=e,l=e.u;try{for(;;){e:for(;l!==null;){let u=l.o,r=u.e;if((r&11)===0){if(u.n===l.n){l=l.t;continue}}else{if((r&2)===0){u.e=r&-10,d[i++]=l,o=u,l=u.u;continue}if(E(u),u.n===l.n){l=l.t;continue}}o.r!==null&&E(o);break e}for(;;){if(i===t){w();return}let u=d[--i];if(d[i]=null,o=u._,u.o.n===u.n){l=u.t;break}o.r!==null&&E(o)}}}catch(u){for(;;){if(o.r!==null){let r=o.e&-42;o.e=(r&2)===0?r|8:r}if(i===t)break;o=d[--i]._,d[i]=null}throw w(),u}}function oe(e,n){let t=e.d+1&1073741823;for(;;){let o=e.u;if((n&2)===0)for(;o!==null;){let l=o.o;if((l.e&11)===0){if(l.n===o.n){o=o.t;continue}}else if(P(l),l.n===o.n){o=o.t;continue}e.e|=2,o=o.t;break}for(;o!==null;){let l=o.o;if((l.e&11)===0||o.d===t){o=o.t;continue}P(l),o=o.t}if(e.r===null)return 0;if(n=e.e,(n&1)===0)return n;e.e=n&-2}}function g(e){let n=a;a=null;try{return e()}finally{a=n}}function E(e){let n=a,t=f,o=i;e.e=e.e&-44|4,a=e,f=null;let l;try{l=e.r(e.l)}catch(R){let V=f;throw a=n,f=t,e.e=e.e&-5|(e.r!==null?2:0),Ae(e,o,V),R}let u=f;a=n,f=t;let r=e.e;if(u!==null&&u.o.a===u&&re(e,o),e.e=r&-5,e.r===null)return be(e,l);(u===null?e.u:u.t)!==null&&I(e,u),e.d=e.d+1&1073741823,(e.d&j)===0&&J(e),Y(l,e.l)===!1&&(e.l=l,q(e))}function be(e,n){B(e),(e.e&16)===0&&Y(n,e.l)===!1&&(e.l=n,q(e))}function Ae(e,n,t){if(t!==null&&t.o.a===t&&re(e,n),e.r===null)return B(e);let o=e.d+1&1073741823;for(let l=t===null?e.u:t.t;l!==null;){let u=l.t;if(l.d===o){let r=l.i;r!==null?r.t=u:e.u=u,u!==null?u.i=r:e.c=r,A(l),l.i=null,l.t=null}l=u}}function W(e){e.r!==null&&(e.r=null,(e.e&4)===0&&B(e))}function B(e){if((e.e&16)===0)I(e,null);else{let n=e.u;for(e.u=e.c=null;n!==null;){let t=n.t;A(n),n.i=n.t=null,n=t}}e.e&=-44}function le(e,n){let t=!1;for(let o=e.u;o!==null;o=o.t)o===n&&(t=!0),t&&(o.n=T),ue(o.o,o)}function ue(e,n){let t=e.a;t!==null&&(d[i++]=t),e.a=n}function re(e,n){for(let t=e.u;t!==null;t=t.t)t.o.a=null;for(;i>n;){let t=d[--i];d[i]=null,t.o.a=t}w()}function h(e,n,t,o){let l=n.f,u=l!==null?l.p:null,r={o:n,n:n.n,t:o,_:e,s:null,d:e.d+1&1073741823,i:t,p:u};t!==null?t.t=r:e.u=r,o!==null?o.i=r:e.c=r,l!==null?(u.s=r,l.p=r):(n.f=r,r.p=r),f=r,(n.e&1)!==0&&O(r)}function C(e,n,t,o){if(t!==null&&t.o.a===t)return de(e,n,t,o);let l=n.f;if(l===null||Pe(l,e))return h(e,n,t,o);if(o!==null&&o.n===T)return fe(e,n,t,o,se(l,e));if(o!==null){let u=o.t;if(u!==null&&u.o===n)return ie(e,n,t,o,u);let r=H;for(u=e.c;u!==o&&u.o!==n&&--r!==0;)u=u.i;if(u.o===n)return u.n=n.n,f=u,N(e,u,t,o)}De(e,n,t,o,l)}function De(e,n,t,o,l){let u=null;if(o!==null){let V=x;for(u=o.t;u!==null&&u.o!==n&&--V!==0;)u=u.t;if(u!==null&&u.o===n)return ie(e,n,t,o,u)}let r=t!==null?t.i:null,R=x;for(;r!==null&&r.o!==n&&--R!==0;)r=r.i;if(!(r!==null&&r.o===n)){if(u===null&&r===null)return h(e,n,t,o);we(e,n,t,o,l)}}function ie(e,n,t,o,l){if(l.n=n.n,f=l,o.n===y)return F(e,t,o,l);o.n=y,N(e,l,t,o)}function we(e,n,t,o,l){let u=se(l,e);if(u!=null){if(u.n===y)return u.n=n.n,f=u,N(e,u,t,o);Ce(e,u,l,o)}fe(e,n,t,o,u)}function fe(e,n,t,o,l){if(l===null)return h(e,n,t,o);if(l!==void 0)return ce(e,l,n,t,o);le(e,o),de(e,n,t,o)}function de(e,n,t,o){let l=n.a;if(l!==null&&l._===e)return ce(e,l,n,t,o);h(e,n,t,o),ue(n,f)}function Pe(e,n){let t=e.p;return e._!==n&&t._!==n&&(t===e||e.s===t)}function se(e,n){let t=x;for(let o=e;o!==null;o=o.s){if(o._===n)return o;if(--t===0)return}return null}function Ce(e,n,t,o){if(o!==null){if(n!==t)return le(e,o);for(let l=o;l!==null;l=l.t)l.n=T}}function ce(e,n,t,o,l){n.n===T&&(n.n=t.n,N(e,n,o,l),f=n)}var m=new Array(k).fill(null),p=k-1,_=0,U=0,v=0,s=0,c=0;function ae(e){let n=e.e;(n&192)===64&&(s>p&&We(),m[_+s++&p]=e,e.e=n|128)}Z(ae);function We(){let e=new Array(s+s).fill(null);for(let n=0;n<s;n++)e[n]=m[_+n&p];m=e,p=s+s-1,_=0}function pe(e,n){return S(e,void 0,19|(n?64:0))}function Re(e,n){if(e.r===null||(n&33)===0){e.e=n;return}if(e.e=n&-34,(n&1)!==0)try{if((oe(e,n)&2)===0)return}catch(o){throw e.e|=1,o}let t=e.l;typeof t=="function"&&(e.l=void 0,g(t),e.r===null)||E(e)}function Q(e){if(e.r===null)return;let n=e.l;e.l=void 0,W(e),typeof n=="function"&&g(n)}function K(){s===0||c!==0||G()}function G(){c=1,L(!1,void 0)}function _e(e){if(c!==0||s!==0)return ae(e),K();c=1;try{E(e)}catch(n){return L(!0,n)}L(!1,void 0)}function L(e,n){let t=0;for(;s!==0;t++){let o=m[_];m[_]=null,_=_+1&p,s--;let l=o.e&-129;o.e=l;try{Re(o,l)}catch(u){e||(n=u),e=!0}}if(_=0,p>=b&&(t+t<p>>1?(t>v&&(v=t),(U+=t)>p&&Ve(v)):U=v=0),c=0,e)throw n}function Ve(e){let n=k;for(;n<e+e;)n+=n;m.length=n,p=n-1,U=v=0}function Te(e){c++;let n;try{n=e()}catch(t){if(--c===0)try{K()}catch{}throw t}return--c===0&&K(),n}function Me(e){let n=e;return(n.e&16)!==0?"effect":n.r===null?"signal":"computed"}function Ie(e){return S(null,e,0)}function Oe(e,n){return S(e,n,2)}function qe(e){let n=pe(e,!0);try{_e(n)}catch(t){try{Q(n)}catch{}throw t}return n}var X=ee,Be=X,Ue=ne;var Ke=X,Le=te;function Ee(e,n){$(e,n)&&s!==0&&c===0&&G()}function Qe(e,n){Ee(e,g(()=>n(e.l)))}function Ge(e){let n=e;(n.e&16)!==0?Q(n):W(n)}
3
3
  //# sourceMappingURL=index.cjs.map