@oscarpalmer/mora 0.12.0 → 0.14.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.
Files changed (59) hide show
  1. package/dist/batch.cjs +2 -2
  2. package/dist/batch.js +1 -1
  3. package/dist/effect.cjs +2 -1
  4. package/dist/effect.js +2 -1
  5. package/dist/helpers/emit.cjs +42 -0
  6. package/dist/helpers/emit.js +42 -0
  7. package/dist/helpers/is.cjs +34 -0
  8. package/dist/helpers/is.js +34 -0
  9. package/dist/helpers/value.cjs +22 -0
  10. package/dist/helpers/value.js +22 -0
  11. package/dist/index.cjs +12 -9
  12. package/dist/index.js +6 -3
  13. package/dist/mora.full.js +214 -55
  14. package/dist/value/array.cjs +108 -0
  15. package/dist/value/array.js +108 -0
  16. package/dist/{computed.cjs → value/computed.cjs} +6 -5
  17. package/dist/{computed.js → value/computed.js} +4 -3
  18. package/dist/{reactive.cjs → value/reactive.cjs} +13 -1
  19. package/dist/{reactive.js → value/reactive.js} +13 -1
  20. package/dist/value/signal.cjs +33 -0
  21. package/dist/value/signal.js +33 -0
  22. package/package.json +1 -1
  23. package/src/batch.ts +1 -1
  24. package/src/effect.ts +12 -11
  25. package/src/helpers/emit.ts +52 -0
  26. package/src/helpers/is.ts +56 -0
  27. package/src/helpers/value.ts +27 -0
  28. package/src/index.ts +11 -5
  29. package/src/subscription.ts +1 -1
  30. package/src/value/array.ts +170 -0
  31. package/src/{computed.ts → value/computed.ts} +4 -3
  32. package/src/{reactive.ts → value/reactive.ts} +17 -3
  33. package/src/value/signal.ts +37 -0
  34. package/types/batch.d.cts +8 -0
  35. package/types/{is.d.cts → helpers/emit.d.cts} +10 -28
  36. package/types/helpers/emit.d.ts +3 -0
  37. package/types/helpers/is.d.cts +133 -0
  38. package/types/helpers/is.d.ts +26 -0
  39. package/types/helpers/value.d.cts +63 -0
  40. package/types/helpers/value.d.ts +3 -0
  41. package/types/index.d.cts +63 -8
  42. package/types/index.d.ts +5 -4
  43. package/types/subscription.d.cts +8 -0
  44. package/types/subscription.d.ts +1 -1
  45. package/types/value/array.d.cts +101 -0
  46. package/types/value/array.d.ts +41 -0
  47. package/types/{computed.d.cts → value/computed.d.cts} +8 -0
  48. package/types/{computed.d.ts → value/computed.d.ts} +1 -1
  49. package/types/{reactive.d.cts → value/reactive.d.cts} +8 -0
  50. package/types/{reactive.d.ts → value/reactive.d.ts} +10 -2
  51. package/types/{signal.d.cts → value/signal.d.cts} +11 -0
  52. package/types/{signal.d.ts → value/signal.d.ts} +3 -0
  53. package/dist/is.cjs +0 -21
  54. package/dist/is.js +0 -21
  55. package/dist/signal.cjs +0 -55
  56. package/dist/signal.js +0 -55
  57. package/src/is.ts +0 -39
  58. package/src/signal.ts +0 -63
  59. package/types/is.d.ts +0 -17
@@ -0,0 +1,170 @@
1
+ import {emitArrayChanges, emitValue} from '../helpers/emit';
2
+ import {arrayName} from '../helpers/is';
3
+ import {getValue} from '../helpers/value';
4
+ import {Reactive, type ReactiveState} from './reactive';
5
+ import {type Signal, signal} from './signal';
6
+
7
+ export class ReactiveArray<Item> extends Reactive<Item[]> {
8
+ #size = signal(0);
9
+
10
+ /**
11
+ * The length of the array
12
+ */
13
+ get length(): number {
14
+ return this.#size.get();
15
+ }
16
+
17
+ /**
18
+ * Set the length of the array
19
+ */
20
+ set length(value: number) {
21
+ if (
22
+ typeof value === 'number' &&
23
+ value >= 0 &&
24
+ value !== this.state.value.length
25
+ ) {
26
+ this.get().length = value;
27
+ }
28
+ }
29
+
30
+ constructor(value: Item[]) {
31
+ super(
32
+ arrayName,
33
+ new Proxy(value, {
34
+ get: (target, property) =>
35
+ updateMethods.has(property as string)
36
+ ? updateArray(property as string, target, this.state, this.#size)
37
+ : Reflect.get(target, property),
38
+ set: (target, property, value) =>
39
+ setValue(target, property, value, this.state, this.#size),
40
+ }),
41
+ );
42
+
43
+ this.#size.set(value.length);
44
+ }
45
+
46
+ /**
47
+ * @inheritdoc
48
+ */
49
+ get(): Item[] {
50
+ return getValue(this.state);
51
+ }
52
+
53
+ /**
54
+ * @inheritdoc
55
+ */
56
+ peek(): Item[];
57
+
58
+ /**
59
+ * Get the length of the array _(without reactivity)_
60
+ */
61
+ peek(length: true): number;
62
+
63
+ peek(length?: unknown): Item[] | number {
64
+ return length === true ? this.#size.peek() : [...this.state.value];
65
+ }
66
+
67
+ /**
68
+ * Set the value
69
+ */
70
+ set(value: Item[]): void;
71
+
72
+ /**
73
+ * Set the value at an index
74
+ */
75
+ set(index: number, value: Item): void;
76
+
77
+ /**
78
+ * Set the length of the array
79
+ */
80
+ set(property: 'length', value: number): void;
81
+
82
+ set(first: number | 'length' | Item[], second?: number | Item): void {
83
+ if (Array.isArray(first)) {
84
+ this.state.value.splice(0, this.state.value.length, ...first);
85
+ } else if (first === 'length') {
86
+ this.length = second as number;
87
+ } else if (typeof first === 'number') {
88
+ this.state.value[first] = second as Item;
89
+ }
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Create a reactive array
95
+ */
96
+ export function array<Item>(value: Item[]): ReactiveArray<Item> {
97
+ return new ReactiveArray(Array.isArray(value) ? value : []);
98
+ }
99
+
100
+ function setValue<Item>(
101
+ target: Item[],
102
+ property: PropertyKey,
103
+ value: unknown,
104
+ state: ReactiveState<Item[]>,
105
+ length: Signal<number>,
106
+ ): boolean {
107
+ const isIndex = !Number.isNaN(Number(property));
108
+ const isLength = property === 'length';
109
+
110
+ if (!isIndex && !isLength) {
111
+ return Reflect.set(target, property, value);
112
+ }
113
+
114
+ const previous = Reflect.get(target, property);
115
+
116
+ if (!Object.is(previous, value)) {
117
+ Reflect.set(target, property, value);
118
+
119
+ emitValue(state);
120
+
121
+ length.set(target.length);
122
+ }
123
+
124
+ return true;
125
+ }
126
+
127
+ function updateArray<Item>(
128
+ type: string,
129
+ array: Item[],
130
+ state: ReactiveState<Item[]>,
131
+ length: Signal<number>,
132
+ ): unknown {
133
+ const affectsLength = lengthAffectingMethods.has(type);
134
+ const previousArray = affectsLength ? [] : [...array];
135
+ const previousLength = array.length;
136
+
137
+ return (...args: unknown[]): unknown => {
138
+ const result = (array[type as never] as (...args: unknown[]) => unknown)(
139
+ ...args,
140
+ );
141
+
142
+ if (
143
+ affectsLength
144
+ ? array.length !== previousLength
145
+ : emitArrayChanges(previousArray, array)
146
+ ) {
147
+ emitValue(state);
148
+
149
+ length.set(array.length);
150
+ }
151
+
152
+ return result;
153
+ };
154
+ }
155
+
156
+ const lengthAffectingMethods = new Set<string>([
157
+ 'pop',
158
+ 'push',
159
+ 'shift',
160
+ 'unshift',
161
+ ]);
162
+
163
+ const updateMethods = new Set<string>([
164
+ ...lengthAffectingMethods,
165
+ 'copyWithin',
166
+ 'fill',
167
+ 'reverse',
168
+ 'sort',
169
+ 'splice',
170
+ ]);
@@ -1,5 +1,6 @@
1
- import {batchDepth, batchedHandlers} from './batch';
2
- import {type Effect, activeEffect, effect, runEffect} from './effect';
1
+ import {batchDepth, batchedHandlers} from '../batch';
2
+ import {type Effect, activeEffect, effect, runEffect} from '../effect';
3
+ import {computedName} from '../helpers/is';
3
4
  import {Reactive, type ReactiveState} from './reactive';
4
5
 
5
6
  type ComputedEffect = {
@@ -21,7 +22,7 @@ export class Computed<Value> extends Reactive<Value> {
21
22
  };
22
23
 
23
24
  constructor(callback: () => Value) {
24
- super('computed', undefined as never);
25
+ super(computedName, undefined as never);
25
26
 
26
27
  this.effect.instance = effect(() => {
27
28
  if (this.effect.dirty) {
@@ -1,11 +1,11 @@
1
- import type {Computed} from './computed';
2
- import type {Effect} from './effect';
1
+ import type {Effect} from '../effect';
3
2
  import {
4
3
  type Subscription,
5
4
  type Unsubscribe,
6
5
  subscribe,
7
6
  unsubscribe,
8
- } from './subscription';
7
+ } from '../subscription';
8
+ import type {Computed} from './computed';
9
9
 
10
10
  export abstract class Reactive<Value> {
11
11
  protected readonly state: ReactiveState<Value> = {
@@ -42,6 +42,20 @@ export abstract class Reactive<Value> {
42
42
  return subscribe(this.state, callback);
43
43
  }
44
44
 
45
+ /**
46
+ * JSON representation of the value
47
+ */
48
+ toJSON(): Value {
49
+ return this.get();
50
+ }
51
+
52
+ /**
53
+ * String representation of the value
54
+ */
55
+ toString(): string {
56
+ return String(this.get());
57
+ }
58
+
45
59
  /**
46
60
  * Unsubscribe from changes
47
61
  */
@@ -0,0 +1,37 @@
1
+ import {signalName} from '../helpers/is';
2
+ import {getValue, setValue} from '../helpers/value';
3
+ import {Reactive} from './reactive';
4
+
5
+ export class Signal<Value> extends Reactive<Value> {
6
+ constructor(value: Value) {
7
+ super(signalName, value);
8
+ }
9
+
10
+ /**
11
+ * @inheritdoc
12
+ */
13
+ get(): Value {
14
+ return getValue(this.state);
15
+ }
16
+
17
+ /**
18
+ * Set the value
19
+ */
20
+ set(value: Value): void {
21
+ setValue(this.state, value);
22
+ }
23
+
24
+ /**
25
+ * Update the value
26
+ */
27
+ update(callback: (value: Value) => Value): void {
28
+ this.set(callback(this.state.value));
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Create a reactive value
34
+ */
35
+ export function signal<Value>(value: Value): Signal<Value> {
36
+ return new Signal(value);
37
+ }
package/types/batch.d.cts CHANGED
@@ -29,6 +29,14 @@ declare abstract class Reactive<Value> {
29
29
  * Subscribe to changes
30
30
  */
31
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;
32
40
  /**
33
41
  * Unsubscribe from changes
34
42
  */
@@ -29,6 +29,14 @@ declare abstract class Reactive<Value> {
29
29
  * Subscribe to changes
30
30
  */
31
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;
32
40
  /**
33
41
  * Unsubscribe from changes
34
42
  */
@@ -49,33 +57,7 @@ declare class Subscription<Value> {
49
57
  * Unsubscribe from changes
50
58
  */
51
59
  export type Unsubscribe = () => void;
52
- declare class Signal<Value> extends Reactive<Value> {
53
- constructor(value: Value);
54
- /**
55
- * @inheritdoc
56
- */
57
- get(): Value;
58
- /**
59
- * Set the value
60
- */
61
- set(value: Value): void;
62
- /**
63
- * Update the value
64
- */
65
- update(callback: (value: Value) => Value): void;
66
- }
67
- /**
68
- * Is the value a computed signal?
69
- */
70
- export declare function isComputed(value: unknown): value is Computed<unknown>;
71
- /**
72
- * Is the value an effect?
73
- */
74
- export declare function isEffect(value: unknown): value is Effect;
75
- export declare function isReactive(value: unknown): value is Reactive<unknown>;
76
- /**
77
- * Is the value a signal?
78
- */
79
- export declare function isSignal(value: unknown): value is Signal<unknown>;
60
+ export declare function emitArrayChanges(first: unknown[], second: unknown[]): boolean;
61
+ export declare function emitValue<Value>(state: ReactiveState<Value>): void;
80
62
 
81
63
  export {};
@@ -0,0 +1,3 @@
1
+ import type { ReactiveState } from '../value/reactive';
2
+ export declare function emitArrayChanges(first: unknown[], second: unknown[]): boolean;
3
+ export declare function emitValue<Value>(state: ReactiveState<Value>): void;
@@ -0,0 +1,133 @@
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);
12
+ /**
13
+ * @inheritdoc
14
+ */
15
+ get(): Value;
16
+ }
17
+ declare abstract class Reactive<Value> {
18
+ protected readonly state: ReactiveState<Value>;
19
+ constructor(name: string, value: Value);
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 ReactiveState<Value> = {
46
+ computeds: Set<Computed<unknown>>;
47
+ effects: Set<Effect>;
48
+ subscriptions: Map<(value: Value) => void, Subscription<Value>>;
49
+ value: Value;
50
+ };
51
+ declare class Subscription<Value> {
52
+ state: ReactiveState<Value>;
53
+ callback: GenericCallback;
54
+ constructor(state: ReactiveState<Value>, callback: GenericCallback);
55
+ }
56
+ /**
57
+ * Unsubscribe from changes
58
+ */
59
+ export type Unsubscribe = () => void;
60
+ declare class ReactiveArray<Item> extends Reactive<Item[]> {
61
+ #private;
62
+ /**
63
+ * The length of the array
64
+ */
65
+ get length(): number;
66
+ /**
67
+ * Set the length of the array
68
+ */
69
+ set length(value: number);
70
+ constructor(value: Item[]);
71
+ /**
72
+ * @inheritdoc
73
+ */
74
+ get(): Item[];
75
+ /**
76
+ * @inheritdoc
77
+ */
78
+ peek(): Item[];
79
+ /**
80
+ * Get the length of the array _(without reactivity)_
81
+ */
82
+ peek(length: true): number;
83
+ /**
84
+ * Set the value
85
+ */
86
+ set(value: Item[]): void;
87
+ /**
88
+ * Set the value at an index
89
+ */
90
+ set(index: number, value: Item): void;
91
+ /**
92
+ * Set the length of the array
93
+ */
94
+ set(property: "length", value: number): void;
95
+ }
96
+ declare class Signal<Value> extends Reactive<Value> {
97
+ constructor(value: Value);
98
+ /**
99
+ * @inheritdoc
100
+ */
101
+ get(): Value;
102
+ /**
103
+ * Set the value
104
+ */
105
+ set(value: Value): void;
106
+ /**
107
+ * Update the value
108
+ */
109
+ update(callback: (value: Value) => Value): void;
110
+ }
111
+ /**
112
+ * Is the value a reactive array?
113
+ */
114
+ export declare function isArray(value: unknown): value is ReactiveArray<unknown>;
115
+ /**
116
+ * Is the value a computed signal?
117
+ */
118
+ export declare function isComputed(value: unknown): value is Computed<unknown>;
119
+ /**
120
+ * Is the value an effect?
121
+ */
122
+ export declare function isEffect(value: unknown): value is Effect;
123
+ export declare function isReactive(value: unknown): value is Reactive<unknown>;
124
+ /**
125
+ * Is the value a signal?
126
+ */
127
+ export declare function isSignal(value: unknown): value is Signal<unknown>;
128
+ export declare const arrayName = "array";
129
+ export declare const computedName = "computed";
130
+ export declare const effectName = "effect";
131
+ export declare const signalName = "signal";
132
+
133
+ export {};
@@ -0,0 +1,26 @@
1
+ import type { Effect } from '../effect';
2
+ import type { ReactiveArray } from '../value/array';
3
+ import type { Computed } from '../value/computed';
4
+ import type { Reactive } from '../value/reactive';
5
+ import { type Signal } from '../value/signal';
6
+ /**
7
+ * Is the value a reactive array?
8
+ */
9
+ export declare function isArray(value: unknown): value is ReactiveArray<unknown>;
10
+ /**
11
+ * Is the value a computed signal?
12
+ */
13
+ export declare function isComputed(value: unknown): value is Computed<unknown>;
14
+ /**
15
+ * Is the value an effect?
16
+ */
17
+ export declare function isEffect(value: unknown): value is Effect;
18
+ export declare function isReactive(value: unknown): value is Reactive<unknown>;
19
+ /**
20
+ * Is the value a signal?
21
+ */
22
+ export declare function isSignal(value: unknown): value is Signal<unknown>;
23
+ export declare const arrayName = "array";
24
+ export declare const computedName = "computed";
25
+ export declare const effectName = "effect";
26
+ export declare const signalName = "signal";
@@ -0,0 +1,63 @@
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);
12
+ /**
13
+ * @inheritdoc
14
+ */
15
+ get(): Value;
16
+ }
17
+ declare abstract class Reactive<Value> {
18
+ protected readonly state: ReactiveState<Value>;
19
+ constructor(name: string, value: Value);
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 ReactiveState<Value> = {
46
+ computeds: Set<Computed<unknown>>;
47
+ effects: Set<Effect>;
48
+ subscriptions: Map<(value: Value) => void, Subscription<Value>>;
49
+ value: Value;
50
+ };
51
+ declare class Subscription<Value> {
52
+ state: ReactiveState<Value>;
53
+ callback: GenericCallback;
54
+ constructor(state: ReactiveState<Value>, callback: GenericCallback);
55
+ }
56
+ /**
57
+ * Unsubscribe from changes
58
+ */
59
+ export type Unsubscribe = () => void;
60
+ export declare function getValue<Value>(state: ReactiveState<Value>): Value;
61
+ export declare function setValue<Value>(state: ReactiveState<Value>, value: Value): void;
62
+
63
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { ReactiveState } from '../value/reactive';
2
+ export declare function getValue<Value>(state: ReactiveState<Value>): Value;
3
+ export declare function setValue<Value>(state: ReactiveState<Value>, value: Value): void;
package/types/index.d.cts CHANGED
@@ -37,6 +37,14 @@ export declare abstract class Reactive<Value> {
37
37
  * Subscribe to changes
38
38
  */
39
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;
40
48
  /**
41
49
  * Unsubscribe from changes
42
50
  */
@@ -57,6 +65,54 @@ declare class Subscription<Value> {
57
65
  * Unsubscribe from changes
58
66
  */
59
67
  export type Unsubscribe = () => 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 class ReactiveArray<Item> extends Reactive<Item[]> {
77
+ #private;
78
+ /**
79
+ * The length of the array
80
+ */
81
+ get length(): number;
82
+ /**
83
+ * Set the length of the array
84
+ */
85
+ set length(value: number);
86
+ constructor(value: Item[]);
87
+ /**
88
+ * @inheritdoc
89
+ */
90
+ get(): Item[];
91
+ /**
92
+ * @inheritdoc
93
+ */
94
+ peek(): Item[];
95
+ /**
96
+ * Get the length of the array _(without reactivity)_
97
+ */
98
+ peek(length: true): number;
99
+ /**
100
+ * Set the value
101
+ */
102
+ set(value: Item[]): void;
103
+ /**
104
+ * Set the value at an index
105
+ */
106
+ set(index: number, value: Item): void;
107
+ /**
108
+ * Set the length of the array
109
+ */
110
+ set(property: "length", value: number): void;
111
+ }
112
+ /**
113
+ * Create a reactive array
114
+ */
115
+ export declare function array<Item>(value: Item[]): ReactiveArray<Item>;
60
116
  export declare class Signal<Value> extends Reactive<Value> {
61
117
  constructor(value: Value);
62
118
  /**
@@ -72,7 +128,14 @@ export declare class Signal<Value> extends Reactive<Value> {
72
128
  */
73
129
  update(callback: (value: Value) => Value): void;
74
130
  }
131
+ /**
132
+ * Create a reactive value
133
+ */
75
134
  export declare function signal<Value>(value: Value): Signal<Value>;
135
+ /**
136
+ * Is the value a reactive array?
137
+ */
138
+ export declare function isArray(value: unknown): value is ReactiveArray<unknown>;
76
139
  /**
77
140
  * Is the value a computed signal?
78
141
  */
@@ -86,13 +149,5 @@ export declare function isReactive(value: unknown): value is Reactive<unknown>;
86
149
  * Is the value a signal?
87
150
  */
88
151
  export declare function isSignal(value: unknown): value is Signal<unknown>;
89
- /**
90
- * Start batching effects _(use `stopBatch` to flush and run batched effects)_
91
- */
92
- export declare function startBatch(): void;
93
- /**
94
- * Stop batching effects and flush _(run)_ them
95
- */
96
- export declare function stopBatch(): void;
97
152
 
98
153
  export {};
package/types/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { startBatch, stopBatch } from './batch';
2
- export { computed, type Computed } from './computed';
3
2
  export { effect, type Effect } from './effect';
4
- export { isComputed, isEffect, isReactive, isSignal } from './is';
5
- export type { Reactive } from './reactive';
6
- export { signal, type Signal } from './signal';
3
+ export { isArray, isComputed, isEffect, isReactive, isSignal, } from './helpers/is';
4
+ export { array, type ReactiveArray } from './value/array';
5
+ export { computed, type Computed } from './value/computed';
6
+ export type { Reactive } from './value/reactive';
7
+ export { signal, type Signal } from './value/signal';
@@ -29,6 +29,14 @@ declare abstract class Reactive<Value> {
29
29
  * Subscribe to changes
30
30
  */
31
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;
32
40
  /**
33
41
  * Unsubscribe from changes
34
42
  */
@@ -1,5 +1,5 @@
1
1
  import type { GenericCallback } from '@oscarpalmer/atoms/models';
2
- import type { ReactiveState } from './reactive';
2
+ import type { ReactiveState } from './value/reactive';
3
3
  export declare class Subscription<Value> {
4
4
  state: ReactiveState<Value>;
5
5
  callback: GenericCallback;