@oscarpalmer/mora 0.27.0 → 0.29.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/constants.d.mts +19 -1
- package/dist/effect.d.mts +26 -1
- package/dist/helpers/is.d.mts +4 -2
- package/dist/helpers/proxy.d.mts +3 -2
- package/dist/helpers/proxy.mjs +36 -14
- package/dist/helpers/value.d.mts +1 -1
- package/dist/helpers/value.mjs +2 -1
- package/dist/index.d.mts +5 -2
- package/dist/models.d.mts +61 -1
- package/dist/mora.full.mjs +187 -84
- package/dist/subscription.d.mts +14 -1
- package/dist/value/array.d.mts +20 -4
- package/dist/value/array.mjs +19 -16
- package/dist/value/computed.d.mts +20 -1
- package/dist/value/computed.mjs +32 -11
- package/dist/value/reactive.d.mts +50 -1
- package/dist/value/reactive.mjs +5 -0
- package/dist/value/signal.d.mts +43 -1
- package/dist/value/signal.mjs +27 -11
- package/dist/value/store.d.mts +18 -3
- package/dist/value/store.mjs +31 -11
- package/package.json +6 -5
- package/src/effect.ts +10 -0
- package/src/helpers/proxy.ts +64 -17
- package/src/helpers/value.ts +2 -1
- package/src/models.ts +3 -1
- package/src/value/array.ts +74 -18
- package/src/value/computed.ts +65 -30
- package/src/value/reactive.ts +13 -0
- package/src/value/signal.ts +77 -9
- package/src/value/store.ts +100 -11
- package/types/constants.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/types/value/array.d.ts +1 -1
- package/types/value/computed.d.ts +0 -3
- package/types/value/signal.d.ts +1 -1
- package/types/value/store.d.ts +1 -1
- package/dist/constants-Cy6_M9Vk.d.mts +0 -20
- package/dist/effect-BkupB1p9.d.mts +0 -17
- package/dist/models-QwNga87R.d.mts +0 -148
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { t as Effect } from "./effect-BkupB1p9.mjs";
|
|
2
|
-
import { GenericCallback } from "@oscarpalmer/atoms/models";
|
|
3
|
-
|
|
4
|
-
//#region src/subscription.d.ts
|
|
5
|
-
declare class Subscription {
|
|
6
|
-
callback: GenericCallback;
|
|
7
|
-
state: ReactiveState<unknown, never>;
|
|
8
|
-
constructor(state: ReactiveState<unknown, never>, callback: GenericCallback);
|
|
9
|
-
destroy(): void;
|
|
10
|
-
}
|
|
11
|
-
declare function noop(): void;
|
|
12
|
-
declare function subscribe<Value>(state: ReactiveState<Value, never>, callback: (value: Value) => void): Unsubscribe;
|
|
13
|
-
declare function unsubscribe<Value>(state: ReactiveState<Value, never>, callback: (value: Value) => void): void;
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/value/reactive.d.ts
|
|
16
|
-
declare abstract class Reactive<Value, Equal = Value> {
|
|
17
|
-
protected readonly state: ReactiveState<Value, Equal>;
|
|
18
|
-
constructor(name: string, value: Value, options?: ReactiveOptions<Equal>);
|
|
19
|
-
/**
|
|
20
|
-
* Get the value
|
|
21
|
-
* @return Current value
|
|
22
|
-
*/
|
|
23
|
-
abstract get(): Value;
|
|
24
|
-
/**
|
|
25
|
-
* Get the value _(without reactivity)_
|
|
26
|
-
* @return Current value
|
|
27
|
-
*/
|
|
28
|
-
peek(): Value;
|
|
29
|
-
/**
|
|
30
|
-
* Subscribe to changes
|
|
31
|
-
* @param callback Callback for changes
|
|
32
|
-
* @return Unsubscribe callback
|
|
33
|
-
*/
|
|
34
|
-
subscribe(callback: (value: Value) => void): Unsubscribe;
|
|
35
|
-
/**
|
|
36
|
-
* JSON representation of the value
|
|
37
|
-
* @return JSON value
|
|
38
|
-
*/
|
|
39
|
-
toJSON(): Value;
|
|
40
|
-
/**
|
|
41
|
-
* String representation of the value
|
|
42
|
-
* @return Value as string
|
|
43
|
-
*/
|
|
44
|
-
toString(): string;
|
|
45
|
-
/**
|
|
46
|
-
* Unsubscribe from changes
|
|
47
|
-
* @param callback Callback to unsubscribe
|
|
48
|
-
*/
|
|
49
|
-
unsubscribe(callback: (value: Value) => void): void;
|
|
50
|
-
}
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region src/value/computed.d.ts
|
|
53
|
-
declare class Computed<Value> extends Reactive<Value> {
|
|
54
|
-
private readonly effect;
|
|
55
|
-
constructor(callback: () => Value, options?: ReactiveOptions<Value>);
|
|
56
|
-
/**
|
|
57
|
-
* @inheritdoc
|
|
58
|
-
*/
|
|
59
|
-
get(): Value;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Create a computed value
|
|
63
|
-
* @param callback Callback to compute the value
|
|
64
|
-
* @param options Reactivity options
|
|
65
|
-
* @returns Computed value
|
|
66
|
-
*/
|
|
67
|
-
declare function computed<Value>(callback: () => Value, options?: ReactiveOptions<Value>): Computed<Value>;
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/value/signal.d.ts
|
|
70
|
-
declare class Signal<Value> extends Reactive<Value> {
|
|
71
|
-
constructor(value: Value, options?: ReactiveOptions<Value>);
|
|
72
|
-
/**
|
|
73
|
-
* @inheritdoc
|
|
74
|
-
*/
|
|
75
|
-
get(): Value;
|
|
76
|
-
/**
|
|
77
|
-
* Set the value
|
|
78
|
-
* @param value New value
|
|
79
|
-
*/
|
|
80
|
-
set(value: Value): void;
|
|
81
|
-
/**
|
|
82
|
-
* Update the value _(based on the current value)_
|
|
83
|
-
* @param callback Callback to update the value
|
|
84
|
-
*/
|
|
85
|
-
update(callback: (value: Value) => Value): void;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Create a reactive value
|
|
89
|
-
* @param value Initial value
|
|
90
|
-
* @param options Reactivity options
|
|
91
|
-
* @returns Reactive value
|
|
92
|
-
*/
|
|
93
|
-
declare function signal<Value>(value: Value, options?: ReactiveOptions<Value>): Signal<Value>;
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/models.d.ts
|
|
96
|
-
type Active = {
|
|
97
|
-
computed?: Computed<unknown>;
|
|
98
|
-
effect?: Effect;
|
|
99
|
-
};
|
|
100
|
-
type Batch = {
|
|
101
|
-
depth: number;
|
|
102
|
-
handlers: Set<Effect | Subscription>;
|
|
103
|
-
};
|
|
104
|
-
type ComputedEffect = {
|
|
105
|
-
dirty: boolean;
|
|
106
|
-
instance: Effect;
|
|
107
|
-
};
|
|
108
|
-
type EffectState = {
|
|
109
|
-
callback: GenericCallback;
|
|
110
|
-
};
|
|
111
|
-
type InternalComputed = {
|
|
112
|
-
readonly effect: ComputedEffect;
|
|
113
|
-
readonly state: ReactiveState<unknown, unknown>;
|
|
114
|
-
};
|
|
115
|
-
type InternalEffect = {
|
|
116
|
-
state: EffectState;
|
|
117
|
-
};
|
|
118
|
-
type ReactiveOptions<Value> = {
|
|
119
|
-
/**
|
|
120
|
-
* Method for comparing values for equality
|
|
121
|
-
* @param first First value
|
|
122
|
-
* @param second Second value
|
|
123
|
-
* @returns Are the values equal?
|
|
124
|
-
* @default Object.is
|
|
125
|
-
*/
|
|
126
|
-
equal?: (first: Value, second: Value) => boolean;
|
|
127
|
-
};
|
|
128
|
-
type ReactiveState<Value, Equal> = {
|
|
129
|
-
computeds: Set<Computed<unknown>>;
|
|
130
|
-
effects: Set<Effect>;
|
|
131
|
-
equal: (first: Equal, second: Equal) => boolean;
|
|
132
|
-
subscriptions: Map<GenericCallback, Subscription>;
|
|
133
|
-
value: Value;
|
|
134
|
-
};
|
|
135
|
-
type SetValueInProxyParameters<Value, Equal> = {
|
|
136
|
-
target: Value;
|
|
137
|
-
property: PropertyKey;
|
|
138
|
-
value: unknown;
|
|
139
|
-
state: ReactiveState<Value, Equal>;
|
|
140
|
-
isArray: boolean;
|
|
141
|
-
length?: Signal<number>;
|
|
142
|
-
};
|
|
143
|
-
/**
|
|
144
|
-
* Unsubscribe from changes
|
|
145
|
-
*/
|
|
146
|
-
type Unsubscribe = () => void;
|
|
147
|
-
//#endregion
|
|
148
|
-
export { noop as _, InternalComputed as a, ReactiveState as c, Signal as d, signal as f, Subscription as g, Reactive as h, EffectState as i, SetValueInProxyParameters as l, computed as m, Batch as n, InternalEffect as o, Computed as p, ComputedEffect as r, ReactiveOptions as s, Active as t, Unsubscribe as u, subscribe as v, unsubscribe as y };
|