@but212/atom-effect 0.18.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/atom-effect.min.js +1 -1
- package/dist/atom-effect.min.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +16 -66
- package/dist/index.mjs +298 -285
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -54,13 +54,6 @@ export declare type Branded<T, Brand> = T & {
|
|
|
54
54
|
readonly __brand: Brand;
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
/**
|
|
58
|
-
* Computation context.
|
|
59
|
-
*/
|
|
60
|
-
export declare interface ComputationContext {
|
|
61
|
-
links: DependencyLink[];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
57
|
/**
|
|
65
58
|
* Creates a computed value.
|
|
66
59
|
* @param fn - Computation function
|
|
@@ -106,13 +99,14 @@ export declare interface ComputedOptions<T = unknown> {
|
|
|
106
99
|
lazy?: boolean;
|
|
107
100
|
/** Error handler. */
|
|
108
101
|
onError?: (error: Error) => void;
|
|
102
|
+
/** Maximum number of async retries before giving up (default: 3). */
|
|
103
|
+
maxAsyncRetries?: number;
|
|
109
104
|
}
|
|
110
105
|
|
|
111
106
|
/**
|
|
112
107
|
* Debugging thresholds.
|
|
113
108
|
*/
|
|
114
109
|
export declare const DEBUG_CONFIG: {
|
|
115
|
-
readonly MAX_DEPENDENCIES: 1000;
|
|
116
110
|
readonly WARN_INFINITE_LOOP: true;
|
|
117
111
|
};
|
|
118
112
|
|
|
@@ -123,7 +117,6 @@ export declare const DEBUG_RUNTIME: DebugConfig;
|
|
|
123
117
|
|
|
124
118
|
export declare interface DebugConfig {
|
|
125
119
|
enabled: boolean;
|
|
126
|
-
maxDependencies: number;
|
|
127
120
|
warnInfiniteLoop: boolean;
|
|
128
121
|
warn(condition: boolean, message: string): void;
|
|
129
122
|
checkCircular(dep: Dependency, current: object): void;
|
|
@@ -143,8 +136,6 @@ export declare interface Dependency {
|
|
|
143
136
|
flags: number;
|
|
144
137
|
/** Last validated epoch. */
|
|
145
138
|
_lastSeenEpoch: number;
|
|
146
|
-
/** Temporary unsubscribe. */
|
|
147
|
-
_tempUnsub?: (() => void) | undefined;
|
|
148
139
|
/** Last modified epoch. */
|
|
149
140
|
_modifiedAtEpoch?: number;
|
|
150
141
|
/**
|
|
@@ -158,30 +149,11 @@ export declare interface Dependency {
|
|
|
158
149
|
value?: unknown;
|
|
159
150
|
}
|
|
160
151
|
|
|
161
|
-
/**
|
|
162
|
-
* Graph entry.
|
|
163
|
-
*/
|
|
164
|
-
export declare interface DependencyEntry<T extends object = Dependency> {
|
|
165
|
-
/** Dependency reference. */
|
|
166
|
-
ref: WeakRef<T>;
|
|
167
|
-
unsubscribe: () => void;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
152
|
/**
|
|
171
153
|
* Dependency ID.
|
|
172
154
|
*/
|
|
173
155
|
export declare type DependencyId = Branded<number, 'DependencyId'>;
|
|
174
156
|
|
|
175
|
-
/**
|
|
176
|
-
* Dependency graph edge.
|
|
177
|
-
*/
|
|
178
|
-
declare class DependencyLink {
|
|
179
|
-
node: Dependency;
|
|
180
|
-
version: number;
|
|
181
|
-
unsub: (() => void) | undefined;
|
|
182
|
-
constructor(node: Dependency, version: number, unsub?: (() => void) | undefined);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
157
|
/**
|
|
186
158
|
* Creates and starts an effect.
|
|
187
159
|
*
|
|
@@ -196,11 +168,6 @@ export declare class EffectError extends AtomError {
|
|
|
196
168
|
constructor(message: string, cause?: Error | null);
|
|
197
169
|
}
|
|
198
170
|
|
|
199
|
-
export declare interface EffectExecutionContext {
|
|
200
|
-
prevLinks: DependencyLink[];
|
|
201
|
-
nextLinks: DependencyLink[];
|
|
202
|
-
}
|
|
203
|
-
|
|
204
171
|
/**
|
|
205
172
|
* Effect return type.
|
|
206
173
|
*/
|
|
@@ -221,16 +188,6 @@ export declare interface EffectOptions {
|
|
|
221
188
|
onError?: (error: unknown) => void;
|
|
222
189
|
}
|
|
223
190
|
|
|
224
|
-
/**
|
|
225
|
-
* Scheduler atom interface.
|
|
226
|
-
*/
|
|
227
|
-
export declare interface IAtom {
|
|
228
|
-
readonly id: number;
|
|
229
|
-
version: number;
|
|
230
|
-
_internalNotifySubscribers(): void;
|
|
231
|
-
recompute?(): void;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
191
|
/**
|
|
235
192
|
* Readonly atom check.
|
|
236
193
|
*
|
|
@@ -238,11 +195,6 @@ export declare interface IAtom {
|
|
|
238
195
|
*/
|
|
239
196
|
export declare function isAtom(obj: unknown): obj is ReadonlyAtom;
|
|
240
197
|
|
|
241
|
-
export declare interface IScheduler<T> {
|
|
242
|
-
markDirty(atom: T): void;
|
|
243
|
-
scheduleNotify(atom: T): void;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
198
|
/**
|
|
247
199
|
* Computed atom check.
|
|
248
200
|
*/
|
|
@@ -259,15 +211,9 @@ export declare function isEffect(obj: unknown): obj is EffectObject;
|
|
|
259
211
|
export declare const POOL_CONFIG: {
|
|
260
212
|
readonly MAX_SIZE: 1000;
|
|
261
213
|
readonly WARMUP_SIZE: 100;
|
|
214
|
+
readonly ENABLE_STATS: false;
|
|
262
215
|
};
|
|
263
216
|
|
|
264
|
-
/**
|
|
265
|
-
* Poolable interface.
|
|
266
|
-
*/
|
|
267
|
-
export declare interface Poolable {
|
|
268
|
-
reset(): void;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
217
|
export declare interface PoolStats {
|
|
272
218
|
acquired: number;
|
|
273
219
|
released: number;
|
|
@@ -301,7 +247,7 @@ export declare interface ReadonlyAtom<T = unknown> {
|
|
|
301
247
|
/**
|
|
302
248
|
* Scheduler implementation.
|
|
303
249
|
*/
|
|
304
|
-
|
|
250
|
+
declare class Scheduler {
|
|
305
251
|
/** Queue buffer */
|
|
306
252
|
_queueBuffer: [SchedulerJob[], SchedulerJob[]];
|
|
307
253
|
_bufferIndex: number;
|
|
@@ -318,9 +264,13 @@ export declare const scheduler: {
|
|
|
318
264
|
_batchQueueSize: number;
|
|
319
265
|
/** Config */
|
|
320
266
|
_maxFlushIterations: number;
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
267
|
+
/** Overflow callback */
|
|
268
|
+
onOverflow: ((droppedCount: number) => void) | null;
|
|
269
|
+
/** Bound run loop for microtask */
|
|
270
|
+
private readonly _boundRunLoop;
|
|
271
|
+
get phase(): SchedulerPhase;
|
|
272
|
+
get queueSize(): number;
|
|
273
|
+
get isBatching(): boolean;
|
|
324
274
|
/**
|
|
325
275
|
* Schedules job.
|
|
326
276
|
*/
|
|
@@ -332,16 +282,18 @@ export declare const scheduler: {
|
|
|
332
282
|
/**
|
|
333
283
|
* Scheduler loop.
|
|
334
284
|
*/
|
|
335
|
-
_runLoop
|
|
285
|
+
private _runLoop;
|
|
336
286
|
_flushSync(): void;
|
|
337
287
|
_mergeBatchQueue(): void;
|
|
338
288
|
_drainQueue(): void;
|
|
339
289
|
_processQueue(): void;
|
|
340
|
-
_handleFlushOverflow
|
|
290
|
+
private _handleFlushOverflow;
|
|
341
291
|
startBatch(): void;
|
|
342
292
|
endBatch(): void;
|
|
343
293
|
setMaxFlushIterations(max: number): void;
|
|
344
|
-
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export declare const scheduler: Scheduler;
|
|
345
297
|
|
|
346
298
|
/**
|
|
347
299
|
* Scheduler configuration.
|
|
@@ -377,8 +329,6 @@ export declare interface Subscriber {
|
|
|
377
329
|
execute(): void;
|
|
378
330
|
}
|
|
379
331
|
|
|
380
|
-
export declare type TransformFunction<T, U> = (value: T) => U;
|
|
381
|
-
|
|
382
332
|
/**
|
|
383
333
|
* Untracked execution.
|
|
384
334
|
*
|