@thi.ng/interceptors 3.2.0 → 3.2.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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2022-12-16T12:52:25Z
3
+ - **Last updated**: 2022-12-20T16:33:11Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
package/event-bus.d.ts CHANGED
@@ -81,9 +81,8 @@ export declare class StatelessEventBus implements IDispatch {
81
81
  * Adds built-in event & side effect handlers.
82
82
  *
83
83
  * @remarks
84
- * Also see additional built-ins defined by the stateful
85
- * {@link EventBus} extension of this class, as well as comments for
86
- * these class methods:
84
+ * Also see additional built-ins defined by the stateful {@link EventBus}
85
+ * extension of this class, as well as comments for these class methods:
87
86
  *
88
87
  * - {@link StatelessEventBus.mergeEffects}
89
88
  * - {@link StatelessEventBus.processEvent}
@@ -96,8 +95,8 @@ export declare class StatelessEventBus implements IDispatch {
96
95
  *
97
96
  * #### `FX_CANCEL`
98
97
  *
99
- * If assigned `true`, cancels processing of current event, though
100
- * still applies any side effects already accumulated.
98
+ * If assigned `true`, cancels processing of current event, though still
99
+ * applies any side effects already accumulated.
101
100
  *
102
101
  * #### `FX_DISPATCH`
103
102
  *
@@ -109,8 +108,8 @@ export declare class StatelessEventBus implements IDispatch {
109
108
  *
110
109
  * #### `FX_DISPATCH_NOW`
111
110
  *
112
- * Dispatches assigned events as part of currently processed event
113
- * queue (no delay).
111
+ * Dispatches assigned events as part of currently processed event queue (no
112
+ * delay).
114
113
  *
115
114
  * #### `FX_DELAY`
116
115
  *
@@ -125,13 +124,13 @@ export declare class StatelessEventBus implements IDispatch {
125
124
  * #### `FX_FETCH`
126
125
  *
127
126
  * Async side effect. Only to be used in conjunction with
128
- * `FX_DISPATCH_ASYNC`. Performs `fetch()` HTTP request and triggers
129
- * success with received response, or if there was an error with
130
- * response's `statusText`. The error event is only triggered if the
131
- * fetched response's `ok` field is non-truthy.
127
+ * `FX_DISPATCH_ASYNC`. Performs `fetch()` HTTP request and triggers success
128
+ * with received response, or if there was an error with response's
129
+ * `statusText`. The error event is only triggered if the fetched response's
130
+ * `ok` field is non-truthy.
132
131
  *
133
- * - {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/ok}
134
- * - {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/statusText}
132
+ * - https://developer.mozilla.org/en-US/docs/Web/API/Response/ok
133
+ * - https://developer.mozilla.org/en-US/docs/Web/API/Response/statusText
135
134
  *
136
135
  * ```
137
136
  * // fetches "foo.json" and then dispatches EV_SUCCESS or EV_ERROR event
@@ -301,25 +300,25 @@ export declare class StatelessEventBus implements IDispatch {
301
300
  * Stateful version of {@link StatelessEventBus}.
302
301
  *
303
302
  * @remarks
304
- * Wraps an {@link @thi.ng/atom#IAtom} state container (i.e.
305
- * `Atom`/`Cursor`/`History`) and provides additional pre-defined event
306
- * handlers and side effects to manipulate wrapped state. Prefer this as
307
- * the default implementation for most use cases.
303
+ * Wraps an [`IAtom`](https://docs.thi.ng/umbrella/atom/interfaces/IAtom.html)
304
+ * state container (i.e. `Atom`/`Cursor`/`History`) and provides additional
305
+ * pre-defined event handlers and side effects to manipulate wrapped state.
306
+ * Prefer this as the default implementation for most use cases.
308
307
  */
309
308
  export declare class EventBus extends StatelessEventBus implements IDeref<any>, IDispatch {
310
309
  readonly state: IAtom<any>;
311
310
  /**
312
- * Creates a new event bus instance with given parent state, handler
313
- * and effect definitions (all optional).
311
+ * Creates a new event bus instance with given parent state, handler and
312
+ * effect definitions (all optional).
314
313
  *
315
314
  * @remarks
316
315
  * If no state is given, automatically creates an
317
- * {@link @thi.ng/atom#Atom} with empty state object.
316
+ * [`Atom`](https://docs.thi.ng/umbrella/atom/classes/Atom.html) with empty
317
+ * state object.
318
318
  *
319
319
  * In addition to the user provided handlers & effects, a number of
320
- * built-ins are added automatically. See
321
- * {@link EventBus.addBuiltIns}. User handlers can override
322
- * built-ins.
320
+ * built-ins are added automatically. See {@link EventBus.addBuiltIns}. User
321
+ * handlers can override built-ins.
323
322
  *
324
323
  * @param state -
325
324
  * @param handlers -
@@ -340,7 +339,7 @@ export declare class EventBus extends StatelessEventBus implements IDeref<any>,
340
339
  * #### `EV_SET_VALUE`
341
340
  *
342
341
  * Resets state path to provided value. See
343
- * {@link @thi.ng/paths#setIn}.
342
+ * [`setIn()`](https://docs.thi.ng/umbrella/paths/functions/setIn.html).
344
343
  *
345
344
  * Example event definition:
346
345
  * ```
@@ -349,8 +348,9 @@ export declare class EventBus extends StatelessEventBus implements IDeref<any>,
349
348
  *
350
349
  * #### `EV_UPDATE_VALUE`
351
350
  *
352
- * Updates a state path's value with provided function and optional
353
- * extra arguments. See {@link @thi.ng/paths#updateIn}.
351
+ * Updates a state path's value with provided function and optional extra
352
+ * arguments. See
353
+ * [`updateIn()`](https://docs.thi.ng/umbrella/paths/functions/updateIn.html).
354
354
  *
355
355
  * Example event definition:
356
356
  * ```
@@ -368,18 +368,19 @@ export declare class EventBus extends StatelessEventBus implements IDeref<any>,
368
368
  *
369
369
  * #### `EV_UNDO`
370
370
  *
371
- * Calls `ctx[id].undo()` and uses return value as new state.
372
- * Assumes `ctx[id]` is a {@link @thi.ng/atom#History} instance,
373
- * provided via e.g. `processQueue({ history })`. The event can be
374
- * triggered with or without ID. By default `"history"` is used as
375
- * default key to lookup the `History` instance. Furthermore, an
376
- * additional event can be triggered based on if a previous state
377
- * has been restored or not (basically, if the undo was successful).
378
- * This is useful for resetting/re-initializing stateful resources
379
- * after a successful undo action or to notify the user that no more
380
- * undo's are possible. The new event will be processed in the same
381
- * frame and has access to the (possibly) restored state. The event
382
- * structure for these options is shown below:
371
+ * Calls `ctx[id].undo()` and uses return value as new state. Assumes
372
+ * `ctx[id]` is a
373
+ * [`History`](https://docs.thi.ng/umbrella/atom/classes/History.html)
374
+ * instance, provided via e.g. `processQueue({ history })`. The event can be
375
+ * triggered with or without ID. By default `"history"` is used as default
376
+ * key to lookup the `History` instance. Furthermore, an additional event
377
+ * can be triggered based on if a previous state has been restored or not
378
+ * (basically, if the undo was successful). This is useful for
379
+ * resetting/re-initializing stateful resources after a successful undo
380
+ * action or to notify the user that no more undo's are possible. The new
381
+ * event will be processed in the same frame and has access to the
382
+ * (possibly) restored state. The event structure for these options is shown
383
+ * below:
383
384
  *
384
385
  * ```
385
386
  * // using default ID
@@ -400,26 +401,27 @@ export declare class EventBus extends StatelessEventBus implements IDeref<any>,
400
401
  *
401
402
  * #### `FX_STATE`
402
403
  *
403
- * Resets state atom to provided value (only a single update per
404
- * processing frame).
404
+ * Resets state atom to provided value (only a single update per processing
405
+ * frame).
405
406
  */
406
407
  addBuiltIns(): any;
407
408
  /**
408
- * Triggers processing of current event queue and returns `true` if
409
- * the any of the processed events caused a state change.
409
+ * Triggers processing of current event queue and returns `true` if the any
410
+ * of the processed events caused a state change.
410
411
  *
411
- * If an event handler triggers the `FX_DISPATCH_NOW` side effect,
412
- * the new event will be added to the currently processed batch and
413
- * therefore executed in the same frame. Also see {@link dispatchNow}.
412
+ * If an event handler triggers the `FX_DISPATCH_NOW` side effect, the new
413
+ * event will be added to the currently processed batch and therefore
414
+ * executed in the same frame. Also see {@link dispatchNow}.
414
415
  *
415
416
  * If the optional `ctx` arg is provided it will be merged into the
416
417
  * {@link InterceptorContext} object passed to each interceptor. Since the
417
- * merged object is also used to collect triggered side effects,
418
- * care must be taken that there're no key name clashes.
418
+ * merged object is also used to collect triggered side effects, care must
419
+ * be taken that there're no key name clashes.
419
420
  *
420
- * In order to use the built-in `EV_UNDO`, `EV_REDO` events, users
421
- * MUST provide a {@link @thi.ng/atom#History} (or compatible undo
422
- * history instance) via the `ctx` arg, e.g.
421
+ * In order to use the built-in `EV_UNDO`, `EV_REDO` events, users MUST
422
+ * provide a
423
+ * [`History`](https://docs.thi.ng/umbrella/atom/classes/History.html) (or
424
+ * compatible undo history instance) via the `ctx` arg, e.g.
423
425
  *
424
426
  * ```
425
427
  * bus.processQueue({ history });
package/event-bus.js CHANGED
@@ -92,9 +92,8 @@ export class StatelessEventBus {
92
92
  * Adds built-in event & side effect handlers.
93
93
  *
94
94
  * @remarks
95
- * Also see additional built-ins defined by the stateful
96
- * {@link EventBus} extension of this class, as well as comments for
97
- * these class methods:
95
+ * Also see additional built-ins defined by the stateful {@link EventBus}
96
+ * extension of this class, as well as comments for these class methods:
98
97
  *
99
98
  * - {@link StatelessEventBus.mergeEffects}
100
99
  * - {@link StatelessEventBus.processEvent}
@@ -107,8 +106,8 @@ export class StatelessEventBus {
107
106
  *
108
107
  * #### `FX_CANCEL`
109
108
  *
110
- * If assigned `true`, cancels processing of current event, though
111
- * still applies any side effects already accumulated.
109
+ * If assigned `true`, cancels processing of current event, though still
110
+ * applies any side effects already accumulated.
112
111
  *
113
112
  * #### `FX_DISPATCH`
114
113
  *
@@ -120,8 +119,8 @@ export class StatelessEventBus {
120
119
  *
121
120
  * #### `FX_DISPATCH_NOW`
122
121
  *
123
- * Dispatches assigned events as part of currently processed event
124
- * queue (no delay).
122
+ * Dispatches assigned events as part of currently processed event queue (no
123
+ * delay).
125
124
  *
126
125
  * #### `FX_DELAY`
127
126
  *
@@ -136,13 +135,13 @@ export class StatelessEventBus {
136
135
  * #### `FX_FETCH`
137
136
  *
138
137
  * Async side effect. Only to be used in conjunction with
139
- * `FX_DISPATCH_ASYNC`. Performs `fetch()` HTTP request and triggers
140
- * success with received response, or if there was an error with
141
- * response's `statusText`. The error event is only triggered if the
142
- * fetched response's `ok` field is non-truthy.
138
+ * `FX_DISPATCH_ASYNC`. Performs `fetch()` HTTP request and triggers success
139
+ * with received response, or if there was an error with response's
140
+ * `statusText`. The error event is only triggered if the fetched response's
141
+ * `ok` field is non-truthy.
143
142
  *
144
- * - {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/ok}
145
- * - {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/statusText}
143
+ * - https://developer.mozilla.org/en-US/docs/Web/API/Response/ok
144
+ * - https://developer.mozilla.org/en-US/docs/Web/API/Response/statusText
146
145
  *
147
146
  * ```
148
147
  * // fetches "foo.json" and then dispatches EV_SUCCESS or EV_ERROR event
@@ -521,24 +520,24 @@ export class StatelessEventBus {
521
520
  * Stateful version of {@link StatelessEventBus}.
522
521
  *
523
522
  * @remarks
524
- * Wraps an {@link @thi.ng/atom#IAtom} state container (i.e.
525
- * `Atom`/`Cursor`/`History`) and provides additional pre-defined event
526
- * handlers and side effects to manipulate wrapped state. Prefer this as
527
- * the default implementation for most use cases.
523
+ * Wraps an [`IAtom`](https://docs.thi.ng/umbrella/atom/interfaces/IAtom.html)
524
+ * state container (i.e. `Atom`/`Cursor`/`History`) and provides additional
525
+ * pre-defined event handlers and side effects to manipulate wrapped state.
526
+ * Prefer this as the default implementation for most use cases.
528
527
  */
529
528
  export class EventBus extends StatelessEventBus {
530
529
  /**
531
- * Creates a new event bus instance with given parent state, handler
532
- * and effect definitions (all optional).
530
+ * Creates a new event bus instance with given parent state, handler and
531
+ * effect definitions (all optional).
533
532
  *
534
533
  * @remarks
535
534
  * If no state is given, automatically creates an
536
- * {@link @thi.ng/atom#Atom} with empty state object.
535
+ * [`Atom`](https://docs.thi.ng/umbrella/atom/classes/Atom.html) with empty
536
+ * state object.
537
537
  *
538
538
  * In addition to the user provided handlers & effects, a number of
539
- * built-ins are added automatically. See
540
- * {@link EventBus.addBuiltIns}. User handlers can override
541
- * built-ins.
539
+ * built-ins are added automatically. See {@link EventBus.addBuiltIns}. User
540
+ * handlers can override built-ins.
542
541
  *
543
542
  * @param state -
544
543
  * @param handlers -
@@ -564,7 +563,7 @@ export class EventBus extends StatelessEventBus {
564
563
  * #### `EV_SET_VALUE`
565
564
  *
566
565
  * Resets state path to provided value. See
567
- * {@link @thi.ng/paths#setIn}.
566
+ * [`setIn()`](https://docs.thi.ng/umbrella/paths/functions/setIn.html).
568
567
  *
569
568
  * Example event definition:
570
569
  * ```
@@ -573,8 +572,9 @@ export class EventBus extends StatelessEventBus {
573
572
  *
574
573
  * #### `EV_UPDATE_VALUE`
575
574
  *
576
- * Updates a state path's value with provided function and optional
577
- * extra arguments. See {@link @thi.ng/paths#updateIn}.
575
+ * Updates a state path's value with provided function and optional extra
576
+ * arguments. See
577
+ * [`updateIn()`](https://docs.thi.ng/umbrella/paths/functions/updateIn.html).
578
578
  *
579
579
  * Example event definition:
580
580
  * ```
@@ -592,18 +592,19 @@ export class EventBus extends StatelessEventBus {
592
592
  *
593
593
  * #### `EV_UNDO`
594
594
  *
595
- * Calls `ctx[id].undo()` and uses return value as new state.
596
- * Assumes `ctx[id]` is a {@link @thi.ng/atom#History} instance,
597
- * provided via e.g. `processQueue({ history })`. The event can be
598
- * triggered with or without ID. By default `"history"` is used as
599
- * default key to lookup the `History` instance. Furthermore, an
600
- * additional event can be triggered based on if a previous state
601
- * has been restored or not (basically, if the undo was successful).
602
- * This is useful for resetting/re-initializing stateful resources
603
- * after a successful undo action or to notify the user that no more
604
- * undo's are possible. The new event will be processed in the same
605
- * frame and has access to the (possibly) restored state. The event
606
- * structure for these options is shown below:
595
+ * Calls `ctx[id].undo()` and uses return value as new state. Assumes
596
+ * `ctx[id]` is a
597
+ * [`History`](https://docs.thi.ng/umbrella/atom/classes/History.html)
598
+ * instance, provided via e.g. `processQueue({ history })`. The event can be
599
+ * triggered with or without ID. By default `"history"` is used as default
600
+ * key to lookup the `History` instance. Furthermore, an additional event
601
+ * can be triggered based on if a previous state has been restored or not
602
+ * (basically, if the undo was successful). This is useful for
603
+ * resetting/re-initializing stateful resources after a successful undo
604
+ * action or to notify the user that no more undo's are possible. The new
605
+ * event will be processed in the same frame and has access to the
606
+ * (possibly) restored state. The event structure for these options is shown
607
+ * below:
607
608
  *
608
609
  * ```
609
610
  * // using default ID
@@ -624,8 +625,8 @@ export class EventBus extends StatelessEventBus {
624
625
  *
625
626
  * #### `FX_STATE`
626
627
  *
627
- * Resets state atom to provided value (only a single update per
628
- * processing frame).
628
+ * Resets state atom to provided value (only a single update per processing
629
+ * frame).
629
630
  */
630
631
  addBuiltIns() {
631
632
  super.addBuiltIns();
@@ -649,21 +650,22 @@ export class EventBus extends StatelessEventBus {
649
650
  });
650
651
  }
651
652
  /**
652
- * Triggers processing of current event queue and returns `true` if
653
- * the any of the processed events caused a state change.
653
+ * Triggers processing of current event queue and returns `true` if the any
654
+ * of the processed events caused a state change.
654
655
  *
655
- * If an event handler triggers the `FX_DISPATCH_NOW` side effect,
656
- * the new event will be added to the currently processed batch and
657
- * therefore executed in the same frame. Also see {@link dispatchNow}.
656
+ * If an event handler triggers the `FX_DISPATCH_NOW` side effect, the new
657
+ * event will be added to the currently processed batch and therefore
658
+ * executed in the same frame. Also see {@link dispatchNow}.
658
659
  *
659
660
  * If the optional `ctx` arg is provided it will be merged into the
660
661
  * {@link InterceptorContext} object passed to each interceptor. Since the
661
- * merged object is also used to collect triggered side effects,
662
- * care must be taken that there're no key name clashes.
662
+ * merged object is also used to collect triggered side effects, care must
663
+ * be taken that there're no key name clashes.
663
664
  *
664
- * In order to use the built-in `EV_UNDO`, `EV_REDO` events, users
665
- * MUST provide a {@link @thi.ng/atom#History} (or compatible undo
666
- * history instance) via the `ctx` arg, e.g.
665
+ * In order to use the built-in `EV_UNDO`, `EV_REDO` events, users MUST
666
+ * provide a
667
+ * [`History`](https://docs.thi.ng/umbrella/atom/classes/History.html) (or
668
+ * compatible undo history instance) via the `ctx` arg, e.g.
667
669
  *
668
670
  * ```
669
671
  * bus.processQueue({ history });
package/interceptors.d.ts CHANGED
@@ -27,11 +27,11 @@ export declare const dispatch: (event: Event) => InterceptorFn;
27
27
  */
28
28
  export declare const dispatchNow: (event: Event) => InterceptorFn;
29
29
  /**
30
- * Higher-order interceptor. Returns interceptor which calls
31
- * `ctx[id].record()`, where `ctx` is the currently active
32
- * {@link InterceptorContext} passed to all event handlers and `ctx[id]`
33
- * is assumed to be a {@link @thi.ng/atom#History} instance, passed to
34
- * {@link EventBus.processQueue}. The default ID for the history
30
+ * Higher-order interceptor. Returns interceptor which calls `ctx[id].record()`,
31
+ * where `ctx` is the currently active {@link InterceptorContext} passed to all
32
+ * event handlers and `ctx[id]` is assumed to be a
33
+ * [`History`](https://docs.thi.ng/umbrella/atom/classes/History.html) instance,
34
+ * passed to {@link EventBus.processQueue}. The default ID for the history
35
35
  * instance is `"history"`.
36
36
  *
37
37
  * Example usage:
package/interceptors.js CHANGED
@@ -33,11 +33,11 @@ export const dispatchNow = (event) => () => ({
33
33
  [FX_DISPATCH_NOW]: event,
34
34
  });
35
35
  /**
36
- * Higher-order interceptor. Returns interceptor which calls
37
- * `ctx[id].record()`, where `ctx` is the currently active
38
- * {@link InterceptorContext} passed to all event handlers and `ctx[id]`
39
- * is assumed to be a {@link @thi.ng/atom#History} instance, passed to
40
- * {@link EventBus.processQueue}. The default ID for the history
36
+ * Higher-order interceptor. Returns interceptor which calls `ctx[id].record()`,
37
+ * where `ctx` is the currently active {@link InterceptorContext} passed to all
38
+ * event handlers and `ctx[id]` is assumed to be a
39
+ * [`History`](https://docs.thi.ng/umbrella/atom/classes/History.html) instance,
40
+ * passed to {@link EventBus.processQueue}. The default ID for the history
41
41
  * instance is `"history"`.
42
42
  *
43
43
  * Example usage:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/interceptors",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "description": "Interceptor based event bus, side effect & immutable state handling",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -37,12 +37,12 @@
37
37
  "test": "testament test"
38
38
  },
39
39
  "dependencies": {
40
- "@thi.ng/api": "^8.6.0",
41
- "@thi.ng/atom": "^5.1.25",
40
+ "@thi.ng/api": "^8.6.1",
41
+ "@thi.ng/atom": "^5.1.26",
42
42
  "@thi.ng/checks": "^3.3.5",
43
43
  "@thi.ng/errors": "^2.2.6",
44
44
  "@thi.ng/logger": "^1.4.5",
45
- "@thi.ng/paths": "^5.1.25"
45
+ "@thi.ng/paths": "^5.1.26"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@microsoft/api-extractor": "^7.33.7",
@@ -94,5 +94,5 @@
94
94
  "status": "completed",
95
95
  "year": 2016
96
96
  },
97
- "gitHead": "f445a9cc8022bcdebbf6ff91fd66ced016d72f01\n"
97
+ "gitHead": "7b2af448da8a63fb21704a79cc4cdf1f3d7d7a64\n"
98
98
  }