@ng-org/alien-deepsignals 0.1.2

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.
@@ -0,0 +1,238 @@
1
+ import { signal as signal$1, computed as computed$1 } from 'alien-signals';
2
+ export { computed as _rawComputed, effect as _rawEffect, endBatch as _rawEndBatch, getCurrentSub as _rawGetCurrentSub, setCurrentSub as _rawSetCurrentSub, signal as _rawSignal, startBatch as _rawStartBatch } from 'alien-signals';
3
+
4
+ /** Lightweight facade adding ergonomic helpers (.value/.peek/.get/.set) to native alien-signals function signals. */
5
+
6
+ /** Internal shape of a tagged writable signal after adding ergonomic helpers. */
7
+ type TaggedSignal<T> = ReturnType<typeof signal$1<T>> & {
8
+ /** Tracking read / write via property syntax */
9
+ value: T;
10
+ /** Non-tracking read */
11
+ peek(): T;
12
+ /** Alias for tracking read */
13
+ get(): T;
14
+ /** Write helper */
15
+ set(v: T): void;
16
+ };
17
+ /**
18
+ * Create a new writable function-form signal enhanced with `.value`, `.peek()`, `.get()`, `.set()`.
19
+ *
20
+ * @example
21
+ * const count = signal(0);
22
+ * count(); // 0 (track)
23
+ * count(1); // write
24
+ * count.value; // 1 (track)
25
+ * count.peek(); // 1 (non-tracking)
26
+ */
27
+ declare const signal: <T>(v?: T) => TaggedSignal<any>;
28
+ /** Internal shape of a tagged computed signal after adding ergonomic helpers. */
29
+ type TaggedComputed<T> = ReturnType<typeof computed$1<T>> & {
30
+ /** Tracking read via property syntax (readonly) */
31
+ readonly value: T;
32
+ /** Non-tracking read */
33
+ peek(): T;
34
+ /** Alias for tracking read */
35
+ get(): T;
36
+ };
37
+ /**
38
+ * Create a lazy computed (readonly) signal derived from other signals.
39
+ *
40
+ * Computed signals are automatically cached and only recompute when their tracked
41
+ * dependencies change. The getter function is evaluated lazily—if you never read
42
+ * the computed value, the computation never runs.
43
+ *
44
+ * The returned function can be called directly `computed()` or accessed via `.value`.
45
+ * Use `.peek()` for non-tracking reads (won't establish reactive dependency).
46
+ *
47
+ * @example
48
+ * const count = signal(5);
49
+ * const doubled = computed(() => count() * 2);
50
+ * doubled(); // 10 (establishes dependency, caches result)
51
+ * doubled.value; // 10 (cached, same as calling it)
52
+ * doubled.peek(); // 10 (no dependency tracking)
53
+ * count(10);
54
+ * doubled(); // 20 (recomputed because count changed)
55
+ */
56
+ declare const computed: <T>(getter: () => T) => TaggedComputed<T>;
57
+ /** Union allowing a plain value or a writable signal wrapping that value. */
58
+ type MaybeSignal<T = any> = T | ReturnType<typeof signal>;
59
+ /** Union allowing value, writable signal, computed signal or plain getter function. */
60
+ type MaybeSignalOrGetter<T = any> = MaybeSignal<T> | ReturnType<typeof computed> | (() => T);
61
+ /** Runtime guard that an unknown value is one of our tagged signals/computeds. */
62
+ declare const isSignal: (s: any) => boolean;
63
+ /**
64
+ * Execute multiple signal writes in a single batched update frame.
65
+ * All downstream computed/effect re-evaluations are deferred until the function exits.
66
+ *
67
+ * IMPORTANT: The callback MUST be synchronous. If it returns a Promise the batch will
68
+ * still end immediately after scheduling, possibly causing mid-async flushes.
69
+ *
70
+ * @example
71
+ * batch(() => {
72
+ * count(count() + 1);
73
+ * other(other() + 2);
74
+ * }); // effects observing both run only once
75
+ */
76
+ declare function batch<T>(fn: () => T): T;
77
+
78
+ /** Deep mutation emitted from a deepSignal root. */
79
+ type DeepPatch = {
80
+ path: (string | number)[];
81
+ } & ({
82
+ op: "add";
83
+ type?: "object" | "set";
84
+ value?: any;
85
+ } | {
86
+ op: "remove";
87
+ type?: "set";
88
+ value?: any;
89
+ });
90
+ /** Batched patch payload tagged with a monotonically increasing version. */
91
+ interface DeepPatchBatch {
92
+ version: number;
93
+ patches: DeepPatch[];
94
+ }
95
+ /** Batched patch payload for justInTime listeners. */
96
+ interface DeepPatchJITBatch {
97
+ patches: DeepPatch[];
98
+ }
99
+ type DeepPatchSubscriber = (batch: DeepPatchBatch) => void;
100
+ type DeepPatchJITSubscriber = (batch: DeepPatchJITBatch) => void;
101
+ interface DeepSignalOptions {
102
+ propGenerator?: DeepSignalPropGenFn;
103
+ syntheticIdPropertyName?: string;
104
+ readOnlyProps?: string[];
105
+ }
106
+ type DeepSignalPropGenFn = (props: {
107
+ path: (string | number)[];
108
+ inSet: boolean;
109
+ object: any;
110
+ }) => {
111
+ syntheticId?: string | number;
112
+ extraProps?: Record<string, unknown>;
113
+ };
114
+ interface ProxyMeta {
115
+ raw: object;
116
+ parent?: object;
117
+ key?: string | number | symbol;
118
+ isSyntheticId?: boolean;
119
+ root: symbol;
120
+ options: DeepSignalOptions;
121
+ setInfo?: SetMeta;
122
+ }
123
+ interface SetMeta {
124
+ idForObject: WeakMap<object, string>;
125
+ objectForId: Map<string, object>;
126
+ }
127
+ interface RootState {
128
+ options?: DeepSignalOptions;
129
+ version: number;
130
+ justInTimeListeners: Set<DeepPatchJITSubscriber>;
131
+ listeners: Set<DeepPatchSubscriber>;
132
+ pendingPatches: DeepPatch[];
133
+ }
134
+ type WritableSignalFunction<T> = typeof signal<T>;
135
+ type ComputedSignalFunction<T> = typeof computed<T>;
136
+ type WritableSignal<T = any> = ReturnType<WritableSignalFunction<T>>;
137
+ type ComputedSignal<T = any> = ReturnType<ComputedSignalFunction<T>>;
138
+ type SignalLike<T = any> = WritableSignal<T> | ComputedSignal<T>;
139
+ /** Raw and meta key. */
140
+ type DeepSignalObjectProps<T> = {
141
+ __raw__: T;
142
+ __meta__: ProxyMeta;
143
+ };
144
+ /** Utility functions for sets. */
145
+ type DeepSignalSetProps<T> = {
146
+ /** Get the element that was first inserted into the set. */
147
+ first(): undefined | (T extends object ? DeepSignal<T> : T);
148
+ /**
149
+ * Retrieve an entry from the Set by its synthetic ID.
150
+ * @param id - The synthetic ID (string or number) assigned to the entry.
151
+ * @returns The proxied entry if found, undefined otherwise.
152
+ */
153
+ getById(id: string | number): DeepSignal<T> | undefined;
154
+ /**
155
+ * Retrieve an entry from the Set by constructing an ID from graphIri and subjectIri.
156
+ * This is a convenience method that constructs the ID as "graphIri|subjectIri".
157
+ * @param graphIri - The graph IRI part of the identifier.
158
+ * @param subjectIri - The subject IRI part of the identifier.
159
+ * @returns The proxied entry if found, undefined otherwise.
160
+ */
161
+ getBy(graphIri: string, subjectIri: string): DeepSignal<T> | undefined;
162
+ };
163
+ /** Reactive Set wrapper that accepts raw or proxied entries. */
164
+ interface DeepSignalSet<T> extends Set<DeepSignal<T>>, DeepSignalObjectProps<Set<T>>, SetIterator<DeepSignal<T>>, DeepSignalSetProps<T> {
165
+ add(value: T | DeepSignal<T>): this;
166
+ delete(value: T | DeepSignal<T>): boolean;
167
+ has(value: T | DeepSignal<T>): boolean;
168
+ forEach(callbackfn: (value: DeepSignal<T>, value2: DeepSignal<T>, set: DeepSignalSet<T>) => void, thisArg?: any): void;
169
+ forEach(callbackfn: (value: DeepSignal<T>, index: number) => void, thisArg?: any): void;
170
+ }
171
+ /**
172
+ * The object returned by the @see deepSignal function.
173
+ * It is decorated with utility functions for sets and a
174
+ * `__raw__` prop to get the underlying non-reactive object
175
+ * and `__meta__` prop, to get the internal metadata.
176
+ */
177
+ type DeepSignal<T> = T extends Function ? T : T extends string | number | boolean ? T : T extends DeepSignalObjectProps<any> | DeepSignalObjectProps<any>[] ? T : T extends Array<infer I> ? DeepSignal<I>[] : T extends Set<infer S> ? DeepSignalSet<S> : T extends object ? DeepSignalObject<T> : T;
178
+ type DeepSignalObject<T extends object> = {
179
+ [K in keyof T]: DeepSignal<T[K]>;
180
+ };
181
+ type RevertDeepSignal<T> = T extends DeepSignal<infer S> ? S : T;
182
+
183
+ /** Runtime guard that checks whether a value is a deepSignal proxy. */
184
+ declare function isDeepSignal(value: any): boolean;
185
+ /**
186
+ * Create a deep reactive proxy for objects, arrays or Sets.
187
+ * Returns the input itself, if it's a deepSignal already.
188
+ * Throws if provided with unsupported input types.
189
+ */
190
+ declare function deepSignal<T extends object>(input: T, options?: DeepSignalOptions): DeepSignal<T>;
191
+ /**
192
+ * Low-level function, you should probably use `watch` instead.
193
+ *
194
+ * Register a deep mutation subscriber for the provided root or proxy.
195
+ */
196
+ declare function subscribeDeepMutations(root: object | symbol, cb: DeepPatchSubscriber | DeepPatchJITSubscriber, triggerInstantly?: boolean): () => void;
197
+ /** Return the root identifier symbol for a deepSignal proxy (if any). */
198
+ declare function getDeepSignalRootId(value: any): symbol | undefined;
199
+ /** Retrieve the current patch version for a deepSignal root (if tracked). */
200
+ declare function getDeepSignalVersion(root: object | symbol): number | undefined;
201
+ /** Mark an object so deepSignal skips proxying it (shallow boundary). */
202
+ declare function shallow<T extends object>(obj: T): T;
203
+ /** Force a specific synthetic ID to be used for a Set entry prior to insertion. */
204
+ declare function setSetEntrySyntheticId(obj: object, id: string | number): void;
205
+ /** Convenience helper to add an entry to a proxied Set with a pre-defined synthetic ID. */
206
+ declare function addWithId<T>(set: Set<T>, entry: T, id: string | number): T;
207
+
208
+ type RegisterCleanup$1 = (cleanupFn: () => void) => void;
209
+ interface WatchOptions {
210
+ /** True, if the callback should be run immediately after `watch` was called. @default false*/
211
+ immediate?: boolean;
212
+ /** True, if the watcher should be unsubscribed after the first event. @default false*/
213
+ once?: boolean;
214
+ /**
215
+ * If true, triggers watch callback instantly after changes to the signal object.
216
+ * Otherwise, changes are batched and the watch callback is triggered in a microtask.
217
+ * This is useful for frontends like React where modifications on the changed input in
218
+ * a separate (microtask) will cause the cursor in input elements to reset.
219
+ */
220
+ triggerInstantly?: boolean;
221
+ }
222
+ interface WatchPatchEvent<T extends object> {
223
+ patches: DeepPatch[];
224
+ /** The version if `triggerInstantly` is not true. */
225
+ version?: number;
226
+ newValue: DeepSignal<T>;
227
+ }
228
+ type WatchPatchCallback<T extends object> = (event: WatchPatchEvent<T>) => void;
229
+ declare function watch<T extends object>(source: DeepSignal<T>, callback: WatchPatchCallback<T>, options?: WatchOptions): {
230
+ stopListening: () => void;
231
+ registerCleanup: RegisterCleanup$1;
232
+ };
233
+
234
+ type RegisterCleanup = (cleanup: () => void) => void;
235
+ /** Wrap `alien-signals` effect with optional cleanup registration. */
236
+ declare function effect(run: (registerCleanup?: RegisterCleanup) => void): () => void;
237
+
238
+ export { type ComputedSignal, type DeepPatch, type DeepPatchBatch, type DeepPatchJITBatch, type DeepPatchJITSubscriber, type DeepPatchSubscriber, type DeepSignal, type DeepSignalObject, type DeepSignalObjectProps, type DeepSignalOptions, type DeepSignalPropGenFn, type DeepSignalSet, type DeepSignalSetProps, type MaybeSignal, type MaybeSignalOrGetter, type ProxyMeta, type RegisterCleanup$1 as RegisterCleanup, type RevertDeepSignal, type RootState, type SetMeta, type SignalLike, type WatchOptions, type WatchPatchCallback, type WatchPatchEvent, type WritableSignal, addWithId, batch, computed, deepSignal, effect, getDeepSignalRootId, getDeepSignalVersion, isDeepSignal, isSignal, setSetEntrySyntheticId, shallow, signal, subscribeDeepMutations, watch };
@@ -0,0 +1,238 @@
1
+ import { signal as signal$1, computed as computed$1 } from 'alien-signals';
2
+ export { computed as _rawComputed, effect as _rawEffect, endBatch as _rawEndBatch, getCurrentSub as _rawGetCurrentSub, setCurrentSub as _rawSetCurrentSub, signal as _rawSignal, startBatch as _rawStartBatch } from 'alien-signals';
3
+
4
+ /** Lightweight facade adding ergonomic helpers (.value/.peek/.get/.set) to native alien-signals function signals. */
5
+
6
+ /** Internal shape of a tagged writable signal after adding ergonomic helpers. */
7
+ type TaggedSignal<T> = ReturnType<typeof signal$1<T>> & {
8
+ /** Tracking read / write via property syntax */
9
+ value: T;
10
+ /** Non-tracking read */
11
+ peek(): T;
12
+ /** Alias for tracking read */
13
+ get(): T;
14
+ /** Write helper */
15
+ set(v: T): void;
16
+ };
17
+ /**
18
+ * Create a new writable function-form signal enhanced with `.value`, `.peek()`, `.get()`, `.set()`.
19
+ *
20
+ * @example
21
+ * const count = signal(0);
22
+ * count(); // 0 (track)
23
+ * count(1); // write
24
+ * count.value; // 1 (track)
25
+ * count.peek(); // 1 (non-tracking)
26
+ */
27
+ declare const signal: <T>(v?: T) => TaggedSignal<any>;
28
+ /** Internal shape of a tagged computed signal after adding ergonomic helpers. */
29
+ type TaggedComputed<T> = ReturnType<typeof computed$1<T>> & {
30
+ /** Tracking read via property syntax (readonly) */
31
+ readonly value: T;
32
+ /** Non-tracking read */
33
+ peek(): T;
34
+ /** Alias for tracking read */
35
+ get(): T;
36
+ };
37
+ /**
38
+ * Create a lazy computed (readonly) signal derived from other signals.
39
+ *
40
+ * Computed signals are automatically cached and only recompute when their tracked
41
+ * dependencies change. The getter function is evaluated lazily—if you never read
42
+ * the computed value, the computation never runs.
43
+ *
44
+ * The returned function can be called directly `computed()` or accessed via `.value`.
45
+ * Use `.peek()` for non-tracking reads (won't establish reactive dependency).
46
+ *
47
+ * @example
48
+ * const count = signal(5);
49
+ * const doubled = computed(() => count() * 2);
50
+ * doubled(); // 10 (establishes dependency, caches result)
51
+ * doubled.value; // 10 (cached, same as calling it)
52
+ * doubled.peek(); // 10 (no dependency tracking)
53
+ * count(10);
54
+ * doubled(); // 20 (recomputed because count changed)
55
+ */
56
+ declare const computed: <T>(getter: () => T) => TaggedComputed<T>;
57
+ /** Union allowing a plain value or a writable signal wrapping that value. */
58
+ type MaybeSignal<T = any> = T | ReturnType<typeof signal>;
59
+ /** Union allowing value, writable signal, computed signal or plain getter function. */
60
+ type MaybeSignalOrGetter<T = any> = MaybeSignal<T> | ReturnType<typeof computed> | (() => T);
61
+ /** Runtime guard that an unknown value is one of our tagged signals/computeds. */
62
+ declare const isSignal: (s: any) => boolean;
63
+ /**
64
+ * Execute multiple signal writes in a single batched update frame.
65
+ * All downstream computed/effect re-evaluations are deferred until the function exits.
66
+ *
67
+ * IMPORTANT: The callback MUST be synchronous. If it returns a Promise the batch will
68
+ * still end immediately after scheduling, possibly causing mid-async flushes.
69
+ *
70
+ * @example
71
+ * batch(() => {
72
+ * count(count() + 1);
73
+ * other(other() + 2);
74
+ * }); // effects observing both run only once
75
+ */
76
+ declare function batch<T>(fn: () => T): T;
77
+
78
+ /** Deep mutation emitted from a deepSignal root. */
79
+ type DeepPatch = {
80
+ path: (string | number)[];
81
+ } & ({
82
+ op: "add";
83
+ type?: "object" | "set";
84
+ value?: any;
85
+ } | {
86
+ op: "remove";
87
+ type?: "set";
88
+ value?: any;
89
+ });
90
+ /** Batched patch payload tagged with a monotonically increasing version. */
91
+ interface DeepPatchBatch {
92
+ version: number;
93
+ patches: DeepPatch[];
94
+ }
95
+ /** Batched patch payload for justInTime listeners. */
96
+ interface DeepPatchJITBatch {
97
+ patches: DeepPatch[];
98
+ }
99
+ type DeepPatchSubscriber = (batch: DeepPatchBatch) => void;
100
+ type DeepPatchJITSubscriber = (batch: DeepPatchJITBatch) => void;
101
+ interface DeepSignalOptions {
102
+ propGenerator?: DeepSignalPropGenFn;
103
+ syntheticIdPropertyName?: string;
104
+ readOnlyProps?: string[];
105
+ }
106
+ type DeepSignalPropGenFn = (props: {
107
+ path: (string | number)[];
108
+ inSet: boolean;
109
+ object: any;
110
+ }) => {
111
+ syntheticId?: string | number;
112
+ extraProps?: Record<string, unknown>;
113
+ };
114
+ interface ProxyMeta {
115
+ raw: object;
116
+ parent?: object;
117
+ key?: string | number | symbol;
118
+ isSyntheticId?: boolean;
119
+ root: symbol;
120
+ options: DeepSignalOptions;
121
+ setInfo?: SetMeta;
122
+ }
123
+ interface SetMeta {
124
+ idForObject: WeakMap<object, string>;
125
+ objectForId: Map<string, object>;
126
+ }
127
+ interface RootState {
128
+ options?: DeepSignalOptions;
129
+ version: number;
130
+ justInTimeListeners: Set<DeepPatchJITSubscriber>;
131
+ listeners: Set<DeepPatchSubscriber>;
132
+ pendingPatches: DeepPatch[];
133
+ }
134
+ type WritableSignalFunction<T> = typeof signal<T>;
135
+ type ComputedSignalFunction<T> = typeof computed<T>;
136
+ type WritableSignal<T = any> = ReturnType<WritableSignalFunction<T>>;
137
+ type ComputedSignal<T = any> = ReturnType<ComputedSignalFunction<T>>;
138
+ type SignalLike<T = any> = WritableSignal<T> | ComputedSignal<T>;
139
+ /** Raw and meta key. */
140
+ type DeepSignalObjectProps<T> = {
141
+ __raw__: T;
142
+ __meta__: ProxyMeta;
143
+ };
144
+ /** Utility functions for sets. */
145
+ type DeepSignalSetProps<T> = {
146
+ /** Get the element that was first inserted into the set. */
147
+ first(): undefined | (T extends object ? DeepSignal<T> : T);
148
+ /**
149
+ * Retrieve an entry from the Set by its synthetic ID.
150
+ * @param id - The synthetic ID (string or number) assigned to the entry.
151
+ * @returns The proxied entry if found, undefined otherwise.
152
+ */
153
+ getById(id: string | number): DeepSignal<T> | undefined;
154
+ /**
155
+ * Retrieve an entry from the Set by constructing an ID from graphIri and subjectIri.
156
+ * This is a convenience method that constructs the ID as "graphIri|subjectIri".
157
+ * @param graphIri - The graph IRI part of the identifier.
158
+ * @param subjectIri - The subject IRI part of the identifier.
159
+ * @returns The proxied entry if found, undefined otherwise.
160
+ */
161
+ getBy(graphIri: string, subjectIri: string): DeepSignal<T> | undefined;
162
+ };
163
+ /** Reactive Set wrapper that accepts raw or proxied entries. */
164
+ interface DeepSignalSet<T> extends Set<DeepSignal<T>>, DeepSignalObjectProps<Set<T>>, SetIterator<DeepSignal<T>>, DeepSignalSetProps<T> {
165
+ add(value: T | DeepSignal<T>): this;
166
+ delete(value: T | DeepSignal<T>): boolean;
167
+ has(value: T | DeepSignal<T>): boolean;
168
+ forEach(callbackfn: (value: DeepSignal<T>, value2: DeepSignal<T>, set: DeepSignalSet<T>) => void, thisArg?: any): void;
169
+ forEach(callbackfn: (value: DeepSignal<T>, index: number) => void, thisArg?: any): void;
170
+ }
171
+ /**
172
+ * The object returned by the @see deepSignal function.
173
+ * It is decorated with utility functions for sets and a
174
+ * `__raw__` prop to get the underlying non-reactive object
175
+ * and `__meta__` prop, to get the internal metadata.
176
+ */
177
+ type DeepSignal<T> = T extends Function ? T : T extends string | number | boolean ? T : T extends DeepSignalObjectProps<any> | DeepSignalObjectProps<any>[] ? T : T extends Array<infer I> ? DeepSignal<I>[] : T extends Set<infer S> ? DeepSignalSet<S> : T extends object ? DeepSignalObject<T> : T;
178
+ type DeepSignalObject<T extends object> = {
179
+ [K in keyof T]: DeepSignal<T[K]>;
180
+ };
181
+ type RevertDeepSignal<T> = T extends DeepSignal<infer S> ? S : T;
182
+
183
+ /** Runtime guard that checks whether a value is a deepSignal proxy. */
184
+ declare function isDeepSignal(value: any): boolean;
185
+ /**
186
+ * Create a deep reactive proxy for objects, arrays or Sets.
187
+ * Returns the input itself, if it's a deepSignal already.
188
+ * Throws if provided with unsupported input types.
189
+ */
190
+ declare function deepSignal<T extends object>(input: T, options?: DeepSignalOptions): DeepSignal<T>;
191
+ /**
192
+ * Low-level function, you should probably use `watch` instead.
193
+ *
194
+ * Register a deep mutation subscriber for the provided root or proxy.
195
+ */
196
+ declare function subscribeDeepMutations(root: object | symbol, cb: DeepPatchSubscriber | DeepPatchJITSubscriber, triggerInstantly?: boolean): () => void;
197
+ /** Return the root identifier symbol for a deepSignal proxy (if any). */
198
+ declare function getDeepSignalRootId(value: any): symbol | undefined;
199
+ /** Retrieve the current patch version for a deepSignal root (if tracked). */
200
+ declare function getDeepSignalVersion(root: object | symbol): number | undefined;
201
+ /** Mark an object so deepSignal skips proxying it (shallow boundary). */
202
+ declare function shallow<T extends object>(obj: T): T;
203
+ /** Force a specific synthetic ID to be used for a Set entry prior to insertion. */
204
+ declare function setSetEntrySyntheticId(obj: object, id: string | number): void;
205
+ /** Convenience helper to add an entry to a proxied Set with a pre-defined synthetic ID. */
206
+ declare function addWithId<T>(set: Set<T>, entry: T, id: string | number): T;
207
+
208
+ type RegisterCleanup$1 = (cleanupFn: () => void) => void;
209
+ interface WatchOptions {
210
+ /** True, if the callback should be run immediately after `watch` was called. @default false*/
211
+ immediate?: boolean;
212
+ /** True, if the watcher should be unsubscribed after the first event. @default false*/
213
+ once?: boolean;
214
+ /**
215
+ * If true, triggers watch callback instantly after changes to the signal object.
216
+ * Otherwise, changes are batched and the watch callback is triggered in a microtask.
217
+ * This is useful for frontends like React where modifications on the changed input in
218
+ * a separate (microtask) will cause the cursor in input elements to reset.
219
+ */
220
+ triggerInstantly?: boolean;
221
+ }
222
+ interface WatchPatchEvent<T extends object> {
223
+ patches: DeepPatch[];
224
+ /** The version if `triggerInstantly` is not true. */
225
+ version?: number;
226
+ newValue: DeepSignal<T>;
227
+ }
228
+ type WatchPatchCallback<T extends object> = (event: WatchPatchEvent<T>) => void;
229
+ declare function watch<T extends object>(source: DeepSignal<T>, callback: WatchPatchCallback<T>, options?: WatchOptions): {
230
+ stopListening: () => void;
231
+ registerCleanup: RegisterCleanup$1;
232
+ };
233
+
234
+ type RegisterCleanup = (cleanup: () => void) => void;
235
+ /** Wrap `alien-signals` effect with optional cleanup registration. */
236
+ declare function effect(run: (registerCleanup?: RegisterCleanup) => void): () => void;
237
+
238
+ export { type ComputedSignal, type DeepPatch, type DeepPatchBatch, type DeepPatchJITBatch, type DeepPatchJITSubscriber, type DeepPatchSubscriber, type DeepSignal, type DeepSignalObject, type DeepSignalObjectProps, type DeepSignalOptions, type DeepSignalPropGenFn, type DeepSignalSet, type DeepSignalSetProps, type MaybeSignal, type MaybeSignalOrGetter, type ProxyMeta, type RegisterCleanup$1 as RegisterCleanup, type RevertDeepSignal, type RootState, type SetMeta, type SignalLike, type WatchOptions, type WatchPatchCallback, type WatchPatchEvent, type WritableSignal, addWithId, batch, computed, deepSignal, effect, getDeepSignalRootId, getDeepSignalVersion, isDeepSignal, isSignal, setSetEntrySyntheticId, shallow, signal, subscribeDeepMutations, watch };