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