@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.
Files changed (70) hide show
  1. package/dist/batch.js +11 -25
  2. package/dist/constants.js +34 -0
  3. package/dist/effect.js +18 -28
  4. package/dist/helpers/is.js +9 -26
  5. package/dist/helpers/proxy.js +36 -48
  6. package/dist/helpers/value.js +21 -48
  7. package/dist/index.js +3 -16
  8. package/dist/models.js +0 -0
  9. package/dist/mora.full.js +218 -130
  10. package/dist/subscription.js +22 -28
  11. package/dist/value/array.js +97 -182
  12. package/dist/value/computed.js +33 -58
  13. package/dist/value/reactive.js +29 -53
  14. package/dist/value/signal.js +21 -33
  15. package/dist/value/store.js +37 -60
  16. package/package.json +17 -24
  17. package/src/batch.ts +11 -13
  18. package/src/constants.ts +49 -0
  19. package/src/effect.ts +11 -16
  20. package/src/helpers/is.ts +41 -19
  21. package/src/helpers/proxy.ts +34 -38
  22. package/src/helpers/value.ts +19 -14
  23. package/src/index.ts +1 -1
  24. package/src/models.ts +66 -0
  25. package/src/subscription.ts +14 -16
  26. package/src/value/array.ts +87 -45
  27. package/src/value/computed.ts +29 -39
  28. package/src/value/reactive.ts +9 -24
  29. package/src/value/signal.ts +9 -3
  30. package/src/value/store.ts +40 -9
  31. package/types/batch.d.ts +3 -5
  32. package/types/constants.d.ts +14 -0
  33. package/types/effect.d.ts +2 -1
  34. package/types/helpers/is.d.ts +23 -10
  35. package/types/helpers/proxy.d.ts +2 -3
  36. package/types/helpers/value.d.ts +1 -1
  37. package/types/index.d.ts +1 -0
  38. package/types/models.d.ts +56 -0
  39. package/types/subscription.d.ts +3 -6
  40. package/types/value/array.d.ts +48 -7
  41. package/types/value/computed.d.ts +2 -11
  42. package/types/value/reactive.d.ts +8 -17
  43. package/types/value/signal.d.ts +7 -1
  44. package/types/value/store.d.ts +28 -4
  45. package/dist/batch.cjs +0 -32
  46. package/dist/effect.cjs +0 -30
  47. package/dist/helpers/is.cjs +0 -40
  48. package/dist/helpers/proxy.cjs +0 -56
  49. package/dist/helpers/value.cjs +0 -54
  50. package/dist/index.cjs +0 -21
  51. package/dist/node_modules/@oscarpalmer/atoms/dist/internal/is.cjs +0 -17
  52. package/dist/node_modules/@oscarpalmer/atoms/dist/internal/is.js +0 -17
  53. package/dist/subscription.cjs +0 -32
  54. package/dist/value/array.cjs +0 -187
  55. package/dist/value/computed.cjs +0 -60
  56. package/dist/value/reactive.cjs +0 -55
  57. package/dist/value/signal.cjs +0 -36
  58. package/dist/value/store.cjs +0 -63
  59. package/types/batch.d.cts +0 -79
  60. package/types/effect.d.cts +0 -16
  61. package/types/helpers/is.d.cts +0 -259
  62. package/types/helpers/proxy.d.cts +0 -244
  63. package/types/helpers/value.d.cts +0 -71
  64. package/types/index.d.cts +0 -281
  65. package/types/subscription.d.cts +0 -71
  66. package/types/value/array.d.cts +0 -161
  67. package/types/value/computed.d.cts +0 -81
  68. package/types/value/reactive.d.cts +0 -68
  69. package/types/value/signal.d.cts +0 -87
  70. package/types/value/store.d.cts +0 -136
@@ -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 {};