sia-reactor 0.0.23 → 0.0.24

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.
@@ -1,5 +1,5 @@
1
- import { d as Reactive } from './index-m0aAWxhX.js';
2
- import { m as TimeTravelModule } from './timeTravel-DExvNb04.js';
1
+ import { d as Reactive } from './index-CDRimfvj.js';
2
+ import { m as TimeTravelModule } from './timeTravel-Cb8MHdYz.js';
3
3
 
4
4
  /** Reactive options for the TimeTravel overlay instance. */
5
5
  interface TimeTravelConfig {
@@ -1,5 +1,5 @@
1
- import { d as Reactive } from './index-m0aAWxhX.cjs';
2
- import { m as TimeTravelModule } from './timeTravel-DctvcHVt.cjs';
1
+ import { d as Reactive } from './index-CDRimfvj.cjs';
2
+ import { m as TimeTravelModule } from './timeTravel-CVgE6N0I.cjs';
3
3
 
4
4
  /** Reactive options for the TimeTravel overlay instance. */
5
5
  interface TimeTravelConfig {
@@ -73,7 +73,7 @@ function isPOJO(obj, config = NIL, typecheck = true) {
73
73
  function canHandle(obj, config = NIL, typecheck = true) {
74
74
  if (typecheck && !isObj(obj, false) || obj[INERTIA]) return false;
75
75
  if (Array.isArray(obj) || !config.preserveContext && isPOJO(obj, config, false)) return true;
76
- if (config.preserveContext) return !(obj instanceof Map) && !(obj instanceof Set) && !(obj instanceof WeakMap) && !(obj instanceof WeakSet) && !(obj instanceof Error) && !(obj instanceof Number) && !(obj instanceof Date) && !(obj instanceof String) && !(obj instanceof RegExp) && !(obj instanceof ArrayBuffer) && !(obj instanceof Promise);
76
+ if (config.preserveContext) return !(obj instanceof String) && !(obj instanceof Number) && !(obj instanceof Function) && !(obj instanceof Date) && !(obj instanceof Error) && !(obj instanceof RegExp) && !(obj instanceof Promise) && !(obj instanceof Map) && !(obj instanceof WeakMap) && !(obj instanceof Set) && !(obj instanceof WeakSet) && !(obj instanceof EventTarget);
77
77
  return false;
78
78
  }
79
79
  function getAny(source, key, separator = ".", keyFunc) {
@@ -157,7 +157,10 @@ function parseEvtOpts(options, opts, boolOpt = opts[0], result = {}) {
157
157
  }
158
158
  function getTrailRecords(obj, path, reverse = false) {
159
159
  const parts = path.split("."), chain = [["*", obj, obj]];
160
- for (let acc = "", currObj = obj, i = 0, len = parts.length; i < len; i++) chain.push([acc += (i ? "." : "") + parts[i], currObj, currObj = currObj?.[parts[i]]]);
160
+ for (let acc = "", currObj = obj, i = 0, len = parts.length; i < len; i++) {
161
+ const part = parts[i];
162
+ chain.push([acc += (i ? "." : "") + part, currObj, currObj = currObj?.[part]]);
163
+ }
161
164
  return reverse ? chain.reverse() : chain;
162
165
  }
163
166
  function nuke(target) {
@@ -165,10 +168,11 @@ function nuke(target) {
165
168
  while (proto && proto !== Object.prototype) {
166
169
  const keys2 = Object.getOwnPropertyNames(proto);
167
170
  for (let i = 0, len = keys2.length; i < len; i++) {
168
- if (keys2[i] === "constructor") continue;
171
+ const key = keys2[i];
172
+ if (key === "constructor") continue;
169
173
  const desc = Object.getOwnPropertyDescriptor(proto, keys2[i]);
170
174
  if (desc && ("function" === typeof desc.value || desc.get || desc.set)) continue;
171
- proto[keys2[i]] = null;
175
+ proto[key] = null;
172
176
  }
173
177
  proto = Object.getPrototypeOf(proto);
174
178
  }
@@ -463,7 +467,10 @@ var Reactor = class {
463
467
  seen.add(target);
464
468
  const es = (this.lineage ??= /* @__PURE__ */ new WeakMap()).get(target);
465
469
  if (!es) return paths;
466
- for (let i = 0, len = es.length; i < len; i += 2) this.trace(es[i], es[i + 1] ? es[i + 1] + "." + path : path, paths, seen);
470
+ for (let i = 0, len = es.length; i < len; i += 2) {
471
+ const prev = es[i + 1];
472
+ this.trace(es[i], prev ? prev + "." + path : path, paths, seen);
473
+ }
467
474
  return paths;
468
475
  }
469
476
  // won't be called without `.config.referenceTracking` so internal guard avoided
@@ -493,9 +500,9 @@ var Reactor = class {
493
500
  let terminated = false, value = payload.target.value;
494
501
  const isGet = type === "get", isSet = type === "set", mediators = isGet ? this.getters : isSet ? this.setters : this.deleters;
495
502
  for (let i = !isGet ? 0 : cords.length - 1, len = !isGet ? cords.length : -1; i !== len; i += !isGet ? 1 : -1) {
496
- const response = isGet ? cords[i].cb(value, payload) : isSet ? cords[i].cb(value, terminated, payload) : cords[i].cb(terminated, payload);
503
+ const cord = cords[i], response = isGet ? cord.cb(value, payload) : isSet ? cord.cb(value, terminated, payload) : cord.cb(terminated, payload);
497
504
  if (isGet || !(terminated ||= payload.terminated = response === TERMINATOR)) value = response;
498
- if (cords[i].once) cords.splice((len--, i--), 1), !cords.length && mediators.delete(path);
505
+ if (cord.once) cords.splice((len--, i--), 1), !cords.length && mediators.delete(path);
499
506
  }
500
507
  return value;
501
508
  }
@@ -504,13 +511,15 @@ var Reactor = class {
504
511
  const wildcords = this.watchers.get("*"), cords = this.watchers.get(path);
505
512
  if (cords)
506
513
  for (let i = 0, len = cords.length; i < len; i++) {
507
- cords[i].cb(payload.target.value, payload);
508
- if (cords[i].once) cords.splice((len--, i--), 1), !cords.length && this.watchers.delete(path);
514
+ const cord = cords[i];
515
+ cord.cb(payload.target.value, payload);
516
+ if (cord.once) cords.splice((len--, i--), 1), !cords.length && this.watchers.delete(path);
509
517
  }
510
518
  if (wildcords)
511
519
  for (let i = 0, len = wildcords.length; i < len; i++) {
512
- wildcords[i].cb(payload.target.value, payload);
513
- if (wildcords[i].once) wildcords.splice((len--, i--), 1), !wildcords.length && this.watchers.delete("*");
520
+ const wildcord = wildcords[i];
521
+ wildcord.cb(payload.target.value, payload);
522
+ if (wildcord.once) wildcords.splice((len--, i--), 1), !wildcords.length && this.watchers.delete("*");
514
523
  }
515
524
  }
516
525
  this.listeners && this.schedule(path, payload);
@@ -549,14 +558,15 @@ var Reactor = class {
549
558
  e.type = path !== e.target.path ? "update" : e.staticType;
550
559
  e.currentTarget = { path, value, oldValue: e.type !== "update" ? e.target.oldValue : void 0, key: e.type !== "update" ? path : path.slice(path.lastIndexOf(".") + 1) || "", hadKey: e.type !== "update" ? e.target.hadKey : true, object };
551
560
  for (let i = 0, len = cords.length, tDepth; i < len; i++) {
561
+ const cord = cords[i];
552
562
  if (e.immediatePropagationStopped) break;
553
- if (cords[i].capture !== isCapture) continue;
554
- if (cords[i].depth !== void 0) {
563
+ if (cord.capture !== isCapture) continue;
564
+ if (cord.depth !== void 0) {
555
565
  tDepth ??= this.getDepth(e.target.path);
556
- if (tDepth > cords[i].lDepth + cords[i].depth) continue;
566
+ if (tDepth > cord.lDepth + cord.depth) continue;
557
567
  }
558
- cords[i].cb(e);
559
- if (cords[i].once) cords.splice((len--, i--), 1), !cords.length && this.listeners.delete(path);
568
+ cord.cb(e);
569
+ if (cord.once) cords.splice((len--, i--), 1), !cords.length && this.listeners.delete(path);
560
570
  }
561
571
  }
562
572
  /**
@@ -618,25 +628,28 @@ var Reactor = class {
618
628
  const clone = !raw ? this.config.preserveContext ? Object.create(Object.getPrototypeOf(obj)) : Array.isArray(obj) ? [] : {} : obj;
619
629
  seen.set(obj, clone);
620
630
  const keys2 = this.config.preserveContext ? Reflect.ownKeys(obj) : Object.keys(obj);
621
- for (let i = 0, len = keys2.length; i < len; i++)
631
+ for (let i = 0, len = keys2.length; i < len; i++) {
632
+ const key = keys2[i];
622
633
  try {
623
- clone[keys2[i]] = this.cloned(obj[keys2[i]], raw, seen);
634
+ clone[key] = this.cloned(obj[key], raw, seen);
624
635
  } catch (e) {
625
636
  if (e instanceof RangeError) throw e;
626
637
  }
638
+ }
627
639
  if (!raw && this.config.smartCloning) this.snapCache.set(obj, clone), obj[SSVERSION] = version;
628
640
  return clone;
629
641
  }
630
642
  syncAdd(key, path, cb, opts, onImmediate = NOOP) {
631
643
  const { lazy = false, once = false, signal, immediate = false } = parseEvtOpts(opts, EVT_OPTS.MEDIATOR), store = this[`${key}${key.endsWith("t") ? "t" : ""}ers`] ??= /* @__PURE__ */ new Map();
632
644
  let cords = store.get(path), cord;
633
- if (cords) {
634
- for (let i = 0, len = cords.length; i < len; i++)
635
- if (Object.is(cords[i].cb, cb)) {
636
- cord = cords[i];
645
+ if (cords)
646
+ for (let i = 0, len = cords.length; i < len; i++) {
647
+ const excord = cords[i];
648
+ if (Object.is(excord.cb, cb)) {
649
+ cord = excord;
637
650
  break;
638
651
  }
639
- }
652
+ }
640
653
  if (cord) return cord.clup;
641
654
  let task;
642
655
  cord = { cb, once, clup: () => (lazy && this.nostall(task), this[`no${key}`](path, cb)) };
@@ -648,7 +661,10 @@ var Reactor = class {
648
661
  syncDrop(store, path, cb) {
649
662
  const cords = store?.get(path);
650
663
  if (!cords) return void 0;
651
- for (let i = 0, len = cords.length; i < len; i++) if (Object.is(cords[i].cb, cb)) return cords[i].sclup(), cords.splice((len--, i--), 1), !cords.length && store.delete(path), true;
664
+ for (let i = 0, len = cords.length; i < len; i++) {
665
+ const cord = cords[i];
666
+ if (Object.is(cord.cb, cb)) return cord.sclup(), cords.splice((len--, i--), 1), !cords.length && store.delete(path), true;
667
+ }
652
668
  return false;
653
669
  }
654
670
  /**
@@ -766,13 +782,14 @@ var Reactor = class {
766
782
  this.listeners ??= /* @__PURE__ */ new Map();
767
783
  const { capture = false, once = false, signal, immediate = false, depth } = parseEvtOpts(options, EVT_OPTS.LISTENER);
768
784
  let cords = this.listeners.get(path), cord;
769
- if (cords) {
770
- for (let i = 0, len = cords.length; i < len; i++)
771
- if (Object.is(cords[i].cb, callback) && capture === cords[i].capture) {
772
- cord = cords[i];
785
+ if (cords)
786
+ for (let i = 0, len = cords.length; i < len; i++) {
787
+ const excord = cords[i];
788
+ if (Object.is(excord.cb, callback) && capture === excord.capture) {
789
+ cord = excord;
773
790
  break;
774
791
  }
775
- }
792
+ }
776
793
  if (cord) return cord.clup;
777
794
  cord = { cb: callback, capture, depth, once, clup: () => this.off(path, callback, options), lDepth: depth !== void 0 ? this.getDepth(path) : depth };
778
795
  if (immediate && (immediate !== "auto" || inAny(this.core, path))) {
@@ -801,7 +818,10 @@ var Reactor = class {
801
818
  const cords = this.listeners?.get(path);
802
819
  if (!cords) return void 0;
803
820
  const { capture } = parseEvtOpts(options, EVT_OPTS.LISTENER);
804
- for (let i = 0, len = cords.length; i < len; i++) if (Object.is(cords[i].cb, callback) && cords[i].capture === capture) return cords[i].sclup(), cords.splice((len--, i--), 1), !cords.length && this.listeners.delete(path), true;
821
+ for (let i = 0, len = cords.length; i < len; i++) {
822
+ const cord = cords[i];
823
+ if (Object.is(cord.cb, callback) && cord.capture === capture) return cord.sclup(), cords.splice((len--, i--), 1), !cords.length && this.listeners.delete(path), true;
824
+ }
805
825
  return false;
806
826
  }
807
827
  snapshot(raw = !this.config.smartCloning, branch) {
@@ -873,19 +893,19 @@ var Autotracker = class {
873
893
  this.autortr = this.rtr = rtr;
874
894
  }
875
895
  /**
876
- * Starts a new tracking pass and returns a tracking proxy for `target` if `this` was instantiated with a `Reactor`.
896
+ * Starts a new tracking pass and returns a readonly tracking proxy for `target` if `this` was instantiated with a `Reactor`.
877
897
  * @param target Snapshot (or state branch) to track reads from.
878
- * @returns Read-tracking proxy.
898
+ * @returns Read-tracking readonly proxy.
879
899
  * @example
880
900
  * const atrkr = new Autotracker(rtr);
881
901
  * const state = atrkr.tracked(rtr.snapshot());
882
902
  * const name = state.user.profile.name;
883
903
  */
884
904
  tracked(target) {
885
- return this.unblock(), this.rtr ? this.proxy = this.proxied(target, "") : target;
905
+ return this.unblock(), this.proxy = this.proxied(target, "");
886
906
  }
887
907
  proxied(obj, path) {
888
- if (!obj || "object" !== typeof obj) return obj;
908
+ if (!this.rtr || !obj || "object" !== typeof obj) return obj;
889
909
  const cached = this.proxyCache.get(obj);
890
910
  if (cached) return cached;
891
911
  if (!canHandle(obj, this.rtr.config, false)) return obj;
@@ -1,7 +1,7 @@
1
- import { E as EffectOptions, R as Reactor, d as Reactive, u as ReactorBuild, W as WildPaths, v as PathValue } from '../index-m0aAWxhX.cjs';
1
+ import { E as EffectOptions, R as Reactor, d as Reactive, v as ReactorBuild, D as DeepReadonly, W as WildPaths, e as PathValue } from '../index-CDRimfvj.cjs';
2
2
  import { useLayoutEffect } from 'react';
3
- import { m as TimeTravelModule } from '../timeTravel-DctvcHVt.cjs';
4
- import { T as TimeTravelConfig } from '../TimeTravelOverlay-OjklzuCD.cjs';
3
+ import { m as TimeTravelModule } from '../timeTravel-CVgE6N0I.cjs';
4
+ import { T as TimeTravelConfig } from '../TimeTravelOverlay-XwZju4iS.cjs';
5
5
 
6
6
  /**
7
7
  * Subscribes a component to desired Reactor state and returns it.
@@ -30,7 +30,7 @@ declare function useReactor<T extends object>(target: T | Reactor<T> | Reactive<
30
30
  */
31
31
  declare function useAnyReactor(options?: EffectOptions): void;
32
32
  /**
33
- * Subscribes a component to Reactor state and returns a tracked snapshot.
33
+ * Subscribes a component to Reactor state and returns a readonly tracked snapshot.
34
34
  * Rule of thumb: read from snapshots, mutate the source.
35
35
  * The hook uses access tracking so re-renders occur only when accessed fields change.
36
36
  * @typeParam T Root state object type.
@@ -47,7 +47,7 @@ declare function useAnyReactor(options?: EffectOptions): void;
47
47
  * const rtr = new Reactor({ user: { name: "Kosi" } });
48
48
  * const c = useReactorSnapshot(rtr);
49
49
  */
50
- declare function useReactorSnapshot<T extends object>(target: T | Reactor<T> | Reactive<T>, options?: EffectOptions, build?: ReactorBuild<T>): T;
50
+ declare function useReactorSnapshot<T extends object>(target: T | Reactor<T> | Reactive<T>, options?: EffectOptions, build?: ReactorBuild<T>): DeepReadonly<T>;
51
51
 
52
52
  /**
53
53
  * Subscribes to a derived slice of Reactor state.
@@ -84,7 +84,7 @@ declare function useSelector<T extends object, R>(target: T | Reactor<T> | React
84
84
  declare function useAnySelector<R>(sel: () => R, eq?: (value1: any, value2: any) => boolean, options?: EffectOptions): R;
85
85
  /**
86
86
  * Subscribes to a derived slice of Reactor state.
87
- * The selector runs against a tracked snapshot and uses the provided equality function
87
+ * The selector runs against a readonly tracked snapshot and uses the provided equality function
88
88
  * to suppress unchanged results.
89
89
  * @typeParam T Root state object type.
90
90
  * @typeParam R Selector return type.
@@ -103,7 +103,7 @@ declare function useAnySelector<R>(sel: () => R, eq?: (value1: any, value2: any)
103
103
  * const rtr = new Reactor({ user: { name: "Kosi" } });
104
104
  * const c = useSelectorSnapshot(rtr, (s) => s.user.name);
105
105
  */
106
- declare function useSelectorSnapshot<T extends object, R>(target: T | Reactor<T> | Reactive<T>, sel: (state: T) => R, eq?: (value1: any, value2: any) => boolean, options?: EffectOptions, build?: ReactorBuild<T>): R;
106
+ declare function useSelectorSnapshot<T extends object, R>(target: T | Reactor<T> | Reactive<T>, sel: (state: DeepReadonly<T>) => R, eq?: (value1: any, value2: any) => boolean, options?: EffectOptions, build?: ReactorBuild<T>): R;
107
107
 
108
108
  /**
109
109
  * Subscribes to a single path in Reactor state.
@@ -1,7 +1,7 @@
1
- import { E as EffectOptions, R as Reactor, d as Reactive, u as ReactorBuild, W as WildPaths, v as PathValue } from '../index-m0aAWxhX.js';
1
+ import { E as EffectOptions, R as Reactor, d as Reactive, v as ReactorBuild, D as DeepReadonly, W as WildPaths, e as PathValue } from '../index-CDRimfvj.js';
2
2
  import { useLayoutEffect } from 'react';
3
- import { m as TimeTravelModule } from '../timeTravel-DExvNb04.js';
4
- import { T as TimeTravelConfig } from '../TimeTravelOverlay-Dglcwpg-.js';
3
+ import { m as TimeTravelModule } from '../timeTravel-Cb8MHdYz.js';
4
+ import { T as TimeTravelConfig } from '../TimeTravelOverlay-BdJMMcX9.js';
5
5
 
6
6
  /**
7
7
  * Subscribes a component to desired Reactor state and returns it.
@@ -30,7 +30,7 @@ declare function useReactor<T extends object>(target: T | Reactor<T> | Reactive<
30
30
  */
31
31
  declare function useAnyReactor(options?: EffectOptions): void;
32
32
  /**
33
- * Subscribes a component to Reactor state and returns a tracked snapshot.
33
+ * Subscribes a component to Reactor state and returns a readonly tracked snapshot.
34
34
  * Rule of thumb: read from snapshots, mutate the source.
35
35
  * The hook uses access tracking so re-renders occur only when accessed fields change.
36
36
  * @typeParam T Root state object type.
@@ -47,7 +47,7 @@ declare function useAnyReactor(options?: EffectOptions): void;
47
47
  * const rtr = new Reactor({ user: { name: "Kosi" } });
48
48
  * const c = useReactorSnapshot(rtr);
49
49
  */
50
- declare function useReactorSnapshot<T extends object>(target: T | Reactor<T> | Reactive<T>, options?: EffectOptions, build?: ReactorBuild<T>): T;
50
+ declare function useReactorSnapshot<T extends object>(target: T | Reactor<T> | Reactive<T>, options?: EffectOptions, build?: ReactorBuild<T>): DeepReadonly<T>;
51
51
 
52
52
  /**
53
53
  * Subscribes to a derived slice of Reactor state.
@@ -84,7 +84,7 @@ declare function useSelector<T extends object, R>(target: T | Reactor<T> | React
84
84
  declare function useAnySelector<R>(sel: () => R, eq?: (value1: any, value2: any) => boolean, options?: EffectOptions): R;
85
85
  /**
86
86
  * Subscribes to a derived slice of Reactor state.
87
- * The selector runs against a tracked snapshot and uses the provided equality function
87
+ * The selector runs against a readonly tracked snapshot and uses the provided equality function
88
88
  * to suppress unchanged results.
89
89
  * @typeParam T Root state object type.
90
90
  * @typeParam R Selector return type.
@@ -103,7 +103,7 @@ declare function useAnySelector<R>(sel: () => R, eq?: (value1: any, value2: any)
103
103
  * const rtr = new Reactor({ user: { name: "Kosi" } });
104
104
  * const c = useSelectorSnapshot(rtr, (s) => s.user.name);
105
105
  */
106
- declare function useSelectorSnapshot<T extends object, R>(target: T | Reactor<T> | Reactive<T>, sel: (state: T) => R, eq?: (value1: any, value2: any) => boolean, options?: EffectOptions, build?: ReactorBuild<T>): R;
106
+ declare function useSelectorSnapshot<T extends object, R>(target: T | Reactor<T> | Reactive<T>, sel: (state: DeepReadonly<T>) => R, eq?: (value1: any, value2: any) => boolean, options?: EffectOptions, build?: ReactorBuild<T>): R;
107
107
 
108
108
  /**
109
109
  * Subscribes to a single path in Reactor state.
@@ -2,10 +2,10 @@ import {
2
2
  Autotracker,
3
3
  TimeTravelOverlay,
4
4
  withTracker
5
- } from "../chunk-5JNWC7Z4.js";
5
+ } from "../chunk-6V5NR37Q.js";
6
6
  import {
7
7
  getReactor
8
- } from "../chunk-MSTHQVNK.js";
8
+ } from "../chunk-4FES5IIH.js";
9
9
  import "../chunk-5A44QFT6.js";
10
10
  import "../chunk-P37ADJMM.js";
11
11
  import {
@@ -13,7 +13,7 @@ import {
13
13
  NIL,
14
14
  NOOP,
15
15
  getAny
16
- } from "../chunk-MKL3JUPO.js";
16
+ } from "../chunk-EZ4VRGYI.js";
17
17
 
18
18
  // src/ts/adapters/react/hooks/useReactor.ts
19
19
  import { useRef, useCallback, useSyncExternalStore, useMemo } from "react";
@@ -61,7 +61,7 @@ function isPOJO(obj, config = NIL, typecheck = true) {
61
61
  function canHandle(obj, config = NIL, typecheck = true) {
62
62
  if (typecheck && !isObj(obj, false) || obj[INERTIA]) return false;
63
63
  if (Array.isArray(obj) || !config.preserveContext && isPOJO(obj, config, false)) return true;
64
- if (config.preserveContext) return !(obj instanceof Map) && !(obj instanceof Set) && !(obj instanceof WeakMap) && !(obj instanceof WeakSet) && !(obj instanceof Error) && !(obj instanceof Number) && !(obj instanceof Date) && !(obj instanceof String) && !(obj instanceof RegExp) && !(obj instanceof ArrayBuffer) && !(obj instanceof Promise);
64
+ if (config.preserveContext) return !(obj instanceof String) && !(obj instanceof Number) && !(obj instanceof Function) && !(obj instanceof Date) && !(obj instanceof Error) && !(obj instanceof RegExp) && !(obj instanceof Promise) && !(obj instanceof Map) && !(obj instanceof WeakMap) && !(obj instanceof Set) && !(obj instanceof WeakSet) && !(obj instanceof EventTarget);
65
65
  return false;
66
66
  }
67
67
  function getAny(source, key, separator = ".", keyFunc) {
@@ -145,7 +145,10 @@ function parseEvtOpts(options, opts, boolOpt = opts[0], result = {}) {
145
145
  }
146
146
  function getTrailRecords(obj, path, reverse = false) {
147
147
  const parts = path.split("."), chain = [["*", obj, obj]];
148
- for (let acc = "", currObj = obj, i = 0, len = parts.length; i < len; i++) chain.push([acc += (i ? "." : "") + parts[i], currObj, currObj = currObj?.[parts[i]]]);
148
+ for (let acc = "", currObj = obj, i = 0, len = parts.length; i < len; i++) {
149
+ const part = parts[i];
150
+ chain.push([acc += (i ? "." : "") + part, currObj, currObj = currObj?.[part]]);
151
+ }
149
152
  return reverse ? chain.reverse() : chain;
150
153
  }
151
154
  function nuke(target) {
@@ -153,10 +156,11 @@ function nuke(target) {
153
156
  while (proto && proto !== Object.prototype) {
154
157
  const keys2 = Object.getOwnPropertyNames(proto);
155
158
  for (let i = 0, len = keys2.length; i < len; i++) {
156
- if (keys2[i] === "constructor") continue;
159
+ const key = keys2[i];
160
+ if (key === "constructor") continue;
157
161
  const desc = Object.getOwnPropertyDescriptor(proto, keys2[i]);
158
162
  if (desc && ("function" === typeof desc.value || desc.get || desc.set)) continue;
159
- proto[keys2[i]] = null;
163
+ proto[key] = null;
160
164
  }
161
165
  proto = Object.getPrototypeOf(proto);
162
166
  }
@@ -178,19 +182,19 @@ var Autotracker = class {
178
182
  this.autortr = this.rtr = rtr;
179
183
  }
180
184
  /**
181
- * Starts a new tracking pass and returns a tracking proxy for `target` if `this` was instantiated with a `Reactor`.
185
+ * Starts a new tracking pass and returns a readonly tracking proxy for `target` if `this` was instantiated with a `Reactor`.
182
186
  * @param target Snapshot (or state branch) to track reads from.
183
- * @returns Read-tracking proxy.
187
+ * @returns Read-tracking readonly proxy.
184
188
  * @example
185
189
  * const atrkr = new Autotracker(rtr);
186
190
  * const state = atrkr.tracked(rtr.snapshot());
187
191
  * const name = state.user.profile.name;
188
192
  */
189
193
  tracked(target) {
190
- return this.unblock(), this.rtr ? this.proxy = this.proxied(target, "") : target;
194
+ return this.unblock(), this.proxy = this.proxied(target, "");
191
195
  }
192
196
  proxied(obj, path) {
193
- if (!obj || "object" !== typeof obj) return obj;
197
+ if (!this.rtr || !obj || "object" !== typeof obj) return obj;
194
198
  const cached = this.proxyCache.get(obj);
195
199
  if (cached) return cached;
196
200
  if (!canHandle(obj, this.rtr.config, false)) return obj;
@@ -603,7 +607,10 @@ var Reactor = class {
603
607
  seen.add(target);
604
608
  const es = (this.lineage ??= /* @__PURE__ */ new WeakMap()).get(target);
605
609
  if (!es) return paths;
606
- for (let i = 0, len = es.length; i < len; i += 2) this.trace(es[i], es[i + 1] ? es[i + 1] + "." + path : path, paths, seen);
610
+ for (let i = 0, len = es.length; i < len; i += 2) {
611
+ const prev = es[i + 1];
612
+ this.trace(es[i], prev ? prev + "." + path : path, paths, seen);
613
+ }
607
614
  return paths;
608
615
  }
609
616
  // won't be called without `.config.referenceTracking` so internal guard avoided
@@ -633,9 +640,9 @@ var Reactor = class {
633
640
  let terminated = false, value = payload.target.value;
634
641
  const isGet = type === "get", isSet = type === "set", mediators = isGet ? this.getters : isSet ? this.setters : this.deleters;
635
642
  for (let i = !isGet ? 0 : cords.length - 1, len = !isGet ? cords.length : -1; i !== len; i += !isGet ? 1 : -1) {
636
- const response = isGet ? cords[i].cb(value, payload) : isSet ? cords[i].cb(value, terminated, payload) : cords[i].cb(terminated, payload);
643
+ const cord = cords[i], response = isGet ? cord.cb(value, payload) : isSet ? cord.cb(value, terminated, payload) : cord.cb(terminated, payload);
637
644
  if (isGet || !(terminated ||= payload.terminated = response === TERMINATOR)) value = response;
638
- if (cords[i].once) cords.splice((len--, i--), 1), !cords.length && mediators.delete(path);
645
+ if (cord.once) cords.splice((len--, i--), 1), !cords.length && mediators.delete(path);
639
646
  }
640
647
  return value;
641
648
  }
@@ -644,13 +651,15 @@ var Reactor = class {
644
651
  const wildcords = this.watchers.get("*"), cords = this.watchers.get(path);
645
652
  if (cords)
646
653
  for (let i = 0, len = cords.length; i < len; i++) {
647
- cords[i].cb(payload.target.value, payload);
648
- if (cords[i].once) cords.splice((len--, i--), 1), !cords.length && this.watchers.delete(path);
654
+ const cord = cords[i];
655
+ cord.cb(payload.target.value, payload);
656
+ if (cord.once) cords.splice((len--, i--), 1), !cords.length && this.watchers.delete(path);
649
657
  }
650
658
  if (wildcords)
651
659
  for (let i = 0, len = wildcords.length; i < len; i++) {
652
- wildcords[i].cb(payload.target.value, payload);
653
- if (wildcords[i].once) wildcords.splice((len--, i--), 1), !wildcords.length && this.watchers.delete("*");
660
+ const wildcord = wildcords[i];
661
+ wildcord.cb(payload.target.value, payload);
662
+ if (wildcord.once) wildcords.splice((len--, i--), 1), !wildcords.length && this.watchers.delete("*");
654
663
  }
655
664
  }
656
665
  this.listeners && this.schedule(path, payload);
@@ -689,14 +698,15 @@ var Reactor = class {
689
698
  e.type = path !== e.target.path ? "update" : e.staticType;
690
699
  e.currentTarget = { path, value, oldValue: e.type !== "update" ? e.target.oldValue : void 0, key: e.type !== "update" ? path : path.slice(path.lastIndexOf(".") + 1) || "", hadKey: e.type !== "update" ? e.target.hadKey : true, object };
691
700
  for (let i = 0, len = cords.length, tDepth; i < len; i++) {
701
+ const cord = cords[i];
692
702
  if (e.immediatePropagationStopped) break;
693
- if (cords[i].capture !== isCapture) continue;
694
- if (cords[i].depth !== void 0) {
703
+ if (cord.capture !== isCapture) continue;
704
+ if (cord.depth !== void 0) {
695
705
  tDepth ??= this.getDepth(e.target.path);
696
- if (tDepth > cords[i].lDepth + cords[i].depth) continue;
706
+ if (tDepth > cord.lDepth + cord.depth) continue;
697
707
  }
698
- cords[i].cb(e);
699
- if (cords[i].once) cords.splice((len--, i--), 1), !cords.length && this.listeners.delete(path);
708
+ cord.cb(e);
709
+ if (cord.once) cords.splice((len--, i--), 1), !cords.length && this.listeners.delete(path);
700
710
  }
701
711
  }
702
712
  /**
@@ -758,25 +768,28 @@ var Reactor = class {
758
768
  const clone = !raw ? this.config.preserveContext ? Object.create(Object.getPrototypeOf(obj)) : Array.isArray(obj) ? [] : {} : obj;
759
769
  seen.set(obj, clone);
760
770
  const keys2 = this.config.preserveContext ? Reflect.ownKeys(obj) : Object.keys(obj);
761
- for (let i = 0, len = keys2.length; i < len; i++)
771
+ for (let i = 0, len = keys2.length; i < len; i++) {
772
+ const key = keys2[i];
762
773
  try {
763
- clone[keys2[i]] = this.cloned(obj[keys2[i]], raw, seen);
774
+ clone[key] = this.cloned(obj[key], raw, seen);
764
775
  } catch (e) {
765
776
  if (e instanceof RangeError) throw e;
766
777
  }
778
+ }
767
779
  if (!raw && this.config.smartCloning) this.snapCache.set(obj, clone), obj[SSVERSION] = version;
768
780
  return clone;
769
781
  }
770
782
  syncAdd(key, path, cb, opts, onImmediate = NOOP) {
771
783
  const { lazy = false, once = false, signal, immediate = false } = parseEvtOpts(opts, EVT_OPTS.MEDIATOR), store = this[`${key}${key.endsWith("t") ? "t" : ""}ers`] ??= /* @__PURE__ */ new Map();
772
784
  let cords = store.get(path), cord;
773
- if (cords) {
774
- for (let i = 0, len = cords.length; i < len; i++)
775
- if (Object.is(cords[i].cb, cb)) {
776
- cord = cords[i];
785
+ if (cords)
786
+ for (let i = 0, len = cords.length; i < len; i++) {
787
+ const excord = cords[i];
788
+ if (Object.is(excord.cb, cb)) {
789
+ cord = excord;
777
790
  break;
778
791
  }
779
- }
792
+ }
780
793
  if (cord) return cord.clup;
781
794
  let task;
782
795
  cord = { cb, once, clup: () => (lazy && this.nostall(task), this[`no${key}`](path, cb)) };
@@ -788,7 +801,10 @@ var Reactor = class {
788
801
  syncDrop(store, path, cb) {
789
802
  const cords = store?.get(path);
790
803
  if (!cords) return void 0;
791
- for (let i = 0, len = cords.length; i < len; i++) if (Object.is(cords[i].cb, cb)) return cords[i].sclup(), cords.splice((len--, i--), 1), !cords.length && store.delete(path), true;
804
+ for (let i = 0, len = cords.length; i < len; i++) {
805
+ const cord = cords[i];
806
+ if (Object.is(cord.cb, cb)) return cord.sclup(), cords.splice((len--, i--), 1), !cords.length && store.delete(path), true;
807
+ }
792
808
  return false;
793
809
  }
794
810
  /**
@@ -906,13 +922,14 @@ var Reactor = class {
906
922
  this.listeners ??= /* @__PURE__ */ new Map();
907
923
  const { capture = false, once = false, signal, immediate = false, depth } = parseEvtOpts(options, EVT_OPTS.LISTENER);
908
924
  let cords = this.listeners.get(path), cord;
909
- if (cords) {
910
- for (let i = 0, len = cords.length; i < len; i++)
911
- if (Object.is(cords[i].cb, callback) && capture === cords[i].capture) {
912
- cord = cords[i];
925
+ if (cords)
926
+ for (let i = 0, len = cords.length; i < len; i++) {
927
+ const excord = cords[i];
928
+ if (Object.is(excord.cb, callback) && capture === excord.capture) {
929
+ cord = excord;
913
930
  break;
914
931
  }
915
- }
932
+ }
916
933
  if (cord) return cord.clup;
917
934
  cord = { cb: callback, capture, depth, once, clup: () => this.off(path, callback, options), lDepth: depth !== void 0 ? this.getDepth(path) : depth };
918
935
  if (immediate && (immediate !== "auto" || inAny(this.core, path))) {
@@ -941,7 +958,10 @@ var Reactor = class {
941
958
  const cords = this.listeners?.get(path);
942
959
  if (!cords) return void 0;
943
960
  const { capture } = parseEvtOpts(options, EVT_OPTS.LISTENER);
944
- for (let i = 0, len = cords.length; i < len; i++) if (Object.is(cords[i].cb, callback) && cords[i].capture === capture) return cords[i].sclup(), cords.splice((len--, i--), 1), !cords.length && this.listeners.delete(path), true;
961
+ for (let i = 0, len = cords.length; i < len; i++) {
962
+ const cord = cords[i];
963
+ if (Object.is(cord.cb, callback) && cord.capture === capture) return cord.sclup(), cords.splice((len--, i--), 1), !cords.length && this.listeners.delete(path), true;
964
+ }
945
965
  return false;
946
966
  }
947
967
  snapshot(raw = !this.config.smartCloning, branch) {
@@ -1,7 +1,7 @@
1
- import { E as EffectOptions } from '../index-m0aAWxhX.cjs';
2
- export { A as Autotracker, w as withTracker } from '../index-m0aAWxhX.cjs';
3
- export { T as TimeTravelConfig, a as TimeTravelOverlay } from '../TimeTravelOverlay-OjklzuCD.cjs';
4
- import '../timeTravel-DctvcHVt.cjs';
1
+ import { E as EffectOptions } from '../index-CDRimfvj.cjs';
2
+ export { A as Autotracker, w as withTracker } from '../index-CDRimfvj.cjs';
3
+ export { T as TimeTravelConfig, a as TimeTravelOverlay } from '../TimeTravelOverlay-XwZju4iS.cjs';
4
+ import '../timeTravel-CVgE6N0I.cjs';
5
5
 
6
6
  /**
7
7
  * Runs a reactive side effect in vanilla JavaScript.
@@ -1,7 +1,7 @@
1
- import { E as EffectOptions } from '../index-m0aAWxhX.js';
2
- export { A as Autotracker, w as withTracker } from '../index-m0aAWxhX.js';
3
- export { T as TimeTravelConfig, a as TimeTravelOverlay } from '../TimeTravelOverlay-Dglcwpg-.js';
4
- import '../timeTravel-DExvNb04.js';
1
+ import { E as EffectOptions } from '../index-CDRimfvj.js';
2
+ export { A as Autotracker, w as withTracker } from '../index-CDRimfvj.js';
3
+ export { T as TimeTravelConfig, a as TimeTravelOverlay } from '../TimeTravelOverlay-BdJMMcX9.js';
4
+ import '../timeTravel-Cb8MHdYz.js';
5
5
 
6
6
  /**
7
7
  * Runs a reactive side effect in vanilla JavaScript.
@@ -3,11 +3,11 @@ import {
3
3
  TimeTravelOverlay,
4
4
  effect,
5
5
  withTracker
6
- } from "../chunk-5JNWC7Z4.js";
7
- import "../chunk-MSTHQVNK.js";
6
+ } from "../chunk-6V5NR37Q.js";
7
+ import "../chunk-4FES5IIH.js";
8
8
  import "../chunk-5A44QFT6.js";
9
9
  import "../chunk-P37ADJMM.js";
10
- import "../chunk-MKL3JUPO.js";
10
+ import "../chunk-EZ4VRGYI.js";
11
11
  export {
12
12
  Autotracker,
13
13
  TimeTravelOverlay,