mutts 1.0.7 → 1.0.8

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 (132) hide show
  1. package/README.md +61 -23
  2. package/dist/async/browser.d.ts +2 -0
  3. package/dist/async/browser.d.ts.map +1 -0
  4. package/dist/async/index.d.ts +18 -0
  5. package/dist/async/index.d.ts.map +1 -0
  6. package/dist/async/node.d.ts +2 -0
  7. package/dist/async/node.d.ts.map +1 -0
  8. package/dist/{chunks/index-BFYK02LG.js → browser.cjs} +169 -60
  9. package/dist/browser.cjs.map +1 -0
  10. package/dist/browser.d.ts +1654 -1
  11. package/dist/browser.esm.js +260 -25
  12. package/dist/browser.esm.js.map +1 -1
  13. package/dist/chunks/async-browser-CA0jPWIi.cjs +304 -0
  14. package/dist/chunks/async-browser-CA0jPWIi.cjs.map +1 -0
  15. package/dist/chunks/async-core-UqHzvJ-S.cjs +25 -0
  16. package/dist/chunks/async-core-UqHzvJ-S.cjs.map +1 -0
  17. package/dist/chunks/async-node-BYHuGTni.cjs +103 -0
  18. package/dist/chunks/async-node-BYHuGTni.cjs.map +1 -0
  19. package/dist/chunks/{index-CNR6QRUl.esm.js → index-DhaOVusv.esm.js} +173 -53
  20. package/dist/chunks/index-DhaOVusv.esm.js.map +1 -0
  21. package/dist/decorator.d.ts +106 -0
  22. package/dist/decorator.d.ts.map +1 -0
  23. package/dist/destroyable.d.ts +87 -0
  24. package/dist/destroyable.d.ts.map +1 -0
  25. package/dist/devtools/devtool/devtools.d.ts +1 -0
  26. package/dist/devtools/devtool/devtools.d.ts.map +1 -0
  27. package/dist/devtools/devtool/panel.d.ts +2 -0
  28. package/dist/devtools/devtool/panel.d.ts.map +1 -0
  29. package/dist/entry-browser.d.ts +3 -0
  30. package/dist/entry-browser.d.ts.map +1 -0
  31. package/dist/entry-node.d.ts +3 -0
  32. package/dist/entry-node.d.ts.map +1 -0
  33. package/dist/eventful.d.ts +18 -0
  34. package/dist/eventful.d.ts.map +1 -0
  35. package/dist/index.d.ts +13 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/indexable.d.ts +243 -0
  38. package/dist/indexable.d.ts.map +1 -0
  39. package/dist/introspection.d.ts +27 -0
  40. package/dist/introspection.d.ts.map +1 -0
  41. package/dist/iterableWeak.d.ts +53 -0
  42. package/dist/iterableWeak.d.ts.map +1 -0
  43. package/dist/mixins.d.ts +25 -0
  44. package/dist/mixins.d.ts.map +1 -0
  45. package/dist/mutts.umd.js +1 -1
  46. package/dist/mutts.umd.js.map +1 -1
  47. package/dist/mutts.umd.min.js +1 -1
  48. package/dist/mutts.umd.min.js.map +1 -1
  49. package/dist/node.cjs +105 -0
  50. package/dist/node.cjs.map +1 -0
  51. package/dist/node.d.ts +1 -2
  52. package/dist/node.esm.js +91 -32
  53. package/dist/node.esm.js.map +1 -1
  54. package/dist/promiseChain.d.ts +20 -0
  55. package/dist/promiseChain.d.ts.map +1 -0
  56. package/dist/reactive/array.d.ts +49 -0
  57. package/dist/reactive/array.d.ts.map +1 -0
  58. package/dist/reactive/buffer.d.ts +44 -0
  59. package/dist/reactive/buffer.d.ts.map +1 -0
  60. package/dist/reactive/change.d.ts +29 -0
  61. package/dist/reactive/change.d.ts.map +1 -0
  62. package/dist/reactive/debug.d.ts +111 -0
  63. package/dist/reactive/debug.d.ts.map +1 -0
  64. package/dist/reactive/deep-touch.d.ts +28 -0
  65. package/dist/reactive/deep-touch.d.ts.map +1 -0
  66. package/dist/reactive/deep-watch-state.d.ts +25 -0
  67. package/dist/reactive/deep-watch-state.d.ts.map +1 -0
  68. package/dist/reactive/deep-watch.d.ts +19 -0
  69. package/dist/reactive/deep-watch.d.ts.map +1 -0
  70. package/dist/reactive/effect-context.d.ts +7 -0
  71. package/dist/reactive/effect-context.d.ts.map +1 -0
  72. package/dist/reactive/effects.d.ts +151 -0
  73. package/dist/reactive/effects.d.ts.map +1 -0
  74. package/dist/reactive/index.d.ts +20 -0
  75. package/dist/reactive/index.d.ts.map +1 -0
  76. package/dist/reactive/interface.d.ts +64 -0
  77. package/dist/reactive/interface.d.ts.map +1 -0
  78. package/dist/reactive/map.d.ts +30 -0
  79. package/dist/reactive/map.d.ts.map +1 -0
  80. package/dist/reactive/memoize.d.ts +5 -0
  81. package/dist/reactive/memoize.d.ts.map +1 -0
  82. package/dist/reactive/non-reactive-state.d.ts +9 -0
  83. package/dist/reactive/non-reactive-state.d.ts.map +1 -0
  84. package/dist/reactive/non-reactive.d.ts +11 -0
  85. package/dist/reactive/non-reactive.d.ts.map +1 -0
  86. package/dist/reactive/project.d.ts +41 -0
  87. package/dist/reactive/project.d.ts.map +1 -0
  88. package/dist/reactive/proxy-state.d.ts +8 -0
  89. package/dist/reactive/proxy-state.d.ts.map +1 -0
  90. package/dist/reactive/proxy.d.ts +23 -0
  91. package/dist/reactive/proxy.d.ts.map +1 -0
  92. package/dist/reactive/record.d.ts +116 -0
  93. package/dist/reactive/record.d.ts.map +1 -0
  94. package/dist/reactive/register.d.ts +64 -0
  95. package/dist/reactive/register.d.ts.map +1 -0
  96. package/dist/reactive/registry.d.ts +20 -0
  97. package/dist/reactive/registry.d.ts.map +1 -0
  98. package/dist/reactive/set.d.ts +28 -0
  99. package/dist/reactive/set.d.ts.map +1 -0
  100. package/dist/reactive/tracking.d.ts +7 -0
  101. package/dist/reactive/tracking.d.ts.map +1 -0
  102. package/dist/reactive/types.d.ts +376 -0
  103. package/dist/reactive/types.d.ts.map +1 -0
  104. package/dist/std-decorators.d.ts +50 -0
  105. package/dist/std-decorators.d.ts.map +1 -0
  106. package/dist/utils.d.ts +49 -0
  107. package/dist/utils.d.ts.map +1 -0
  108. package/dist/zone.d.ts +40 -0
  109. package/dist/zone.d.ts.map +1 -0
  110. package/docs/std-decorators.md +69 -1
  111. package/docs/zone.md +7 -0
  112. package/package.json +39 -27
  113. package/src/async/browser.ts +266 -34
  114. package/src/async/index.ts +17 -2
  115. package/src/async/node.ts +89 -31
  116. package/src/entry-browser.ts +5 -0
  117. package/src/entry-node.ts +5 -0
  118. package/src/index.d.ts +12 -9
  119. package/src/index.ts +1 -0
  120. package/src/reactive/array.ts +139 -52
  121. package/src/reactive/effect-context.ts +3 -3
  122. package/src/reactive/index.ts +2 -1
  123. package/src/reactive/map.ts +1 -1
  124. package/src/reactive/set.ts +1 -1
  125. package/src/utils.ts +1 -1
  126. package/src/zone.ts +19 -8
  127. package/dist/browser.js +0 -161
  128. package/dist/browser.js.map +0 -1
  129. package/dist/chunks/index-BFYK02LG.js.map +0 -1
  130. package/dist/chunks/index-CNR6QRUl.esm.js.map +0 -1
  131. package/dist/node.js +0 -136
  132. package/dist/node.js.map +0 -1
package/dist/browser.d.ts CHANGED
@@ -1,2 +1,1655 @@
1
+ /**
2
+ * Error thrown when decorator operations fail
3
+ */
4
+ declare class DecoratorError extends Error {
5
+ constructor(message: string);
6
+ }
7
+ /**
8
+ * Legacy property decorator type for methods, getters, and setters
9
+ */
10
+ type LegacyPropertyDecorator<T> = (target: T, name: string | symbol, descriptor: PropertyDescriptor) => any;
11
+ /**
12
+ * Legacy class decorator type
13
+ */
14
+ type LegacyClassDecorator<T> = (target: T) => any;
15
+ /**
16
+ * Modern method decorator type
17
+ */
18
+ type ModernMethodDecorator<T> = (target: T, context: ClassMethodDecoratorContext) => any;
19
+ /**
20
+ * Modern getter decorator type
21
+ */
22
+ type ModernGetterDecorator<T> = (target: T, context: ClassGetterDecoratorContext) => any;
23
+ /**
24
+ * Modern setter decorator type
25
+ */
26
+ type ModernSetterDecorator<T> = (target: T, context: ClassSetterDecoratorContext) => any;
27
+ /**
28
+ * Modern accessor decorator type
29
+ */
30
+ type ModernAccessorDecorator<T> = (target: T, context: ClassAccessorDecoratorContext) => any;
31
+ /**
32
+ * Modern class decorator type
33
+ */
34
+ type ModernClassDecorator<T> = (target: T, context: ClassDecoratorContext) => any;
35
+ type DDMethod<T> = (original: (this: T, ...args: any[]) => any, target: any, name: PropertyKey) => ((this: T, ...args: any[]) => any) | void;
36
+ type DDGetter<T> = (original: (this: T) => any, target: any, name: PropertyKey) => ((this: T) => any) | void;
37
+ type DDSetter<T> = (original: (this: T, value: any) => void, target: any, name: PropertyKey) => ((this: T, value: any) => void) | void;
38
+ type DDClass<T> = <Ctor extends new (...args: any[]) => T = new (...args: any[]) => T>(target: Ctor) => Ctor | void;
39
+ /**
40
+ * Description object for creating decorators that work with both Legacy and Modern decorator proposals
41
+ */
42
+ interface DecoratorDescription<T> {
43
+ /** Handler for method decorators */
44
+ method?: DDMethod<T>;
45
+ /** Handler for class decorators */
46
+ class?: DDClass<T>;
47
+ /** Handler for getter decorators */
48
+ getter?: DDGetter<T>;
49
+ /** Handler for setter decorators */
50
+ setter?: DDSetter<T>;
51
+ /** Default handler for any decorator type not explicitly defined */
52
+ default?: (...args: any[]) => any;
53
+ }
54
+ /**
55
+ * Type for decorators that work with both Legacy and Modern decorator proposals
56
+ * Automatically infers the correct decorator type based on the description
57
+ */
58
+ type Decorator<T, Description extends DecoratorDescription<T>> = (Description extends {
59
+ method: DDMethod<T>;
60
+ } ? LegacyPropertyDecorator<T> & ModernMethodDecorator<T> : unknown) & (Description extends {
61
+ class: DDClass<new (...args: any[]) => T>;
62
+ } ? LegacyClassDecorator<new (...args: any[]) => T> & ModernClassDecorator<new (...args: any[]) => T> : unknown) & (Description extends {
63
+ getter: DDGetter<T>;
64
+ } ? LegacyPropertyDecorator<T> & ModernGetterDecorator<T> & ModernAccessorDecorator<T> : unknown) & (Description extends {
65
+ setter: DDSetter<T>;
66
+ } ? LegacyPropertyDecorator<T> & ModernSetterDecorator<T> & ModernAccessorDecorator<T> : unknown) & (Description extends {
67
+ default: infer Signature;
68
+ } ? Signature : unknown);
69
+ /**
70
+ * Factory type for creating decorators that work with both Legacy and Modern decorator proposals
71
+ */
72
+ type DecoratorFactory<T> = <Description extends DecoratorDescription<T>>(description: Description) => (Description extends {
73
+ method: DDMethod<T>;
74
+ } ? LegacyPropertyDecorator<T> & ModernMethodDecorator<T> : unknown) & (Description extends {
75
+ class: DDClass<new (...args: any[]) => T>;
76
+ } ? LegacyClassDecorator<new (...args: any[]) => T> & ModernClassDecorator<new (...args: any[]) => T> : unknown) & (Description extends {
77
+ getter: DDGetter<T>;
78
+ } ? LegacyPropertyDecorator<T> & ModernGetterDecorator<T> & ModernAccessorDecorator<T> : unknown) & (Description extends {
79
+ setter: DDSetter<T>;
80
+ } ? LegacyPropertyDecorator<T> & ModernSetterDecorator<T> & ModernAccessorDecorator<T> : unknown) & (Description extends {
81
+ default: infer Signature;
82
+ } ? Signature : unknown);
83
+ /**
84
+ * Creates a decorator that works with Legacy decorator proposals
85
+ * @param description - The decorator description object
86
+ * @returns A decorator function compatible with Legacy decorators
87
+ */
88
+ declare function legacyDecorator<T = any>(description: DecoratorDescription<T>): any;
89
+ /**
90
+ * Creates a decorator that works with Modern decorator proposals
91
+ * @param description - The decorator description object
92
+ * @returns A decorator function compatible with Modern decorators
93
+ */
94
+ declare function modernDecorator<T = any>(description: DecoratorDescription<T>): any;
95
+ /**
96
+ * Main decorator factory that automatically detects and works with both Legacy and Modern decorator proposals
97
+ * @param description - The decorator description object
98
+ * @returns A decorator that works in both Legacy and Modern environments
99
+ */
100
+ declare const decorator: DecoratorFactory<any>;
101
+ /**
102
+ * Generic class decorator type that works with both Legacy and Modern decorator proposals
103
+ */
104
+ type GenericClassDecorator<T> = LegacyClassDecorator<abstract new (...args: any[]) => T> & ModernClassDecorator<abstract new (...args: any[]) => T>;
1
105
 
2
- export { };
106
+ /**
107
+ * Symbol for marking destructor methods
108
+ */
109
+ declare const destructor: unique symbol;
110
+ /**
111
+ * Symbol for accessing allocated values in destroyable objects
112
+ */
113
+ declare const allocatedValues: unique symbol;
114
+ /**
115
+ * Error thrown when attempting to access a destroyed object
116
+ */
117
+ declare class DestructionError extends Error {
118
+ static throw<_T = void>(msg: string): () => never;
119
+ constructor(msg: string);
120
+ }
121
+ declare abstract class AbstractDestroyable<Allocated> {
122
+ abstract [destructor](allocated: Allocated): void;
123
+ [Symbol.dispose](): void;
124
+ }
125
+ interface Destructor<Allocated> {
126
+ destructor(allocated: Allocated): void;
127
+ }
128
+ /**
129
+ * Creates a destroyable class with a base class and destructor object
130
+ * @param base - The base class to extend
131
+ * @param destructorObj - Object containing the destructor method
132
+ * @returns A destroyable class with static destroy and isDestroyable methods
133
+ */
134
+ 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> & {
135
+ [allocatedValues]: Allocated;
136
+ }) & {
137
+ destroy(obj: InstanceType<T>): boolean;
138
+ isDestroyable(obj: InstanceType<T>): boolean;
139
+ };
140
+ /**
141
+ * Creates a destroyable class with only a destructor object (no base class)
142
+ * @param destructorObj - Object containing the destructor method
143
+ * @returns A destroyable class with static destroy and isDestroyable methods
144
+ */
145
+ declare function Destroyable<Allocated extends Record<PropertyKey, any> = Record<PropertyKey, any>>(destructorObj: Destructor<Allocated>): (new () => {
146
+ [allocatedValues]: Allocated;
147
+ }) & {
148
+ destroy(obj: any): boolean;
149
+ isDestroyable(obj: any): boolean;
150
+ };
151
+ /**
152
+ * Creates a destroyable class with a base class (requires [destructor] method)
153
+ * @param base - The base class to extend
154
+ * @returns A destroyable class with static destroy and isDestroyable methods
155
+ */
156
+ 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> & {
157
+ [allocatedValues]: Allocated;
158
+ }) & {
159
+ destroy(obj: InstanceType<T>): boolean;
160
+ isDestroyable(obj: InstanceType<T>): boolean;
161
+ };
162
+ /**
163
+ * Creates an abstract destroyable base class
164
+ * @returns An abstract destroyable class with static destroy and isDestroyable methods
165
+ */
166
+ declare function Destroyable<Allocated extends Record<PropertyKey, any> = Record<PropertyKey, any>>(): abstract new () => (AbstractDestroyable<Allocated> & {
167
+ [allocatedValues]: Allocated;
168
+ }) & {
169
+ destroy(obj: any): boolean;
170
+ isDestroyable(obj: any): boolean;
171
+ };
172
+ /**
173
+ * Decorator that marks properties to be stored in the allocated object and passed to the destructor
174
+ * Use with accessor properties or explicit get/set pairs
175
+ */
176
+ declare const allocated: LegacyPropertyDecorator<any> & ModernSetterDecorator<any> & ModernAccessorDecorator<any>;
177
+ /**
178
+ * Registers a callback to be called when an object is garbage collected
179
+ * @param cb - The callback function to execute on garbage collection
180
+ * @returns The object whose reference can be collected
181
+ */
182
+ declare function callOnGC(cb: () => void): () => void;
183
+ /**
184
+ * Context Manager Protocol for `using` statement integration
185
+ * Provides automatic resource cleanup when used with the `using` statement
186
+ */
187
+ interface ContextManager<T = any> {
188
+ [Symbol.dispose](): void;
189
+ value?: T;
190
+ }
191
+
192
+ /**
193
+ * Base type for event maps - all event handlers must be functions
194
+ */
195
+ type EventsBase = Record<string, (...args: any[]) => void>;
196
+ /**
197
+ * A type-safe event system that provides a clean API for event handling
198
+ * @template Events - The event map defining event names and their handler signatures
199
+ */
200
+ declare class Eventful<Events extends EventsBase> {
201
+ #private;
202
+ hook(cb: <EventType extends keyof Events>(event: EventType, ...args: Parameters<Events[EventType]>) => void): () => void;
203
+ on(events: Partial<Events>): void;
204
+ on<EventType extends keyof Events>(event: EventType, cb: Events[EventType]): () => void;
205
+ off(events: Partial<Events>): void;
206
+ off<EventType extends keyof Events>(event: EventType, cb?: Events[EventType]): void;
207
+ emit<EventType extends keyof Events>(event: EventType, ...args: Parameters<Events[EventType]>): void;
208
+ }
209
+
210
+ /**
211
+ * Symbol for defining custom getter logic for numeric index access
212
+ */
213
+ declare const getAt: unique symbol;
214
+ /**
215
+ * Symbol for defining custom setter logic for numeric index access
216
+ */
217
+ declare const setAt: unique symbol;
218
+ interface IndexingAt<Items = any> {
219
+ [getAt](index: number): Items;
220
+ }
221
+ interface Accessor<T, Items> {
222
+ get(this: T, index: number): Items;
223
+ set?(this: T, index: number, value: Items): void;
224
+ getLength?(this: T): number;
225
+ setLength?(this: T, value: number): void;
226
+ }
227
+ declare abstract class AbstractGetAt<Items = any> {
228
+ abstract [getAt](index: number): Items;
229
+ }
230
+ /**
231
+ * Creates an indexable class with a base class and accessor object
232
+ * @param base - The base class to extend
233
+ * @param accessor - Object containing get/set methods for numeric index access
234
+ * @returns A class that supports numeric index access
235
+ */
236
+ declare function Indexable<Items, Base extends abstract new (...args: any[]) => any>(base: Base, accessor: Accessor<InstanceType<Base>, Items>): new (...args: ConstructorParameters<Base>) => InstanceType<Base> & {
237
+ [x: number]: Items;
238
+ };
239
+ /**
240
+ * Creates an indexable class with only an accessor object (no base class)
241
+ * @param accessor - Object containing get/set methods for numeric index access
242
+ * @returns A class that supports numeric index access
243
+ */
244
+ declare function Indexable<Items>(accessor: Accessor<any, Items>): new () => {
245
+ [x: number]: Items;
246
+ };
247
+ /**
248
+ * Creates an indexable class with a base class that has [getAt] method
249
+ * @param base - The base class that implements [getAt] method
250
+ * @returns A class that supports numeric index access using the base class's [getAt] method
251
+ */
252
+ declare function Indexable<Base extends new (...args: any[]) => IndexingAt>(base: Base): new (...args: ConstructorParameters<Base>) => InstanceType<Base> & {
253
+ [x: number]: AtReturnType<InstanceType<Base>>;
254
+ };
255
+ /**
256
+ * Creates an abstract indexable base class
257
+ * @returns An abstract class that supports numeric index access
258
+ */
259
+ declare function Indexable<Items>(): abstract new (...args: any[]) => AbstractGetAt & {
260
+ [x: number]: Items;
261
+ };
262
+ type AtReturnType<T> = T extends {
263
+ [getAt](index: number): infer R;
264
+ } ? R : never;
265
+ /**
266
+ * Symbol for accessing the forwarded array in ArrayReadForward
267
+ */
268
+ declare const forwardArray: unique symbol;
269
+ /**
270
+ * A read-only array forwarder that implements all reading/iterating methods of Array
271
+ * but does not implement modification methods.
272
+ *
273
+ * The constructor takes a callback that returns an array, and all methods forward
274
+ * their behavior to the result of that callback.
275
+ */
276
+ declare class ArrayReadForward<T> {
277
+ protected get [forwardArray](): readonly T[];
278
+ /**
279
+ * Get the length of the array
280
+ */
281
+ get length(): number;
282
+ /**
283
+ * Get an element at a specific index
284
+ */
285
+ [index: number]: T | undefined;
286
+ /**
287
+ * Iterator protocol support
288
+ */
289
+ [Symbol.iterator](): Iterator<T>;
290
+ /**
291
+ * Creates a new array with the results of calling a provided function on every element
292
+ */
293
+ map<U>(callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any): U[];
294
+ /**
295
+ * Creates a new array with all elements that pass the test implemented by the provided function
296
+ */
297
+ filter<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S[];
298
+ filter(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T[];
299
+ /**
300
+ * Executes a reducer function on each element of the array, resulting in a single output value
301
+ */
302
+ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T;
303
+ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T;
304
+ reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U;
305
+ /**
306
+ * Executes a reducer function on each element of the array (right-to-left), resulting in a single output value
307
+ */
308
+ reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T;
309
+ reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T;
310
+ reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U;
311
+ /**
312
+ * Executes a provided function once for each array element
313
+ */
314
+ forEach(callbackfn: (value: T, index: number, array: readonly T[]) => void, thisArg?: any): void;
315
+ /**
316
+ * Returns the value of the first element in the array that satisfies the provided testing function
317
+ */
318
+ find<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S | undefined;
319
+ find(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T | undefined;
320
+ /**
321
+ * Returns the index of the first element in the array that satisfies the provided testing function
322
+ */
323
+ findIndex(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): number;
324
+ /**
325
+ * Returns the value of the last element in the array that satisfies the provided testing function
326
+ */
327
+ findLast<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S | undefined;
328
+ findLast(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T | undefined;
329
+ /**
330
+ * Returns the index of the last element in the array that satisfies the provided testing function
331
+ */
332
+ findLastIndex(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): number;
333
+ /**
334
+ * Determines whether an array includes a certain value among its entries
335
+ */
336
+ includes(searchElement: T, fromIndex?: number): boolean;
337
+ /**
338
+ * Returns the first index at which a given element can be found in the array
339
+ */
340
+ indexOf(searchElement: T, fromIndex?: number): number;
341
+ /**
342
+ * Returns the last index at which a given element can be found in the array
343
+ */
344
+ lastIndexOf(searchElement: T, fromIndex?: number): number;
345
+ /**
346
+ * Returns a shallow copy of a portion of an array into a new array object
347
+ */
348
+ slice(start?: number, end?: number): T[];
349
+ /**
350
+ * Returns a new array comprised of this array joined with other array(s) and/or value(s)
351
+ */
352
+ concat(...items: ConcatArray<T>[]): T[];
353
+ concat(...items: (T | ConcatArray<T>)[]): T[];
354
+ /**
355
+ * Tests whether all elements in the array pass the test implemented by the provided function
356
+ */
357
+ every(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean;
358
+ /**
359
+ * Tests whether at least one element in the array passes the test implemented by the provided function
360
+ */
361
+ some(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean;
362
+ /**
363
+ * Joins all elements of an array into a string
364
+ */
365
+ join(separator?: string): string;
366
+ /**
367
+ * Returns a new array iterator that contains the keys for each index in the array
368
+ */
369
+ keys(): IterableIterator<number>;
370
+ /**
371
+ * Returns a new array iterator that contains the values for each index in the array
372
+ */
373
+ values(): IterableIterator<T>;
374
+ /**
375
+ * Returns a new array iterator that contains the key/value pairs for each index in the array
376
+ */
377
+ entries(): IterableIterator<[number, T]>;
378
+ /**
379
+ * Returns a string representation of the array
380
+ */
381
+ toString(): string;
382
+ /**
383
+ * Returns a localized string representing the array
384
+ */
385
+ toLocaleString(locales?: string | string[], options?: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions): string;
386
+ /**
387
+ * Returns the element at the specified index, or undefined if the index is out of bounds
388
+ */
389
+ at(index: number): T | undefined;
390
+ /**
391
+ * Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth
392
+ */
393
+ flat(depth?: number): T[];
394
+ /**
395
+ * Returns a new array formed by applying a given callback function to each element of the array,
396
+ * and then flattening the result by one level
397
+ */
398
+ flatMap<U, This = undefined>(callback: (this: This, value: T, index: number, array: readonly T[]) => U | ReadonlyArray<U>, thisArg?: This): U[];
399
+ /**
400
+ * Returns a new array with elements in reversed order (ES2023)
401
+ */
402
+ toReversed(): T[];
403
+ /**
404
+ * Returns a new array with elements sorted (ES2023)
405
+ */
406
+ toSorted(compareFn?: ((a: T, b: T) => number) | undefined): T[];
407
+ /**
408
+ * Returns a new array with some elements removed and/or replaced at a given index (ES2023)
409
+ */
410
+ toSpliced(start: number, deleteCount?: number, ...items: T[]): T[];
411
+ /**
412
+ * Returns a new array with the element at the given index replaced with the given value (ES2023)
413
+ */
414
+ with(index: number, value: T): T[];
415
+ get [Symbol.unscopables](): {
416
+ readonly [x: number]: boolean;
417
+ readonly length?: boolean;
418
+ toString?: boolean;
419
+ toLocaleString?: boolean;
420
+ concat?: boolean;
421
+ join?: boolean;
422
+ slice?: boolean;
423
+ indexOf?: boolean;
424
+ lastIndexOf?: boolean;
425
+ every?: boolean;
426
+ some?: boolean;
427
+ forEach?: boolean;
428
+ map?: boolean;
429
+ filter?: boolean;
430
+ reduce?: boolean;
431
+ reduceRight?: boolean;
432
+ find?: boolean;
433
+ findIndex?: boolean;
434
+ entries?: boolean;
435
+ keys?: boolean;
436
+ values?: boolean;
437
+ includes?: boolean;
438
+ flatMap?: boolean;
439
+ flat?: boolean;
440
+ at?: boolean;
441
+ findLast?: boolean;
442
+ findLastIndex?: boolean;
443
+ toReversed?: boolean;
444
+ toSorted?: boolean;
445
+ toSpliced?: boolean;
446
+ with?: boolean;
447
+ [Symbol.iterator]?: boolean;
448
+ readonly [Symbol.unscopables]?: boolean;
449
+ };
450
+ }
451
+
452
+ /**
453
+ * Uses weak references but still may iterate through them
454
+ * Note: The behavior is highly dependant on the garbage collector - some entries are perhaps deemed to be collected: don't resuscitate them
455
+ */
456
+ declare class IterableWeakMap<K extends WeakKey, V> implements Map<K, V> {
457
+ private uuids;
458
+ private refs;
459
+ private readonly registry;
460
+ constructor(entries?: Iterable<[K, V]>);
461
+ private createIterator;
462
+ clear(): void;
463
+ delete(key: K): boolean;
464
+ forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
465
+ get(key: K): V | undefined;
466
+ has(key: K): boolean;
467
+ set(key: K, value: V): this;
468
+ get size(): number;
469
+ entries(): MapIterator<[K, V]>;
470
+ keys(): MapIterator<K>;
471
+ values(): MapIterator<V>;
472
+ [Symbol.iterator](): MapIterator<[K, V]>;
473
+ readonly [Symbol.toStringTag]: string;
474
+ }
475
+ /**
476
+ * Uses weak references but still may iterate through them
477
+ * Note: The behavior is highly dependant on the garbage collector - some entries are perhaps deemed to be collected: don't resuscitate them
478
+ */
479
+ declare class IterableWeakSet<K extends WeakKey> implements Set<K> {
480
+ private uuids;
481
+ private refs;
482
+ private readonly registry;
483
+ constructor(entries?: Iterable<K>);
484
+ private createIterator;
485
+ clear(): void;
486
+ add(value: K): this;
487
+ delete(value: K): boolean;
488
+ forEach(callbackfn: (value: K, value2: K, set: Set<K>) => void, thisArg?: any): void;
489
+ has(value: K): boolean;
490
+ get size(): number;
491
+ entries(): SetIterator<[K, K]>;
492
+ keys(): SetIterator<K>;
493
+ values(): SetIterator<K>;
494
+ [Symbol.iterator](): SetIterator<K>;
495
+ readonly [Symbol.toStringTag]: string;
496
+ union<U>(other: ReadonlySetLike<U>): Set<K | U>;
497
+ intersection<U>(other: ReadonlySetLike<U>): Set<K & U>;
498
+ difference<U>(other: ReadonlySetLike<U>): Set<K>;
499
+ symmetricDifference<U>(other: ReadonlySetLike<U>): Set<K | U>;
500
+ isSubsetOf(other: ReadonlySetLike<unknown>): boolean;
501
+ isSupersetOf(other: ReadonlySetLike<unknown>): boolean;
502
+ isDisjointFrom(other: ReadonlySetLike<unknown>): boolean;
503
+ }
504
+
505
+ /**
506
+ * A mixin function that takes a base class and returns a new class with mixed-in functionality
507
+ * @template Mixed - The functionality to be mixed in
508
+ */
509
+ type MixinFunction<Mixed> = <Base>(base: new (...args: any[]) => Base) => new (...args: any[]) => Base & Mixed;
510
+ /**
511
+ * A mixin class that can be used both as a base class and as a mixin function
512
+ * @template Mixed - The functionality to be mixed in
513
+ */
514
+ type MixinClass<Mixed> = new (...args: any[]) => Mixed;
515
+ /**
516
+ * Creates a mixin that can be used both as a class (extends) and as a function (mixin)
517
+ *
518
+ * This function supports:
519
+ * - Using mixins as base classes: `class MyClass extends MyMixin`
520
+ * - Using mixins as functions: `class MyClass extends MyMixin(SomeBase)`
521
+ * - Composing mixins: `const Composed = MixinA(MixinB)`
522
+ * - Type-safe property inference for all patterns
523
+ *
524
+ * @param mixinFunction - The function that creates the mixin
525
+ * @param unwrapFunction - Optional function to unwrap reactive objects for method calls
526
+ * @returns A mixin that can be used both as a class and as a function
527
+ */
528
+ 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);
529
+
530
+ type Resolved<T> = T extends Promise<infer U> ? Resolved<U> : T extends (...args: infer Args) => infer R ? (...args: Args) => Resolved<R> : T extends object ? {
531
+ [k in keyof T]: k extends 'then' | 'catch' | 'finally' ? T[k] : Resolved<T[k]>;
532
+ } : T;
533
+ type PromiseAnd<T> = Resolved<T> & Promise<Resolved<T>>;
534
+ /**
535
+ * Type that transforms promises into chainable objects
536
+ * Allows calling methods directly on promise results without awaiting them first
537
+ */
538
+ type PromiseChain<T> = T extends (...args: infer Args) => infer R ? PromiseAnd<(...args: Args) => PromiseChain<Resolved<R>>> : T extends object ? PromiseAnd<{
539
+ [k in keyof T]: k extends 'then' | 'catch' | 'finally' ? T[k] : PromiseChain<Resolved<T[k]>>;
540
+ }> : Promise<Resolved<T>>;
541
+ /**
542
+ * Transforms a promise or value into a chainable object
543
+ * Allows calling methods directly on promise results without awaiting them first
544
+ * @param given - The promise or value to make chainable
545
+ * @returns A chainable version of the input
546
+ */
547
+ declare function chainPromise<T>(given: Promise<T> | T): PromiseChain<T>;
548
+
549
+ declare abstract class AZone<T> {
550
+ abstract active?: T;
551
+ protected enter(value?: T): unknown;
552
+ protected leave(entered: unknown): void;
553
+ with<R>(value: T, fn: () => R): R;
554
+ root<R>(fn: () => R): R;
555
+ get zoned(): FunctionWrapper;
556
+ }
557
+ type FunctionWrapper = <R>(fn?: () => R) => R;
558
+ declare class Zone<T> extends AZone<T> {
559
+ active: T | undefined;
560
+ }
561
+ type HistoryValue<T> = {
562
+ present: T | undefined;
563
+ history: Set<T>;
564
+ };
565
+ declare class ZoneHistory<T> extends AZone<HistoryValue<T>> {
566
+ private controlled;
567
+ private history;
568
+ readonly present: AZone<T>;
569
+ has(value: T): boolean;
570
+ some(predicate: (value: T) => boolean): boolean;
571
+ constructor(controlled?: AZone<T>);
572
+ get active(): HistoryValue<T> | undefined;
573
+ set active(value: HistoryValue<T> | undefined);
574
+ }
575
+ declare class ZoneAggregator extends AZone<Map<AZone<unknown>, unknown>> {
576
+ #private;
577
+ constructor(...zones: AZone<unknown>[]);
578
+ get active(): Map<AZone<unknown>, unknown> | undefined;
579
+ set active(value: Map<AZone<unknown>, unknown> | undefined);
580
+ enter(value?: Map<AZone<unknown>, unknown> | undefined): Map<AZone<unknown>, unknown>;
581
+ leave(entered: Map<AZone<unknown>, unknown>): void;
582
+ add(z: AZone<unknown>): void;
583
+ delete(z: AZone<unknown>): void;
584
+ clear(): void;
585
+ }
586
+ declare const asyncZone: ZoneAggregator;
587
+
588
+ /**
589
+ * Dependency access passed to user callbacks within effects/watch
590
+ * Provides functions to track dependencies and information about the effect execution
591
+ */
592
+ interface DependencyAccess {
593
+ /**
594
+ * Tracks dependencies in the current effect context
595
+ * Use this for normal dependency tracking within the effect
596
+ * @example
597
+ * ```typescript
598
+ * effect(({ tracked }) => {
599
+ * // In async context, use tracked to restore dependency tracking
600
+ * await someAsyncOperation()
601
+ * const value = tracked(() => state.count) // Tracks state.count in this effect
602
+ * })
603
+ * ```
604
+ */
605
+ tracked: FunctionWrapper;
606
+ /**
607
+ * Tracks dependencies in the parent effect context
608
+ * Use this when child effects should track dependencies in the parent,
609
+ * allowing parent cleanup to manage child effects while dependencies trigger the parent
610
+ * @example
611
+ * ```typescript
612
+ * effect(({ ascend }) => {
613
+ * const length = inputs.length
614
+ * if (length > 0) {
615
+ * ascend(() => {
616
+ * // Dependencies here are tracked in the parent effect
617
+ * inputs.forEach(item => console.log(item))
618
+ * })
619
+ * }
620
+ * })
621
+ * ```
622
+ */
623
+ ascend: FunctionWrapper;
624
+ /**
625
+ * Indicates whether the effect is running as a reaction (i.e. not the first call)
626
+ * - `false`: First execution when the effect is created
627
+ * - `true`: Subsequent executions triggered by dependency changes
628
+ * @example
629
+ * ```typescript
630
+ * effect(({ reaction }) => {
631
+ * if (!reaction) {
632
+ * console.log('Effect initialized')
633
+ * // Setup code that should only run once
634
+ * } else {
635
+ * console.log('Effect re-ran due to dependency change')
636
+ * // Code that runs on every update
637
+ * }
638
+ * })
639
+ * ```
640
+ */
641
+ reaction: boolean;
642
+ }
643
+ /**
644
+ * Type for effect cleanup functions
645
+ */
646
+ type ScopedCallback = () => void;
647
+ /**
648
+ * Async execution mode for effects
649
+ * - `cancel`: Cancel previous async execution when dependencies change (default)
650
+ * - `queue`: Queue next execution to run after current completes
651
+ * - `ignore`: Ignore new executions while async work is running
652
+ */
653
+ type AsyncExecutionMode = 'cancel' | 'queue' | 'ignore';
654
+ /**
655
+ * Options for effect creation
656
+ */
657
+ interface EffectOptions {
658
+ /**
659
+ * How to handle async effect executions when dependencies change
660
+ * @default 'cancel'
661
+ */
662
+ asyncMode?: AsyncExecutionMode;
663
+ /**
664
+ * If true, this effect is "opaque" to deep optimizations: it sees the object reference itself
665
+ * and must be notified when it changes, regardless of deep content similarity.
666
+ * Use this for effects that depend on object identity (like memoize).
667
+ */
668
+ opaque?: boolean;
669
+ }
670
+ /**
671
+ * Type for property evolution events
672
+ */
673
+ type PropEvolution = {
674
+ type: 'set' | 'del' | 'add' | 'invalidate';
675
+ prop: any;
676
+ };
677
+ /**
678
+ * Type for collection operation evolution events
679
+ */
680
+ type BunchEvolution = {
681
+ type: 'bunch';
682
+ method: string;
683
+ };
684
+ type Evolution = PropEvolution | BunchEvolution;
685
+ type State = {
686
+ evolution: Evolution;
687
+ next: State;
688
+ } | {};
689
+ /**
690
+ * Symbol to check if an effect is stopped
691
+ */
692
+ declare const stopped: unique symbol;
693
+ /**
694
+ * Symbol to access effect cleanup function
695
+ */
696
+ declare const cleanup$1: unique symbol;
697
+ /**
698
+ * Context for a running projection item effect
699
+ */
700
+ interface ProjectionContext {
701
+ source: any;
702
+ key?: any;
703
+ target: any;
704
+ depth: number;
705
+ parent?: ProjectionContext;
706
+ }
707
+ /**
708
+ * Structured error codes for machine-readable diagnosis
709
+ */
710
+ declare enum ReactiveErrorCode {
711
+ CycleDetected = "CYCLE_DETECTED",
712
+ MaxDepthExceeded = "MAX_DEPTH_EXCEEDED",
713
+ MaxReactionExceeded = "MAX_REACTION_EXCEEDED",
714
+ WriteInComputed = "WRITE_IN_COMPUTED",
715
+ TrackingError = "TRACKING_ERROR",
716
+ BrokenEffects = "BROKEN_EFFECTS"
717
+ }
718
+ type CycleDebugInfo = {
719
+ code: ReactiveErrorCode.CycleDetected;
720
+ cycle: string[];
721
+ details?: string;
722
+ };
723
+ type MaxDepthDebugInfo = {
724
+ code: ReactiveErrorCode.MaxDepthExceeded;
725
+ depth: number;
726
+ chain: string[];
727
+ };
728
+ type MaxReactionDebugInfo = {
729
+ code: ReactiveErrorCode.MaxReactionExceeded;
730
+ count: number;
731
+ effect: string;
732
+ };
733
+ type BrokenEffectsDebugInfo = {
734
+ code: ReactiveErrorCode.BrokenEffects;
735
+ cause: any;
736
+ };
737
+ type GenericDebugInfo = {
738
+ code: ReactiveErrorCode;
739
+ causalChain?: string[];
740
+ creationStack?: string;
741
+ [key: string]: any;
742
+ };
743
+ type ReactiveDebugInfo = CycleDebugInfo | MaxDepthDebugInfo | MaxReactionDebugInfo | BrokenEffectsDebugInfo | GenericDebugInfo;
744
+ /**
745
+ * Error class for reactive system errors
746
+ */
747
+ declare class ReactiveError extends Error {
748
+ debugInfo?: ReactiveDebugInfo;
749
+ constructor(message: string, debugInfo?: ReactiveDebugInfo);
750
+ get code(): ReactiveErrorCode | undefined;
751
+ get cause(): any;
752
+ }
753
+ /**
754
+ * Global options for the reactive system
755
+ */
756
+ declare const options: {
757
+ /**
758
+ * Debug purpose: called when an effect is entered
759
+ * @param effect - The effect that is entered
760
+ */
761
+ enter: (_effect: Function) => void;
762
+ /**
763
+ * Debug purpose: called when an effect is left
764
+ * @param effect - The effect that is left
765
+ */
766
+ leave: (_effect: Function) => void;
767
+ /**
768
+ * Debug purpose: called when an effect is chained
769
+ * @param target - The effect that is being triggered
770
+ * @param caller - The effect that is calling the target
771
+ */
772
+ chain: (_targets: Function[], _caller?: Function) => void;
773
+ /**
774
+ * Debug purpose: called when an effect chain is started
775
+ * @param target - The effect that is being triggered
776
+ */
777
+ beginChain: (_targets: Function[]) => void;
778
+ /**
779
+ * Debug purpose: called when an effect chain is ended
780
+ */
781
+ endChain: () => void;
782
+ garbageCollected: (_fn: Function) => void;
783
+ /**
784
+ * Debug purpose: called when an object is touched
785
+ * @param obj - The object that is touched
786
+ * @param evolution - The type of change
787
+ * @param props - The properties that changed
788
+ * @param deps - The dependencies that changed
789
+ */
790
+ touched: (_obj: any, _evolution: Evolution, _props?: any[], _deps?: Set<ScopedCallback>) => void;
791
+ /**
792
+ * Debug purpose: called when an effect is skipped because it's already running
793
+ * @param effect - The effect that is already running
794
+ * @param runningChain - The array of effects from the detected one to the currently running one
795
+ */
796
+ skipRunningEffect: (_effect: ScopedCallback) => void;
797
+ /**
798
+ * Debug purpose: maximum effect chain (like call stack max depth)
799
+ * Used to prevent infinite loops
800
+ * @default 100
801
+ */
802
+ maxEffectChain: number;
803
+ /**
804
+ * Maximum number of times an effect can be triggered by the same cause in a single batch
805
+ * Used to detect aggressive re-computation or infinite loops
806
+ * @default 10
807
+ */
808
+ maxTriggerPerBatch: number;
809
+ /**
810
+ * Debug purpose: maximum effect reaction (like call stack max depth)
811
+ * Used to prevent infinite loops
812
+ * @default 'throw'
813
+ */
814
+ maxEffectReaction: "throw" | "debug" | "warn";
815
+ /**
816
+ * Callback called when a memoization discrepancy is detected (debug only)
817
+ * When defined, memoized functions will run a second time (untracked) to verify consistency.
818
+ * If the untracked run returns a different value than the cached one, this callback is triggered.
819
+ *
820
+ * This is the primary tool for detecting missing reactive dependencies in computed values.
821
+ *
822
+ * @param cached - The value currently in the memoization cache
823
+ * @param fresh - The value obtained by re-running the function untracked
824
+ * @param fn - The memoized function itself
825
+ * @param args - Arguments passed to the function
826
+ *
827
+ * @example
828
+ * ```typescript
829
+ * reactiveOptions.onMemoizationDiscrepancy = (cached, fresh, fn, args) => {
830
+ * throw new Error(`Memoization discrepancy in ${fn.name}!`);
831
+ * };
832
+ * ```
833
+ */
834
+ onMemoizationDiscrepancy: ((cached: any, fresh: any, fn: Function, args: any[], cause: "calculation" | "comparison") => void) | undefined;
835
+ /**
836
+ * How to handle cycles detected in effect batches.
837
+ *
838
+ * - `'none'` (Default): High-performance mode. Disables dependency graph maintenance and
839
+ * Topological Sorting in favor of a simple FIFO queue. Use this for trustworthy, acyclic UI code.
840
+ * Cycle detection is heuristic (uses execution counts).
841
+ *
842
+ * - `'throw'`: Traditional Topological Sorting. Guarantees dependency order and catches
843
+ * circular dependencies mathematically before execution.
844
+ *
845
+ * - `'warn'`: Topological sorting, but logs a warning instead of throwing on cycles.
846
+ * - `'break'`: Topological sorting, but silently breaks cycles.
847
+ * - `'strict'`: Prevents cycle creation by checking the graph *during* dependency discovery.
848
+ *
849
+ * @default 'none'
850
+ */
851
+ cycleHandling: "none" | "throw" | "warn" | "break" | "strict";
852
+ /**
853
+ * Internal flag used by memoization discrepancy detector to avoid counting calls in tests
854
+ * @warning Do not modify this flag manually, this flag is given by the engine
855
+ */
856
+ isVerificationRun: boolean;
857
+ /**
858
+ * Maximum depth for deep watching traversal
859
+ * Used to prevent infinite recursion in circular references
860
+ * @default 100
861
+ */
862
+ maxDeepWatchDepth: number;
863
+ /**
864
+ * Only react on instance members modification (not inherited properties)
865
+ * For instance, do not track class methods
866
+ * @default true
867
+ */
868
+ instanceMembers: boolean;
869
+ /**
870
+ * Ignore accessors (getters and setters) and only track direct properties
871
+ * @default true
872
+ */
873
+ ignoreAccessors: boolean;
874
+ /**
875
+ * Enable recursive touching when objects with the same prototype are replaced
876
+ * When enabled, replacing an object with another of the same prototype triggers
877
+ * recursive diffing instead of notifying parent effects
878
+ * @default true
879
+ */
880
+ recursiveTouching: boolean;
881
+ /**
882
+ * Default async execution mode for effects that return Promises
883
+ * - 'cancel': Cancel previous async execution when dependencies change (default, enables async zone)
884
+ * - 'queue': Queue next execution to run after current completes (enables async zone)
885
+ * - 'ignore': Ignore new executions while async work is running (enables async zone)
886
+ * - false: Disable async zone and async mode handling (effects run concurrently)
887
+ *
888
+ * **When truthy:** Enables async zone (Promise.prototype wrapping) for automatic context
889
+ * preservation in Promise callbacks. Warning: This modifies Promise.prototype globally.
890
+ * Only enable if no other library modifies Promise.prototype.
891
+ *
892
+ * **When false:** Async zone is disabled. Use `tracked()` manually in Promise callbacks.
893
+ *
894
+ * Can be overridden per-effect via EffectOptions
895
+ * @default 'cancel'
896
+ */
897
+ asyncMode: AsyncExecutionMode | false;
898
+ warn: (...args: any[]) => void;
899
+ /**
900
+ * Configuration for the introspection system
901
+ */
902
+ introspection: {
903
+ /**
904
+ * Whether to keep a history of mutations for debugging
905
+ * @default false
906
+ */
907
+ enableHistory: boolean;
908
+ /**
909
+ * Number of mutations to keep in history
910
+ * @default 50
911
+ */
912
+ historySize: number;
913
+ };
914
+ /**
915
+ * Configuration for zone hooks - control which async APIs are hooked
916
+ * Each option controls whether the corresponding async API is wrapped to preserve effect context
917
+ * Only applies when asyncMode is enabled (truthy)
918
+ * @deprecated Should take all when we made sure PIXI.create, Game.create, ... are -> .root()
919
+ */
920
+ zones: {
921
+ /**
922
+ * Hook setTimeout to preserve effect context
923
+ * @default true
924
+ */
925
+ setTimeout: boolean;
926
+ /**
927
+ * Hook setInterval to preserve effect context
928
+ * @default true
929
+ */
930
+ setInterval: boolean;
931
+ /**
932
+ * Hook requestAnimationFrame (runs in untracked context when hooked)
933
+ * @default true
934
+ */
935
+ requestAnimationFrame: boolean;
936
+ /**
937
+ * Hook queueMicrotask to preserve effect context
938
+ * @default true
939
+ */
940
+ queueMicrotask: boolean;
941
+ };
942
+ };
943
+
944
+ /**
945
+ * Gets the current state of a reactive object for evolution tracking
946
+ * @param obj - The reactive object
947
+ * @returns The current state object
948
+ */
949
+ declare function getState(obj: any): State;
950
+ /**
951
+ * Triggers effects for a single property change
952
+ * @param obj - The object that changed
953
+ * @param evolution - The type of change
954
+ * @param prop - The property that changed
955
+ */
956
+ declare function touched1(obj: any, evolution: Evolution, prop: any): void;
957
+ /**
958
+ * Triggers effects for property changes
959
+ * @param obj - The object that changed
960
+ * @param evolution - The type of change
961
+ * @param props - The properties that changed
962
+ */
963
+ declare function touched(obj: any, evolution: Evolution, props?: Iterable<any>): void;
964
+
965
+ /**
966
+ * Debug utilities for the reactivity system
967
+ * - Captures effect metadata (names, parent relationships)
968
+ * - Records cause → consequence edges with object/prop labels
969
+ * - Provides graph data for tooling (DevTools panel, etc.)
970
+ */
971
+
972
+ type NodeKind = 'effect' | 'external' | 'state';
973
+ type EdgeKind = 'cause' | 'dependency' | 'trigger';
974
+ interface EffectNode {
975
+ id: string;
976
+ label: string;
977
+ type: NodeKind;
978
+ depth: number;
979
+ parentId?: string;
980
+ debugName?: string;
981
+ }
982
+ interface ObjectNode {
983
+ id: string;
984
+ label: string;
985
+ type: NodeKind;
986
+ debugName?: string;
987
+ }
988
+ interface GraphEdge {
989
+ id: string;
990
+ source: string;
991
+ target: string;
992
+ type: EdgeKind;
993
+ label: string;
994
+ count?: number;
995
+ }
996
+ interface ReactivityGraph {
997
+ nodes: Array<EffectNode | ObjectNode>;
998
+ edges: GraphEdge[];
999
+ meta: {
1000
+ generatedAt: number;
1001
+ devtoolsEnabled: boolean;
1002
+ };
1003
+ }
1004
+ /**
1005
+ * Assign a debug-friendly name to an effect (shown in DevTools)
1006
+ */
1007
+ declare function setEffectName(effect: ScopedCallback, name: string): void;
1008
+ /**
1009
+ * Assign a debug-friendly name to a reactive object
1010
+ */
1011
+ declare function setObjectName(obj: object, name: string): void;
1012
+ /**
1013
+ * Register an effect so it appears in the DevTools graph
1014
+ */
1015
+ declare function registerEffectForDebug(effect: ScopedCallback): void;
1016
+ /**
1017
+ * Register a reactive object so it appears in the DevTools graph
1018
+ */
1019
+ declare function registerObjectForDebug(obj: object): void;
1020
+ /**
1021
+ * Builds a graph representing current reactive state (effects, objects, and trigger edges)
1022
+ */
1023
+ declare function buildReactivityGraph(): ReactivityGraph;
1024
+ /**
1025
+ * Enables the DevTools bridge and exposes the debug API on window.
1026
+ * Call as early as possible in development builds.
1027
+ */
1028
+ declare function enableDevTools(): void;
1029
+ declare function isDevtoolsEnabled(): boolean;
1030
+
1031
+ /**
1032
+ * Deep watch an object and all its nested properties
1033
+ * @param target - The object to watch deeply
1034
+ * @param callback - The callback to call when any nested property changes
1035
+ * @param options - Options for the deep watch
1036
+ * @returns A cleanup function to stop watching
1037
+ */
1038
+ /**
1039
+ * Sets up deep watching for an object, tracking all nested property changes
1040
+ * @param target - The object to watch
1041
+ * @param callback - The callback to call when changes occur
1042
+ * @param options - Options for deep watching
1043
+ * @returns A cleanup function to stop deep watching
1044
+ */
1045
+ declare function deepWatch<T extends object>(target: T, callback: (value: T) => void, { immediate }?: {
1046
+ immediate?: boolean;
1047
+ }): (() => void) | undefined;
1048
+
1049
+ type EffectTracking = (obj: any, evolution: Evolution, prop: any) => void;
1050
+ interface ActivationRecord {
1051
+ effect: ScopedCallback;
1052
+ obj: any;
1053
+ evolution: Evolution;
1054
+ prop: any;
1055
+ batchId: number;
1056
+ }
1057
+ declare function getActivationLog(): Omit<ActivationRecord, "batchId">[];
1058
+ /**
1059
+ * Registers a debug callback that is called when the current effect is triggered by a dependency change
1060
+ *
1061
+ * This function is useful for debugging purposes as it pin-points exactly which reactive property
1062
+ * change triggered the effect. The callback receives information about:
1063
+ * - The object that changed
1064
+ * - The type of change (evolution)
1065
+ * - The specific property that changed
1066
+ *
1067
+ * **Note:** The tracker callback is automatically removed after being called once. If you need
1068
+ * to track multiple triggers, call `trackEffect` again within the effect.
1069
+ *
1070
+ * @param onTouch - Callback function that receives (obj, evolution, prop) when the effect is triggered
1071
+ * @throws {Error} If called outside of an effect context
1072
+ *
1073
+ * @example
1074
+ * ```typescript
1075
+ * const state = reactive({ count: 0, name: 'John' })
1076
+ *
1077
+ * effect(() => {
1078
+ * // Register a tracker to see what triggers this effect
1079
+ * trackEffect((obj, evolution, prop) => {
1080
+ * console.log(`Effect triggered by:`, {
1081
+ * object: obj,
1082
+ * change: evolution.type,
1083
+ * property: prop
1084
+ * })
1085
+ * })
1086
+ *
1087
+ * // Access reactive properties
1088
+ * console.log(state.count, state.name)
1089
+ * })
1090
+ *
1091
+ * state.count = 5
1092
+ * // Logs: Effect triggered by: { object: state, change: 'set', property: 'count' }
1093
+ * ```
1094
+ */
1095
+ declare function trackEffect(onTouch: EffectTracking): void;
1096
+ /**
1097
+ * Adds a cleanup function to be called when the current batch of effects completes
1098
+ * @param cleanup - The cleanup function to add
1099
+ */
1100
+ declare function addBatchCleanup(cleanup: ScopedCallback): void;
1101
+ /**
1102
+ * Semantic alias for `addBatchCleanup` - defers work to the end of the current reactive batch.
1103
+ *
1104
+ * Use this when an effect needs to perform an action that would modify state the effect depends on,
1105
+ * which would create a reactive cycle. The deferred callback runs after all effects complete.
1106
+ *
1107
+ * @param callback - The callback to defer until after the current batch completes
1108
+ *
1109
+ * @example
1110
+ * ```typescript
1111
+ * effect(() => {
1112
+ * processData()
1113
+ *
1114
+ * // Defer to avoid cycle (createMovement modifies state this effect reads)
1115
+ * defer(() => {
1116
+ * createMovement(data)
1117
+ * })
1118
+ * })
1119
+ * ```
1120
+ */
1121
+ declare const defer: typeof addBatchCleanup;
1122
+ /**
1123
+ * Decorator that makes methods atomic - batches all effects triggered within the method
1124
+ */
1125
+ declare const atomic: LegacyPropertyDecorator<any> & ModernMethodDecorator<any> & (<Args extends any[], Return>(original: (...args: Args) => Return) => (...args: Args) => Return);
1126
+ /**
1127
+ * @param fn - The effect function to run - provides the cleaner
1128
+ * @returns The cleanup function
1129
+ */
1130
+ /**
1131
+ * Creates a reactive effect that automatically re-runs when dependencies change
1132
+ * @param fn - The effect function that provides dependencies and may return a cleanup function or Promise
1133
+ * @param options - Options for effect execution
1134
+ * @returns A cleanup function to stop the effect
1135
+ */
1136
+ declare function effect(fn: (access: DependencyAccess) => ScopedCallback | undefined | void | Promise<any>, effectOptions?: EffectOptions): ScopedCallback & {
1137
+ [stopped]: boolean;
1138
+ [cleanup$1]: () => void;
1139
+ };
1140
+ /**
1141
+ * Executes a function without tracking dependencies but maintains parent cleanup relationship
1142
+ * Effects created inside will still be cleaned up when the parent effect is destroyed
1143
+ * @param fn - The function to execute
1144
+ */
1145
+ declare function untracked<T>(fn: () => T): T;
1146
+ /**
1147
+ * Executes a function from a virgin/root context - no parent effect, no tracking
1148
+ * Creates completely independent effects that won't be cleaned up by any parent
1149
+ * @param fn - The function to execute
1150
+ */
1151
+ declare function root<T>(fn: () => T): T;
1152
+
1153
+ /**
1154
+ * Creates a bidirectional binding between a reactive value and a non-reactive external value
1155
+ * Prevents infinite loops by automatically suppressing circular notifications
1156
+ *
1157
+ * @param received - Function called when the reactive value changes (external setter)
1158
+ * @param get - Getter for the reactive value OR an object with `{ get, set }` properties
1159
+ * @param set - Setter for the reactive value (required if `get` is a function)
1160
+ * @returns A function to manually provide updates from the external side
1161
+ *
1162
+ * @example
1163
+ * ```typescript
1164
+ * const model = reactive({ value: '' })
1165
+ * const input = { value: '' }
1166
+ *
1167
+ * // Bidirectional binding
1168
+ * const provide = biDi(
1169
+ * (v) => input.value = v, // external setter
1170
+ * () => model.value, // reactive getter
1171
+ * (v) => model.value = v // reactive setter
1172
+ * )
1173
+ *
1174
+ * // External notification (e.g., from input event)
1175
+ * provide('new value') // Updates model.value, doesn't trigger circular loop
1176
+ * ```
1177
+ *
1178
+ * @example Using object syntax
1179
+ * ```typescript
1180
+ * const provide = biDi(
1181
+ * (v) => setHTMLValue(v),
1182
+ * { get: () => reactiveObj.value, set: (v) => reactiveObj.value = v }
1183
+ * )
1184
+ * ```
1185
+ */
1186
+ declare function biDi<T>(received: (value: T) => void, value: {
1187
+ get: () => T;
1188
+ set: (value: T) => void;
1189
+ }): (value: T) => void;
1190
+ declare function biDi<T>(received: (value: T) => void, get: () => T, set: (value: T) => void): (value: T) => void;
1191
+
1192
+ /**
1193
+ * Symbol for accessing the cleanup function on cleaned objects
1194
+ */
1195
+ declare const cleanup: unique symbol;
1196
+ /**
1197
+ * Options for the watch function
1198
+ */
1199
+ interface WatchOptions {
1200
+ /** Whether to call the callback immediately */
1201
+ immediate?: boolean;
1202
+ /** Whether to watch nested properties */
1203
+ deep?: boolean;
1204
+ }
1205
+ /**
1206
+ * Watches a reactive value and calls a callback when it changes
1207
+ * @param value - Function that returns the value to watch
1208
+ * @param changed - Callback to call when the value changes
1209
+ * @param options - Watch options
1210
+ * @returns Cleanup function to stop watching
1211
+ */
1212
+ declare function watch<T>(value: (dep: DependencyAccess) => T, changed: (value: T, oldValue?: T) => void, options?: Omit<WatchOptions, 'deep'> & {
1213
+ deep?: false;
1214
+ }): ScopedCallback;
1215
+ /**
1216
+ * Watches a reactive value with deep watching enabled
1217
+ * @param value - Function that returns the value to watch
1218
+ * @param changed - Callback to call when the value changes
1219
+ * @param options - Watch options with deep watching enabled
1220
+ * @returns Cleanup function to stop watching
1221
+ */
1222
+ declare function watch<T extends object | any[]>(value: (dep: DependencyAccess) => T, changed: (value: T, oldValue?: T) => void, options?: Omit<WatchOptions, 'deep'> & {
1223
+ deep: true;
1224
+ }): ScopedCallback;
1225
+ /**
1226
+ * Watches a reactive object directly
1227
+ * @param value - The reactive object to watch
1228
+ * @param changed - Callback to call when the object changes
1229
+ * @param options - Watch options
1230
+ * @returns Cleanup function to stop watching
1231
+ */
1232
+ declare function watch<T extends object | any[]>(value: T, changed: (value: T) => void, options?: WatchOptions): ScopedCallback;
1233
+ declare function unreactiveApplication<T extends object>(...args: (keyof T)[]): GenericClassDecorator<T>;
1234
+ declare function unreactiveApplication<T extends object>(obj: T): T;
1235
+ /**
1236
+ * Decorator that marks classes or properties as non-reactive
1237
+ * Prevents objects from being made reactive
1238
+ */
1239
+ declare const unreactive: LegacyClassDecorator<new (...args: any[]) => any> & ModernClassDecorator<new (...args: any[]) => any> & typeof unreactiveApplication;
1240
+ declare function cleanedBy<T extends object>(obj: T, cleanupFn: ScopedCallback): T & {
1241
+ [cleanup]: ScopedCallback;
1242
+ };
1243
+ /**
1244
+ * Creates a derived value that automatically recomputes when dependencies change
1245
+ * @param compute - Function that computes the derived value
1246
+ * @returns Object with value and cleanup function
1247
+ */
1248
+ declare function derived<T>(compute: (dep: DependencyAccess) => T): {
1249
+ value: T;
1250
+ [cleanup]: ScopedCallback;
1251
+ };
1252
+
1253
+ type Memoizable = object | any[] | symbol | ((...args: any[]) => any);
1254
+ declare function memoizeFunction<Result, Args extends Memoizable[]>(fn: (...args: Args) => Result): (...args: Args) => Result;
1255
+ declare const memoize: LegacyPropertyDecorator<any> & ModernMethodDecorator<any> & ModernGetterDecorator<any> & ModernAccessorDecorator<any> & typeof memoizeFunction;
1256
+
1257
+ declare const immutables: Set<(tested: any) => boolean>;
1258
+ declare function isNonReactive(obj: any): boolean;
1259
+ declare function registerNativeReactivity(originalClass: new (...args: any[]) => any, reactiveClass: new (...args: any[]) => any): void;
1260
+
1261
+ type KeyFunction<T, K extends PropertyKey> = (item: T) => K;
1262
+ interface RegisterInstance<T> extends ArrayReadForward<T> {
1263
+ [index: number]: T;
1264
+ }
1265
+ declare const RegisterClass_base: new () => ArrayReadForward<any> & {
1266
+ [x: number]: any;
1267
+ toArray(): any[];
1268
+ };
1269
+ declare class RegisterClass<T, K extends PropertyKey = PropertyKey> extends RegisterClass_base implements RegisterInstance<T> {
1270
+ #private;
1271
+ protected get [forwardArray](): readonly T[];
1272
+ constructor(keyFn: KeyFunction<T, K>, initial?: Iterable<T>);
1273
+ private ensureKey;
1274
+ private assertValidKey;
1275
+ private setKeyValue;
1276
+ private cleanupValue;
1277
+ private disposeKeyEffects;
1278
+ private incrementUsage;
1279
+ private decrementUsage;
1280
+ private normalizeIndex;
1281
+ private assignAt;
1282
+ private insertKeyValue;
1283
+ private rebuildFrom;
1284
+ get length(): number;
1285
+ [getAt](index: number): T | undefined;
1286
+ [setAt](index: number, value: T): void;
1287
+ push(...items: T[]): number;
1288
+ pop(): T | undefined;
1289
+ shift(): T | undefined;
1290
+ unshift(...items: T[]): number;
1291
+ splice(start: number, deleteCount?: number, ...items: T[]): T[];
1292
+ clear(): void;
1293
+ get(key: K): T | undefined;
1294
+ set(key: K, value: T): void;
1295
+ remove(key: K): void;
1296
+ removeAt(index: number): T | undefined;
1297
+ /**
1298
+ * Keep only the items for which the predicate returns true.
1299
+ * Items for which the predicate returns false are removed.
1300
+ *
1301
+ * The predicate is evaluated once per distinct key; duplicate keys
1302
+ * will follow the same keep/remove decision.
1303
+ */
1304
+ keep(predicate: (value: T) => boolean): void;
1305
+ hasKey(key: K): boolean;
1306
+ indexOfKey(key: K): number;
1307
+ mapKeys(): IterableIterator<K>;
1308
+ update(...values: T[]): void;
1309
+ upsert(insert: (value: T) => void, ...values: T[]): void;
1310
+ entries(): IterableIterator<[number, T]>;
1311
+ [Symbol.iterator](): IterableIterator<T>;
1312
+ toString(): string;
1313
+ at(index: number): T | undefined;
1314
+ reverse(): this;
1315
+ sort(compareFn?: ((a: T, b: T) => number) | undefined): this;
1316
+ fill(value: T, start?: number, end?: number): this;
1317
+ copyWithin(target: number, start: number, end?: number): this;
1318
+ }
1319
+ type Register<T, K extends PropertyKey = PropertyKey> = RegisterClass<T, K> & T[];
1320
+ declare const Register: new <T, K extends PropertyKey = PropertyKey>(keyFn: KeyFunction<T, K>, initial?: Iterable<T>) => Register<T, K>;
1321
+ declare function register<T, K extends PropertyKey = PropertyKey>(keyFn: KeyFunction<T, K>, initial?: Iterable<T>): Register<T, K>;
1322
+
1323
+ /**
1324
+ * Returns the projection context of the currently running effect, if any.
1325
+ */
1326
+ declare function getActiveProjection(): ProjectionContext | undefined;
1327
+ type ProjectOldValue<Target> = Target extends readonly (infer Item)[] ? Item : Target extends Map<any, infer Item> ? Item : Target extends Record<PropertyKey, infer Item> ? Item : unknown;
1328
+ type ProjectAccess<SourceValue, Key, SourceType, Target> = {
1329
+ readonly key: Key;
1330
+ get(): SourceValue;
1331
+ set(value: SourceValue): boolean;
1332
+ readonly source: SourceType;
1333
+ readonly old?: ProjectOldValue<Target>;
1334
+ value: SourceValue;
1335
+ };
1336
+ type ProjectCallback<SourceValue, Key, Target extends object, SourceType, Result> = (access: ProjectAccess<SourceValue, Key, SourceType, Target>, target: Target) => Result;
1337
+ type ProjectResult<Target extends object> = Target & {
1338
+ [cleanup]: ScopedCallback;
1339
+ };
1340
+ declare function projectArray<SourceValue, ResultValue>(source: readonly SourceValue[], apply: ProjectCallback<SourceValue, number, ResultValue[], readonly SourceValue[], ResultValue>): ProjectResult<ResultValue[]>;
1341
+ declare function projectRegister<Key extends PropertyKey, SourceValue, ResultValue>(source: Register<SourceValue, Key>, apply: ProjectCallback<SourceValue, Key, Map<Key, ResultValue>, Register<SourceValue, Key>, ResultValue>): ProjectResult<Map<Key, ResultValue>>;
1342
+ declare function projectRecord<Source extends Record<PropertyKey, any>, ResultValue>(source: Source, apply: ProjectCallback<Source[keyof Source], keyof Source, Record<keyof Source, ResultValue>, Source, ResultValue>): ProjectResult<Record<keyof Source, ResultValue>>;
1343
+ declare function projectMap<Key, Value, ResultValue>(source: Map<Key, Value>, apply: ProjectCallback<Value, Key, Map<Key, ResultValue>, Map<Key, Value>, ResultValue>): ProjectResult<Map<Key, ResultValue>>;
1344
+ type ProjectOverload = {
1345
+ <SourceValue, ResultValue>(source: readonly SourceValue[], apply: ProjectCallback<SourceValue, number, ResultValue[], readonly SourceValue[], ResultValue>): ProjectResult<ResultValue[]>;
1346
+ <Key extends PropertyKey, SourceValue, ResultValue>(source: Register<SourceValue, Key>, apply: ProjectCallback<SourceValue, Key, Map<Key, ResultValue>, Register<SourceValue, Key>, ResultValue>): ProjectResult<Map<Key, ResultValue>>;
1347
+ <Source extends Record<PropertyKey, any>, ResultValue>(source: Source, apply: ProjectCallback<Source[keyof Source], keyof Source, Record<keyof Source, ResultValue>, Source, ResultValue>): ProjectResult<Record<keyof Source, ResultValue>>;
1348
+ <Key, Value, ResultValue>(source: Map<Key, Value>, apply: ProjectCallback<Value, Key, Map<Key, ResultValue>, Map<Key, Value>, ResultValue>): ProjectResult<Map<Key, ResultValue>>;
1349
+ array: typeof projectArray;
1350
+ register: typeof projectRegister;
1351
+ record: typeof projectRecord;
1352
+ map: typeof projectMap;
1353
+ };
1354
+ declare const project: ProjectOverload;
1355
+
1356
+ declare function unwrap<T>(obj: T): T;
1357
+ declare function isReactive(obj: any): boolean;
1358
+
1359
+ /**
1360
+ * Base mixin for reactive classes that provides proper constructor reactivity
1361
+ * Solves constructor reactivity issues in complex inheritance trees
1362
+ */
1363
+ declare const ReactiveBase: (new (...args: any[]) => {
1364
+ [x: string]: any;
1365
+ }) & (<Base>(base: abstract new (...args: any[]) => Base) => new (...args: any[]) => {
1366
+ [x: string]: any;
1367
+ } & Base);
1368
+ declare function reactiveObject<T>(anyTarget: T): T;
1369
+ /**
1370
+ * Main decorator for making classes reactive
1371
+ * Automatically makes class instances reactive when created
1372
+ */
1373
+ declare const reactive: LegacyClassDecorator<new (...args: any[]) => any> & ModernClassDecorator<new (...args: any[]) => any> & typeof reactiveObject;
1374
+
1375
+ /**
1376
+ * Provides type-safe access to a source object's property within the organized callback.
1377
+ * @template Source - The type of the source object
1378
+ * @template Key - The type of the property key in the source object
1379
+ */
1380
+ type OrganizedAccess<Source extends Record<PropertyKey, any>, Key extends keyof Source> = {
1381
+ /** The property key being accessed */
1382
+ readonly key: Key;
1383
+ /**
1384
+ * Gets the current value of the property from the source object
1385
+ * @returns The current value of the property
1386
+ */
1387
+ get(): Source[Key];
1388
+ /**
1389
+ * Updates the property value in the source object
1390
+ * @param value - The new value to set
1391
+ * @returns {boolean} True if the update was successful
1392
+ */
1393
+ set(value: Source[Key]): boolean;
1394
+ /**
1395
+ * The current value of the property (equivalent to using get()/set() directly)
1396
+ */
1397
+ value: Source[Key];
1398
+ };
1399
+ /**
1400
+ * Callback function type for the organized function that processes each source property.
1401
+ * @template Source - The type of the source object
1402
+ * @template Target - The type of the target object
1403
+ */
1404
+ type OrganizedCallback<Source extends Record<PropertyKey, any>, Target extends object> = <Key extends keyof Source>(
1405
+ /**
1406
+ * Accessor object for the current source property
1407
+ */
1408
+ access: OrganizedAccess<Source, Key>,
1409
+ /**
1410
+ * The target object where organized data will be stored
1411
+ */
1412
+ target: Target) => ScopedCallback | undefined;
1413
+ /**
1414
+ * The result type of the organized function, combining the target object with cleanup capability.
1415
+ * @template Target - The type of the target object
1416
+ */
1417
+ type OrganizedResult<Target extends object> = Target & {
1418
+ /**
1419
+ * Cleanup function to dispose of all reactive bindings created by organized().
1420
+ * This is automatically called when the effect that created the organized binding is disposed.
1421
+ */
1422
+ [cleanup]: ScopedCallback;
1423
+ };
1424
+ /**
1425
+ * Organizes a source object's properties into a target object using a callback function.
1426
+ * This creates a reactive mapping between source properties and a target object,
1427
+ * automatically handling property additions, updates, and removals.
1428
+ *
1429
+ * @template Source - The type of the source object
1430
+ * @template Target - The type of the target object (defaults to Record<PropertyKey, any>)
1431
+ *
1432
+ * @param {Source} source - The source object to organize
1433
+ * @param {OrganizedCallback<Source, Target>} apply - Callback function that defines how each source property is mapped to the target
1434
+ * @param {Target} [baseTarget={}] - Optional base target object to use (will be made reactive if not already)
1435
+ *
1436
+ * @returns {OrganizedResult<Target>} The target object with cleanup capability
1437
+ *
1438
+ * @example
1439
+ * // Organize user permissions into role-based access
1440
+ * const user = reactive({ isAdmin: true, canEdit: false });
1441
+ * const permissions = organized(
1442
+ * user,
1443
+ * (access, target) => {
1444
+ * if (access.key === 'isAdmin') {
1445
+ * target.hasFullAccess = access.value;
1446
+ * }
1447
+ * target[`can${access.key.charAt(0).toUpperCase() + access.key.slice(1)}`] = access.value;
1448
+ * }
1449
+ * );
1450
+ *
1451
+ * @example
1452
+ * // Transform object structure with cleanup
1453
+ * const source = reactive({ firstName: 'John', lastName: 'Doe' });
1454
+ * const formatted = organized(
1455
+ * source,
1456
+ * (access, target) => {
1457
+ * if (access.key === 'firstName' || access.key === 'lastName') {
1458
+ * target.fullName = `${source.firstName} ${source.lastName}`.trim();
1459
+ * }
1460
+ * }
1461
+ * );
1462
+ *
1463
+ * @example
1464
+ * // Using with cleanup in a component
1465
+ * effect(() => {
1466
+ * const data = fetchData();
1467
+ * const organizedData = organized(data, (access, target) => {
1468
+ * // Transform data
1469
+ * });
1470
+ *
1471
+ * // The cleanup will be called automatically when the effect is disposed
1472
+ * return () => organizedData[cleanup]();
1473
+ * });
1474
+ */
1475
+ declare function organized<Source extends Record<PropertyKey, any>, Target extends object = Record<PropertyKey, any>>(source: Source, apply: OrganizedCallback<Source, Target>, baseTarget?: Target): OrganizedResult<Target>;
1476
+ /**
1477
+ * Organizes a property on a target object
1478
+ * Shortcut for defineProperty/delete with touched signal
1479
+ * @param target - The target object
1480
+ * @param property - The property to organize
1481
+ * @param access - The access object
1482
+ * @returns The property descriptor
1483
+ */
1484
+ declare function organize<T>(target: object, property: PropertyKey, access: {
1485
+ get?(): T;
1486
+ set?(value: T): boolean;
1487
+ }): () => boolean;
1488
+
1489
+ /**
1490
+ * Result of a reactive scan, which is a reactive array of accumulated values
1491
+ * with an attached cleanup function.
1492
+ */
1493
+ type ScanResult<Output> = readonly Output[] & {
1494
+ [cleanup]: ScopedCallback;
1495
+ };
1496
+ /**
1497
+ * Perform a reactive scan over an array of items.
1498
+ *
1499
+ * This implementation is highly optimized for performance and fine-grained reactivity:
1500
+ * - **Incremental Updates**: Changes to an item only trigger re-computation from that
1501
+ * point onwards in the result chain.
1502
+ * - **Move Optimization**: If items are moved within the array, their accumulated
1503
+ * values are reused as long as their predecessor remains the same.
1504
+ * - **Duplicate Support**: Correctly handles multiple occurrences of the same object
1505
+ * instance using an internal occurrence tracking mechanism.
1506
+ * - **Memory Efficient**: Uses `WeakMap` for caching intermediates, which are
1507
+ * automatically cleared when source items are garbage collected.
1508
+ *
1509
+ * @example
1510
+ * ```typescript
1511
+ * const source = reactive([{ val: 1 }, { val: 2 }, { val: 3 }])
1512
+ * const sum = scan(source, (acc, item) => acc + item.val, 0)
1513
+ *
1514
+ * expect([...sum]).toEqual([1, 3, 6])
1515
+ *
1516
+ * // Modifying an item only re-computes subsequent sums
1517
+ * source[1].val = 10
1518
+ * expect([...sum]).toEqual([1, 11, 14])
1519
+ * ```
1520
+ *
1521
+ * @param source The source array of objects (will be made reactive)
1522
+ * @param callback The accumulator function called with (accumulator, currentItem)
1523
+ * @param initialValue The starting value for the accumulation
1524
+ * @returns A reactive array of accumulated values, with a [cleanup] property to stop the tracking
1525
+ */
1526
+ declare function scan<Input extends object, Output>(source: readonly Input[], callback: (acc: Output, val: Input) => Output, initialValue: Output): ScanResult<Output>;
1527
+ declare function resolve<Output>(cb: () => Output[]): Output[] & {
1528
+ [cleanup]: ScopedCallback;
1529
+ };
1530
+
1531
+ declare const effectAggregator: ZoneAggregator;
1532
+ declare function getActiveEffect(): ScopedCallback;
1533
+
1534
+ /**
1535
+ * Object containing internal reactive system state for debugging and profiling
1536
+ */
1537
+ declare const profileInfo: any;
1538
+
1539
+ /**
1540
+ * Decorator that caches the result of a getter method and only recomputes when dependencies change
1541
+ * Prevents circular dependencies and provides automatic cache invalidation
1542
+ */
1543
+ declare const cached: LegacyPropertyDecorator<any> & ModernGetterDecorator<any> & ModernAccessorDecorator<any>;
1544
+ /**
1545
+ * Checks if a property is cached (has a cached value)
1546
+ * @param object - The object to check
1547
+ * @param propertyKey - The property key to check
1548
+ * @returns True if the property has a cached value
1549
+ */
1550
+ declare function isCached(object: Object, propertyKey: PropertyKey): boolean;
1551
+ /**
1552
+ * Caches a value for a property on an object
1553
+ * @param object - The object to cache the value on
1554
+ * @param propertyKey - The property key to cache
1555
+ * @param value - The value to cache
1556
+ */
1557
+ declare function cache(object: Object, propertyKey: PropertyKey, value: any): void;
1558
+ /**
1559
+ * Creates a decorator that modifies property descriptors for specified properties
1560
+ * @param descriptor - The descriptor properties to apply
1561
+ * @returns A class decorator that applies the descriptor to specified properties
1562
+ */
1563
+ declare function describe(descriptor: {
1564
+ enumerable?: boolean;
1565
+ configurable?: boolean;
1566
+ writable?: boolean;
1567
+ }): <T>(...properties: (keyof T)[]) => GenericClassDecorator<T>;
1568
+ /**
1569
+ * Decorator that marks methods, properties, or classes as deprecated
1570
+ * Provides warning messages when deprecated items are used
1571
+ */
1572
+ 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>) & {
1573
+ warn: (target: any, propertyKey: PropertyKey, message?: string) => void;
1574
+ };
1575
+ /**
1576
+ * Creates a debounced method decorator that delays execution until after the delay period has passed
1577
+ * @param delay - The delay in milliseconds
1578
+ * @returns A method decorator that debounces method calls
1579
+ */
1580
+ declare function debounce(delay: number): LegacyPropertyDecorator<any> & ModernMethodDecorator<any>;
1581
+ /**
1582
+ * Creates a throttled method decorator that limits execution to once per delay period
1583
+ * @param delay - The delay in milliseconds
1584
+ * @returns A method decorator that throttles method calls
1585
+ */
1586
+ declare function throttle(delay: number): LegacyPropertyDecorator<any> & ModernMethodDecorator<any>;
1587
+
1588
+ type ElementTypes<T extends readonly unknown[]> = {
1589
+ [K in keyof T]: T[K] extends readonly (infer U)[] ? U : T[K];
1590
+ };
1591
+ /**
1592
+ * Combines multiple arrays into an array of tuples, stopping at the shortest array length
1593
+ * @param args - Arrays to zip together
1594
+ * @returns Array of tuples containing elements from each input array
1595
+ */
1596
+ declare function zip<T extends (readonly unknown[])[]>(...args: T): ElementTypes<T>[];
1597
+ /**
1598
+ * Checks if two arrays are strictly equal (shallow comparison)
1599
+ * @param a - First value
1600
+ * @param b - Second value
1601
+ * @returns True if arrays are equal or values are strictly equal
1602
+ */
1603
+ declare function arrayEquals(a: any, b: any): boolean;
1604
+ /**
1605
+ * Checks if a function is a constructor (class or constructor function)
1606
+ * @param fn - The function to check
1607
+ * @returns True if the function is a constructor
1608
+ */
1609
+ declare function isConstructor(fn: Function): boolean;
1610
+ /**
1611
+ * Renames a function with a new name
1612
+ * @param fct - The function to rename
1613
+ * @param name - The new name for the function
1614
+ * @returns The function with the new name
1615
+ */
1616
+ declare function renamed<F extends Function>(fct: F, name: string): F;
1617
+ declare const FoolProof: {
1618
+ get(obj: any, prop: any, receiver: any): any;
1619
+ set(obj: any, prop: any, value: any, receiver: any): boolean;
1620
+ };
1621
+ declare function isOwnAccessor(obj: any, prop: any): boolean;
1622
+ /**
1623
+ * Deeply compares two values.
1624
+ * For objects, compares prototypes with === and then own properties recursively.
1625
+ * Uses a cache to handle circular references.
1626
+ * @param a - First value
1627
+ * @param b - Second value
1628
+ * @param cache - Map for circular reference protection (internal use)
1629
+ * @returns True if values are deeply equal
1630
+ */
1631
+ declare function deepCompare(a: any, b: any, cache?: Map<object, Set<object>>): boolean;
1632
+ declare function contentRef(container: object): any;
1633
+ declare function tag<T extends object>(name: string, obj: T): T;
1634
+ declare function named<T extends Function>(name: string, fn: T): T;
1635
+
1636
+ type Restorer = () => () => void;
1637
+ type Hook = () => Restorer;
1638
+ declare const asyncHooks: {
1639
+ addHook(_hook: Hook): () => void;
1640
+ /**
1641
+ * [Hack] Sanitize a promise (or value) to prevent context leaks.
1642
+ * Default: Identity function.
1643
+ * Browser: Uses Macrotask wrapping to break microtask chains.
1644
+ */
1645
+ sanitizePromise(p: any): any;
1646
+ };
1647
+ /**
1648
+ * Register a hook that will be called whenever an asynchronous operation is initiated.
1649
+ * The hook should return a restorer function which will be called just before the async callback runs.
1650
+ * That restorer should in turn return an undoer function which will be called just after the async callback finishes.
1651
+ */
1652
+ declare const asyncHook: (hook: Hook) => () => void;
1653
+
1654
+ export { AZone, ArrayReadForward, DecoratorError, Destroyable, DestructionError, Eventful, FoolProof, Indexable, IterableWeakMap, IterableWeakSet, ReactiveBase, ReactiveError, ReactiveErrorCode, Register, Zone, ZoneAggregator, ZoneHistory, addBatchCleanup, allocated, allocatedValues, arrayEquals, asyncHook, asyncHooks, asyncZone, atomic, biDi, buildReactivityGraph, cache, cached, callOnGC, chainPromise, cleanedBy, cleanup, contentRef, debounce, decorator, deepCompare, deepWatch, defer, deprecated, derived, describe, destructor, effect, effectAggregator, enableDevTools, forwardArray, getActivationLog, getActiveEffect, getActiveProjection, getAt, getState, immutables, isCached, isConstructor, isDevtoolsEnabled, isNonReactive, isOwnAccessor, isReactive, legacyDecorator, memoize, mixin, modernDecorator, named, organize, organized, profileInfo, project, reactive, options as reactiveOptions, register, registerEffectForDebug, registerNativeReactivity, registerObjectForDebug, renamed, resolve, root, scan, setAt, setEffectName, setObjectName, tag, throttle, touched, touched1, trackEffect, unreactive, untracked, unwrap, watch, zip };
1655
+ export type { ContextManager, Decorator, DecoratorDescription, DecoratorFactory, DependencyAccess, EventsBase, Evolution, FunctionWrapper, GenericClassDecorator, Hook, LegacyClassDecorator, LegacyPropertyDecorator, Memoizable, MixinClass, MixinFunction, ModernAccessorDecorator, ModernClassDecorator, ModernGetterDecorator, ModernMethodDecorator, ModernSetterDecorator, PromiseChain, ReactivityGraph, Restorer, ScanResult, ScopedCallback };