@ckeditor/ckeditor5-watchdog 46.0.3 → 46.1.0-alpha.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/dist/index.js +645 -18
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/actionsrecorder.d.ts +259 -0
- package/src/actionsrecorder.js +627 -0
- package/src/actionsrecorderconfig.d.ts +204 -0
- package/src/actionsrecorderconfig.js +5 -0
- package/src/augmentation.d.ts +5 -0
- package/src/editorwatchdog.js +21 -14
- package/src/index.d.ts +2 -0
- package/src/index.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-watchdog",
|
|
3
|
-
"version": "46.0.
|
|
3
|
+
"version": "46.1.0-alpha.1",
|
|
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,10 +12,10 @@
|
|
|
12
12
|
"type": "module",
|
|
13
13
|
"main": "src/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@ckeditor/ckeditor5-core": "46.0.
|
|
16
|
-
"@ckeditor/ckeditor5-editor-multi-root": "46.0.
|
|
17
|
-
"@ckeditor/ckeditor5-engine": "46.0.
|
|
18
|
-
"@ckeditor/ckeditor5-utils": "46.0.
|
|
15
|
+
"@ckeditor/ckeditor5-core": "46.1.0-alpha.1",
|
|
16
|
+
"@ckeditor/ckeditor5-editor-multi-root": "46.1.0-alpha.1",
|
|
17
|
+
"@ckeditor/ckeditor5-engine": "46.1.0-alpha.1",
|
|
18
|
+
"@ckeditor/ckeditor5-utils": "46.1.0-alpha.1",
|
|
19
19
|
"es-toolkit": "1.39.5"
|
|
20
20
|
},
|
|
21
21
|
"author": "CKSource (http://cksource.com/)",
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2025, 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
|
+
/**
|
|
6
|
+
* @module watchdog/actionsrecorder
|
|
7
|
+
*/
|
|
8
|
+
import type { Editor } from '@ckeditor/ckeditor5-core';
|
|
9
|
+
import type { ActionsRecorderEntry } from './actionsrecorderconfig.js';
|
|
10
|
+
/**
|
|
11
|
+
* A plugin that records user actions and editor state changes for debugging purposes. It tracks commands execution, model operations,
|
|
12
|
+
* UI interactions, and document events. It just collects data locally, and does not send it anywhere, integrator is responsible
|
|
13
|
+
* for gathering data from this plugin for further processing.
|
|
14
|
+
*
|
|
15
|
+
* **Important! `ActionsRecorder` is an experimental feature, and may become deprecated.**
|
|
16
|
+
*
|
|
17
|
+
* By default, plugin stores latest 1000 action entries. Integrator can register an `onError` callback to collect those entries
|
|
18
|
+
* in case of exception. Integrator should augment this data with application specific data such as page-id or session-id,
|
|
19
|
+
* depending on the application. Augmented data should be processed by the integrator, for example integrator should send it
|
|
20
|
+
* to some data collecting endpoint for later analysis.
|
|
21
|
+
*
|
|
22
|
+
* Example:
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* ClassicEditor
|
|
26
|
+
* .create( editorElement, {
|
|
27
|
+
* plugins: [ ActionsRecorder, ... ],
|
|
28
|
+
* actionsRecorder: {
|
|
29
|
+
* maxEntries: 1000, // This is the default value and could be adjusted.
|
|
30
|
+
*
|
|
31
|
+
* onError( error, entries ) {
|
|
32
|
+
* console.error( 'ActionsRecorder - Error detected:', error );
|
|
33
|
+
* console.warn( 'Actions recorded before error:', entries );
|
|
34
|
+
*
|
|
35
|
+
* this.flushEntries();
|
|
36
|
+
*
|
|
37
|
+
* // Integrator should send and store the entries. The error is already in the last entry in serializable form.
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* } )
|
|
41
|
+
* .then( ... )
|
|
42
|
+
* .catch( ... );
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* Alternatively integrator could continuously collect actions in batches and send them to theirs endpoint for later analysis:
|
|
46
|
+
*
|
|
47
|
+
* ```ts
|
|
48
|
+
* ClassicEditor
|
|
49
|
+
* .create( editorElement, {
|
|
50
|
+
* plugins: [ ActionsRecorder, ... ],
|
|
51
|
+
* actionsRecorder: {
|
|
52
|
+
* maxEntries: 50, // This is the batch size.
|
|
53
|
+
*
|
|
54
|
+
* onMaxEntries() {
|
|
55
|
+
* const entries = this.getEntries();
|
|
56
|
+
*
|
|
57
|
+
* this.flushEntries();
|
|
58
|
+
*
|
|
59
|
+
* console.log( 'ActionsRecorder - Batch of entries:', entries );
|
|
60
|
+
*
|
|
61
|
+
* // Integrator should send and store the entries.
|
|
62
|
+
* },
|
|
63
|
+
*
|
|
64
|
+
* onError( error, entries ) {
|
|
65
|
+
* console.error( 'ActionsRecorder - Error detected:', error );
|
|
66
|
+
* console.warn( 'Actions recorded before error:', entries );
|
|
67
|
+
*
|
|
68
|
+
* this.flushEntries();
|
|
69
|
+
*
|
|
70
|
+
* // Integrator should send and store the entries. The error is already in the last entry in serializable form.
|
|
71
|
+
* }
|
|
72
|
+
* }
|
|
73
|
+
* } )
|
|
74
|
+
* .then( ... )
|
|
75
|
+
* .catch( ... );
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* See {@link module:watchdog/actionsrecorderconfig~ActionsRecorderConfig plugin configuration} for more details.
|
|
79
|
+
*
|
|
80
|
+
*/
|
|
81
|
+
export declare class ActionsRecorder {
|
|
82
|
+
/**
|
|
83
|
+
* The editor instance.
|
|
84
|
+
*/
|
|
85
|
+
readonly editor: Editor;
|
|
86
|
+
/**
|
|
87
|
+
* Array storing all recorded action entries with their context and state snapshots.
|
|
88
|
+
*/
|
|
89
|
+
private _entries;
|
|
90
|
+
/**
|
|
91
|
+
* Stack tracking nested action frames to maintain call hierarchy.
|
|
92
|
+
*/
|
|
93
|
+
private _frameStack;
|
|
94
|
+
/**
|
|
95
|
+
* Set of already reported errors used to notify only once for each error (not on every try-catch nested block).
|
|
96
|
+
*/
|
|
97
|
+
private _errors;
|
|
98
|
+
/**
|
|
99
|
+
* Maximum number of action entries to keep in memory.
|
|
100
|
+
*/
|
|
101
|
+
private _maxEntries;
|
|
102
|
+
/**
|
|
103
|
+
* Error callback.
|
|
104
|
+
*/
|
|
105
|
+
private _errorCallback?;
|
|
106
|
+
/**
|
|
107
|
+
* Filter function to determine which entries should be stored.
|
|
108
|
+
*/
|
|
109
|
+
private _filterCallback?;
|
|
110
|
+
/**
|
|
111
|
+
* Callback triggered every time count of recorded entries reaches maxEntries.
|
|
112
|
+
*/
|
|
113
|
+
private _maxEntriesCallback;
|
|
114
|
+
/**
|
|
115
|
+
* @inheritDoc
|
|
116
|
+
*/
|
|
117
|
+
static get pluginName(): "ActionsRecorder";
|
|
118
|
+
/**
|
|
119
|
+
* @inheritDoc
|
|
120
|
+
*/
|
|
121
|
+
static get isOfficialPlugin(): true;
|
|
122
|
+
/**
|
|
123
|
+
* @inheritDoc
|
|
124
|
+
*/
|
|
125
|
+
constructor(editor: Editor);
|
|
126
|
+
/**
|
|
127
|
+
* Returns all recorded action entries.
|
|
128
|
+
*/
|
|
129
|
+
getEntries(): Array<ActionsRecorderEntry>;
|
|
130
|
+
/**
|
|
131
|
+
* Flushes all recorded entries.
|
|
132
|
+
*/
|
|
133
|
+
flushEntries(): void;
|
|
134
|
+
/**
|
|
135
|
+
* Creates a new action frame and adds it to the recording stack.
|
|
136
|
+
*
|
|
137
|
+
* @param action The name/type of the action being recorded.
|
|
138
|
+
* @param params Optional parameters associated with the event.
|
|
139
|
+
* @returns The created call frame object.
|
|
140
|
+
*/
|
|
141
|
+
private _enterFrame;
|
|
142
|
+
/**
|
|
143
|
+
* Closes an action frame and records its final state and results.
|
|
144
|
+
*
|
|
145
|
+
* @param callFrame The call frame to close.
|
|
146
|
+
* @param result Optional result value from the action.
|
|
147
|
+
* @param error Optional error that occurred during the action.
|
|
148
|
+
*/
|
|
149
|
+
private _leaveFrame;
|
|
150
|
+
/**
|
|
151
|
+
* Builds a snapshot of the current editor state including document version,
|
|
152
|
+
* read-only status, focus state, and model selection.
|
|
153
|
+
*
|
|
154
|
+
* @returns An object containing the current editor state snapshot.
|
|
155
|
+
*/
|
|
156
|
+
private _buildStateSnapshot;
|
|
157
|
+
/**
|
|
158
|
+
* Sets up recording for all editor commands, both existing and future ones.
|
|
159
|
+
* Taps into the command execution to track when commands are run.
|
|
160
|
+
*/
|
|
161
|
+
private _tapCommands;
|
|
162
|
+
/**
|
|
163
|
+
* Sets up recording for model operation applications.
|
|
164
|
+
* Tracks when operations are applied to the model document.
|
|
165
|
+
*/
|
|
166
|
+
private _tapOperationApply;
|
|
167
|
+
/**
|
|
168
|
+
* Sets up recording for key model methods like insertContent, insertObject, and deleteContent.
|
|
169
|
+
* These methods represent high-level model manipulation operations.
|
|
170
|
+
*/
|
|
171
|
+
private _tapModelMethods;
|
|
172
|
+
/**
|
|
173
|
+
* Sets up recording for model selection changes.
|
|
174
|
+
* Tracks when the selection range, attributes, or markers change.
|
|
175
|
+
*/
|
|
176
|
+
private _tapModelSelection;
|
|
177
|
+
/**
|
|
178
|
+
* Sets up recording for a specific command execution.
|
|
179
|
+
*
|
|
180
|
+
* @param commandName The name of the command to record.
|
|
181
|
+
* @param command The command instance to tap into.
|
|
182
|
+
*/
|
|
183
|
+
private _tapCommand;
|
|
184
|
+
/**
|
|
185
|
+
* Sets up recording for UI component factory creation and component interactions.
|
|
186
|
+
* Tracks when components are created and their execute events.
|
|
187
|
+
*/
|
|
188
|
+
private _tapComponentFactory;
|
|
189
|
+
/**
|
|
190
|
+
* Sets up recording for view document events like clicks, keyboard input,
|
|
191
|
+
* selection changes, and other user interactions.
|
|
192
|
+
*/
|
|
193
|
+
private _tapViewDocumentEvents;
|
|
194
|
+
/**
|
|
195
|
+
* Sets up recording for specific events fired by an emitter object.
|
|
196
|
+
*
|
|
197
|
+
* @param emitter The object that fires events to be recorded.
|
|
198
|
+
* @param eventNames Array of event names to record.
|
|
199
|
+
* @param context Additional context to include with recorded events.
|
|
200
|
+
*/
|
|
201
|
+
private _tapFireMethod;
|
|
202
|
+
/**
|
|
203
|
+
* Triggers error callback.
|
|
204
|
+
*/
|
|
205
|
+
private _callErrorCallback;
|
|
206
|
+
/**
|
|
207
|
+
* The default handler for maxEntries callback.
|
|
208
|
+
*/
|
|
209
|
+
private _maxEntriesDefaultHandler;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Creates a wrapper around a method to record its calls, results, and errors.
|
|
213
|
+
*
|
|
214
|
+
* @internal
|
|
215
|
+
*
|
|
216
|
+
* @param object The object containing the method to tap.
|
|
217
|
+
* @param methodName The name of the method to tap.
|
|
218
|
+
* @param tap The tap configuration with before/after/error hooks.
|
|
219
|
+
* @param context Additional context to include with the method calls.
|
|
220
|
+
*/
|
|
221
|
+
export declare function tapObjectMethod(object: any, methodName: string, tap: MethodTap, context?: Record<string, any>): void;
|
|
222
|
+
/**
|
|
223
|
+
* Represents a method tap with optional hooks for before, after, and error handling.
|
|
224
|
+
*/
|
|
225
|
+
interface MethodTap extends Record<string, any> {
|
|
226
|
+
/**
|
|
227
|
+
* Hook called before the original method execution.
|
|
228
|
+
*
|
|
229
|
+
* @param context The call context object for storing state between hooks.
|
|
230
|
+
* @param args The arguments passed to the original method.
|
|
231
|
+
* @returns True if the method call should be recorded, false to ignore it.
|
|
232
|
+
*/
|
|
233
|
+
before?: (context: Record<string, any>, args: Array<any>) => boolean;
|
|
234
|
+
/**
|
|
235
|
+
* Hook called after successful method execution.
|
|
236
|
+
*
|
|
237
|
+
* @param context The call context object with state from the before hook.
|
|
238
|
+
* @param result The result returned by the original method.
|
|
239
|
+
*/
|
|
240
|
+
after?: (context: Record<string, any>, result: any) => void;
|
|
241
|
+
/**
|
|
242
|
+
* Hook called when the method execution throws an error.
|
|
243
|
+
*
|
|
244
|
+
* @param context The call context object with state from the before hook.
|
|
245
|
+
* @param error The error thrown by the original method.
|
|
246
|
+
*/
|
|
247
|
+
error?: (context: Record<string, any>, error: any) => void;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Serializes a value into a JSON-serializable format.
|
|
251
|
+
*
|
|
252
|
+
* @internal
|
|
253
|
+
*
|
|
254
|
+
* @param value The value to serialize.
|
|
255
|
+
* @param visited Set of already serialized objects to avoid circular references.
|
|
256
|
+
* @returns A JSON-serializable representation of the value.
|
|
257
|
+
*/
|
|
258
|
+
export declare function serializeValue(value: any, visited?: WeakSet<object>): any;
|
|
259
|
+
export {};
|