@zeix/cause-effect 0.16.0 → 0.17.0
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.
- package/.ai-context.md +71 -21
- package/.cursorrules +3 -2
- package/.github/copilot-instructions.md +59 -13
- package/CLAUDE.md +170 -24
- package/LICENSE +1 -1
- package/README.md +156 -52
- package/archive/benchmark.ts +688 -0
- package/archive/collection.ts +312 -0
- package/{src → archive}/computed.ts +33 -34
- package/archive/list.ts +551 -0
- package/archive/memo.ts +138 -0
- package/archive/state.ts +89 -0
- package/archive/store.ts +368 -0
- package/archive/task.ts +194 -0
- package/eslint.config.js +1 -0
- package/index.dev.js +902 -501
- package/index.js +1 -1
- package/index.ts +42 -22
- package/package.json +1 -1
- package/src/classes/collection.ts +272 -0
- package/src/classes/composite.ts +176 -0
- package/src/classes/computed.ts +333 -0
- package/src/classes/list.ts +304 -0
- package/src/classes/state.ts +98 -0
- package/src/classes/store.ts +210 -0
- package/src/diff.ts +28 -52
- package/src/effect.ts +9 -9
- package/src/errors.ts +50 -25
- package/src/signal.ts +58 -41
- package/src/system.ts +79 -42
- package/src/util.ts +16 -34
- package/test/batch.test.ts +15 -17
- package/test/benchmark.test.ts +4 -4
- package/test/collection.test.ts +796 -0
- package/test/computed.test.ts +138 -130
- package/test/diff.test.ts +2 -2
- package/test/effect.test.ts +36 -35
- package/test/list.test.ts +754 -0
- package/test/match.test.ts +25 -25
- package/test/resolve.test.ts +17 -19
- package/test/signal.test.ts +72 -121
- package/test/state.test.ts +44 -44
- package/test/store.test.ts +344 -1663
- package/types/index.d.ts +11 -9
- package/types/src/classes/collection.d.ts +32 -0
- package/types/src/classes/composite.d.ts +15 -0
- package/types/src/classes/computed.d.ts +97 -0
- package/types/src/classes/list.d.ts +41 -0
- package/types/src/classes/state.d.ts +52 -0
- package/types/src/classes/store.d.ts +51 -0
- package/types/src/diff.d.ts +8 -12
- package/types/src/errors.d.ts +12 -11
- package/types/src/signal.d.ts +27 -14
- package/types/src/system.d.ts +41 -20
- package/types/src/util.d.ts +6 -3
- package/src/state.ts +0 -98
- package/src/store.ts +0 -525
- package/types/src/collection.d.ts +0 -26
- package/types/src/computed.d.ts +0 -33
- package/types/src/scheduler.d.ts +0 -55
- package/types/src/state.d.ts +0 -24
- package/types/src/store.d.ts +0 -66
package/types/src/store.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { type UnknownArray, type UnknownRecord, type UnknownRecordOrArray } from './diff';
|
|
2
|
-
import { type State } from './state';
|
|
3
|
-
import { type Cleanup } from './system';
|
|
4
|
-
type ArrayItem<T> = T extends readonly (infer U extends {})[] ? U : never;
|
|
5
|
-
type StoreChanges<T> = {
|
|
6
|
-
add: Partial<T>;
|
|
7
|
-
change: Partial<T>;
|
|
8
|
-
remove: Partial<T>;
|
|
9
|
-
sort: string[];
|
|
10
|
-
};
|
|
11
|
-
interface BaseStore {
|
|
12
|
-
readonly [Symbol.toStringTag]: 'Store';
|
|
13
|
-
readonly size: State<number>;
|
|
14
|
-
}
|
|
15
|
-
type RecordStore<T extends UnknownRecord> = BaseStore & {
|
|
16
|
-
[K in keyof T]: T[K] extends readonly unknown[] | Record<string, unknown> ? Store<T[K]> : State<T[K]>;
|
|
17
|
-
} & {
|
|
18
|
-
[Symbol.iterator](): IterableIterator<[
|
|
19
|
-
Extract<keyof T, string>,
|
|
20
|
-
T[Extract<keyof T, string>] extends readonly unknown[] | Record<string, unknown> ? Store<T[Extract<keyof T, string>]> : State<T[Extract<keyof T, string>]>
|
|
21
|
-
]>;
|
|
22
|
-
add<K extends Extract<keyof T, string>>(key: K, value: T[K]): void;
|
|
23
|
-
get(): T;
|
|
24
|
-
set(value: T): void;
|
|
25
|
-
update(fn: (value: T) => T): void;
|
|
26
|
-
sort<U = T[Extract<keyof T, string>]>(compareFn?: (a: U, b: U) => number): void;
|
|
27
|
-
on<K extends keyof StoreChanges<T>>(type: K, listener: (change: StoreChanges<T>[K]) => void): Cleanup;
|
|
28
|
-
remove<K extends Extract<keyof T, string>>(key: K): void;
|
|
29
|
-
};
|
|
30
|
-
type ArrayStore<T extends UnknownArray> = BaseStore & {
|
|
31
|
-
[Symbol.iterator](): IterableIterator<ArrayItem<T> extends readonly unknown[] | Record<string, unknown> ? Store<ArrayItem<T>> : State<ArrayItem<T>>>;
|
|
32
|
-
readonly [Symbol.isConcatSpreadable]: boolean;
|
|
33
|
-
[n: number]: ArrayItem<T> extends readonly unknown[] | Record<string, unknown> ? Store<ArrayItem<T>> : State<ArrayItem<T>>;
|
|
34
|
-
add(value: ArrayItem<T>): void;
|
|
35
|
-
get(): T;
|
|
36
|
-
set(value: T): void;
|
|
37
|
-
update(fn: (value: T) => T): void;
|
|
38
|
-
sort<U = ArrayItem<T>>(compareFn?: (a: U, b: U) => number): void;
|
|
39
|
-
on<K extends keyof StoreChanges<T>>(type: K, listener: (change: StoreChanges<T>[K]) => void): Cleanup;
|
|
40
|
-
remove(index: number): void;
|
|
41
|
-
readonly length: number;
|
|
42
|
-
};
|
|
43
|
-
type Store<T extends UnknownRecord | UnknownArray> = T extends UnknownRecord ? RecordStore<T> : T extends UnknownArray ? ArrayStore<T> : never;
|
|
44
|
-
declare const TYPE_STORE = "Store";
|
|
45
|
-
/**
|
|
46
|
-
* Create a new store with deeply nested reactive properties
|
|
47
|
-
*
|
|
48
|
-
* Supports both objects and arrays as initial values. Arrays are converted
|
|
49
|
-
* to records internally for storage but maintain their array type through
|
|
50
|
-
* the .get() method, which automatically converts objects with consecutive
|
|
51
|
-
* numeric keys back to arrays.
|
|
52
|
-
*
|
|
53
|
-
* @since 0.15.0
|
|
54
|
-
* @param {T} initialValue - initial object or array value of the store
|
|
55
|
-
* @returns {Store<T>} - new store with reactive properties that preserves the original type T
|
|
56
|
-
*/
|
|
57
|
-
declare const createStore: <T extends UnknownRecord | UnknownArray>(initialValue: T) => Store<T>;
|
|
58
|
-
/**
|
|
59
|
-
* Check if the provided value is a Store instance
|
|
60
|
-
*
|
|
61
|
-
* @since 0.15.0
|
|
62
|
-
* @param {unknown} value - value to check
|
|
63
|
-
* @returns {boolean} - true if the value is a Store instance, false otherwise
|
|
64
|
-
*/
|
|
65
|
-
declare const isStore: <T extends UnknownRecordOrArray>(value: unknown) => value is Store<T>;
|
|
66
|
-
export { TYPE_STORE, isStore, createStore, type Store, type StoreChanges };
|