@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.
@@ -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 };