mutts 1.0.8 → 1.0.10

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 (195) hide show
  1. package/README.md +77 -35
  2. package/dist/browser.cjs +2144 -5355
  3. package/dist/browser.cjs.map +1 -1
  4. package/dist/browser.d.ts +2 -1655
  5. package/dist/browser.dev.cjs +110 -0
  6. package/dist/browser.dev.cjs.map +1 -0
  7. package/dist/browser.dev.d.ts +2 -0
  8. package/dist/browser.dev.esm.js +5 -0
  9. package/dist/browser.dev.esm.js.map +1 -0
  10. package/dist/browser.esm.js +20 -107
  11. package/dist/browser.esm.js.map +1 -1
  12. package/dist/chunks/{async-browser-CA0jPWIi.cjs → async-browser-BU_IfxYD.cjs} +19 -107
  13. package/dist/chunks/async-browser-BU_IfxYD.cjs.map +1 -0
  14. package/dist/chunks/{async-core-UqHzvJ-S.cjs → async-core-CRLKP3l-.cjs} +8 -4
  15. package/dist/chunks/async-core-CRLKP3l-.cjs.map +1 -0
  16. package/dist/chunks/{async-node-BYHuGTni.cjs → async-node-3PrbVAbB.cjs} +7 -12
  17. package/dist/chunks/async-node-3PrbVAbB.cjs.map +1 -0
  18. package/dist/chunks/index-CaaQQlPJ.esm.js +3174 -0
  19. package/dist/chunks/index-CaaQQlPJ.esm.js.map +1 -0
  20. package/dist/chunks/node-nKJBk8iJ.esm.js +96 -0
  21. package/dist/chunks/node-nKJBk8iJ.esm.js.map +1 -0
  22. package/dist/chunks/proxy-Dtg-bJ3T.cjs +3763 -0
  23. package/dist/chunks/proxy-Dtg-bJ3T.cjs.map +1 -0
  24. package/dist/chunks/proxy-r7lARftl.esm.js +3701 -0
  25. package/dist/chunks/proxy-r7lARftl.esm.js.map +1 -0
  26. package/dist/debug.cjs +980 -0
  27. package/dist/debug.cjs.map +1 -0
  28. package/dist/debug.d.ts +208 -0
  29. package/dist/debug.esm.js +950 -0
  30. package/dist/debug.esm.js.map +1 -0
  31. package/dist/devtools/manifest.json +1 -1
  32. package/dist/devtools/panel.html +1 -1
  33. package/dist/devtools/panel.js +107 -94
  34. package/dist/devtools/panel.js.map +1 -1
  35. package/dist/index.d.ts +1447 -13
  36. package/dist/mutts.umd.js +7167 -1
  37. package/dist/mutts.umd.js.map +1 -1
  38. package/dist/mutts.umd.min.js +1 -1
  39. package/dist/mutts.umd.min.js.map +1 -1
  40. package/dist/node.cjs +70 -66
  41. package/dist/node.cjs.map +1 -1
  42. package/dist/node.d.ts +2 -1
  43. package/dist/node.dev.cjs +110 -0
  44. package/dist/node.dev.cjs.map +1 -0
  45. package/dist/node.dev.d.ts +2 -0
  46. package/dist/node.dev.esm.js +6 -0
  47. package/dist/node.dev.esm.js.map +1 -0
  48. package/dist/node.esm.js +4 -103
  49. package/dist/node.esm.js.map +1 -1
  50. package/dist/{reactive/types.d.ts → types-W5vD6m2n.d.ts} +186 -93
  51. package/docs/ai/api-reference.md +12 -19
  52. package/docs/ai/manual.md +521 -17
  53. package/docs/events.md +57 -2
  54. package/docs/flavored.md +210 -0
  55. package/docs/reactive/advanced.md +314 -5
  56. package/docs/reactive/attend.md +142 -0
  57. package/docs/reactive/collections.md +76 -39
  58. package/docs/reactive/core.md +100 -14
  59. package/docs/reactive/debugging.md +123 -18
  60. package/docs/reactive/error-handling.md +121 -0
  61. package/docs/reactive/resource.md +125 -0
  62. package/docs/reactive/scan.md +247 -1
  63. package/docs/reactive.md +4 -1
  64. package/docs/std-decorators.md +102 -51
  65. package/docs/utils.md +70 -0
  66. package/docs/zone.md +3 -7
  67. package/package.json +64 -30
  68. package/dist/async/browser.d.ts +0 -2
  69. package/dist/async/browser.d.ts.map +0 -1
  70. package/dist/async/index.d.ts +0 -18
  71. package/dist/async/index.d.ts.map +0 -1
  72. package/dist/async/node.d.ts +0 -2
  73. package/dist/async/node.d.ts.map +0 -1
  74. package/dist/chunks/async-browser-CA0jPWIi.cjs.map +0 -1
  75. package/dist/chunks/async-core-UqHzvJ-S.cjs.map +0 -1
  76. package/dist/chunks/async-node-BYHuGTni.cjs.map +0 -1
  77. package/dist/chunks/index-DhaOVusv.esm.js +0 -6411
  78. package/dist/chunks/index-DhaOVusv.esm.js.map +0 -1
  79. package/dist/decorator.d.ts +0 -106
  80. package/dist/decorator.d.ts.map +0 -1
  81. package/dist/destroyable.d.ts +0 -87
  82. package/dist/destroyable.d.ts.map +0 -1
  83. package/dist/entry-browser.d.ts +0 -3
  84. package/dist/entry-browser.d.ts.map +0 -1
  85. package/dist/entry-node.d.ts +0 -3
  86. package/dist/entry-node.d.ts.map +0 -1
  87. package/dist/eventful.d.ts +0 -18
  88. package/dist/eventful.d.ts.map +0 -1
  89. package/dist/index.d.ts.map +0 -1
  90. package/dist/indexable.d.ts +0 -243
  91. package/dist/indexable.d.ts.map +0 -1
  92. package/dist/introspection.d.ts +0 -27
  93. package/dist/introspection.d.ts.map +0 -1
  94. package/dist/iterableWeak.d.ts +0 -53
  95. package/dist/iterableWeak.d.ts.map +0 -1
  96. package/dist/mixins.d.ts +0 -25
  97. package/dist/mixins.d.ts.map +0 -1
  98. package/dist/promiseChain.d.ts +0 -20
  99. package/dist/promiseChain.d.ts.map +0 -1
  100. package/dist/reactive/array.d.ts +0 -49
  101. package/dist/reactive/array.d.ts.map +0 -1
  102. package/dist/reactive/buffer.d.ts +0 -44
  103. package/dist/reactive/buffer.d.ts.map +0 -1
  104. package/dist/reactive/change.d.ts +0 -29
  105. package/dist/reactive/change.d.ts.map +0 -1
  106. package/dist/reactive/debug.d.ts +0 -111
  107. package/dist/reactive/debug.d.ts.map +0 -1
  108. package/dist/reactive/deep-touch.d.ts +0 -28
  109. package/dist/reactive/deep-touch.d.ts.map +0 -1
  110. package/dist/reactive/deep-watch-state.d.ts +0 -25
  111. package/dist/reactive/deep-watch-state.d.ts.map +0 -1
  112. package/dist/reactive/deep-watch.d.ts +0 -19
  113. package/dist/reactive/deep-watch.d.ts.map +0 -1
  114. package/dist/reactive/effect-context.d.ts +0 -7
  115. package/dist/reactive/effect-context.d.ts.map +0 -1
  116. package/dist/reactive/effects.d.ts +0 -151
  117. package/dist/reactive/effects.d.ts.map +0 -1
  118. package/dist/reactive/index.d.ts +0 -20
  119. package/dist/reactive/index.d.ts.map +0 -1
  120. package/dist/reactive/interface.d.ts +0 -64
  121. package/dist/reactive/interface.d.ts.map +0 -1
  122. package/dist/reactive/map.d.ts +0 -30
  123. package/dist/reactive/map.d.ts.map +0 -1
  124. package/dist/reactive/memoize.d.ts +0 -5
  125. package/dist/reactive/memoize.d.ts.map +0 -1
  126. package/dist/reactive/non-reactive-state.d.ts +0 -9
  127. package/dist/reactive/non-reactive-state.d.ts.map +0 -1
  128. package/dist/reactive/non-reactive.d.ts +0 -11
  129. package/dist/reactive/non-reactive.d.ts.map +0 -1
  130. package/dist/reactive/project.d.ts +0 -41
  131. package/dist/reactive/project.d.ts.map +0 -1
  132. package/dist/reactive/proxy-state.d.ts +0 -8
  133. package/dist/reactive/proxy-state.d.ts.map +0 -1
  134. package/dist/reactive/proxy.d.ts +0 -23
  135. package/dist/reactive/proxy.d.ts.map +0 -1
  136. package/dist/reactive/record.d.ts +0 -116
  137. package/dist/reactive/record.d.ts.map +0 -1
  138. package/dist/reactive/register.d.ts +0 -64
  139. package/dist/reactive/register.d.ts.map +0 -1
  140. package/dist/reactive/registry.d.ts +0 -20
  141. package/dist/reactive/registry.d.ts.map +0 -1
  142. package/dist/reactive/set.d.ts +0 -28
  143. package/dist/reactive/set.d.ts.map +0 -1
  144. package/dist/reactive/tracking.d.ts +0 -7
  145. package/dist/reactive/tracking.d.ts.map +0 -1
  146. package/dist/reactive/types.d.ts.map +0 -1
  147. package/dist/std-decorators.d.ts +0 -50
  148. package/dist/std-decorators.d.ts.map +0 -1
  149. package/dist/utils.d.ts +0 -49
  150. package/dist/utils.d.ts.map +0 -1
  151. package/dist/zone.d.ts +0 -40
  152. package/dist/zone.d.ts.map +0 -1
  153. package/docs/reactive/project.md +0 -93
  154. package/src/async/browser.ts +0 -319
  155. package/src/async/index.ts +0 -23
  156. package/src/async/node.ts +0 -104
  157. package/src/decorator.ts +0 -272
  158. package/src/destroyable.ts +0 -199
  159. package/src/entry-browser.ts +0 -5
  160. package/src/entry-node.ts +0 -5
  161. package/src/eventful.ts +0 -77
  162. package/src/index.d.ts +0 -12
  163. package/src/index.ts +0 -64
  164. package/src/indexable.ts +0 -526
  165. package/src/introspection.ts +0 -59
  166. package/src/iterableWeak.ts +0 -233
  167. package/src/mixins.ts +0 -123
  168. package/src/promiseChain.ts +0 -110
  169. package/src/reactive/array.ts +0 -507
  170. package/src/reactive/buffer.ts +0 -168
  171. package/src/reactive/change.ts +0 -138
  172. package/src/reactive/debug.ts +0 -517
  173. package/src/reactive/deep-touch.ts +0 -268
  174. package/src/reactive/deep-watch-state.ts +0 -82
  175. package/src/reactive/deep-watch.ts +0 -168
  176. package/src/reactive/effect-context.ts +0 -18
  177. package/src/reactive/effects.ts +0 -1382
  178. package/src/reactive/index.ts +0 -75
  179. package/src/reactive/interface.ts +0 -210
  180. package/src/reactive/map.ts +0 -158
  181. package/src/reactive/memoize.ts +0 -163
  182. package/src/reactive/non-reactive-state.ts +0 -49
  183. package/src/reactive/non-reactive.ts +0 -43
  184. package/src/reactive/project.ts +0 -453
  185. package/src/reactive/proxy-state.ts +0 -27
  186. package/src/reactive/proxy.ts +0 -264
  187. package/src/reactive/record.ts +0 -196
  188. package/src/reactive/register.ts +0 -419
  189. package/src/reactive/registry.ts +0 -59
  190. package/src/reactive/set.ts +0 -130
  191. package/src/reactive/tracking.ts +0 -44
  192. package/src/reactive/types.ts +0 -440
  193. package/src/std-decorators.ts +0 -217
  194. package/src/utils.ts +0 -301
  195. package/src/zone.ts +0 -138
package/dist/index.d.ts CHANGED
@@ -1,13 +1,1447 @@
1
- export * from './decorator';
2
- export * from './destroyable';
3
- export * from './eventful';
4
- export * from './indexable';
5
- export * from './iterableWeak';
6
- export * from './mixins';
7
- export * from './promiseChain';
8
- export * from './reactive';
9
- export * from './std-decorators';
10
- export * from './utils';
11
- export * from './zone';
12
- export * from './async';
13
- //# sourceMappingURL=index.d.ts.map
1
+ import { c as cleanup, S as ScopedCallback, d as EffectCloser, e as EffectAccess, f as State, a as Evolution, b as EffectCleanup, Z as ZoneAggregator, C as CatchFunction, E as EffectTrigger, g as EffectOptions } from './types-W5vD6m2n.js';
2
+ export { A as AZone, h as CleanupReason, F as FunctionWrapper, P as PropTrigger, R as ReactiveError, i as ReactiveErrorCode, j as Zone, k as ZoneHistory, l as asyncZone, m as formatCleanupReason, n as isReactive, o as objectToProxy, p as proxyToObject, q as reactiveOptions, s as stopped, u as unwrap } from './types-W5vD6m2n.js';
3
+
4
+ type Restorer = () => () => void;
5
+ type Hook = () => Restorer;
6
+ declare const hooks$1: Set<Hook>;
7
+ declare const asyncHooks: {
8
+ addHook(hook: Hook): () => void;
9
+ /**
10
+ * [Hack] Sanitize a promise (or value) to prevent context leaks.
11
+ * Default: Identity function.
12
+ * Browser: Uses Macrotask wrapping to break microtask chains.
13
+ */
14
+ sanitizePromise(p: any): any;
15
+ };
16
+ /**
17
+ * Register a hook that will be called whenever an asynchronous operation is initiated.
18
+ * The hook should return a restorer function which will be called just before the async callback runs.
19
+ * That restorer should in turn return an undoer function which will be called just after the async callback finishes.
20
+ */
21
+ declare const asyncHook: (hook: Hook) => () => void;
22
+
23
+ /**
24
+ * Error thrown when decorator operations fail
25
+ */
26
+ declare class DecoratorError extends Error {
27
+ constructor(message: string);
28
+ }
29
+ /**
30
+ * Legacy property decorator type for methods, getters, and setters
31
+ */
32
+ type LegacyPropertyDecorator<T> = (target: T, name: string | symbol, descriptor: PropertyDescriptor) => any;
33
+ /**
34
+ * Legacy class decorator type
35
+ */
36
+ type LegacyClassDecorator<T> = (target: T) => any;
37
+ /**
38
+ * Modern method decorator type
39
+ */
40
+ type ModernMethodDecorator<T> = (target: T, context: ClassMethodDecoratorContext) => any;
41
+ /**
42
+ * Modern getter decorator type
43
+ */
44
+ type ModernGetterDecorator<T> = (target: T, context: ClassGetterDecoratorContext) => any;
45
+ /**
46
+ * Modern setter decorator type
47
+ */
48
+ type ModernSetterDecorator<T> = (target: T, context: ClassSetterDecoratorContext) => any;
49
+ /**
50
+ * Modern accessor decorator type
51
+ */
52
+ type ModernAccessorDecorator<T> = (target: T, context: ClassAccessorDecoratorContext) => any;
53
+ /**
54
+ * Modern class decorator type
55
+ */
56
+ type ModernClassDecorator<T> = (target: T, context: ClassDecoratorContext) => any;
57
+ type DDMethod<T> = (original: (this: T, ...args: any[]) => any, target: any, name: PropertyKey) => ((this: T, ...args: any[]) => any) | void;
58
+ type DDGetter<T> = (original: (this: T) => any, target: any, name: PropertyKey) => ((this: T) => any) | void;
59
+ type DDSetter<T> = (original: (this: T, value: any) => void, target: any, name: PropertyKey) => ((this: T, value: any) => void) | void;
60
+ type DDClass<T> = <Ctor extends new (...args: any[]) => T = new (...args: any[]) => T>(target: Ctor) => Ctor | void;
61
+ /**
62
+ * Description object for creating decorators that work with both Legacy and Modern decorator proposals
63
+ */
64
+ interface DecoratorDescription<T> {
65
+ /** Handler for method decorators */
66
+ method?: DDMethod<T>;
67
+ /** Handler for class decorators */
68
+ class?: DDClass<T>;
69
+ /** Handler for getter decorators */
70
+ getter?: DDGetter<T>;
71
+ /** Handler for setter decorators */
72
+ setter?: DDSetter<T>;
73
+ /** Default handler for any decorator type not explicitly defined */
74
+ default?: (...args: any[]) => any;
75
+ }
76
+ /**
77
+ * Type for decorators that work with both Legacy and Modern decorator proposals
78
+ * Automatically infers the correct decorator type based on the description
79
+ */
80
+ type Decorator<T, Description extends DecoratorDescription<T>> = (Description extends {
81
+ method: DDMethod<T>;
82
+ } ? LegacyPropertyDecorator<T> & ModernMethodDecorator<T> : unknown) & (Description extends {
83
+ class: DDClass<new (...args: any[]) => T>;
84
+ } ? LegacyClassDecorator<new (...args: any[]) => T> & ModernClassDecorator<new (...args: any[]) => T> : unknown) & (Description extends {
85
+ getter: DDGetter<T>;
86
+ } ? LegacyPropertyDecorator<T> & ModernGetterDecorator<T> & ModernAccessorDecorator<T> : unknown) & (Description extends {
87
+ setter: DDSetter<T>;
88
+ } ? LegacyPropertyDecorator<T> & ModernSetterDecorator<T> & ModernAccessorDecorator<T> : unknown) & (Description extends {
89
+ default: infer Signature;
90
+ } ? Signature : unknown);
91
+ /**
92
+ * Factory type for creating decorators that work with both Legacy and Modern decorator proposals
93
+ */
94
+ type DecoratorFactory<T> = <Description extends DecoratorDescription<T>>(description: Description) => (Description extends {
95
+ method: DDMethod<T>;
96
+ } ? LegacyPropertyDecorator<T> & ModernMethodDecorator<T> : unknown) & (Description extends {
97
+ class: DDClass<new (...args: any[]) => T>;
98
+ } ? LegacyClassDecorator<new (...args: any[]) => T> & ModernClassDecorator<new (...args: any[]) => T> : unknown) & (Description extends {
99
+ getter: DDGetter<T>;
100
+ } ? LegacyPropertyDecorator<T> & ModernGetterDecorator<T> & ModernAccessorDecorator<T> : unknown) & (Description extends {
101
+ setter: DDSetter<T>;
102
+ } ? LegacyPropertyDecorator<T> & ModernSetterDecorator<T> & ModernAccessorDecorator<T> : unknown) & (Description extends {
103
+ default: infer Signature;
104
+ } ? Signature : unknown);
105
+ /**
106
+ * Creates a decorator that works with Legacy decorator proposals
107
+ * @param description - The decorator description object
108
+ * @returns A decorator function compatible with Legacy decorators
109
+ */
110
+ declare function legacyDecorator<T = any>(description: DecoratorDescription<T>): any;
111
+ /**
112
+ * Creates a decorator that works with Modern decorator proposals
113
+ * @param description - The decorator description object
114
+ * @returns A decorator function compatible with Modern decorators
115
+ */
116
+ declare function modernDecorator<T = any>(description: DecoratorDescription<T>): any;
117
+ /**
118
+ * Main decorator factory that automatically detects and works with both Legacy and Modern decorator proposals
119
+ * @param description - The decorator description object
120
+ * @returns A decorator that works in both Legacy and Modern environments
121
+ */
122
+ declare const decorator: DecoratorFactory<any>;
123
+ /**
124
+ * Generic class decorator type that works with both Legacy and Modern decorator proposals
125
+ */
126
+ type GenericClassDecorator<T> = LegacyClassDecorator<abstract new (...args: any[]) => T> & ModernClassDecorator<abstract new (...args: any[]) => T>;
127
+
128
+ /**
129
+ * Symbol for marking destructor methods
130
+ */
131
+ declare const destructor: unique symbol;
132
+ /**
133
+ * Symbol for accessing allocated values in destroyable objects
134
+ */
135
+ declare const allocatedValues: unique symbol;
136
+ /**
137
+ * Error thrown when attempting to access a destroyed object
138
+ */
139
+ declare class DestructionError extends Error {
140
+ static throw<_T = void>(msg: string): () => never;
141
+ constructor(msg: string);
142
+ }
143
+ declare abstract class AbstractDestroyable<Allocated> {
144
+ abstract [destructor](allocated: Allocated): void;
145
+ [Symbol.dispose](): void;
146
+ }
147
+ interface Destructor<Allocated> {
148
+ destructor(allocated: Allocated): void;
149
+ }
150
+ /**
151
+ * Creates a destroyable class with a base class and destructor object
152
+ * @param base - The base class to extend
153
+ * @param destructorObj - Object containing the destructor method
154
+ * @returns A destroyable class with static destroy and isDestroyable methods
155
+ */
156
+ declare function Destroyable<T extends new (...args: any[]) => any, Allocated extends Partial<InstanceType<T>>>(base: T, destructorObj: Destructor<Allocated>): (new (...args: ConstructorParameters<T>) => InstanceType<T> & {
157
+ [allocatedValues]: Allocated;
158
+ }) & {
159
+ destroy(obj: InstanceType<T>): boolean;
160
+ isDestroyable(obj: InstanceType<T>): boolean;
161
+ };
162
+ /**
163
+ * Creates a destroyable class with only a destructor object (no base class)
164
+ * @param destructorObj - Object containing the destructor method
165
+ * @returns A destroyable class with static destroy and isDestroyable methods
166
+ */
167
+ declare function Destroyable<Allocated extends Record<PropertyKey, any> = Record<PropertyKey, any>>(destructorObj: Destructor<Allocated>): (new () => {
168
+ [allocatedValues]: Allocated;
169
+ }) & {
170
+ destroy(obj: any): boolean;
171
+ isDestroyable(obj: any): boolean;
172
+ };
173
+ /**
174
+ * Creates a destroyable class with a base class (requires [destructor] method)
175
+ * @param base - The base class to extend
176
+ * @returns A destroyable class with static destroy and isDestroyable methods
177
+ */
178
+ declare function Destroyable<T extends new (...args: any[]) => any, Allocated extends Record<PropertyKey, any> = Record<PropertyKey, any>>(base: T): (new (...args: ConstructorParameters<T>) => AbstractDestroyable<Allocated> & InstanceType<T> & {
179
+ [allocatedValues]: Allocated;
180
+ }) & {
181
+ destroy(obj: InstanceType<T>): boolean;
182
+ isDestroyable(obj: InstanceType<T>): boolean;
183
+ };
184
+ /**
185
+ * Creates an abstract destroyable base class
186
+ * @returns An abstract destroyable class with static destroy and isDestroyable methods
187
+ */
188
+ declare function Destroyable<Allocated extends Record<PropertyKey, any> = Record<PropertyKey, any>>(): abstract new () => (AbstractDestroyable<Allocated> & {
189
+ [allocatedValues]: Allocated;
190
+ }) & {
191
+ destroy(obj: any): boolean;
192
+ isDestroyable(obj: any): boolean;
193
+ };
194
+ /**
195
+ * Decorator that marks properties to be stored in the allocated object and passed to the destructor
196
+ * Use with accessor properties or explicit get/set pairs
197
+ */
198
+ declare const allocated: LegacyPropertyDecorator<any> & ModernSetterDecorator<any> & ModernAccessorDecorator<any>;
199
+ /**
200
+ * Registers a callback to be called when an object is garbage collected
201
+ * @param cb - The callback function to execute on garbage collection
202
+ * @returns The object whose reference can be collected
203
+ */
204
+ declare function callOnGC(cb: () => void): () => void;
205
+ /**
206
+ * Context Manager Protocol for `using` statement integration
207
+ * Provides automatic resource cleanup when used with the `using` statement
208
+ */
209
+ interface ContextManager<T = any> {
210
+ [Symbol.dispose](): void;
211
+ value?: T;
212
+ }
213
+
214
+ interface ArrayDiffResult<T> {
215
+ indexA: number;
216
+ indexB: number;
217
+ sliceA: T[];
218
+ sliceB: T[];
219
+ }
220
+ /**
221
+ * Myers' diff producing grouped patches: `{indexA, indexB, sliceA, sliceB}[]`.
222
+ * - O(N) for identical or prefix/suffix-only differences
223
+ * - O(ND) for small D, with a hard bailout at D=BAILOUT_D → single replacement patch
224
+ */
225
+ declare function arrayDiff<T>(A: readonly T[], B: readonly T[]): ArrayDiffResult<T>[];
226
+
227
+ /**
228
+ * Base type for event maps - all event handlers must be functions
229
+ */
230
+ type EventsBase = Record<string, (...args: any[]) => void>;
231
+ declare const events: unique symbol;
232
+ declare const hooks: unique symbol;
233
+ /**
234
+ * A type-safe event system that provides a clean API for event handling
235
+ * @template Events - The event map defining event names and their handler signatures
236
+ */
237
+ declare class Eventful<Events extends EventsBase> {
238
+ private readonly [events];
239
+ private readonly [hooks];
240
+ hook(cb: <EventType extends keyof Events>(event: EventType, ...args: Parameters<Events[EventType]>) => void): () => void;
241
+ on: ((events: Partial<Events>) => void) & (<EventType extends keyof Events>(event: EventType, cb: Events[EventType]) => () => void) & { [event in keyof Events]: (cb: Events[event]) => () => void; };
242
+ off: ((events: Partial<Events>) => void) & (<EventType extends keyof Events>(event: EventType, cb?: Events[EventType]) => void) & { [event in keyof Events]: (cb?: Events[event]) => void; };
243
+ emit: (<EventType extends keyof Events>(event: EventType, ...args: Parameters<Events[EventType]>) => void) & Events;
244
+ }
245
+
246
+ /**
247
+ * Creates a flavored (extensible) version of a function with chainable property modifiers.
248
+ */
249
+ declare function flavored<T extends (...args: any[]) => any, F>(fn: T, flavors: F & ThisType<T & F>): T & F;
250
+ /**
251
+ * Creates a new flavored function that transforms arguments before calling the base.
252
+ *
253
+ * @param fn - The base flavored function
254
+ * @param transform - Function that receives the original arguments and returns transformed arguments
255
+ * @returns A new flavored function with the transformation applied
256
+ *
257
+ * @example
258
+ * ```typescript
259
+ * const loudGreet = createFlavor(greet, (name, opts) => [name, { ...opts, loud: true }])
260
+ * ```
261
+ */
262
+ declare function createFlavor<T extends (...args: any[]) => any>(fn: T, transform: (...args: Parameters<T>) => Parameters<T>, name?: string): T;
263
+ /**
264
+ * Creates a new flavored function that merges options objects at a specific index.
265
+ * By default, uses the function's arity (length) as the index for options.
266
+ *
267
+ * @param fn - The base flavored function
268
+ * @param defaultOptions - Options to merge
269
+ * @param optionsIndex - Optional explicit index for options (defaults to fn.length)
270
+ * @param name - Optional name for the wrapper
271
+ * @returns A new flavored function
272
+ */
273
+ declare function flavorOptions<T extends (...args: any[]) => any>(fn: T, defaultOptions: Record<string, any>, opts?: {
274
+ optionsIndex?: number;
275
+ name?: string;
276
+ }): T;
277
+
278
+ /**
279
+ * Symbol for defining custom getter logic for numeric index access
280
+ */
281
+ declare const getAt: unique symbol;
282
+ /**
283
+ * Symbol for defining custom setter logic for numeric index access
284
+ */
285
+ declare const setAt: unique symbol;
286
+ interface IndexingAt<Items = any> {
287
+ [getAt](index: number): Items;
288
+ }
289
+ interface Accessor<T, Items> {
290
+ get(this: T, index: number): Items;
291
+ set?(this: T, index: number, value: Items): void;
292
+ getLength?(this: T): number;
293
+ setLength?(this: T, value: number): void;
294
+ }
295
+ declare abstract class AbstractGetAt<Items = any> {
296
+ abstract [getAt](index: number): Items;
297
+ }
298
+ /**
299
+ * Creates an indexable class with a base class and accessor object
300
+ * @param base - The base class to extend
301
+ * @param accessor - Object containing get/set methods for numeric index access
302
+ * @returns A class that supports numeric index access
303
+ */
304
+ declare function Indexable<Items, Base extends abstract new (...args: any[]) => any>(base: Base, accessor: Accessor<InstanceType<Base>, Items>): new (...args: ConstructorParameters<Base>) => InstanceType<Base> & {
305
+ [x: number]: Items;
306
+ };
307
+ /**
308
+ * Creates an indexable class with only an accessor object (no base class)
309
+ * @param accessor - Object containing get/set methods for numeric index access
310
+ * @returns A class that supports numeric index access
311
+ */
312
+ declare function Indexable<Items>(accessor: Accessor<any, Items>): new () => {
313
+ [x: number]: Items;
314
+ };
315
+ /**
316
+ * Creates an indexable class with a base class that has [getAt] method
317
+ * @param base - The base class that implements [getAt] method
318
+ * @returns A class that supports numeric index access using the base class's [getAt] method
319
+ */
320
+ declare function Indexable<Base extends new (...args: any[]) => IndexingAt>(base: Base): new (...args: ConstructorParameters<Base>) => InstanceType<Base> & {
321
+ [x: number]: AtReturnType<InstanceType<Base>>;
322
+ };
323
+ /**
324
+ * Creates an abstract indexable base class
325
+ * @returns An abstract class that supports numeric index access
326
+ */
327
+ declare function Indexable<Items>(): abstract new (...args: any[]) => AbstractGetAt & {
328
+ [x: number]: Items;
329
+ };
330
+ type AtReturnType<T> = T extends {
331
+ [getAt](index: number): infer R;
332
+ } ? R : never;
333
+ /**
334
+ * Symbol for accessing the forwarded array in ArrayReadForward
335
+ */
336
+ declare const forwardArray: unique symbol;
337
+ /**
338
+ * A read-only array forwarder that implements all reading/iterating methods of Array
339
+ * but does not implement modification methods.
340
+ *
341
+ * The constructor takes a callback that returns an array, and all methods forward
342
+ * their behavior to the result of that callback.
343
+ */
344
+ declare class ArrayReadForward<T> {
345
+ protected get [forwardArray](): readonly T[];
346
+ /**
347
+ * Get the length of the array
348
+ */
349
+ get length(): number;
350
+ /**
351
+ * Get an element at a specific index
352
+ */
353
+ [index: number]: T | undefined;
354
+ /**
355
+ * Iterator protocol support
356
+ */
357
+ [Symbol.iterator](): Iterator<T>;
358
+ /**
359
+ * Creates a new array with the results of calling a provided function on every element
360
+ */
361
+ map<U>(callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any): U[];
362
+ /**
363
+ * Creates a new array with all elements that pass the test implemented by the provided function
364
+ */
365
+ filter<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S[];
366
+ filter(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T[];
367
+ /**
368
+ * Executes a reducer function on each element of the array, resulting in a single output value
369
+ */
370
+ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T;
371
+ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T;
372
+ reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U;
373
+ /**
374
+ * Executes a reducer function on each element of the array (right-to-left), resulting in a single output value
375
+ */
376
+ reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T;
377
+ reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T;
378
+ reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U;
379
+ /**
380
+ * Executes a provided function once for each array element
381
+ */
382
+ forEach(callbackfn: (value: T, index: number, array: readonly T[]) => void, thisArg?: any): void;
383
+ /**
384
+ * Returns the value of the first element in the array that satisfies the provided testing function
385
+ */
386
+ find<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S | undefined;
387
+ find(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T | undefined;
388
+ /**
389
+ * Returns the index of the first element in the array that satisfies the provided testing function
390
+ */
391
+ findIndex(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): number;
392
+ /**
393
+ * Returns the value of the last element in the array that satisfies the provided testing function
394
+ */
395
+ findLast<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S | undefined;
396
+ findLast(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T | undefined;
397
+ /**
398
+ * Returns the index of the last element in the array that satisfies the provided testing function
399
+ */
400
+ findLastIndex(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): number;
401
+ /**
402
+ * Determines whether an array includes a certain value among its entries
403
+ */
404
+ includes(searchElement: T, fromIndex?: number): boolean;
405
+ /**
406
+ * Returns the first index at which a given element can be found in the array
407
+ */
408
+ indexOf(searchElement: T, fromIndex?: number): number;
409
+ /**
410
+ * Returns the last index at which a given element can be found in the array
411
+ */
412
+ lastIndexOf(searchElement: T, fromIndex?: number): number;
413
+ /**
414
+ * Returns a shallow copy of a portion of an array into a new array object
415
+ */
416
+ slice(start?: number, end?: number): T[];
417
+ /**
418
+ * Returns a new array comprised of this array joined with other array(s) and/or value(s)
419
+ */
420
+ concat(...items: ConcatArray<T>[]): T[];
421
+ concat(...items: (T | ConcatArray<T>)[]): T[];
422
+ /**
423
+ * Tests whether all elements in the array pass the test implemented by the provided function
424
+ */
425
+ every(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean;
426
+ /**
427
+ * Tests whether at least one element in the array passes the test implemented by the provided function
428
+ */
429
+ some(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean;
430
+ /**
431
+ * Joins all elements of an array into a string
432
+ */
433
+ join(separator?: string): string;
434
+ /**
435
+ * Returns a new array iterator that contains the keys for each index in the array
436
+ */
437
+ keys(): IterableIterator<number>;
438
+ /**
439
+ * Returns a new array iterator that contains the values for each index in the array
440
+ */
441
+ values(): IterableIterator<T>;
442
+ /**
443
+ * Returns a new array iterator that contains the key/value pairs for each index in the array
444
+ */
445
+ entries(): IterableIterator<[number, T]>;
446
+ /**
447
+ * Returns a string representation of the array
448
+ */
449
+ toString(): string;
450
+ /**
451
+ * Returns a localized string representing the array
452
+ */
453
+ toLocaleString(locales?: string | string[], options?: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions): string;
454
+ /**
455
+ * Returns the element at the specified index, or undefined if the index is out of bounds
456
+ */
457
+ at(index: number): T | undefined;
458
+ /**
459
+ * Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth
460
+ */
461
+ flat(depth?: number): T[];
462
+ /**
463
+ * Returns a new array formed by applying a given callback function to each element of the array,
464
+ * and then flattening the result by one level
465
+ */
466
+ flatMap<U, This = undefined>(callback: (this: This, value: T, index: number, array: readonly T[]) => U | ReadonlyArray<U>, thisArg?: This): U[];
467
+ /**
468
+ * Returns a new array with elements in reversed order (ES2023)
469
+ */
470
+ toReversed(): T[];
471
+ /**
472
+ * Returns a new array with elements sorted (ES2023)
473
+ */
474
+ toSorted(compareFn?: ((a: T, b: T) => number) | undefined): T[];
475
+ /**
476
+ * Returns a new array with some elements removed and/or replaced at a given index (ES2023)
477
+ */
478
+ toSpliced(start: number, deleteCount?: number, ...items: T[]): T[];
479
+ /**
480
+ * Returns a new array with the element at the given index replaced with the given value (ES2023)
481
+ */
482
+ with(index: number, value: T): T[];
483
+ get [Symbol.unscopables](): {
484
+ readonly [x: number]: boolean;
485
+ readonly length?: boolean;
486
+ toString?: boolean;
487
+ toLocaleString?: boolean;
488
+ concat?: boolean;
489
+ join?: boolean;
490
+ slice?: boolean;
491
+ indexOf?: boolean;
492
+ lastIndexOf?: boolean;
493
+ every?: boolean;
494
+ some?: boolean;
495
+ forEach?: boolean;
496
+ map?: boolean;
497
+ filter?: boolean;
498
+ reduce?: boolean;
499
+ reduceRight?: boolean;
500
+ find?: boolean;
501
+ findIndex?: boolean;
502
+ entries?: boolean;
503
+ keys?: boolean;
504
+ values?: boolean;
505
+ includes?: boolean;
506
+ flatMap?: boolean;
507
+ flat?: boolean;
508
+ at?: boolean;
509
+ findLast?: boolean;
510
+ findLastIndex?: boolean;
511
+ toReversed?: boolean;
512
+ toSorted?: boolean;
513
+ toSpliced?: boolean;
514
+ with?: boolean;
515
+ [Symbol.iterator]?: boolean;
516
+ readonly [Symbol.unscopables]?: boolean;
517
+ };
518
+ }
519
+
520
+ /**
521
+ * Uses weak references but still may iterate through them
522
+ * Note: The behavior is highly dependant on the garbage collector - some entries are perhaps deemed to be collected: don't resuscitate them
523
+ */
524
+ declare class IterableWeakMap<K extends WeakKey, V> implements Map<K, V> {
525
+ private uuids;
526
+ private refs;
527
+ private readonly registry;
528
+ constructor(entries?: Iterable<[K, V]>);
529
+ private createIterator;
530
+ clear(): void;
531
+ delete(key: K): boolean;
532
+ forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
533
+ get(key: K): V | undefined;
534
+ has(key: K): boolean;
535
+ set(key: K, value: V): this;
536
+ get size(): number;
537
+ entries(): MapIterator<[K, V]>;
538
+ keys(): MapIterator<K>;
539
+ values(): MapIterator<V>;
540
+ [Symbol.iterator](): MapIterator<[K, V]>;
541
+ readonly [Symbol.toStringTag]: string;
542
+ }
543
+ /**
544
+ * Uses weak references but still may iterate through them
545
+ * Note: The behavior is highly dependant on the garbage collector - some entries are perhaps deemed to be collected: don't resuscitate them
546
+ */
547
+ declare class IterableWeakSet<K extends WeakKey> implements Set<K> {
548
+ private uuids;
549
+ private refs;
550
+ private readonly registry;
551
+ constructor(entries?: Iterable<K>);
552
+ private createIterator;
553
+ clear(): void;
554
+ add(value: K): this;
555
+ delete(value: K): boolean;
556
+ forEach(callbackfn: (value: K, value2: K, set: Set<K>) => void, thisArg?: any): void;
557
+ has(value: K): boolean;
558
+ get size(): number;
559
+ entries(): SetIterator<[K, K]>;
560
+ keys(): SetIterator<K>;
561
+ values(): SetIterator<K>;
562
+ [Symbol.iterator](): SetIterator<K>;
563
+ readonly [Symbol.toStringTag]: string;
564
+ union<U>(other: ReadonlySetLike<U>): Set<K | U>;
565
+ intersection<U>(other: ReadonlySetLike<U>): Set<K & U>;
566
+ difference<U>(other: ReadonlySetLike<U>): Set<K>;
567
+ symmetricDifference<U>(other: ReadonlySetLike<U>): Set<K | U>;
568
+ isSubsetOf(other: ReadonlySetLike<unknown>): boolean;
569
+ isSupersetOf(other: ReadonlySetLike<unknown>): boolean;
570
+ isDisjointFrom(other: ReadonlySetLike<unknown>): boolean;
571
+ }
572
+
573
+ /**
574
+ * A mixin function that takes a base class and returns a new class with mixed-in functionality
575
+ * @template Mixed - The functionality to be mixed in
576
+ */
577
+ type MixinFunction<Mixed> = <Base>(base: new (...args: any[]) => Base) => new (...args: any[]) => Base & Mixed;
578
+ /**
579
+ * A mixin class that can be used both as a base class and as a mixin function
580
+ * @template Mixed - The functionality to be mixed in
581
+ */
582
+ type MixinClass<Mixed> = new (...args: any[]) => Mixed;
583
+ /**
584
+ * Creates a mixin that can be used both as a class (extends) and as a function (mixin)
585
+ *
586
+ * This function supports:
587
+ * - Using mixins as base classes: `class MyClass extends MyMixin`
588
+ * - Using mixins as functions: `class MyClass extends MyMixin(SomeBase)`
589
+ * - Composing mixins: `const Composed = MixinA(MixinB)`
590
+ * - Type-safe property inference for all patterns
591
+ *
592
+ * @param mixinFunction - The function that creates the mixin
593
+ * @param unwrapFunction - Optional function to unwrap reactive objects for method calls
594
+ * @returns A mixin that can be used both as a class and as a function
595
+ */
596
+ declare function mixin<MixinFn extends (base: any) => new (...args: any[]) => any>(mixinFunction: MixinFn, unwrapFunction?: (obj: any) => any): (new (...args: any[]) => InstanceType<ReturnType<MixinFn>>) & (<Base>(base: abstract new (...args: any[]) => Base) => new (...args: any[]) => InstanceType<ReturnType<MixinFn>> & Base);
597
+
598
+ type Resolved<T> = T extends Promise<infer U> ? Resolved<U> : T extends (...args: infer Args) => infer R ? (...args: Args) => Resolved<R> : T extends object ? {
599
+ [k in keyof T]: k extends 'then' | 'catch' | 'finally' ? T[k] : Resolved<T[k]>;
600
+ } : T;
601
+ type PromiseAnd<T> = Resolved<T> & Promise<Resolved<T>>;
602
+ /**
603
+ * Type that transforms promises into chainable objects
604
+ * Allows calling methods directly on promise results without awaiting them first
605
+ */
606
+ type PromiseChain<T> = T extends (...args: infer Args) => infer R ? PromiseAnd<(...args: Args) => PromiseChain<Resolved<R>>> : T extends object ? PromiseAnd<{
607
+ [k in keyof T]: k extends 'then' | 'catch' | 'finally' ? T[k] : PromiseChain<Resolved<T[k]>>;
608
+ }> : Promise<Resolved<T>>;
609
+ /**
610
+ * Transforms a promise or value into a chainable object
611
+ * Allows calling methods directly on promise results without awaiting them first
612
+ * @param given - The promise or value to make chainable
613
+ * @returns A chainable version of the input
614
+ */
615
+ declare function chainPromise<T>(given: Promise<T> | T): PromiseChain<T>;
616
+
617
+ /**
618
+ * Reactively attends to each entry of a collection or each key yielded by an
619
+ * enumeration callback. For each key, an inner effect runs the callback. When a
620
+ * key disappears, its inner effect is disposed. The callback may return a cleanup
621
+ * (like a regular effect closer).
622
+ *
623
+ * Accepts arrays, records, Maps, Sets, or a raw `() => Iterable<Key>` callback.
624
+ *
625
+ * @example
626
+ * ```typescript
627
+ * // Record shorthand
628
+ * attend(record, (key) => { console.log(key, record[key]) })
629
+ *
630
+ * // Array shorthand
631
+ * attend(array, (index) => { console.log(index, array[index]) })
632
+ *
633
+ * // Raw enumeration callback
634
+ * attend(() => Object.keys(record), (key) => { ... })
635
+ * ```
636
+ */
637
+ declare function attend<T>(source: readonly T[], callback: (index: number) => EffectCloser | undefined): ScopedCallback;
638
+ declare function attend<K, V>(source: Map<K, V>, callback: (key: K) => EffectCloser | undefined): ScopedCallback;
639
+ declare function attend<T>(source: Set<T>, callback: (value: T) => EffectCloser | undefined): ScopedCallback;
640
+ declare function attend<S extends Record<PropertyKey, any>>(source: S, callback: (key: keyof S & string) => EffectCloser | undefined): ScopedCallback;
641
+ declare function attend<Key>(enumerate: () => Iterable<Key>, callback: (key: Key) => EffectCloser | undefined): ScopedCallback;
642
+ /**
643
+ * Result of a reactive scan, which is a reactive array of accumulated values
644
+ * with an attached cleanup function.
645
+ */
646
+ type ScanResult<Output> = readonly Output[] & {
647
+ [cleanup]: ScopedCallback;
648
+ };
649
+ /**
650
+ * Perform a reactive scan over an array of items.
651
+ *
652
+ * This implementation is highly optimized for performance and fine-grained reactivity:
653
+ * - **Incremental Updates**: Changes to an item only trigger re-computation from that
654
+ * point onwards in the result chain.
655
+ * - **Move Optimization**: If items are moved within the array, their accumulated
656
+ * values are reused as long as their predecessor remains the same.
657
+ * - **Duplicate Support**: Correctly handles multiple occurrences of the same object
658
+ * instance using an internal occurrence tracking mechanism.
659
+ * - **Memory Efficient**: Uses `WeakMap` for caching intermediates, which are
660
+ * automatically cleared when source items are garbage collected.
661
+ *
662
+ * @example
663
+ * ```typescript
664
+ * const source = reactive([{ val: 1 }, { val: 2 }, { val: 3 }])
665
+ * const sum = scan(source, (acc, item) => acc + item.val, 0)
666
+ *
667
+ * expect([...sum]).toEqual([1, 3, 6])
668
+ *
669
+ * // Modifying an item only re-computes subsequent sums
670
+ * source[1].val = 10
671
+ * expect([...sum]).toEqual([1, 11, 14])
672
+ * ```
673
+ *
674
+ * @param source The source array of objects (will be made reactive)
675
+ * @param callback The accumulator function called with (accumulator, currentItem)
676
+ * @param initialValue The starting value for the accumulation
677
+ * @returns A reactive array of accumulated values, with a [cleanup] property to stop the tracking
678
+ */
679
+ declare function scan<Input extends object, Output>(source: readonly Input[], callback: (acc: Output, val: Input) => Output, initialValue: Output): ScanResult<Output>;
680
+ /**
681
+ * Lifts a callback that returns an array into a reactive array that automatically
682
+ * synchronizes with the source array returned by the callback.
683
+ *
684
+ * The returned reactive array will update whenever the callback's dependencies change,
685
+ * efficiently syncing only the elements that differ from the previous result.
686
+ *
687
+ * @example
688
+ * ```typescript
689
+ * const items = reactive([1, 2, 3])
690
+ * const doubled = lift(() => items.map(x => x * 2))
691
+ *
692
+ * console.log([...doubled]) // [2, 4, 6]
693
+ *
694
+ * items.push(4)
695
+ * console.log([...doubled]) // [2, 4, 6, 8]
696
+ * ```
697
+ *
698
+ * @param cb Callback function that returns an array
699
+ * @returns A reactive array synchronized with the callback's result, with a [cleanup] property to stop tracking
700
+ */
701
+ declare function lift<Output extends any[]>(cb: (access: EffectAccess) => Output): Output & {
702
+ [cleanup]: ScopedCallback;
703
+ };
704
+ /**
705
+ * Lifts a callback that returns an object into a reactive object that automatically
706
+ * synchronizes with the source object returned by the callback.
707
+ *
708
+ * The returned reactive object will update whenever the callback's dependencies change,
709
+ * efficiently syncing only the properties that differ from the previous result using
710
+ * Object.assign(). Properties that no longer exist in the source are automatically removed.
711
+ *
712
+ * @example
713
+ * ```typescript
714
+ * const user = reactive({ name: 'John', age: 30 })
715
+ * const profile = lift(() => ({
716
+ * displayName: user.name.toUpperCase(),
717
+ * isAdult: user.age >= 18,
718
+ * description: `${user.name} is ${user.age} years old`
719
+ * }))
720
+ *
721
+ * console.log(profile.displayName) // JOHN
722
+ * console.log(profile.isAdult) // true
723
+ *
724
+ * user.name = 'Jane'
725
+ * console.log(profile.displayName) // JANE
726
+ * console.log(profile.description) // Jane is 30 years old
727
+ * ```
728
+ *
729
+ * @param cb Callback function that returns an object
730
+ * @returns A reactive object synchronized with the callback's result, with a [cleanup] property to stop tracking
731
+ */
732
+ declare function lift<Output extends object>(cb: (access: EffectAccess) => Output): Output & {
733
+ [cleanup]: ScopedCallback;
734
+ };
735
+ /**
736
+ * Options for `morph` and its variants.
737
+ *
738
+ * @property pure - When `true`, the mapping function is assumed pure (no reactive reads inside `fn`).
739
+ * Per-item effects are skipped and items are computed eagerly. When a predicate `(i) => boolean`,
740
+ * purity is evaluated per item — pure items skip the effect wrapper, non-pure items get their own.
741
+ */
742
+ type MorphOptions<I> = {
743
+ pure?: boolean | ((i: I) => boolean);
744
+ };
745
+ /**
746
+ * Unified reactive collection mapper. Dispatches to `morphArray`, `morphMap`, or `morphRecord`
747
+ * based on the source type. Access `morph.pure(source, fn)` for the `{ pure: true }` shorthand.
748
+ *
749
+ * @see morphArray
750
+ * @see morphMap
751
+ * @see morphRecord
752
+ */
753
+ type Morph = {
754
+ <I, O>(source: readonly I[] | (() => readonly I[]), fn: (arg: I) => O, options?: MorphOptions<I>): readonly O[] & {
755
+ [cleanup]: ScopedCallback;
756
+ };
757
+ <K, V, O>(source: Map<K, V>, fn: (arg: V) => O, options?: MorphOptions<V>): Map<K, O> & {
758
+ [cleanup]: ScopedCallback;
759
+ };
760
+ <S extends Record<PropertyKey, any>, O>(source: S, fn: (arg: S[keyof S]) => O, options?: MorphOptions<S[keyof S]>): {
761
+ [K in keyof S]: O;
762
+ } & {
763
+ [cleanup]: ScopedCallback;
764
+ };
765
+ pure: Morph;
766
+ };
767
+ /**
768
+ * Reactively maps a collection (array, Map, or record) through a per-entry function.
769
+ *
770
+ * Each entry in the source gets its own reactive context — when only one entry's dependencies
771
+ * change, only that entry's projection recomputes. Structural changes (additions, removals,
772
+ * reorders) are detected via diffing and applied surgically.
773
+ *
774
+ * Use `morph.pure(source, fn)` when `fn` has no reactive reads (skips per-item effects).
775
+ *
776
+ * @example
777
+ * ```ts
778
+ * const users = reactive([{ name: 'John' }, { name: 'Jane' }])
779
+ * const names = morph(users, u => u.name.toUpperCase())
780
+ * // names[0] = 'JOHN', names[1] = 'JANE'
781
+ * // Changing users[0].name only recomputes names[0]
782
+ * ```
783
+ */
784
+ declare const morph: Morph;
785
+
786
+ /**
787
+ * Gets the current state of a reactive object for evolution tracking
788
+ * @param obj - The reactive object
789
+ * @returns The current state object
790
+ */
791
+ declare function getState(obj: any): State;
792
+ /**
793
+ * Triggers effects for a single property change
794
+ * @param obj - The object that changed
795
+ * @param evolution - The type of change
796
+ * @param prop - The property that changed
797
+ */
798
+ declare function touched1(obj: any, evolution: Evolution, prop: any): void;
799
+ /**
800
+ * Triggers effects for property changes
801
+ * @param obj - The object that changed
802
+ * @param evolution - The type of change
803
+ * @param props - The properties that changed
804
+ */
805
+ declare function touched(obj: any, evolution: Evolution, props?: Iterable<any>): void;
806
+
807
+ /**
808
+ * Deep watch an object and all its nested properties
809
+ * @param target - The object to watch deeply
810
+ * @param callback - The callback to call when any nested property changes
811
+ * @param options - Options for the deep watch
812
+ * @returns A cleanup function to stop watching
813
+ */
814
+ /**
815
+ * Sets up deep watching for an object, tracking all nested property changes
816
+ * @param target - The object to watch
817
+ * @param callback - The callback to call when changes occur
818
+ * @param options - Options for deep watching
819
+ * @returns A cleanup function to stop deep watching
820
+ */
821
+ declare function deepWatch<T extends object>(target: T, callback: (value: T) => void, { immediate }?: {
822
+ immediate?: boolean;
823
+ }): EffectCleanup | undefined;
824
+
825
+ /**
826
+ * Aggregator for zones that need to be tracked along effects.
827
+ * ie. in each effect, the active zone of the given zoning will be the one active at effect's definition
828
+ */
829
+ declare const effectAggregator: ZoneAggregator;
830
+ declare function getActiveEffect(): ScopedCallback;
831
+ /**
832
+ * ADD a cleanup function to an object using the cleanup symbol.
833
+ * The cleanup function will be called when the object needs to be disposed.
834
+ *
835
+ * Note: most of the time, you don't need to use this function directly.
836
+ * The main use if for the cleanup function to be stored with the object, as GC calls the cleanup function when the *function* is garbage collected.
837
+ *
838
+ * @param obj - The object to attach the cleanup function to
839
+ * @param cleanupFn - The cleanup function to attach
840
+ * @returns The object with the cleanup function attached
841
+ */
842
+ declare function cleanedBy<T extends object>(obj: T, cleanupFn: ScopedCallback): T & {
843
+ [cleanup]: ScopedCallback;
844
+ };
845
+
846
+ interface ActivationRecord {
847
+ effect: EffectTrigger;
848
+ obj: any;
849
+ evolution: Evolution;
850
+ prop: any;
851
+ batchId: number;
852
+ }
853
+ /**
854
+ * Returns the activation log containing recent effect activations for debugging.
855
+ * The log is a circular buffer of the last 100 activations.
856
+ *
857
+ * @returns Array of activation records
858
+ */
859
+ declare function getActivationLog(): Omit<ActivationRecord, "batchId">[];
860
+ declare function caught(onThrow: CatchFunction, effect?: EffectTrigger): void;
861
+ /** @deprecated Use `caught` instead */
862
+ declare const onEffectThrow: typeof caught;
863
+ /**
864
+ * Adds a cleanup function to be called when the current batch of effects completes
865
+ * @param cleanup - The cleanup function to add
866
+ */
867
+ declare function addBatchCleanup(cleanup: EffectCleanup): void;
868
+ /**
869
+ * Semantic alias for `addBatchCleanup` - defers work to the end of the current reactive batch.
870
+ *
871
+ * Use this when an effect needs to perform an action that would modify state the effect depends on,
872
+ * which would create a reactive cycle. The deferred callback runs after all effects complete.
873
+ *
874
+ * @param callback - The callback to defer until after the current batch completes
875
+ *
876
+ * @example
877
+ * ```typescript
878
+ * effect(() => {
879
+ * processData()
880
+ *
881
+ * // Defer to avoid cycle (createMovement modifies state this effect reads)
882
+ * defer(() => {
883
+ * createMovement(data)
884
+ * })
885
+ * })
886
+ * ```
887
+ */
888
+ declare const defer: typeof addBatchCleanup;
889
+ /**
890
+ * Resets the reactive system to a consistent state.
891
+ * Call this after an unrecoverable error has set the system to "broken".
892
+ * This clears all batch state, effect dependency graphs, and watcher registrations.
893
+ * All existing effects become orphaned and must be recreated.
894
+ */
895
+ declare function reset(): void;
896
+
897
+ /**
898
+ * Decorator that makes methods atomic - batches all effects triggered within the method
899
+ */
900
+ declare const atomic: LegacyPropertyDecorator<any> & ModernMethodDecorator<any> & (<Args extends any[], Return>(original: (...args: Args) => Return) => (...args: Args) => Return);
901
+ /**
902
+ * Runs `fn` atomically and **always immediately**, batching all reactive effects
903
+ * triggered inside it so they fire only once after `fn` completes.
904
+ *
905
+ * Unlike `atomic(fn)` which **wraps** a function for later invocation,
906
+ * `atom(fn)` **executes** the function right away.
907
+ *
908
+ * @example
909
+ * ```ts
910
+ * const state = reactive({ a: 0, b: 0 })
911
+ * effect(() => console.log(state.a, state.b)) // logs once after atom completes
912
+ *
913
+ * atom(() => {
914
+ * state.a = 1
915
+ * state.b = 2
916
+ * })
917
+ * ```
918
+ */
919
+ declare function atom<T>(fn: () => T): any;
920
+ /**
921
+ * @param fn - The effect function to run - provides the cleaner
922
+ * @returns The cleanup function
923
+ */
924
+ /**
925
+ * Creates a reactive effect that automatically re-runs when dependencies change
926
+ * @param fn - The effect function that provides dependencies and may return a cleanup function or Promise
927
+ * @param options - Options for effect execution
928
+ * @returns A cleanup function to stop the effect
929
+ */
930
+ declare const effect: ((fn: (access: EffectAccess) => EffectCloser | undefined | void | Promise<any>, effectOptions?: EffectOptions) => EffectCleanup) & {
931
+ readonly opaque: any;
932
+ named(name: string): any;
933
+ };
934
+ /**
935
+ * Executes a function without tracking dependencies but maintains parent cleanup relationship
936
+ * Effects created inside will still be cleaned up when the parent effect is destroyed
937
+ * @param fn - The function to execute
938
+ */
939
+ declare function untracked<T>(fn: () => T): T;
940
+ /**
941
+ * Executes a function from a virgin/root context - no parent effect, no tracking
942
+ * Creates completely independent effects that won't be cleaned up by any parent
943
+ * @param fn - The function to execute
944
+ */
945
+ declare function root<T>(fn: () => T): T;
946
+ /**
947
+ * Creates a bidirectional binding between a reactive value and a non-reactive external value
948
+ * Prevents infinite loops by automatically suppressing circular notifications
949
+ *
950
+ * @param received - Function called when the reactive value changes (external setter)
951
+ * @param get - Getter for the reactive value OR an object with `{ get, set }` properties
952
+ * @param set - Setter for the reactive value (required if `get` is a function)
953
+ * @returns A function to manually provide updates from the external side
954
+ *
955
+ * @example
956
+ * ```typescript
957
+ * const model = reactive({ value: '' })
958
+ * const input = { value: '' }
959
+ *
960
+ * // Bidirectional binding
961
+ * const provide = biDi(
962
+ * (v) => input.value = v, // external setter
963
+ * () => model.value, // reactive getter
964
+ * (v) => model.value = v // reactive setter
965
+ * )
966
+ *
967
+ * // External notification (e.g., from input event)
968
+ * provide('new value') // Updates model.value, doesn't trigger circular loop
969
+ * ```
970
+ *
971
+ * @example Using object syntax
972
+ * ```typescript
973
+ * const provide = biDi(
974
+ * (v) => setHTMLValue(v),
975
+ * { get: () => reactiveObj.value, set: (v) => reactiveObj.value = v }
976
+ * )
977
+ * ```
978
+ */
979
+ declare function biDi<T>(received: (value: T) => void, value: {
980
+ get: () => T;
981
+ set: (value: T) => void;
982
+ }): (value: T) => void;
983
+ declare function biDi<T>(received: (value: T) => void, get: () => T, set: (value: T) => void): (value: T) => void;
984
+
985
+ type MemoizableArgument = object | any[] | ((...args: any[]) => any);
986
+ type Memoizable = ((...args: MemoizableArgument[]) => unknown) | Record<string, any>;
987
+ /**
988
+ * Decorator and function wrapper for memoizing computed values based on reactive dependencies.
989
+ *
990
+ * When used as a decorator on getters or methods, it caches the result and automatically
991
+ * invalidates the cache when reactive dependencies change.
992
+ *
993
+ * When used as a function wrapper, it memoizes based on object arguments (WeakMap-based cache).
994
+ *
995
+ * @example
996
+ * ```typescript
997
+ * class User {
998
+ * @memoize
999
+ * get fullName() {
1000
+ * return `${this.firstName} ${this.lastName}`
1001
+ * }
1002
+ * }
1003
+ *
1004
+ * // Or as a function wrapper
1005
+ * const expensive = memoize((obj: SomeObject) => {
1006
+ * return heavyComputation(obj)
1007
+ * })
1008
+ * ```
1009
+ */
1010
+ declare function makeMemoizeDecorator(memoizeOpts?: {
1011
+ lenient?: boolean;
1012
+ }): LegacyPropertyDecorator<any> & ModernMethodDecorator<any> & ModernGetterDecorator<any> & ModernAccessorDecorator<any> & (<T extends Memoizable>(target: T) => T);
1013
+ declare const memoize: ReturnType<typeof makeMemoizeDecorator> & {
1014
+ readonly lenient: ReturnType<typeof makeMemoizeDecorator>;
1015
+ };
1016
+
1017
+ declare const immutables: Set<(tested: any) => boolean>;
1018
+ declare function isNonReactive(obj: any): boolean;
1019
+
1020
+ type SubProxy = {
1021
+ get?(obj: any, prop: PropertyKey, receiver: any): any;
1022
+ has?(obj: any, prop: PropertyKey): boolean;
1023
+ ownKeys?(obj: any): ArrayLike<string | symbol>;
1024
+ getOwnPropertyDescriptor?(obj: any, prop: PropertyKey): PropertyDescriptor | undefined;
1025
+ };
1026
+ /**
1027
+ * Base mixin for reactive classes that provides proper constructor reactivity
1028
+ * Solves constructor reactivity issues in complex inheritance trees
1029
+ */
1030
+ declare const ReactiveBase: (new (...args: any[]) => {
1031
+ [x: string]: any;
1032
+ }) & (<Base>(base: abstract new (...args: any[]) => Base) => new (...args: any[]) => {
1033
+ [x: string]: any;
1034
+ } & Base);
1035
+ declare function reactiveObject<T>(anyTarget: T, subProxy?: SubProxy): T;
1036
+ /**
1037
+ * Main decorator for making classes reactive
1038
+ * Automatically makes class instances reactive when created
1039
+ */
1040
+ declare const reactive: LegacyClassDecorator<new (...args: any[]) => any> & ModernClassDecorator<new (...args: any[]) => any> & typeof reactiveObject;
1041
+
1042
+ /**
1043
+ * Provides type-safe access to a source object's property within the organized callback.
1044
+ * @template Source - The type of the source object
1045
+ * @template Key - The type of the property key in the source object
1046
+ */
1047
+ type OrganizedAccess<Source extends Record<PropertyKey, any>, Key extends keyof Source> = {
1048
+ /** The property key being accessed */
1049
+ readonly key: Key;
1050
+ /**
1051
+ * Gets the current value of the property from the source object
1052
+ * @returns The current value of the property
1053
+ */
1054
+ get(): Source[Key];
1055
+ /**
1056
+ * Updates the property value in the source object
1057
+ * @param value - The new value to set
1058
+ * @returns {boolean} True if the update was successful
1059
+ */
1060
+ set(value: Source[Key]): boolean;
1061
+ /**
1062
+ * The current value of the property (equivalent to using get()/set() directly)
1063
+ */
1064
+ value: Source[Key];
1065
+ };
1066
+ /**
1067
+ * Callback function type for the organized function that processes each source property.
1068
+ * @template Source - The type of the source object
1069
+ * @template Target - The type of the target object
1070
+ */
1071
+ type OrganizedCallback<Source extends Record<PropertyKey, any>, Target extends object> = <Key extends keyof Source>(
1072
+ /**
1073
+ * Accessor object for the current source property
1074
+ */
1075
+ access: OrganizedAccess<Source, Key>,
1076
+ /**
1077
+ * The target object where organized data will be stored
1078
+ */
1079
+ target: Target) => EffectCloser | undefined;
1080
+ /**
1081
+ * The result type of the organized function, combining the target object with cleanup capability.
1082
+ * @template Target - The type of the target object
1083
+ */
1084
+ type OrganizedResult<Target extends object> = Target & {
1085
+ /**
1086
+ * Cleanup function to dispose of all reactive bindings created by organized().
1087
+ * This is automatically called when the effect that created the organized binding is disposed.
1088
+ */
1089
+ [cleanup]: ScopedCallback;
1090
+ };
1091
+ /**
1092
+ * Organizes a source object's properties into a target object using a callback function.
1093
+ * This creates a reactive mapping between source properties and a target object,
1094
+ * automatically handling property additions, updates, and removals.
1095
+ *
1096
+ * @template Source - The type of the source object
1097
+ * @template Target - The type of the target object (defaults to Record<PropertyKey, any>)
1098
+ *
1099
+ * @param {Source} source - The source object to organize
1100
+ * @param {OrganizedCallback<Source, Target>} apply - Callback function that defines how each source property is mapped to the target
1101
+ * @param {Target} [baseTarget={}] - Optional base target object to use (will be made reactive if not already)
1102
+ *
1103
+ * @returns {OrganizedResult<Target>} The target object with cleanup capability
1104
+ *
1105
+ * @example
1106
+ * // Organize user permissions into role-based access
1107
+ * const user = reactive({ isAdmin: true, canEdit: false });
1108
+ * const permissions = organized(
1109
+ * user,
1110
+ * (access, target) => {
1111
+ * if (access.key === 'isAdmin') {
1112
+ * target.hasFullAccess = access.value;
1113
+ * }
1114
+ * target[`can${access.key.charAt(0).toUpperCase() + access.key.slice(1)}`] = access.value;
1115
+ * }
1116
+ * );
1117
+ *
1118
+ * @example
1119
+ * // Transform object structure with cleanup
1120
+ * const source = reactive({ firstName: 'John', lastName: 'Doe' });
1121
+ * const formatted = organized(
1122
+ * source,
1123
+ * (access, target) => {
1124
+ * if (access.key === 'firstName' || access.key === 'lastName') {
1125
+ * target.fullName = `${source.firstName} ${source.lastName}`.trim();
1126
+ * }
1127
+ * }
1128
+ * );
1129
+ *
1130
+ * @example
1131
+ * // Using with cleanup in a component
1132
+ * effect(() => {
1133
+ * const data = fetchData();
1134
+ * const organizedData = organized(data, (access, target) => {
1135
+ * // Transform data
1136
+ * });
1137
+ *
1138
+ * // The cleanup will be called automatically when the effect is disposed
1139
+ * return () => organizedData[cleanup]();
1140
+ * });
1141
+ */
1142
+ declare function organized<Source extends Record<PropertyKey, any>, Target extends object = Record<PropertyKey, any>>(source: Source, apply: OrganizedCallback<Source, Target>, baseTarget?: Target): OrganizedResult<Target>;
1143
+ /**
1144
+ * Organizes a property on a target object
1145
+ * Shortcut for defineProperty/delete with touched signal
1146
+ * @param target - The target object
1147
+ * @param property - The property to organize
1148
+ * @param access - The access object
1149
+ * @returns The property descriptor
1150
+ */
1151
+ declare function organize<T>(target: object, property: PropertyKey, access: {
1152
+ get?(): T;
1153
+ set?(value: T): boolean;
1154
+ }): () => boolean;
1155
+
1156
+ type KeyFunction<T, K extends PropertyKey> = (item: T) => K;
1157
+ /**
1158
+ * Events emitted by the Register for CRUD operations
1159
+ */
1160
+ interface RegisterEvents<T, K extends PropertyKey> {
1161
+ /**
1162
+ * Emitted when a new item is added to the register
1163
+ */
1164
+ add: (item: T, key: K, index: number) => void;
1165
+ /**
1166
+ * Emitted when an item is removed from the register
1167
+ */
1168
+ delete: (item: T, key: K, index: number) => void;
1169
+ /**
1170
+ * Emitted when an item's value is updated (same key, new value)
1171
+ */
1172
+ update: (oldItem: T, newItem: T, key: K, index: number) => void;
1173
+ /**
1174
+ * Emitted when an item's key changes (rekey operation)
1175
+ */
1176
+ rekey: (item: T, oldKey: K, newKey: K, index: number) => void;
1177
+ /**
1178
+ * Index signature for EventsBase compatibility
1179
+ */
1180
+ [key: string]: (...args: any[]) => void;
1181
+ }
1182
+ interface RegisterInstance<T> extends ArrayReadForward<T> {
1183
+ [index: number]: T;
1184
+ }
1185
+ declare const RegisterClass_base: new () => ArrayReadForward<any> & {
1186
+ [x: number]: any;
1187
+ toArray(): any[];
1188
+ };
1189
+ declare class RegisterClass<T, K extends PropertyKey = PropertyKey> extends RegisterClass_base implements RegisterInstance<T> {
1190
+ #private;
1191
+ protected get [forwardArray](): readonly T[];
1192
+ /**
1193
+ * Register event listeners for CRUD operations
1194
+ */
1195
+ on(events: Partial<RegisterEvents<T, K>>): void;
1196
+ on<EventType extends keyof RegisterEvents<T, K>>(event: EventType, cb: RegisterEvents<T, K>[EventType]): () => void;
1197
+ /**
1198
+ * Remove event listeners
1199
+ */
1200
+ off(events: Partial<RegisterEvents<T, K>>): void;
1201
+ off<EventType extends keyof RegisterEvents<T, K>>(event: EventType, cb?: RegisterEvents<T, K>[EventType]): void;
1202
+ /**
1203
+ * Register a global hook that receives all events
1204
+ */
1205
+ hook(cb: <EventType extends keyof RegisterEvents<T, K>>(event: EventType, ...args: Parameters<RegisterEvents<T, K>[EventType]>) => void): () => void;
1206
+ constructor(keyFn: KeyFunction<T, K>, initial?: Iterable<T>);
1207
+ private ensureKey;
1208
+ private assertValidKey;
1209
+ private setKeyValue;
1210
+ private cleanupValue;
1211
+ private disposeKeyEffects;
1212
+ private incrementUsage;
1213
+ private decrementUsage;
1214
+ private normalizeIndex;
1215
+ private assignAt;
1216
+ private insertKeyValue;
1217
+ private rebuildFrom;
1218
+ get length(): number;
1219
+ [getAt](index: number): T | undefined;
1220
+ [setAt](index: number, value: T): void;
1221
+ push(...items: T[]): number;
1222
+ pop(): T | undefined;
1223
+ shift(): T | undefined;
1224
+ unshift(...items: T[]): number;
1225
+ splice(start: number, deleteCount?: number, ...items: T[]): T[];
1226
+ clear(): void;
1227
+ get(key: K): T | undefined;
1228
+ set(key: K, value: T): void;
1229
+ remove(key: K): void;
1230
+ removeAt(index: number): T | undefined;
1231
+ /**
1232
+ * Keep only the items for which the predicate returns true.
1233
+ * Items for which the predicate returns false are removed.
1234
+ *
1235
+ * The predicate is evaluated once per distinct key; duplicate keys
1236
+ * will follow the same keep/remove decision.
1237
+ */
1238
+ keep(predicate: (value: T) => boolean): void;
1239
+ hasKey(key: K): boolean;
1240
+ indexOfKey(key: K): number;
1241
+ mapKeys(): IterableIterator<K>;
1242
+ update(...values: T[]): void;
1243
+ upsert(insert: (value: T) => void, ...values: T[]): void;
1244
+ entries(): IterableIterator<[number, T]>;
1245
+ [Symbol.iterator](): IterableIterator<T>;
1246
+ toString(): string;
1247
+ at(index: number): T | undefined;
1248
+ reverse(): this;
1249
+ sort(compareFn?: ((a: T, b: T) => number) | undefined): this;
1250
+ fill(value: T, start?: number, end?: number): this;
1251
+ copyWithin(target: number, start: number, end?: number): this;
1252
+ }
1253
+ type Register<T, K extends PropertyKey = PropertyKey> = RegisterClass<T, K> & T[];
1254
+ declare const Register: new <T, K extends PropertyKey = PropertyKey>(keyFn: KeyFunction<T, K>, initial?: Iterable<T>) => Register<T, K>;
1255
+ /**
1256
+ * Creates a reactive Register - an ordered, array-like collection with stable key-based identity.
1257
+ *
1258
+ * Register combines array semantics (indexable access, ordering, iteration) with Map-like
1259
+ * key-based lookups. Items with the same key share the same value instance, making it ideal
1260
+ * for UI lists keyed by IDs or when you need to preserve identity across reorders.
1261
+ *
1262
+ * @param keyFn - Function that extracts the key from each item
1263
+ * @param initial - Optional initial items to populate the register
1264
+ * @returns A reactive Register instance
1265
+ *
1266
+ * @example
1267
+ * ```typescript
1268
+ * const users = register(
1269
+ * (user: User) => user.id,
1270
+ * [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]
1271
+ * )
1272
+ *
1273
+ * users.push({ id: 3, name: 'Charlie' })
1274
+ * const bob = users.get(2) // Get by key
1275
+ * ```
1276
+ */
1277
+ declare function register<T, K extends PropertyKey = PropertyKey>(keyFn: KeyFunction<T, K>, initial?: Iterable<T>): Register<T, K>;
1278
+
1279
+ /**
1280
+ * Options for the watch function
1281
+ */
1282
+ interface WatchOptions {
1283
+ /** Whether to call the callback immediately */
1284
+ immediate?: boolean;
1285
+ /** Whether to watch nested properties */
1286
+ deep?: boolean;
1287
+ }
1288
+ /**
1289
+ * Watches a reactive value and calls a callback when it changes
1290
+ */
1291
+ interface Watch {
1292
+ <T>(value: (dep: EffectAccess) => T, changed: (value: T, oldValue?: T) => void, options?: Omit<WatchOptions, 'deep'> & {
1293
+ deep?: false;
1294
+ }): EffectCleanup;
1295
+ /**
1296
+ * Watches a reactive value with deep watching enabled
1297
+ */
1298
+ <T extends object | any[]>(value: (dep: EffectAccess) => T, changed: (value: T, oldValue?: T) => void, options?: Omit<WatchOptions, 'deep'> & {
1299
+ deep: true;
1300
+ }): EffectCleanup;
1301
+ /**
1302
+ * Watches a reactive object directly
1303
+ */
1304
+ <T extends object | any[]>(value: T, changed: (value: T) => void, options?: WatchOptions): EffectCleanup;
1305
+ /** Deep watch flavor */
1306
+ get deep(): Watch;
1307
+ /** Immediate watch flavor */
1308
+ get immediate(): Watch;
1309
+ }
1310
+ declare const watch: Watch;
1311
+ /**
1312
+ * Returns a promise that resolves when the predicate returns a truthy value.
1313
+ * The predicate is evaluated reactively — it re-runs whenever its dependencies change.
1314
+ * @param predicate - Reactive function that returns a value; resolves when truthy
1315
+ * @param timeout - Optional timeout in milliseconds — rejects if condition is not met within this duration
1316
+ * @returns Promise that resolves with the first truthy return value
1317
+ */
1318
+ declare function when<T>(predicate: (dep: EffectAccess) => T, timeout?: number): Promise<T>;
1319
+ declare function unreactiveApplication<T extends object>(...args: (keyof T)[]): GenericClassDecorator<T>;
1320
+ declare function unreactiveApplication<T extends object>(obj: T): T;
1321
+ /**
1322
+ * Decorator that marks classes or properties as non-reactive
1323
+ * Prevents objects from being made reactive
1324
+ */
1325
+ declare const unreactive: LegacyClassDecorator<new (...args: any[]) => any> & ModernClassDecorator<new (...args: any[]) => any> & typeof unreactiveApplication;
1326
+ interface Resource<T> {
1327
+ value: T | undefined;
1328
+ loading: boolean;
1329
+ error: any;
1330
+ latest: T | undefined;
1331
+ reload: () => void;
1332
+ }
1333
+ /**
1334
+ * Creates a reactive resource that automatically tracks async state.
1335
+ * @param fetcher - Async function that returns the value. Reactive dependencies are tracked.
1336
+ * @param options - Resource options (initialValue)
1337
+ * @returns Reactive Resource object with value, loading, error, latest properties
1338
+ */
1339
+ declare function resource<T>(fetcher: (dep: EffectAccess) => Promise<T> | T, options?: {
1340
+ initialValue?: T;
1341
+ }): Resource<T>;
1342
+
1343
+ /**
1344
+ * Object containing internal reactive system state for debugging and profiling
1345
+ */
1346
+ declare const profileInfo: any;
1347
+
1348
+ /**
1349
+ * Decorator that caches the result of a getter method and only recomputes when dependencies change
1350
+ * Prevents circular dependencies and provides automatic cache invalidation
1351
+ */
1352
+ declare const cached: LegacyPropertyDecorator<any> & ModernGetterDecorator<any> & ModernAccessorDecorator<any>;
1353
+ /**
1354
+ * Checks if a property is cached (has a cached value)
1355
+ * @param object - The object to check
1356
+ * @param propertyKey - The property key to check
1357
+ * @returns True if the property has a cached value
1358
+ */
1359
+ declare function isCached(object: Object, propertyKey: PropertyKey): boolean;
1360
+ /**
1361
+ * Caches a value for a property on an object
1362
+ * @param object - The object to cache the value on
1363
+ * @param propertyKey - The property key to cache
1364
+ * @param value - The value to cache
1365
+ */
1366
+ declare function cache(object: Object, propertyKey: PropertyKey, value: any): void;
1367
+ /**
1368
+ * Creates a decorator that modifies property descriptors for specified properties
1369
+ * @param descriptor - The descriptor properties to apply
1370
+ * @returns A class decorator that applies the descriptor to specified properties
1371
+ */
1372
+ declare const descriptor: any;
1373
+ /**
1374
+ * Decorator that marks methods, properties, or classes as deprecated
1375
+ * Provides warning messages when deprecated items are used
1376
+ */
1377
+ declare const deprecated: LegacyPropertyDecorator<any> & ModernMethodDecorator<any> & LegacyClassDecorator<new (...args: any[]) => any> & ModernClassDecorator<new (...args: any[]) => any> & ModernGetterDecorator<any> & ModernAccessorDecorator<any> & ModernSetterDecorator<any> & ((message: string) => LegacyPropertyDecorator<any> & ModernMethodDecorator<any> & LegacyClassDecorator<new (...args: any[]) => any> & ModernClassDecorator<new (...args: any[]) => any> & ModernGetterDecorator<any> & ModernAccessorDecorator<any> & ModernSetterDecorator<any>) & {
1378
+ warn: (target: any, propertyKey: PropertyKey, message?: string) => void;
1379
+ };
1380
+ /**
1381
+ * Creates a debounced method decorator that delays execution until after the delay period has passed
1382
+ * @param delay - The delay in milliseconds
1383
+ * @returns A method decorator that debounces method calls
1384
+ */
1385
+ declare function debounce(delay: number): LegacyPropertyDecorator<any> & ModernMethodDecorator<any>;
1386
+ /**
1387
+ * Creates a throttled method decorator that limits execution to once per delay period
1388
+ * @param delay - The delay in milliseconds
1389
+ * @returns A method decorator that throttles method calls
1390
+ */
1391
+ declare function throttle(delay: number): LegacyPropertyDecorator<any> & ModernMethodDecorator<any>;
1392
+
1393
+ type ElementTypes<T extends readonly unknown[]> = {
1394
+ [K in keyof T]: T[K] extends readonly (infer U)[] ? U : T[K];
1395
+ };
1396
+ /**
1397
+ * Yields tuples containing elements from each input array, stopping at the longest array length
1398
+ * @param args - Arrays to zip together
1399
+ * @returns Generator yielding tuples containing elements from each input array
1400
+ */
1401
+ declare function zip<T extends (readonly unknown[])[]>(...args: T): Generator<ElementTypes<T>>;
1402
+ /**
1403
+ * Checks if two arrays are strictly equal (shallow comparison)
1404
+ * @param a - First value
1405
+ * @param b - Second value
1406
+ * @returns True if arrays are equal or values are strictly equal
1407
+ */
1408
+ declare function arrayEquals(a: any, b: any): boolean;
1409
+ /**
1410
+ * Checks if a function is a constructor (class or constructor function)
1411
+ * @param fn - The function to check
1412
+ * @returns True if the function is a constructor
1413
+ */
1414
+ declare function isConstructor(fn: Function): boolean;
1415
+ /**
1416
+ * Checks if a value is an object
1417
+ * @param value - The value to check
1418
+ * @returns True if the value is an object
1419
+ */
1420
+ declare function isObject(value: any): value is object;
1421
+ /**
1422
+ * Deeply compares two values.
1423
+ * For objects, compares prototypes with === and then own properties recursively.
1424
+ * Uses a cache to handle circular references.
1425
+ * @param a - First value
1426
+ * @param b - Second value
1427
+ * @param cache - Map for circular reference protection (internal use)
1428
+ * @returns True if values are deeply equal
1429
+ */
1430
+ declare function deepCompare(a: any, b: any, cache?: Map<object, Set<object>>): boolean;
1431
+ /**
1432
+ * Tags an object with a name
1433
+ * @param name - The name to tag the object with
1434
+ * @param obj - The object to tag
1435
+ * @returns The object with the tag
1436
+ */
1437
+ declare function tag<T extends object>(name: string, obj: T): T;
1438
+ /**
1439
+ * Renames a function with a new name
1440
+ * @param name - The new name for the function
1441
+ * @param fn - The function to rename
1442
+ * @returns The function with the new name
1443
+ */
1444
+ declare function named<T extends Function>(name: string, fn: T): T;
1445
+
1446
+ export { ArrayReadForward, DecoratorError, Destroyable, DestructionError, EffectAccess, EffectCleanup, EffectCloser, EffectOptions, EffectTrigger, Eventful, Evolution, Indexable, IterableWeakMap, IterableWeakSet, ReactiveBase, Register, ScopedCallback, ZoneAggregator, addBatchCleanup, allocated, allocatedValues, arrayDiff, arrayEquals, asyncHook, asyncHooks, atom, atomic, attend, biDi, cache, cached, callOnGC, caught, chainPromise, cleanedBy, cleanup, createFlavor, debounce, decorator, deepCompare, deepWatch, defer, deprecated, descriptor, destructor, effect, effectAggregator, flavorOptions, flavored, forwardArray, getActivationLog, getActiveEffect, getAt, getState, hooks$1 as hooks, immutables, isCached, isConstructor, isNonReactive, isObject, legacyDecorator, lift, memoize, mixin, modernDecorator, morph, named, onEffectThrow, organize, organized, profileInfo, morph as project, reactive, register, reset, resource, root, scan, setAt, tag, throttle, touched, touched1, unreactive, untracked, watch, when, zip };
1447
+ export type { ArrayDiffResult, ContextManager, Decorator, DecoratorDescription, DecoratorFactory, EventsBase, GenericClassDecorator, Hook, LegacyClassDecorator, LegacyPropertyDecorator, Memoizable, MemoizableArgument, MixinClass, MixinFunction, ModernAccessorDecorator, ModernClassDecorator, ModernGetterDecorator, ModernMethodDecorator, ModernSetterDecorator, PromiseChain, Resource, Restorer, ScanResult };