@oscarpalmer/mora 0.21.0 → 0.22.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/dist/batch.js +11 -24
- package/dist/effect.js +17 -26
- package/dist/helpers/is.js +14 -21
- package/dist/helpers/proxy.js +34 -47
- package/dist/helpers/value.js +20 -46
- package/dist/index.js +4 -17
- package/dist/subscription.js +20 -28
- package/dist/value/array.js +94 -179
- package/dist/value/computed.js +34 -56
- package/dist/value/reactive.js +29 -53
- package/dist/value/signal.js +20 -32
- package/dist/value/store.js +30 -59
- package/package.json +12 -18
- package/src/helpers/value.ts +1 -1
- package/src/index.ts +0 -1
- package/src/value/array.ts +1 -1
- package/dist/batch.cjs +0 -32
- package/dist/effect.cjs +0 -30
- package/dist/helpers/is.cjs +0 -40
- package/dist/helpers/proxy.cjs +0 -56
- package/dist/helpers/value.cjs +0 -54
- package/dist/index.cjs +0 -21
- package/dist/node_modules/@oscarpalmer/atoms/dist/internal/is.cjs +0 -17
- package/dist/node_modules/@oscarpalmer/atoms/dist/internal/is.js +0 -17
- package/dist/subscription.cjs +0 -32
- package/dist/value/array.cjs +0 -187
- package/dist/value/computed.cjs +0 -60
- package/dist/value/reactive.cjs +0 -55
- package/dist/value/signal.cjs +0 -36
- package/dist/value/store.cjs +0 -63
- package/types/batch.d.cts +0 -79
- package/types/effect.d.cts +0 -16
- package/types/helpers/is.d.cts +0 -259
- package/types/helpers/proxy.d.cts +0 -244
- package/types/helpers/value.d.cts +0 -71
- package/types/index.d.cts +0 -281
- package/types/subscription.d.cts +0 -71
- package/types/value/array.d.cts +0 -161
- package/types/value/computed.d.cts +0 -81
- package/types/value/reactive.d.cts +0 -68
- package/types/value/signal.d.cts +0 -87
- package/types/value/store.d.cts +0 -136
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A generic array or object
|
|
5
|
-
*/
|
|
6
|
-
export type ArrayOrPlainObject = unknown[] | Record<PropertyKey, unknown>;
|
|
7
|
-
export type GenericCallback = (...args: any[]) => any;
|
|
8
|
-
/**
|
|
9
|
-
* A useful key type
|
|
10
|
-
*/
|
|
11
|
-
export type Key = number | string;
|
|
12
|
-
/**
|
|
13
|
-
* A generic object
|
|
14
|
-
*/
|
|
15
|
-
export type PlainObject = Record<PropertyKey, unknown>;
|
|
16
|
-
declare class Effect {
|
|
17
|
-
private readonly $mora;
|
|
18
|
-
private readonly state;
|
|
19
|
-
constructor(callback: GenericCallback);
|
|
20
|
-
}
|
|
21
|
-
declare class Computed<Value> extends Reactive<Value> {
|
|
22
|
-
private readonly effect;
|
|
23
|
-
constructor(callback: () => Value, options?: ReactiveOptions<Value>);
|
|
24
|
-
/**
|
|
25
|
-
* @inheritdoc
|
|
26
|
-
*/
|
|
27
|
-
get(): Value;
|
|
28
|
-
}
|
|
29
|
-
declare abstract class Reactive<Value, Equal = Value> {
|
|
30
|
-
protected readonly state: ReactiveState<Value, Equal>;
|
|
31
|
-
constructor(name: string, value: Value, options?: ReactiveOptions<Equal>);
|
|
32
|
-
/**
|
|
33
|
-
* Get the value
|
|
34
|
-
*/
|
|
35
|
-
abstract get(): Value;
|
|
36
|
-
/**
|
|
37
|
-
* Get the value _(without reactivity)_
|
|
38
|
-
*/
|
|
39
|
-
peek(): Value;
|
|
40
|
-
/**
|
|
41
|
-
* Subscribe to changes
|
|
42
|
-
*/
|
|
43
|
-
subscribe(callback: (value: Value) => void): Unsubscribe;
|
|
44
|
-
/**
|
|
45
|
-
* JSON representation of the value
|
|
46
|
-
*/
|
|
47
|
-
toJSON(): Value;
|
|
48
|
-
/**
|
|
49
|
-
* String representation of the value
|
|
50
|
-
*/
|
|
51
|
-
toString(): string;
|
|
52
|
-
/**
|
|
53
|
-
* Unsubscribe from changes
|
|
54
|
-
*/
|
|
55
|
-
unsubscribe(callback: (value: Value) => void): void;
|
|
56
|
-
}
|
|
57
|
-
export type ReactiveOptions<Value> = {
|
|
58
|
-
/**
|
|
59
|
-
* Method to compare values for equality
|
|
60
|
-
*/
|
|
61
|
-
equal?: (first: Value, second: Value) => boolean;
|
|
62
|
-
};
|
|
63
|
-
export type ReactiveState<Value, Equal> = {
|
|
64
|
-
computeds: Set<Computed<unknown>>;
|
|
65
|
-
effects: Set<Effect>;
|
|
66
|
-
equal: (first: Equal, second: Equal) => boolean;
|
|
67
|
-
subscriptions: Map<GenericCallback, Subscription>;
|
|
68
|
-
value: Value;
|
|
69
|
-
};
|
|
70
|
-
declare class Subscription {
|
|
71
|
-
state: ReactiveState<unknown, never>;
|
|
72
|
-
callback: GenericCallback;
|
|
73
|
-
constructor(state: ReactiveState<unknown, never>, callback: GenericCallback);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Unsubscribe from changes
|
|
77
|
-
*/
|
|
78
|
-
export type Unsubscribe = () => void;
|
|
79
|
-
declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
80
|
-
#private;
|
|
81
|
-
/**
|
|
82
|
-
* The length of the array
|
|
83
|
-
*/
|
|
84
|
-
get length(): number;
|
|
85
|
-
/**
|
|
86
|
-
* Set the length of the array
|
|
87
|
-
*/
|
|
88
|
-
set length(value: number);
|
|
89
|
-
constructor(value: Item[], options?: ReactiveOptions<Item>);
|
|
90
|
-
/**
|
|
91
|
-
* Clear the array
|
|
92
|
-
*/
|
|
93
|
-
clear(): void;
|
|
94
|
-
/**
|
|
95
|
-
* @inheritdoc
|
|
96
|
-
*/
|
|
97
|
-
get(): Item[];
|
|
98
|
-
/**
|
|
99
|
-
* Get the value at an index
|
|
100
|
-
*/
|
|
101
|
-
get(index: number): Item | undefined;
|
|
102
|
-
/**
|
|
103
|
-
* Get the length of the array
|
|
104
|
-
*/
|
|
105
|
-
get(property: "length"): number;
|
|
106
|
-
/**
|
|
107
|
-
* Create a computed, filtered array
|
|
108
|
-
*/
|
|
109
|
-
filter(callback: (item: Item, index: number, array: Item[]) => boolean): Computed<Item[]>;
|
|
110
|
-
/**
|
|
111
|
-
* Create a computed, mapped array
|
|
112
|
-
*/
|
|
113
|
-
map<Mapped>(callback: (item: Item, index: number, array: Item[]) => Mapped): Computed<Mapped[]>;
|
|
114
|
-
/**
|
|
115
|
-
* @inheritdoc
|
|
116
|
-
*/
|
|
117
|
-
peek(): Item[];
|
|
118
|
-
peek(index: number): Item | undefined;
|
|
119
|
-
/**
|
|
120
|
-
* Get the length of the array _(without reactivity)_
|
|
121
|
-
*/
|
|
122
|
-
peek(length: true): number;
|
|
123
|
-
/**
|
|
124
|
-
* Remove and return the last item of the array
|
|
125
|
-
*/
|
|
126
|
-
pop(): Item | undefined;
|
|
127
|
-
/**
|
|
128
|
-
* Add items to the end of the array
|
|
129
|
-
*/
|
|
130
|
-
push(...items: Item[]): number;
|
|
131
|
-
/**
|
|
132
|
-
* Set the value
|
|
133
|
-
*/
|
|
134
|
-
set(value?: Item[]): void;
|
|
135
|
-
/**
|
|
136
|
-
* Set the value at an index
|
|
137
|
-
*/
|
|
138
|
-
set(index: number, value: Item): void;
|
|
139
|
-
/**
|
|
140
|
-
* Set the length of the array
|
|
141
|
-
*/
|
|
142
|
-
set(property: "length", value: number): void;
|
|
143
|
-
/**
|
|
144
|
-
* Remove and return the first item of the array
|
|
145
|
-
*/
|
|
146
|
-
shift(): Item | undefined;
|
|
147
|
-
/**
|
|
148
|
-
* Remove and return items from the array _(and optionally add new items)_
|
|
149
|
-
*/
|
|
150
|
-
splice(from: number, to?: number, ...items: Item[]): Item[];
|
|
151
|
-
/**
|
|
152
|
-
* @inheritdoc
|
|
153
|
-
*/
|
|
154
|
-
subscribe(callback: (value: Item[]) => void): Unsubscribe;
|
|
155
|
-
/**
|
|
156
|
-
* Subscribe to changes at a specific index
|
|
157
|
-
*/
|
|
158
|
-
subscribe(index: number, callback: (value: Item | undefined) => void): Unsubscribe;
|
|
159
|
-
/**
|
|
160
|
-
* Add items to the beginning of the array
|
|
161
|
-
*/
|
|
162
|
-
unshift(...items: Item[]): number;
|
|
163
|
-
/**
|
|
164
|
-
* Update the value _(based on the current value)_
|
|
165
|
-
*/
|
|
166
|
-
update(callback: (value: Item[]) => Item[]): void;
|
|
167
|
-
}
|
|
168
|
-
declare class Signal<Value> extends Reactive<Value> {
|
|
169
|
-
constructor(value: Value, options?: ReactiveOptions<Value>);
|
|
170
|
-
/**
|
|
171
|
-
* @inheritdoc
|
|
172
|
-
*/
|
|
173
|
-
get(): Value;
|
|
174
|
-
/**
|
|
175
|
-
* Set the value
|
|
176
|
-
*/
|
|
177
|
-
set(value: Value): void;
|
|
178
|
-
/**
|
|
179
|
-
* Update the value _(based on the current value)_
|
|
180
|
-
*/
|
|
181
|
-
update(callback: (value: Value) => Value): void;
|
|
182
|
-
}
|
|
183
|
-
declare class Store<Value extends PlainObject> extends Reactive<Value, Value> {
|
|
184
|
-
#private;
|
|
185
|
-
constructor(value: Value, options?: ReactiveOptions<Value>);
|
|
186
|
-
/**
|
|
187
|
-
* @inheritdoc
|
|
188
|
-
*/
|
|
189
|
-
get(): Value;
|
|
190
|
-
/**
|
|
191
|
-
* Get a value by key _(without reactivity)_
|
|
192
|
-
*/
|
|
193
|
-
get(key: keyof Value): Value[keyof Value];
|
|
194
|
-
/**
|
|
195
|
-
* Get a value by key _(without reactivity)_
|
|
196
|
-
*/
|
|
197
|
-
get(key: Key): unknown;
|
|
198
|
-
/**
|
|
199
|
-
* Get the value _(without reactivity)_
|
|
200
|
-
*/
|
|
201
|
-
peek(): Value;
|
|
202
|
-
/**
|
|
203
|
-
* Get a value by key _(without reactivity)_
|
|
204
|
-
*/
|
|
205
|
-
peek(key: keyof Value): Value[keyof Value];
|
|
206
|
-
/**
|
|
207
|
-
* Get a value by key _(without reactivity)_
|
|
208
|
-
*/
|
|
209
|
-
peek(key: Key): unknown;
|
|
210
|
-
/**
|
|
211
|
-
* Set the value
|
|
212
|
-
*/
|
|
213
|
-
set(value?: Value): void;
|
|
214
|
-
/**
|
|
215
|
-
* Set a value by key
|
|
216
|
-
*/
|
|
217
|
-
set(key: keyof Value, value: Value[keyof Value]): void;
|
|
218
|
-
/**
|
|
219
|
-
* Set a value by key
|
|
220
|
-
*/
|
|
221
|
-
set(key: Key, value: unknown): void;
|
|
222
|
-
/**
|
|
223
|
-
* @inheritdoc
|
|
224
|
-
*/
|
|
225
|
-
subscribe(callback: (value: Value) => void): Unsubscribe;
|
|
226
|
-
/**
|
|
227
|
-
* Subscribe to changes for a specific key
|
|
228
|
-
*/
|
|
229
|
-
subscribe<Key extends keyof Value>(key: Key, callback: (value: Value[Key] | undefined) => void): Unsubscribe;
|
|
230
|
-
/**
|
|
231
|
-
* Subscribe to changes for a specific key
|
|
232
|
-
*/
|
|
233
|
-
subscribe(key: Key, callback: (value: unknown) => void): Unsubscribe;
|
|
234
|
-
/**
|
|
235
|
-
* Update the value _(based on the current value)_
|
|
236
|
-
*/
|
|
237
|
-
update(callback: (value: Value) => Value): void;
|
|
238
|
-
}
|
|
239
|
-
export declare function getReactiveValueInProxy<Value>(array: ReactiveArray<Value>, mapped: Map<Key, Computed<unknown>>, index: number, isArray: true): Computed<unknown>;
|
|
240
|
-
export declare function getReactiveValueInProxy<Value extends PlainObject>(store: Store<Value>, mapped: Map<Key, Computed<unknown>>, key: Key, isArray: false): Computed<unknown>;
|
|
241
|
-
export declare function setProxyValue(proxy: ArrayOrPlainObject, value: ArrayOrPlainObject): void;
|
|
242
|
-
export declare function setValueInProxy<Value extends ArrayOrPlainObject, Equal>(target: Value, property: PropertyKey, value: unknown, state: ReactiveState<Value, Equal>, isArray: boolean, length?: Signal<number>): boolean;
|
|
243
|
-
|
|
244
|
-
export {};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
-
|
|
3
|
-
export type GenericCallback = (...args: any[]) => any;
|
|
4
|
-
declare class Effect {
|
|
5
|
-
private readonly $mora;
|
|
6
|
-
private readonly state;
|
|
7
|
-
constructor(callback: GenericCallback);
|
|
8
|
-
}
|
|
9
|
-
declare class Computed<Value> extends Reactive<Value> {
|
|
10
|
-
private readonly effect;
|
|
11
|
-
constructor(callback: () => Value, options?: ReactiveOptions<Value>);
|
|
12
|
-
/**
|
|
13
|
-
* @inheritdoc
|
|
14
|
-
*/
|
|
15
|
-
get(): Value;
|
|
16
|
-
}
|
|
17
|
-
declare abstract class Reactive<Value, Equal = Value> {
|
|
18
|
-
protected readonly state: ReactiveState<Value, Equal>;
|
|
19
|
-
constructor(name: string, value: Value, options?: ReactiveOptions<Equal>);
|
|
20
|
-
/**
|
|
21
|
-
* Get the value
|
|
22
|
-
*/
|
|
23
|
-
abstract get(): Value;
|
|
24
|
-
/**
|
|
25
|
-
* Get the value _(without reactivity)_
|
|
26
|
-
*/
|
|
27
|
-
peek(): Value;
|
|
28
|
-
/**
|
|
29
|
-
* Subscribe to changes
|
|
30
|
-
*/
|
|
31
|
-
subscribe(callback: (value: Value) => void): Unsubscribe;
|
|
32
|
-
/**
|
|
33
|
-
* JSON representation of the value
|
|
34
|
-
*/
|
|
35
|
-
toJSON(): Value;
|
|
36
|
-
/**
|
|
37
|
-
* String representation of the value
|
|
38
|
-
*/
|
|
39
|
-
toString(): string;
|
|
40
|
-
/**
|
|
41
|
-
* Unsubscribe from changes
|
|
42
|
-
*/
|
|
43
|
-
unsubscribe(callback: (value: Value) => void): void;
|
|
44
|
-
}
|
|
45
|
-
export type ReactiveOptions<Value> = {
|
|
46
|
-
/**
|
|
47
|
-
* Method to compare values for equality
|
|
48
|
-
*/
|
|
49
|
-
equal?: (first: Value, second: Value) => boolean;
|
|
50
|
-
};
|
|
51
|
-
export type ReactiveState<Value, Equal> = {
|
|
52
|
-
computeds: Set<Computed<unknown>>;
|
|
53
|
-
effects: Set<Effect>;
|
|
54
|
-
equal: (first: Equal, second: Equal) => boolean;
|
|
55
|
-
subscriptions: Map<GenericCallback, Subscription>;
|
|
56
|
-
value: Value;
|
|
57
|
-
};
|
|
58
|
-
declare class Subscription {
|
|
59
|
-
state: ReactiveState<unknown, never>;
|
|
60
|
-
callback: GenericCallback;
|
|
61
|
-
constructor(state: ReactiveState<unknown, never>, callback: GenericCallback);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Unsubscribe from changes
|
|
65
|
-
*/
|
|
66
|
-
export type Unsubscribe = () => void;
|
|
67
|
-
export declare function emitValue<Value>(state: ReactiveState<Value, never>): void;
|
|
68
|
-
export declare function equalArrays<Value>(state: ReactiveState<Value[], Value>, first: Value[], second: Value[]): boolean;
|
|
69
|
-
export declare function getValue<Value>(state: ReactiveState<Value, never>): Value;
|
|
70
|
-
|
|
71
|
-
export {};
|
package/types/index.d.cts
DELETED
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
-
|
|
3
|
-
export type GenericCallback = (...args: any[]) => any;
|
|
4
|
-
/**
|
|
5
|
-
* A useful key type
|
|
6
|
-
*/
|
|
7
|
-
export type Key = number | string;
|
|
8
|
-
/**
|
|
9
|
-
* A generic object
|
|
10
|
-
*/
|
|
11
|
-
export type PlainObject = Record<PropertyKey, unknown>;
|
|
12
|
-
export declare class Effect {
|
|
13
|
-
private readonly $mora;
|
|
14
|
-
private readonly state;
|
|
15
|
-
constructor(callback: GenericCallback);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Create an effect
|
|
19
|
-
*/
|
|
20
|
-
export declare function effect(callback: GenericCallback): Effect;
|
|
21
|
-
export declare class Computed<Value> extends Reactive<Value> {
|
|
22
|
-
private readonly effect;
|
|
23
|
-
constructor(callback: () => Value, options?: ReactiveOptions<Value>);
|
|
24
|
-
/**
|
|
25
|
-
* @inheritdoc
|
|
26
|
-
*/
|
|
27
|
-
get(): Value;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Create a computed value
|
|
31
|
-
*/
|
|
32
|
-
export declare function computed<Value>(callback: () => Value, options?: ReactiveOptions<Value>): Computed<Value>;
|
|
33
|
-
export declare abstract class Reactive<Value, Equal = Value> {
|
|
34
|
-
protected readonly state: ReactiveState<Value, Equal>;
|
|
35
|
-
constructor(name: string, value: Value, options?: ReactiveOptions<Equal>);
|
|
36
|
-
/**
|
|
37
|
-
* Get the value
|
|
38
|
-
*/
|
|
39
|
-
abstract get(): Value;
|
|
40
|
-
/**
|
|
41
|
-
* Get the value _(without reactivity)_
|
|
42
|
-
*/
|
|
43
|
-
peek(): Value;
|
|
44
|
-
/**
|
|
45
|
-
* Subscribe to changes
|
|
46
|
-
*/
|
|
47
|
-
subscribe(callback: (value: Value) => void): Unsubscribe;
|
|
48
|
-
/**
|
|
49
|
-
* JSON representation of the value
|
|
50
|
-
*/
|
|
51
|
-
toJSON(): Value;
|
|
52
|
-
/**
|
|
53
|
-
* String representation of the value
|
|
54
|
-
*/
|
|
55
|
-
toString(): string;
|
|
56
|
-
/**
|
|
57
|
-
* Unsubscribe from changes
|
|
58
|
-
*/
|
|
59
|
-
unsubscribe(callback: (value: Value) => void): void;
|
|
60
|
-
}
|
|
61
|
-
export type ReactiveOptions<Value> = {
|
|
62
|
-
/**
|
|
63
|
-
* Method to compare values for equality
|
|
64
|
-
*/
|
|
65
|
-
equal?: (first: Value, second: Value) => boolean;
|
|
66
|
-
};
|
|
67
|
-
export type ReactiveState<Value, Equal> = {
|
|
68
|
-
computeds: Set<Computed<unknown>>;
|
|
69
|
-
effects: Set<Effect>;
|
|
70
|
-
equal: (first: Equal, second: Equal) => boolean;
|
|
71
|
-
subscriptions: Map<GenericCallback, Subscription>;
|
|
72
|
-
value: Value;
|
|
73
|
-
};
|
|
74
|
-
declare class Subscription {
|
|
75
|
-
state: ReactiveState<unknown, never>;
|
|
76
|
-
callback: GenericCallback;
|
|
77
|
-
constructor(state: ReactiveState<unknown, never>, callback: GenericCallback);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Unsubscribe from changes
|
|
81
|
-
*/
|
|
82
|
-
export type Unsubscribe = () => void;
|
|
83
|
-
/**
|
|
84
|
-
* Start batching effects _(use `stopBatch` to flush and run batched effects)_
|
|
85
|
-
*/
|
|
86
|
-
export declare function startBatch(): void;
|
|
87
|
-
/**
|
|
88
|
-
* Stop batching effects and flush _(run)_ them
|
|
89
|
-
*/
|
|
90
|
-
export declare function stopBatch(): void;
|
|
91
|
-
export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
92
|
-
#private;
|
|
93
|
-
/**
|
|
94
|
-
* The length of the array
|
|
95
|
-
*/
|
|
96
|
-
get length(): number;
|
|
97
|
-
/**
|
|
98
|
-
* Set the length of the array
|
|
99
|
-
*/
|
|
100
|
-
set length(value: number);
|
|
101
|
-
constructor(value: Item[], options?: ReactiveOptions<Item>);
|
|
102
|
-
/**
|
|
103
|
-
* Clear the array
|
|
104
|
-
*/
|
|
105
|
-
clear(): void;
|
|
106
|
-
/**
|
|
107
|
-
* @inheritdoc
|
|
108
|
-
*/
|
|
109
|
-
get(): Item[];
|
|
110
|
-
/**
|
|
111
|
-
* Get the value at an index
|
|
112
|
-
*/
|
|
113
|
-
get(index: number): Item | undefined;
|
|
114
|
-
/**
|
|
115
|
-
* Get the length of the array
|
|
116
|
-
*/
|
|
117
|
-
get(property: "length"): number;
|
|
118
|
-
/**
|
|
119
|
-
* Create a computed, filtered array
|
|
120
|
-
*/
|
|
121
|
-
filter(callback: (item: Item, index: number, array: Item[]) => boolean): Computed<Item[]>;
|
|
122
|
-
/**
|
|
123
|
-
* Create a computed, mapped array
|
|
124
|
-
*/
|
|
125
|
-
map<Mapped>(callback: (item: Item, index: number, array: Item[]) => Mapped): Computed<Mapped[]>;
|
|
126
|
-
/**
|
|
127
|
-
* @inheritdoc
|
|
128
|
-
*/
|
|
129
|
-
peek(): Item[];
|
|
130
|
-
peek(index: number): Item | undefined;
|
|
131
|
-
/**
|
|
132
|
-
* Get the length of the array _(without reactivity)_
|
|
133
|
-
*/
|
|
134
|
-
peek(length: true): number;
|
|
135
|
-
/**
|
|
136
|
-
* Remove and return the last item of the array
|
|
137
|
-
*/
|
|
138
|
-
pop(): Item | undefined;
|
|
139
|
-
/**
|
|
140
|
-
* Add items to the end of the array
|
|
141
|
-
*/
|
|
142
|
-
push(...items: Item[]): number;
|
|
143
|
-
/**
|
|
144
|
-
* Set the value
|
|
145
|
-
*/
|
|
146
|
-
set(value?: Item[]): void;
|
|
147
|
-
/**
|
|
148
|
-
* Set the value at an index
|
|
149
|
-
*/
|
|
150
|
-
set(index: number, value: Item): void;
|
|
151
|
-
/**
|
|
152
|
-
* Set the length of the array
|
|
153
|
-
*/
|
|
154
|
-
set(property: "length", value: number): void;
|
|
155
|
-
/**
|
|
156
|
-
* Remove and return the first item of the array
|
|
157
|
-
*/
|
|
158
|
-
shift(): Item | undefined;
|
|
159
|
-
/**
|
|
160
|
-
* Remove and return items from the array _(and optionally add new items)_
|
|
161
|
-
*/
|
|
162
|
-
splice(from: number, to?: number, ...items: Item[]): Item[];
|
|
163
|
-
/**
|
|
164
|
-
* @inheritdoc
|
|
165
|
-
*/
|
|
166
|
-
subscribe(callback: (value: Item[]) => void): Unsubscribe;
|
|
167
|
-
/**
|
|
168
|
-
* Subscribe to changes at a specific index
|
|
169
|
-
*/
|
|
170
|
-
subscribe(index: number, callback: (value: Item | undefined) => void): Unsubscribe;
|
|
171
|
-
/**
|
|
172
|
-
* Add items to the beginning of the array
|
|
173
|
-
*/
|
|
174
|
-
unshift(...items: Item[]): number;
|
|
175
|
-
/**
|
|
176
|
-
* Update the value _(based on the current value)_
|
|
177
|
-
*/
|
|
178
|
-
update(callback: (value: Item[]) => Item[]): void;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Create a reactive array
|
|
182
|
-
*/
|
|
183
|
-
export declare function array<Item>(value: Item[], options?: ReactiveOptions<Item>): ReactiveArray<Item>;
|
|
184
|
-
export declare class Signal<Value> extends Reactive<Value> {
|
|
185
|
-
constructor(value: Value, options?: ReactiveOptions<Value>);
|
|
186
|
-
/**
|
|
187
|
-
* @inheritdoc
|
|
188
|
-
*/
|
|
189
|
-
get(): Value;
|
|
190
|
-
/**
|
|
191
|
-
* Set the value
|
|
192
|
-
*/
|
|
193
|
-
set(value: Value): void;
|
|
194
|
-
/**
|
|
195
|
-
* Update the value _(based on the current value)_
|
|
196
|
-
*/
|
|
197
|
-
update(callback: (value: Value) => Value): void;
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Create a reactive value
|
|
201
|
-
*/
|
|
202
|
-
export declare function signal<Value>(value: Value, options?: ReactiveOptions<Value>): Signal<Value>;
|
|
203
|
-
export declare class Store<Value extends PlainObject> extends Reactive<Value, Value> {
|
|
204
|
-
#private;
|
|
205
|
-
constructor(value: Value, options?: ReactiveOptions<Value>);
|
|
206
|
-
/**
|
|
207
|
-
* @inheritdoc
|
|
208
|
-
*/
|
|
209
|
-
get(): Value;
|
|
210
|
-
/**
|
|
211
|
-
* Get a value by key _(without reactivity)_
|
|
212
|
-
*/
|
|
213
|
-
get(key: keyof Value): Value[keyof Value];
|
|
214
|
-
/**
|
|
215
|
-
* Get a value by key _(without reactivity)_
|
|
216
|
-
*/
|
|
217
|
-
get(key: Key): unknown;
|
|
218
|
-
/**
|
|
219
|
-
* Get the value _(without reactivity)_
|
|
220
|
-
*/
|
|
221
|
-
peek(): Value;
|
|
222
|
-
/**
|
|
223
|
-
* Get a value by key _(without reactivity)_
|
|
224
|
-
*/
|
|
225
|
-
peek(key: keyof Value): Value[keyof Value];
|
|
226
|
-
/**
|
|
227
|
-
* Get a value by key _(without reactivity)_
|
|
228
|
-
*/
|
|
229
|
-
peek(key: Key): unknown;
|
|
230
|
-
/**
|
|
231
|
-
* Set the value
|
|
232
|
-
*/
|
|
233
|
-
set(value?: Value): void;
|
|
234
|
-
/**
|
|
235
|
-
* Set a value by key
|
|
236
|
-
*/
|
|
237
|
-
set(key: keyof Value, value: Value[keyof Value]): void;
|
|
238
|
-
/**
|
|
239
|
-
* Set a value by key
|
|
240
|
-
*/
|
|
241
|
-
set(key: Key, value: unknown): void;
|
|
242
|
-
/**
|
|
243
|
-
* @inheritdoc
|
|
244
|
-
*/
|
|
245
|
-
subscribe(callback: (value: Value) => void): Unsubscribe;
|
|
246
|
-
/**
|
|
247
|
-
* Subscribe to changes for a specific key
|
|
248
|
-
*/
|
|
249
|
-
subscribe<Key extends keyof Value>(key: Key, callback: (value: Value[Key] | undefined) => void): Unsubscribe;
|
|
250
|
-
/**
|
|
251
|
-
* Subscribe to changes for a specific key
|
|
252
|
-
*/
|
|
253
|
-
subscribe(key: Key, callback: (value: unknown) => void): Unsubscribe;
|
|
254
|
-
/**
|
|
255
|
-
* Update the value _(based on the current value)_
|
|
256
|
-
*/
|
|
257
|
-
update(callback: (value: Value) => Value): void;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Create a reactive store
|
|
261
|
-
*/
|
|
262
|
-
export declare function store<Value extends PlainObject>(value: Value, options?: ReactiveOptions<Value>): Store<Value>;
|
|
263
|
-
/**
|
|
264
|
-
* Is the value a reactive array?
|
|
265
|
-
*/
|
|
266
|
-
export declare function isArray(value: unknown): value is ReactiveArray<unknown>;
|
|
267
|
-
/**
|
|
268
|
-
* Is the value a computed signal?
|
|
269
|
-
*/
|
|
270
|
-
export declare function isComputed(value: unknown): value is Computed<unknown>;
|
|
271
|
-
/**
|
|
272
|
-
* Is the value an effect?
|
|
273
|
-
*/
|
|
274
|
-
export declare function isEffect(value: unknown): value is Effect;
|
|
275
|
-
export declare function isReactive(value: unknown): value is Reactive<unknown>;
|
|
276
|
-
/**
|
|
277
|
-
* Is the value a signal?
|
|
278
|
-
*/
|
|
279
|
-
export declare function isSignal(value: unknown): value is Signal<unknown>;
|
|
280
|
-
|
|
281
|
-
export {};
|
package/types/subscription.d.cts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
-
|
|
3
|
-
export type GenericCallback = (...args: any[]) => any;
|
|
4
|
-
declare class Effect {
|
|
5
|
-
private readonly $mora;
|
|
6
|
-
private readonly state;
|
|
7
|
-
constructor(callback: GenericCallback);
|
|
8
|
-
}
|
|
9
|
-
declare class Computed<Value> extends Reactive<Value> {
|
|
10
|
-
private readonly effect;
|
|
11
|
-
constructor(callback: () => Value, options?: ReactiveOptions<Value>);
|
|
12
|
-
/**
|
|
13
|
-
* @inheritdoc
|
|
14
|
-
*/
|
|
15
|
-
get(): Value;
|
|
16
|
-
}
|
|
17
|
-
declare abstract class Reactive<Value, Equal = Value> {
|
|
18
|
-
protected readonly state: ReactiveState<Value, Equal>;
|
|
19
|
-
constructor(name: string, value: Value, options?: ReactiveOptions<Equal>);
|
|
20
|
-
/**
|
|
21
|
-
* Get the value
|
|
22
|
-
*/
|
|
23
|
-
abstract get(): Value;
|
|
24
|
-
/**
|
|
25
|
-
* Get the value _(without reactivity)_
|
|
26
|
-
*/
|
|
27
|
-
peek(): Value;
|
|
28
|
-
/**
|
|
29
|
-
* Subscribe to changes
|
|
30
|
-
*/
|
|
31
|
-
subscribe(callback: (value: Value) => void): Unsubscribe;
|
|
32
|
-
/**
|
|
33
|
-
* JSON representation of the value
|
|
34
|
-
*/
|
|
35
|
-
toJSON(): Value;
|
|
36
|
-
/**
|
|
37
|
-
* String representation of the value
|
|
38
|
-
*/
|
|
39
|
-
toString(): string;
|
|
40
|
-
/**
|
|
41
|
-
* Unsubscribe from changes
|
|
42
|
-
*/
|
|
43
|
-
unsubscribe(callback: (value: Value) => void): void;
|
|
44
|
-
}
|
|
45
|
-
export type ReactiveOptions<Value> = {
|
|
46
|
-
/**
|
|
47
|
-
* Method to compare values for equality
|
|
48
|
-
*/
|
|
49
|
-
equal?: (first: Value, second: Value) => boolean;
|
|
50
|
-
};
|
|
51
|
-
export type ReactiveState<Value, Equal> = {
|
|
52
|
-
computeds: Set<Computed<unknown>>;
|
|
53
|
-
effects: Set<Effect>;
|
|
54
|
-
equal: (first: Equal, second: Equal) => boolean;
|
|
55
|
-
subscriptions: Map<GenericCallback, Subscription>;
|
|
56
|
-
value: Value;
|
|
57
|
-
};
|
|
58
|
-
export declare class Subscription {
|
|
59
|
-
state: ReactiveState<unknown, never>;
|
|
60
|
-
callback: GenericCallback;
|
|
61
|
-
constructor(state: ReactiveState<unknown, never>, callback: GenericCallback);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Unsubscribe from changes
|
|
65
|
-
*/
|
|
66
|
-
export type Unsubscribe = () => void;
|
|
67
|
-
export declare function noop(): void;
|
|
68
|
-
export declare function subscribe<Value>(state: ReactiveState<Value, never>, callback: (value: Value) => void): Unsubscribe;
|
|
69
|
-
export declare function unsubscribe<Value>(state: ReactiveState<Value, never>, callback: (value: Value) => void): void;
|
|
70
|
-
|
|
71
|
-
export {};
|