@solidjs/signals 0.0.8 → 0.0.10

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.
@@ -7,8 +7,7 @@
7
7
  export declare const STATE_CLEAN = 0;
8
8
  export declare const STATE_CHECK = 1;
9
9
  export declare const STATE_DIRTY = 2;
10
- export declare const STATE_UNINITIALIZED = 3;
11
- export declare const STATE_DISPOSED = 4;
10
+ export declare const STATE_DISPOSED = 3;
12
11
  export declare const EFFECT_PURE = 0;
13
12
  export declare const EFFECT_RENDER = 1;
14
13
  export declare const EFFECT_USER = 2;
@@ -28,6 +28,7 @@
28
28
  */
29
29
  import { type Flags } from "./flags.js";
30
30
  import { Owner } from "./owner.js";
31
+ import { type IQueue } from "./scheduler.js";
31
32
  export interface SignalOptions<T> {
32
33
  name?: string;
33
34
  equals?: ((prev: T, next: T) => boolean) | false;
@@ -51,14 +52,13 @@ interface ObserverType {
51
52
  * Returns the current observer.
52
53
  */
53
54
  export declare function getObserver(): ObserverType | null;
54
- export declare function getClock(): number;
55
- export declare function incrementClock(): void;
56
55
  export declare const UNCHANGED: unique symbol;
57
56
  export type UNCHANGED = typeof UNCHANGED;
58
57
  export declare class Computation<T = any> extends Owner implements SourceType, ObserverType {
59
58
  _sources: SourceType[] | null;
60
59
  _observers: ObserverType[] | null;
61
60
  _value: T | undefined;
61
+ _error: unknown;
62
62
  _compute: null | ((p?: T) => T);
63
63
  _name: string | undefined;
64
64
  _equals: false | ((a: T, b: T) => boolean);
@@ -140,22 +140,19 @@ export declare function untrack<T>(fn: () => T): T;
140
140
  */
141
141
  export declare function hasUpdated(fn: () => any): boolean;
142
142
  /**
143
- * Returns true if the given function contains async signals that are not ready yet.
143
+ * Returns true if the given function contains async signals are out of date.
144
144
  */
145
- export declare function isPending(fn: () => any): boolean;
146
- export type PossiblyResolved<T> = T extends Object ? RecursivePartial<T> : T;
147
- export type RecursivePartial<T> = {
148
- [P in keyof T]?: PossiblyResolved<T[P]>;
149
- };
145
+ export declare function isStale(fn: () => any): boolean;
150
146
  /**
151
147
  * Attempts to resolve value of expression synchronously returning the last resolved value for any async computation.
152
148
  */
153
- export declare function resolveSync<T>(fn: () => T): PossiblyResolved<T> | undefined;
149
+ export declare function latest<T>(fn: () => T): T;
154
150
  export declare function catchError(fn: () => void): unknown | undefined;
155
151
  /**
156
152
  * A convenient wrapper that calls `compute` with the `owner` and `observer` and is guaranteed
157
153
  * to reset the global context after the computation is finished even if an error is thrown.
158
154
  */
159
- export declare function compute<T>(owner: Owner | null, compute: (val: T) => T, observer: Computation<T>): T;
160
- export declare function compute<T>(owner: Owner | null, compute: (val: undefined) => T, observer: null): T;
155
+ export declare function compute<T>(owner: Owner | null, fn: (val: T) => T, observer: Computation<T>): T;
156
+ export declare function compute<T>(owner: Owner | null, fn: (val: undefined) => T, observer: null): T;
157
+ export declare function createBoundary<T>(fn: () => T, queue: IQueue): T;
161
158
  export {};
@@ -1,6 +1,5 @@
1
1
  import { EFFECT_RENDER, EFFECT_USER } from "./constants.js";
2
2
  import { Computation, type SignalOptions } from "./core.js";
3
- import { type IQueue } from "./scheduler.js";
4
3
  /**
5
4
  * Effects are the leaf nodes of our reactive graph. When their sources change, they are
6
5
  * automatically added to the queue of effects to re-execute, which will cause them to fetch their
@@ -8,13 +7,12 @@ import { type IQueue } from "./scheduler.js";
8
7
  */
9
8
  export declare class Effect<T = any> extends Computation<T> {
10
9
  _effect: (val: T, prev: T | undefined) => void | (() => void);
11
- _error: ((err: unknown) => void | (() => void)) | undefined;
10
+ _onerror: ((err: unknown) => void | (() => void)) | undefined;
12
11
  _cleanup: (() => void) | undefined;
13
12
  _modified: boolean;
14
13
  _prevValue: T | undefined;
15
14
  _type: typeof EFFECT_RENDER | typeof EFFECT_USER;
16
- _queue: IQueue;
17
- constructor(initialValue: T, compute: () => T, effect: (val: T, prev: T | undefined) => void | (() => void), error?: (err: unknown) => void | (() => void), options?: SignalOptions<T> & {
15
+ constructor(initialValue: T, compute: (val?: T) => T, effect: (val: T, prev: T | undefined) => void | (() => void), error?: (err: unknown) => void | (() => void), options?: SignalOptions<T> & {
18
16
  render?: boolean;
19
17
  defer?: boolean;
20
18
  });
@@ -25,7 +23,12 @@ export declare class Effect<T = any> extends Computation<T> {
25
23
  _runEffect(): void;
26
24
  }
27
25
  export declare class EagerComputation<T = any> extends Computation<T> {
28
- _queue: IQueue;
29
- constructor(initialValue: T, compute: () => T, options?: SignalOptions<T>);
26
+ constructor(initialValue: T, compute: () => T, options?: SignalOptions<T> & {
27
+ defer?: boolean;
28
+ });
29
+ _notify(state: number, skipQueue?: boolean): void;
30
+ }
31
+ export declare class ProjectionComputation extends Computation {
32
+ constructor(compute: () => void);
30
33
  _notify(state: number, skipQueue?: boolean): void;
31
34
  }
@@ -1,3 +1,4 @@
1
+ import type { Owner } from "./owner.js";
1
2
  export declare class NotReadyError extends Error {
2
3
  }
3
4
  export declare class NoOwnerError extends Error {
@@ -10,5 +11,5 @@ export declare class EffectError extends Error {
10
11
  constructor(effect: Function, cause: unknown);
11
12
  }
12
13
  export interface ErrorHandler {
13
- (error: unknown): void;
14
+ (error: unknown, node: Owner): void;
14
15
  }
@@ -5,4 +5,7 @@ export declare const ERROR: unique symbol;
5
5
  export declare const LOADING_OFFSET = 1;
6
6
  export declare const LOADING_BIT: number;
7
7
  export declare const LOADING: unique symbol;
8
+ export declare const UNINITIALIZED_OFFSET = 2;
9
+ export declare const UNINITIALIZED_BIT: number;
10
+ export declare const UNINITIALIZED: unique symbol;
8
11
  export declare const DEFAULT_FLAGS: number;
@@ -1,8 +1,8 @@
1
1
  export { ContextNotFoundError, NoOwnerError, NotReadyError, type ErrorHandler } from "./error.js";
2
2
  export { Owner, createContext, getContext, setContext, hasContext, getOwner, onCleanup, type Context, type ContextRecord, type Disposable } from "./owner.js";
3
- export { Computation, getObserver, isEqual, untrack, getClock, hasUpdated, isPending, resolveSync, catchError, UNCHANGED, compute, type SignalOptions } from "./core.js";
3
+ export { Computation, createBoundary, getObserver, isEqual, untrack, hasUpdated, isStale, latest, catchError, UNCHANGED, compute, type SignalOptions } from "./core.js";
4
4
  export { Effect, EagerComputation } from "./effect.js";
5
- export { flushSync, createBoundary, type IQueue, Queue } from "./scheduler.js";
5
+ export { flushSync, getClock, incrementClock, type IQueue, Queue } from "./scheduler.js";
6
6
  export { createSuspense } from "./suspense.js";
7
7
  export { SUPPORTS_PROXY } from "./constants.js";
8
8
  export * from "./flags.js";
@@ -28,7 +28,7 @@
28
28
  * Note that the owner tree is largely orthogonal to the reactivity tree, and is much closer to the component tree.
29
29
  */
30
30
  import { type ErrorHandler } from "./error.js";
31
- import type { IQueue } from "./scheduler.js";
31
+ import { type IQueue } from "./scheduler.js";
32
32
  export type ContextRecord = Record<string | symbol, unknown>;
33
33
  export interface Disposable {
34
34
  (): void;
@@ -46,7 +46,7 @@ export declare class Owner {
46
46
  _disposal: Disposable | Disposable[] | null;
47
47
  _context: ContextRecord;
48
48
  _handlers: ErrorHandler[] | null;
49
- _queue: IQueue | null;
49
+ _queue: IQueue;
50
50
  constructor(signal?: boolean);
51
51
  append(child: Owner): void;
52
52
  dispose(this: Owner, self?: boolean): void;
@@ -1,5 +1,7 @@
1
- import { Computation } from "./core.js";
1
+ import type { Computation } from "./core.js";
2
2
  import type { Effect } from "./effect.js";
3
+ export declare function getClock(): number;
4
+ export declare function incrementClock(): void;
3
5
  export interface IQueue {
4
6
  enqueue<T extends Computation | Effect>(type: number, node: T): void;
5
7
  run(type: number): boolean | void;
@@ -23,4 +25,3 @@ export declare const globalQueue: Queue;
23
25
  * the queue synchronously to get the latest updates by calling `flushSync()`.
24
26
  */
25
27
  export declare function flushSync(): void;
26
- export declare function createBoundary<T>(fn: () => T, queue: IQueue): T;
@@ -1,4 +1,4 @@
1
- export { Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, createContext, flatten, flushSync, createBoundary, getContext, setContext, hasContext, getOwner, onCleanup, getObserver, isEqual, untrack, hasUpdated, isPending, resolveSync, catchError, createSuspense, SUPPORTS_PROXY } from "./core/index.js";
1
+ export { Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, createContext, flatten, flushSync, createBoundary, getContext, setContext, hasContext, getOwner, onCleanup, getObserver, isEqual, untrack, hasUpdated, isStale, latest, catchError, createSuspense, SUPPORTS_PROXY } from "./core/index.js";
2
2
  export type { ErrorHandler, SignalOptions, Context, ContextRecord, Disposable, IQueue } from "./core/index.js";
3
3
  export { mapArray, repeat, type Maybe } from "./map.js";
4
4
  export * from "./signals.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/signals",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",