@ckeditor/ckeditor5-watchdog 44.1.0-alpha.5 → 44.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-watchdog",
3
- "version": "44.1.0-alpha.5",
3
+ "version": "44.2.0-alpha.0",
4
4
  "description": "A watchdog feature for CKEditor 5 editors. It keeps a CKEditor 5 editor instance running.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,6 +12,10 @@
12
12
  "type": "module",
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
+ "@ckeditor/ckeditor5-core": "44.2.0-alpha.0",
16
+ "@ckeditor/ckeditor5-editor-multi-root": "44.2.0-alpha.0",
17
+ "@ckeditor/ckeditor5-engine": "44.2.0-alpha.0",
18
+ "@ckeditor/ckeditor5-utils": "44.2.0-alpha.0",
15
19
  "lodash-es": "4.17.21"
16
20
  },
17
21
  "author": "CKSource (http://cksource.com/)",
@@ -32,5 +36,24 @@
32
36
  "ckeditor5-metadata.json",
33
37
  "CHANGELOG.md"
34
38
  ],
35
- "types": "src/index.d.ts"
39
+ "types": "src/index.d.ts",
40
+ "exports": {
41
+ ".": {
42
+ "types": "./src/index.d.ts",
43
+ "import": "./src/index.js",
44
+ "default": "./src/index.js"
45
+ },
46
+ "./dist/*": {
47
+ "types": "./src/index.d.ts",
48
+ "import": "./dist/*",
49
+ "default": "./dist/*"
50
+ },
51
+ "./src/*": {
52
+ "types": "./src/*.d.ts",
53
+ "import": "./src/*",
54
+ "default": "./src/*"
55
+ },
56
+ "./ckeditor5-metadata.json": "./ckeditor5-metadata.json",
57
+ "./package.json": "./package.json"
58
+ }
36
59
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  import type { EditorData } from './editorwatchdog.js';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  export {};
@@ -1,14 +1,14 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
6
6
  * @module watchdog/contextwatchdog
7
7
  */
8
- import type { Context, Editor, EditorConfig, ContextConfig } from 'ckeditor5/src/core.js';
9
- import type { ArrayOrItem, CKEditorError } from 'ckeditor5/src/utils.js';
10
8
  import Watchdog, { type WatchdogConfig, type WatchdogState } from './watchdog.js';
11
9
  import EditorWatchdog, { type EditorCreatorFunction } from './editorwatchdog.js';
10
+ import type { ArrayOrItem, CKEditorError } from '@ckeditor/ckeditor5-utils';
11
+ import type { Context, Editor, EditorConfig, ContextConfig } from '@ckeditor/ckeditor5-core';
12
12
  /**
13
13
  * A watchdog for the {@link module:core/context~Context} class.
14
14
  *
@@ -1,7 +1,11 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
+ /**
6
+ * @module watchdog/contextwatchdog
7
+ */
8
+ /* globals console */
5
9
  import Watchdog from './watchdog.js';
6
10
  import EditorWatchdog from './editorwatchdog.js';
7
11
  import areConnectedThroughProperties from './utils/areconnectedthroughproperties.js';
@@ -1,13 +1,10 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
- /**
6
- * @module watchdog/editorwatchdog
7
- */
8
- import type { CKEditorError } from 'ckeditor5/src/utils.js';
9
- import type { Editor, EditorConfig, Context } from 'ckeditor5/src/core.js';
10
5
  import Watchdog, { type WatchdogConfig } from './watchdog.js';
6
+ import type { CKEditorError } from '@ckeditor/ckeditor5-utils';
7
+ import type { Editor, EditorConfig, Context } from '@ckeditor/ckeditor5-core';
11
8
  /**
12
9
  * A watchdog for CKEditor 5 editors.
13
10
  *
@@ -1,10 +1,14 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
+ /**
6
+ * @module watchdog/editorwatchdog
7
+ */
8
+ /* globals console */
9
+ import { throttle, cloneDeepWith, isElement } from 'lodash-es';
5
10
  import areConnectedThroughProperties from './utils/areconnectedthroughproperties.js';
6
11
  import Watchdog from './watchdog.js';
7
- import { throttle, cloneDeepWith, isElement } from 'lodash-es';
8
12
  /**
9
13
  * A watchdog for CKEditor 5 editors.
10
14
  *
package/src/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
package/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
package/src/watchdog.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
6
6
  * @module watchdog/watchdog
7
7
  */
8
- import type { CKEditorError } from 'ckeditor5/src/utils.js';
8
+ import type { CKEditorError } from '@ckeditor/ckeditor5-utils';
9
9
  import type { EditorWatchdogRestartEvent } from './editorwatchdog.js';
10
10
  import type { ContextWatchdogItemErrorEvent, ContextWatchdogItemRestartEvent } from './contextwatchdog.js';
11
11
  /**
package/src/watchdog.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  /**
@@ -1,19 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
8
- */
9
- import type { EditorData } from './editorwatchdog.js';
10
- declare module '@ckeditor/ckeditor5-core' {
11
- interface EditorConfig {
12
- /**
13
- * The temporary property that is used for passing data to the plugin which restores the editor state.
14
- *
15
- * @internal
16
- */
17
- _watchdogInitialData?: EditorData;
18
- }
19
- }
@@ -1,337 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, 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
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
8
- */
9
- /**
10
- * @module watchdog/contextwatchdog
11
- */
12
- import type { Context, Editor, EditorConfig, ContextConfig } from 'ckeditor5/src/core.js';
13
- import type { ArrayOrItem, CKEditorError } from 'ckeditor5/src/utils.js';
14
- import Watchdog, { type WatchdogConfig, type WatchdogState } from './watchdog.js';
15
- import EditorWatchdog, { type EditorCreatorFunction } from './editorwatchdog.js';
16
- /**
17
- * A watchdog for the {@link module:core/context~Context} class.
18
- *
19
- * See the {@glink features/watchdog Watchdog feature guide} to learn the rationale behind it and
20
- * how to use it.
21
- */
22
- export default class ContextWatchdog<TContext extends Context = Context> extends Watchdog {
23
- /**
24
- * A map of internal watchdogs for added items.
25
- */
26
- protected _watchdogs: Map<string, EditorWatchdog<Editor>>;
27
- /**
28
- * The watchdog configuration.
29
- */
30
- private readonly _watchdogConfig;
31
- /**
32
- * The current context instance.
33
- */
34
- private _context;
35
- /**
36
- * Context properties (nodes/references) that are gathered during the initial context creation
37
- * and are used to distinguish the origin of an error.
38
- */
39
- private _contextProps;
40
- /**
41
- * An action queue, which is used to handle async functions queuing.
42
- */
43
- private _actionQueues;
44
- /**
45
- * The configuration for the {@link module:core/context~Context}.
46
- */
47
- private _contextConfig?;
48
- /**
49
- * The creation method.
50
- *
51
- * @see #setCreator
52
- */
53
- protected _creator: (config: ContextConfig) => Promise<TContext>;
54
- /**
55
- * The destruction method.
56
- *
57
- * @see #setDestructor
58
- */
59
- protected _destructor: (context: Context) => Promise<unknown>;
60
- /**
61
- * The watched item.
62
- */
63
- _item: unknown;
64
- /**
65
- * The context watchdog class constructor.
66
- *
67
- * ```ts
68
- * const watchdog = new ContextWatchdog( Context );
69
- *
70
- * await watchdog.create( contextConfiguration );
71
- *
72
- * await watchdog.add( item );
73
- * ```
74
- *
75
- * See the {@glink features/watchdog Watchdog feature guide} to learn more how to use this feature.
76
- *
77
- * @param Context The {@link module:core/context~Context} class.
78
- * @param watchdogConfig The watchdog configuration.
79
- */
80
- constructor(Context: {
81
- create(...args: any): Promise<TContext>;
82
- }, watchdogConfig?: WatchdogConfig);
83
- /**
84
- * Sets the function that is responsible for the context creation.
85
- * It expects a function that should return a promise (or `undefined`).
86
- *
87
- * ```ts
88
- * watchdog.setCreator( config => Context.create( config ) );
89
- * ```
90
- */
91
- setCreator(creator: (config: ContextConfig) => Promise<TContext>): void;
92
- /**
93
- * Sets the function that is responsible for the context destruction.
94
- * Overrides the default destruction function, which destroys only the context instance.
95
- * It expects a function that should return a promise (or `undefined`).
96
- *
97
- * ```ts
98
- * watchdog.setDestructor( context => {
99
- * // Do something before the context is destroyed.
100
- *
101
- * return context
102
- * .destroy()
103
- * .then( () => {
104
- * // Do something after the context is destroyed.
105
- * } );
106
- * } );
107
- * ```
108
- */
109
- setDestructor(destructor: (context: Context) => Promise<unknown>): void;
110
- /**
111
- * The context instance. Keep in mind that this property might be changed when the context watchdog restarts,
112
- * so do not keep this instance internally. Always operate on the `ContextWatchdog#context` property.
113
- */
114
- get context(): Context | null;
115
- /**
116
- * Initializes the context watchdog. Once it is created, the watchdog takes care about
117
- * recreating the context and the provided items, and starts the error handling mechanism.
118
- *
119
- * ```ts
120
- * await watchdog.create( {
121
- * plugins: []
122
- * } );
123
- * ```
124
- *
125
- * @param contextConfig The context configuration. See {@link module:core/context~Context}.
126
- */
127
- create(contextConfig?: ContextConfig): Promise<unknown>;
128
- /**
129
- * Returns an item instance with the given `itemId`.
130
- *
131
- * ```ts
132
- * const editor1 = watchdog.getItem( 'editor1' );
133
- * ```
134
- *
135
- * @param itemId The item ID.
136
- * @returns The item instance or `undefined` if an item with a given ID has not been found.
137
- */
138
- getItem(itemId: string): unknown;
139
- /**
140
- * Gets the state of the given item. See {@link #state} for a list of available states.
141
- *
142
- * ```ts
143
- * const editor1State = watchdog.getItemState( 'editor1' );
144
- * ```
145
- *
146
- * @param itemId Item ID.
147
- * @returns The state of the item.
148
- */
149
- getItemState(itemId: string): WatchdogState;
150
- /**
151
- * Adds items to the watchdog. Once created, instances of these items will be available using the {@link #getItem} method.
152
- *
153
- * Items can be passed together as an array of objects:
154
- *
155
- * ```ts
156
- * await watchdog.add( [ {
157
- * id: 'editor1',
158
- * type: 'editor',
159
- * sourceElementOrData: document.querySelector( '#editor' ),
160
- * config: {
161
- * plugins: [ Essentials, Paragraph, Bold, Italic ],
162
- * toolbar: [ 'bold', 'italic', 'alignment' ]
163
- * },
164
- * creator: ( element, config ) => ClassicEditor.create( element, config )
165
- * } ] );
166
- * ```
167
- *
168
- * Or one by one as objects:
169
- *
170
- * ```ts
171
- * await watchdog.add( {
172
- * id: 'editor1',
173
- * type: 'editor',
174
- * sourceElementOrData: document.querySelector( '#editor' ),
175
- * config: {
176
- * plugins: [ Essentials, Paragraph, Bold, Italic ],
177
- * toolbar: [ 'bold', 'italic', 'alignment' ]
178
- * },
179
- * creator: ( element, config ) => ClassicEditor.create( element, config )
180
- * ] );
181
- * ```
182
- *
183
- * Then an instance can be retrieved using the {@link #getItem} method:
184
- *
185
- * ```ts
186
- * const editor1 = watchdog.getItem( 'editor1' );
187
- * ```
188
- *
189
- * Note that this method can be called multiple times, but for performance reasons it is better
190
- * to pass all items together.
191
- *
192
- * @param itemConfigurationOrItemConfigurations An item configuration object or an array of item configurations.
193
- */
194
- add(itemConfigurationOrItemConfigurations: ArrayOrItem<WatchdogItemConfiguration>): Promise<unknown>;
195
- /**
196
- * Removes and destroys item(s) with given ID(s).
197
- *
198
- * ```ts
199
- * await watchdog.remove( 'editor1' );
200
- * ```
201
- *
202
- * Or
203
- *
204
- * ```ts
205
- * await watchdog.remove( [ 'editor1', 'editor2' ] );
206
- * ```
207
- *
208
- * @param itemIdOrItemIds Item ID or an array of item IDs.
209
- */
210
- remove(itemIdOrItemIds: ArrayOrItem<string>): Promise<unknown>;
211
- /**
212
- * Destroys the context watchdog and all added items.
213
- * Once the context watchdog is destroyed, new items cannot be added.
214
- *
215
- * ```ts
216
- * await watchdog.destroy();
217
- * ```
218
- */
219
- destroy(): Promise<unknown>;
220
- /**
221
- * Restarts the context watchdog.
222
- */
223
- protected _restart(): Promise<unknown>;
224
- /**
225
- * Initializes the context watchdog.
226
- */
227
- private _create;
228
- /**
229
- * Destroys the context instance and all added items.
230
- */
231
- private _destroy;
232
- /**
233
- * Returns the watchdog for a given item ID.
234
- *
235
- * @param itemId Item ID.
236
- */
237
- protected _getWatchdog(itemId: string): Watchdog;
238
- /**
239
- * Checks whether an error comes from the context instance and not from the item instances.
240
- *
241
- * @internal
242
- */
243
- _isErrorComingFromThisItem(error: CKEditorError): boolean;
244
- }
245
- /**
246
- * Fired after the watchdog restarts the context and the added items because of a crash.
247
- *
248
- * ```ts
249
- * watchdog.on( 'restart', () => {
250
- * console.log( 'The context has been restarted.' );
251
- * } );
252
- * ```
253
- *
254
- * @eventName ~ContextWatchdog#restart
255
- */
256
- export type ContextWatchdogRestartEvent = {
257
- name: 'restart';
258
- args: [];
259
- return: undefined;
260
- };
261
- /**
262
- * Fired when a new error occurred in one of the added items.
263
- *
264
- * ```ts
265
- * watchdog.on( 'itemError', ( evt, { error, itemId } ) => {
266
- * console.log( `An error occurred in an item with the '${ itemId }' ID.` );
267
- * } );
268
- * ```
269
- *
270
- * @eventName ~ContextWatchdog#itemError
271
- */
272
- export type ContextWatchdogItemErrorEvent = {
273
- name: 'itemError';
274
- args: [ContextWatchdogItemErrorEventData];
275
- return: undefined;
276
- };
277
- /**
278
- * The `itemError` event data.
279
- */
280
- export type ContextWatchdogItemErrorEventData = {
281
- itemId: string;
282
- error: Error;
283
- };
284
- /**
285
- * Fired after an item has been restarted.
286
- *
287
- * ```ts
288
- * watchdog.on( 'itemRestart', ( evt, { itemId } ) => {
289
- * console.log( 'An item with with the '${ itemId }' ID has been restarted.' );
290
- * } );
291
- * ```
292
- *
293
- * @eventName ~ContextWatchdog#itemRestart
294
- */
295
- export type ContextWatchdogItemRestartEvent = {
296
- name: 'itemRestart';
297
- args: [ContextWatchdogItemRestartEventData];
298
- return: undefined;
299
- };
300
- /**
301
- * The `itemRestart` event data.
302
- */
303
- export type ContextWatchdogItemRestartEventData = {
304
- itemId: string;
305
- };
306
- /**
307
- * The watchdog item configuration interface.
308
- */
309
- export interface WatchdogItemConfiguration {
310
- /**
311
- * id A unique item identificator.
312
- */
313
- id: string;
314
- /**
315
- * The type of the item to create. At the moment, only `'editor'` is supported.
316
- */
317
- type: 'editor';
318
- /**
319
- * A function that initializes the item (the editor). The function takes editor initialization arguments
320
- * and should return a promise. For example: `( el, config ) => ClassicEditor.create( el, config )`.
321
- */
322
- creator: EditorCreatorFunction;
323
- /**
324
- * A function that destroys the item instance (the editor). The function
325
- * takes an item and should return a promise. For example: `editor => editor.destroy()`
326
- */
327
- destructor?: (editor: Editor) => Promise<unknown>;
328
- /**
329
- * The source element or data that will be passed
330
- * as the first argument to the `Editor.create()` method.
331
- */
332
- sourceElementOrData: string | HTMLElement;
333
- /**
334
- * An editor configuration.
335
- */
336
- config: EditorConfig;
337
- }