@solidjs/signals 0.8.2 → 0.8.4

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.
@@ -12,7 +12,7 @@ export declare class CollectionQueue extends Queue {
12
12
  run(type: number): void;
13
13
  notify(node: Effect<any>, type: number, flags: number): boolean;
14
14
  }
15
- export declare enum BoundaryMode {
15
+ export declare const enum BoundaryMode {
16
16
  VISIBLE = "visible",
17
17
  HIDDEN = "hidden"
18
18
  }
@@ -1,23 +1,18 @@
1
- export declare const enum ReactiveFlags {
2
- None = 0,
3
- Check = 1,
4
- Dirty = 2,
5
- RecomputingDeps = 4,
6
- InHeap = 8,
7
- InHeapHeight = 16,
8
- Zombie = 32,
9
- Disposed = 64
10
- }
11
- export declare const enum StatusFlags {
12
- None = 0,
13
- Pending = 1,
14
- Error = 2,
15
- Uninitialized = 4
16
- }
17
- export declare const enum EffectType {
18
- Pure = 0,
19
- Render = 1,
20
- User = 2
21
- }
1
+ export declare const REACTIVE_NONE = 0;
2
+ export declare const REACTIVE_CHECK: number;
3
+ export declare const REACTIVE_DIRTY: number;
4
+ export declare const REACTIVE_RECOMPUTING_DEPS: number;
5
+ export declare const REACTIVE_IN_HEAP: number;
6
+ export declare const REACTIVE_IN_HEAP_HEIGHT: number;
7
+ export declare const REACTIVE_ZOMBIE: number;
8
+ export declare const REACTIVE_DISPOSED: number;
9
+ export declare const STATUS_NONE = 0;
10
+ export declare const STATUS_PENDING: number;
11
+ export declare const STATUS_ERROR: number;
12
+ export declare const STATUS_UNINITIALIZED: number;
13
+ export declare const EFFECT_PURE = 0;
14
+ export declare const EFFECT_RENDER = 1;
15
+ export declare const EFFECT_USER = 2;
22
16
  export declare const NOT_PENDING: {};
23
17
  export declare const SUPPORTS_PROXY: boolean;
18
+ export declare const defaultContext: {};
@@ -1,4 +1,4 @@
1
- import { NOT_PENDING, ReactiveFlags, StatusFlags } from "./constants.js";
1
+ import { NOT_PENDING } from "./constants.js";
2
2
  import { type IQueue, type Transition } from "./scheduler.js";
3
3
  export interface Disposable {
4
4
  (): void;
@@ -23,7 +23,7 @@ export interface RawSignal<T> {
23
23
  _subsTail: Link | null;
24
24
  _value: T;
25
25
  _error?: unknown;
26
- _statusFlags: StatusFlags;
26
+ _statusFlags: number;
27
27
  _name?: string;
28
28
  _equals: false | ((a: T, b: T) => boolean);
29
29
  _pureWrite?: boolean;
@@ -37,9 +37,10 @@ export interface RawSignal<T> {
37
37
  _set: (v: T) => void;
38
38
  };
39
39
  _transition?: Transition;
40
+ _optimistic?: boolean;
40
41
  }
41
42
  export interface FirewallSignal<T> extends RawSignal<T> {
42
- _owner: Computed<any>;
43
+ _firewall: Computed<any>;
43
44
  _nextChild: FirewallSignal<unknown> | null;
44
45
  }
45
46
  export type Signal<T> = RawSignal<T> | FirewallSignal<T>;
@@ -58,7 +59,7 @@ export interface Owner {
58
59
  export interface Computed<T> extends RawSignal<T>, Owner {
59
60
  _deps: Link | null;
60
61
  _depsTail: Link | null;
61
- _flags: ReactiveFlags;
62
+ _flags: number;
62
63
  _height: number;
63
64
  _nextHeap: Computed<any> | undefined;
64
65
  _prevHeap: Computed<any>;
@@ -71,7 +72,9 @@ export interface Root extends Owner {
71
72
  _parentComputed: Computed<any> | null;
72
73
  dispose(self?: boolean): void;
73
74
  }
75
+ export declare let context: Owner | null;
74
76
  export declare function recompute(el: Computed<any>, create?: boolean): void;
77
+ export declare function dispose(node: Computed<unknown>): void;
75
78
  export declare function getNextChildId(owner: Owner): string;
76
79
  export declare function computed<T>(fn: (prev?: T) => T): Computed<T>;
77
80
  export declare function computed<T>(fn: (prev: T) => T, initialValue?: T, options?: SignalOptions<T>): Computed<T>;
@@ -16,4 +16,3 @@ export declare function effect<T>(compute: (prev: T | undefined) => T, effect: (
16
16
  render?: boolean;
17
17
  defer?: boolean;
18
18
  }): void;
19
- export declare function runEffect(this: Effect<any>): void;
@@ -1,4 +1,3 @@
1
- import { ReactiveFlags } from "./constants.js";
2
1
  import type { Computed } from "./core.js";
3
2
  export interface Heap {
4
3
  _heap: (Computed<unknown> | undefined)[];
@@ -11,5 +10,5 @@ export declare function insertIntoHeap(n: Computed<any>, heap: Heap): void;
11
10
  export declare function insertIntoHeapHeight(n: Computed<unknown>, heap: Heap): void;
12
11
  export declare function deleteFromHeap(n: Computed<unknown>, heap: Heap): void;
13
12
  export declare function markHeap(heap: Heap): void;
14
- export declare function markNode(el: Computed<unknown>, newState?: ReactiveFlags): void;
13
+ export declare function markNode(el: Computed<unknown>, newState?: number): void;
15
14
  export declare function runHeap(heap: Heap, recompute: (el: Computed<unknown>) => void): void;
@@ -1,6 +1,6 @@
1
1
  export { ContextNotFoundError, NoOwnerError, NotReadyError } from "./error.js";
2
2
  export { createContext, getContext, setContext, type Context, type ContextRecord } from "./context.js";
3
- export { getObserver, isEqual, untrack, getOwner, runWithOwner, createOwner, createRoot, computed, signal, asyncComputed, read, setSignal, onCleanup, getNextChildId, isPending, pending, staleValues, type Owner, type Computed, type Root, type Signal, type SignalOptions } from "./core.js";
3
+ export { getObserver, isEqual, untrack, getOwner, runWithOwner, createOwner, createRoot, computed, dispose, signal, asyncComputed, read, setSignal, onCleanup, getNextChildId, isPending, pending, staleValues, type Owner, type Computed, type Root, type Signal, type SignalOptions } from "./core.js";
4
4
  export { effect, type Effect } from "./effect.js";
5
5
  export { flush, Queue, type IQueue, type QueueCallback } from "./scheduler.js";
6
6
  export * from "./constants.js";
@@ -1,8 +1,9 @@
1
1
  import type { Computed, Signal } from "./core.js";
2
2
  import { type Heap } from "./heap.js";
3
+ export declare const dirtyQueue: Heap;
4
+ export declare const zombieQueue: Heap;
3
5
  export declare let clock: number;
4
6
  export declare let activeTransition: Transition | null;
5
- export declare let unobserved: Signal<unknown>[];
6
7
  export type QueueCallback = (type: number) => void;
7
8
  type QueueStub = {
8
9
  _queues: [QueueCallback[], QueueCallback[]];
@@ -15,8 +16,6 @@ export interface Transition {
15
16
  queueStash: QueueStub;
16
17
  }
17
18
  export declare function schedule(): void;
18
- export declare const dirtyQueue: Heap;
19
- export declare const zombieQueue: Heap;
20
19
  export interface IQueue {
21
20
  enqueue(type: number, fn: QueueCallback): void;
22
21
  run(type: number): boolean | void;
@@ -56,5 +55,5 @@ export declare const globalQueue: GlobalQueue;
56
55
  * the queue synchronously to get the latest updates by calling `flush()`.
57
56
  */
58
57
  export declare function flush(): void;
59
- export declare function transitionComplete(transition: Transition): boolean;
58
+ export declare function runInTransition(el: Computed<unknown>, recompute: (el: Computed<unknown>) => void): void;
60
59
  export {};
@@ -149,7 +149,7 @@ export declare function createTrackedEffect(compute: () => void | (() => void),
149
149
  *
150
150
  * @description https://docs.solidjs.com/reference/secondary-primitives/create-reaction
151
151
  */
152
- export declare function createReaction(effect: EffectFunction<undefined> | EffectBundle<undefined>, options?: EffectOptions): void;
152
+ export declare function createReaction(effectFn: EffectFunction<undefined> | EffectBundle<undefined>, options?: EffectOptions): (tracking: () => void) => void;
153
153
  /**
154
154
  * Returns a promise of the resolved value of a reactive expression
155
155
  * @param fn a reactive expression to resolve
@@ -1,4 +1,4 @@
1
- import { type Signal } from "../core/index.js";
1
+ import { type Computed, type Signal } from "../core/index.js";
2
2
  export type Store<T> = Readonly<T>;
3
3
  export type StoreSetter<T> = (fn: (state: T) => T | void) => void;
4
4
  export type StoreOptions = {
@@ -8,7 +8,7 @@ export type StoreOptions = {
8
8
  type DataNode = Signal<any>;
9
9
  type DataNodes = Record<PropertyKey, DataNode>;
10
10
  export declare const $TRACK: unique symbol, $DEEP: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $DELETED: unique symbol;
11
- export declare const STORE_VALUE = "v", STORE_OVERRIDE = "o", STORE_NODE = "n", STORE_HAS = "h", STORE_WRAP = "w", STORE_LOOKUP = "l";
11
+ export declare const STORE_VALUE = "v", STORE_OVERRIDE = "o", STORE_NODE = "n", STORE_HAS = "h", STORE_WRAP = "w", STORE_LOOKUP = "l", STORE_FIREWALL = "f";
12
12
  export type StoreNode = {
13
13
  [$PROXY]: any;
14
14
  [STORE_VALUE]: Record<PropertyKey, any>;
@@ -17,6 +17,7 @@ export type StoreNode = {
17
17
  [STORE_HAS]?: DataNodes;
18
18
  [STORE_WRAP]?: (value: any, target?: StoreNode) => any;
19
19
  [STORE_LOOKUP]?: WeakMap<any, any>;
20
+ [STORE_FIREWALL]?: () => Computed<any>;
20
21
  };
21
22
  export declare namespace SolidStore {
22
23
  interface Unwrappable {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/signals",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
4
4
  "description": "",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
@@ -20,9 +20,14 @@
20
20
  ],
21
21
  "devDependencies": {
22
22
  "@ianvs/prettier-plugin-sort-imports": "^4.1.1",
23
+ "@rollup/plugin-replace": "^6.0.3",
24
+ "@rollup/plugin-terser": "^0.4.4",
25
+ "@rollup/plugin-typescript": "^12.3.0",
23
26
  "@types/node": "^20.5.1",
24
27
  "rimraf": "^5.0.1",
25
- "tsup": "^7.2.0",
28
+ "rollup": "^4.53.4",
29
+ "rollup-plugin-prettier": "^4.1.2",
30
+ "tslib": "^2.8.1",
26
31
  "typescript": "5.1.6",
27
32
  "vite": "^5.4.10",
28
33
  "vitest": "^2.0.0"
@@ -39,7 +44,7 @@
39
44
  }
40
45
  },
41
46
  "scripts": {
42
- "build": "rimraf dist && tsup && pnpm types",
47
+ "build": "rimraf dist && rollup -c && pnpm types",
43
48
  "types": "tsc -p tsconfig.build.json",
44
49
  "format": "prettier src tests --write --log-level warn",
45
50
  "sandbox": "node ./.sandbox/launch.js",