@oscarpalmer/mora 0.11.0 → 0.12.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/computed.cjs +1 -1
- package/dist/computed.js +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.js +2 -1
- package/dist/mora.full.js +6 -3
- package/dist/signal.cjs +1 -1
- package/dist/signal.js +1 -1
- package/package.json +1 -1
- package/src/computed.ts +1 -1
- package/src/index.ts +3 -1
- package/src/reactive.ts +5 -0
- package/src/signal.ts +1 -1
- package/types/batch.d.cts +5 -1
- package/types/computed.d.cts +5 -1
- package/types/computed.d.ts +1 -1
- package/types/index.d.cts +8 -3
- package/types/index.d.ts +2 -1
- package/types/is.d.cts +6 -2
- package/types/reactive.d.cts +5 -1
- package/types/reactive.d.ts +4 -0
- package/types/signal.d.cts +6 -2
- package/types/signal.d.ts +1 -1
- package/types/subscription.d.cts +5 -1
package/dist/computed.cjs
CHANGED
package/dist/computed.js
CHANGED
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { startBatch, stopBatch } from "./batch.js";
|
|
2
2
|
import { computed } from "./computed.js";
|
|
3
3
|
import { effect } from "./effect.js";
|
|
4
|
-
import { isComputed, isEffect, isSignal } from "./is.js";
|
|
4
|
+
import { isComputed, isEffect, isReactive, isSignal } from "./is.js";
|
|
5
5
|
import { signal } from "./signal.js";
|
|
6
6
|
export {
|
|
7
7
|
computed,
|
|
8
8
|
effect,
|
|
9
9
|
isComputed,
|
|
10
10
|
isEffect,
|
|
11
|
+
isReactive,
|
|
11
12
|
isSignal,
|
|
12
13
|
signal,
|
|
13
14
|
startBatch,
|
package/dist/mora.full.js
CHANGED
|
@@ -45,6 +45,9 @@ function isMora(value, name) {
|
|
|
45
45
|
'$mora' in value &&
|
|
46
46
|
value.$mora === name);
|
|
47
47
|
}
|
|
48
|
+
function isReactive(value) {
|
|
49
|
+
return isComputed(value) || isSignal(value);
|
|
50
|
+
}
|
|
48
51
|
/**
|
|
49
52
|
* Is the value a signal?
|
|
50
53
|
*/
|
|
@@ -176,7 +179,7 @@ class Computed extends Reactive {
|
|
|
176
179
|
});
|
|
177
180
|
}
|
|
178
181
|
/**
|
|
179
|
-
*
|
|
182
|
+
* @inheritdoc
|
|
180
183
|
*/
|
|
181
184
|
get() {
|
|
182
185
|
if (activeComputed != null && activeComputed !== this) {
|
|
@@ -203,7 +206,7 @@ class Signal extends Reactive {
|
|
|
203
206
|
super('signal', value);
|
|
204
207
|
}
|
|
205
208
|
/**
|
|
206
|
-
*
|
|
209
|
+
* @inheritdoc
|
|
207
210
|
*/
|
|
208
211
|
get() {
|
|
209
212
|
if (activeComputed != null) {
|
|
@@ -246,4 +249,4 @@ function signal(value) {
|
|
|
246
249
|
return new Signal(value);
|
|
247
250
|
}
|
|
248
251
|
|
|
249
|
-
export { computed, effect, isComputed, isEffect, isSignal, signal, startBatch, stopBatch };
|
|
252
|
+
export { computed, effect, isComputed, isEffect, isReactive, isSignal, signal, startBatch, stopBatch };
|
package/dist/signal.cjs
CHANGED
package/dist/signal.js
CHANGED
package/package.json
CHANGED
package/src/computed.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export {startBatch, stopBatch} from './batch';
|
|
2
2
|
export {computed, type Computed} from './computed';
|
|
3
3
|
export {effect, type Effect} from './effect';
|
|
4
|
-
export {isComputed, isEffect, isSignal} from './is';
|
|
4
|
+
export {isComputed, isEffect, isReactive, isSignal} from './is';
|
|
5
|
+
export type {Reactive} from './reactive';
|
|
5
6
|
export {signal, type Signal} from './signal';
|
|
7
|
+
|
package/src/reactive.ts
CHANGED
package/src/signal.ts
CHANGED
package/types/batch.d.cts
CHANGED
|
@@ -10,13 +10,17 @@ declare class Computed<Value> extends Reactive<Value> {
|
|
|
10
10
|
private readonly effect;
|
|
11
11
|
constructor(callback: () => Value);
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* @inheritdoc
|
|
14
14
|
*/
|
|
15
15
|
get(): Value;
|
|
16
16
|
}
|
|
17
17
|
declare abstract class Reactive<Value> {
|
|
18
18
|
protected readonly state: ReactiveState<Value>;
|
|
19
19
|
constructor(name: string, value: Value);
|
|
20
|
+
/**
|
|
21
|
+
* Get the value
|
|
22
|
+
*/
|
|
23
|
+
abstract get(): Value;
|
|
20
24
|
/**
|
|
21
25
|
* Get the value _(without reactivity)_
|
|
22
26
|
*/
|
package/types/computed.d.cts
CHANGED
|
@@ -19,7 +19,7 @@ export declare class Computed<Value> extends Reactive<Value> {
|
|
|
19
19
|
private readonly effect;
|
|
20
20
|
constructor(callback: () => Value);
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* @inheritdoc
|
|
23
23
|
*/
|
|
24
24
|
get(): Value;
|
|
25
25
|
}
|
|
@@ -30,6 +30,10 @@ export declare function computed<Value>(callback: () => Value): Computed<Value>;
|
|
|
30
30
|
declare abstract class Reactive<Value> {
|
|
31
31
|
protected readonly state: ReactiveState<Value>;
|
|
32
32
|
constructor(name: string, value: Value);
|
|
33
|
+
/**
|
|
34
|
+
* Get the value
|
|
35
|
+
*/
|
|
36
|
+
abstract get(): Value;
|
|
33
37
|
/**
|
|
34
38
|
* Get the value _(without reactivity)_
|
|
35
39
|
*/
|
package/types/computed.d.ts
CHANGED
package/types/index.d.cts
CHANGED
|
@@ -14,7 +14,7 @@ export declare class Computed<Value> extends Reactive<Value> {
|
|
|
14
14
|
private readonly effect;
|
|
15
15
|
constructor(callback: () => Value);
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* @inheritdoc
|
|
18
18
|
*/
|
|
19
19
|
get(): Value;
|
|
20
20
|
}
|
|
@@ -22,9 +22,13 @@ export declare class Computed<Value> extends Reactive<Value> {
|
|
|
22
22
|
* Create a computed value
|
|
23
23
|
*/
|
|
24
24
|
export declare function computed<Value>(callback: () => Value): Computed<Value>;
|
|
25
|
-
declare abstract class Reactive<Value> {
|
|
25
|
+
export declare abstract class Reactive<Value> {
|
|
26
26
|
protected readonly state: ReactiveState<Value>;
|
|
27
27
|
constructor(name: string, value: Value);
|
|
28
|
+
/**
|
|
29
|
+
* Get the value
|
|
30
|
+
*/
|
|
31
|
+
abstract get(): Value;
|
|
28
32
|
/**
|
|
29
33
|
* Get the value _(without reactivity)_
|
|
30
34
|
*/
|
|
@@ -56,7 +60,7 @@ export type Unsubscribe = () => void;
|
|
|
56
60
|
export declare class Signal<Value> extends Reactive<Value> {
|
|
57
61
|
constructor(value: Value);
|
|
58
62
|
/**
|
|
59
|
-
*
|
|
63
|
+
* @inheritdoc
|
|
60
64
|
*/
|
|
61
65
|
get(): Value;
|
|
62
66
|
/**
|
|
@@ -77,6 +81,7 @@ export declare function isComputed(value: unknown): value is Computed<unknown>;
|
|
|
77
81
|
* Is the value an effect?
|
|
78
82
|
*/
|
|
79
83
|
export declare function isEffect(value: unknown): value is Effect;
|
|
84
|
+
export declare function isReactive(value: unknown): value is Reactive<unknown>;
|
|
80
85
|
/**
|
|
81
86
|
* Is the value a signal?
|
|
82
87
|
*/
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { startBatch, stopBatch } from './batch';
|
|
2
2
|
export { computed, type Computed } from './computed';
|
|
3
3
|
export { effect, type Effect } from './effect';
|
|
4
|
-
export { isComputed, isEffect, isSignal } from './is';
|
|
4
|
+
export { isComputed, isEffect, isReactive, isSignal } from './is';
|
|
5
|
+
export type { Reactive } from './reactive';
|
|
5
6
|
export { signal, type Signal } from './signal';
|
package/types/is.d.cts
CHANGED
|
@@ -10,13 +10,17 @@ declare class Computed<Value> extends Reactive<Value> {
|
|
|
10
10
|
private readonly effect;
|
|
11
11
|
constructor(callback: () => Value);
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* @inheritdoc
|
|
14
14
|
*/
|
|
15
15
|
get(): Value;
|
|
16
16
|
}
|
|
17
17
|
declare abstract class Reactive<Value> {
|
|
18
18
|
protected readonly state: ReactiveState<Value>;
|
|
19
19
|
constructor(name: string, value: Value);
|
|
20
|
+
/**
|
|
21
|
+
* Get the value
|
|
22
|
+
*/
|
|
23
|
+
abstract get(): Value;
|
|
20
24
|
/**
|
|
21
25
|
* Get the value _(without reactivity)_
|
|
22
26
|
*/
|
|
@@ -48,7 +52,7 @@ export type Unsubscribe = () => void;
|
|
|
48
52
|
declare class Signal<Value> extends Reactive<Value> {
|
|
49
53
|
constructor(value: Value);
|
|
50
54
|
/**
|
|
51
|
-
*
|
|
55
|
+
* @inheritdoc
|
|
52
56
|
*/
|
|
53
57
|
get(): Value;
|
|
54
58
|
/**
|
package/types/reactive.d.cts
CHANGED
|
@@ -10,13 +10,17 @@ declare class Computed<Value> extends Reactive<Value> {
|
|
|
10
10
|
private readonly effect;
|
|
11
11
|
constructor(callback: () => Value);
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* @inheritdoc
|
|
14
14
|
*/
|
|
15
15
|
get(): Value;
|
|
16
16
|
}
|
|
17
17
|
export declare abstract class Reactive<Value> {
|
|
18
18
|
protected readonly state: ReactiveState<Value>;
|
|
19
19
|
constructor(name: string, value: Value);
|
|
20
|
+
/**
|
|
21
|
+
* Get the value
|
|
22
|
+
*/
|
|
23
|
+
abstract get(): Value;
|
|
20
24
|
/**
|
|
21
25
|
* Get the value _(without reactivity)_
|
|
22
26
|
*/
|
package/types/reactive.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ import { type Subscription, type Unsubscribe } from './subscription';
|
|
|
4
4
|
export declare abstract class Reactive<Value> {
|
|
5
5
|
protected readonly state: ReactiveState<Value>;
|
|
6
6
|
constructor(name: string, value: Value);
|
|
7
|
+
/**
|
|
8
|
+
* Get the value
|
|
9
|
+
*/
|
|
10
|
+
abstract get(): Value;
|
|
7
11
|
/**
|
|
8
12
|
* Get the value _(without reactivity)_
|
|
9
13
|
*/
|
package/types/signal.d.cts
CHANGED
|
@@ -10,13 +10,17 @@ declare class Computed<Value> extends Reactive<Value> {
|
|
|
10
10
|
private readonly effect;
|
|
11
11
|
constructor(callback: () => Value);
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* @inheritdoc
|
|
14
14
|
*/
|
|
15
15
|
get(): Value;
|
|
16
16
|
}
|
|
17
17
|
declare abstract class Reactive<Value> {
|
|
18
18
|
protected readonly state: ReactiveState<Value>;
|
|
19
19
|
constructor(name: string, value: Value);
|
|
20
|
+
/**
|
|
21
|
+
* Get the value
|
|
22
|
+
*/
|
|
23
|
+
abstract get(): Value;
|
|
20
24
|
/**
|
|
21
25
|
* Get the value _(without reactivity)_
|
|
22
26
|
*/
|
|
@@ -48,7 +52,7 @@ export type Unsubscribe = () => void;
|
|
|
48
52
|
export declare class Signal<Value> extends Reactive<Value> {
|
|
49
53
|
constructor(value: Value);
|
|
50
54
|
/**
|
|
51
|
-
*
|
|
55
|
+
* @inheritdoc
|
|
52
56
|
*/
|
|
53
57
|
get(): Value;
|
|
54
58
|
/**
|
package/types/signal.d.ts
CHANGED
package/types/subscription.d.cts
CHANGED
|
@@ -10,13 +10,17 @@ declare class Computed<Value> extends Reactive<Value> {
|
|
|
10
10
|
private readonly effect;
|
|
11
11
|
constructor(callback: () => Value);
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* @inheritdoc
|
|
14
14
|
*/
|
|
15
15
|
get(): Value;
|
|
16
16
|
}
|
|
17
17
|
declare abstract class Reactive<Value> {
|
|
18
18
|
protected readonly state: ReactiveState<Value>;
|
|
19
19
|
constructor(name: string, value: Value);
|
|
20
|
+
/**
|
|
21
|
+
* Get the value
|
|
22
|
+
*/
|
|
23
|
+
abstract get(): Value;
|
|
20
24
|
/**
|
|
21
25
|
* Get the value _(without reactivity)_
|
|
22
26
|
*/
|