@estjs/signals 0.0.15-beta.8 → 0.0.15

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.
@@ -125,11 +125,17 @@ interface Link {
125
125
  * Examples: Effect, Computed
126
126
  */
127
127
  subNode: ReactiveNode;
128
- /** Previous subscriber Link */
128
+ /**
129
+ * Connects multiple subscribers of the same depNode.
130
+ * Previous subscriber Link
131
+ */
129
132
  prevSubLink?: Link;
130
133
  /** Next subscriber Link */
131
134
  nextSubLink?: Link;
132
- /** Previous dependency Link */
135
+ /**
136
+ * Connects multiple dependencies of the same subNode.
137
+ * Previous dependency Link
138
+ */
133
139
  prevDepLink?: Link;
134
140
  /** Next dependency Link */
135
141
  nextDepLink?: Link;
@@ -210,13 +216,8 @@ interface ReactiveNode {
210
216
  * @see ReactiveFlags
211
217
  */
212
218
  flag: ReactiveFlags;
213
- /**
214
- * Optional debugging hook called when dependencies are tracked
215
- */
219
+ _triggerVersion?: number;
216
220
  onTrack?: (event: DebuggerEvent) => void;
217
- /**
218
- * Optional debugging hook called when reactive changes are triggered
219
- */
220
221
  onTrigger?: (event: DebuggerEvent) => void;
221
222
  }
222
223
  /**
@@ -348,6 +349,7 @@ type SignalType<T> = T extends Signal<infer V> ? V : never;
348
349
  * const empty = signal(); // undefined
349
350
  * ```
350
351
  */
352
+ declare function signal<T>(value: Signal<T>): Signal<T>;
351
353
  declare function signal<T>(value?: T): Signal<T>;
352
354
  /**
353
355
  * Create a new shallow signal with the given initial value.
@@ -473,7 +475,7 @@ declare class ComputedImpl<T = any> implements Computed<T>, ReactiveNode {
473
475
  /**
474
476
  * Recompute the value
475
477
  *
476
- * computation logic:
478
+ * computation logic:
477
479
  * 1. Start tracking dependencies
478
480
  * 2. Execute getter function
479
481
  * 3. Check if value changed using optimized comparison
@@ -616,8 +618,9 @@ type FlushTiming = 'pre' | 'post' | 'sync';
616
618
  /**
617
619
  * Schedules a function to be executed in the next microtask
618
620
  *
619
- * If no function is provided, returns a Promise that resolves in the next microtask.
620
- * This is useful for waiting until the DOM is update or deferring execution.
621
+ * Returns a Promise that resolves in the next microtask.
622
+ * Passing fn chains it onto the shared resolved promise cheaper than
623
+ * constructing a new Promise + queueMicrotask pair.
621
624
  *
622
625
  * @param fn - Optional function to execute
623
626
  * @returns A Promise that resolves after the function execution
@@ -748,12 +751,11 @@ declare class EffectImpl<T = any> implements ReactiveNode {
748
751
  flag: ReactiveFlags;
749
752
  private readonly [SignalFlags.IS_EFFECT];
750
753
  readonly fn: EffectFunction<T>;
751
- readonly scheduler?: EffectScheduler | FlushTiming;
752
- readonly onStop?: () => void;
753
- readonly onTrack?: (event: DebuggerEvent) => void;
754
- readonly onTrigger?: (event: DebuggerEvent) => void;
755
- readonly flash?: 'sync' | 'pre' | 'post';
756
- private _active;
754
+ private _flushScheduler?;
755
+ _active: boolean;
756
+ onTrack?: (event: DebuggerEvent) => void;
757
+ onTrigger?: (event: DebuggerEvent) => void;
758
+ onStop?: () => void;
757
759
  /**
758
760
  * Create an Effect instance
759
761
  *
@@ -767,7 +769,6 @@ declare class EffectImpl<T = any> implements ReactiveNode {
767
769
  get active(): boolean;
768
770
  /**
769
771
  * Check if the Effect is dirty (needs re-execution)
770
-
771
772
  */
772
773
  get dirty(): boolean;
773
774
  /**
@@ -1203,6 +1204,7 @@ interface WatchOptions {
1203
1204
  immediate?: boolean;
1204
1205
  deep?: boolean;
1205
1206
  }
1207
+ /** Watch source type, can be value, ref/signal, getter function or array. */
1206
1208
  type WatchSource<T = any> = T | {
1207
1209
  value: T;
1208
1210
  } | (() => T);
package/dist/signals.d.ts CHANGED
@@ -125,11 +125,17 @@ interface Link {
125
125
  * Examples: Effect, Computed
126
126
  */
127
127
  subNode: ReactiveNode;
128
- /** Previous subscriber Link */
128
+ /**
129
+ * Connects multiple subscribers of the same depNode.
130
+ * Previous subscriber Link
131
+ */
129
132
  prevSubLink?: Link;
130
133
  /** Next subscriber Link */
131
134
  nextSubLink?: Link;
132
- /** Previous dependency Link */
135
+ /**
136
+ * Connects multiple dependencies of the same subNode.
137
+ * Previous dependency Link
138
+ */
133
139
  prevDepLink?: Link;
134
140
  /** Next dependency Link */
135
141
  nextDepLink?: Link;
@@ -210,13 +216,8 @@ interface ReactiveNode {
210
216
  * @see ReactiveFlags
211
217
  */
212
218
  flag: ReactiveFlags;
213
- /**
214
- * Optional debugging hook called when dependencies are tracked
215
- */
219
+ _triggerVersion?: number;
216
220
  onTrack?: (event: DebuggerEvent) => void;
217
- /**
218
- * Optional debugging hook called when reactive changes are triggered
219
- */
220
221
  onTrigger?: (event: DebuggerEvent) => void;
221
222
  }
222
223
  /**
@@ -348,6 +349,7 @@ type SignalType<T> = T extends Signal<infer V> ? V : never;
348
349
  * const empty = signal(); // undefined
349
350
  * ```
350
351
  */
352
+ declare function signal<T>(value: Signal<T>): Signal<T>;
351
353
  declare function signal<T>(value?: T): Signal<T>;
352
354
  /**
353
355
  * Create a new shallow signal with the given initial value.
@@ -473,7 +475,7 @@ declare class ComputedImpl<T = any> implements Computed<T>, ReactiveNode {
473
475
  /**
474
476
  * Recompute the value
475
477
  *
476
- * computation logic:
478
+ * computation logic:
477
479
  * 1. Start tracking dependencies
478
480
  * 2. Execute getter function
479
481
  * 3. Check if value changed using optimized comparison
@@ -616,8 +618,9 @@ type FlushTiming = 'pre' | 'post' | 'sync';
616
618
  /**
617
619
  * Schedules a function to be executed in the next microtask
618
620
  *
619
- * If no function is provided, returns a Promise that resolves in the next microtask.
620
- * This is useful for waiting until the DOM is update or deferring execution.
621
+ * Returns a Promise that resolves in the next microtask.
622
+ * Passing fn chains it onto the shared resolved promise cheaper than
623
+ * constructing a new Promise + queueMicrotask pair.
621
624
  *
622
625
  * @param fn - Optional function to execute
623
626
  * @returns A Promise that resolves after the function execution
@@ -748,12 +751,11 @@ declare class EffectImpl<T = any> implements ReactiveNode {
748
751
  flag: ReactiveFlags;
749
752
  private readonly [SignalFlags.IS_EFFECT];
750
753
  readonly fn: EffectFunction<T>;
751
- readonly scheduler?: EffectScheduler | FlushTiming;
752
- readonly onStop?: () => void;
753
- readonly onTrack?: (event: DebuggerEvent) => void;
754
- readonly onTrigger?: (event: DebuggerEvent) => void;
755
- readonly flash?: 'sync' | 'pre' | 'post';
756
- private _active;
754
+ private _flushScheduler?;
755
+ _active: boolean;
756
+ onTrack?: (event: DebuggerEvent) => void;
757
+ onTrigger?: (event: DebuggerEvent) => void;
758
+ onStop?: () => void;
757
759
  /**
758
760
  * Create an Effect instance
759
761
  *
@@ -767,7 +769,6 @@ declare class EffectImpl<T = any> implements ReactiveNode {
767
769
  get active(): boolean;
768
770
  /**
769
771
  * Check if the Effect is dirty (needs re-execution)
770
-
771
772
  */
772
773
  get dirty(): boolean;
773
774
  /**
@@ -1203,6 +1204,7 @@ interface WatchOptions {
1203
1204
  immediate?: boolean;
1204
1205
  deep?: boolean;
1205
1206
  }
1207
+ /** Watch source type, can be value, ref/signal, getter function or array. */
1206
1208
  type WatchSource<T = any> = T | {
1207
1209
  value: T;
1208
1210
  } | (() => T);