devtools-tracing 1.0.1 → 1.1.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/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 +5 -5
- package/patches/chrome-devtools-frontend+1.0.1533544.patch +1549 -20
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
// Copyright 2014 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 * as Common from '../../core/common/common.js';
|
|
6
|
+
import * as Platform from '../../core/platform/platform.js';
|
|
7
|
+
import * as SDK from '../../core/sdk/sdk.js';
|
|
8
|
+
import type * as Workspace from '../workspace/workspace.js';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
type LiveLocation as LiveLocationInterface,
|
|
12
|
+
type LiveLocationPool,
|
|
13
|
+
LiveLocationWithPool,
|
|
14
|
+
} from './LiveLocation.js';
|
|
15
|
+
import type {ResourceMapping} from './ResourceMapping.js';
|
|
16
|
+
import {SASSSourceMapping} from './SASSSourceMapping.js';
|
|
17
|
+
import {StylesSourceMapping} from './StylesSourceMapping.js';
|
|
18
|
+
|
|
19
|
+
let cssWorkspaceBindingInstance: CSSWorkspaceBinding|undefined;
|
|
20
|
+
|
|
21
|
+
export class CSSWorkspaceBinding implements SDK.TargetManager.SDKModelObserver<SDK.CSSModel.CSSModel> {
|
|
22
|
+
readonly #resourceMapping: ResourceMapping;
|
|
23
|
+
readonly #modelToInfo: Map<SDK.CSSModel.CSSModel, ModelInfo>;
|
|
24
|
+
readonly #liveLocationPromises: Set<Promise<unknown>>;
|
|
25
|
+
|
|
26
|
+
private constructor(resourceMapping: ResourceMapping, targetManager: SDK.TargetManager.TargetManager) {
|
|
27
|
+
this.#resourceMapping = resourceMapping;
|
|
28
|
+
this.#modelToInfo = new Map();
|
|
29
|
+
targetManager.observeModels(SDK.CSSModel.CSSModel, this);
|
|
30
|
+
|
|
31
|
+
this.#liveLocationPromises = new Set();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static instance(opts: {
|
|
35
|
+
forceNew: boolean|null,
|
|
36
|
+
resourceMapping: ResourceMapping|null,
|
|
37
|
+
targetManager: SDK.TargetManager.TargetManager|null,
|
|
38
|
+
} = {forceNew: null, resourceMapping: null, targetManager: null}): CSSWorkspaceBinding {
|
|
39
|
+
const {forceNew, resourceMapping, targetManager} = opts;
|
|
40
|
+
if (!cssWorkspaceBindingInstance || forceNew) {
|
|
41
|
+
if (!resourceMapping || !targetManager) {
|
|
42
|
+
throw new Error(`Unable to create CSSWorkspaceBinding: resourceMapping and targetManager must be provided: ${
|
|
43
|
+
new Error().stack}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
cssWorkspaceBindingInstance = new CSSWorkspaceBinding(resourceMapping, targetManager);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return cssWorkspaceBindingInstance;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static removeInstance(): void {
|
|
53
|
+
cssWorkspaceBindingInstance = undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get modelToInfo(): Map<SDK.CSSModel.CSSModel, ModelInfo> {
|
|
57
|
+
return this.#modelToInfo;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private getCSSModelInfo(cssModel: SDK.CSSModel.CSSModel): ModelInfo {
|
|
61
|
+
return this.#modelToInfo.get(cssModel) as ModelInfo;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
modelAdded(cssModel: SDK.CSSModel.CSSModel): void {
|
|
65
|
+
this.#modelToInfo.set(cssModel, new ModelInfo(cssModel, this.#resourceMapping));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
modelRemoved(cssModel: SDK.CSSModel.CSSModel): void {
|
|
69
|
+
this.getCSSModelInfo(cssModel).dispose();
|
|
70
|
+
this.#modelToInfo.delete(cssModel);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The promise returned by this function is resolved once all *currently*
|
|
75
|
+
* pending LiveLocations are processed.
|
|
76
|
+
*/
|
|
77
|
+
async pendingLiveLocationChangesPromise(): Promise<void> {
|
|
78
|
+
await Promise.all(this.#liveLocationPromises);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private recordLiveLocationChange(promise: Promise<unknown>): void {
|
|
82
|
+
void promise.then(() => {
|
|
83
|
+
this.#liveLocationPromises.delete(promise);
|
|
84
|
+
});
|
|
85
|
+
this.#liveLocationPromises.add(promise);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async updateLocations(header: SDK.CSSStyleSheetHeader.CSSStyleSheetHeader): Promise<void> {
|
|
89
|
+
const updatePromise = this.getCSSModelInfo(header.cssModel()).updateLocations(header);
|
|
90
|
+
this.recordLiveLocationChange(updatePromise);
|
|
91
|
+
await updatePromise;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
createLiveLocation(
|
|
95
|
+
rawLocation: SDK.CSSModel.CSSLocation, updateDelegate: (arg0: LiveLocationInterface) => Promise<void>,
|
|
96
|
+
locationPool: LiveLocationPool): Promise<LiveLocation> {
|
|
97
|
+
const locationPromise =
|
|
98
|
+
this.getCSSModelInfo(rawLocation.cssModel()).createLiveLocation(rawLocation, updateDelegate, locationPool);
|
|
99
|
+
this.recordLiveLocationChange(locationPromise);
|
|
100
|
+
return locationPromise;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
propertyRawLocation(cssProperty: SDK.CSSProperty.CSSProperty, forName: boolean): SDK.CSSModel.CSSLocation|null {
|
|
104
|
+
const style = cssProperty.ownerStyle;
|
|
105
|
+
if (!style || style.type !== SDK.CSSStyleDeclaration.Type.Regular || !style.styleSheetId) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
const header = style.cssModel().styleSheetHeaderForId(style.styleSheetId);
|
|
109
|
+
if (!header) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const range = forName ? cssProperty.nameRange() : cssProperty.valueRange();
|
|
114
|
+
if (!range) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const lineNumber = range.startLine;
|
|
119
|
+
const columnNumber = range.startColumn;
|
|
120
|
+
return new SDK.CSSModel.CSSLocation(
|
|
121
|
+
header, header.lineNumberInSource(lineNumber), header.columnNumberInSource(lineNumber, columnNumber));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
propertyUILocation(cssProperty: SDK.CSSProperty.CSSProperty, forName: boolean): Workspace.UISourceCode.UILocation
|
|
125
|
+
|null {
|
|
126
|
+
const rawLocation = this.propertyRawLocation(cssProperty, forName);
|
|
127
|
+
if (!rawLocation) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
return this.rawLocationToUILocation(rawLocation);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
rawLocationToUILocation(rawLocation: SDK.CSSModel.CSSLocation): Workspace.UISourceCode.UILocation|null {
|
|
134
|
+
return this.getCSSModelInfo(rawLocation.cssModel()).rawLocationToUILocation(rawLocation);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
uiLocationToRawLocations(uiLocation: Workspace.UISourceCode.UILocation): SDK.CSSModel.CSSLocation[] {
|
|
138
|
+
const rawLocations = [];
|
|
139
|
+
for (const modelInfo of this.#modelToInfo.values()) {
|
|
140
|
+
rawLocations.push(...modelInfo.uiLocationToRawLocations(uiLocation));
|
|
141
|
+
}
|
|
142
|
+
return rawLocations;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface SourceMapping {
|
|
147
|
+
rawLocationToUILocation(rawLocation: SDK.CSSModel.CSSLocation): Workspace.UISourceCode.UILocation|null;
|
|
148
|
+
|
|
149
|
+
uiLocationToRawLocations(uiLocation: Workspace.UISourceCode.UILocation): SDK.CSSModel.CSSLocation[];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export class ModelInfo {
|
|
153
|
+
readonly #eventListeners: Common.EventTarget.EventDescriptor[];
|
|
154
|
+
readonly #resourceMapping: ResourceMapping;
|
|
155
|
+
#stylesSourceMapping: StylesSourceMapping;
|
|
156
|
+
#sassSourceMapping: SASSSourceMapping;
|
|
157
|
+
readonly #locations: Platform.MapUtilities.Multimap<SDK.CSSStyleSheetHeader.CSSStyleSheetHeader, LiveLocation>;
|
|
158
|
+
readonly #unboundLocations: Platform.MapUtilities.Multimap<Platform.DevToolsPath.UrlString, LiveLocation>;
|
|
159
|
+
constructor(cssModel: SDK.CSSModel.CSSModel, resourceMapping: ResourceMapping) {
|
|
160
|
+
this.#eventListeners = [
|
|
161
|
+
cssModel.addEventListener(
|
|
162
|
+
SDK.CSSModel.Events.StyleSheetAdded,
|
|
163
|
+
event => {
|
|
164
|
+
void this.styleSheetAdded(event);
|
|
165
|
+
},
|
|
166
|
+
this),
|
|
167
|
+
cssModel.addEventListener(
|
|
168
|
+
SDK.CSSModel.Events.StyleSheetRemoved,
|
|
169
|
+
event => {
|
|
170
|
+
void this.styleSheetRemoved(event);
|
|
171
|
+
},
|
|
172
|
+
this),
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
this.#resourceMapping = resourceMapping;
|
|
176
|
+
this.#stylesSourceMapping = new StylesSourceMapping(cssModel, resourceMapping.workspace);
|
|
177
|
+
const sourceMapManager = cssModel.sourceMapManager();
|
|
178
|
+
this.#sassSourceMapping = new SASSSourceMapping(cssModel.target(), sourceMapManager, resourceMapping.workspace);
|
|
179
|
+
|
|
180
|
+
this.#locations = new Platform.MapUtilities.Multimap();
|
|
181
|
+
this.#unboundLocations = new Platform.MapUtilities.Multimap();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
get locations(): Platform.MapUtilities.Multimap<SDK.CSSStyleSheetHeader.CSSStyleSheetHeader, LiveLocation> {
|
|
185
|
+
return this.#locations;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async createLiveLocation(
|
|
189
|
+
rawLocation: SDK.CSSModel.CSSLocation, updateDelegate: (arg0: LiveLocationInterface) => Promise<void>,
|
|
190
|
+
locationPool: LiveLocationPool): Promise<LiveLocation> {
|
|
191
|
+
const location = new LiveLocation(rawLocation, this, updateDelegate, locationPool);
|
|
192
|
+
const header = rawLocation.header();
|
|
193
|
+
if (header) {
|
|
194
|
+
location.setHeader(header);
|
|
195
|
+
this.#locations.set(header, location);
|
|
196
|
+
await location.update();
|
|
197
|
+
} else {
|
|
198
|
+
this.#unboundLocations.set(rawLocation.url, location);
|
|
199
|
+
}
|
|
200
|
+
return location;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
disposeLocation(location: LiveLocation): void {
|
|
204
|
+
const header = location.header();
|
|
205
|
+
if (header) {
|
|
206
|
+
this.#locations.delete(header, location);
|
|
207
|
+
} else {
|
|
208
|
+
this.#unboundLocations.delete(location.url, location);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
updateLocations(header: SDK.CSSStyleSheetHeader.CSSStyleSheetHeader): Promise<void[]> {
|
|
213
|
+
const promises = [];
|
|
214
|
+
for (const location of this.#locations.get(header)) {
|
|
215
|
+
promises.push(location.update());
|
|
216
|
+
}
|
|
217
|
+
return Promise.all(promises);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
private async styleSheetAdded(
|
|
221
|
+
event: Common.EventTarget.EventTargetEvent<SDK.CSSStyleSheetHeader.CSSStyleSheetHeader>): Promise<void> {
|
|
222
|
+
const header = event.data;
|
|
223
|
+
if (!header.sourceURL) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const promises = [];
|
|
228
|
+
for (const location of this.#unboundLocations.get(header.sourceURL)) {
|
|
229
|
+
location.setHeader(header);
|
|
230
|
+
this.#locations.set(header, location);
|
|
231
|
+
promises.push(location.update());
|
|
232
|
+
}
|
|
233
|
+
await Promise.all(promises);
|
|
234
|
+
this.#unboundLocations.deleteAll(header.sourceURL);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
private async styleSheetRemoved(
|
|
238
|
+
event: Common.EventTarget.EventTargetEvent<SDK.CSSStyleSheetHeader.CSSStyleSheetHeader>): Promise<void> {
|
|
239
|
+
const header = event.data;
|
|
240
|
+
const promises = [];
|
|
241
|
+
for (const location of this.#locations.get(header)) {
|
|
242
|
+
location.setHeader(header);
|
|
243
|
+
this.#unboundLocations.set(location.url, location);
|
|
244
|
+
promises.push(location.update());
|
|
245
|
+
}
|
|
246
|
+
await Promise.all(promises);
|
|
247
|
+
this.#locations.deleteAll(header);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
addSourceMap(sourceUrl: Platform.DevToolsPath.UrlString, sourceMapUrl: Platform.DevToolsPath.UrlString): void {
|
|
251
|
+
this.#stylesSourceMapping.addSourceMap(sourceUrl, sourceMapUrl);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
rawLocationToUILocation(rawLocation: SDK.CSSModel.CSSLocation): Workspace.UISourceCode.UILocation|null {
|
|
255
|
+
let uiLocation: (Workspace.UISourceCode.UILocation|null)|null = null;
|
|
256
|
+
uiLocation = uiLocation || this.#sassSourceMapping.rawLocationToUILocation(rawLocation);
|
|
257
|
+
uiLocation = uiLocation || this.#stylesSourceMapping.rawLocationToUILocation(rawLocation);
|
|
258
|
+
uiLocation = uiLocation || this.#resourceMapping.cssLocationToUILocation(rawLocation);
|
|
259
|
+
return uiLocation;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
uiLocationToRawLocations(uiLocation: Workspace.UISourceCode.UILocation): SDK.CSSModel.CSSLocation[] {
|
|
263
|
+
let rawLocations = this.#sassSourceMapping.uiLocationToRawLocations(uiLocation);
|
|
264
|
+
if (rawLocations.length) {
|
|
265
|
+
return rawLocations;
|
|
266
|
+
}
|
|
267
|
+
rawLocations = this.#stylesSourceMapping.uiLocationToRawLocations(uiLocation);
|
|
268
|
+
if (rawLocations.length) {
|
|
269
|
+
return rawLocations;
|
|
270
|
+
}
|
|
271
|
+
return this.#resourceMapping.uiLocationToCSSLocations(uiLocation);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
dispose(): void {
|
|
275
|
+
Common.EventTarget.removeEventListeners(this.#eventListeners);
|
|
276
|
+
this.#stylesSourceMapping.dispose();
|
|
277
|
+
this.#sassSourceMapping.dispose();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export class LiveLocation extends LiveLocationWithPool {
|
|
282
|
+
readonly url: Platform.DevToolsPath.UrlString;
|
|
283
|
+
readonly #lineNumber: number;
|
|
284
|
+
readonly #columnNumber: number;
|
|
285
|
+
readonly #info: ModelInfo;
|
|
286
|
+
#header: SDK.CSSStyleSheetHeader.CSSStyleSheetHeader|null;
|
|
287
|
+
constructor(
|
|
288
|
+
rawLocation: SDK.CSSModel.CSSLocation, info: ModelInfo,
|
|
289
|
+
updateDelegate: (arg0: LiveLocationInterface) => Promise<void>, locationPool: LiveLocationPool) {
|
|
290
|
+
super(updateDelegate, locationPool);
|
|
291
|
+
this.url = rawLocation.url;
|
|
292
|
+
this.#lineNumber = rawLocation.lineNumber;
|
|
293
|
+
this.#columnNumber = rawLocation.columnNumber;
|
|
294
|
+
this.#info = info;
|
|
295
|
+
this.#header = null;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
header(): SDK.CSSStyleSheetHeader.CSSStyleSheetHeader|null {
|
|
299
|
+
return this.#header;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
setHeader(header: SDK.CSSStyleSheetHeader.CSSStyleSheetHeader|null): void {
|
|
303
|
+
this.#header = header;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
override async uiLocation(): Promise<Workspace.UISourceCode.UILocation|null> {
|
|
307
|
+
if (!this.#header) {
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
const rawLocation = new SDK.CSSModel.CSSLocation(this.#header, this.#lineNumber, this.#columnNumber);
|
|
311
|
+
return CSSWorkspaceBinding.instance().rawLocationToUILocation(rawLocation);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
override dispose(): void {
|
|
315
|
+
super.dispose();
|
|
316
|
+
this.#info.disposeLocation(this);
|
|
317
|
+
}
|
|
318
|
+
}
|