chrome-devtools-frontend 1.0.929965 → 1.0.930993
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/config/gni/devtools_grd_files.gni +2 -1
- package/front_end/core/host/InspectorFrontendHost.ts +8 -1
- package/front_end/core/host/InspectorFrontendHostAPI.ts +12 -0
- package/front_end/core/i18n/locales/en-US.json +3 -0
- package/front_end/core/i18n/locales/en-XL.json +3 -0
- package/front_end/core/protocol_client/InspectorBackend.ts +71 -71
- package/front_end/core/sdk/NetworkManager.ts +6 -2
- package/front_end/devtools_compatibility.js +8 -0
- package/front_end/legacy_test_runner/sources_test_runner/DebuggerTestRunner.js +2 -2
- package/front_end/legacy_test_runner/test_runner/TestRunner.js +2 -3
- package/front_end/models/bindings/BreakpointManager.ts +158 -154
- package/front_end/models/bindings/CSSWorkspaceBinding.ts +64 -56
- package/front_end/models/bindings/CompilerScriptMapping.ts +70 -70
- package/front_end/models/bindings/ContentProviderBasedProject.ts +20 -20
- package/front_end/models/bindings/DebuggerLanguagePlugins.ts +132 -132
- package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +73 -72
- package/front_end/models/bindings/DefaultScriptMapping.ts +22 -22
- package/front_end/models/bindings/FileUtils.ts +81 -81
- package/front_end/models/bindings/IgnoreListManager.ts +17 -17
- package/front_end/models/bindings/LiveLocation.ts +21 -21
- package/front_end/models/bindings/PresentationConsoleMessageHelper.ts +28 -28
- package/front_end/models/bindings/ResourceMapping.ts +50 -50
- package/front_end/models/bindings/ResourceScriptMapping.ts +71 -71
- package/front_end/models/bindings/SASSSourceMapping.ts +32 -32
- package/front_end/models/bindings/StylesSourceMapping.ts +57 -57
- package/front_end/models/bindings/TempFile.ts +34 -34
- package/front_end/models/emulation/DeviceModeModel.ts +208 -203
- package/front_end/models/emulation/EmulatedDevices.ts +34 -34
- package/front_end/panels/console/ConsoleView.ts +2 -1
- package/front_end/panels/console/ConsoleViewMessage.ts +3 -3
- package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +133 -133
- package/front_end/panels/css_overview/CSSOverviewModel.ts +16 -16
- package/front_end/panels/css_overview/CSSOverviewPanel.ts +77 -77
- package/front_end/panels/css_overview/CSSOverviewProcessingView.ts +5 -5
- package/front_end/panels/css_overview/components/CSSOverviewStartView.ts +4 -4
- package/front_end/panels/elements/ElementsTreeElement.ts +6 -10
- package/front_end/panels/elements/ElementsTreeOutline.ts +3 -1
- package/front_end/panels/elements/components/LayoutPane.ts +6 -0
- package/front_end/panels/elements/elementsPanel.css +0 -1
- package/front_end/panels/elements/elementsTreeOutline.css +0 -4
- package/front_end/panels/lighthouse/LighthouseController.ts +18 -9
- package/front_end/panels/lighthouse/LighthousePanel.ts +2 -2
- package/front_end/panels/lighthouse/LighthouseProtocolService.ts +7 -2
- package/front_end/panels/network/BlockedURLsPane.ts +8 -5
- package/front_end/panels/network/blockedURLsPane.css +0 -1
- package/front_end/panels/search/SearchView.ts +0 -2
- package/front_end/panels/sources/BreakpointEditDialog.ts +98 -81
- package/front_end/panels/sources/DebuggerPlugin.ts +15 -14
- package/front_end/ui/components/code_highlighter/CodeHighlighter.ts +18 -2
- package/front_end/ui/components/text_editor/config.ts +6 -0
- package/front_end/ui/components/text_editor/cursor_tooltip.ts +70 -0
- package/front_end/ui/components/text_editor/javascript.ts +590 -0
- package/front_end/ui/components/text_editor/text_editor.ts +1 -0
- package/front_end/ui/components/text_editor/theme.ts +11 -0
- package/front_end/ui/components/tree_outline/TreeOutline.ts +3 -1
- package/front_end/ui/legacy/ARIAUtils.ts +24 -8
- package/front_end/ui/legacy/components/text_editor/cmdevtools.css +1 -0
- package/front_end/ui/legacy/components/text_editor/text_editor-legacy.ts +0 -3
- package/front_end/ui/legacy/components/text_editor/text_editor.ts +0 -2
- package/package.json +1 -1
- package/scripts/migration/class-fields/migrate.js +15 -2
- package/scripts/migration/class-fields/migrate.sh +10 -0
- package/front_end/ui/legacy/components/text_editor/SyntaxHighlighter.ts +0 -62
|
@@ -54,74 +54,74 @@ declare const DecompressionStream: {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
export class ChunkedFileReader implements ChunkedReader {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
#file: File|null;
|
|
58
|
+
readonly #fileSizeInternal: number;
|
|
59
|
+
#loadedSizeInternal: number;
|
|
60
|
+
#streamReader: ReadableStreamReader<Uint8Array>|null;
|
|
61
|
+
readonly #chunkSize: number;
|
|
62
|
+
readonly #chunkTransferredCallback: ((arg0: ChunkedReader) => void)|undefined;
|
|
63
|
+
readonly #decoder: TextDecoder;
|
|
64
|
+
#isCanceled: boolean;
|
|
65
|
+
#errorInternal: DOMException|null;
|
|
66
|
+
#transferFinished!: (arg0: boolean) => void;
|
|
67
|
+
#output?: Common.StringOutputStream.OutputStream;
|
|
68
|
+
#reader?: FileReader|null;
|
|
69
69
|
|
|
70
70
|
constructor(file: File, chunkSize: number, chunkTransferredCallback?: ((arg0: ChunkedReader) => void)) {
|
|
71
|
-
this
|
|
72
|
-
this
|
|
73
|
-
this
|
|
74
|
-
this
|
|
75
|
-
this
|
|
76
|
-
this
|
|
77
|
-
this
|
|
78
|
-
this
|
|
79
|
-
this
|
|
71
|
+
this.#file = file;
|
|
72
|
+
this.#fileSizeInternal = file.size;
|
|
73
|
+
this.#loadedSizeInternal = 0;
|
|
74
|
+
this.#chunkSize = chunkSize;
|
|
75
|
+
this.#chunkTransferredCallback = chunkTransferredCallback;
|
|
76
|
+
this.#decoder = new TextDecoder();
|
|
77
|
+
this.#isCanceled = false;
|
|
78
|
+
this.#errorInternal = null;
|
|
79
|
+
this.#streamReader = null;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
async read(output: Common.StringOutputStream.OutputStream): Promise<boolean> {
|
|
83
|
-
if (this
|
|
84
|
-
this
|
|
83
|
+
if (this.#chunkTransferredCallback) {
|
|
84
|
+
this.#chunkTransferredCallback(this);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
if (this
|
|
88
|
-
const stream = this.decompressStream(this
|
|
89
|
-
this
|
|
87
|
+
if (this.#file?.type.endsWith('gzip')) {
|
|
88
|
+
const stream = this.decompressStream(this.#file.stream());
|
|
89
|
+
this.#streamReader = stream.getReader();
|
|
90
90
|
} else {
|
|
91
|
-
this
|
|
92
|
-
this
|
|
93
|
-
this
|
|
91
|
+
this.#reader = new FileReader();
|
|
92
|
+
this.#reader.onload = this.onChunkLoaded.bind(this);
|
|
93
|
+
this.#reader.onerror = this.onError.bind(this);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
this
|
|
96
|
+
this.#output = output;
|
|
97
97
|
this.loadChunk();
|
|
98
98
|
|
|
99
99
|
return new Promise(resolve => {
|
|
100
|
-
this
|
|
100
|
+
this.#transferFinished = resolve;
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
cancel(): void {
|
|
105
|
-
this
|
|
105
|
+
this.#isCanceled = true;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
loadedSize(): number {
|
|
109
|
-
return this
|
|
109
|
+
return this.#loadedSizeInternal;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
fileSize(): number {
|
|
113
|
-
return this
|
|
113
|
+
return this.#fileSizeInternal;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
fileName(): string {
|
|
117
|
-
if (!this
|
|
117
|
+
if (!this.#file) {
|
|
118
118
|
return '';
|
|
119
119
|
}
|
|
120
|
-
return this
|
|
120
|
+
return this.#file.name;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
error(): DOMException|null {
|
|
124
|
-
return this
|
|
124
|
+
return this.#errorInternal;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
// Decompress gzip natively thanks to https://wicg.github.io/compression/
|
|
@@ -132,7 +132,7 @@ export class ChunkedFileReader implements ChunkedReader {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
private onChunkLoaded(event: Event): void {
|
|
135
|
-
if (this
|
|
135
|
+
if (this.#isCanceled) {
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -141,27 +141,27 @@ export class ChunkedFileReader implements ChunkedReader {
|
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
if (!this
|
|
144
|
+
if (!this.#reader) {
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
const buffer = (this
|
|
149
|
-
this
|
|
150
|
-
const endOfFile = this
|
|
148
|
+
const buffer = (this.#reader.result as ArrayBuffer);
|
|
149
|
+
this.#loadedSizeInternal += buffer.byteLength;
|
|
150
|
+
const endOfFile = this.#loadedSizeInternal === this.#fileSizeInternal;
|
|
151
151
|
this.decodeChunkBuffer(buffer, endOfFile);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
private async decodeChunkBuffer(buffer: ArrayBuffer, endOfFile: boolean): Promise<void> {
|
|
155
|
-
if (!this
|
|
155
|
+
if (!this.#output) {
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
|
-
const decodedString = this
|
|
159
|
-
await this
|
|
160
|
-
if (this
|
|
158
|
+
const decodedString = this.#decoder.decode(buffer, {stream: !endOfFile});
|
|
159
|
+
await this.#output.write(decodedString);
|
|
160
|
+
if (this.#isCanceled) {
|
|
161
161
|
return;
|
|
162
162
|
}
|
|
163
|
-
if (this
|
|
164
|
-
this
|
|
163
|
+
if (this.#chunkTransferredCallback) {
|
|
164
|
+
this.#chunkTransferredCallback(this);
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
if (endOfFile) {
|
|
@@ -172,55 +172,55 @@ export class ChunkedFileReader implements ChunkedReader {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
private finishRead(): void {
|
|
175
|
-
if (!this
|
|
175
|
+
if (!this.#output) {
|
|
176
176
|
return;
|
|
177
177
|
}
|
|
178
|
-
this
|
|
179
|
-
this
|
|
180
|
-
this
|
|
181
|
-
this
|
|
178
|
+
this.#file = null;
|
|
179
|
+
this.#reader = null;
|
|
180
|
+
this.#output.close();
|
|
181
|
+
this.#transferFinished(!this.#errorInternal);
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
private async loadChunk(): Promise<void> {
|
|
185
|
-
if (!this
|
|
185
|
+
if (!this.#output || !this.#file) {
|
|
186
186
|
return;
|
|
187
187
|
}
|
|
188
|
-
if (this
|
|
189
|
-
const {value, done} = await this
|
|
188
|
+
if (this.#streamReader) {
|
|
189
|
+
const {value, done} = await this.#streamReader.read();
|
|
190
190
|
if (done || !value) {
|
|
191
191
|
return this.finishRead();
|
|
192
192
|
}
|
|
193
193
|
this.decodeChunkBuffer(value.buffer, false);
|
|
194
194
|
}
|
|
195
|
-
if (this
|
|
196
|
-
const chunkStart = this
|
|
197
|
-
const chunkEnd = Math.min(this
|
|
198
|
-
const nextPart = this
|
|
199
|
-
this
|
|
195
|
+
if (this.#reader) {
|
|
196
|
+
const chunkStart = this.#loadedSizeInternal;
|
|
197
|
+
const chunkEnd = Math.min(this.#fileSizeInternal, chunkStart + this.#chunkSize);
|
|
198
|
+
const nextPart = this.#file.slice(chunkStart, chunkEnd);
|
|
199
|
+
this.#reader.readAsArrayBuffer(nextPart);
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
private onError(event: Event): void {
|
|
204
204
|
const eventTarget = (event.target as FileReader);
|
|
205
|
-
this
|
|
206
|
-
this
|
|
205
|
+
this.#errorInternal = eventTarget.error;
|
|
206
|
+
this.#transferFinished(false);
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
export class FileOutputStream implements Common.StringOutputStream.OutputStream {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
#writeCallbacks: (() => void)[];
|
|
212
|
+
#fileName!: string;
|
|
213
|
+
#closed?: boolean;
|
|
214
214
|
constructor() {
|
|
215
|
-
this
|
|
215
|
+
this.#writeCallbacks = [];
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
async open(fileName: string): Promise<boolean> {
|
|
219
|
-
this
|
|
219
|
+
this.#closed = false;
|
|
220
220
|
/** @type {!Array<function():void>} */
|
|
221
|
-
this
|
|
222
|
-
this
|
|
223
|
-
const saveResponse = await Workspace.FileManager.FileManager.instance().save(this
|
|
221
|
+
this.#writeCallbacks = [];
|
|
222
|
+
this.#fileName = fileName;
|
|
223
|
+
const saveResponse = await Workspace.FileManager.FileManager.instance().save(this.#fileName, '', true);
|
|
224
224
|
if (saveResponse) {
|
|
225
225
|
Workspace.FileManager.FileManager.instance().addEventListener(
|
|
226
226
|
Workspace.FileManager.Events.AppendedToURL, this.onAppendDone, this);
|
|
@@ -230,37 +230,37 @@ export class FileOutputStream implements Common.StringOutputStream.OutputStream
|
|
|
230
230
|
|
|
231
231
|
write(data: string): Promise<void> {
|
|
232
232
|
return new Promise(resolve => {
|
|
233
|
-
this
|
|
234
|
-
Workspace.FileManager.FileManager.instance().append(this
|
|
233
|
+
this.#writeCallbacks.push(resolve);
|
|
234
|
+
Workspace.FileManager.FileManager.instance().append(this.#fileName, data);
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
async close(): Promise<void> {
|
|
239
|
-
this
|
|
240
|
-
if (this
|
|
239
|
+
this.#closed = true;
|
|
240
|
+
if (this.#writeCallbacks.length) {
|
|
241
241
|
return;
|
|
242
242
|
}
|
|
243
243
|
Workspace.FileManager.FileManager.instance().removeEventListener(
|
|
244
244
|
Workspace.FileManager.Events.AppendedToURL, this.onAppendDone, this);
|
|
245
|
-
Workspace.FileManager.FileManager.instance().close(this
|
|
245
|
+
Workspace.FileManager.FileManager.instance().close(this.#fileName);
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
private onAppendDone(event: Common.EventTarget.EventTargetEvent<string>): void {
|
|
249
|
-
if (event.data !== this
|
|
249
|
+
if (event.data !== this.#fileName) {
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
|
-
const writeCallback = this
|
|
252
|
+
const writeCallback = this.#writeCallbacks.shift();
|
|
253
253
|
if (writeCallback) {
|
|
254
254
|
writeCallback();
|
|
255
255
|
}
|
|
256
|
-
if (this
|
|
256
|
+
if (this.#writeCallbacks.length) {
|
|
257
257
|
return;
|
|
258
258
|
}
|
|
259
|
-
if (!this
|
|
259
|
+
if (!this.#closed) {
|
|
260
260
|
return;
|
|
261
261
|
}
|
|
262
262
|
Workspace.FileManager.FileManager.instance().removeEventListener(
|
|
263
263
|
Workspace.FileManager.Events.AppendedToURL, this.onAppendDone, this);
|
|
264
|
-
Workspace.FileManager.FileManager.instance().close(this
|
|
264
|
+
Workspace.FileManager.FileManager.instance().close(this.#fileName);
|
|
265
265
|
}
|
|
266
266
|
}
|
|
@@ -12,12 +12,12 @@ import type {DebuggerWorkspaceBinding} from './DebuggerWorkspaceBinding.js';
|
|
|
12
12
|
let ignoreListManagerInstance: IgnoreListManager;
|
|
13
13
|
|
|
14
14
|
export class IgnoreListManager implements SDK.TargetManager.SDKModelObserver<SDK.DebuggerModel.DebuggerModel> {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
readonly #debuggerWorkspaceBinding: DebuggerWorkspaceBinding;
|
|
16
|
+
readonly #listeners: Set<() => void>;
|
|
17
|
+
readonly #isIgnoreListedURLCache: Map<string, boolean>;
|
|
18
18
|
|
|
19
19
|
private constructor(debuggerWorkspaceBinding: DebuggerWorkspaceBinding) {
|
|
20
|
-
this
|
|
20
|
+
this.#debuggerWorkspaceBinding = debuggerWorkspaceBinding;
|
|
21
21
|
|
|
22
22
|
SDK.TargetManager.TargetManager.instance().addModelListener(
|
|
23
23
|
SDK.DebuggerModel.DebuggerModel, SDK.DebuggerModel.Events.GlobalObjectCleared,
|
|
@@ -29,9 +29,9 @@ export class IgnoreListManager implements SDK.TargetManager.SDKModelObserver<SDK
|
|
|
29
29
|
.moduleSetting('skipContentScripts')
|
|
30
30
|
.addChangeListener(this.patternChanged.bind(this));
|
|
31
31
|
|
|
32
|
-
this
|
|
32
|
+
this.#listeners = new Set();
|
|
33
33
|
|
|
34
|
-
this
|
|
34
|
+
this.#isIgnoreListedURLCache = new Map();
|
|
35
35
|
|
|
36
36
|
SDK.TargetManager.TargetManager.instance().observeModels(SDK.DebuggerModel.DebuggerModel, this);
|
|
37
37
|
}
|
|
@@ -55,11 +55,11 @@ export class IgnoreListManager implements SDK.TargetManager.SDKModelObserver<SDK
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
addChangeListener(listener: () => void): void {
|
|
58
|
-
this
|
|
58
|
+
this.#listeners.add(listener);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
removeChangeListener(listener: () => void): void {
|
|
62
|
-
this
|
|
62
|
+
this.#listeners.delete(listener);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
modelAdded(debuggerModel: SDK.DebuggerModel.DebuggerModel): void {
|
|
@@ -77,8 +77,8 @@ export class IgnoreListManager implements SDK.TargetManager.SDKModelObserver<SDK
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
private clearCacheIfNeeded(): void {
|
|
80
|
-
if (this
|
|
81
|
-
this
|
|
80
|
+
if (this.#isIgnoreListedURLCache.size > 1024) {
|
|
81
|
+
this.#isIgnoreListedURLCache.clear();
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -109,15 +109,15 @@ export class IgnoreListManager implements SDK.TargetManager.SDKModelObserver<SDK
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
isIgnoreListedURL(url: string, isContentScript?: boolean): boolean {
|
|
112
|
-
if (this
|
|
113
|
-
return Boolean(this
|
|
112
|
+
if (this.#isIgnoreListedURLCache.has(url)) {
|
|
113
|
+
return Boolean(this.#isIgnoreListedURLCache.get(url));
|
|
114
114
|
}
|
|
115
115
|
if (isContentScript && Common.Settings.Settings.instance().moduleSetting('skipContentScripts').get()) {
|
|
116
116
|
return true;
|
|
117
117
|
}
|
|
118
118
|
const regex = this.getSkipStackFramesPatternSetting().asRegExp();
|
|
119
119
|
const isIgnoreListed = (regex && regex.test(url)) || false;
|
|
120
|
-
this
|
|
120
|
+
this.#isIgnoreListedURLCache.set(url, isIgnoreListed);
|
|
121
121
|
return isIgnoreListed;
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -145,7 +145,7 @@ export class IgnoreListManager implements SDK.TargetManager.SDKModelObserver<SDK
|
|
|
145
145
|
if (scriptToRange.get(script) && await script.setBlackboxedRanges([])) {
|
|
146
146
|
scriptToRange.delete(script);
|
|
147
147
|
}
|
|
148
|
-
await this
|
|
148
|
+
await this.#debuggerWorkspaceBinding.updateLocations(script);
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -173,7 +173,7 @@ export class IgnoreListManager implements SDK.TargetManager.SDKModelObserver<SDK
|
|
|
173
173
|
if (!isEqual(oldRanges, newRanges) && await script.setBlackboxedRanges(newRanges)) {
|
|
174
174
|
scriptToRange.set(script, newRanges);
|
|
175
175
|
}
|
|
176
|
-
this
|
|
176
|
+
this.#debuggerWorkspaceBinding.updateLocations(script);
|
|
177
177
|
|
|
178
178
|
function isEqual(rangesA: SourceRange[], rangesB: SourceRange[]): boolean {
|
|
179
179
|
if (rangesA.length !== rangesB.length) {
|
|
@@ -266,7 +266,7 @@ export class IgnoreListManager implements SDK.TargetManager.SDKModelObserver<SDK
|
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
private async patternChanged(): Promise<void> {
|
|
269
|
-
this
|
|
269
|
+
this.#isIgnoreListedURLCache.clear();
|
|
270
270
|
|
|
271
271
|
const promises: Promise<unknown>[] = [];
|
|
272
272
|
for (const debuggerModel of SDK.TargetManager.TargetManager.instance().models(SDK.DebuggerModel.DebuggerModel)) {
|
|
@@ -277,7 +277,7 @@ export class IgnoreListManager implements SDK.TargetManager.SDKModelObserver<SDK
|
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
await Promise.all(promises);
|
|
280
|
-
const listeners = Array.from(this
|
|
280
|
+
const listeners = Array.from(this.#listeners);
|
|
281
281
|
for (const listener of listeners) {
|
|
282
282
|
listener();
|
|
283
283
|
}
|
|
@@ -12,31 +12,31 @@ export interface LiveLocation {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export class LiveLocationWithPool implements LiveLocation {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
#updateDelegate: ((arg0: LiveLocation) => Promise<void>)|null;
|
|
16
|
+
readonly #locationPool: LiveLocationPool;
|
|
17
|
+
#updatePromise: Promise<void>|null;
|
|
18
18
|
|
|
19
19
|
constructor(updateDelegate: (arg0: LiveLocation) => Promise<void>, locationPool: LiveLocationPool) {
|
|
20
|
-
this
|
|
21
|
-
this
|
|
22
|
-
this
|
|
20
|
+
this.#updateDelegate = updateDelegate;
|
|
21
|
+
this.#locationPool = locationPool;
|
|
22
|
+
this.#locationPool.add(this);
|
|
23
23
|
|
|
24
|
-
this
|
|
24
|
+
this.#updatePromise = null;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
async update(): Promise<void> {
|
|
28
|
-
if (!this
|
|
28
|
+
if (!this.#updateDelegate) {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
// The following is a basic scheduling algorithm, guaranteeing that
|
|
32
|
-
// {updateDelegate} is always run atomically. That is, we always
|
|
32
|
+
// {#updateDelegate} is always run atomically. That is, we always
|
|
33
33
|
// wait for an update to finish before we trigger the next run.
|
|
34
|
-
if (this
|
|
35
|
-
await this
|
|
34
|
+
if (this.#updatePromise) {
|
|
35
|
+
await this.#updatePromise.then(() => this.update());
|
|
36
36
|
} else {
|
|
37
|
-
this
|
|
38
|
-
await this
|
|
39
|
-
this
|
|
37
|
+
this.#updatePromise = this.#updateDelegate(this);
|
|
38
|
+
await this.#updatePromise;
|
|
39
|
+
this.#updatePromise = null;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -45,8 +45,8 @@ export class LiveLocationWithPool implements LiveLocation {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
dispose(): void {
|
|
48
|
-
this
|
|
49
|
-
this
|
|
48
|
+
this.#locationPool.delete(this);
|
|
49
|
+
this.#updateDelegate = null;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
async isIgnoreListed(): Promise<boolean> {
|
|
@@ -55,22 +55,22 @@ export class LiveLocationWithPool implements LiveLocation {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
export class LiveLocationPool {
|
|
58
|
-
|
|
58
|
+
readonly #locations: Set<LiveLocation>;
|
|
59
59
|
|
|
60
60
|
constructor() {
|
|
61
|
-
this
|
|
61
|
+
this.#locations = new Set();
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
add(location: LiveLocation): void {
|
|
65
|
-
this
|
|
65
|
+
this.#locations.add(location);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
delete(location: LiveLocation): void {
|
|
69
|
-
this
|
|
69
|
+
this.#locations.delete(location);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
disposeAll(): void {
|
|
73
|
-
for (const location of this
|
|
73
|
+
for (const location of this.#locations) {
|
|
74
74
|
location.dispose();
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -87,17 +87,17 @@ export class PresentationConsoleMessageManager implements
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export class PresentationConsoleMessageHelper {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
readonly #debuggerModel: SDK.DebuggerModel.DebuggerModel;
|
|
91
|
+
#pendingConsoleMessages: Map<string, SDK.ConsoleModel.ConsoleMessage[]>;
|
|
92
|
+
#presentationConsoleMessages: PresentationConsoleMessage[];
|
|
93
|
+
readonly #locationPool: LiveLocationPool;
|
|
94
94
|
|
|
95
95
|
constructor(debuggerModel: SDK.DebuggerModel.DebuggerModel) {
|
|
96
|
-
this
|
|
96
|
+
this.#debuggerModel = debuggerModel;
|
|
97
97
|
|
|
98
|
-
this
|
|
98
|
+
this.#pendingConsoleMessages = new Map();
|
|
99
99
|
|
|
100
|
-
this
|
|
100
|
+
this.#presentationConsoleMessages = [];
|
|
101
101
|
|
|
102
102
|
// TODO(dgozman): queueMicrotask because we race with DebuggerWorkspaceBinding on ParsedScriptSource event delivery.
|
|
103
103
|
debuggerModel.addEventListener(SDK.DebuggerModel.Events.ParsedScriptSource, event => {
|
|
@@ -107,7 +107,7 @@ export class PresentationConsoleMessageHelper {
|
|
|
107
107
|
});
|
|
108
108
|
debuggerModel.addEventListener(SDK.DebuggerModel.Events.GlobalObjectCleared, this.debuggerReset, this);
|
|
109
109
|
|
|
110
|
-
this
|
|
110
|
+
this.#locationPool = new LiveLocationPool();
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
consoleMessageAdded(message: SDK.ConsoleModel.ConsoleMessage): void {
|
|
@@ -121,31 +121,31 @@ export class PresentationConsoleMessageHelper {
|
|
|
121
121
|
|
|
122
122
|
private rawLocation(message: SDK.ConsoleModel.ConsoleMessage): SDK.DebuggerModel.Location|null {
|
|
123
123
|
if (message.scriptId) {
|
|
124
|
-
return this
|
|
124
|
+
return this.#debuggerModel.createRawLocationByScriptId(message.scriptId, message.line, message.column);
|
|
125
125
|
}
|
|
126
126
|
const callFrame = message.stackTrace && message.stackTrace.callFrames ? message.stackTrace.callFrames[0] : null;
|
|
127
127
|
if (callFrame) {
|
|
128
|
-
return this
|
|
128
|
+
return this.#debuggerModel.createRawLocationByScriptId(
|
|
129
129
|
callFrame.scriptId, callFrame.lineNumber, callFrame.columnNumber);
|
|
130
130
|
}
|
|
131
131
|
if (message.url) {
|
|
132
|
-
return this
|
|
132
|
+
return this.#debuggerModel.createRawLocationByURL(message.url, message.line, message.column);
|
|
133
133
|
}
|
|
134
134
|
return null;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
private addConsoleMessageToScript(message: SDK.ConsoleModel.ConsoleMessage, rawLocation: SDK.DebuggerModel.Location):
|
|
138
138
|
void {
|
|
139
|
-
this
|
|
139
|
+
this.#presentationConsoleMessages.push(new PresentationConsoleMessage(message, rawLocation, this.#locationPool));
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
private addPendingConsoleMessage(message: SDK.ConsoleModel.ConsoleMessage): void {
|
|
143
143
|
if (!message.url) {
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
|
-
const pendingMessages = this
|
|
146
|
+
const pendingMessages = this.#pendingConsoleMessages.get(message.url);
|
|
147
147
|
if (!pendingMessages) {
|
|
148
|
-
this
|
|
148
|
+
this.#pendingConsoleMessages.set(message.url, [message]);
|
|
149
149
|
} else {
|
|
150
150
|
pendingMessages.push(message);
|
|
151
151
|
}
|
|
@@ -154,7 +154,7 @@ export class PresentationConsoleMessageHelper {
|
|
|
154
154
|
private parsedScriptSource(event: Common.EventTarget.EventTargetEvent<SDK.Script.Script>): void {
|
|
155
155
|
const script = event.data;
|
|
156
156
|
|
|
157
|
-
const messages = this
|
|
157
|
+
const messages = this.#pendingConsoleMessages.get(script.sourceURL);
|
|
158
158
|
if (!messages) {
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
@@ -170,28 +170,28 @@ export class PresentationConsoleMessageHelper {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
if (pendingMessages.length) {
|
|
173
|
-
this
|
|
173
|
+
this.#pendingConsoleMessages.set(script.sourceURL, pendingMessages);
|
|
174
174
|
} else {
|
|
175
|
-
this
|
|
175
|
+
this.#pendingConsoleMessages.delete(script.sourceURL);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
consoleCleared(): void {
|
|
180
|
-
this
|
|
180
|
+
this.#pendingConsoleMessages = new Map();
|
|
181
181
|
this.debuggerReset();
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
private debuggerReset(): void {
|
|
185
|
-
for (const message of this
|
|
185
|
+
for (const message of this.#presentationConsoleMessages) {
|
|
186
186
|
message.dispose();
|
|
187
187
|
}
|
|
188
|
-
this
|
|
189
|
-
this
|
|
188
|
+
this.#presentationConsoleMessages = [];
|
|
189
|
+
this.#locationPool.disposeAll();
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
export class PresentationConsoleMessage extends Workspace.UISourceCode.Message {
|
|
194
|
-
|
|
194
|
+
#uiSourceCode?: Workspace.UISourceCode.UISourceCode;
|
|
195
195
|
|
|
196
196
|
constructor(
|
|
197
197
|
message: SDK.ConsoleModel.ConsoleMessage, rawLocation: SDK.DebuggerModel.Location,
|
|
@@ -203,21 +203,21 @@ export class PresentationConsoleMessage extends Workspace.UISourceCode.Message {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
private async updateLocation(liveLocation: LiveLocation): Promise<void> {
|
|
206
|
-
if (this
|
|
207
|
-
this
|
|
206
|
+
if (this.#uiSourceCode) {
|
|
207
|
+
this.#uiSourceCode.removeMessage(this);
|
|
208
208
|
}
|
|
209
209
|
const uiLocation = await liveLocation.uiLocation();
|
|
210
210
|
if (!uiLocation) {
|
|
211
211
|
return;
|
|
212
212
|
}
|
|
213
213
|
this.range = TextUtils.TextRange.TextRange.createFromLocation(uiLocation.lineNumber, uiLocation.columnNumber || 0);
|
|
214
|
-
this
|
|
215
|
-
this
|
|
214
|
+
this.#uiSourceCode = uiLocation.uiSourceCode;
|
|
215
|
+
this.#uiSourceCode.addMessage(this);
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
dispose(): void {
|
|
219
|
-
if (this
|
|
220
|
-
this
|
|
219
|
+
if (this.#uiSourceCode) {
|
|
220
|
+
this.#uiSourceCode.removeMessage(this);
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
}
|