@ckeditor/ckeditor5-utils 48.2.0-alpha.7 → 48.3.0-alpha.0
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/abortabledebounce.d.ts +19 -13
- package/dist/areconnectedthroughproperties.d.ts +7 -7
- package/dist/ckeditorerror.d.ts +113 -113
- package/dist/collection.d.ts +419 -415
- package/dist/collectstylesheets.d.ts +9 -9
- package/dist/comparearrays.d.ts +25 -25
- package/dist/config.d.ts +159 -156
- package/dist/count.d.ts +14 -14
- package/dist/crc32.d.ts +19 -19
- package/dist/decodelicensekey.d.ts +7 -7
- package/dist/delay.d.ts +13 -13
- package/dist/diff.d.ts +32 -27
- package/dist/difftochanges.d.ts +47 -47
- package/dist/dom/createelement.d.ts +43 -43
- package/dist/dom/emittermixin.d.ts +144 -135
- package/dist/dom/findclosestscrollableancestor.d.ts +8 -8
- package/dist/dom/getancestors.d.ts +13 -13
- package/dist/dom/getborderwidths.d.ts +16 -16
- package/dist/dom/getcommonancestor.d.ts +9 -9
- package/dist/dom/getdatafromelement.d.ts +10 -10
- package/dist/dom/getpositionedancestor.d.ts +7 -7
- package/dist/dom/getrangefrommouseevent.d.ts +12 -12
- package/dist/dom/getvisualviewportoffset.d.ts +7 -7
- package/dist/dom/global.d.ts +24 -24
- package/dist/dom/indexof.d.ts +10 -10
- package/dist/dom/insertat.d.ts +11 -11
- package/dist/dom/iscomment.d.ts +7 -7
- package/dist/dom/isnode.d.ts +7 -7
- package/dist/dom/isrange.d.ts +7 -7
- package/dist/dom/istext.d.ts +7 -7
- package/dist/dom/isvalidattributename.d.ts +7 -7
- package/dist/dom/isvisible.d.ts +12 -12
- package/dist/dom/iswindow.d.ts +7 -7
- package/dist/dom/position.d.ts +200 -200
- package/dist/dom/rect.d.ts +194 -194
- package/dist/dom/remove.d.ts +9 -9
- package/dist/dom/resizeobserver.d.ts +70 -70
- package/dist/dom/scroll.d.ts +75 -72
- package/dist/dom/setdatainelement.d.ts +10 -10
- package/dist/dom/tounit.d.ts +16 -16
- package/dist/elementreplacer.d.ts +26 -26
- package/dist/emittermixin.d.ts +290 -280
- package/dist/env.d.ts +124 -124
- package/dist/eventinfo.d.ts +58 -55
- package/dist/fastdiff.d.ts +112 -109
- package/dist/first.d.ts +7 -7
- package/dist/focustracker.d.ts +133 -131
- package/dist/formathtml.d.ts +15 -15
- package/dist/index-content.css +1 -0
- package/dist/index-editor.css +1 -0
- package/dist/index.css +0 -2
- package/dist/index.d.ts +78 -77
- package/dist/index.js +5695 -6360
- package/dist/index.js.map +1 -1
- package/dist/inserttopriorityarray.d.ts +23 -23
- package/dist/isfeatureblockedbylicensekey.d.ts +10 -10
- package/dist/isiterable.d.ts +10 -10
- package/dist/keyboard.d.ts +107 -109
- package/dist/keystrokehandler.d.ts +90 -90
- package/dist/language.d.ts +12 -12
- package/dist/legacyerrors.d.ts +0 -4
- package/dist/locale.d.ts +122 -122
- package/dist/mapsequal.d.ts +11 -11
- package/dist/mix.d.ts +54 -53
- package/dist/nth.d.ts +12 -12
- package/dist/objecttomap.d.ts +18 -18
- package/dist/observablemixin.d.ts +621 -539
- package/dist/parsebase64encodedobject.d.ts +7 -7
- package/dist/parsedimensionwithunit.d.ts +40 -0
- package/dist/priorities.d.ts +24 -24
- package/dist/retry.d.ts +27 -27
- package/dist/splicearray.d.ts +22 -22
- package/dist/spy.d.ts +15 -15
- package/dist/toarray.d.ts +17 -17
- package/dist/tomap.d.ts +15 -15
- package/dist/translation-service.d.ts +157 -157
- package/dist/uid.d.ts +12 -12
- package/dist/unicode.d.ts +42 -42
- package/dist/version.d.ts +5 -5
- package/dist/wait.d.ts +11 -11
- package/package.json +2 -2
- package/dist/index.css.map +0 -1
package/dist/emittermixin.d.ts
CHANGED
|
@@ -1,312 +1,322 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { EventInfo } from
|
|
9
|
-
import { type PriorityString } from
|
|
10
|
-
import type { Constructor, Mixed } from
|
|
11
|
-
import
|
|
6
|
+
* @module utils/emittermixin
|
|
7
|
+
*/
|
|
8
|
+
import { EventInfo } from "./eventinfo.js";
|
|
9
|
+
import { type PriorityString } from "./priorities.js";
|
|
10
|
+
import type { Constructor, Mixed } from "./mix.js";
|
|
11
|
+
import "./version.js";
|
|
12
12
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*
|
|
25
|
-
* Read more about the concept of emitters in the:
|
|
26
|
-
* * {@glink framework/architecture/core-editor-architecture#event-system-and-observables Event system and observables}
|
|
27
|
-
* section of the {@glink framework/architecture/core-editor-architecture Core editor architecture} guide.
|
|
28
|
-
* * {@glink framework/deep-dive/event-system Event system} deep-dive guide.
|
|
29
|
-
*
|
|
30
|
-
* @label EXTENDS
|
|
31
|
-
*/
|
|
32
|
-
export declare function EmitterMixin<Base extends Constructor>(base: Base): Mixed<Base, Emitter>;
|
|
33
|
-
/**
|
|
34
|
-
* Mixin that injects the {@link ~Emitter events API} into its host.
|
|
35
|
-
*
|
|
36
|
-
* This function creates a class that implements `Emitter` interface.
|
|
37
|
-
*
|
|
38
|
-
* ```ts
|
|
39
|
-
* class MyClass extends EmitterMixin() {
|
|
40
|
-
* // This class implements the `Emitter` interface.
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* Read more about the concept of emitters in the:
|
|
45
|
-
* * {@glink framework/architecture/core-editor-architecture#event-system-and-observables Event system and observables}
|
|
46
|
-
* section of the {@glink framework/architecture/core-editor-architecture Core editor architecture} guide.
|
|
47
|
-
* * {@glink framework/deep-dive/event-system Event system} deep dive guide.
|
|
48
|
-
*
|
|
49
|
-
* @label NO_ARGUMENTS
|
|
50
|
-
*/
|
|
51
|
-
export declare function EmitterMixin(): {
|
|
52
|
-
new (): Emitter;
|
|
53
|
-
prototype: Emitter;
|
|
13
|
+
* Constructor returned by {@link ~EmitterMixin}. Use it to name a mixin base class before extending it.
|
|
14
|
+
*
|
|
15
|
+
* ```
|
|
16
|
+
* const MyEmitterBase: EmitterMixinConstructor<typeof BaseClass> = EmitterMixin( BaseClass );
|
|
17
|
+
*
|
|
18
|
+
* class MyEmitter extends MyEmitterBase {}
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export type EmitterMixinConstructor<Base extends Constructor | undefined = undefined> = Base extends Constructor ? Mixed<Base, Emitter> : {
|
|
22
|
+
new (): Emitter;
|
|
23
|
+
prototype: Emitter;
|
|
54
24
|
};
|
|
55
25
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
26
|
+
* Mixin that injects the {@link ~Emitter events API} into its host.
|
|
27
|
+
*
|
|
28
|
+
* This function creates a class that inherits from the provided `base` and implements `Emitter` interface.
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* class BaseClass { ... }
|
|
32
|
+
*
|
|
33
|
+
* class MyClass extends EmitterMixin( BaseClass ) {
|
|
34
|
+
* // This class derives from `BaseClass` and implements the `Emitter` interface.
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* Read more about the concept of emitters in the:
|
|
39
|
+
* * {@glink framework/architecture/core-editor-architecture#event-system-and-observables Event system and observables}
|
|
40
|
+
* section of the {@glink framework/architecture/core-editor-architecture Core editor architecture} guide.
|
|
41
|
+
* * {@glink framework/deep-dive/event-system Event system} deep-dive guide.
|
|
42
|
+
*
|
|
43
|
+
* @label EXTENDS
|
|
44
|
+
*/
|
|
45
|
+
export declare function EmitterMixin<Base extends Constructor>(base: Base): EmitterMixinConstructor<Base>;
|
|
46
|
+
/**
|
|
47
|
+
* Mixin that injects the {@link ~Emitter events API} into its host.
|
|
48
|
+
*
|
|
49
|
+
* This function creates a class that implements `Emitter` interface.
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* class MyClass extends EmitterMixin() {
|
|
53
|
+
* // This class implements the `Emitter` interface.
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* Read more about the concept of emitters in the:
|
|
58
|
+
* * {@glink framework/architecture/core-editor-architecture#event-system-and-observables Event system and observables}
|
|
59
|
+
* section of the {@glink framework/architecture/core-editor-architecture Core editor architecture} guide.
|
|
60
|
+
* * {@glink framework/deep-dive/event-system Event system} deep dive guide.
|
|
61
|
+
*
|
|
62
|
+
* @label NO_ARGUMENTS
|
|
63
|
+
*/
|
|
64
|
+
export declare function EmitterMixin(): EmitterMixinConstructor;
|
|
65
|
+
/**
|
|
66
|
+
* Emitter/listener interface.
|
|
67
|
+
*
|
|
68
|
+
* Can be easily implemented by a class by mixing the {@link module:utils/emittermixin~Emitter} mixin.
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* class MyClass extends EmitterMixin() {
|
|
72
|
+
* // This class now implements the `Emitter` interface.
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* Read more about the usage of this interface in the:
|
|
77
|
+
* * {@glink framework/architecture/core-editor-architecture#event-system-and-observables Event system and observables}
|
|
78
|
+
* section of the {@glink framework/architecture/core-editor-architecture Core editor architecture} guide.
|
|
79
|
+
* * {@glink framework/deep-dive/event-system Event system} deep-dive guide.
|
|
80
|
+
*/
|
|
71
81
|
export interface Emitter {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Registers a callback function to be executed when an event is fired.
|
|
84
|
+
*
|
|
85
|
+
* Shorthand for {@link #listenTo `this.listenTo( this, event, callback, options )`} (it makes the emitter
|
|
86
|
+
* listen on itself).
|
|
87
|
+
*
|
|
88
|
+
* @typeParam TEvent The type descibing the event. See {@link module:utils/emittermixin~BaseEvent}.
|
|
89
|
+
* @param event The name of the event.
|
|
90
|
+
* @param callback The function to be called on event.
|
|
91
|
+
* @param options Additional options.
|
|
92
|
+
*/
|
|
93
|
+
on<TEvent extends BaseEvent>(event: TEvent["name"], callback: GetCallback<TEvent>, options?: GetCallbackOptions<TEvent>): void;
|
|
94
|
+
/**
|
|
95
|
+
* Registers a callback function to be executed on the next time the event is fired only. This is similar to
|
|
96
|
+
* calling {@link #on} followed by {@link #off} in the callback.
|
|
97
|
+
*
|
|
98
|
+
* @typeParam TEvent The type descibing the event. See {@link module:utils/emittermixin~BaseEvent}.
|
|
99
|
+
* @param event The name of the event.
|
|
100
|
+
* @param callback The function to be called on event.
|
|
101
|
+
* @param options Additional options.
|
|
102
|
+
*/
|
|
103
|
+
once<TEvent extends BaseEvent>(event: TEvent["name"], callback: GetCallback<TEvent>, options?: GetCallbackOptions<TEvent>): void;
|
|
104
|
+
/**
|
|
105
|
+
* Stops executing the callback on the given event.
|
|
106
|
+
* Shorthand for {@link #stopListening `this.stopListening( this, event, callback )`}.
|
|
107
|
+
*
|
|
108
|
+
* @param event The name of the event.
|
|
109
|
+
* @param callback The function to stop being called.
|
|
110
|
+
*/
|
|
111
|
+
off(event: string, callback: Function): void;
|
|
112
|
+
/**
|
|
113
|
+
* Registers a callback function to be executed when an event is fired in a specific (emitter) object.
|
|
114
|
+
*
|
|
115
|
+
* Events can be grouped in namespaces using `:`.
|
|
116
|
+
* When namespaced event is fired, it additionally fires all callbacks for that namespace.
|
|
117
|
+
*
|
|
118
|
+
* ```ts
|
|
119
|
+
* // myEmitter.on( ... ) is a shorthand for myEmitter.listenTo( myEmitter, ... ).
|
|
120
|
+
* myEmitter.on( 'myGroup', genericCallback );
|
|
121
|
+
* myEmitter.on( 'myGroup:myEvent', specificCallback );
|
|
122
|
+
*
|
|
123
|
+
* // genericCallback is fired.
|
|
124
|
+
* myEmitter.fire( 'myGroup' );
|
|
125
|
+
* // both genericCallback and specificCallback are fired.
|
|
126
|
+
* myEmitter.fire( 'myGroup:myEvent' );
|
|
127
|
+
* // genericCallback is fired even though there are no callbacks for "foo".
|
|
128
|
+
* myEmitter.fire( 'myGroup:foo' );
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* An event callback can {@link module:utils/eventinfo~EventInfo#stop stop the event} and
|
|
132
|
+
* set the {@link module:utils/eventinfo~EventInfo#return return value} of the {@link #fire} method.
|
|
133
|
+
*
|
|
134
|
+
* @label BASE_EMITTER
|
|
135
|
+
* @typeParam TEvent The type describing the event. See {@link module:utils/emittermixin~BaseEvent}.
|
|
136
|
+
* @param emitter The object that fires the event.
|
|
137
|
+
* @param event The name of the event.
|
|
138
|
+
* @param callback The function to be called on event.
|
|
139
|
+
* @param options Additional options.
|
|
140
|
+
*/
|
|
141
|
+
listenTo<TEvent extends BaseEvent>(emitter: Emitter, event: TEvent["name"], callback: GetCallback<TEvent>, options?: GetCallbackOptions<TEvent>): void;
|
|
142
|
+
/**
|
|
143
|
+
* Stops listening for events. It can be used at different levels:
|
|
144
|
+
*
|
|
145
|
+
* * To stop listening to a specific callback.
|
|
146
|
+
* * To stop listening to a specific event.
|
|
147
|
+
* * To stop listening to all events fired by a specific object.
|
|
148
|
+
* * To stop listening to all events fired by all objects.
|
|
149
|
+
*
|
|
150
|
+
* @label BASE_STOP
|
|
151
|
+
* @param emitter The object to stop listening to. If omitted, stops it for all objects.
|
|
152
|
+
* @param event (Requires the `emitter`) The name of the event to stop listening to. If omitted, stops it
|
|
153
|
+
* for all events from `emitter`.
|
|
154
|
+
* @param callback (Requires the `event`) The function to be removed from the call list for the given
|
|
155
|
+
* `event`.
|
|
156
|
+
*/
|
|
157
|
+
stopListening(emitter?: Emitter, event?: string, callback?: Function): void;
|
|
158
|
+
/**
|
|
159
|
+
* Fires an event, executing all callbacks registered for it.
|
|
160
|
+
*
|
|
161
|
+
* The first parameter passed to callbacks is an {@link module:utils/eventinfo~EventInfo} object,
|
|
162
|
+
* followed by the optional `args` provided in the `fire()` method call.
|
|
163
|
+
*
|
|
164
|
+
* @typeParam TEvent The type describing the event. See {@link module:utils/emittermixin~BaseEvent}.
|
|
165
|
+
* @param eventOrInfo The name of the event or `EventInfo` object if event is delegated.
|
|
166
|
+
* @param args Additional arguments to be passed to the callbacks.
|
|
167
|
+
* @returns By default the method returns `undefined`. However, the return value can be changed by listeners
|
|
168
|
+
* through modification of the {@link module:utils/eventinfo~EventInfo#return `evt.return`}'s property (the event info
|
|
169
|
+
* is the first param of every callback).
|
|
170
|
+
*/
|
|
171
|
+
fire<TEvent extends BaseEvent>(eventOrInfo: GetNameOrEventInfo<TEvent>, ...args: TEvent["args"]): GetEventInfo<TEvent>["return"];
|
|
172
|
+
/**
|
|
173
|
+
* Delegates selected events to another {@link module:utils/emittermixin~Emitter}. For instance:
|
|
174
|
+
*
|
|
175
|
+
* ```ts
|
|
176
|
+
* emitterA.delegate( 'eventX' ).to( emitterB );
|
|
177
|
+
* emitterA.delegate( 'eventX', 'eventY' ).to( emitterC );
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* then `eventX` is delegated (fired by) `emitterB` and `emitterC` along with `data`:
|
|
181
|
+
*
|
|
182
|
+
* ```ts
|
|
183
|
+
* emitterA.fire( 'eventX', data );
|
|
184
|
+
* ```
|
|
185
|
+
*
|
|
186
|
+
* and `eventY` is delegated (fired by) `emitterC` along with `data`:
|
|
187
|
+
*
|
|
188
|
+
* ```ts
|
|
189
|
+
* emitterA.fire( 'eventY', data );
|
|
190
|
+
* ```
|
|
191
|
+
*
|
|
192
|
+
* @param events Event names that will be delegated to another emitter.
|
|
193
|
+
*/
|
|
194
|
+
delegate(...events: Array<string>): EmitterMixinDelegateChain;
|
|
195
|
+
/**
|
|
196
|
+
* Stops delegating events. It can be used at different levels:
|
|
197
|
+
*
|
|
198
|
+
* * To stop delegating all events.
|
|
199
|
+
* * To stop delegating a specific event to all emitters.
|
|
200
|
+
* * To stop delegating a specific event to a specific emitter.
|
|
201
|
+
*
|
|
202
|
+
* @param event The name of the event to stop delegating. If omitted, stops it all delegations.
|
|
203
|
+
* @param emitter (requires `event`) The object to stop delegating a particular event to.
|
|
204
|
+
* If omitted, stops delegation of `event` to all emitters.
|
|
205
|
+
*/
|
|
206
|
+
stopDelegating(event?: string, emitter?: Emitter): void;
|
|
197
207
|
}
|
|
198
208
|
/**
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
209
|
+
* Default type describing any event.
|
|
210
|
+
*
|
|
211
|
+
* Every custom event has to be compatible with `BaseEvent`.
|
|
212
|
+
*
|
|
213
|
+
* ```ts
|
|
214
|
+
* type MyEvent = {
|
|
215
|
+
* // In `fire<MyEvent>( name )`, `on<MyEvent>( name )`, `once<MyEvent>( name )` and `listenTo<MyEvent>( name )` calls
|
|
216
|
+
* // the `name` argument will be type-checked to ensure it's `'myEvent'` or have `'myEvent:'` prefix.
|
|
217
|
+
* // Required.
|
|
218
|
+
* name: 'myEvent' | `myEvent:${ string }`;
|
|
219
|
+
*
|
|
220
|
+
* // In `fire<MyEvent>( name, a, b )` call, `a` and `b` parameters will be type-checked against `number` and `string`.
|
|
221
|
+
* // In `on<MyEvent>`, `once<MyEvent>` and `listenTo<MyEvent>` calls, the parameters of provided callback function
|
|
222
|
+
* // will be automatically inferred as `EventInfo`, `number` and `string`.
|
|
223
|
+
* // Required.
|
|
224
|
+
* args: [ number, string ];
|
|
225
|
+
*
|
|
226
|
+
* // `fire<MyEvent>` will have return type `boolean | undefined`.
|
|
227
|
+
* // Optional, unknown by default.
|
|
228
|
+
* return: boolean;
|
|
229
|
+
*
|
|
230
|
+
* // `fire<MyEvent>( eventInfo )` will type-check that `eventInfo` is `MyEventInfo`, not a base `EventInfo` or string.
|
|
231
|
+
* // In `on<MyEvent>`, `once<MyEvent>` and `listenTo<MyEvent>` calls, the first callback parameter will be of this type.
|
|
232
|
+
* // Optional.
|
|
233
|
+
* eventInfo: MyEventInfo;
|
|
234
|
+
*
|
|
235
|
+
* // In `on<MyEvent>`, `once<MyEvent>` and `listenTo<MyEvent>` calls, the `options` parameter will be of type
|
|
236
|
+
* // `{ myOption?: boolean; priority?: PriorityString }
|
|
237
|
+
* // Optional.
|
|
238
|
+
* callbackOptions: { myOption?: boolean };
|
|
239
|
+
* };
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
232
242
|
export type BaseEvent = {
|
|
233
|
-
|
|
234
|
-
|
|
243
|
+
name: string;
|
|
244
|
+
args: Array<any>;
|
|
235
245
|
};
|
|
236
246
|
/**
|
|
237
|
-
|
|
238
|
-
|
|
247
|
+
* Utility type that gets the `EventInfo` subclass for the given event.
|
|
248
|
+
*/
|
|
239
249
|
export type GetEventInfo<TEvent extends BaseEvent> = TEvent extends {
|
|
240
|
-
|
|
241
|
-
} ? TEvent[
|
|
242
|
-
|
|
250
|
+
eventInfo: EventInfo;
|
|
251
|
+
} ? TEvent["eventInfo"] : EventInfo<TEvent["name"], (TEvent extends {
|
|
252
|
+
return: infer TReturn;
|
|
243
253
|
} ? TReturn : unknown)>;
|
|
244
254
|
/**
|
|
245
|
-
|
|
246
|
-
|
|
255
|
+
* Utility type that gets the `EventInfo` subclass or event name type for the given event.
|
|
256
|
+
*/
|
|
247
257
|
export type GetNameOrEventInfo<TEvent extends BaseEvent> = TEvent extends {
|
|
248
|
-
|
|
249
|
-
} ? TEvent[
|
|
250
|
-
|
|
258
|
+
eventInfo: EventInfo;
|
|
259
|
+
} ? TEvent["eventInfo"] : TEvent["name"] | EventInfo<TEvent["name"], (TEvent extends {
|
|
260
|
+
return: infer TReturn;
|
|
251
261
|
} ? TReturn : unknown)>;
|
|
252
262
|
/**
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
export type GetCallback<TEvent extends BaseEvent> = (this: Emitter, ev: GetEventInfo<TEvent>, ...args: TEvent[
|
|
263
|
+
* Utility type that gets the callback type for the given event.
|
|
264
|
+
*/
|
|
265
|
+
export type GetCallback<TEvent extends BaseEvent> = (this: Emitter, ev: GetEventInfo<TEvent>, ...args: TEvent["args"]) => void;
|
|
256
266
|
/**
|
|
257
|
-
|
|
258
|
-
|
|
267
|
+
* Utility type that gets the callback options for the given event.
|
|
268
|
+
*/
|
|
259
269
|
export type GetCallbackOptions<TEvent extends BaseEvent> = TEvent extends {
|
|
260
|
-
|
|
270
|
+
callbackOptions: infer TOptions;
|
|
261
271
|
} ? TOptions & CallbackOptions : CallbackOptions;
|
|
262
272
|
/**
|
|
263
|
-
|
|
264
|
-
|
|
273
|
+
* Additional options for registering a callback.
|
|
274
|
+
*/
|
|
265
275
|
export interface CallbackOptions {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
276
|
+
/**
|
|
277
|
+
* The priority of this event callback. The higher
|
|
278
|
+
* the priority value the sooner the callback will be fired. Events having the same priority are called in the
|
|
279
|
+
* order they were added.
|
|
280
|
+
*
|
|
281
|
+
* @defaultValue `'normal'`
|
|
282
|
+
*/
|
|
283
|
+
readonly priority?: PriorityString;
|
|
274
284
|
}
|
|
275
285
|
/**
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
286
|
+
* Checks if `listeningEmitter` listens to an emitter with given `listenedToEmitterId` and if so, returns that emitter.
|
|
287
|
+
* If not, returns `null`.
|
|
288
|
+
*
|
|
289
|
+
* @internal
|
|
290
|
+
* @param listeningEmitter An emitter that listens.
|
|
291
|
+
* @param listenedToEmitterId Unique emitter id of emitter listened to.
|
|
292
|
+
*/
|
|
283
293
|
export declare function _getEmitterListenedTo(listeningEmitter: Emitter, listenedToEmitterId: string): Emitter | null;
|
|
284
294
|
/**
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
295
|
+
* Sets emitter's unique id.
|
|
296
|
+
*
|
|
297
|
+
* **Note:** `_emitterId` can be set only once.
|
|
298
|
+
*
|
|
299
|
+
* @internal
|
|
300
|
+
* @param emitter An emitter for which id will be set.
|
|
301
|
+
* @param id Unique id to set. If not passed, random unique id will be set.
|
|
302
|
+
*/
|
|
293
303
|
export declare function _setEmitterId(emitter: Emitter, id?: string): void;
|
|
294
304
|
/**
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
305
|
+
* Returns emitter's unique id.
|
|
306
|
+
*
|
|
307
|
+
* @internal
|
|
308
|
+
* @param emitter An emitter which id will be returned.
|
|
309
|
+
*/
|
|
300
310
|
export declare function _getEmitterId(emitter: Emitter): string | undefined;
|
|
301
311
|
/**
|
|
302
|
-
|
|
303
|
-
|
|
312
|
+
* The return value of {@link ~Emitter#delegate}.
|
|
313
|
+
*/
|
|
304
314
|
export interface EmitterMixinDelegateChain {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
315
|
+
/**
|
|
316
|
+
* Selects destination for {@link module:utils/emittermixin~Emitter#delegate} events.
|
|
317
|
+
*
|
|
318
|
+
* @param emitter An `EmitterMixin` instance which is the destination for delegated events.
|
|
319
|
+
* @param nameOrFunction A custom event name or function which converts the original name string.
|
|
320
|
+
*/
|
|
321
|
+
to(emitter: Emitter, nameOrFunction?: string | ((name: string) => string)): void;
|
|
312
322
|
}
|