@solidjs/signals 0.6.2 → 0.6.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.
@@ -6,7 +6,7 @@ export declare class CollectionQueue extends Queue {
6
6
  _disabled: Computation<boolean>;
7
7
  constructor(type: number);
8
8
  run(type: number): void;
9
- notify(node: Effect, type: number, flags: number): any;
9
+ notify(node: Effect, type: number, flags: number): boolean;
10
10
  merge(queue: CollectionQueue): void;
11
11
  }
12
12
  export declare enum BoundaryMode {
@@ -77,6 +77,7 @@ export declare class Computation<T = any> extends Owner implements SourceType, O
77
77
  _forceNotify: boolean;
78
78
  _transition?: Transition | undefined;
79
79
  _cloned?: Computation;
80
+ _optimistic?: boolean;
80
81
  constructor(initialValue: T | undefined, compute: null | ((p?: T) => T), options?: SignalOptions<T>);
81
82
  _read(): T;
82
83
  /**
@@ -79,7 +79,7 @@ export declare class Transition implements IQueue {
79
79
  * @description https://docs.solidjs.com/reference/advanced-reactivity/transition
80
80
  */
81
81
  export declare function transition(fn: (resume: (fn: () => any | Promise<any>) => void) => any | Promise<any> | Iterable<any>): void;
82
- export declare function cloneGraph(node: Computation): Computation;
82
+ export declare function cloneGraph(node: Computation, optimistic?: boolean): Computation;
83
83
  export declare function getOGSource<T extends Computation>(input: T): T;
84
84
  export declare function getTransitionSource<T extends Computation>(input: T): T;
85
85
  export declare function getQueue(node: Computation): IQueue;
@@ -1,6 +1,5 @@
1
1
  import type { SignalOptions } from "./core/index.js";
2
2
  import { Owner } from "./core/index.js";
3
- import { type Store, type StoreSetter } from "./store/index.js";
4
3
  export type Accessor<T> = () => T;
5
4
  export type Setter<in out T> = {
6
5
  <U extends T>(...args: undefined extends T ? [] : [value: Exclude<U, Function> | ((prev: T) => U)]): undefined extends T ? undefined : U;
@@ -157,24 +156,3 @@ export declare function useTransition(): [
157
156
  get: Accessor<boolean>,
158
157
  start: (fn: (resume: (fn: () => any | Promise<any>) => void) => any | Promise<any> | Iterable<any>) => void
159
158
  ];
160
- /**
161
- * Creates an optimistic store that can be used to optimistically update a value
162
- * and then revert it back to the previous value at end of transition.
163
- * ```typescript
164
- * export function createOptimistic<T>(
165
- * fn: (store: T) => void,
166
- * initial: T,
167
- * options?: { key?: string | ((item: NonNullable<any>) => any); all?: boolean }
168
- * ): [get: Store<T>, set: StoreSetter<T>];
169
- * ```
170
- * @param fn a function that receives the current store and can be used to mutate it directly inside a transition
171
- * @param initial The initial value of the signal.
172
- * @param options Optional signal options.
173
- *
174
- * @returns A tuple containing an accessor for the current value and a setter function to apply changes.
175
- */
176
- export declare function createOptimistic<T extends object = {}>(initial: T | Store<T>): [get: Store<T>, set: StoreSetter<T>];
177
- export declare function createOptimistic<T extends object = {}>(fn: (store: T) => void, initial: T | Store<T>, options?: {
178
- key?: string | ((item: NonNullable<any>) => any);
179
- all?: boolean;
180
- }): [get: Store<T>, set: StoreSetter<T>];
@@ -2,5 +2,6 @@ export type { Store, StoreSetter, StoreNode, NotWrappable, SolidStore } from "./
2
2
  export type { Merge, Omit } from "./utils.js";
3
3
  export { isWrappable, createStore, deep, $TRACK, $PROXY, $TARGET } from "./store.js";
4
4
  export { createProjection } from "./projection.js";
5
+ export { createOptimistic } from "./optimistic.js";
5
6
  export { reconcile } from "./reconcile.js";
6
7
  export { snapshot, merge, omit } from "./utils.js";
@@ -0,0 +1,22 @@
1
+ import { type Store, type StoreSetter } from "./store.js";
2
+ /**
3
+ * Creates an optimistic store that can be used to optimistically update a value
4
+ * and then revert it back to the previous value at end of transition.
5
+ * ```typescript
6
+ * export function createOptimistic<T>(
7
+ * fn: (store: T) => void,
8
+ * initial: T,
9
+ * options?: { key?: string | ((item: NonNullable<any>) => any); all?: boolean }
10
+ * ): [get: Store<T>, set: StoreSetter<T>];
11
+ * ```
12
+ * @param fn a function that receives the current store and can be used to mutate it directly inside a transition
13
+ * @param initial The initial value of the signal.
14
+ * @param options Optional signal options.
15
+ *
16
+ * @returns A tuple containing an accessor for the current value and a setter function to apply changes.
17
+ */
18
+ export declare function createOptimistic<T extends object = {}>(initial: T | Store<T>): [get: Store<T>, set: StoreSetter<T>];
19
+ export declare function createOptimistic<T extends object = {}>(fn: (store: T) => T | void, initial: T | Store<T>, options?: {
20
+ key?: string | ((item: NonNullable<any>) => any);
21
+ all?: boolean;
22
+ }): [get: Store<T>, set: StoreSetter<T>];
@@ -1,7 +1,12 @@
1
+ import { FirewallComputation } from "../core/effect.js";
1
2
  import { type Store, type StoreOptions } from "./store.js";
3
+ export declare function createProjectionInternal<T extends object = {}>(fn: (draft: T) => void | T, initialValue?: T, options?: StoreOptions): {
4
+ store: Readonly<T>;
5
+ node: FirewallComputation;
6
+ };
2
7
  /**
3
8
  * Creates a mutable derived value
4
9
  *
5
10
  * @see {@link https://github.com/solidjs/x-reactivity#createprojection}
6
11
  */
7
- export declare function createProjection<T extends Object>(fn: (draft: T) => void | T, initialValue?: T, options?: StoreOptions): Store<T>;
12
+ export declare function createProjection<T extends Object = {}>(fn: (draft: T) => void | T, initialValue?: T, options?: StoreOptions): Store<T>;
@@ -32,6 +32,6 @@ export declare function getPropertyDescriptor(source: Record<PropertyKey, any>,
32
32
  export declare const storeTraps: ProxyHandler<StoreNode>;
33
33
  export declare function storeSetter<T extends object>(store: Store<T>, fn: (draft: T) => T | void): void;
34
34
  export declare function createStore<T extends object = {}>(store: T | Store<T>): [get: Store<T>, set: StoreSetter<T>];
35
- export declare function createStore<T extends object = {}>(fn: (store: T) => void, store: T | Store<T>, options?: StoreOptions): [get: Store<T>, set: StoreSetter<T>];
35
+ export declare function createStore<T extends object = {}>(fn: (store: T) => void | T, store: T | Store<T>, options?: StoreOptions): [get: Store<T>, set: StoreSetter<T>];
36
36
  export declare function deep<T extends object>(store: Store<T>): Store<T>;
37
37
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/signals",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",