sia-reactor 0.0.32 → 0.0.34

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.
Files changed (35) hide show
  1. package/README.md +5 -4
  2. package/dist/{TimeTravelOverlay-BlVhj8n1.d.cts → TimeTravelOverlay-DTqM5uJB.d.cts} +2 -2
  3. package/dist/{TimeTravelOverlay-D8jAd_Fz.d.ts → TimeTravelOverlay-cSlHzoKB.d.ts} +2 -2
  4. package/dist/adapters/react.cjs +19 -22
  5. package/dist/adapters/react.d.cts +3 -3
  6. package/dist/adapters/react.d.ts +3 -3
  7. package/dist/adapters/react.js +6 -6
  8. package/dist/adapters/vanilla.cjs +18 -21
  9. package/dist/adapters/vanilla.d.cts +4 -4
  10. package/dist/adapters/vanilla.d.ts +4 -4
  11. package/dist/adapters/vanilla.js +4 -4
  12. package/dist/{chunk-EZ4VRGYI.js → chunk-4PLMBUCP.js} +13 -17
  13. package/dist/{chunk-XNYVGOKB.js → chunk-CEPDD5XN.js} +3 -3
  14. package/dist/{chunk-AKQSBLBX.js → chunk-T2CAL5F4.js} +19 -18
  15. package/dist/{chunk-GD7HZBXA.js → chunk-VIDZLTP2.js} +2 -2
  16. package/dist/{index-CWbDYjby.d.cts → index-0TjDsae1.d.cts} +15 -15
  17. package/dist/{index-CWbDYjby.d.ts → index-0TjDsae1.d.ts} +15 -15
  18. package/dist/index.cjs +18 -21
  19. package/dist/index.d.cts +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +2 -2
  22. package/dist/modules.cjs +35 -34
  23. package/dist/modules.d.cts +4 -4
  24. package/dist/modules.d.ts +4 -4
  25. package/dist/modules.js +21 -17
  26. package/dist/styles/time-travel-overlay.css +14 -13
  27. package/dist/super.d.ts +22 -22
  28. package/dist/super.global.js +42 -41
  29. package/dist/{timeTravel-BsVQ5z7v.d.ts → timeTravel-CX100S8f.d.ts} +3 -3
  30. package/dist/{timeTravel-DoWtLH_e.d.cts → timeTravel-wU23uudD.d.cts} +3 -3
  31. package/dist/utils.cjs +18 -22
  32. package/dist/utils.d.cts +1 -1
  33. package/dist/utils.d.ts +1 -1
  34. package/dist/utils.js +11 -11
  35. package/package.json +3 -3
package/README.md CHANGED
@@ -50,8 +50,9 @@ const player = reactive({
50
50
 
51
51
  // Logic layer (capture phase)
52
52
  player.on("intent.playing", (e) => {
53
- if (!ready) return e.reject();
53
+ if (!ready) return e.reject(); // warning optimistic UI
54
54
  player.state.playing = true;
55
+ e.resolve(); // claimed and handled
55
56
  }, { capture: true });
56
57
 
57
58
  // UI layer
@@ -92,7 +93,7 @@ pnpm add sia-reactor
92
93
  import { reactive, Reactor, TERMINATOR } from "sia-reactor";
93
94
 
94
95
  // 2. Deep Object Utilities
95
- import { setAny, getAny, mergeObjs } from "sia-reactor/utils";
96
+ import { setPath, getPath, mergeObjs } from "sia-reactor/utils";
96
97
  ```
97
98
 
98
99
  ---
@@ -103,7 +104,7 @@ import { setAny, getAny, mergeObjs } from "sia-reactor/utils";
103
104
 
104
105
  ```javascript
105
106
  import { reactive, Reactor } from "sia-reactor";
106
- import "sia-reactor/utils"; // deep object helpers (setAny/getAny/deleteAny/inAny/parseAnyObj/fanout/mergeObjs/deepClone/nuke...) take note of `fanout`!
107
+ import "sia-reactor/utils"; // deep object helpers (setPath/getPath/deletePath/hasPath/parsePathObj/fanout/mergeObjs/deepClone/nuke...) take note of `fanout`!
107
108
  import "sia-reactor/modules"; // built-in modules + storage adapters
108
109
  import "sia-reactor/adapters/vanilla"; // Autotracker + effect API + TimeTravelOverlay class
109
110
  import "sia-reactor/adapters/react"; // useReactor/useSelector/usePath hooks
@@ -269,7 +270,7 @@ const time = new TimeTravelModule({ maxHistory: 300, loop: false, rate: 150, whi
269
270
  store.use(time);
270
271
 
271
272
  // If persist uses an async adapter (e.g. IndexedDB), wait till after hydration:
272
- persist.state.once("hydrated", () => store.use(time)); // starts `false`, one-time stall until it flips
273
+ persist.state.once("hydrated", () => store.use(time)); // starts `false`, one-time stall until it flips. i.e, also escapes custom initialization
273
274
  effect(() => persist.state.hydrated && store.use(time), { once: true }) // same logic, different look :)
274
275
 
275
276
  const overlay = new TimeTravelOverlay(time, { color: "#e26e02", startOpen: false, devOnly: true, container: document.body }); // optional debug interface for visulazation
@@ -1,5 +1,5 @@
1
- import { e as Reactive } from './index-CWbDYjby.cjs';
2
- import { m as TimeTravelModule } from './timeTravel-DoWtLH_e.cjs';
1
+ import { e as Reactive } from './index-0TjDsae1.cjs';
2
+ import { m as TimeTravelModule } from './timeTravel-wU23uudD.cjs';
3
3
 
4
4
  /** Reactive options for the TimeTravel overlay instance. */
5
5
  interface TimeTravelOverlayConfig {
@@ -1,5 +1,5 @@
1
- import { e as Reactive } from './index-CWbDYjby.js';
2
- import { m as TimeTravelModule } from './timeTravel-BsVQ5z7v.js';
1
+ import { e as Reactive } from './index-0TjDsae1.js';
2
+ import { m as TimeTravelModule } from './timeTravel-CX100S8f.js';
3
3
 
4
4
  /** Reactive options for the TimeTravel overlay instance. */
5
5
  interface TimeTravelOverlayConfig {
@@ -76,9 +76,8 @@ function canHandle(obj, config = NIL, typecheck = true) {
76
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
- function getAny(source, key, separator = ".", keyFunc) {
79
+ function getPath(source, key, separator = ".", keyFunc) {
80
80
  if (key === "*") return source;
81
- if (!key.includes(separator)) return source[keyFunc ? keyFunc(key) : key];
82
81
  const keys2 = key.split(separator);
83
82
  let currObj = source;
84
83
  for (let i = 0, len = keys2.length; i < len; i++) {
@@ -94,9 +93,8 @@ function getAny(source, key, separator = ".", keyFunc) {
94
93
  }
95
94
  return currObj;
96
95
  }
97
- function setAny(target, key, value, separator = ".", keyFunc) {
96
+ function setPath(target, key, value, separator = ".", keyFunc) {
98
97
  if (key === "*") return Object.assign(target, value);
99
- if (!key.includes(separator)) return void (target[keyFunc ? keyFunc(key) : key] = value);
100
98
  const keys2 = key.split(separator);
101
99
  for (let currObj = target, i = 0, len = keys2.length; i < len; i++) {
102
100
  const key2 = keyFunc ? keyFunc(keys2[i]) : keys2[i], match = key2.includes("[") && key2.match(arrRegex);
@@ -111,13 +109,12 @@ function setAny(target, key, value, separator = ".", keyFunc) {
111
109
  }
112
110
  }
113
111
  }
114
- function deleteAny(target, key, separator = ".", keyFunc) {
112
+ function deletePath(target, key, separator = ".", keyFunc) {
115
113
  if (key === "*") {
116
114
  const keys3 = Object.keys(target);
117
115
  for (let i = 0, len = keys3.length; i < len; i++) delete target[keys3[i]];
118
116
  return;
119
117
  }
120
- if (!key.includes(separator)) return void delete target[keyFunc ? keyFunc(key) : key];
121
118
  const keys2 = key.split(separator);
122
119
  for (let currObj = target, i = 0, len = keys2.length; i < len; i++) {
123
120
  const key2 = keyFunc ? keyFunc(keys2[i]) : keys2[i], match = key2.includes("[") && key2.match(arrRegex);
@@ -133,9 +130,8 @@ function deleteAny(target, key, separator = ".", keyFunc) {
133
130
  }
134
131
  }
135
132
  }
136
- function inAny(source, key, separator = ".", keyFunc) {
133
+ function hasPath(source, key, separator = ".", keyFunc) {
137
134
  if (key === "*") return true;
138
- if (!key.includes(separator)) return key in source;
139
135
  const keys2 = key.split(separator);
140
136
  for (let currObj = source, i = 0, len = keys2.length; i < len; i++) {
141
137
  const key2 = keyFunc ? keyFunc(keys2[i]) : keys2[i], match = key2.includes("[") && key2.match(arrRegex);
@@ -271,7 +267,7 @@ var ReactorEvent = class _ReactorEvent {
271
267
  resolve(message) {
272
268
  if (!this.rejectable) return this.reactor.log(`[ReactorEvent] Ignored \`resolve()\` call on a non-rejectable ${this.staticType} at "${this.path}"`);
273
269
  if (this.eventPhase !== _ReactorEvent.CAPTURING_PHASE) this.reactor.log(`[ReactorEvent] Resolving an intent on ${this.staticType} at "${this.path}" outside of the capture phase is unadvised.`);
274
- if (this.rejectable) this.reactor.log(`[ReactorEvent] ${this._resolved = message || `Could ${this.staticType} intended value at "${this.path}"`}`);
270
+ if (this.rejectable) this.reactor.log(`[ReactorEvent] ${this._resolved = message || `${this.staticType} intent resolved at "${this.path}"`}`);
275
271
  }
276
272
  /** Rejection reason for rejectable events. */
277
273
  get rejected() {
@@ -286,7 +282,7 @@ var ReactorEvent = class _ReactorEvent {
286
282
  reject(reason) {
287
283
  if (!this.rejectable) return this.reactor.log(`[ReactorEvent] Ignored \`reject()\` call on a non-rejectable ${this.staticType} at "${this.path}"`);
288
284
  if (this.eventPhase !== _ReactorEvent.CAPTURING_PHASE) this.reactor.log(`[ReactorEvent] Rejecting an intent on ${this.staticType} at "${this.path}" outside of the capture phase is unadvised.`);
289
- if (this.rejectable) this.reactor.log(`[ReactorEvent] ${this._rejected = reason || `Couldn't ${this.staticType} intended value at "${this.path}"`}`);
285
+ if (this.rejectable) this.reactor.log(`[ReactorEvent] ${this._rejected = reason || `${this.staticType} intent rejected at "${this.path}"`}`);
290
286
  }
291
287
  /**
292
288
  * Returns event path values from target to root.
@@ -624,7 +620,7 @@ var Reactor = class {
624
620
  return depth;
625
621
  }
626
622
  getContext(path) {
627
- const last = path.lastIndexOf("."), value = getAny(this.core, path), object = last === -1 ? this.core : getAny(this.core, path.slice(0, last));
623
+ const last = path.lastIndexOf("."), value = getPath(this.core, path), object = last === -1 ? this.core : getPath(this.core, path.slice(0, last));
628
624
  return { path, value, key: path.slice(last + 1) || "", hadKey: true, object };
629
625
  }
630
626
  bindSignal(cord, sig) {
@@ -666,9 +662,8 @@ var Reactor = class {
666
662
  if (cord) return cord.clup;
667
663
  let task;
668
664
  cord = { cb, once, clup: () => (lazy && this.nostall(task), this[`no${key}`](path, cb)) };
669
- immediate && onImmediate(immediate);
670
665
  task = () => (cords ?? (store.set(path, cords = []), cords)).push(cord);
671
- lazy ? this.stall(task) : task();
666
+ immediate && onImmediate(immediate), lazy ? this.stall(task) : task();
672
667
  return this.bindSignal(cord, signal);
673
668
  }
674
669
  dropSync(store, path, cb) {
@@ -690,7 +685,7 @@ var Reactor = class {
690
685
  * const cleanup = rtr.get("user.name", (value) => String(value).trim());
691
686
  */
692
687
  get(path, callback, options) {
693
- return this.addSync("get", path, callback, options, (imm) => (imm !== "auto" || inAny(this.core, path)) && getAny(this.core, path));
688
+ return this.addSync("get", path, callback, options, (imm) => (imm !== "auto" || hasPath(this.core, path)) && getPath(this.core, path));
694
689
  }
695
690
  /** Registers a get mediator for a path that only triggers once. */
696
691
  gonce(path, callback, options) {
@@ -715,7 +710,7 @@ var Reactor = class {
715
710
  * rtr.set("user.name", (value) => String(value).trim());
716
711
  */
717
712
  set(path, callback, options) {
718
- return this.addSync("set", path, callback, options, (imm) => (imm !== "auto" || inAny(this.core, path)) && setAny(this.core, path, getAny(this.core, path)));
713
+ return this.addSync("set", path, callback, options, (imm) => (imm !== "auto" || hasPath(this.core, path)) && setPath(this.core, path, getPath(this.core, path)));
719
714
  }
720
715
  /** Registers a set mediator for a path that only triggers once. */
721
716
  sonce(path, callback, options) {
@@ -740,7 +735,7 @@ var Reactor = class {
740
735
  * rtr.delete("cache.temp", () => TERMINATOR);
741
736
  */
742
737
  delete(path, callback, options) {
743
- return this.addSync("delete", path, callback, options, (imm) => (imm !== "auto" || inAny(this.core, path)) && deleteAny(this.core, path));
738
+ return this.addSync("delete", path, callback, options, (imm) => (imm !== "auto" || hasPath(this.core, path)) && deletePath(this.core, path));
744
739
  }
745
740
  /** Registers a delete mediator for a path that only triggers once. */
746
741
  donce(path, callback, options) {
@@ -766,7 +761,7 @@ var Reactor = class {
766
761
  * const cleanup = rtr.watch("user.name", (value) => console.log(value));
767
762
  */
768
763
  watch(path, callback, options) {
769
- return this.addSync("watch", path, callback, options, (imm) => imm !== "auto" && inAny(this.core, path) && ((target) => callback(target.value, { type: "init", target, currentTarget: target, root: this.core, rejectable: false }))(this.getContext(path)));
764
+ return this.addSync("watch", path, callback, options, (imm) => (imm !== "auto" || hasPath(this.core, path)) && (imm === "strict" ? setPath(this.core, path, getPath(this.core, path)) : ((target) => callback(target.value, { type: "init", target, currentTarget: target, root: this.core, rejectable: false }))(this.getContext(path))));
770
765
  }
771
766
  /** Registers a watcher for a path that only triggers once. */
772
767
  wonce(path, callback, options) {
@@ -805,10 +800,12 @@ var Reactor = class {
805
800
  }
806
801
  if (cord) return cord.clup;
807
802
  cord = { cb: callback, capture, depth, once, clup: () => this.off(path, callback, options), lDepth: depth !== void 0 ? this.getDepth(path) : depth };
808
- if (immediate && (immediate !== "auto" || inAny(this.core, path))) {
809
- const target = this.getContext(path);
810
- callback(new ReactorEvent({ type: "init", target, currentTarget: target, root: this.core, rejectable: false }, this));
811
- }
803
+ if (immediate && (immediate !== "auto" || hasPath(this.core, path)))
804
+ if (immediate === "strict") setPath(this.core, path, getPath(this.core, path));
805
+ else {
806
+ const target = this.getContext(path);
807
+ callback(new ReactorEvent({ type: "init", target, currentTarget: target, root: this.core, rejectable: false }, this));
808
+ }
812
809
  (cords ?? (this.listeners.set(path, cords = []), cords)).push(cord);
813
810
  return this.bindSignal(cord, signal);
814
811
  }
@@ -1107,7 +1104,7 @@ function usePath(target, path, options = NIL, build) {
1107
1104
  const subscribe = (0, import_react4.useCallback)((notify) => rtr[optsRef.current.sync ? "watch" : "on"](path, () => (versionRef.current++, notify()), optsRef.current), [rtr, path]);
1108
1105
  const getSnapshot = (0, import_react4.useCallback)(() => versionRef.current, []);
1109
1106
  (0, import_react4.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
1110
- return getAny(rtr.core, path);
1107
+ return getPath(rtr.core, path);
1111
1108
  }
1112
1109
 
1113
1110
  // src/ts/adapters/react/TimeTravelOverlay.tsx
@@ -1,7 +1,7 @@
1
- import { E as EffectOptions, a as Reactor, e as Reactive, x as ReactorBuild, D as DeepReadonly, W as WildPaths, f as PathValue } from '../index-CWbDYjby.cjs';
1
+ import { E as EffectOptions, a as Reactor, e as Reactive, x as ReactorBuild, D as DeepReadonly, W as WildPaths, f as PathValue } from '../index-0TjDsae1.cjs';
2
2
  import { useLayoutEffect } from 'react';
3
- import { m as TimeTravelModule } from '../timeTravel-DoWtLH_e.cjs';
4
- import { a as TimeTravelOverlayConfig } from '../TimeTravelOverlay-BlVhj8n1.cjs';
3
+ import { m as TimeTravelModule } from '../timeTravel-wU23uudD.cjs';
4
+ import { a as TimeTravelOverlayConfig } from '../TimeTravelOverlay-DTqM5uJB.cjs';
5
5
 
6
6
  /**
7
7
  * Subscribes a component to desired Reactor state and returns it.
@@ -1,7 +1,7 @@
1
- import { E as EffectOptions, a as Reactor, e as Reactive, x as ReactorBuild, D as DeepReadonly, W as WildPaths, f as PathValue } from '../index-CWbDYjby.js';
1
+ import { E as EffectOptions, a as Reactor, e as Reactive, x as ReactorBuild, D as DeepReadonly, W as WildPaths, f as PathValue } from '../index-0TjDsae1.js';
2
2
  import { useLayoutEffect } from 'react';
3
- import { m as TimeTravelModule } from '../timeTravel-BsVQ5z7v.js';
4
- import { a as TimeTravelOverlayConfig } from '../TimeTravelOverlay-D8jAd_Fz.js';
3
+ import { m as TimeTravelModule } from '../timeTravel-CX100S8f.js';
4
+ import { a as TimeTravelOverlayConfig } from '../TimeTravelOverlay-cSlHzoKB.js';
5
5
 
6
6
  /**
7
7
  * Subscribes a component to desired Reactor state and returns it.
@@ -2,20 +2,20 @@ import {
2
2
  Autotracker,
3
3
  TimeTravelOverlay,
4
4
  withTracker
5
- } from "../chunk-XNYVGOKB.js";
5
+ } from "../chunk-CEPDD5XN.js";
6
6
  import "../chunk-PLYS4CVP.js";
7
- import "../chunk-GD7HZBXA.js";
7
+ import "../chunk-VIDZLTP2.js";
8
8
  import {
9
9
  getReactor
10
- } from "../chunk-AKQSBLBX.js";
10
+ } from "../chunk-T2CAL5F4.js";
11
11
  import "../chunk-RI45W4O6.js";
12
12
  import "../chunk-3OT72G7R.js";
13
13
  import {
14
14
  CTX,
15
15
  NIL,
16
16
  NOOP,
17
- getAny
18
- } from "../chunk-EZ4VRGYI.js";
17
+ getPath
18
+ } from "../chunk-4PLMBUCP.js";
19
19
 
20
20
  // src/ts/adapters/react/hooks/useReactor.ts
21
21
  import { useRef, useCallback, useSyncExternalStore, useMemo } from "react";
@@ -99,7 +99,7 @@ function usePath(target, path, options = NIL, build) {
99
99
  const subscribe = useCallback3((notify) => rtr[optsRef.current.sync ? "watch" : "on"](path, () => (versionRef.current++, notify()), optsRef.current), [rtr, path]);
100
100
  const getSnapshot = useCallback3(() => versionRef.current, []);
101
101
  useSyncExternalStore3(subscribe, getSnapshot, getSnapshot);
102
- return getAny(rtr.core, path);
102
+ return getPath(rtr.core, path);
103
103
  }
104
104
 
105
105
  // src/ts/adapters/react/TimeTravelOverlay.tsx
@@ -64,9 +64,8 @@ function canHandle(obj, config = NIL, typecheck = true) {
64
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
- function getAny(source, key, separator = ".", keyFunc) {
67
+ function getPath(source, key, separator = ".", keyFunc) {
68
68
  if (key === "*") return source;
69
- if (!key.includes(separator)) return source[keyFunc ? keyFunc(key) : key];
70
69
  const keys2 = key.split(separator);
71
70
  let currObj = source;
72
71
  for (let i = 0, len = keys2.length; i < len; i++) {
@@ -82,9 +81,8 @@ function getAny(source, key, separator = ".", keyFunc) {
82
81
  }
83
82
  return currObj;
84
83
  }
85
- function setAny(target, key, value, separator = ".", keyFunc) {
84
+ function setPath(target, key, value, separator = ".", keyFunc) {
86
85
  if (key === "*") return Object.assign(target, value);
87
- if (!key.includes(separator)) return void (target[keyFunc ? keyFunc(key) : key] = value);
88
86
  const keys2 = key.split(separator);
89
87
  for (let currObj = target, i = 0, len = keys2.length; i < len; i++) {
90
88
  const key2 = keyFunc ? keyFunc(keys2[i]) : keys2[i], match = key2.includes("[") && key2.match(arrRegex);
@@ -99,13 +97,12 @@ function setAny(target, key, value, separator = ".", keyFunc) {
99
97
  }
100
98
  }
101
99
  }
102
- function deleteAny(target, key, separator = ".", keyFunc) {
100
+ function deletePath(target, key, separator = ".", keyFunc) {
103
101
  if (key === "*") {
104
102
  const keys3 = Object.keys(target);
105
103
  for (let i = 0, len = keys3.length; i < len; i++) delete target[keys3[i]];
106
104
  return;
107
105
  }
108
- if (!key.includes(separator)) return void delete target[keyFunc ? keyFunc(key) : key];
109
106
  const keys2 = key.split(separator);
110
107
  for (let currObj = target, i = 0, len = keys2.length; i < len; i++) {
111
108
  const key2 = keyFunc ? keyFunc(keys2[i]) : keys2[i], match = key2.includes("[") && key2.match(arrRegex);
@@ -121,9 +118,8 @@ function deleteAny(target, key, separator = ".", keyFunc) {
121
118
  }
122
119
  }
123
120
  }
124
- function inAny(source, key, separator = ".", keyFunc) {
121
+ function hasPath(source, key, separator = ".", keyFunc) {
125
122
  if (key === "*") return true;
126
- if (!key.includes(separator)) return key in source;
127
123
  const keys2 = key.split(separator);
128
124
  for (let currObj = source, i = 0, len = keys2.length; i < len; i++) {
129
125
  const key2 = keyFunc ? keyFunc(keys2[i]) : keys2[i], match = key2.includes("[") && key2.match(arrRegex);
@@ -259,7 +255,7 @@ var ReactorEvent = class _ReactorEvent {
259
255
  resolve(message) {
260
256
  if (!this.rejectable) return this.reactor.log(`[ReactorEvent] Ignored \`resolve()\` call on a non-rejectable ${this.staticType} at "${this.path}"`);
261
257
  if (this.eventPhase !== _ReactorEvent.CAPTURING_PHASE) this.reactor.log(`[ReactorEvent] Resolving an intent on ${this.staticType} at "${this.path}" outside of the capture phase is unadvised.`);
262
- if (this.rejectable) this.reactor.log(`[ReactorEvent] ${this._resolved = message || `Could ${this.staticType} intended value at "${this.path}"`}`);
258
+ if (this.rejectable) this.reactor.log(`[ReactorEvent] ${this._resolved = message || `${this.staticType} intent resolved at "${this.path}"`}`);
263
259
  }
264
260
  /** Rejection reason for rejectable events. */
265
261
  get rejected() {
@@ -274,7 +270,7 @@ var ReactorEvent = class _ReactorEvent {
274
270
  reject(reason) {
275
271
  if (!this.rejectable) return this.reactor.log(`[ReactorEvent] Ignored \`reject()\` call on a non-rejectable ${this.staticType} at "${this.path}"`);
276
272
  if (this.eventPhase !== _ReactorEvent.CAPTURING_PHASE) this.reactor.log(`[ReactorEvent] Rejecting an intent on ${this.staticType} at "${this.path}" outside of the capture phase is unadvised.`);
277
- if (this.rejectable) this.reactor.log(`[ReactorEvent] ${this._rejected = reason || `Couldn't ${this.staticType} intended value at "${this.path}"`}`);
273
+ if (this.rejectable) this.reactor.log(`[ReactorEvent] ${this._rejected = reason || `${this.staticType} intent rejected at "${this.path}"`}`);
278
274
  }
279
275
  /**
280
276
  * Returns event path values from target to root.
@@ -612,7 +608,7 @@ var Reactor = class {
612
608
  return depth;
613
609
  }
614
610
  getContext(path) {
615
- const last = path.lastIndexOf("."), value = getAny(this.core, path), object = last === -1 ? this.core : getAny(this.core, path.slice(0, last));
611
+ const last = path.lastIndexOf("."), value = getPath(this.core, path), object = last === -1 ? this.core : getPath(this.core, path.slice(0, last));
616
612
  return { path, value, key: path.slice(last + 1) || "", hadKey: true, object };
617
613
  }
618
614
  bindSignal(cord, sig) {
@@ -654,9 +650,8 @@ var Reactor = class {
654
650
  if (cord) return cord.clup;
655
651
  let task;
656
652
  cord = { cb, once, clup: () => (lazy && this.nostall(task), this[`no${key}`](path, cb)) };
657
- immediate && onImmediate(immediate);
658
653
  task = () => (cords ?? (store.set(path, cords = []), cords)).push(cord);
659
- lazy ? this.stall(task) : task();
654
+ immediate && onImmediate(immediate), lazy ? this.stall(task) : task();
660
655
  return this.bindSignal(cord, signal);
661
656
  }
662
657
  dropSync(store, path, cb) {
@@ -678,7 +673,7 @@ var Reactor = class {
678
673
  * const cleanup = rtr.get("user.name", (value) => String(value).trim());
679
674
  */
680
675
  get(path, callback, options) {
681
- return this.addSync("get", path, callback, options, (imm) => (imm !== "auto" || inAny(this.core, path)) && getAny(this.core, path));
676
+ return this.addSync("get", path, callback, options, (imm) => (imm !== "auto" || hasPath(this.core, path)) && getPath(this.core, path));
682
677
  }
683
678
  /** Registers a get mediator for a path that only triggers once. */
684
679
  gonce(path, callback, options) {
@@ -703,7 +698,7 @@ var Reactor = class {
703
698
  * rtr.set("user.name", (value) => String(value).trim());
704
699
  */
705
700
  set(path, callback, options) {
706
- return this.addSync("set", path, callback, options, (imm) => (imm !== "auto" || inAny(this.core, path)) && setAny(this.core, path, getAny(this.core, path)));
701
+ return this.addSync("set", path, callback, options, (imm) => (imm !== "auto" || hasPath(this.core, path)) && setPath(this.core, path, getPath(this.core, path)));
707
702
  }
708
703
  /** Registers a set mediator for a path that only triggers once. */
709
704
  sonce(path, callback, options) {
@@ -728,7 +723,7 @@ var Reactor = class {
728
723
  * rtr.delete("cache.temp", () => TERMINATOR);
729
724
  */
730
725
  delete(path, callback, options) {
731
- return this.addSync("delete", path, callback, options, (imm) => (imm !== "auto" || inAny(this.core, path)) && deleteAny(this.core, path));
726
+ return this.addSync("delete", path, callback, options, (imm) => (imm !== "auto" || hasPath(this.core, path)) && deletePath(this.core, path));
732
727
  }
733
728
  /** Registers a delete mediator for a path that only triggers once. */
734
729
  donce(path, callback, options) {
@@ -754,7 +749,7 @@ var Reactor = class {
754
749
  * const cleanup = rtr.watch("user.name", (value) => console.log(value));
755
750
  */
756
751
  watch(path, callback, options) {
757
- return this.addSync("watch", path, callback, options, (imm) => imm !== "auto" && inAny(this.core, path) && ((target) => callback(target.value, { type: "init", target, currentTarget: target, root: this.core, rejectable: false }))(this.getContext(path)));
752
+ return this.addSync("watch", path, callback, options, (imm) => (imm !== "auto" || hasPath(this.core, path)) && (imm === "strict" ? setPath(this.core, path, getPath(this.core, path)) : ((target) => callback(target.value, { type: "init", target, currentTarget: target, root: this.core, rejectable: false }))(this.getContext(path))));
758
753
  }
759
754
  /** Registers a watcher for a path that only triggers once. */
760
755
  wonce(path, callback, options) {
@@ -793,10 +788,12 @@ var Reactor = class {
793
788
  }
794
789
  if (cord) return cord.clup;
795
790
  cord = { cb: callback, capture, depth, once, clup: () => this.off(path, callback, options), lDepth: depth !== void 0 ? this.getDepth(path) : depth };
796
- if (immediate && (immediate !== "auto" || inAny(this.core, path))) {
797
- const target = this.getContext(path);
798
- callback(new ReactorEvent({ type: "init", target, currentTarget: target, root: this.core, rejectable: false }, this));
799
- }
791
+ if (immediate && (immediate !== "auto" || hasPath(this.core, path)))
792
+ if (immediate === "strict") setPath(this.core, path, getPath(this.core, path));
793
+ else {
794
+ const target = this.getContext(path);
795
+ callback(new ReactorEvent({ type: "init", target, currentTarget: target, root: this.core, rejectable: false }, this));
796
+ }
800
797
  (cords ?? (this.listeners.set(path, cords = []), cords)).push(cord);
801
798
  return this.bindSignal(cord, signal);
802
799
  }
@@ -1,7 +1,7 @@
1
- import { E as EffectOptions } from '../index-CWbDYjby.cjs';
2
- export { A as Autotracker, w as withTracker } from '../index-CWbDYjby.cjs';
3
- export { T as TimeTravelOverlay, a as TimeTravelOverlayConfig } from '../TimeTravelOverlay-BlVhj8n1.cjs';
4
- import '../timeTravel-DoWtLH_e.cjs';
1
+ import { E as EffectOptions } from '../index-0TjDsae1.cjs';
2
+ export { A as Autotracker, w as withTracker } from '../index-0TjDsae1.cjs';
3
+ export { T as TimeTravelOverlay, a as TimeTravelOverlayConfig } from '../TimeTravelOverlay-DTqM5uJB.cjs';
4
+ import '../timeTravel-wU23uudD.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-CWbDYjby.js';
2
- export { A as Autotracker, w as withTracker } from '../index-CWbDYjby.js';
3
- export { T as TimeTravelOverlay, a as TimeTravelOverlayConfig } from '../TimeTravelOverlay-D8jAd_Fz.js';
4
- import '../timeTravel-BsVQ5z7v.js';
1
+ import { E as EffectOptions } from '../index-0TjDsae1.js';
2
+ export { A as Autotracker, w as withTracker } from '../index-0TjDsae1.js';
3
+ export { T as TimeTravelOverlay, a as TimeTravelOverlayConfig } from '../TimeTravelOverlay-cSlHzoKB.js';
4
+ import '../timeTravel-CX100S8f.js';
5
5
 
6
6
  /**
7
7
  * Runs a reactive side effect in vanilla JavaScript.
@@ -3,13 +3,13 @@ import {
3
3
  TimeTravelOverlay,
4
4
  effect,
5
5
  withTracker
6
- } from "../chunk-XNYVGOKB.js";
6
+ } from "../chunk-CEPDD5XN.js";
7
7
  import "../chunk-PLYS4CVP.js";
8
- import "../chunk-GD7HZBXA.js";
9
- import "../chunk-AKQSBLBX.js";
8
+ import "../chunk-VIDZLTP2.js";
9
+ import "../chunk-T2CAL5F4.js";
10
10
  import "../chunk-RI45W4O6.js";
11
11
  import "../chunk-3OT72G7R.js";
12
- import "../chunk-EZ4VRGYI.js";
12
+ import "../chunk-4PLMBUCP.js";
13
13
  export {
14
14
  Autotracker,
15
15
  TimeTravelOverlay,
@@ -35,9 +35,8 @@ function canHandle(obj, config = NIL, typecheck = true) {
35
35
  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);
36
36
  return false;
37
37
  }
38
- function getAny(source, key, separator = ".", keyFunc) {
38
+ function getPath(source, key, separator = ".", keyFunc) {
39
39
  if (key === "*") return source;
40
- if (!key.includes(separator)) return source[keyFunc ? keyFunc(key) : key];
41
40
  const keys = key.split(separator);
42
41
  let currObj = source;
43
42
  for (let i = 0, len = keys.length; i < len; i++) {
@@ -53,9 +52,8 @@ function getAny(source, key, separator = ".", keyFunc) {
53
52
  }
54
53
  return currObj;
55
54
  }
56
- function setAny(target, key, value, separator = ".", keyFunc) {
55
+ function setPath(target, key, value, separator = ".", keyFunc) {
57
56
  if (key === "*") return Object.assign(target, value);
58
- if (!key.includes(separator)) return void (target[keyFunc ? keyFunc(key) : key] = value);
59
57
  const keys = key.split(separator);
60
58
  for (let currObj = target, i = 0, len = keys.length; i < len; i++) {
61
59
  const key2 = keyFunc ? keyFunc(keys[i]) : keys[i], match = key2.includes("[") && key2.match(arrRegex);
@@ -70,13 +68,12 @@ function setAny(target, key, value, separator = ".", keyFunc) {
70
68
  }
71
69
  }
72
70
  }
73
- function deleteAny(target, key, separator = ".", keyFunc) {
71
+ function deletePath(target, key, separator = ".", keyFunc) {
74
72
  if (key === "*") {
75
73
  const keys2 = Object.keys(target);
76
74
  for (let i = 0, len = keys2.length; i < len; i++) delete target[keys2[i]];
77
75
  return;
78
76
  }
79
- if (!key.includes(separator)) return void delete target[keyFunc ? keyFunc(key) : key];
80
77
  const keys = key.split(separator);
81
78
  for (let currObj = target, i = 0, len = keys.length; i < len; i++) {
82
79
  const key2 = keyFunc ? keyFunc(keys[i]) : keys[i], match = key2.includes("[") && key2.match(arrRegex);
@@ -92,9 +89,8 @@ function deleteAny(target, key, separator = ".", keyFunc) {
92
89
  }
93
90
  }
94
91
  }
95
- function inAny(source, key, separator = ".", keyFunc) {
92
+ function hasPath(source, key, separator = ".", keyFunc) {
96
93
  if (key === "*") return true;
97
- if (!key.includes(separator)) return key in source;
98
94
  const keys = key.split(separator);
99
95
  for (let currObj = source, i = 0, len = keys.length; i < len; i++) {
100
96
  const key2 = keyFunc ? keyFunc(keys[i]) : keys[i], match = key2.includes("[") && key2.match(arrRegex);
@@ -111,13 +107,13 @@ function inAny(source, key, separator = ".", keyFunc) {
111
107
  }
112
108
  return true;
113
109
  }
114
- function parseAnyObj(obj, separator = ".", keyFunc = (p) => p, seen = /* @__PURE__ */ new WeakSet()) {
110
+ function parsePathObj(obj, separator = ".", keyFunc = (p) => p, seen = /* @__PURE__ */ new WeakSet()) {
115
111
  if (!isObj(obj) || seen.has(obj)) return obj;
116
112
  seen.add(obj);
117
113
  const result = {}, keys = Object.keys(obj);
118
114
  for (let i = 0, len = keys.length; i < len; i++) {
119
115
  const key = keys[i], val = obj[key];
120
- key === "*" || key.includes(separator) ? setAny(result, key, parseAnyObj(val, separator, keyFunc, seen), separator, keyFunc) : result[key] = isObj(val) ? parseAnyObj(val, separator, keyFunc, seen) : val;
116
+ key === "*" || key.includes(separator) ? setPath(result, key, parsePathObj(val, separator, keyFunc, seen), separator, keyFunc) : result[key] = isObj(val) ? parsePathObj(val, separator, keyFunc, seen) : val;
121
117
  }
122
118
  return result;
123
119
  }
@@ -125,7 +121,7 @@ function parseEvtOpts(options, opts, boolOpt = opts[0], result = {}) {
125
121
  return Object.assign(result, "boolean" === typeof options ? { [boolOpt]: options } : options), result;
126
122
  }
127
123
  function fanout(a, b, c, d) {
128
- const isEvPd = !!a?.target, isPath = !isEvPd && "string" === typeof b, [state, path, olds, news, opts, type] = isEvPd ? [a.root, a.currentTarget.path, a.currentTarget.oldValue, a.currentTarget.value, b || NIL, a.type] : isPath ? [a, b, getAny(a, b), c, d || NIL, void 0] : [void 0, void 0, a, b, c || NIL, void 0], target = isEvPd ? getAny(a.root, a.currentTarget.path) : isPath ? getAny(state, path) : olds;
124
+ const isEvPd = !!a?.target, isPath = !isEvPd && "string" === typeof b, [state, path, olds, news, opts, type] = isEvPd ? [a.root, a.currentTarget.path, a.currentTarget.oldValue, a.currentTarget.value, b || NIL, a.type] : isPath ? [a, b, getPath(a, b), c, d || NIL, void 0] : [void 0, void 0, a, b, c || NIL, void 0], target = isEvPd ? getPath(a.root, a.currentTarget.path) : isPath ? getPath(state, path) : olds;
129
125
  if (isEvPd && type !== "set" && type !== "delete" || !target || !canHandle(news, opts)) return;
130
126
  const prev = CTX.isCascading;
131
127
  CTX.isCascading = isEvPd;
@@ -141,7 +137,7 @@ function fanout(a, b, c, d) {
141
137
  }
142
138
  }
143
139
  };
144
- if ((opts.atomic ?? true) && Array.isArray(news) && isPath) setAny(state, path, news), getAny(state, path).length = news.length;
140
+ if ((opts.atomic ?? true) && Array.isArray(news) && isPath) setPath(state, path, news), getPath(state, path).length = news.length;
145
141
  else walk(target, opts.merge ? mergeObjs(olds, news, opts) : news, opts.depth === true ? Infinity : opts.depth);
146
142
  } finally {
147
143
  CTX.isCascading = prev;
@@ -216,11 +212,11 @@ export {
216
212
  isObj,
217
213
  isPOJO,
218
214
  canHandle,
219
- getAny,
220
- setAny,
221
- deleteAny,
222
- inAny,
223
- parseAnyObj,
215
+ getPath,
216
+ setPath,
217
+ deletePath,
218
+ hasPath,
219
+ parsePathObj,
224
220
  parseEvtOpts,
225
221
  fanout,
226
222
  fanoutOptsArr,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  wpArr
3
- } from "./chunk-GD7HZBXA.js";
3
+ } from "./chunk-VIDZLTP2.js";
4
4
  import {
5
5
  reactive
6
- } from "./chunk-AKQSBLBX.js";
6
+ } from "./chunk-T2CAL5F4.js";
7
7
  import {
8
8
  createEl,
9
9
  formatKeyForDisplay,
@@ -16,7 +16,7 @@ import {
16
16
  RAW,
17
17
  canHandle,
18
18
  nuke
19
- } from "./chunk-EZ4VRGYI.js";
19
+ } from "./chunk-4PLMBUCP.js";
20
20
 
21
21
  // src/ts/adapters/autotracker.ts
22
22
  var Autotracker = class {