@oscarpalmer/mora 0.17.0 → 0.18.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/helpers/value.cjs +5 -5
- package/dist/helpers/value.js +5 -5
- package/dist/mora.full.js +23 -27
- package/dist/value/array.cjs +6 -7
- package/dist/value/array.js +6 -7
- package/dist/value/computed.cjs +5 -5
- package/dist/value/computed.js +5 -5
- package/dist/value/reactive.cjs +1 -5
- package/dist/value/reactive.js +1 -5
- package/dist/value/signal.cjs +5 -5
- package/dist/value/signal.js +5 -5
- package/package.json +1 -1
- package/src/helpers/is.ts +7 -1
- package/src/helpers/proxy.ts +72 -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/batch.d.cts +7 -14
- package/types/helpers/is.d.cts +10 -17
- package/types/helpers/value.d.cts +11 -18
- package/types/helpers/value.d.ts +4 -4
- package/types/index.d.cts +13 -20
- package/types/subscription.d.cts +9 -16
- package/types/subscription.d.ts +4 -4
- package/types/value/array.d.cts +10 -17
- package/types/value/array.d.ts +4 -4
- package/types/value/computed.d.cts +9 -16
- package/types/value/computed.d.ts +4 -4
- package/types/value/reactive.d.cts +7 -14
- package/types/value/reactive.d.ts +4 -11
- package/types/value/signal.d.cts +9 -16
- package/types/value/signal.d.ts +3 -3
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { type Effect } from '../effect';
|
|
2
|
-
import { Reactive, type
|
|
2
|
+
import { Reactive, type ReactiveState } from './reactive';
|
|
3
3
|
export type ComputedEffect = {
|
|
4
4
|
dirty: boolean;
|
|
5
5
|
instance: Effect;
|
|
6
6
|
};
|
|
7
7
|
export type InternalComputed = {
|
|
8
8
|
readonly effect: ComputedEffect;
|
|
9
|
-
readonly state: ReactiveState<unknown
|
|
9
|
+
readonly state: ReactiveState<unknown>;
|
|
10
10
|
};
|
|
11
11
|
export declare let activeComputed: Computed<unknown> | undefined;
|
|
12
12
|
export declare class Computed<Value> extends Reactive<Value> {
|
|
13
13
|
private readonly effect;
|
|
14
|
-
constructor(callback: () => Value
|
|
14
|
+
constructor(callback: () => Value);
|
|
15
15
|
/**
|
|
16
16
|
* @inheritdoc
|
|
17
17
|
*/
|
|
@@ -20,4 +20,4 @@ export declare class Computed<Value> extends Reactive<Value> {
|
|
|
20
20
|
/**
|
|
21
21
|
* Create a computed value
|
|
22
22
|
*/
|
|
23
|
-
export declare function computed<Value>(callback: () => Value
|
|
23
|
+
export declare function computed<Value>(callback: () => Value): Computed<Value>;
|
|
@@ -8,15 +8,15 @@ declare class Effect {
|
|
|
8
8
|
}
|
|
9
9
|
declare class Computed<Value> extends Reactive<Value> {
|
|
10
10
|
private readonly effect;
|
|
11
|
-
constructor(callback: () => Value
|
|
11
|
+
constructor(callback: () => Value);
|
|
12
12
|
/**
|
|
13
13
|
* @inheritdoc
|
|
14
14
|
*/
|
|
15
15
|
get(): Value;
|
|
16
16
|
}
|
|
17
|
-
export declare abstract class Reactive<Value
|
|
18
|
-
protected readonly state: ReactiveState<Value
|
|
19
|
-
constructor(name: string, value: Value
|
|
17
|
+
export declare abstract class Reactive<Value> {
|
|
18
|
+
protected readonly state: ReactiveState<Value>;
|
|
19
|
+
constructor(name: string, value: Value);
|
|
20
20
|
/**
|
|
21
21
|
* Get the value
|
|
22
22
|
*/
|
|
@@ -42,23 +42,16 @@ export declare abstract class Reactive<Value, Equal = Value> {
|
|
|
42
42
|
*/
|
|
43
43
|
unsubscribe(callback: (value: Value) => void): void;
|
|
44
44
|
}
|
|
45
|
-
export type
|
|
46
|
-
/**
|
|
47
|
-
* Method to compare values for equality
|
|
48
|
-
*/
|
|
49
|
-
equal?: (first: Value, second: Value) => boolean;
|
|
50
|
-
};
|
|
51
|
-
export type ReactiveState<Value, Equal> = {
|
|
45
|
+
export type ReactiveState<Value> = {
|
|
52
46
|
computeds: Set<Computed<unknown>>;
|
|
53
47
|
effects: Set<Effect>;
|
|
54
|
-
equal: (first: Equal, second: Equal) => boolean;
|
|
55
48
|
subscriptions: Map<(value: Value) => void, Subscription<Value>>;
|
|
56
49
|
value: Value;
|
|
57
50
|
};
|
|
58
51
|
declare class Subscription<Value> {
|
|
59
|
-
state: ReactiveState<Value
|
|
52
|
+
state: ReactiveState<Value>;
|
|
60
53
|
callback: GenericCallback;
|
|
61
|
-
constructor(state: ReactiveState<Value
|
|
54
|
+
constructor(state: ReactiveState<Value>, callback: GenericCallback);
|
|
62
55
|
}
|
|
63
56
|
/**
|
|
64
57
|
* Unsubscribe from changes
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Effect } from '../effect';
|
|
2
2
|
import { type Subscription, type Unsubscribe } from '../subscription';
|
|
3
3
|
import type { Computed } from './computed';
|
|
4
|
-
export declare abstract class Reactive<Value
|
|
5
|
-
protected readonly state: ReactiveState<Value
|
|
6
|
-
constructor(name: string, value: Value
|
|
4
|
+
export declare abstract class Reactive<Value> {
|
|
5
|
+
protected readonly state: ReactiveState<Value>;
|
|
6
|
+
constructor(name: string, value: Value);
|
|
7
7
|
/**
|
|
8
8
|
* Get the value
|
|
9
9
|
*/
|
|
@@ -29,16 +29,9 @@ export declare abstract class Reactive<Value, Equal = Value> {
|
|
|
29
29
|
*/
|
|
30
30
|
unsubscribe(callback: (value: Value) => void): void;
|
|
31
31
|
}
|
|
32
|
-
export type
|
|
33
|
-
/**
|
|
34
|
-
* Method to compare values for equality
|
|
35
|
-
*/
|
|
36
|
-
equal?: (first: Value, second: Value) => boolean;
|
|
37
|
-
};
|
|
38
|
-
export type ReactiveState<Value, Equal> = {
|
|
32
|
+
export type ReactiveState<Value> = {
|
|
39
33
|
computeds: Set<Computed<unknown>>;
|
|
40
34
|
effects: Set<Effect>;
|
|
41
|
-
equal: (first: Equal, second: Equal) => boolean;
|
|
42
35
|
subscriptions: Map<(value: Value) => void, Subscription<Value>>;
|
|
43
36
|
value: Value;
|
|
44
37
|
};
|
package/types/value/signal.d.cts
CHANGED
|
@@ -8,15 +8,15 @@ declare class Effect {
|
|
|
8
8
|
}
|
|
9
9
|
declare class Computed<Value> extends Reactive<Value> {
|
|
10
10
|
private readonly effect;
|
|
11
|
-
constructor(callback: () => Value
|
|
11
|
+
constructor(callback: () => Value);
|
|
12
12
|
/**
|
|
13
13
|
* @inheritdoc
|
|
14
14
|
*/
|
|
15
15
|
get(): Value;
|
|
16
16
|
}
|
|
17
|
-
declare abstract class Reactive<Value
|
|
18
|
-
protected readonly state: ReactiveState<Value
|
|
19
|
-
constructor(name: string, value: Value
|
|
17
|
+
declare abstract class Reactive<Value> {
|
|
18
|
+
protected readonly state: ReactiveState<Value>;
|
|
19
|
+
constructor(name: string, value: Value);
|
|
20
20
|
/**
|
|
21
21
|
* Get the value
|
|
22
22
|
*/
|
|
@@ -42,30 +42,23 @@ declare abstract class Reactive<Value, Equal = Value> {
|
|
|
42
42
|
*/
|
|
43
43
|
unsubscribe(callback: (value: Value) => void): void;
|
|
44
44
|
}
|
|
45
|
-
export type
|
|
46
|
-
/**
|
|
47
|
-
* Method to compare values for equality
|
|
48
|
-
*/
|
|
49
|
-
equal?: (first: Value, second: Value) => boolean;
|
|
50
|
-
};
|
|
51
|
-
export type ReactiveState<Value, Equal> = {
|
|
45
|
+
export type ReactiveState<Value> = {
|
|
52
46
|
computeds: Set<Computed<unknown>>;
|
|
53
47
|
effects: Set<Effect>;
|
|
54
|
-
equal: (first: Equal, second: Equal) => boolean;
|
|
55
48
|
subscriptions: Map<(value: Value) => void, Subscription<Value>>;
|
|
56
49
|
value: Value;
|
|
57
50
|
};
|
|
58
51
|
declare class Subscription<Value> {
|
|
59
|
-
state: ReactiveState<Value
|
|
52
|
+
state: ReactiveState<Value>;
|
|
60
53
|
callback: GenericCallback;
|
|
61
|
-
constructor(state: ReactiveState<Value
|
|
54
|
+
constructor(state: ReactiveState<Value>, callback: GenericCallback);
|
|
62
55
|
}
|
|
63
56
|
/**
|
|
64
57
|
* Unsubscribe from changes
|
|
65
58
|
*/
|
|
66
59
|
export type Unsubscribe = () => void;
|
|
67
60
|
export declare class Signal<Value> extends Reactive<Value> {
|
|
68
|
-
constructor(value: Value
|
|
61
|
+
constructor(value: Value);
|
|
69
62
|
/**
|
|
70
63
|
* @inheritdoc
|
|
71
64
|
*/
|
|
@@ -82,6 +75,6 @@ export declare class Signal<Value> extends Reactive<Value> {
|
|
|
82
75
|
/**
|
|
83
76
|
* Create a reactive value
|
|
84
77
|
*/
|
|
85
|
-
export declare function signal<Value>(value: Value
|
|
78
|
+
export declare function signal<Value>(value: Value): Signal<Value>;
|
|
86
79
|
|
|
87
80
|
export {};
|
package/types/value/signal.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Reactive
|
|
1
|
+
import { Reactive } from './reactive';
|
|
2
2
|
export declare class Signal<Value> extends Reactive<Value> {
|
|
3
|
-
constructor(value: Value
|
|
3
|
+
constructor(value: Value);
|
|
4
4
|
/**
|
|
5
5
|
* @inheritdoc
|
|
6
6
|
*/
|
|
@@ -17,4 +17,4 @@ export declare class Signal<Value> extends Reactive<Value> {
|
|
|
17
17
|
/**
|
|
18
18
|
* Create a reactive value
|
|
19
19
|
*/
|
|
20
|
-
export declare function signal<Value>(value: Value
|
|
20
|
+
export declare function signal<Value>(value: Value): Signal<Value>;
|