@oscarpalmer/mora 0.20.0 → 0.22.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 (44) hide show
  1. package/dist/batch.js +11 -24
  2. package/dist/effect.js +17 -26
  3. package/dist/helpers/is.js +14 -21
  4. package/dist/helpers/proxy.js +34 -47
  5. package/dist/helpers/value.js +20 -46
  6. package/dist/index.js +4 -17
  7. package/dist/mora.full.js +8 -2
  8. package/dist/subscription.js +20 -28
  9. package/dist/value/array.js +94 -173
  10. package/dist/value/computed.js +34 -56
  11. package/dist/value/reactive.js +29 -53
  12. package/dist/value/signal.js +20 -32
  13. package/dist/value/store.js +30 -59
  14. package/package.json +12 -18
  15. package/src/helpers/value.ts +1 -1
  16. package/src/index.ts +0 -1
  17. package/src/value/array.ts +13 -3
  18. package/types/value/array.d.ts +1 -0
  19. package/dist/batch.cjs +0 -32
  20. package/dist/effect.cjs +0 -30
  21. package/dist/helpers/is.cjs +0 -40
  22. package/dist/helpers/proxy.cjs +0 -56
  23. package/dist/helpers/value.cjs +0 -54
  24. package/dist/index.cjs +0 -21
  25. package/dist/node_modules/@oscarpalmer/atoms/dist/internal/is.cjs +0 -17
  26. package/dist/node_modules/@oscarpalmer/atoms/dist/internal/is.js +0 -17
  27. package/dist/subscription.cjs +0 -32
  28. package/dist/value/array.cjs +0 -181
  29. package/dist/value/computed.cjs +0 -60
  30. package/dist/value/reactive.cjs +0 -55
  31. package/dist/value/signal.cjs +0 -36
  32. package/dist/value/store.cjs +0 -63
  33. package/types/batch.d.cts +0 -79
  34. package/types/effect.d.cts +0 -16
  35. package/types/helpers/is.d.cts +0 -258
  36. package/types/helpers/proxy.d.cts +0 -243
  37. package/types/helpers/value.d.cts +0 -71
  38. package/types/index.d.cts +0 -280
  39. package/types/subscription.d.cts +0 -71
  40. package/types/value/array.d.cts +0 -160
  41. package/types/value/computed.d.cts +0 -81
  42. package/types/value/reactive.d.cts +0 -68
  43. package/types/value/signal.d.cts +0 -87
  44. package/types/value/store.d.cts +0 -136
@@ -1,160 +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 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
- * Clear the array
80
- */
81
- clear(): void;
82
- /**
83
- * @inheritdoc
84
- */
85
- get(): Item[];
86
- /**
87
- * Get the value at an index
88
- */
89
- get(index: number): Item | undefined;
90
- /**
91
- * Get the length of the array
92
- */
93
- get(property: "length"): number;
94
- /**
95
- * Create a computed, filtered array
96
- */
97
- filter(callback: (item: Item, index: number, array: Item[]) => boolean): Computed<Item[]>;
98
- /**
99
- * Create a computed, mapped array
100
- */
101
- map<Mapped>(callback: (item: Item, index: number, array: Item[]) => Mapped): Computed<Mapped[]>;
102
- /**
103
- * @inheritdoc
104
- */
105
- peek(): Item[];
106
- /**
107
- * Get the length of the array _(without reactivity)_
108
- */
109
- peek(length: true): number;
110
- /**
111
- * Remove and return the last item of the array
112
- */
113
- pop(): Item | undefined;
114
- /**
115
- * Add items to the end of the array
116
- */
117
- push(...items: Item[]): number;
118
- /**
119
- * Set the value
120
- */
121
- set(value?: Item[]): void;
122
- /**
123
- * Set the value at an index
124
- */
125
- set(index: number, value: Item): void;
126
- /**
127
- * Set the length of the array
128
- */
129
- set(property: "length", value: number): void;
130
- /**
131
- * Remove and return the first item of the array
132
- */
133
- shift(): Item | undefined;
134
- /**
135
- * Remove and return items from the array _(and optionally add new items)_
136
- */
137
- splice(from: number, to?: number, ...items: Item[]): Item[];
138
- /**
139
- * @inheritdoc
140
- */
141
- subscribe(callback: (value: Item[]) => void): Unsubscribe;
142
- /**
143
- * Subscribe to changes at a specific index
144
- */
145
- subscribe(index: number, callback: (value: Item | undefined) => void): Unsubscribe;
146
- /**
147
- * Add items to the beginning of the array
148
- */
149
- unshift(...items: Item[]): number;
150
- /**
151
- * Update the value _(based on the current value)_
152
- */
153
- update(callback: (value: Item[]) => Item[]): void;
154
- }
155
- /**
156
- * Create a reactive array
157
- */
158
- export declare function array<Item>(value: Item[], options?: ReactiveOptions<Item>): ReactiveArray<Item>;
159
-
160
- export {};
@@ -1,81 +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
- export type ComputedEffect = {
10
- dirty: boolean;
11
- instance: Effect;
12
- };
13
- export type InternalComputed = {
14
- readonly effect: ComputedEffect;
15
- readonly state: ReactiveState<unknown, unknown>;
16
- };
17
- export declare let activeComputed: Computed<unknown> | undefined;
18
- export declare class Computed<Value> extends Reactive<Value> {
19
- private readonly effect;
20
- constructor(callback: () => Value, options?: ReactiveOptions<Value>);
21
- /**
22
- * @inheritdoc
23
- */
24
- get(): Value;
25
- }
26
- /**
27
- * Create a computed value
28
- */
29
- export declare function computed<Value>(callback: () => Value, options?: ReactiveOptions<Value>): Computed<Value>;
30
- declare abstract class Reactive<Value, Equal = Value> {
31
- protected readonly state: ReactiveState<Value, Equal>;
32
- constructor(name: string, value: Value, options?: ReactiveOptions<Equal>);
33
- /**
34
- * Get the value
35
- */
36
- abstract get(): Value;
37
- /**
38
- * Get the value _(without reactivity)_
39
- */
40
- peek(): Value;
41
- /**
42
- * Subscribe to changes
43
- */
44
- subscribe(callback: (value: Value) => void): Unsubscribe;
45
- /**
46
- * JSON representation of the value
47
- */
48
- toJSON(): Value;
49
- /**
50
- * String representation of the value
51
- */
52
- toString(): string;
53
- /**
54
- * Unsubscribe from changes
55
- */
56
- unsubscribe(callback: (value: Value) => void): void;
57
- }
58
- export type ReactiveOptions<Value> = {
59
- /**
60
- * Method to compare values for equality
61
- */
62
- equal?: (first: Value, second: Value) => boolean;
63
- };
64
- export type ReactiveState<Value, Equal> = {
65
- computeds: Set<Computed<unknown>>;
66
- effects: Set<Effect>;
67
- equal: (first: Equal, second: Equal) => boolean;
68
- subscriptions: Map<GenericCallback, Subscription>;
69
- value: Value;
70
- };
71
- declare class Subscription {
72
- state: ReactiveState<unknown, never>;
73
- callback: GenericCallback;
74
- constructor(state: ReactiveState<unknown, never>, callback: GenericCallback);
75
- }
76
- /**
77
- * Unsubscribe from changes
78
- */
79
- export type Unsubscribe = () => void;
80
-
81
- export {};
@@ -1,68 +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
- export 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
-
68
- export {};
@@ -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 {};
@@ -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 {};