@oscarpalmer/mora 0.21.0 → 0.23.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 -25
- package/dist/constants.js +34 -0
- package/dist/effect.js +18 -28
- package/dist/helpers/is.js +9 -26
- package/dist/helpers/proxy.js +36 -48
- package/dist/helpers/value.js +21 -48
- package/dist/index.js +3 -16
- package/dist/models.js +0 -0
- package/dist/mora.full.js +218 -130
- package/dist/subscription.js +22 -28
- package/dist/value/array.js +97 -182
- package/dist/value/computed.js +33 -58
- package/dist/value/reactive.js +29 -53
- package/dist/value/signal.js +21 -33
- package/dist/value/store.js +37 -60
- package/package.json +17 -24
- package/src/batch.ts +11 -13
- package/src/constants.ts +49 -0
- package/src/effect.ts +11 -16
- package/src/helpers/is.ts +41 -19
- package/src/helpers/proxy.ts +34 -38
- package/src/helpers/value.ts +19 -14
- package/src/index.ts +1 -1
- package/src/models.ts +66 -0
- package/src/subscription.ts +14 -16
- package/src/value/array.ts +87 -45
- package/src/value/computed.ts +29 -39
- package/src/value/reactive.ts +9 -24
- package/src/value/signal.ts +9 -3
- package/src/value/store.ts +40 -9
- package/types/batch.d.ts +3 -5
- package/types/constants.d.ts +14 -0
- package/types/effect.d.ts +2 -1
- package/types/helpers/is.d.ts +23 -10
- package/types/helpers/proxy.d.ts +2 -3
- package/types/helpers/value.d.ts +1 -1
- package/types/index.d.ts +1 -0
- package/types/models.d.ts +56 -0
- package/types/subscription.d.ts +3 -6
- package/types/value/array.d.ts +48 -7
- package/types/value/computed.d.ts +2 -11
- package/types/value/reactive.d.ts +8 -17
- package/types/value/signal.d.ts +7 -1
- package/types/value/store.d.ts +28 -4
- 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
package/types/value/signal.d.cts
DELETED
|
@@ -1,87 +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 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 _(based on the current 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 {};
|
package/types/value/store.d.cts
DELETED
|
@@ -1,136 +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
|
-
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<GenericCallback, Subscription>;
|
|
64
|
-
value: Value;
|
|
65
|
-
};
|
|
66
|
-
declare class Subscription {
|
|
67
|
-
state: ReactiveState<unknown, never>;
|
|
68
|
-
callback: GenericCallback;
|
|
69
|
-
constructor(state: ReactiveState<unknown, 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
|
-
#private;
|
|
77
|
-
constructor(value: Value, options?: ReactiveOptions<Value>);
|
|
78
|
-
/**
|
|
79
|
-
* @inheritdoc
|
|
80
|
-
*/
|
|
81
|
-
get(): Value;
|
|
82
|
-
/**
|
|
83
|
-
* Get a value by key _(without reactivity)_
|
|
84
|
-
*/
|
|
85
|
-
get(key: keyof Value): Value[keyof Value];
|
|
86
|
-
/**
|
|
87
|
-
* Get a value by key _(without reactivity)_
|
|
88
|
-
*/
|
|
89
|
-
get(key: Key): unknown;
|
|
90
|
-
/**
|
|
91
|
-
* Get the value _(without reactivity)_
|
|
92
|
-
*/
|
|
93
|
-
peek(): Value;
|
|
94
|
-
/**
|
|
95
|
-
* Get a value by key _(without reactivity)_
|
|
96
|
-
*/
|
|
97
|
-
peek(key: keyof Value): Value[keyof Value];
|
|
98
|
-
/**
|
|
99
|
-
* Get a value by key _(without reactivity)_
|
|
100
|
-
*/
|
|
101
|
-
peek(key: Key): unknown;
|
|
102
|
-
/**
|
|
103
|
-
* Set the value
|
|
104
|
-
*/
|
|
105
|
-
set(value?: Value): void;
|
|
106
|
-
/**
|
|
107
|
-
* Set a value by key
|
|
108
|
-
*/
|
|
109
|
-
set(key: keyof Value, value: Value[keyof Value]): void;
|
|
110
|
-
/**
|
|
111
|
-
* Set a value by key
|
|
112
|
-
*/
|
|
113
|
-
set(key: Key, value: unknown): void;
|
|
114
|
-
/**
|
|
115
|
-
* @inheritdoc
|
|
116
|
-
*/
|
|
117
|
-
subscribe(callback: (value: Value) => void): Unsubscribe;
|
|
118
|
-
/**
|
|
119
|
-
* Subscribe to changes for a specific key
|
|
120
|
-
*/
|
|
121
|
-
subscribe<Key extends keyof Value>(key: Key, callback: (value: Value[Key] | undefined) => void): Unsubscribe;
|
|
122
|
-
/**
|
|
123
|
-
* Subscribe to changes for a specific key
|
|
124
|
-
*/
|
|
125
|
-
subscribe(key: Key, callback: (value: unknown) => void): Unsubscribe;
|
|
126
|
-
/**
|
|
127
|
-
* Update the value _(based on the current value)_
|
|
128
|
-
*/
|
|
129
|
-
update(callback: (value: Value) => Value): void;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Create a reactive store
|
|
133
|
-
*/
|
|
134
|
-
export declare function store<Value extends PlainObject>(value: Value, options?: ReactiveOptions<Value>): Store<Value>;
|
|
135
|
-
|
|
136
|
-
export {};
|