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.
Files changed (132) hide show
  1. package/generate.ts +32 -26
  2. package/index.ts +2 -1
  3. package/lib/extension-api/ExtensionAPI.d.ts +357 -0
  4. package/lib/front_end/models/bindings/CSSWorkspaceBinding.ts +318 -0
  5. package/lib/front_end/models/bindings/CompilerScriptMapping.ts +536 -0
  6. package/lib/front_end/models/bindings/ContentProviderBasedProject.ts +187 -0
  7. package/lib/front_end/models/bindings/DebuggerLanguagePlugins.ts +1197 -0
  8. package/lib/front_end/models/bindings/DebuggerWorkspaceBinding.ts +733 -0
  9. package/lib/front_end/models/bindings/DefaultScriptMapping.ts +141 -0
  10. package/lib/front_end/models/bindings/FileUtils.ts +228 -0
  11. package/lib/front_end/models/bindings/LiveLocation.ts +81 -0
  12. package/lib/front_end/models/bindings/NetworkProject.ts +157 -0
  13. package/lib/front_end/models/bindings/PresentationConsoleMessageHelper.ts +312 -0
  14. package/lib/front_end/models/bindings/ResourceMapping.ts +539 -0
  15. package/lib/front_end/models/bindings/ResourceScriptMapping.ts +491 -0
  16. package/lib/front_end/models/bindings/ResourceUtils.ts +103 -0
  17. package/lib/front_end/models/bindings/SASSSourceMapping.ts +222 -0
  18. package/lib/front_end/models/bindings/StylesSourceMapping.ts +316 -0
  19. package/lib/front_end/models/bindings/TempFile.ts +67 -0
  20. package/lib/front_end/models/bindings/bindings.ts +39 -0
  21. package/lib/front_end/models/source_map_scopes/NamesResolver.ts +765 -0
  22. package/lib/front_end/models/source_map_scopes/ScopeChainModel.ts +84 -0
  23. package/lib/front_end/models/source_map_scopes/source_map_scopes.ts +11 -0
  24. package/lib/front_end/models/stack_trace/StackTrace.ts +53 -0
  25. package/lib/front_end/models/stack_trace/StackTraceImpl.ts +85 -0
  26. package/lib/front_end/models/stack_trace/StackTraceModel.ts +128 -0
  27. package/lib/front_end/models/stack_trace/Trie.ts +163 -0
  28. package/lib/front_end/models/stack_trace/stack_trace.ts +9 -0
  29. package/lib/front_end/models/stack_trace/stack_trace_impl.ts +13 -0
  30. package/lib/front_end/models/trace_source_maps_resolver/SourceMapsResolver.ts +240 -0
  31. package/lib/front_end/models/trace_source_maps_resolver/trace_source_maps_resolver.ts +5 -0
  32. package/lib/front_end/models/workspace/FileManager.ts +97 -0
  33. package/lib/front_end/models/workspace/IgnoreListManager.ts +628 -0
  34. package/lib/front_end/models/workspace/SearchConfig.ts +149 -0
  35. package/lib/front_end/models/workspace/UISourceCode.ts +698 -0
  36. package/lib/front_end/models/workspace/WorkspaceImpl.ts +339 -0
  37. package/lib/front_end/models/workspace/workspace.ts +17 -0
  38. package/lib/front_end/panels/timeline/TimelineUIUtils.ts +1029 -0
  39. package/lib/front_end/panels/timeline/extensions/ExtensionUI.ts +49 -0
  40. package/lib/front_end/panels/timeline/extensions/extensions.ts +9 -0
  41. package/lib/front_end/third_party/codemirror.next/LICENSE +21 -0
  42. package/lib/front_end/third_party/codemirror.next/README.chromium +30 -0
  43. package/lib/front_end/third_party/codemirror.next/bundle-tsconfig.json +24 -0
  44. package/lib/front_end/third_party/codemirror.next/bundle.ts +135 -0
  45. package/lib/front_end/third_party/codemirror.next/chunk/angular.js +2 -0
  46. package/lib/front_end/third_party/codemirror.next/chunk/angular.js.map +1 -0
  47. package/lib/front_end/third_party/codemirror.next/chunk/codemirror.js +2 -0
  48. package/lib/front_end/third_party/codemirror.next/chunk/codemirror.js.map +1 -0
  49. package/lib/front_end/third_party/codemirror.next/chunk/cpp.js +2 -0
  50. package/lib/front_end/third_party/codemirror.next/chunk/cpp.js.map +1 -0
  51. package/lib/front_end/third_party/codemirror.next/chunk/css.js +2 -0
  52. package/lib/front_end/third_party/codemirror.next/chunk/html.js +4 -0
  53. package/lib/front_end/third_party/codemirror.next/chunk/java.js +2 -0
  54. package/lib/front_end/third_party/codemirror.next/chunk/java.js.map +1 -0
  55. package/lib/front_end/third_party/codemirror.next/chunk/javascript.js +2 -0
  56. package/lib/front_end/third_party/codemirror.next/chunk/legacy.js +2 -0
  57. package/lib/front_end/third_party/codemirror.next/chunk/legacy.js.map +1 -0
  58. package/lib/front_end/third_party/codemirror.next/chunk/less.js +2 -0
  59. package/lib/front_end/third_party/codemirror.next/chunk/less.js.map +1 -0
  60. package/lib/front_end/third_party/codemirror.next/chunk/markdown.js +2 -0
  61. package/lib/front_end/third_party/codemirror.next/chunk/markdown.js.map +1 -0
  62. package/lib/front_end/third_party/codemirror.next/chunk/php.js +2 -0
  63. package/lib/front_end/third_party/codemirror.next/chunk/php.js.map +1 -0
  64. package/lib/front_end/third_party/codemirror.next/chunk/python.js +2 -0
  65. package/lib/front_end/third_party/codemirror.next/chunk/python.js.map +1 -0
  66. package/lib/front_end/third_party/codemirror.next/chunk/sass.js +2 -0
  67. package/lib/front_end/third_party/codemirror.next/chunk/sass.js.map +1 -0
  68. package/lib/front_end/third_party/codemirror.next/chunk/svelte.js +2 -0
  69. package/lib/front_end/third_party/codemirror.next/chunk/svelte.js.map +1 -0
  70. package/lib/front_end/third_party/codemirror.next/chunk/vue.js +2 -0
  71. package/lib/front_end/third_party/codemirror.next/chunk/vue.js.map +1 -0
  72. package/lib/front_end/third_party/codemirror.next/chunk/wast.js +2 -0
  73. package/lib/front_end/third_party/codemirror.next/chunk/wast.js.map +1 -0
  74. package/lib/front_end/third_party/codemirror.next/chunk/xml.js +2 -0
  75. package/lib/front_end/third_party/codemirror.next/chunk/xml.js.map +1 -0
  76. package/lib/front_end/third_party/codemirror.next/codemirror.next.d.ts +8057 -0
  77. package/lib/front_end/third_party/codemirror.next/codemirror.next.js +2 -0
  78. package/lib/front_end/third_party/codemirror.next/codemirror.next.js.map +1 -0
  79. package/lib/front_end/third_party/codemirror.next/package.json +43 -0
  80. package/lib/front_end/third_party/codemirror.next/rebuild.sh +6 -0
  81. package/lib/front_end/third_party/codemirror.next/rollup.config.mjs +49 -0
  82. package/lib/front_end/third_party/source-map-scopes-codec/LICENSE +26 -0
  83. package/lib/front_end/third_party/source-map-scopes-codec/README.chromium +31 -0
  84. package/lib/front_end/third_party/source-map-scopes-codec/package/CONTRIBUTING.md +33 -0
  85. package/lib/front_end/third_party/source-map-scopes-codec/package/LICENSE +26 -0
  86. package/lib/front_end/third_party/source-map-scopes-codec/package/README.md +64 -0
  87. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts +62 -0
  88. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts.map +1 -0
  89. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts +37 -0
  90. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts.map +1 -0
  91. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts +29 -0
  92. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts.map +1 -0
  93. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts +8 -0
  94. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts.map +1 -0
  95. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts +6 -0
  96. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts.map +1 -0
  97. package/lib/front_end/third_party/source-map-scopes-codec/package/deno.json +21 -0
  98. package/lib/front_end/third_party/source-map-scopes-codec/package/package.json +14 -0
  99. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js +196 -0
  100. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js.map +1 -0
  101. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.ts +262 -0
  102. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js +235 -0
  103. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js.map +1 -0
  104. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.ts +359 -0
  105. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.js +39 -0
  106. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.js.map +1 -0
  107. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.ts +53 -0
  108. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js +438 -0
  109. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js.map +1 -0
  110. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.ts +539 -0
  111. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js +23 -0
  112. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js.map +1 -0
  113. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.ts +35 -0
  114. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js +257 -0
  115. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js.map +1 -0
  116. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.ts +348 -0
  117. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.js +8 -0
  118. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.js.map +1 -0
  119. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.ts +20 -0
  120. package/lib/front_end/third_party/source-map-scopes-codec/package/src/scopes-tsconfig.json +8 -0
  121. package/lib/front_end/third_party/source-map-scopes-codec/package/src/scopes.d.ts +184 -0
  122. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.js +9 -0
  123. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.js.map +1 -0
  124. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.ts +12 -0
  125. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.js +82 -0
  126. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.js.map +1 -0
  127. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.ts +99 -0
  128. package/lib/front_end/third_party/source-map-scopes-codec/source-map-scopes-codec.ts +5 -0
  129. package/lib/front_end/ui/legacy/theme_support/ThemeSupport.ts +222 -0
  130. package/lib/front_end/ui/legacy/theme_support/theme_support.ts +5 -0
  131. package/package.json +5 -5
  132. package/patches/chrome-devtools-frontend+1.0.1533544.patch +1549 -20
@@ -0,0 +1,733 @@
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 * as Protocol from '../../generated/protocol.js';
9
+ import type * as StackTrace from '../stack_trace/stack_trace.js';
10
+ // eslint-disable-next-line @devtools/es-modules-import
11
+ import * as StackTraceImpl from '../stack_trace/stack_trace_impl.js';
12
+ import type * as TextUtils from '../text_utils/text_utils.js';
13
+ import * as Workspace from '../workspace/workspace.js';
14
+
15
+ import {CompilerScriptMapping} from './CompilerScriptMapping.js';
16
+ import {DebuggerLanguagePluginManager} from './DebuggerLanguagePlugins.js';
17
+ import {DefaultScriptMapping} from './DefaultScriptMapping.js';
18
+ import {type LiveLocation, type LiveLocationPool, LiveLocationWithPool} from './LiveLocation.js';
19
+ import {NetworkProject} from './NetworkProject.js';
20
+ import type {ResourceMapping} from './ResourceMapping.js';
21
+ import {type ResourceScriptFile, ResourceScriptMapping} from './ResourceScriptMapping.js';
22
+
23
+ let debuggerWorkspaceBindingInstance: DebuggerWorkspaceBinding|undefined;
24
+
25
+ export class DebuggerWorkspaceBinding implements SDK.TargetManager.SDKModelObserver<SDK.DebuggerModel.DebuggerModel> {
26
+ readonly resourceMapping: ResourceMapping;
27
+ readonly #debuggerModelToData: Map<SDK.DebuggerModel.DebuggerModel, ModelData>;
28
+ readonly #liveLocationPromises: Set<Promise<void|Location|StackTraceTopFrameLocation|null>>;
29
+ readonly pluginManager: DebuggerLanguagePluginManager;
30
+
31
+ private constructor(
32
+ resourceMapping: ResourceMapping, targetManager: SDK.TargetManager.TargetManager,
33
+ ignoreListManager: Workspace.IgnoreListManager.IgnoreListManager) {
34
+ this.resourceMapping = resourceMapping;
35
+
36
+ this.#debuggerModelToData = new Map();
37
+ targetManager.addModelListener(
38
+ SDK.DebuggerModel.DebuggerModel, SDK.DebuggerModel.Events.GlobalObjectCleared, this.globalObjectCleared, this);
39
+ targetManager.addModelListener(
40
+ SDK.DebuggerModel.DebuggerModel, SDK.DebuggerModel.Events.DebuggerResumed, this.debuggerResumed, this);
41
+ targetManager.observeModels(SDK.DebuggerModel.DebuggerModel, this);
42
+ ignoreListManager.addEventListener(
43
+ Workspace.IgnoreListManager.Events.IGNORED_SCRIPT_RANGES_UPDATED, event => this.updateLocations(event.data));
44
+
45
+ this.#liveLocationPromises = new Set();
46
+
47
+ this.pluginManager = new DebuggerLanguagePluginManager(targetManager, resourceMapping.workspace, this);
48
+ }
49
+
50
+ setFunctionRanges(
51
+ uiSourceCode: Workspace.UISourceCode.UISourceCode,
52
+ ranges: SDK.SourceMapFunctionRanges.NamedFunctionRange[]): void {
53
+ for (const modelData of this.#debuggerModelToData.values()) {
54
+ modelData.compilerMapping.setFunctionRanges(uiSourceCode, ranges);
55
+ }
56
+ }
57
+
58
+ static instance(opts: {
59
+ forceNew: boolean|null,
60
+ resourceMapping: ResourceMapping|null,
61
+ targetManager: SDK.TargetManager.TargetManager|null,
62
+ ignoreListManager: Workspace.IgnoreListManager.IgnoreListManager|null,
63
+ } = {forceNew: null, resourceMapping: null, targetManager: null, ignoreListManager: null}): DebuggerWorkspaceBinding {
64
+ const {forceNew, resourceMapping, targetManager, ignoreListManager} = opts;
65
+ if (!debuggerWorkspaceBindingInstance || forceNew) {
66
+ if (!resourceMapping || !targetManager || !ignoreListManager) {
67
+ throw new Error(
68
+ `Unable to create DebuggerWorkspaceBinding: resourceMapping, targetManager and IgnoreLIstManager must be provided: ${
69
+ new Error().stack}`);
70
+ }
71
+
72
+ debuggerWorkspaceBindingInstance =
73
+ new DebuggerWorkspaceBinding(resourceMapping, targetManager, ignoreListManager);
74
+ }
75
+
76
+ return debuggerWorkspaceBindingInstance;
77
+ }
78
+
79
+ static removeInstance(): void {
80
+ debuggerWorkspaceBindingInstance = undefined;
81
+ }
82
+
83
+ private async computeAutoStepRanges(mode: SDK.DebuggerModel.StepMode, callFrame: SDK.DebuggerModel.CallFrame):
84
+ Promise<SDK.DebuggerModel.LocationRange[]> {
85
+ function contained(location: SDK.DebuggerModel.Location, range: SDK.DebuggerModel.LocationRange): boolean {
86
+ const {start, end} = range;
87
+ if (start.scriptId !== location.scriptId) {
88
+ return false;
89
+ }
90
+ if (location.lineNumber < start.lineNumber || location.lineNumber > end.lineNumber) {
91
+ return false;
92
+ }
93
+ if (location.lineNumber === start.lineNumber && location.columnNumber < start.columnNumber) {
94
+ return false;
95
+ }
96
+ if (location.lineNumber === end.lineNumber && location.columnNumber >= end.columnNumber) {
97
+ return false;
98
+ }
99
+ return true;
100
+ }
101
+
102
+ const rawLocation = callFrame.location();
103
+ if (!rawLocation) {
104
+ return [];
105
+ }
106
+ const pluginManager = this.pluginManager;
107
+ let ranges: SDK.DebuggerModel.LocationRange[] = [];
108
+ if (mode === SDK.DebuggerModel.StepMode.STEP_OUT) {
109
+ // Step out of inline function.
110
+ return await pluginManager.getInlinedFunctionRanges(rawLocation);
111
+ }
112
+ const uiLocation = await pluginManager.rawLocationToUILocation(rawLocation);
113
+ if (uiLocation) {
114
+ ranges = await pluginManager.uiLocationToRawLocationRanges(
115
+ uiLocation.uiSourceCode, uiLocation.lineNumber, uiLocation.columnNumber) ||
116
+ [];
117
+ // TODO(bmeurer): Remove the {rawLocation} from the {ranges}?
118
+ ranges = ranges.filter(range => contained(rawLocation, range));
119
+ if (mode === SDK.DebuggerModel.StepMode.STEP_OVER) {
120
+ // Step over an inlined function.
121
+ ranges = ranges.concat(await pluginManager.getInlinedCalleesRanges(rawLocation));
122
+ }
123
+ return ranges;
124
+ }
125
+
126
+ const compilerMapping = this.#debuggerModelToData.get(rawLocation.debuggerModel)?.compilerMapping;
127
+ if (!compilerMapping) {
128
+ return [];
129
+ }
130
+ ranges = compilerMapping.getLocationRangesForSameSourceLocation(rawLocation);
131
+ ranges = ranges.filter(range => contained(rawLocation, range));
132
+ return ranges;
133
+ }
134
+
135
+ modelAdded(debuggerModel: SDK.DebuggerModel.DebuggerModel): void {
136
+ debuggerModel.setBeforePausedCallback(this.shouldPause.bind(this));
137
+ this.#debuggerModelToData.set(debuggerModel, new ModelData(debuggerModel, this));
138
+ debuggerModel.setComputeAutoStepRangesCallback(this.computeAutoStepRanges.bind(this));
139
+ }
140
+
141
+ modelRemoved(debuggerModel: SDK.DebuggerModel.DebuggerModel): void {
142
+ debuggerModel.setComputeAutoStepRangesCallback(null);
143
+ const modelData = this.#debuggerModelToData.get(debuggerModel);
144
+ if (modelData) {
145
+ modelData.dispose();
146
+ this.#debuggerModelToData.delete(debuggerModel);
147
+ }
148
+ }
149
+
150
+ /**
151
+ * The promise returned by this function is resolved once all *currently*
152
+ * pending LiveLocations are processed.
153
+ */
154
+ async pendingLiveLocationChangesPromise(): Promise<void|Location|StackTraceTopFrameLocation|null> {
155
+ await Promise.all(this.#liveLocationPromises);
156
+ }
157
+
158
+ private recordLiveLocationChange(promise: Promise<void|Location|StackTraceTopFrameLocation|null>): void {
159
+ void promise.then(() => {
160
+ this.#liveLocationPromises.delete(promise);
161
+ });
162
+ this.#liveLocationPromises.add(promise);
163
+ }
164
+
165
+ async updateLocations(script: SDK.Script.Script): Promise<void> {
166
+ const updatePromises = [script.target()
167
+ .model(StackTraceImpl.StackTraceModel.StackTraceModel)
168
+ ?.scriptInfoChanged(script, this.#translateRawFrames.bind(this))];
169
+
170
+ const modelData = this.#debuggerModelToData.get(script.debuggerModel);
171
+ if (modelData) {
172
+ const updatePromise = modelData.updateLocations(script);
173
+ this.recordLiveLocationChange(updatePromise);
174
+ updatePromises.push(updatePromise);
175
+ }
176
+
177
+ await Promise.all(updatePromises);
178
+ }
179
+
180
+ async createStackTraceFromProtocolRuntime(stackTrace: Protocol.Runtime.StackTrace, target: SDK.Target.Target):
181
+ Promise<StackTrace.StackTrace.StackTrace> {
182
+ const model =
183
+ target.model(StackTraceImpl.StackTraceModel.StackTraceModel) as StackTraceImpl.StackTraceModel.StackTraceModel;
184
+ return await model.createFromProtocolRuntime(stackTrace, this.#translateRawFrames.bind(this));
185
+ }
186
+
187
+ async createLiveLocation(
188
+ rawLocation: SDK.DebuggerModel.Location, updateDelegate: (arg0: LiveLocation) => Promise<void>,
189
+ locationPool: LiveLocationPool): Promise<Location|null> {
190
+ const modelData = this.#debuggerModelToData.get(rawLocation.debuggerModel);
191
+ if (!modelData) {
192
+ return null;
193
+ }
194
+ const liveLocationPromise = modelData.createLiveLocation(rawLocation, updateDelegate, locationPool);
195
+ this.recordLiveLocationChange(liveLocationPromise);
196
+ return await liveLocationPromise;
197
+ }
198
+
199
+ async createStackTraceTopFrameLiveLocation(
200
+ rawLocations: SDK.DebuggerModel.Location[], updateDelegate: (arg0: LiveLocation) => Promise<void>,
201
+ locationPool: LiveLocationPool): Promise<LiveLocation> {
202
+ console.assert(rawLocations.length > 0);
203
+ const locationPromise =
204
+ StackTraceTopFrameLocation.createStackTraceTopFrameLocation(rawLocations, this, updateDelegate, locationPool);
205
+ this.recordLiveLocationChange(locationPromise);
206
+ return await locationPromise;
207
+ }
208
+
209
+ async createCallFrameLiveLocation(
210
+ location: SDK.DebuggerModel.Location, updateDelegate: (arg0: LiveLocation) => Promise<void>,
211
+ locationPool: LiveLocationPool): Promise<Location|null> {
212
+ const script = location.script();
213
+ if (!script) {
214
+ return null;
215
+ }
216
+ const debuggerModel = location.debuggerModel;
217
+ const liveLocationPromise = this.createLiveLocation(location, updateDelegate, locationPool);
218
+ this.recordLiveLocationChange(liveLocationPromise);
219
+ const liveLocation = await liveLocationPromise;
220
+ if (!liveLocation) {
221
+ return null;
222
+ }
223
+ this.registerCallFrameLiveLocation(debuggerModel, liveLocation);
224
+ return liveLocation;
225
+ }
226
+
227
+ async rawLocationToUILocation(rawLocation: SDK.DebuggerModel.Location):
228
+ Promise<Workspace.UISourceCode.UILocation|null> {
229
+ const uiLocation = await this.pluginManager.rawLocationToUILocation(rawLocation);
230
+ if (uiLocation) {
231
+ return uiLocation;
232
+ }
233
+ const modelData = this.#debuggerModelToData.get(rawLocation.debuggerModel);
234
+ return modelData ? modelData.rawLocationToUILocation(rawLocation) : null;
235
+ }
236
+
237
+ uiSourceCodeForSourceMapSourceURL(
238
+ debuggerModel: SDK.DebuggerModel.DebuggerModel, url: Platform.DevToolsPath.UrlString,
239
+ isContentScript: boolean): Workspace.UISourceCode.UISourceCode|null {
240
+ const modelData = this.#debuggerModelToData.get(debuggerModel);
241
+ if (!modelData) {
242
+ return null;
243
+ }
244
+ return modelData.compilerMapping.uiSourceCodeForURL(url, isContentScript);
245
+ }
246
+
247
+ async uiSourceCodeForSourceMapSourceURLPromise(
248
+ debuggerModel: SDK.DebuggerModel.DebuggerModel, url: Platform.DevToolsPath.UrlString,
249
+ isContentScript: boolean): Promise<Workspace.UISourceCode.UISourceCode> {
250
+ const uiSourceCode = this.uiSourceCodeForSourceMapSourceURL(debuggerModel, url, isContentScript);
251
+ return await (uiSourceCode || this.waitForUISourceCodeAdded(url, debuggerModel.target()));
252
+ }
253
+
254
+ async uiSourceCodeForDebuggerLanguagePluginSourceURLPromise(
255
+ debuggerModel: SDK.DebuggerModel.DebuggerModel,
256
+ url: Platform.DevToolsPath.UrlString): Promise<Workspace.UISourceCode.UISourceCode|null> {
257
+ const uiSourceCode = this.pluginManager.uiSourceCodeForURL(debuggerModel, url);
258
+ return await (uiSourceCode || this.waitForUISourceCodeAdded(url, debuggerModel.target()));
259
+ }
260
+
261
+ uiSourceCodeForScript(script: SDK.Script.Script): Workspace.UISourceCode.UISourceCode|null {
262
+ const modelData = this.#debuggerModelToData.get(script.debuggerModel);
263
+ if (!modelData) {
264
+ return null;
265
+ }
266
+ return modelData.uiSourceCodeForScript(script);
267
+ }
268
+
269
+ waitForUISourceCodeAdded(url: Platform.DevToolsPath.UrlString, target: SDK.Target.Target):
270
+ Promise<Workspace.UISourceCode.UISourceCode> {
271
+ return new Promise(resolve => {
272
+ const workspace = Workspace.Workspace.WorkspaceImpl.instance();
273
+ const descriptor = workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeAdded, event => {
274
+ const uiSourceCode = event.data;
275
+ if (uiSourceCode.url() === url && NetworkProject.targetForUISourceCode(uiSourceCode) === target) {
276
+ workspace.removeEventListener(Workspace.Workspace.Events.UISourceCodeAdded, descriptor.listener);
277
+ resolve(uiSourceCode);
278
+ }
279
+ });
280
+ });
281
+ }
282
+
283
+ async uiLocationToRawLocations(
284
+ uiSourceCode: Workspace.UISourceCode.UISourceCode, lineNumber: number,
285
+ columnNumber?: number): Promise<SDK.DebuggerModel.Location[]> {
286
+ const locations = await this.pluginManager.uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber);
287
+ if (locations) {
288
+ return locations;
289
+ }
290
+ for (const modelData of this.#debuggerModelToData.values()) {
291
+ const locations = modelData.uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber);
292
+ if (locations.length) {
293
+ return locations;
294
+ }
295
+ }
296
+ return [];
297
+ }
298
+
299
+ /**
300
+ * Computes all the raw location ranges that intersect with the {@link textRange} in the given
301
+ * {@link uiSourceCode}. The reverse mappings of the returned ranges must not be fully contained
302
+ * with the {@link textRange} and it's the responsibility of the caller to appropriately filter or
303
+ * clamp if desired.
304
+ *
305
+ * It's important to note that for a contiguous range in the {@link uiSourceCode} there can be a
306
+ * variety of non-contiguous raw location ranges that intersect with the {@link textRange}. A
307
+ * simple example is that of an HTML document with multiple inline `<script>`s in the same line,
308
+ * so just asking for the raw locations in this single line will return a set of location ranges
309
+ * in different scripts.
310
+ *
311
+ * This method returns an empty array if this {@link uiSourceCode} is not provided by any of the
312
+ * mappings for this instance.
313
+ *
314
+ * @param uiSourceCode the {@link UISourceCode} to which the {@link textRange} belongs.
315
+ * @param textRange the text range in terms of the UI.
316
+ * @returns the list of raw location ranges that intersect with the text range or `[]` if
317
+ * the {@link uiSourceCode} does not belong to this instance.
318
+ */
319
+ async uiLocationRangeToRawLocationRanges(
320
+ uiSourceCode: Workspace.UISourceCode.UISourceCode,
321
+ textRange: TextUtils.TextRange.TextRange): Promise<SDK.DebuggerModel.LocationRange[]> {
322
+ const ranges = await this.pluginManager.uiLocationRangeToRawLocationRanges(uiSourceCode, textRange);
323
+ if (ranges) {
324
+ return ranges;
325
+ }
326
+ for (const modelData of this.#debuggerModelToData.values()) {
327
+ const ranges = modelData.uiLocationRangeToRawLocationRanges(uiSourceCode, textRange);
328
+ if (ranges) {
329
+ return ranges;
330
+ }
331
+ }
332
+ return [];
333
+ }
334
+
335
+ async normalizeUILocation(uiLocation: Workspace.UISourceCode.UILocation): Promise<Workspace.UISourceCode.UILocation> {
336
+ const rawLocations =
337
+ await this.uiLocationToRawLocations(uiLocation.uiSourceCode, uiLocation.lineNumber, uiLocation.columnNumber);
338
+ for (const location of rawLocations) {
339
+ const uiLocationCandidate = await this.rawLocationToUILocation(location);
340
+ if (uiLocationCandidate) {
341
+ return uiLocationCandidate;
342
+ }
343
+ }
344
+ return uiLocation;
345
+ }
346
+
347
+ /**
348
+ * Computes the set of lines in the {@link uiSourceCode} that map to scripts by either looking at
349
+ * the debug info (if any) or checking for inline scripts within documents. If this set cannot be
350
+ * computed or all the lines in the {@link uiSourceCode} correspond to lines in a script, `null`
351
+ * is returned here.
352
+ *
353
+ * @param uiSourceCode the source entity.
354
+ * @returns a set of known mapped lines for {@link uiSourceCode} or `null` if it's impossible to
355
+ * determine the set or the {@link uiSourceCode} does not map to or include any scripts.
356
+ */
357
+ async getMappedLines(uiSourceCode: Workspace.UISourceCode.UISourceCode): Promise<Set<number>|null> {
358
+ for (const modelData of this.#debuggerModelToData.values()) {
359
+ const mappedLines = modelData.getMappedLines(uiSourceCode);
360
+ if (mappedLines !== null) {
361
+ return mappedLines;
362
+ }
363
+ }
364
+ return await this.pluginManager.getMappedLines(uiSourceCode);
365
+ }
366
+
367
+ scriptFile(uiSourceCode: Workspace.UISourceCode.UISourceCode, debuggerModel: SDK.DebuggerModel.DebuggerModel):
368
+ ResourceScriptFile|null {
369
+ const modelData = this.#debuggerModelToData.get(debuggerModel);
370
+ return modelData ? modelData.getResourceScriptMapping().scriptFile(uiSourceCode) : null;
371
+ }
372
+
373
+ scriptsForUISourceCode(uiSourceCode: Workspace.UISourceCode.UISourceCode): SDK.Script.Script[] {
374
+ const scripts = new Set<SDK.Script.Script>();
375
+ this.pluginManager.scriptsForUISourceCode(uiSourceCode).forEach(script => scripts.add(script));
376
+ for (const modelData of this.#debuggerModelToData.values()) {
377
+ const resourceScriptFile = modelData.getResourceScriptMapping().scriptFile(uiSourceCode);
378
+ if (resourceScriptFile?.script) {
379
+ scripts.add(resourceScriptFile.script);
380
+ }
381
+ modelData.compilerMapping.scriptsForUISourceCode(uiSourceCode).forEach(script => scripts.add(script));
382
+ }
383
+ return [...scripts];
384
+ }
385
+
386
+ supportsConditionalBreakpoints(uiSourceCode: Workspace.UISourceCode.UISourceCode): boolean {
387
+ const scripts = this.pluginManager.scriptsForUISourceCode(uiSourceCode);
388
+ return scripts.every(script => script.isJavaScript());
389
+ }
390
+
391
+ private globalObjectCleared(event: Common.EventTarget.EventTargetEvent<SDK.DebuggerModel.DebuggerModel>): void {
392
+ this.reset(event.data);
393
+ }
394
+
395
+ private reset(debuggerModel: SDK.DebuggerModel.DebuggerModel): void {
396
+ const modelData = this.#debuggerModelToData.get(debuggerModel);
397
+ if (!modelData) {
398
+ return;
399
+ }
400
+ for (const location of modelData.callFrameLocations.values()) {
401
+ this.removeLiveLocation(location);
402
+ }
403
+ modelData.callFrameLocations.clear();
404
+ }
405
+
406
+ resetForTest(target: SDK.Target.Target): void {
407
+ const debuggerModel = (target.model(SDK.DebuggerModel.DebuggerModel) as SDK.DebuggerModel.DebuggerModel);
408
+ const modelData = this.#debuggerModelToData.get(debuggerModel);
409
+ if (modelData) {
410
+ modelData.getResourceScriptMapping().resetForTest();
411
+ }
412
+ }
413
+
414
+ private registerCallFrameLiveLocation(debuggerModel: SDK.DebuggerModel.DebuggerModel, location: Location): void {
415
+ const modelData = this.#debuggerModelToData.get(debuggerModel);
416
+ if (modelData) {
417
+ const locations = modelData.callFrameLocations;
418
+ locations.add(location);
419
+ }
420
+ }
421
+
422
+ removeLiveLocation(location: Location): void {
423
+ const modelData = this.#debuggerModelToData.get(location.rawLocation.debuggerModel);
424
+ if (modelData) {
425
+ modelData.disposeLocation(location);
426
+ }
427
+ }
428
+
429
+ private debuggerResumed(event: Common.EventTarget.EventTargetEvent<SDK.DebuggerModel.DebuggerModel>): void {
430
+ this.reset(event.data);
431
+ }
432
+
433
+ private async shouldPause(
434
+ debuggerPausedDetails: SDK.DebuggerModel.DebuggerPausedDetails,
435
+ autoSteppingContext: SDK.DebuggerModel.Location|null): Promise<boolean> {
436
+ // This function returns false if the debugger should continue stepping
437
+ const {callFrames: [frame]} = debuggerPausedDetails;
438
+ if (!frame) {
439
+ return false;
440
+ }
441
+ const functionLocation = frame.functionLocation();
442
+ if (!autoSteppingContext || debuggerPausedDetails.reason !== Protocol.Debugger.PausedEventReason.Step ||
443
+ !functionLocation || !frame.script.isWasm() || !Common.Settings.moduleSetting('wasm-auto-stepping').get() ||
444
+ !this.pluginManager.hasPluginForScript(frame.script)) {
445
+ return true;
446
+ }
447
+ const uiLocation = await this.pluginManager.rawLocationToUILocation(frame.location());
448
+ if (uiLocation) {
449
+ return true;
450
+ }
451
+
452
+ return autoSteppingContext.script() !== functionLocation.script() ||
453
+ autoSteppingContext.columnNumber !== functionLocation.columnNumber ||
454
+ autoSteppingContext.lineNumber !== functionLocation.lineNumber;
455
+ }
456
+
457
+ async #translateRawFrames(frames: readonly StackTraceImpl.Trie.RawFrame[], target: SDK.Target.Target):
458
+ ReturnType<StackTraceImpl.StackTraceModel.TranslateRawFrames> {
459
+ const rawFrames = frames.slice(0);
460
+ const translatedFrames: Awaited<ReturnType<StackTraceImpl.StackTraceModel.TranslateRawFrames>> = [];
461
+ while (rawFrames.length) {
462
+ await this.#translateRawFramesStep(rawFrames, translatedFrames, target);
463
+ }
464
+ return translatedFrames;
465
+ }
466
+
467
+ async #translateRawFramesStep(
468
+ rawFrames: StackTraceImpl.Trie.RawFrame[],
469
+ translatedFrames: Awaited<ReturnType<StackTraceImpl.StackTraceModel.TranslateRawFrames>>,
470
+ target: SDK.Target.Target): Promise<void> {
471
+ if (await this.pluginManager.translateRawFramesStep(rawFrames, translatedFrames, target)) {
472
+ return;
473
+ }
474
+
475
+ const modelData =
476
+ this.#debuggerModelToData.get(target.model(SDK.DebuggerModel.DebuggerModel) as SDK.DebuggerModel.DebuggerModel);
477
+ if (modelData) {
478
+ modelData.translateRawFramesStep(rawFrames, translatedFrames);
479
+ return;
480
+ }
481
+
482
+ const frame = rawFrames.shift() as StackTraceImpl.Trie.RawFrame;
483
+ const {url, lineNumber, columnNumber, functionName} = frame;
484
+ translatedFrames.push([{url, line: lineNumber, column: columnNumber, name: functionName}]);
485
+ }
486
+ }
487
+
488
+ class ModelData {
489
+ readonly #debuggerModel: SDK.DebuggerModel.DebuggerModel;
490
+ readonly #debuggerWorkspaceBinding: DebuggerWorkspaceBinding;
491
+ callFrameLocations: Set<Location>;
492
+ #defaultMapping: DefaultScriptMapping;
493
+ readonly #resourceMapping: ResourceMapping;
494
+ #resourceScriptMapping: ResourceScriptMapping;
495
+ readonly compilerMapping: CompilerScriptMapping;
496
+ readonly #locations: Platform.MapUtilities.Multimap<string, Location>;
497
+
498
+ constructor(debuggerModel: SDK.DebuggerModel.DebuggerModel, debuggerWorkspaceBinding: DebuggerWorkspaceBinding) {
499
+ this.#debuggerModel = debuggerModel;
500
+ this.#debuggerWorkspaceBinding = debuggerWorkspaceBinding;
501
+
502
+ this.callFrameLocations = new Set();
503
+
504
+ const {workspace} = debuggerWorkspaceBinding.resourceMapping;
505
+ this.#defaultMapping = new DefaultScriptMapping(debuggerModel, workspace, debuggerWorkspaceBinding);
506
+ this.#resourceMapping = debuggerWorkspaceBinding.resourceMapping;
507
+ this.#resourceScriptMapping = new ResourceScriptMapping(debuggerModel, workspace, debuggerWorkspaceBinding);
508
+ this.compilerMapping = new CompilerScriptMapping(debuggerModel, workspace, debuggerWorkspaceBinding);
509
+
510
+ this.#locations = new Platform.MapUtilities.Multimap();
511
+ }
512
+
513
+ async createLiveLocation(
514
+ rawLocation: SDK.DebuggerModel.Location, updateDelegate: (arg0: LiveLocation) => Promise<void>,
515
+ locationPool: LiveLocationPool): Promise<Location> {
516
+ console.assert(rawLocation.scriptId !== '');
517
+ const scriptId = rawLocation.scriptId;
518
+ const location = new Location(scriptId, rawLocation, this.#debuggerWorkspaceBinding, updateDelegate, locationPool);
519
+ this.#locations.set(scriptId, location);
520
+ await location.update();
521
+ return location;
522
+ }
523
+
524
+ disposeLocation(location: Location): void {
525
+ this.#locations.delete(location.scriptId, location);
526
+ }
527
+
528
+ async updateLocations(script: SDK.Script.Script): Promise<void> {
529
+ const promises = [];
530
+ for (const location of this.#locations.get(script.scriptId)) {
531
+ promises.push(location.update());
532
+ }
533
+ await Promise.all(promises);
534
+ }
535
+
536
+ rawLocationToUILocation(rawLocation: SDK.DebuggerModel.Location): Workspace.UISourceCode.UILocation|null {
537
+ let uiLocation = this.compilerMapping.rawLocationToUILocation(rawLocation);
538
+ uiLocation = uiLocation || this.#resourceScriptMapping.rawLocationToUILocation(rawLocation);
539
+ uiLocation = uiLocation || this.#resourceMapping.jsLocationToUILocation(rawLocation);
540
+ uiLocation = uiLocation || this.#defaultMapping.rawLocationToUILocation(rawLocation);
541
+ return uiLocation;
542
+ }
543
+
544
+ uiSourceCodeForScript(script: SDK.Script.Script): Workspace.UISourceCode.UISourceCode|null {
545
+ let uiSourceCode: Workspace.UISourceCode.UISourceCode|null = null;
546
+ uiSourceCode = uiSourceCode || this.#resourceScriptMapping.uiSourceCodeForScript(script);
547
+ uiSourceCode = uiSourceCode || this.#resourceMapping.uiSourceCodeForScript(script);
548
+ uiSourceCode = uiSourceCode || this.#defaultMapping.uiSourceCodeForScript(script);
549
+ return uiSourceCode;
550
+ }
551
+
552
+ uiLocationToRawLocations(
553
+ uiSourceCode: Workspace.UISourceCode.UISourceCode, lineNumber: number,
554
+ columnNumber: number|undefined = 0): SDK.DebuggerModel.Location[] {
555
+ // TODO(crbug.com/1153123): Revisit the `#columnNumber = 0` and also preserve `undefined` for source maps?
556
+ let locations = this.compilerMapping.uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber);
557
+ locations = locations.length ?
558
+ locations :
559
+ this.#resourceScriptMapping.uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber);
560
+ locations = locations.length ?
561
+ locations :
562
+ this.#resourceMapping.uiLocationToJSLocations(uiSourceCode, lineNumber, columnNumber);
563
+ locations = locations.length ?
564
+ locations :
565
+ this.#defaultMapping.uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber);
566
+ return locations;
567
+ }
568
+
569
+ uiLocationRangeToRawLocationRanges(
570
+ uiSourceCode: Workspace.UISourceCode.UISourceCode,
571
+ textRange: TextUtils.TextRange.TextRange): SDK.DebuggerModel.LocationRange[]|null {
572
+ let ranges = this.compilerMapping.uiLocationRangeToRawLocationRanges(uiSourceCode, textRange);
573
+ ranges ??= this.#resourceScriptMapping.uiLocationRangeToRawLocationRanges(uiSourceCode, textRange);
574
+ ranges ??= this.#resourceMapping.uiLocationRangeToJSLocationRanges(uiSourceCode, textRange);
575
+ ranges ??= this.#defaultMapping.uiLocationRangeToRawLocationRanges(uiSourceCode, textRange);
576
+ return ranges;
577
+ }
578
+
579
+ translateRawFramesStep(
580
+ rawFrames: StackTraceImpl.Trie.RawFrame[],
581
+ translatedFrames: Awaited<ReturnType<StackTraceImpl.StackTraceModel.TranslateRawFrames>>): void {
582
+ if (!this.compilerMapping.translateRawFramesStep(rawFrames, translatedFrames)) {
583
+ this.#defaultTranslateRawFramesStep(rawFrames, translatedFrames);
584
+ }
585
+ }
586
+
587
+ /** The default implementation translates one frame at a time and only translates the location, but not the function name. */
588
+ #defaultTranslateRawFramesStep(
589
+ rawFrames: StackTraceImpl.Trie.RawFrame[],
590
+ translatedFrames: Awaited<ReturnType<StackTraceImpl.StackTraceModel.TranslateRawFrames>>): void {
591
+ const frame = rawFrames.shift() as StackTraceImpl.Trie.RawFrame;
592
+ const {scriptId, url, lineNumber, columnNumber, functionName} = frame;
593
+ const rawLocation = scriptId ? this.#debuggerModel.createRawLocationByScriptId(scriptId, lineNumber, columnNumber) :
594
+ url ? this.#debuggerModel.createRawLocationByURL(url, lineNumber, columnNumber) :
595
+ null;
596
+ if (rawLocation) {
597
+ const uiLocation = this.rawLocationToUILocation(rawLocation);
598
+ if (uiLocation) {
599
+ translatedFrames.push([{
600
+ uiSourceCode: uiLocation.uiSourceCode,
601
+ name: functionName,
602
+ line: uiLocation.lineNumber,
603
+ column: uiLocation.columnNumber ?? -1
604
+ }]);
605
+ return;
606
+ }
607
+ }
608
+
609
+ translatedFrames.push([{url, line: lineNumber, column: columnNumber, name: functionName}]);
610
+ }
611
+
612
+ getMappedLines(uiSourceCode: Workspace.UISourceCode.UISourceCode): Set<number>|null {
613
+ const mappedLines = this.compilerMapping.getMappedLines(uiSourceCode);
614
+ // TODO(crbug.com/1411431): The scripts from the ResourceMapping appear over time,
615
+ // and there's currently no way to inform the UI to update.
616
+ // mappedLines = mappedLines ?? this.#resourceMapping.getMappedLines(uiSourceCode);
617
+ return mappedLines;
618
+ }
619
+
620
+ dispose(): void {
621
+ this.#debuggerModel.setBeforePausedCallback(null);
622
+ this.compilerMapping.dispose();
623
+ this.#resourceScriptMapping.dispose();
624
+ this.#defaultMapping.dispose();
625
+ }
626
+
627
+ getResourceScriptMapping(): ResourceScriptMapping {
628
+ return this.#resourceScriptMapping;
629
+ }
630
+ }
631
+
632
+ export class Location extends LiveLocationWithPool {
633
+ readonly scriptId: string;
634
+ readonly rawLocation: SDK.DebuggerModel.Location;
635
+ readonly #binding: DebuggerWorkspaceBinding;
636
+
637
+ constructor(
638
+ scriptId: string, rawLocation: SDK.DebuggerModel.Location, binding: DebuggerWorkspaceBinding,
639
+ updateDelegate: (arg0: LiveLocation) => Promise<void>, locationPool: LiveLocationPool) {
640
+ super(updateDelegate, locationPool);
641
+ this.scriptId = scriptId;
642
+ this.rawLocation = rawLocation;
643
+ this.#binding = binding;
644
+ }
645
+
646
+ override async uiLocation(): Promise<Workspace.UISourceCode.UILocation|null> {
647
+ const debuggerModelLocation = this.rawLocation;
648
+ return await this.#binding.rawLocationToUILocation(debuggerModelLocation);
649
+ }
650
+
651
+ override dispose(): void {
652
+ super.dispose();
653
+ this.#binding.removeLiveLocation(this);
654
+ }
655
+ }
656
+
657
+ class StackTraceTopFrameLocation extends LiveLocationWithPool {
658
+ #updateScheduled: boolean;
659
+ #current: LiveLocation|null;
660
+ #locations: LiveLocation[]|null;
661
+ constructor(updateDelegate: (arg0: LiveLocation) => Promise<void>, locationPool: LiveLocationPool) {
662
+ super(updateDelegate, locationPool);
663
+ this.#updateScheduled = true;
664
+ this.#current = null;
665
+ this.#locations = null;
666
+ }
667
+
668
+ static async createStackTraceTopFrameLocation(
669
+ rawLocations: SDK.DebuggerModel.Location[], binding: DebuggerWorkspaceBinding,
670
+ updateDelegate: (arg0: LiveLocation) => Promise<void>,
671
+ locationPool: LiveLocationPool): Promise<StackTraceTopFrameLocation> {
672
+ const location = new StackTraceTopFrameLocation(updateDelegate, locationPool);
673
+ const locationsPromises = rawLocations.map(
674
+ rawLocation => binding.createLiveLocation(rawLocation, location.scheduleUpdate.bind(location), locationPool));
675
+ location.#locations = ((await Promise.all(locationsPromises)).filter(l => !!l));
676
+ await location.updateLocation();
677
+ return location;
678
+ }
679
+
680
+ override async uiLocation(): Promise<Workspace.UISourceCode.UILocation|null> {
681
+ return this.#current ? await this.#current.uiLocation() : null;
682
+ }
683
+
684
+ override dispose(): void {
685
+ super.dispose();
686
+ if (this.#locations) {
687
+ for (const location of this.#locations) {
688
+ location.dispose();
689
+ }
690
+ }
691
+ this.#locations = null;
692
+ this.#current = null;
693
+ }
694
+
695
+ private async scheduleUpdate(): Promise<void> {
696
+ if (this.#updateScheduled) {
697
+ return;
698
+ }
699
+ this.#updateScheduled = true;
700
+ queueMicrotask(() => {
701
+ void this.updateLocation();
702
+ });
703
+ }
704
+
705
+ private async updateLocation(): Promise<void> {
706
+ this.#updateScheduled = false;
707
+ if (!this.#locations || this.#locations.length === 0) {
708
+ return;
709
+ }
710
+
711
+ this.#current = this.#locations[0];
712
+ for (const location of this.#locations) {
713
+ const uiLocation = await location.uiLocation();
714
+ if (!uiLocation?.isIgnoreListed()) {
715
+ this.#current = location;
716
+ break;
717
+ }
718
+ }
719
+ void this.update();
720
+ }
721
+ }
722
+
723
+ export interface DebuggerSourceMapping {
724
+ rawLocationToUILocation(rawLocation: SDK.DebuggerModel.Location): Workspace.UISourceCode.UILocation|null;
725
+
726
+ uiLocationToRawLocations(
727
+ uiSourceCode: Workspace.UISourceCode.UISourceCode, lineNumber: number,
728
+ columnNumber?: number): SDK.DebuggerModel.Location[];
729
+
730
+ uiLocationRangeToRawLocationRanges(
731
+ uiSourceCode: Workspace.UISourceCode.UISourceCode,
732
+ textRange: TextUtils.TextRange.TextRange): SDK.DebuggerModel.LocationRange[]|null;
733
+ }