@xaendar/signals 0.9.22 → 0.9.23

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.
@@ -192,200 +192,6 @@ declare global {
192
192
 
193
193
  export { };
194
194
 
195
- declare global {
196
- namespace Signal {
197
- /**
198
- * A mutable Signal that holds a value and notifies dependents when it changes.
199
- *
200
- * @template T The type of the value held by this Signal.
201
- */
202
- class State<T = any> {
203
- /**
204
- * Creates a new `State` signal.
205
- *
206
- * @param initialValue - The initial value of the signal.
207
- * @param options - Optional configuration:
208
- * - `equals` — custom equality function; defaults to `Object.is`.
209
- * - `watched` — called when the signal gains its first sink.
210
- * - `unwatched` — called when the signal loses its last sink.
211
- */
212
- constructor(value: T, options?: { equals?: (a: T, b: T) => boolean, watched?: () => void, unwatched?: () => void });
213
- /**
214
- * Returns the current value of the signal, registering this Signal as a
215
- * source of the innermost `Computed` currently being evaluated (if any).
216
- *
217
- * @throws If `frozen` is `true` — reads are forbidden while a protected
218
- * callback (`notify`, `watched`, `unwatched`) is executing.
219
- */
220
- get(): T;
221
- /**
222
- * Updates the signal's value and propagates changes to all dependent
223
- * sinks.
224
- *
225
- * If `equals(currentValue, newValue)` returns `true` the call is a no-op
226
- * and no propagation occurs. Otherwise the value is updated, all direct
227
- * `Computed` sinks are marked dirty, indirect ones checked, and
228
- * each reachable `Watcher` has its `notify` callback invoked synchronously
229
- * (with `frozen = true`).
230
- *
231
- * @param newValue - The new value to set.
232
- * @throws If `frozen` is `true` — writes are forbidden while a protected
233
- * callback is executing.
234
- */
235
- set(newValue: T): void;
236
- }
237
-
238
- /**
239
- * A read-only Signal whose value is derived lazily from other Signals.
240
- *
241
- * The value is recomputed only when explicitly read and only if one or more
242
- * of its (recursive) dependencies have changed since the last evaluation.
243
- * The result is cached and reused until the Signal becomes stale again.
244
- *
245
- * @template T The type of the computed value.
246
- */
247
- class Computed<T = any> {
248
- /**
249
- * Creates a new `Computed` signal.
250
- *
251
- * The Signal starts in the dirty state with an uninitialised value, so
252
- * the callback will be invoked on the first `get()`.
253
- *
254
- * @param computeFn - Pure function evaluated lazily to produce the value.
255
- * @param options - Optional configuration:
256
- * - `equals` — custom equality function; defaults to `Object.is`.
257
- */
258
- constructor(computeFn: () => T, options?: { equals?: (a: T, b: T) => boolean, watched?: () => void, unwatched?: () => void });
259
- /**
260
- * Returns the current value of this Signal, re-evaluating the callback if
261
- * the cached value may be stale.
262
- *
263
- * Registers this Signal as a source of any outer `Computed` currently
264
- * being evaluated (automatic dependency tracking).
265
- *
266
- * @returns The current computed value, or a boxed error object if the last
267
- * evaluation threw.
268
- * @throws If `frozen` is `true`.
269
- * @throws If the Signal is in the computing state (cyclic dependency).
270
- */
271
- get(): T | { isError: true, value: Error };
272
- }
273
-
274
- namespace subtle {
275
- /**
276
- * Executes a function without tracking any dependencies.
277
- * @param fn - The function to execute without tracking.
278
- * @returns The result of the function execution.
279
- */
280
- function untrack<T>(fn: () => T): T;
281
- /**
282
- * Returns the currently active `Computed` instance being evaluated, or `null`.
283
- * @returns The currently active `Computed` instance, or `null` if none is being evaluated.
284
- */
285
- function currentComputed(): Computed | null;
286
- /**
287
- * Returns the ordered list of all Signals which the given `Computed` or
288
- * `Watcher` referenced during its last evaluation.
289
- *
290
- * - For a `Computed`, these are the Signals read inside its callback.
291
- * - For a `Watcher`, these are the Signals it is currently watching.
292
- *
293
- * @param s - The `Computed` or `Watcher` to introspect.
294
- * @returns An array of `State` and `Computed` instances.
295
- */
296
- function introspectSources(s: Computed | Watcher): (State | Computed)[];
297
- /**
298
- * Returns the direct dependents of the given Signal — Watchers that contain
299
- * it, plus any `Computed` Signals which read it during their last evaluation
300
- * (if that `Computed` is recursively watched).
301
- *
302
- * @param signal - The `State` or `Computed` Signal to introspect.
303
- * @returns An array of `Computed` and `Watcher` instances.
304
- */
305
- function introspectSinks(signal: State | Computed): (Computed | Watcher)[];
306
- /**
307
- * Returns `true` if the given Signal is 'live' — i.e. it is watched by a
308
- * `Watcher`, or it is read by a `Computed` Signal which is (recursively)
309
- * live.
310
- *
311
- * @param signal - The `State` or `Computed` Signal to check.
312
- * @returns `true` if the Signal has at least one sink.
313
- */
314
- function hasSinks(signal: State | Computed): boolean;
315
- /**
316
- * Returns `true` if the given node is 'reactive' — i.e. it depends on some
317
- * other Signal. A `Computed` where `hasSources` is `false` will always
318
- * return the same constant.
319
- *
320
- * @param s - The `Computed` or `Watcher` to check.
321
- * @returns `true` if the node has at least one source.
322
- */
323
- function hasSources(s: Computed | Watcher): boolean;
324
-
325
- /**
326
- * A `Watcher` observes a set of Signals and fires a `notify` callback
327
- * synchronously when any of their (recursive) dependencies change.
328
- *
329
- * It is the low-level primitive on top of which frameworks implement
330
- * effects and scheduling. It does not hold a value and has no generic
331
- * type parameter.
332
- */
333
- class Watcher {
334
- /**
335
- * Creates a new Watcher.
336
- *
337
- * The Watcher starts in the waiting state with an empty signals set.
338
- *
339
- * @param notify - Called synchronously (with `frozen = true`) the
340
- * first time a watched dependency changes after each `watch` call. No
341
- * Signals may be read or written inside this callback.
342
- */
343
- constructor(notify: () => void);
344
- /**
345
- * Adds the given Signals to the watched set and transitions the Watcher to
346
- * the watching state.
347
- *
348
- * For each newly-watched Signal, the Watcher is registered as a sink and —
349
- * if it is the first sink — the sink registration is propagated recursively
350
- * up through the Signal's sources, building the live dependency chain.
351
- *
352
- * @param signals - One or more Signals to start watching.
353
- * @throws If `frozen` is `true` at the time of the call.
354
- */
355
- watch(...signals: (State | Computed)[]): void;
356
- /**
357
- * Removes the given Signals from the watched set.
358
- *
359
- * For each removed Signal, the Watcher is unregistered as a sink. If the
360
- * Signal's sink set becomes empty as a result, the removal is propagated
361
- * recursively up through its sources, tearing down the live dependency
362
- * chain and allowing garbage collection of unwatched nodes.
363
- *
364
- * @param signals - One or more Signals to stop watching.
365
- * @throws If `frozen` is `true` at the time of the call.
366
- * @throws If any of the given Signals is not currently being watched.
367
- */
368
- unwatch(...signals: (State | Computed)[]): void;
369
- /**
370
- * Returns the subset of watched Signals that are `Computed` instances
371
- * currently in a `~dirty~` or `~checked~` state, meaning they may have a
372
- * stale value that has not yet been re-evaluated.
373
- *
374
- * Typically called inside the microtask scheduled by the `notify` callback
375
- * to know which Signals need to be pulled.
376
- *
377
- * @returns An array of `Computed` signals that are dirty or checked.
378
- *
379
- * @see Signal algorithms — 'Method: Signal.subtle.Watcher.prototype.getPending()'
380
- */
381
- getPending(): Computed<unknown>[];
382
- }
383
- }
384
- }
385
- }
386
-
387
- export { };
388
-
389
195
  import { NoArgsVoidFunction } from '@xaendar/types';
390
196
  import { NoArgsVoidFunction as NoArgsVoidFunction_2 } from '@xaendar/types';
391
197