@ckeditor/ckeditor5-utils 40.1.0 → 40.2.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/CHANGELOG.md +26 -26
- package/package.json +1 -1
- package/src/abortabledebounce.d.ts +17 -0
- package/src/abortabledebounce.js +22 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +3 -0
- package/src/retry.d.ts +33 -0
- package/src/retry.js +47 -0
- package/src/version.d.ts +1 -1
- package/src/version.js +4 -4
- package/src/wait.d.ts +16 -0
- package/src/wait.js +29 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,7 @@ All changes in the package are documented in the main repository. See: https://g
|
|
|
5
5
|
|
|
6
6
|
Changes for the past releases are available below.
|
|
7
7
|
|
|
8
|
-
## [19.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v18.0.0...v19.0.0) (2020
|
|
8
|
+
## [19.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v18.0.0...v19.0.0) (April 29, 2020)
|
|
9
9
|
|
|
10
10
|
### MINOR BREAKING CHANGES
|
|
11
11
|
|
|
@@ -35,12 +35,12 @@ Changes for the past releases are available below.
|
|
|
35
35
|
* The `getPositionedAncestor()` helper should use `offsetParent` instead of `getComputedStyle()` for performance reasons. Closes [ckeditor/ckeditor5#6573](https://github.com/ckeditor/ckeditor5/issues/6573). ([7939756](https://github.com/ckeditor/ckeditor5-utils/commit/7939756))
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
## [18.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v17.0.0...v18.0.0) (2020
|
|
38
|
+
## [18.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v17.0.0...v18.0.0) (March 19, 2020)
|
|
39
39
|
|
|
40
40
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
## [17.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v16.0.0...v17.0.0) (2020
|
|
43
|
+
## [17.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v16.0.0...v17.0.0) (February 19, 2020)
|
|
44
44
|
|
|
45
45
|
### MINOR BREAKING CHANGES
|
|
46
46
|
|
|
@@ -57,14 +57,14 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
57
57
|
* The `uid()` helper should be a lot faster. Closes [ckeditor/ckeditor5#6188](https://github.com/ckeditor/ckeditor5/issues/6188). ([b57fc3f](https://github.com/ckeditor/ckeditor5-utils/commit/b57fc3f))
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
## [16.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v15.0.0...v16.0.0) (2019
|
|
60
|
+
## [16.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v15.0.0...v16.0.0) (December 4, 2019)
|
|
61
61
|
|
|
62
62
|
### Bug fixes
|
|
63
63
|
|
|
64
64
|
* Improved error rethrowing by replacing the error stack. Closes [ckeditor/ckeditor5#5595](https://github.com/ckeditor/ckeditor5/issues/5595). ([7685c0d](https://github.com/ckeditor/ckeditor5-utils/commit/7685c0d))
|
|
65
65
|
|
|
66
66
|
|
|
67
|
-
## [15.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v14.0.0...v15.0.0) (2019
|
|
67
|
+
## [15.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v14.0.0...v15.0.0) (October 23, 2019)
|
|
68
68
|
|
|
69
69
|
### Features
|
|
70
70
|
|
|
@@ -83,7 +83,7 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
83
83
|
* Introduced the `CKEditorError.rethrowUnexpectedError()` helper. Added custom error handling for the `Emitter#fire()` function. Part of [ckeditor/ckeditor5#1304](https://github.com/ckeditor/ckeditor5/issues/1304). ([1d84705](https://github.com/ckeditor/ckeditor5-utils/commit/1d84705))
|
|
84
84
|
|
|
85
85
|
|
|
86
|
-
## [14.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v13.0.1...v14.0.0) (2019
|
|
86
|
+
## [14.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v13.0.1...v14.0.0) (August 26, 2019)
|
|
87
87
|
|
|
88
88
|
### Features
|
|
89
89
|
|
|
@@ -102,12 +102,12 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
102
102
|
* Removed the CKEditor 5 logger utility.
|
|
103
103
|
|
|
104
104
|
|
|
105
|
-
## [13.0.1](https://github.com/ckeditor/ckeditor5-utils/compare/v13.0.0...v13.0.1) (2019
|
|
105
|
+
## [13.0.1](https://github.com/ckeditor/ckeditor5-utils/compare/v13.0.0...v13.0.1) (July 10, 2019)
|
|
106
106
|
|
|
107
107
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
108
108
|
|
|
109
109
|
|
|
110
|
-
## [13.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v12.1.1...v13.0.0) (2019
|
|
110
|
+
## [13.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v12.1.1...v13.0.0) (July 4, 2019)
|
|
111
111
|
|
|
112
112
|
### Features
|
|
113
113
|
|
|
@@ -122,12 +122,12 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
122
122
|
* The list of `CKEditorError()`'s parameters was changed – now it requires the message, context and then data. The `isCKEditorError()` method was renamed to `is()`.
|
|
123
123
|
|
|
124
124
|
|
|
125
|
-
## [12.1.1](https://github.com/ckeditor/ckeditor5-utils/compare/v12.1.0...v12.1.1) (2019
|
|
125
|
+
## [12.1.1](https://github.com/ckeditor/ckeditor5-utils/compare/v12.1.0...v12.1.1) (June 6, 2019)
|
|
126
126
|
|
|
127
127
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
128
128
|
|
|
129
129
|
|
|
130
|
-
## [12.1.0](https://github.com/ckeditor/ckeditor5-utils/compare/v12.0.0...v12.1.0) (2019
|
|
130
|
+
## [12.1.0](https://github.com/ckeditor/ckeditor5-utils/compare/v12.0.0...v12.1.0) (April 4, 2019)
|
|
131
131
|
|
|
132
132
|
### Features
|
|
133
133
|
|
|
@@ -135,7 +135,7 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
135
135
|
* Made `FocusTracker#focusedElement` observable to bring support for multi-root editors (see [ckeditor/ckeditor5#1599](https://github.com/ckeditor/ckeditor5/issues/1599)). ([952d440](https://github.com/ckeditor/ckeditor5-utils/commit/952d440))
|
|
136
136
|
|
|
137
137
|
|
|
138
|
-
## [12.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v11.1.0...v12.0.0) (2019
|
|
138
|
+
## [12.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v11.1.0...v12.0.0) (February 28, 2019)
|
|
139
139
|
|
|
140
140
|
### Features
|
|
141
141
|
|
|
@@ -158,7 +158,7 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
158
158
|
* Upgraded minimal versions of Node to `8.0.0` and npm to `5.7.1`. See: [ckeditor/ckeditor5#1507](https://github.com/ckeditor/ckeditor5/issues/1507). ([612ea3c](https://github.com/ckeditor/ckeditor5-cloud-services/commit/612ea3c))
|
|
159
159
|
|
|
160
160
|
|
|
161
|
-
## [11.1.0](https://github.com/ckeditor/ckeditor5-utils/compare/v11.0.0...v11.1.0) (2018
|
|
161
|
+
## [11.1.0](https://github.com/ckeditor/ckeditor5-utils/compare/v11.0.0...v11.1.0) (December 5, 2018)
|
|
162
162
|
|
|
163
163
|
### Features
|
|
164
164
|
|
|
@@ -169,7 +169,7 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
169
169
|
* Various fixes in the API docs. Thanks to [@denisname](https://github.com/denisname)!
|
|
170
170
|
|
|
171
171
|
|
|
172
|
-
## [11.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v10.2.1...v11.0.0) (2018
|
|
172
|
+
## [11.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v10.2.1...v11.0.0) (October 8, 2018)
|
|
173
173
|
|
|
174
174
|
### Other changes
|
|
175
175
|
|
|
@@ -180,12 +180,12 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
180
180
|
* Removed the `lodash` library from this package (a modular `lodash` build has been kept under `src/lib/lodash/`). We now recommend using `lodash-es` directly.
|
|
181
181
|
|
|
182
182
|
|
|
183
|
-
## [10.2.1](https://github.com/ckeditor/ckeditor5-utils/compare/v10.2.0...v10.2.1) (2018
|
|
183
|
+
## [10.2.1](https://github.com/ckeditor/ckeditor5-utils/compare/v10.2.0...v10.2.1) (July 18, 2018)
|
|
184
184
|
|
|
185
185
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
186
186
|
|
|
187
187
|
|
|
188
|
-
## [10.2.0](https://github.com/ckeditor/ckeditor5-utils/compare/v10.1.0...v10.2.0) (2018
|
|
188
|
+
## [10.2.0](https://github.com/ckeditor/ckeditor5-utils/compare/v10.1.0...v10.2.0) (July 18, 2018)
|
|
189
189
|
|
|
190
190
|
### Features
|
|
191
191
|
|
|
@@ -197,7 +197,7 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
197
197
|
* The `isWindow()` helper should work in the Electron environment. Closes [ckeditor/ckeditor5#879](https://github.com/ckeditor/ckeditor5/issues/879). ([d561151](https://github.com/ckeditor/ckeditor5-utils/commit/d561151))
|
|
198
198
|
|
|
199
199
|
|
|
200
|
-
## [10.1.0](https://github.com/ckeditor/ckeditor5-utils/compare/v10.0.0...v10.1.0) (2018
|
|
200
|
+
## [10.1.0](https://github.com/ckeditor/ckeditor5-utils/compare/v10.0.0...v10.1.0) (June 21, 2018)
|
|
201
201
|
|
|
202
202
|
### Features
|
|
203
203
|
|
|
@@ -209,7 +209,7 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
209
209
|
* Error should not be thrown when scrolling the viewport from within an iframe in a different domain. Closes [ckeditor/ckeditor5#930](https://github.com/ckeditor/ckeditor5/issues/930). ([ad4656e](https://github.com/ckeditor/ckeditor5-utils/commit/ad4656e))
|
|
210
210
|
|
|
211
211
|
|
|
212
|
-
## [10.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v1.0.0-beta.4...v10.0.0) (2018
|
|
212
|
+
## [10.0.0](https://github.com/ckeditor/ckeditor5-utils/compare/v1.0.0-beta.4...v10.0.0) (April 25, 2018)
|
|
213
213
|
|
|
214
214
|
### Other changes
|
|
215
215
|
|
|
@@ -220,17 +220,17 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
220
220
|
* The license under which CKEditor 5 is released has been changed from a triple GPL, LGPL and MPL license to a GPL2+ only. See [ckeditor/ckeditor5#991](https://github.com/ckeditor/ckeditor5/issues/991) for more information.
|
|
221
221
|
|
|
222
222
|
|
|
223
|
-
## [1.0.0-beta.4](https://github.com/ckeditor/ckeditor5-utils/compare/v1.0.0-beta.2...v1.0.0-beta.4) (2018
|
|
223
|
+
## [1.0.0-beta.4](https://github.com/ckeditor/ckeditor5-utils/compare/v1.0.0-beta.2...v1.0.0-beta.4) (April 19, 2018)
|
|
224
224
|
|
|
225
225
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
226
226
|
|
|
227
227
|
|
|
228
|
-
## [1.0.0-beta.2](https://github.com/ckeditor/ckeditor5-utils/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2018
|
|
228
|
+
## [1.0.0-beta.2](https://github.com/ckeditor/ckeditor5-utils/compare/v1.0.0-beta.1...v1.0.0-beta.2) (April 10, 2018)
|
|
229
229
|
|
|
230
230
|
Internal changes only (updated dependencies, documentation, etc.).
|
|
231
231
|
|
|
232
232
|
|
|
233
|
-
## [1.0.0-beta.1](https://github.com/ckeditor/ckeditor5-utils/compare/v1.0.0-alpha.2...v1.0.0-beta.1) (2018
|
|
233
|
+
## [1.0.0-beta.1](https://github.com/ckeditor/ckeditor5-utils/compare/v1.0.0-alpha.2...v1.0.0-beta.1) (March 15, 2018)
|
|
234
234
|
|
|
235
235
|
### Features
|
|
236
236
|
|
|
@@ -260,14 +260,14 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
260
260
|
* `isDomNode()` was renamed to `isNode()`.
|
|
261
261
|
|
|
262
262
|
|
|
263
|
-
## [1.0.0-alpha.2](https://github.com/ckeditor/ckeditor5-utils/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2017
|
|
263
|
+
## [1.0.0-alpha.2](https://github.com/ckeditor/ckeditor5-utils/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (November 14, 2017)
|
|
264
264
|
|
|
265
265
|
### Bug fixes
|
|
266
266
|
|
|
267
267
|
* Removed a period at the end of an error message because some browsers included the period in links to errors. Closes [#193](https://github.com/ckeditor/ckeditor5-utils/issues/193). ([fdebc2f](https://github.com/ckeditor/ckeditor5-utils/commit/fdebc2f))
|
|
268
268
|
|
|
269
269
|
|
|
270
|
-
## [1.0.0-alpha.1](https://github.com/ckeditor/ckeditor5-utils/compare/v0.10.0...v1.0.0-alpha.1) (2017
|
|
270
|
+
## [1.0.0-alpha.1](https://github.com/ckeditor/ckeditor5-utils/compare/v0.10.0...v1.0.0-alpha.1) (October 3, 2017)
|
|
271
271
|
|
|
272
272
|
### Features
|
|
273
273
|
|
|
@@ -278,7 +278,7 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
278
278
|
* `CKEditorError#message`, `log.error()` and `log.warn()` will contain a link to the error documentation. Closes [#185](https://github.com/ckeditor/ckeditor5-utils/issues/185). ([b7a00c9](https://github.com/ckeditor/ckeditor5-utils/commit/b7a00c9))
|
|
279
279
|
|
|
280
280
|
|
|
281
|
-
## [0.10.0](https://github.com/ckeditor/ckeditor5-utils/compare/v0.9.1...v0.10.0) (2017
|
|
281
|
+
## [0.10.0](https://github.com/ckeditor/ckeditor5-utils/compare/v0.9.1...v0.10.0) (September 3, 2017)
|
|
282
282
|
|
|
283
283
|
### Bug fixes
|
|
284
284
|
|
|
@@ -296,7 +296,7 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
296
296
|
* The `getOptimalPosition()` utility should accept the target option defined as a function. Closes [#157](https://github.com/ckeditor/ckeditor5-utils/issues/157). ([d63abae](https://github.com/ckeditor/ckeditor5-utils/commit/d63abae))
|
|
297
297
|
|
|
298
298
|
|
|
299
|
-
## [0.9.1](https://github.com/ckeditor/ckeditor5-utils/compare/v0.9.0...v0.9.1) (2017
|
|
299
|
+
## [0.9.1](https://github.com/ckeditor/ckeditor5-utils/compare/v0.9.0...v0.9.1) (May 7, 2017)
|
|
300
300
|
|
|
301
301
|
### Bug fixes
|
|
302
302
|
|
|
@@ -304,7 +304,7 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
304
304
|
* The `getOptimalPosition()` utility should consider limiter ancestors with CSS overflow. Closes [#148](https://github.com/ckeditor/ckeditor5-utils/issues/148). ([6bf1741](https://github.com/ckeditor/ckeditor5-utils/commit/6bf1741))
|
|
305
305
|
|
|
306
306
|
|
|
307
|
-
## [0.9.0](https://github.com/ckeditor/ckeditor5-utils/compare/v0.8.0...v0.9.0) (2017
|
|
307
|
+
## [0.9.0](https://github.com/ckeditor/ckeditor5-utils/compare/v0.8.0...v0.9.0) (April 5, 2017)
|
|
308
308
|
|
|
309
309
|
### Bug fixes
|
|
310
310
|
|
|
@@ -317,7 +317,7 @@ Internal changes only (updated dependencies, documentation, etc.).
|
|
|
317
317
|
* Two–way data binding between `Collection` instances. Closes [#132](https://github.com/ckeditor/ckeditor5-utils/issues/132). ([6b79624](https://github.com/ckeditor/ckeditor5-utils/commit/6b79624))
|
|
318
318
|
|
|
319
319
|
|
|
320
|
-
## [0.8.0](https://github.com/ckeditor/ckeditor5-utils/compare/v0.7.0...v0.8.0) (2017
|
|
320
|
+
## [0.8.0](https://github.com/ckeditor/ckeditor5-utils/compare/v0.7.0...v0.8.0) (March 6, 2017)
|
|
321
321
|
|
|
322
322
|
### Features
|
|
323
323
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module utils/abortabledebounce
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Returns a function wrapper that will execute the provided function and abort any previous call that is still in progress.
|
|
10
|
+
*
|
|
11
|
+
* @param func The function to be called. It will be provided with `AbortSignal` as the first parameter.
|
|
12
|
+
*/
|
|
13
|
+
export default function abortableDebounce<Args extends Array<any>, Ret>(func: (signal: AbortSignal, ...args: Args) => Ret): AbortableFunc<Args, Ret>;
|
|
14
|
+
export interface AbortableFunc<Args extends Array<any>, Ret> {
|
|
15
|
+
(...args: Args): Ret;
|
|
16
|
+
abort(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module utils/abortabledebounce
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Returns a function wrapper that will execute the provided function and abort any previous call that is still in progress.
|
|
10
|
+
*
|
|
11
|
+
* @param func The function to be called. It will be provided with `AbortSignal` as the first parameter.
|
|
12
|
+
*/
|
|
13
|
+
export default function abortableDebounce(func) {
|
|
14
|
+
let controller = new AbortController();
|
|
15
|
+
function abortable(...args) {
|
|
16
|
+
controller.abort();
|
|
17
|
+
controller = new AbortController();
|
|
18
|
+
return func(controller.signal, ...args);
|
|
19
|
+
}
|
|
20
|
+
abortable.abort = () => controller.abort();
|
|
21
|
+
return abortable;
|
|
22
|
+
}
|
package/src/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { default as EventInfo } from './eventinfo';
|
|
|
16
16
|
export { default as ObservableMixin, type Observable, type DecoratedMethodEvent, type ObservableChangeEvent, type ObservableSetEvent } from './observablemixin';
|
|
17
17
|
export { default as CKEditorError, logError, logWarning } from './ckeditorerror';
|
|
18
18
|
export { default as ElementReplacer } from './elementreplacer';
|
|
19
|
+
export { default as abortableDebounce, type AbortableFunc } from './abortabledebounce';
|
|
19
20
|
export { default as count } from './count';
|
|
20
21
|
export { default as compareArrays } from './comparearrays';
|
|
21
22
|
export { default as createElement } from './dom/createelement';
|
|
@@ -52,10 +53,12 @@ export { default as KeystrokeHandler } from './keystrokehandler';
|
|
|
52
53
|
export { default as toArray, type ArrayOrItem, type ReadonlyArrayOrItem } from './toarray';
|
|
53
54
|
export { default as toMap } from './tomap';
|
|
54
55
|
export { default as priorities, type PriorityString } from './priorities';
|
|
56
|
+
export { default as retry, exponentialDelay } from './retry';
|
|
55
57
|
export { default as insertToPriorityArray } from './inserttopriorityarray';
|
|
56
58
|
export { default as spliceArray } from './splicearray';
|
|
57
59
|
export { default as uid } from './uid';
|
|
58
60
|
export { default as delay, type DelayedFunc } from './delay';
|
|
59
61
|
export { default as verifyLicense } from './verifylicense';
|
|
62
|
+
export { default as wait } from './wait';
|
|
60
63
|
export * from './unicode';
|
|
61
64
|
export { default as version, releaseDate } from './version';
|
package/src/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export { default as EventInfo } from './eventinfo';
|
|
|
15
15
|
export { default as ObservableMixin } from './observablemixin';
|
|
16
16
|
export { default as CKEditorError, logError, logWarning } from './ckeditorerror';
|
|
17
17
|
export { default as ElementReplacer } from './elementreplacer';
|
|
18
|
+
export { default as abortableDebounce } from './abortabledebounce';
|
|
18
19
|
export { default as count } from './count';
|
|
19
20
|
export { default as compareArrays } from './comparearrays';
|
|
20
21
|
export { default as createElement } from './dom/createelement';
|
|
@@ -51,10 +52,12 @@ export { default as KeystrokeHandler } from './keystrokehandler';
|
|
|
51
52
|
export { default as toArray } from './toarray';
|
|
52
53
|
export { default as toMap } from './tomap';
|
|
53
54
|
export { default as priorities } from './priorities';
|
|
55
|
+
export { default as retry, exponentialDelay } from './retry';
|
|
54
56
|
export { default as insertToPriorityArray } from './inserttopriorityarray';
|
|
55
57
|
export { default as spliceArray } from './splicearray';
|
|
56
58
|
export { default as uid } from './uid';
|
|
57
59
|
export { default as delay } from './delay';
|
|
58
60
|
export { default as verifyLicense } from './verifylicense';
|
|
61
|
+
export { default as wait } from './wait';
|
|
59
62
|
export * from './unicode';
|
|
60
63
|
export { default as version, releaseDate } from './version';
|
package/src/retry.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Tries calling the given callback until it sucessfully resolves.
|
|
7
|
+
*
|
|
8
|
+
* If the callback fails `maxRetries` times, the returned promise is rejected with the last error.
|
|
9
|
+
*
|
|
10
|
+
* @typeParam TResult The result of a successful callback invocation.
|
|
11
|
+
* @param callback The function to call until it succeeds.
|
|
12
|
+
* @param options.maxRetries Maximum number of retries.
|
|
13
|
+
* @param options.retryDelay The time in milliseconds between attempts. By default it implements exponential back-off policy.
|
|
14
|
+
* @param options.signal The signal to abort further retries. The callback itself is not aborted automatically.
|
|
15
|
+
*/
|
|
16
|
+
export default function retry<TResult>(callback: () => Promise<TResult>, options?: {
|
|
17
|
+
maxAttempts?: number;
|
|
18
|
+
retryDelay?: (attempt: number) => number;
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
}): Promise<TResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a function that calculates exponential back-off delay. Pass it as `options.retryDelay` to {@link ~retry}.
|
|
23
|
+
*
|
|
24
|
+
* @param options.delay Base delay between invocations. Defaults to 1s.
|
|
25
|
+
* @param options.factor How much to increase the delay. Defaults to 2x.
|
|
26
|
+
* @param options.maxDelay Maximum timeout. Even if higher timeout is calculated, it cannot get higher than this value. Default to 10s.
|
|
27
|
+
* @returns The function calculating the delay.
|
|
28
|
+
*/
|
|
29
|
+
export declare function exponentialDelay(options?: {
|
|
30
|
+
delay?: number;
|
|
31
|
+
factor?: number;
|
|
32
|
+
maxDelay?: number;
|
|
33
|
+
}): (attempt: number) => number;
|
package/src/retry.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module utils/retry
|
|
7
|
+
*/
|
|
8
|
+
import wait from './wait';
|
|
9
|
+
/**
|
|
10
|
+
* Tries calling the given callback until it sucessfully resolves.
|
|
11
|
+
*
|
|
12
|
+
* If the callback fails `maxRetries` times, the returned promise is rejected with the last error.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam TResult The result of a successful callback invocation.
|
|
15
|
+
* @param callback The function to call until it succeeds.
|
|
16
|
+
* @param options.maxRetries Maximum number of retries.
|
|
17
|
+
* @param options.retryDelay The time in milliseconds between attempts. By default it implements exponential back-off policy.
|
|
18
|
+
* @param options.signal The signal to abort further retries. The callback itself is not aborted automatically.
|
|
19
|
+
*/
|
|
20
|
+
export default async function retry(callback, options = {}) {
|
|
21
|
+
const { maxAttempts = 4, retryDelay = exponentialDelay(), signal = (new AbortController()).signal } = options;
|
|
22
|
+
signal.throwIfAborted();
|
|
23
|
+
for (let attempt = 0;; attempt++) {
|
|
24
|
+
try {
|
|
25
|
+
return await callback();
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
const isLast = attempt + 1 >= maxAttempts;
|
|
29
|
+
if (isLast) {
|
|
30
|
+
throw err;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
await wait(retryDelay(attempt), { signal });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates a function that calculates exponential back-off delay. Pass it as `options.retryDelay` to {@link ~retry}.
|
|
38
|
+
*
|
|
39
|
+
* @param options.delay Base delay between invocations. Defaults to 1s.
|
|
40
|
+
* @param options.factor How much to increase the delay. Defaults to 2x.
|
|
41
|
+
* @param options.maxDelay Maximum timeout. Even if higher timeout is calculated, it cannot get higher than this value. Default to 10s.
|
|
42
|
+
* @returns The function calculating the delay.
|
|
43
|
+
*/
|
|
44
|
+
export function exponentialDelay(options = {}) {
|
|
45
|
+
const { delay = 1000, factor = 2, maxDelay = 10000 } = options;
|
|
46
|
+
return attempt => Math.min(factor ** attempt * delay, maxDelay);
|
|
47
|
+
}
|
package/src/version.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
declare const version = "40.
|
|
5
|
+
declare const version = "40.2.0";
|
|
6
6
|
export default version;
|
|
7
7
|
export declare const releaseDate: Date;
|
|
8
8
|
declare global {
|
package/src/version.js
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* @module utils/version
|
|
7
7
|
*/
|
|
8
8
|
import CKEditorError from './ckeditorerror';
|
|
9
|
-
const version = '40.
|
|
9
|
+
const version = '40.2.0';
|
|
10
10
|
export default version;
|
|
11
11
|
// The second argument is not a month. It is `monthIndex` and starts from `0`.
|
|
12
|
-
export const releaseDate = new Date(2023,
|
|
12
|
+
export const releaseDate = new Date(2023, 11, 12);
|
|
13
13
|
/* istanbul ignore next -- @preserve */
|
|
14
14
|
if (globalThis.CKEDITOR_VERSION) {
|
|
15
15
|
/**
|
|
@@ -35,7 +35,7 @@ if (globalThis.CKEDITOR_VERSION) {
|
|
|
35
35
|
* that it contains all the necessary code from e.g. `@ckeditor/ckeditor5-engine` and `@ckeditor/ckeditor5-utils`.
|
|
36
36
|
*
|
|
37
37
|
* However, the `Highlight` plugin imports some of the modules from these packages, too. If you ask webpack to
|
|
38
|
-
* build such a project, you will end up with the modules being included (and run) twice &
|
|
38
|
+
* build such a project, you will end up with the modules being included (and run) twice – first, because they are
|
|
39
39
|
* included inside the build package, and second, because they are required by the `Highlight` plugin.
|
|
40
40
|
*
|
|
41
41
|
* Therefore, **you must never add plugins to an existing build** unless your plugin has no dependencies.
|
|
@@ -120,7 +120,7 @@ if (globalThis.CKEDITOR_VERSION) {
|
|
|
120
120
|
* asking the author of the third-party package to upgrade its depdendencies (or forking their project and doing this yourself).
|
|
121
121
|
*
|
|
122
122
|
* **Note:** All official CKEditor 5 packages (excluding integrations and `ckeditor5-dev-*` packages) are released in the
|
|
123
|
-
* same major version. This
|
|
123
|
+
* same major version. This means that in the `x.y.z` version, the `x` is the same for all packages. This is the simplest way to check
|
|
124
124
|
* whether you use packages coming from the same CKEditor 5 version. You can read more about versioning in the
|
|
125
125
|
* {@glink updating/versioning-policy Versioning policy} guide.
|
|
126
126
|
*
|
package/src/wait.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module utils/wait
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Returns a promise that is resolved after the specified time.
|
|
10
|
+
*
|
|
11
|
+
* @param timeout The time in milliseconds to wait.
|
|
12
|
+
* @param options.signal A signal to abort the waiting.
|
|
13
|
+
*/
|
|
14
|
+
export default function wait(timeout: number, options?: {
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
}): Promise<void>;
|
package/src/wait.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module utils/wait
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Returns a promise that is resolved after the specified time.
|
|
10
|
+
*
|
|
11
|
+
* @param timeout The time in milliseconds to wait.
|
|
12
|
+
* @param options.signal A signal to abort the waiting.
|
|
13
|
+
*/
|
|
14
|
+
export default function wait(timeout, options = {}) {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
const signal = options.signal || (new AbortController()).signal;
|
|
17
|
+
signal.throwIfAborted();
|
|
18
|
+
const timer = setTimeout(timeoutHandler, timeout);
|
|
19
|
+
signal.addEventListener('abort', abortHandler, { once: true });
|
|
20
|
+
function timeoutHandler() {
|
|
21
|
+
signal.removeEventListener('abort', abortHandler);
|
|
22
|
+
resolve();
|
|
23
|
+
}
|
|
24
|
+
function abortHandler() {
|
|
25
|
+
clearTimeout(timer);
|
|
26
|
+
reject(signal.reason);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|