devtools-tracing 1.0.0 → 1.1.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/README.md +4 -0
- package/generate.ts +32 -26
- package/index.ts +2 -1
- package/lib/extension-api/ExtensionAPI.d.ts +357 -0
- package/lib/front_end/models/bindings/CSSWorkspaceBinding.ts +318 -0
- package/lib/front_end/models/bindings/CompilerScriptMapping.ts +536 -0
- package/lib/front_end/models/bindings/ContentProviderBasedProject.ts +187 -0
- package/lib/front_end/models/bindings/DebuggerLanguagePlugins.ts +1197 -0
- package/lib/front_end/models/bindings/DebuggerWorkspaceBinding.ts +733 -0
- package/lib/front_end/models/bindings/DefaultScriptMapping.ts +141 -0
- package/lib/front_end/models/bindings/FileUtils.ts +228 -0
- package/lib/front_end/models/bindings/LiveLocation.ts +81 -0
- package/lib/front_end/models/bindings/NetworkProject.ts +157 -0
- package/lib/front_end/models/bindings/PresentationConsoleMessageHelper.ts +312 -0
- package/lib/front_end/models/bindings/ResourceMapping.ts +539 -0
- package/lib/front_end/models/bindings/ResourceScriptMapping.ts +491 -0
- package/lib/front_end/models/bindings/ResourceUtils.ts +103 -0
- package/lib/front_end/models/bindings/SASSSourceMapping.ts +222 -0
- package/lib/front_end/models/bindings/StylesSourceMapping.ts +316 -0
- package/lib/front_end/models/bindings/TempFile.ts +67 -0
- package/lib/front_end/models/bindings/bindings.ts +39 -0
- package/lib/front_end/models/source_map_scopes/NamesResolver.ts +765 -0
- package/lib/front_end/models/source_map_scopes/ScopeChainModel.ts +84 -0
- package/lib/front_end/models/source_map_scopes/source_map_scopes.ts +11 -0
- package/lib/front_end/models/stack_trace/StackTrace.ts +53 -0
- package/lib/front_end/models/stack_trace/StackTraceImpl.ts +85 -0
- package/lib/front_end/models/stack_trace/StackTraceModel.ts +128 -0
- package/lib/front_end/models/stack_trace/Trie.ts +163 -0
- package/lib/front_end/models/stack_trace/stack_trace.ts +9 -0
- package/lib/front_end/models/stack_trace/stack_trace_impl.ts +13 -0
- package/lib/front_end/models/trace_source_maps_resolver/SourceMapsResolver.ts +240 -0
- package/lib/front_end/models/trace_source_maps_resolver/trace_source_maps_resolver.ts +5 -0
- package/lib/front_end/models/workspace/FileManager.ts +97 -0
- package/lib/front_end/models/workspace/IgnoreListManager.ts +628 -0
- package/lib/front_end/models/workspace/SearchConfig.ts +149 -0
- package/lib/front_end/models/workspace/UISourceCode.ts +698 -0
- package/lib/front_end/models/workspace/WorkspaceImpl.ts +339 -0
- package/lib/front_end/models/workspace/workspace.ts +17 -0
- package/lib/front_end/panels/timeline/TimelineUIUtils.ts +1029 -0
- package/lib/front_end/panels/timeline/extensions/ExtensionUI.ts +49 -0
- package/lib/front_end/panels/timeline/extensions/extensions.ts +9 -0
- package/lib/front_end/third_party/codemirror.next/LICENSE +21 -0
- package/lib/front_end/third_party/codemirror.next/README.chromium +30 -0
- package/lib/front_end/third_party/codemirror.next/bundle-tsconfig.json +24 -0
- package/lib/front_end/third_party/codemirror.next/bundle.ts +135 -0
- package/lib/front_end/third_party/codemirror.next/chunk/angular.js +2 -0
- package/lib/front_end/third_party/codemirror.next/chunk/angular.js.map +1 -0
- package/lib/front_end/third_party/codemirror.next/chunk/codemirror.js +2 -0
- package/lib/front_end/third_party/codemirror.next/chunk/codemirror.js.map +1 -0
- package/lib/front_end/third_party/codemirror.next/chunk/cpp.js +2 -0
- package/lib/front_end/third_party/codemirror.next/chunk/cpp.js.map +1 -0
- package/lib/front_end/third_party/codemirror.next/chunk/css.js +2 -0
- package/lib/front_end/third_party/codemirror.next/chunk/html.js +4 -0
- package/lib/front_end/third_party/codemirror.next/chunk/java.js +2 -0
- package/lib/front_end/third_party/codemirror.next/chunk/java.js.map +1 -0
- package/lib/front_end/third_party/codemirror.next/chunk/javascript.js +2 -0
- package/lib/front_end/third_party/codemirror.next/chunk/legacy.js +2 -0
- package/lib/front_end/third_party/codemirror.next/chunk/legacy.js.map +1 -0
- package/lib/front_end/third_party/codemirror.next/chunk/less.js +2 -0
- package/lib/front_end/third_party/codemirror.next/chunk/less.js.map +1 -0
- package/lib/front_end/third_party/codemirror.next/chunk/markdown.js +2 -0
- package/lib/front_end/third_party/codemirror.next/chunk/markdown.js.map +1 -0
- package/lib/front_end/third_party/codemirror.next/chunk/php.js +2 -0
- package/lib/front_end/third_party/codemirror.next/chunk/php.js.map +1 -0
- package/lib/front_end/third_party/codemirror.next/chunk/python.js +2 -0
- package/lib/front_end/third_party/codemirror.next/chunk/python.js.map +1 -0
- package/lib/front_end/third_party/codemirror.next/chunk/sass.js +2 -0
- package/lib/front_end/third_party/codemirror.next/chunk/sass.js.map +1 -0
- package/lib/front_end/third_party/codemirror.next/chunk/svelte.js +2 -0
- package/lib/front_end/third_party/codemirror.next/chunk/svelte.js.map +1 -0
- package/lib/front_end/third_party/codemirror.next/chunk/vue.js +2 -0
- package/lib/front_end/third_party/codemirror.next/chunk/vue.js.map +1 -0
- package/lib/front_end/third_party/codemirror.next/chunk/wast.js +2 -0
- package/lib/front_end/third_party/codemirror.next/chunk/wast.js.map +1 -0
- package/lib/front_end/third_party/codemirror.next/chunk/xml.js +2 -0
- package/lib/front_end/third_party/codemirror.next/chunk/xml.js.map +1 -0
- package/lib/front_end/third_party/codemirror.next/codemirror.next.d.ts +8057 -0
- package/lib/front_end/third_party/codemirror.next/codemirror.next.js +2 -0
- package/lib/front_end/third_party/codemirror.next/codemirror.next.js.map +1 -0
- package/lib/front_end/third_party/codemirror.next/package.json +43 -0
- package/lib/front_end/third_party/codemirror.next/rebuild.sh +6 -0
- package/lib/front_end/third_party/codemirror.next/rollup.config.mjs +49 -0
- package/lib/front_end/third_party/source-map-scopes-codec/LICENSE +26 -0
- package/lib/front_end/third_party/source-map-scopes-codec/README.chromium +31 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/CONTRIBUTING.md +33 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/LICENSE +26 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/README.md +64 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts +62 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts.map +1 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts +37 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts.map +1 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts +29 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts.map +1 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts +8 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts.map +1 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts +6 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts.map +1 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/deno.json +21 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/package.json +14 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js +196 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js.map +1 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.ts +262 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js +235 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js.map +1 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.ts +359 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.js +39 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.js.map +1 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.ts +53 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js +438 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js.map +1 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.ts +539 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js +23 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js.map +1 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.ts +35 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js +257 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js.map +1 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.ts +348 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.js +8 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.js.map +1 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.ts +20 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/scopes-tsconfig.json +8 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/scopes.d.ts +184 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.js +9 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.js.map +1 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.ts +12 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.js +82 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.js.map +1 -0
- package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.ts +99 -0
- package/lib/front_end/third_party/source-map-scopes-codec/source-map-scopes-codec.ts +5 -0
- package/lib/front_end/ui/legacy/theme_support/ThemeSupport.ts +222 -0
- package/lib/front_end/ui/legacy/theme_support/theme_support.ts +5 -0
- package/package.json +11 -5
- package/patches/chrome-devtools-frontend+1.0.1533544.patch +1549 -20
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
// Copyright 2012 The Chromium Authors
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
import type * as Common from '../../core/common/common.js';
|
|
6
|
+
import type * as Platform from '../../core/platform/platform.js';
|
|
7
|
+
import * as SDK from '../../core/sdk/sdk.js';
|
|
8
|
+
import * as Protocol from '../../generated/protocol.js';
|
|
9
|
+
import * as TextUtils from '../text_utils/text_utils.js';
|
|
10
|
+
import * as Workspace from '../workspace/workspace.js';
|
|
11
|
+
|
|
12
|
+
import {CSSWorkspaceBinding} from './CSSWorkspaceBinding.js';
|
|
13
|
+
import {DebuggerWorkspaceBinding} from './DebuggerWorkspaceBinding.js';
|
|
14
|
+
import {type LiveLocation, LiveLocationPool, LiveLocationWithPool} from './LiveLocation.js';
|
|
15
|
+
|
|
16
|
+
export interface MessageSource {
|
|
17
|
+
url?: Platform.DevToolsPath.UrlString;
|
|
18
|
+
line: number;
|
|
19
|
+
column: number;
|
|
20
|
+
scriptId?: Protocol.Runtime.ScriptId;
|
|
21
|
+
stackTrace?: Protocol.Runtime.StackTrace;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class PresentationSourceFrameMessageManager implements
|
|
25
|
+
SDK.TargetManager.SDKModelObserver<SDK.DebuggerModel.DebuggerModel>,
|
|
26
|
+
SDK.TargetManager.SDKModelObserver<SDK.CSSModel.CSSModel> {
|
|
27
|
+
#targetToMessageHelperMap = new WeakMap<SDK.Target.Target, PresentationSourceFrameMessageHelper>();
|
|
28
|
+
constructor() {
|
|
29
|
+
SDK.TargetManager.TargetManager.instance().observeModels(SDK.DebuggerModel.DebuggerModel, this);
|
|
30
|
+
SDK.TargetManager.TargetManager.instance().observeModels(SDK.CSSModel.CSSModel, this);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
modelAdded(model: SDK.DebuggerModel.DebuggerModel|SDK.CSSModel.CSSModel): void {
|
|
34
|
+
const target = model.target();
|
|
35
|
+
const helper = this.#targetToMessageHelperMap.get(target) ?? new PresentationSourceFrameMessageHelper();
|
|
36
|
+
if (model instanceof SDK.DebuggerModel.DebuggerModel) {
|
|
37
|
+
helper.setDebuggerModel(model);
|
|
38
|
+
} else {
|
|
39
|
+
helper.setCSSModel(model);
|
|
40
|
+
}
|
|
41
|
+
this.#targetToMessageHelperMap.set(target, helper);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
modelRemoved(model: SDK.DebuggerModel.DebuggerModel|SDK.CSSModel.CSSModel): void {
|
|
45
|
+
const target = model.target();
|
|
46
|
+
const helper = this.#targetToMessageHelperMap.get(target);
|
|
47
|
+
helper?.clear();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
addMessage(message: Workspace.UISourceCode.Message, source: MessageSource, target: SDK.Target.Target): void {
|
|
51
|
+
const helper = this.#targetToMessageHelperMap.get(target);
|
|
52
|
+
void helper?.addMessage(message, source);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
clear(): void {
|
|
56
|
+
for (const target of SDK.TargetManager.TargetManager.instance().targets()) {
|
|
57
|
+
const helper = this.#targetToMessageHelperMap.get(target);
|
|
58
|
+
helper?.clear();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export class PresentationConsoleMessageManager {
|
|
64
|
+
#sourceFrameMessageManager = new PresentationSourceFrameMessageManager();
|
|
65
|
+
|
|
66
|
+
constructor() {
|
|
67
|
+
SDK.TargetManager.TargetManager.instance().addModelListener(
|
|
68
|
+
SDK.ConsoleModel.ConsoleModel, SDK.ConsoleModel.Events.MessageAdded,
|
|
69
|
+
event => this.consoleMessageAdded(event.data));
|
|
70
|
+
SDK.ConsoleModel.ConsoleModel.allMessagesUnordered().forEach(this.consoleMessageAdded, this);
|
|
71
|
+
SDK.TargetManager.TargetManager.instance().addModelListener(
|
|
72
|
+
SDK.ConsoleModel.ConsoleModel, SDK.ConsoleModel.Events.ConsoleCleared,
|
|
73
|
+
() => this.#sourceFrameMessageManager.clear());
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private consoleMessageAdded(consoleMessage: SDK.ConsoleModel.ConsoleMessage): void {
|
|
77
|
+
const runtimeModel = consoleMessage.runtimeModel();
|
|
78
|
+
if (!consoleMessage.isErrorOrWarning() || !consoleMessage.runtimeModel() ||
|
|
79
|
+
consoleMessage.source === Protocol.Log.LogEntrySource.Violation || !runtimeModel) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const level = consoleMessage.level === Protocol.Log.LogEntryLevel.Error ?
|
|
83
|
+
Workspace.UISourceCode.Message.Level.ERROR :
|
|
84
|
+
Workspace.UISourceCode.Message.Level.WARNING;
|
|
85
|
+
this.#sourceFrameMessageManager.addMessage(
|
|
86
|
+
new Workspace.UISourceCode.Message(level, consoleMessage.messageText), consoleMessage, runtimeModel.target());
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export class PresentationSourceFrameMessageHelper {
|
|
91
|
+
#debuggerModel?: SDK.DebuggerModel.DebuggerModel;
|
|
92
|
+
#cssModel?: SDK.CSSModel.CSSModel;
|
|
93
|
+
#presentationMessages = new Map<Platform.DevToolsPath.UrlString, Array<{
|
|
94
|
+
source: MessageSource,
|
|
95
|
+
presentation: PresentationSourceFrameMessage,
|
|
96
|
+
}>>();
|
|
97
|
+
readonly #locationPool: LiveLocationPool;
|
|
98
|
+
|
|
99
|
+
constructor() {
|
|
100
|
+
this.#locationPool = new LiveLocationPool();
|
|
101
|
+
|
|
102
|
+
Workspace.Workspace.WorkspaceImpl.instance().addEventListener(
|
|
103
|
+
Workspace.Workspace.Events.UISourceCodeAdded, this.#uiSourceCodeAdded.bind(this));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
setDebuggerModel(debuggerModel: SDK.DebuggerModel.DebuggerModel): void {
|
|
107
|
+
if (this.#debuggerModel) {
|
|
108
|
+
throw new Error('Cannot set DebuggerModel twice');
|
|
109
|
+
}
|
|
110
|
+
this.#debuggerModel = debuggerModel;
|
|
111
|
+
// TODO(dgozman): queueMicrotask because we race with DebuggerWorkspaceBinding on ParsedScriptSource event delivery.
|
|
112
|
+
debuggerModel.addEventListener(SDK.DebuggerModel.Events.ParsedScriptSource, event => {
|
|
113
|
+
queueMicrotask(() => {
|
|
114
|
+
this.#parsedScriptSource(event);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
debuggerModel.addEventListener(SDK.DebuggerModel.Events.GlobalObjectCleared, this.#debuggerReset, this);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
setCSSModel(cssModel: SDK.CSSModel.CSSModel): void {
|
|
121
|
+
if (this.#cssModel) {
|
|
122
|
+
throw new Error('Cannot set CSSModel twice');
|
|
123
|
+
}
|
|
124
|
+
this.#cssModel = cssModel;
|
|
125
|
+
cssModel.addEventListener(
|
|
126
|
+
SDK.CSSModel.Events.StyleSheetAdded, event => queueMicrotask(() => this.#styleSheetAdded(event)));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async addMessage(message: Workspace.UISourceCode.Message, source: MessageSource): Promise<void> {
|
|
130
|
+
const presentation = new PresentationSourceFrameMessage(message, this.#locationPool);
|
|
131
|
+
const location = this.#rawLocation(source) ?? this.#cssLocation(source) ?? this.#uiLocation(source);
|
|
132
|
+
if (location) {
|
|
133
|
+
await presentation.updateLocationSource(location);
|
|
134
|
+
}
|
|
135
|
+
if (source.url) {
|
|
136
|
+
let messages = this.#presentationMessages.get(source.url);
|
|
137
|
+
if (!messages) {
|
|
138
|
+
messages = [];
|
|
139
|
+
this.#presentationMessages.set(source.url, messages);
|
|
140
|
+
}
|
|
141
|
+
messages.push({source, presentation});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
#uiLocation(source: MessageSource): Workspace.UISourceCode.UILocation|null {
|
|
146
|
+
if (!source.url) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const uiSourceCode = Workspace.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(source.url);
|
|
151
|
+
if (!uiSourceCode) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
return new Workspace.UISourceCode.UILocation(uiSourceCode, source.line, source.column);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
#cssLocation(source: MessageSource): SDK.CSSModel.CSSLocation|null {
|
|
158
|
+
if (!this.#cssModel || !source.url) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
const locations = this.#cssModel.createRawLocationsByURL(source.url, source.line, source.column);
|
|
162
|
+
return locations[0] ?? null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
#rawLocation(source: MessageSource): SDK.DebuggerModel.Location|null {
|
|
166
|
+
if (!this.#debuggerModel) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
if (source.scriptId) {
|
|
170
|
+
return this.#debuggerModel.createRawLocationByScriptId(source.scriptId, source.line, source.column);
|
|
171
|
+
}
|
|
172
|
+
const callFrame = source.stackTrace?.callFrames ? source.stackTrace.callFrames[0] : null;
|
|
173
|
+
if (callFrame) {
|
|
174
|
+
return this.#debuggerModel.createRawLocationByScriptId(
|
|
175
|
+
callFrame.scriptId, callFrame.lineNumber, callFrame.columnNumber);
|
|
176
|
+
}
|
|
177
|
+
if (source.url) {
|
|
178
|
+
return this.#debuggerModel.createRawLocationByURL(source.url, source.line, source.column);
|
|
179
|
+
}
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
#parsedScriptSource(event: Common.EventTarget.EventTargetEvent<SDK.Script.Script>): void {
|
|
184
|
+
const script = event.data;
|
|
185
|
+
const messages = this.#presentationMessages.get(script.sourceURL);
|
|
186
|
+
|
|
187
|
+
const promises: Array<Promise<void>> = [];
|
|
188
|
+
for (const {presentation, source} of messages ?? []) {
|
|
189
|
+
const rawLocation = this.#rawLocation(source);
|
|
190
|
+
if (rawLocation && script.scriptId === rawLocation.scriptId) {
|
|
191
|
+
promises.push(presentation.updateLocationSource(rawLocation));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
void Promise.all(promises).then(this.parsedScriptSourceForTest.bind(this));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
parsedScriptSourceForTest(): void {
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
#uiSourceCodeAdded(event: Common.EventTarget.EventTargetEvent<Workspace.UISourceCode.UISourceCode>): void {
|
|
202
|
+
const uiSourceCode = event.data;
|
|
203
|
+
const messages = this.#presentationMessages.get(uiSourceCode.url());
|
|
204
|
+
|
|
205
|
+
const promises: Array<Promise<void>> = [];
|
|
206
|
+
for (const {presentation, source} of messages ?? []) {
|
|
207
|
+
promises.push(presentation.updateLocationSource(
|
|
208
|
+
new Workspace.UISourceCode.UILocation(uiSourceCode, source.line, source.column)));
|
|
209
|
+
}
|
|
210
|
+
void Promise.all(promises).then(this.uiSourceCodeAddedForTest.bind(this));
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
uiSourceCodeAddedForTest(): void {
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
#styleSheetAdded(event: Common.EventTarget
|
|
217
|
+
.EventTargetEvent<SDK.CSSStyleSheetHeader.CSSStyleSheetHeader, SDK.CSSModel.EventTypes>): void {
|
|
218
|
+
const header = event.data;
|
|
219
|
+
const messages = this.#presentationMessages.get(header.sourceURL);
|
|
220
|
+
|
|
221
|
+
const promises: Array<Promise<void>> = [];
|
|
222
|
+
for (const {source, presentation} of messages ?? []) {
|
|
223
|
+
if (header.containsLocation(source.line, source.column)) {
|
|
224
|
+
promises.push(
|
|
225
|
+
presentation.updateLocationSource(new SDK.CSSModel.CSSLocation(header, source.line, source.column)));
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
void Promise.all(promises).then(this.styleSheetAddedForTest.bind(this));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
styleSheetAddedForTest(): void {
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
clear(): void {
|
|
235
|
+
this.#debuggerReset();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
#debuggerReset(): void {
|
|
239
|
+
const presentations = Array.from(this.#presentationMessages.values()).flat();
|
|
240
|
+
for (const {presentation} of presentations) {
|
|
241
|
+
presentation.dispose();
|
|
242
|
+
}
|
|
243
|
+
this.#presentationMessages.clear();
|
|
244
|
+
this.#locationPool.disposeAll();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
class FrozenLiveLocation extends LiveLocationWithPool {
|
|
249
|
+
#uiLocation: Workspace.UISourceCode.UILocation;
|
|
250
|
+
constructor(
|
|
251
|
+
uiLocation: Workspace.UISourceCode.UILocation, updateDelegate: (arg0: LiveLocation) => Promise<void>,
|
|
252
|
+
locationPool: LiveLocationPool) {
|
|
253
|
+
super(updateDelegate, locationPool);
|
|
254
|
+
this.#uiLocation = uiLocation;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
override async uiLocation(): Promise<Workspace.UISourceCode.UILocation|null> {
|
|
258
|
+
return this.#uiLocation;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export class PresentationSourceFrameMessage {
|
|
263
|
+
#uiSourceCode?: Workspace.UISourceCode.UISourceCode;
|
|
264
|
+
#liveLocation?: LiveLocation;
|
|
265
|
+
readonly #locationPool: LiveLocationPool;
|
|
266
|
+
readonly #message: Workspace.UISourceCode.Message;
|
|
267
|
+
|
|
268
|
+
constructor(message: Workspace.UISourceCode.Message, locationPool: LiveLocationPool) {
|
|
269
|
+
this.#message = message;
|
|
270
|
+
this.#locationPool = locationPool;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
async updateLocationSource(source: SDK.DebuggerModel.Location|Workspace.UISourceCode.UILocation|
|
|
274
|
+
SDK.CSSModel.CSSLocation): Promise<void> {
|
|
275
|
+
if (source instanceof SDK.DebuggerModel.Location) {
|
|
276
|
+
await DebuggerWorkspaceBinding.instance().createLiveLocation(
|
|
277
|
+
source, this.#updateLocation.bind(this), this.#locationPool);
|
|
278
|
+
} else if (source instanceof SDK.CSSModel.CSSLocation) {
|
|
279
|
+
await CSSWorkspaceBinding.instance().createLiveLocation(
|
|
280
|
+
source, this.#updateLocation.bind(this), this.#locationPool);
|
|
281
|
+
} else if (source instanceof Workspace.UISourceCode.UILocation) {
|
|
282
|
+
if (!this.#liveLocation) { // Don't "downgrade" the location if a debugger or css mapping was already successful
|
|
283
|
+
this.#liveLocation = new FrozenLiveLocation(source, this.#updateLocation.bind(this), this.#locationPool);
|
|
284
|
+
await this.#liveLocation.update();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
async #updateLocation(liveLocation: LiveLocation): Promise<void> {
|
|
290
|
+
if (this.#uiSourceCode) {
|
|
291
|
+
this.#uiSourceCode.removeMessage(this.#message);
|
|
292
|
+
}
|
|
293
|
+
if (liveLocation !== this.#liveLocation) {
|
|
294
|
+
this.#uiSourceCode?.removeMessage(this.#message);
|
|
295
|
+
this.#liveLocation?.dispose();
|
|
296
|
+
this.#liveLocation = liveLocation;
|
|
297
|
+
}
|
|
298
|
+
const uiLocation = await liveLocation.uiLocation();
|
|
299
|
+
if (!uiLocation) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
this.#message.range =
|
|
303
|
+
TextUtils.TextRange.TextRange.createFromLocation(uiLocation.lineNumber, uiLocation.columnNumber || 0);
|
|
304
|
+
this.#uiSourceCode = uiLocation.uiSourceCode;
|
|
305
|
+
this.#uiSourceCode.addMessage(this.#message);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
dispose(): void {
|
|
309
|
+
this.#uiSourceCode?.removeMessage(this.#message);
|
|
310
|
+
this.#liveLocation?.dispose();
|
|
311
|
+
}
|
|
312
|
+
}
|