uneventful 0.0.12 → 0.0.13
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/call-or-wait-CvOF0pao.mjs +22 -0
- package/dist/ext.d.ts +5 -4
- package/dist/ext.mjs +2 -2
- package/dist/hooks-BnMYHRlM.mjs +583 -0
- package/dist/{jobutils-Dvu-e99o.mjs → jobutils-O9tOTNKC.mjs} +116 -36
- package/dist/mod.d.ts +16 -54
- package/dist/mod.mjs +8 -8
- package/dist/shared.d.ts +87 -50
- package/dist/shared.mjs +51 -3
- package/dist/signals.d.ts +131 -19
- package/dist/signals.mjs +75 -530
- package/dist/{sinks-5TuxCRtX.d.ts → sinks-B_LfTZgF.d.ts} +1 -1
- package/dist/{types-N2ua11te.d.ts → types-pElgImr7.d.ts} +8 -57
- package/dist/{utils-cyEhnyp7.mjs → utils-BgqyDPjA.mjs} +33 -3
- package/dist/utils.d.ts +52 -7
- package/dist/utils.mjs +1 -1
- package/package.json +11 -12
- package/dist/call-or-wait-EzXJX5Dq.mjs +0 -111
package/dist/signals.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AnyFunction, O as OptionalCleanup, D as DisposeFn, L as SignalSource, Y as Yielding, S as Source, P as PlainFunction, a as Stream } from './types-
|
|
2
|
-
import { U as UntilMethod } from './sinks-
|
|
1
|
+
import { A as AnyFunction, O as OptionalCleanup, D as DisposeFn, L as SignalSource, Y as Yielding, S as Source, P as PlainFunction, a as Stream } from './types-pElgImr7.js';
|
|
2
|
+
import { U as UntilMethod } from './sinks-B_LfTZgF.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A decorator function that supports both TC39 and "legacy" decorator protocols
|
|
@@ -10,11 +10,11 @@ import { U as UntilMethod } from './sinks-5TuxCRtX.js';
|
|
|
10
10
|
* @category Types and Interfaces
|
|
11
11
|
*/
|
|
12
12
|
type GenericMethodDecorator<F extends AnyFunction> = {
|
|
13
|
-
/** TC39 Method Decorator
|
|
13
|
+
/** TC39 Method Decorator */
|
|
14
14
|
(fn: F, ctx?: {
|
|
15
15
|
kind: "method";
|
|
16
16
|
}): F;
|
|
17
|
-
/** Legacy Method Decorator
|
|
17
|
+
/** Legacy Method Decorator */
|
|
18
18
|
(proto: object, name: string | symbol, desc?: {
|
|
19
19
|
value?: F;
|
|
20
20
|
}): void;
|
|
@@ -130,20 +130,6 @@ interface RuleFactory {
|
|
|
130
130
|
*
|
|
131
131
|
*/
|
|
132
132
|
factory(scheduleFn: SchedulerFn): RuleFactory;
|
|
133
|
-
/**
|
|
134
|
-
* @deprecated Use {@link RuleFactory.root} instead
|
|
135
|
-
*
|
|
136
|
-
* ---
|
|
137
|
-
* Create a "detached" or standalone rule, that is not attached to any job.
|
|
138
|
-
*
|
|
139
|
-
* `r.detached(fn)` is shorthand for calling `detached.run(r, fn)`. (Where
|
|
140
|
-
* `r` is a {@link RuleFactory} such as `rule`.)
|
|
141
|
-
*
|
|
142
|
-
* Note that since the created rule isn't attached to a job, it *must* be
|
|
143
|
-
* explicitly stopped, either by calling the returned disposal function or
|
|
144
|
-
* by the rule function arranging to stop itself via {@link rule.stop}().
|
|
145
|
-
*/
|
|
146
|
-
detached(fn: () => OptionalCleanup): DisposeFn;
|
|
147
133
|
/**
|
|
148
134
|
* Create a standalone rule, not attached to the current job.
|
|
149
135
|
*
|
|
@@ -247,6 +233,132 @@ declare class WriteConflict extends Error {
|
|
|
247
233
|
declare class CircularDependency extends Error {
|
|
248
234
|
}
|
|
249
235
|
|
|
236
|
+
/** @inline */
|
|
237
|
+
type Get<V> = () => V;
|
|
238
|
+
/** @inline */
|
|
239
|
+
type GetFactory<O extends WeakKey, V = void> = (obj: O) => Get<V>;
|
|
240
|
+
/** @inline */
|
|
241
|
+
type Method<O extends WeakKey, V = void> = (this: O) => V;
|
|
242
|
+
/** @inline */
|
|
243
|
+
type DeferredFn = {
|
|
244
|
+
<Result>(compute: () => Result): Signal<Result>;
|
|
245
|
+
<Instance extends WeakKey, Result>(factory: GetFactory<Instance, Result>): (obj: Instance) => Result;
|
|
246
|
+
};
|
|
247
|
+
/** @inline */
|
|
248
|
+
type DeferredFx = {
|
|
249
|
+
(compute: () => void): Get<void>;
|
|
250
|
+
<Instance extends WeakKey>(factory: GetFactory<Instance, void>): (obj: Instance) => void;
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Create a signal that computes a value based on other signals. (Can also be
|
|
254
|
+
* used as a method decorator via `@fn`, with either TC39 or "Legacy"
|
|
255
|
+
* decorators.)
|
|
256
|
+
*
|
|
257
|
+
* @param compute The function that will be called to compute the result, if the
|
|
258
|
+
* signals it used in its last invocation have changed since then.
|
|
259
|
+
*
|
|
260
|
+
* @returns A signal that returns a cached value or recomputes it as necessary,
|
|
261
|
+
* and will be tracked as a dependency for other signals, rules, or effects,
|
|
262
|
+
* when they use it in their calculations.
|
|
263
|
+
*
|
|
264
|
+
* @template Result The type of value the created signal will provide.
|
|
265
|
+
*
|
|
266
|
+
* @category none
|
|
267
|
+
*/
|
|
268
|
+
declare function fn<Result>(compute: Get<Result>): Signal<Result>;
|
|
269
|
+
/**
|
|
270
|
+
* Create a parameterized reactive function that tracks separate dependencies
|
|
271
|
+
* and caching state for each object it's called on.
|
|
272
|
+
*
|
|
273
|
+
* @returns a one-argument reactive function that is shorthand for looking up
|
|
274
|
+
* and returning the value of a cached signal customized for the given argument.
|
|
275
|
+
*
|
|
276
|
+
* That is, given `rf = fn(a => () => a.bar)`, calling `rf(foo)` is equivalent
|
|
277
|
+
* to calling `fn(() => foo.bar)()`, except that each `foo` gets its own `fn(()
|
|
278
|
+
* => foo.bar)` signal cached, so that dependencies can be properly tracked
|
|
279
|
+
* per instance.
|
|
280
|
+
*
|
|
281
|
+
* @param factory A function that will be called with each new instance passed
|
|
282
|
+
* to the one-argument reactive function. It must return a zero-argument
|
|
283
|
+
* function, customized to compute the value for the instance it was given.
|
|
284
|
+
*
|
|
285
|
+
* @template Instance The type of object the created function will be used with
|
|
286
|
+
* @template Result The type of result the created function will return
|
|
287
|
+
*
|
|
288
|
+
*/
|
|
289
|
+
declare function fn<Instance extends WeakKey, Result>(factory: GetFactory<Instance, Result>): (obj: Instance) => Result;
|
|
290
|
+
/** @hidden support for ```fn``()``` */
|
|
291
|
+
declare function fn(t: TemplateStringsArray): DeferredFn;
|
|
292
|
+
/** @hidden TC39 decorator */
|
|
293
|
+
declare function fn<Instance extends WeakKey, Result>(f: Method<Instance, Result>, ctx: {
|
|
294
|
+
kind: "method";
|
|
295
|
+
}): Method<Instance, Result>;
|
|
296
|
+
/** @hidden "Legacy"/"TypeScript Experimental" Decorator */
|
|
297
|
+
declare function fn<Instance extends WeakKey, Result, D extends {
|
|
298
|
+
value?: Method<Instance, Result>;
|
|
299
|
+
}>(clsOrProto: any, name: string | symbol, desc: D): D;
|
|
300
|
+
/**
|
|
301
|
+
* Create a reactive effect (void signal) that runs when observed by a rule
|
|
302
|
+
* (directly or via other reactive functions). (Can also be used as a method
|
|
303
|
+
* decorator via `@fx`, with either TC39 or "Legacy" decorators.)
|
|
304
|
+
*
|
|
305
|
+
* @remarks Note that reactive effects do not actually execute unless they are
|
|
306
|
+
* "in use", i.e. either directly invoked from an active job or called
|
|
307
|
+
* indirectly from a rule or effect that is itself in use.
|
|
308
|
+
*
|
|
309
|
+
* @param effect The function that will be called to start (or restart) the
|
|
310
|
+
* effect, if the reactive values it used during its last run have changed since
|
|
311
|
+
* then.
|
|
312
|
+
*
|
|
313
|
+
* The effect function is run in a job that will restart if its dependencies
|
|
314
|
+
* change, and when the effect is no longer in use. (So you can use e.g.
|
|
315
|
+
* {@link must}() to define rollback actions, and any jobs, subscriptions, etc.
|
|
316
|
+
* you start inside the effect function will likewise be terminated when the
|
|
317
|
+
* effect becomes unobserved or its dependencies change.)
|
|
318
|
+
*
|
|
319
|
+
* @returns a zero-argument reactive function that can be called from any rule,
|
|
320
|
+
* job, or other observed reactive functions, to start or continue the effect.
|
|
321
|
+
*
|
|
322
|
+
* Multiple calls from the same or different observers do not restart the
|
|
323
|
+
* effect; only dependency changes will restart it. If it loses all observers
|
|
324
|
+
* (i.e. fails to be called by any of them, or all the calling jobs end), the
|
|
325
|
+
* effect will stop until it's in use again.
|
|
326
|
+
*
|
|
327
|
+
* @category none
|
|
328
|
+
*/
|
|
329
|
+
declare function fx(effect: Get<void>): Get<void>;
|
|
330
|
+
/**
|
|
331
|
+
* Create a parameterized reactive effect that tracks separate dependencies,
|
|
332
|
+
* jobs, and caching state for each object it's called on.
|
|
333
|
+
*
|
|
334
|
+
* @returns a one-argument reactive effect that is shorthand for looking up and
|
|
335
|
+
* calling a cached, zero-argument reactive effect customized for the given
|
|
336
|
+
* argument.
|
|
337
|
+
*
|
|
338
|
+
* That is, given `rx = fx(a => () => a.bar())`, calling `rx(foo)` is equivalent
|
|
339
|
+
* to calling `fx(() => foo.bar())()`, except that each `foo` gets its own
|
|
340
|
+
* `fx(() => foo.bar())` instance cached, so that dependencies can be properly
|
|
341
|
+
* tracked per instance.
|
|
342
|
+
*
|
|
343
|
+
* @param factory A function that will be called with each new instance passed
|
|
344
|
+
* to the returned effect function. It must return a zero-argument effect
|
|
345
|
+
* function, customized to apply the effect to the instance it was given.
|
|
346
|
+
*
|
|
347
|
+
* @template Instance The type of object the effect will be applied to
|
|
348
|
+
*
|
|
349
|
+
*/
|
|
350
|
+
declare function fx<Instance extends WeakKey>(factory: GetFactory<Instance>): (ob: Instance) => void;
|
|
351
|
+
/** @hidden support for ```fx``()``` */
|
|
352
|
+
declare function fx(t: TemplateStringsArray): DeferredFx;
|
|
353
|
+
/** @hidden TC39 decorator */
|
|
354
|
+
declare function fx<Instance extends WeakKey>(method: Method<Instance>, ctx: {
|
|
355
|
+
kind: "method";
|
|
356
|
+
}): Method<Instance>;
|
|
357
|
+
/** @hidden "Legacy"/"TypeScript Experimental" Decorator */
|
|
358
|
+
declare function fx<Instance extends WeakKey, D extends {
|
|
359
|
+
value?: Method<Instance>;
|
|
360
|
+
}>(clsOrProto: any, name: string | symbol, desc: D): D;
|
|
361
|
+
|
|
250
362
|
/**
|
|
251
363
|
* The Signals API for uneventful.
|
|
252
364
|
*
|
|
@@ -558,4 +670,4 @@ declare const stableJSON: <R extends any>(newVal: R) => R;
|
|
|
558
670
|
*/
|
|
559
671
|
declare function until<T>(source: UntilMethod<T> | Stream<T> | (() => T)): Yielding<T>;
|
|
560
672
|
|
|
561
|
-
export { CircularDependency, type Configurable, type GenericMethodDecorator, type RuleFactory, type SchedulerFn, type Signal, type Writable, WriteConflict, action, cached, peek, rule, runRules, stabilizer, stable, stableArray, stableJSON, unchangedIf, until, value };
|
|
673
|
+
export { CircularDependency, type Configurable, type GenericMethodDecorator, type RuleFactory, type SchedulerFn, type Signal, type Writable, WriteConflict, action, cached, fn, fx, peek, rule, runRules, stabilizer, stable, stableArray, stableJSON, unchangedIf, until, value };
|