@oscarpalmer/mora 0.17.0 → 0.18.1
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/helpers/is.cjs +7 -1
- package/dist/helpers/is.js +8 -2
- package/dist/helpers/proxy.cjs +43 -0
- package/dist/helpers/proxy.js +43 -0
- package/dist/helpers/value.cjs +20 -24
- package/dist/helpers/value.js +20 -24
- package/dist/index.cjs +2 -0
- package/dist/index.js +3 -1
- package/dist/mora.full.js +107 -43
- package/dist/node_modules/@oscarpalmer/atoms/dist/internal/is.cjs +17 -0
- package/dist/node_modules/@oscarpalmer/atoms/dist/internal/is.js +17 -0
- package/dist/value/array.cjs +10 -16
- package/dist/value/array.js +11 -17
- package/dist/value/signal.cjs +1 -1
- package/dist/value/signal.js +2 -2
- package/dist/value/store.cjs +36 -0
- package/dist/value/store.js +36 -0
- package/package.json +1 -1
- package/src/helpers/is.ts +7 -1
- package/src/helpers/proxy.ts +71 -0
- package/src/helpers/value.ts +23 -33
- package/src/index.ts +1 -0
- package/src/value/array.ts +11 -30
- package/src/value/signal.ts +2 -2
- package/src/value/store.ts +90 -0
- package/types/helpers/is.d.ts +3 -0
- package/types/helpers/proxy.d.ts +5 -0
- package/types/helpers/value.d.ts +1 -2
- package/types/index.d.ts +1 -0
- package/types/value/store.d.ts +45 -0
- package/types/batch.d.cts +0 -79
- package/types/effect.d.cts +0 -16
- package/types/helpers/is.d.cts +0 -176
- package/types/helpers/value.d.cts +0 -72
- package/types/index.d.cts +0 -196
- package/types/subscription.d.cts +0 -71
- package/types/value/array.d.cts +0 -144
- 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/helpers/is.d.cts
DELETED
|
@@ -1,176 +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<(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
|
-
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
|
-
declare class Signal<Value> extends Reactive<Value> {
|
|
140
|
-
constructor(value: Value, options?: ReactiveOptions<Value>);
|
|
141
|
-
/**
|
|
142
|
-
* @inheritdoc
|
|
143
|
-
*/
|
|
144
|
-
get(): Value;
|
|
145
|
-
/**
|
|
146
|
-
* Set the value
|
|
147
|
-
*/
|
|
148
|
-
set(value: Value): void;
|
|
149
|
-
/**
|
|
150
|
-
* Update the value
|
|
151
|
-
*/
|
|
152
|
-
update(callback: (value: Value) => Value): void;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Is the value a reactive array?
|
|
156
|
-
*/
|
|
157
|
-
export declare function isArray(value: unknown): value is ReactiveArray<unknown>;
|
|
158
|
-
/**
|
|
159
|
-
* Is the value a computed signal?
|
|
160
|
-
*/
|
|
161
|
-
export declare function isComputed(value: unknown): value is Computed<unknown>;
|
|
162
|
-
/**
|
|
163
|
-
* Is the value an effect?
|
|
164
|
-
*/
|
|
165
|
-
export declare function isEffect(value: unknown): value is Effect;
|
|
166
|
-
export declare function isReactive(value: unknown): value is Reactive<unknown>;
|
|
167
|
-
/**
|
|
168
|
-
* Is the value a signal?
|
|
169
|
-
*/
|
|
170
|
-
export declare function isSignal(value: unknown): value is Signal<unknown>;
|
|
171
|
-
export declare const arrayName = "array";
|
|
172
|
-
export declare const computedName = "computed";
|
|
173
|
-
export declare const effectName = "effect";
|
|
174
|
-
export declare const signalName = "signal";
|
|
175
|
-
|
|
176
|
-
export {};
|
|
@@ -1,72 +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<(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 differentArrays<Value>(state: ReactiveState<Value[], Value>, first: Value[], second: Value[]): boolean;
|
|
68
|
-
export declare function differentValues<Value>(state: ReactiveState<Value, Value>, first: Value, second: Value): boolean;
|
|
69
|
-
export declare function emitValue<Value>(state: ReactiveState<Value, never>): void;
|
|
70
|
-
export declare function getValue<Value>(state: ReactiveState<Value, never>): Value;
|
|
71
|
-
|
|
72
|
-
export {};
|
package/types/index.d.cts
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
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
|
-
/**
|
|
10
|
-
* Create an effect
|
|
11
|
-
*/
|
|
12
|
-
export declare function effect(callback: GenericCallback): Effect;
|
|
13
|
-
export 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
|
-
/**
|
|
22
|
-
* Create a computed value
|
|
23
|
-
*/
|
|
24
|
-
export declare function computed<Value>(callback: () => Value, options?: ReactiveOptions<Value>): Computed<Value>;
|
|
25
|
-
export 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
|
-
/**
|
|
76
|
-
* Start batching effects _(use `stopBatch` to flush and run batched effects)_
|
|
77
|
-
*/
|
|
78
|
-
export declare function startBatch(): void;
|
|
79
|
-
/**
|
|
80
|
-
* Stop batching effects and flush _(run)_ them
|
|
81
|
-
*/
|
|
82
|
-
export declare function stopBatch(): void;
|
|
83
|
-
export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
84
|
-
#private;
|
|
85
|
-
/**
|
|
86
|
-
* The length of the array
|
|
87
|
-
*/
|
|
88
|
-
get length(): number;
|
|
89
|
-
/**
|
|
90
|
-
* Set the length of the array
|
|
91
|
-
*/
|
|
92
|
-
set length(value: number);
|
|
93
|
-
constructor(value: Item[], options?: ReactiveOptions<Item>);
|
|
94
|
-
/**
|
|
95
|
-
* Get an indexed item
|
|
96
|
-
*/
|
|
97
|
-
at(index: number): Item | undefined;
|
|
98
|
-
/**
|
|
99
|
-
* Clear the array
|
|
100
|
-
*/
|
|
101
|
-
clear(): void;
|
|
102
|
-
/**
|
|
103
|
-
* @inheritdoc
|
|
104
|
-
*/
|
|
105
|
-
get(): Item[];
|
|
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
|
-
/**
|
|
119
|
-
* Get the length of the array _(without reactivity)_
|
|
120
|
-
*/
|
|
121
|
-
peek(length: true): number;
|
|
122
|
-
/**
|
|
123
|
-
* Remove and return the last item of the array
|
|
124
|
-
*/
|
|
125
|
-
pop(): Item | undefined;
|
|
126
|
-
/**
|
|
127
|
-
* Add items to the end of the array
|
|
128
|
-
*/
|
|
129
|
-
push(...items: Item[]): number;
|
|
130
|
-
/**
|
|
131
|
-
* Set the value
|
|
132
|
-
*/
|
|
133
|
-
set(value: Item[]): void;
|
|
134
|
-
/**
|
|
135
|
-
* Set the value at an index
|
|
136
|
-
*/
|
|
137
|
-
set(index: number, value: Item): void;
|
|
138
|
-
/**
|
|
139
|
-
* Set the length of the array
|
|
140
|
-
*/
|
|
141
|
-
set(property: "length", value: number): void;
|
|
142
|
-
/**
|
|
143
|
-
* Remove and return the first item of the array
|
|
144
|
-
*/
|
|
145
|
-
shift(): Item | undefined;
|
|
146
|
-
/**
|
|
147
|
-
* Remove and return items from the array _(and optionally add new items)_
|
|
148
|
-
*/
|
|
149
|
-
splice(from: number, to?: number, ...items: Item[]): Item[];
|
|
150
|
-
/**
|
|
151
|
-
* Add items to the beginning of the array
|
|
152
|
-
*/
|
|
153
|
-
unshift(...items: Item[]): number;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Create a reactive array
|
|
157
|
-
*/
|
|
158
|
-
export declare function array<Item>(value: Item[], options?: ReactiveOptions<Item>): ReactiveArray<Item>;
|
|
159
|
-
export declare class Signal<Value> extends Reactive<Value> {
|
|
160
|
-
constructor(value: Value, options?: ReactiveOptions<Value>);
|
|
161
|
-
/**
|
|
162
|
-
* @inheritdoc
|
|
163
|
-
*/
|
|
164
|
-
get(): Value;
|
|
165
|
-
/**
|
|
166
|
-
* Set the value
|
|
167
|
-
*/
|
|
168
|
-
set(value: Value): void;
|
|
169
|
-
/**
|
|
170
|
-
* Update the value
|
|
171
|
-
*/
|
|
172
|
-
update(callback: (value: Value) => Value): void;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Create a reactive value
|
|
176
|
-
*/
|
|
177
|
-
export declare function signal<Value>(value: Value, options?: ReactiveOptions<Value>): Signal<Value>;
|
|
178
|
-
/**
|
|
179
|
-
* Is the value a reactive array?
|
|
180
|
-
*/
|
|
181
|
-
export declare function isArray(value: unknown): value is ReactiveArray<unknown>;
|
|
182
|
-
/**
|
|
183
|
-
* Is the value a computed signal?
|
|
184
|
-
*/
|
|
185
|
-
export declare function isComputed(value: unknown): value is Computed<unknown>;
|
|
186
|
-
/**
|
|
187
|
-
* Is the value an effect?
|
|
188
|
-
*/
|
|
189
|
-
export declare function isEffect(value: unknown): value is Effect;
|
|
190
|
-
export declare function isReactive(value: unknown): value is Reactive<unknown>;
|
|
191
|
-
/**
|
|
192
|
-
* Is the value a signal?
|
|
193
|
-
*/
|
|
194
|
-
export declare function isSignal(value: unknown): value is Signal<unknown>;
|
|
195
|
-
|
|
196
|
-
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<(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 {};
|
package/types/value/array.d.cts
DELETED
|
@@ -1,144 +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<(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 {};
|