chrome-devtools-frontend 1.0.929965 → 1.0.930993

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/config/gni/devtools_grd_files.gni +2 -1
  2. package/front_end/core/host/InspectorFrontendHost.ts +8 -1
  3. package/front_end/core/host/InspectorFrontendHostAPI.ts +12 -0
  4. package/front_end/core/i18n/locales/en-US.json +3 -0
  5. package/front_end/core/i18n/locales/en-XL.json +3 -0
  6. package/front_end/core/protocol_client/InspectorBackend.ts +71 -71
  7. package/front_end/core/sdk/NetworkManager.ts +6 -2
  8. package/front_end/devtools_compatibility.js +8 -0
  9. package/front_end/legacy_test_runner/sources_test_runner/DebuggerTestRunner.js +2 -2
  10. package/front_end/legacy_test_runner/test_runner/TestRunner.js +2 -3
  11. package/front_end/models/bindings/BreakpointManager.ts +158 -154
  12. package/front_end/models/bindings/CSSWorkspaceBinding.ts +64 -56
  13. package/front_end/models/bindings/CompilerScriptMapping.ts +70 -70
  14. package/front_end/models/bindings/ContentProviderBasedProject.ts +20 -20
  15. package/front_end/models/bindings/DebuggerLanguagePlugins.ts +132 -132
  16. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +73 -72
  17. package/front_end/models/bindings/DefaultScriptMapping.ts +22 -22
  18. package/front_end/models/bindings/FileUtils.ts +81 -81
  19. package/front_end/models/bindings/IgnoreListManager.ts +17 -17
  20. package/front_end/models/bindings/LiveLocation.ts +21 -21
  21. package/front_end/models/bindings/PresentationConsoleMessageHelper.ts +28 -28
  22. package/front_end/models/bindings/ResourceMapping.ts +50 -50
  23. package/front_end/models/bindings/ResourceScriptMapping.ts +71 -71
  24. package/front_end/models/bindings/SASSSourceMapping.ts +32 -32
  25. package/front_end/models/bindings/StylesSourceMapping.ts +57 -57
  26. package/front_end/models/bindings/TempFile.ts +34 -34
  27. package/front_end/models/emulation/DeviceModeModel.ts +208 -203
  28. package/front_end/models/emulation/EmulatedDevices.ts +34 -34
  29. package/front_end/panels/console/ConsoleView.ts +2 -1
  30. package/front_end/panels/console/ConsoleViewMessage.ts +3 -3
  31. package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +133 -133
  32. package/front_end/panels/css_overview/CSSOverviewModel.ts +16 -16
  33. package/front_end/panels/css_overview/CSSOverviewPanel.ts +77 -77
  34. package/front_end/panels/css_overview/CSSOverviewProcessingView.ts +5 -5
  35. package/front_end/panels/css_overview/components/CSSOverviewStartView.ts +4 -4
  36. package/front_end/panels/elements/ElementsTreeElement.ts +6 -10
  37. package/front_end/panels/elements/ElementsTreeOutline.ts +3 -1
  38. package/front_end/panels/elements/components/LayoutPane.ts +6 -0
  39. package/front_end/panels/elements/elementsPanel.css +0 -1
  40. package/front_end/panels/elements/elementsTreeOutline.css +0 -4
  41. package/front_end/panels/lighthouse/LighthouseController.ts +18 -9
  42. package/front_end/panels/lighthouse/LighthousePanel.ts +2 -2
  43. package/front_end/panels/lighthouse/LighthouseProtocolService.ts +7 -2
  44. package/front_end/panels/network/BlockedURLsPane.ts +8 -5
  45. package/front_end/panels/network/blockedURLsPane.css +0 -1
  46. package/front_end/panels/search/SearchView.ts +0 -2
  47. package/front_end/panels/sources/BreakpointEditDialog.ts +98 -81
  48. package/front_end/panels/sources/DebuggerPlugin.ts +15 -14
  49. package/front_end/ui/components/code_highlighter/CodeHighlighter.ts +18 -2
  50. package/front_end/ui/components/text_editor/config.ts +6 -0
  51. package/front_end/ui/components/text_editor/cursor_tooltip.ts +70 -0
  52. package/front_end/ui/components/text_editor/javascript.ts +590 -0
  53. package/front_end/ui/components/text_editor/text_editor.ts +1 -0
  54. package/front_end/ui/components/text_editor/theme.ts +11 -0
  55. package/front_end/ui/components/tree_outline/TreeOutline.ts +3 -1
  56. package/front_end/ui/legacy/ARIAUtils.ts +24 -8
  57. package/front_end/ui/legacy/components/text_editor/cmdevtools.css +1 -0
  58. package/front_end/ui/legacy/components/text_editor/text_editor-legacy.ts +0 -3
  59. package/front_end/ui/legacy/components/text_editor/text_editor.ts +0 -2
  60. package/package.json +1 -1
  61. package/scripts/migration/class-fields/migrate.js +15 -2
  62. package/scripts/migration/class-fields/migrate.sh +10 -0
  63. package/front_end/ui/legacy/components/text_editor/SyntaxHighlighter.ts +0 -62
@@ -20,11 +20,11 @@ const scriptOffsetMap = new WeakMap<SDK.Script.Script, TextUtils.TextRange.TextR
20
20
  const boundUISourceCodes = new WeakSet<Workspace.UISourceCode.UISourceCode>();
21
21
 
22
22
  export class ResourceMapping implements SDK.TargetManager.SDKModelObserver<SDK.ResourceTreeModel.ResourceTreeModel> {
23
- private readonly workspace: Workspace.Workspace.WorkspaceImpl;
24
- private readonly modelToInfo: Map<SDK.ResourceTreeModel.ResourceTreeModel, ModelInfo>;
23
+ readonly #workspace: Workspace.Workspace.WorkspaceImpl;
24
+ readonly #modelToInfo: Map<SDK.ResourceTreeModel.ResourceTreeModel, ModelInfo>;
25
25
  private constructor(targetManager: SDK.TargetManager.TargetManager, workspace: Workspace.Workspace.WorkspaceImpl) {
26
- this.workspace = workspace;
27
- this.modelToInfo = new Map();
26
+ this.#workspace = workspace;
27
+ this.#modelToInfo = new Map();
28
28
  targetManager.observeModels(SDK.ResourceTreeModel.ResourceTreeModel, this);
29
29
  }
30
30
 
@@ -47,21 +47,21 @@ export class ResourceMapping implements SDK.TargetManager.SDKModelObserver<SDK.R
47
47
  }
48
48
 
49
49
  modelAdded(resourceTreeModel: SDK.ResourceTreeModel.ResourceTreeModel): void {
50
- const info = new ModelInfo(this.workspace, resourceTreeModel);
51
- this.modelToInfo.set(resourceTreeModel, info);
50
+ const info = new ModelInfo(this.#workspace, resourceTreeModel);
51
+ this.#modelToInfo.set(resourceTreeModel, info);
52
52
  }
53
53
 
54
54
  modelRemoved(resourceTreeModel: SDK.ResourceTreeModel.ResourceTreeModel): void {
55
- const info = this.modelToInfo.get(resourceTreeModel);
55
+ const info = this.#modelToInfo.get(resourceTreeModel);
56
56
  if (info) {
57
57
  info.dispose();
58
- this.modelToInfo.delete(resourceTreeModel);
58
+ this.#modelToInfo.delete(resourceTreeModel);
59
59
  }
60
60
  }
61
61
 
62
62
  private infoForTarget(target: SDK.Target.Target): ModelInfo|null {
63
63
  const resourceTreeModel = target.model(SDK.ResourceTreeModel.ResourceTreeModel);
64
- return resourceTreeModel ? this.modelToInfo.get(resourceTreeModel) || null : null;
64
+ return resourceTreeModel ? this.#modelToInfo.get(resourceTreeModel) || null : null;
65
65
  }
66
66
 
67
67
  cssLocationToUILocation(cssLocation: SDK.CSSModel.CSSLocation): Workspace.UISourceCode.UILocation|null {
@@ -151,7 +151,7 @@ export class ResourceMapping implements SDK.TargetManager.SDKModelObserver<SDK.R
151
151
 
152
152
  private resetForTest(target: SDK.Target.Target): void {
153
153
  const resourceTreeModel = target.model(SDK.ResourceTreeModel.ResourceTreeModel);
154
- const info = resourceTreeModel ? this.modelToInfo.get(resourceTreeModel) : null;
154
+ const info = resourceTreeModel ? this.#modelToInfo.get(resourceTreeModel) : null;
155
155
  if (info) {
156
156
  info.resetForTest();
157
157
  }
@@ -160,9 +160,9 @@ export class ResourceMapping implements SDK.TargetManager.SDKModelObserver<SDK.R
160
160
 
161
161
  class ModelInfo {
162
162
  project: ContentProviderBasedProject;
163
- private readonly bindings: Map<string, Binding>;
164
- private readonly cssModel: SDK.CSSModel.CSSModel;
165
- private readonly eventListeners: Common.EventTarget.EventDescriptor[];
163
+ readonly #bindings: Map<string, Binding>;
164
+ readonly #cssModel: SDK.CSSModel.CSSModel;
165
+ readonly #eventListeners: Common.EventTarget.EventDescriptor[];
166
166
  constructor(
167
167
  workspace: Workspace.Workspace.WorkspaceImpl, resourceTreeModel: SDK.ResourceTreeModel.ResourceTreeModel) {
168
168
  const target = resourceTreeModel.target();
@@ -171,16 +171,16 @@ class ModelInfo {
171
171
  false /* isServiceProject */);
172
172
  NetworkProject.setTargetForProject(this.project, target);
173
173
 
174
- this.bindings = new Map();
174
+ this.#bindings = new Map();
175
175
 
176
176
  const cssModel = target.model(SDK.CSSModel.CSSModel);
177
177
  console.assert(Boolean(cssModel));
178
- this.cssModel = (cssModel as SDK.CSSModel.CSSModel);
179
- this.eventListeners = [
178
+ this.#cssModel = (cssModel as SDK.CSSModel.CSSModel);
179
+ this.#eventListeners = [
180
180
  resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.ResourceAdded, this.resourceAdded, this),
181
181
  resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.FrameWillNavigate, this.frameWillNavigate, this),
182
182
  resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.FrameDetached, this.frameDetached, this),
183
- this.cssModel.addEventListener(
183
+ this.#cssModel.addEventListener(
184
184
  SDK.CSSModel.Events.StyleSheetChanged,
185
185
  event => {
186
186
  this.styleSheetChanged(event);
@@ -191,11 +191,11 @@ class ModelInfo {
191
191
 
192
192
  private async styleSheetChanged(event: Common.EventTarget.EventTargetEvent<SDK.CSSModel.StyleSheetChangedEvent>):
193
193
  Promise<void> {
194
- const header = this.cssModel.styleSheetHeaderForId(event.data.styleSheetId);
194
+ const header = this.#cssModel.styleSheetHeaderForId(event.data.styleSheetId);
195
195
  if (!header || !header.isInline || (header.isInline && header.isMutable)) {
196
196
  return;
197
197
  }
198
- const binding = this.bindings.get(header.resourceURL());
198
+ const binding = this.#bindings.get(header.resourceURL());
199
199
  if (!binding) {
200
200
  return;
201
201
  }
@@ -235,10 +235,10 @@ class ModelInfo {
235
235
  return;
236
236
  }
237
237
 
238
- let binding = this.bindings.get(resource.url);
238
+ let binding = this.#bindings.get(resource.url);
239
239
  if (!binding) {
240
240
  binding = new Binding(this.project, resource);
241
- this.bindings.set(resource.url, binding);
241
+ this.#bindings.set(resource.url, binding);
242
242
  } else {
243
243
  binding.addResource(resource);
244
244
  }
@@ -249,13 +249,13 @@ class ModelInfo {
249
249
  if (!this.acceptsResource(resource)) {
250
250
  continue;
251
251
  }
252
- const binding = this.bindings.get(resource.url);
252
+ const binding = this.#bindings.get(resource.url);
253
253
  if (!binding) {
254
254
  continue;
255
255
  }
256
256
  if (binding.resources.size === 1) {
257
257
  binding.dispose();
258
- this.bindings.delete(resource.url);
258
+ this.#bindings.delete(resource.url);
259
259
  } else {
260
260
  binding.removeResource(resource);
261
261
  }
@@ -273,18 +273,18 @@ class ModelInfo {
273
273
  }
274
274
 
275
275
  resetForTest(): void {
276
- for (const binding of this.bindings.values()) {
276
+ for (const binding of this.#bindings.values()) {
277
277
  binding.dispose();
278
278
  }
279
- this.bindings.clear();
279
+ this.#bindings.clear();
280
280
  }
281
281
 
282
282
  dispose(): void {
283
- Common.EventTarget.removeEventListeners(this.eventListeners);
284
- for (const binding of this.bindings.values()) {
283
+ Common.EventTarget.removeEventListeners(this.#eventListeners);
284
+ for (const binding of this.#bindings.values()) {
285
285
  binding.dispose();
286
286
  }
287
- this.bindings.clear();
287
+ this.#bindings.clear();
288
288
  this.project.removeProject();
289
289
  }
290
290
 
@@ -295,33 +295,33 @@ class ModelInfo {
295
295
 
296
296
  class Binding implements TextUtils.ContentProvider.ContentProvider {
297
297
  readonly resources: Set<SDK.Resource.Resource>;
298
- private readonly project: ContentProviderBasedProject;
299
- private readonly uiSourceCode: Workspace.UISourceCode.UISourceCode;
300
- private edits: {
298
+ readonly #project: ContentProviderBasedProject;
299
+ readonly #uiSourceCode: Workspace.UISourceCode.UISourceCode;
300
+ #edits: {
301
301
  stylesheet: SDK.CSSStyleSheetHeader.CSSStyleSheetHeader,
302
302
  edit: SDK.CSSModel.Edit|null,
303
303
  }[];
304
304
  constructor(project: ContentProviderBasedProject, resource: SDK.Resource.Resource) {
305
305
  this.resources = new Set([resource]);
306
- this.project = project;
307
- this.uiSourceCode = this.project.createUISourceCode(resource.url, resource.contentType());
308
- boundUISourceCodes.add(this.uiSourceCode);
306
+ this.#project = project;
307
+ this.#uiSourceCode = this.#project.createUISourceCode(resource.url, resource.contentType());
308
+ boundUISourceCodes.add(this.#uiSourceCode);
309
309
  if (resource.frameId) {
310
- NetworkProject.setInitialFrameAttribution(this.uiSourceCode, resource.frameId);
310
+ NetworkProject.setInitialFrameAttribution(this.#uiSourceCode, resource.frameId);
311
311
  }
312
- this.project.addUISourceCodeWithProvider(this.uiSourceCode, this, resourceMetadata(resource), resource.mimeType);
313
- this.edits = [];
312
+ this.#project.addUISourceCodeWithProvider(this.#uiSourceCode, this, resourceMetadata(resource), resource.mimeType);
313
+ this.#edits = [];
314
314
  }
315
315
 
316
316
  private inlineStyles(): SDK.CSSStyleSheetHeader.CSSStyleSheetHeader[] {
317
- const target = NetworkProject.targetForUISourceCode(this.uiSourceCode);
317
+ const target = NetworkProject.targetForUISourceCode(this.#uiSourceCode);
318
318
  const stylesheets: SDK.CSSStyleSheetHeader.CSSStyleSheetHeader[] = [];
319
319
  if (!target) {
320
320
  return stylesheets;
321
321
  }
322
322
  const cssModel = target.model(SDK.CSSModel.CSSModel);
323
323
  if (cssModel) {
324
- for (const headerId of cssModel.getStyleSheetIdsForURL(this.uiSourceCode.url())) {
324
+ for (const headerId of cssModel.getStyleSheetIdsForURL(this.#uiSourceCode.url())) {
325
325
  const header = cssModel.styleSheetHeaderForId(headerId);
326
326
  if (header) {
327
327
  stylesheets.push(header);
@@ -332,7 +332,7 @@ class Binding implements TextUtils.ContentProvider.ContentProvider {
332
332
  }
333
333
 
334
334
  private inlineScripts(): SDK.Script.Script[] {
335
- const target = NetworkProject.targetForUISourceCode(this.uiSourceCode);
335
+ const target = NetworkProject.targetForUISourceCode(this.#uiSourceCode);
336
336
  if (!target) {
337
337
  return [];
338
338
  }
@@ -340,28 +340,28 @@ class Binding implements TextUtils.ContentProvider.ContentProvider {
340
340
  if (!debuggerModel) {
341
341
  return [];
342
342
  }
343
- return debuggerModel.scriptsForSourceURL(this.uiSourceCode.url());
343
+ return debuggerModel.scriptsForSourceURL(this.#uiSourceCode.url());
344
344
  }
345
345
 
346
346
  async styleSheetChanged(stylesheet: SDK.CSSStyleSheetHeader.CSSStyleSheetHeader, edit: SDK.CSSModel.Edit|null):
347
347
  Promise<void> {
348
- this.edits.push({stylesheet, edit});
349
- if (this.edits.length > 1) {
348
+ this.#edits.push({stylesheet, edit});
349
+ if (this.#edits.length > 1) {
350
350
  return;
351
351
  } // There is already a styleSheetChanged loop running
352
352
 
353
- const {content} = await this.uiSourceCode.requestContent();
353
+ const {content} = await this.#uiSourceCode.requestContent();
354
354
  if (content !== null) {
355
355
  await this.innerStyleSheetChanged(content);
356
356
  }
357
- this.edits = [];
357
+ this.#edits = [];
358
358
  }
359
359
 
360
360
  private async innerStyleSheetChanged(content: string): Promise<void> {
361
361
  const scripts = this.inlineScripts();
362
362
  const styles = this.inlineStyles();
363
363
  let text: TextUtils.Text.Text = new TextUtils.Text.Text(content);
364
- for (const data of this.edits) {
364
+ for (const data of this.#edits) {
365
365
  const edit = data.edit;
366
366
  if (!edit) {
367
367
  continue;
@@ -394,25 +394,25 @@ class Binding implements TextUtils.ContentProvider.ContentProvider {
394
394
  }
395
395
  await Promise.all(updatePromises);
396
396
  }
397
- this.uiSourceCode.addRevision(text.value());
397
+ this.#uiSourceCode.addRevision(text.value());
398
398
  }
399
399
 
400
400
  addResource(resource: SDK.Resource.Resource): void {
401
401
  this.resources.add(resource);
402
402
  if (resource.frameId) {
403
- NetworkProject.addFrameAttribution(this.uiSourceCode, resource.frameId);
403
+ NetworkProject.addFrameAttribution(this.#uiSourceCode, resource.frameId);
404
404
  }
405
405
  }
406
406
 
407
407
  removeResource(resource: SDK.Resource.Resource): void {
408
408
  this.resources.delete(resource);
409
409
  if (resource.frameId) {
410
- NetworkProject.removeFrameAttribution(this.uiSourceCode, resource.frameId);
410
+ NetworkProject.removeFrameAttribution(this.#uiSourceCode, resource.frameId);
411
411
  }
412
412
  }
413
413
 
414
414
  dispose(): void {
415
- this.project.removeFile(this.uiSourceCode.url());
415
+ this.#project.removeFile(this.#uiSourceCode.url());
416
416
  }
417
417
 
418
418
  private firstResource(): SDK.Resource.Resource {
@@ -60,26 +60,26 @@ const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
60
60
 
61
61
  export class ResourceScriptMapping implements DebuggerSourceMapping {
62
62
  readonly debuggerModel: SDK.DebuggerModel.DebuggerModel;
63
- private workspace: Workspace.Workspace.WorkspaceImpl;
63
+ #workspace: Workspace.Workspace.WorkspaceImpl;
64
64
  readonly debuggerWorkspaceBinding: DebuggerWorkspaceBinding;
65
- private readonly uiSourceCodeToScriptFile: Map<Workspace.UISourceCode.UISourceCode, ResourceScriptFile>;
66
- private readonly projects: Map<string, ContentProviderBasedProject>;
67
- private acceptedScripts: Set<SDK.Script.Script>;
68
- private readonly eventListeners: Common.EventTarget.EventDescriptor[];
65
+ readonly #uiSourceCodeToScriptFile: Map<Workspace.UISourceCode.UISourceCode, ResourceScriptFile>;
66
+ readonly #projects: Map<string, ContentProviderBasedProject>;
67
+ #acceptedScripts: Set<SDK.Script.Script>;
68
+ readonly #eventListeners: Common.EventTarget.EventDescriptor[];
69
69
 
70
70
  constructor(
71
71
  debuggerModel: SDK.DebuggerModel.DebuggerModel, workspace: Workspace.Workspace.WorkspaceImpl,
72
72
  debuggerWorkspaceBinding: DebuggerWorkspaceBinding) {
73
73
  this.debuggerModel = debuggerModel;
74
- this.workspace = workspace;
74
+ this.#workspace = workspace;
75
75
  this.debuggerWorkspaceBinding = debuggerWorkspaceBinding;
76
- this.uiSourceCodeToScriptFile = new Map();
76
+ this.#uiSourceCodeToScriptFile = new Map();
77
77
 
78
- this.projects = new Map();
78
+ this.#projects = new Map();
79
79
 
80
- this.acceptedScripts = new Set();
80
+ this.#acceptedScripts = new Set();
81
81
  const runtimeModel = debuggerModel.runtimeModel();
82
- this.eventListeners = [
82
+ this.#eventListeners = [
83
83
  this.debuggerModel.addEventListener(
84
84
  SDK.DebuggerModel.Events.ParsedScriptSource,
85
85
  event => {
@@ -95,14 +95,14 @@ export class ResourceScriptMapping implements DebuggerSourceMapping {
95
95
  private project(script: SDK.Script.Script): ContentProviderBasedProject {
96
96
  const prefix = script.isContentScript() ? 'js:extensions:' : 'js::';
97
97
  const projectId = prefix + this.debuggerModel.target().id() + ':' + script.frameId;
98
- let project = this.projects.get(projectId);
98
+ let project = this.#projects.get(projectId);
99
99
  if (!project) {
100
100
  const projectType = script.isContentScript() ? Workspace.Workspace.projectTypes.ContentScripts :
101
101
  Workspace.Workspace.projectTypes.Network;
102
102
  project = new ContentProviderBasedProject(
103
- this.workspace, projectId, projectType, '' /* displayName */, false /* isServiceProject */);
103
+ this.#workspace, projectId, projectType, '' /* displayName */, false /* isServiceProject */);
104
104
  NetworkProject.setTargetForProject(project, this.debuggerModel.target());
105
- this.projects.set(projectId, project);
105
+ this.#projects.set(projectId, project);
106
106
  }
107
107
  return project;
108
108
  }
@@ -117,7 +117,7 @@ export class ResourceScriptMapping implements DebuggerSourceMapping {
117
117
  if (!uiSourceCode) {
118
118
  return null;
119
119
  }
120
- const scriptFile = this.uiSourceCodeToScriptFile.get(uiSourceCode);
120
+ const scriptFile = this.#uiSourceCodeToScriptFile.get(uiSourceCode);
121
121
  if (!scriptFile) {
122
122
  return null;
123
123
  }
@@ -137,7 +137,7 @@ export class ResourceScriptMapping implements DebuggerSourceMapping {
137
137
 
138
138
  uiLocationToRawLocations(uiSourceCode: Workspace.UISourceCode.UISourceCode, lineNumber: number, columnNumber: number):
139
139
  SDK.DebuggerModel.Location[] {
140
- const scriptFile = this.uiSourceCodeToScriptFile.get(uiSourceCode);
140
+ const scriptFile = this.#uiSourceCodeToScriptFile.get(uiSourceCode);
141
141
  if (!scriptFile || typeof scriptFile.script === 'undefined') {
142
142
  return [];
143
143
  }
@@ -173,7 +173,7 @@ export class ResourceScriptMapping implements DebuggerSourceMapping {
173
173
  if (!this.acceptsScript(script)) {
174
174
  return;
175
175
  }
176
- this.acceptedScripts.add(script);
176
+ this.#acceptedScripts.add(script);
177
177
  const originalContentProvider = script.originalContentProvider();
178
178
 
179
179
  const url = script.sourceURL;
@@ -182,7 +182,7 @@ export class ResourceScriptMapping implements DebuggerSourceMapping {
182
182
  // Remove previous UISourceCode, if any
183
183
  const oldUISourceCode = project.uiSourceCodeForURL(url);
184
184
  if (oldUISourceCode) {
185
- const scriptFile = this.uiSourceCodeToScriptFile.get(oldUISourceCode);
185
+ const scriptFile = this.#uiSourceCodeToScriptFile.get(oldUISourceCode);
186
186
  if (scriptFile && scriptFile.script) {
187
187
  await this.removeScript(scriptFile.script);
188
188
  }
@@ -195,7 +195,7 @@ export class ResourceScriptMapping implements DebuggerSourceMapping {
195
195
 
196
196
  // Bind UISourceCode to scripts.
197
197
  const scriptFile = new ResourceScriptFile(this, uiSourceCode, [script]);
198
- this.uiSourceCodeToScriptFile.set(uiSourceCode, scriptFile);
198
+ this.#uiSourceCodeToScriptFile.set(uiSourceCode, scriptFile);
199
199
 
200
200
  const mimeType = script.isWasm() ? 'application/wasm' : 'text/javascript';
201
201
  project.addUISourceCodeWithProvider(uiSourceCode, originalContentProvider, metadata, mimeType);
@@ -203,21 +203,21 @@ export class ResourceScriptMapping implements DebuggerSourceMapping {
203
203
  }
204
204
 
205
205
  scriptFile(uiSourceCode: Workspace.UISourceCode.UISourceCode): ResourceScriptFile|null {
206
- return this.uiSourceCodeToScriptFile.get(uiSourceCode) || null;
206
+ return this.#uiSourceCodeToScriptFile.get(uiSourceCode) || null;
207
207
  }
208
208
 
209
209
  private async removeScript(script: SDK.Script.Script): Promise<void> {
210
- if (!this.acceptedScripts.has(script)) {
210
+ if (!this.#acceptedScripts.has(script)) {
211
211
  return;
212
212
  }
213
- this.acceptedScripts.delete(script);
213
+ this.#acceptedScripts.delete(script);
214
214
  const project = this.project(script);
215
215
  const uiSourceCode = (project.uiSourceCodeForURL(script.sourceURL) as Workspace.UISourceCode.UISourceCode);
216
- const scriptFile = this.uiSourceCodeToScriptFile.get(uiSourceCode);
216
+ const scriptFile = this.#uiSourceCodeToScriptFile.get(uiSourceCode);
217
217
  if (scriptFile) {
218
218
  scriptFile.dispose();
219
219
  }
220
- this.uiSourceCodeToScriptFile.delete(uiSourceCode);
220
+ this.#uiSourceCodeToScriptFile.delete(uiSourceCode);
221
221
  project.removeFile(script.sourceURL);
222
222
  await this.debuggerWorkspaceBinding.updateLocations(script);
223
223
  }
@@ -232,56 +232,56 @@ export class ResourceScriptMapping implements DebuggerSourceMapping {
232
232
  }
233
233
 
234
234
  private globalObjectCleared(): void {
235
- const scripts = Array.from(this.acceptedScripts);
235
+ const scripts = Array.from(this.#acceptedScripts);
236
236
  for (const script of scripts) {
237
237
  this.removeScript(script);
238
238
  }
239
239
  }
240
240
 
241
241
  resetForTest(): void {
242
- const scripts = Array.from(this.acceptedScripts);
242
+ const scripts = Array.from(this.#acceptedScripts);
243
243
  for (const script of scripts) {
244
244
  this.removeScript(script);
245
245
  }
246
246
  }
247
247
 
248
248
  dispose(): void {
249
- Common.EventTarget.removeEventListeners(this.eventListeners);
250
- const scripts = Array.from(this.acceptedScripts);
249
+ Common.EventTarget.removeEventListeners(this.#eventListeners);
250
+ const scripts = Array.from(this.#acceptedScripts);
251
251
  for (const script of scripts) {
252
252
  this.removeScript(script);
253
253
  }
254
- for (const project of this.projects.values()) {
254
+ for (const project of this.#projects.values()) {
255
255
  project.removeProject();
256
256
  }
257
- this.projects.clear();
257
+ this.#projects.clear();
258
258
  }
259
259
  }
260
260
 
261
261
  export class ResourceScriptFile extends Common.ObjectWrapper.ObjectWrapper<ResourceScriptFile.EventTypes> {
262
- private readonly resourceScriptMapping: ResourceScriptMapping;
263
- private readonly uiSourceCodeInternal: Workspace.UISourceCode.UISourceCode;
262
+ readonly #resourceScriptMapping: ResourceScriptMapping;
263
+ readonly #uiSourceCodeInternal: Workspace.UISourceCode.UISourceCode;
264
264
  scriptInternal: SDK.Script.Script|undefined;
265
- private scriptSource?: string|null;
266
- private isDivergingFromVMInternal?: boolean;
267
- private hasDivergedFromVMInternal?: boolean;
268
- private isMergingToVMInternal?: boolean;
265
+ #scriptSource?: string|null;
266
+ #isDivergingFromVMInternal?: boolean;
267
+ #hasDivergedFromVMInternal?: boolean;
268
+ #isMergingToVMInternal?: boolean;
269
269
  constructor(
270
270
  resourceScriptMapping: ResourceScriptMapping, uiSourceCode: Workspace.UISourceCode.UISourceCode,
271
271
  scripts: SDK.Script.Script[]) {
272
272
  super();
273
273
  console.assert(scripts.length > 0);
274
274
 
275
- this.resourceScriptMapping = resourceScriptMapping;
276
- this.uiSourceCodeInternal = uiSourceCode;
275
+ this.#resourceScriptMapping = resourceScriptMapping;
276
+ this.#uiSourceCodeInternal = uiSourceCode;
277
277
 
278
- if (this.uiSourceCodeInternal.contentType().isScript()) {
278
+ if (this.#uiSourceCodeInternal.contentType().isScript()) {
279
279
  this.scriptInternal = scripts[scripts.length - 1];
280
280
  }
281
281
 
282
- this.uiSourceCodeInternal.addEventListener(
282
+ this.#uiSourceCodeInternal.addEventListener(
283
283
  Workspace.UISourceCode.Events.WorkingCopyChanged, this.workingCopyChanged, this);
284
- this.uiSourceCodeInternal.addEventListener(
284
+ this.#uiSourceCodeInternal.addEventListener(
285
285
  Workspace.UISourceCode.Events.WorkingCopyCommitted, this.workingCopyCommitted, this);
286
286
  }
287
287
 
@@ -290,25 +290,25 @@ export class ResourceScriptFile extends Common.ObjectWrapper.ObjectWrapper<Resou
290
290
  }
291
291
 
292
292
  private isDiverged(): boolean {
293
- if (this.uiSourceCodeInternal.isDirty()) {
293
+ if (this.#uiSourceCodeInternal.isDirty()) {
294
294
  return true;
295
295
  }
296
296
  if (!this.scriptInternal) {
297
297
  return false;
298
298
  }
299
- if (typeof this.scriptSource === 'undefined' || this.scriptSource === null) {
299
+ if (typeof this.#scriptSource === 'undefined' || this.#scriptSource === null) {
300
300
  return false;
301
301
  }
302
- const workingCopy = this.uiSourceCodeInternal.workingCopy();
302
+ const workingCopy = this.#uiSourceCodeInternal.workingCopy();
303
303
  if (!workingCopy) {
304
304
  return false;
305
305
  }
306
306
 
307
307
  // Match ignoring sourceURL.
308
- if (!workingCopy.startsWith(this.scriptSource.trimRight())) {
308
+ if (!workingCopy.startsWith(this.#scriptSource.trimRight())) {
309
309
  return true;
310
310
  }
311
- const suffix = this.uiSourceCodeInternal.workingCopy().substr(this.scriptSource.length);
311
+ const suffix = this.#uiSourceCodeInternal.workingCopy().substr(this.#scriptSource.length);
312
312
  return Boolean(suffix.length) && !suffix.match(SDK.Script.sourceURLRegex);
313
313
  }
314
314
 
@@ -317,17 +317,17 @@ export class ResourceScriptFile extends Common.ObjectWrapper.ObjectWrapper<Resou
317
317
  }
318
318
 
319
319
  private workingCopyCommitted(): void {
320
- if (this.uiSourceCodeInternal.project().canSetFileContent()) {
320
+ if (this.#uiSourceCodeInternal.project().canSetFileContent()) {
321
321
  return;
322
322
  }
323
323
  if (!this.scriptInternal) {
324
324
  return;
325
325
  }
326
- const debuggerModel = this.resourceScriptMapping.debuggerModel;
326
+ const debuggerModel = this.#resourceScriptMapping.debuggerModel;
327
327
  const breakpoints = BreakpointManager.instance()
328
- .breakpointLocationsForUISourceCode(this.uiSourceCodeInternal)
328
+ .breakpointLocationsForUISourceCode(this.#uiSourceCodeInternal)
329
329
  .map(breakpointLocation => breakpointLocation.breakpoint);
330
- const source = this.uiSourceCodeInternal.workingCopy();
330
+ const source = this.#uiSourceCodeInternal.workingCopy();
331
331
  debuggerModel.setScriptSource(this.scriptInternal.scriptId, source, (error, exceptionDetails) => {
332
332
  this.scriptSourceWasSet(source, breakpoints, error, exceptionDetails);
333
333
  });
@@ -337,13 +337,13 @@ export class ResourceScriptFile extends Common.ObjectWrapper.ObjectWrapper<Resou
337
337
  source: string, breakpoints: Breakpoint[], error: string|null,
338
338
  exceptionDetails?: Protocol.Runtime.ExceptionDetails): Promise<void> {
339
339
  if (!error && !exceptionDetails) {
340
- this.scriptSource = source;
340
+ this.#scriptSource = source;
341
341
  }
342
342
  await this.update();
343
343
 
344
344
  if (!error && !exceptionDetails) {
345
- // Live edit can cause breakpoints to be in the wrong position, or to be lost altogether.
346
- // If any breakpoints were in the pre-live edit script, they need to be re-added.
345
+ // Live edit can cause #breakpoints to be in the wrong position, or to be lost altogether.
346
+ // If any #breakpoints were in the pre-live edit script, they need to be re-added.
347
347
  await Promise.all(breakpoints.map(breakpoint => breakpoint.refreshInDebugger()));
348
348
  return;
349
349
  }
@@ -353,58 +353,58 @@ export class ResourceScriptFile extends Common.ObjectWrapper.ObjectWrapper<Resou
353
353
  return;
354
354
  }
355
355
  const messageText = i18nString(UIStrings.liveEditCompileFailed, {PH1: exceptionDetails.text});
356
- this.uiSourceCodeInternal.addLineMessage(
356
+ this.#uiSourceCodeInternal.addLineMessage(
357
357
  Workspace.UISourceCode.Message.Level.Error, messageText, exceptionDetails.lineNumber,
358
358
  exceptionDetails.columnNumber);
359
359
  }
360
360
 
361
361
  private async update(): Promise<void> {
362
- if (this.isDiverged() && !this.hasDivergedFromVMInternal) {
362
+ if (this.isDiverged() && !this.#hasDivergedFromVMInternal) {
363
363
  await this.divergeFromVM();
364
- } else if (!this.isDiverged() && this.hasDivergedFromVMInternal) {
364
+ } else if (!this.isDiverged() && this.#hasDivergedFromVMInternal) {
365
365
  await this.mergeToVM();
366
366
  }
367
367
  }
368
368
 
369
369
  private async divergeFromVM(): Promise<void> {
370
370
  if (this.scriptInternal) {
371
- this.isDivergingFromVMInternal = true;
372
- await this.resourceScriptMapping.debuggerWorkspaceBinding.updateLocations(this.scriptInternal);
373
- delete this.isDivergingFromVMInternal;
374
- this.hasDivergedFromVMInternal = true;
371
+ this.#isDivergingFromVMInternal = true;
372
+ await this.#resourceScriptMapping.debuggerWorkspaceBinding.updateLocations(this.scriptInternal);
373
+ this.#isDivergingFromVMInternal = undefined;
374
+ this.#hasDivergedFromVMInternal = true;
375
375
  this.dispatchEventToListeners(ResourceScriptFile.Events.DidDivergeFromVM);
376
376
  }
377
377
  }
378
378
 
379
379
  private async mergeToVM(): Promise<void> {
380
380
  if (this.scriptInternal) {
381
- delete this.hasDivergedFromVMInternal;
382
- this.isMergingToVMInternal = true;
383
- await this.resourceScriptMapping.debuggerWorkspaceBinding.updateLocations(this.scriptInternal);
384
- delete this.isMergingToVMInternal;
381
+ this.#hasDivergedFromVMInternal = undefined;
382
+ this.#isMergingToVMInternal = true;
383
+ await this.#resourceScriptMapping.debuggerWorkspaceBinding.updateLocations(this.scriptInternal);
384
+ this.#isMergingToVMInternal = undefined;
385
385
  this.dispatchEventToListeners(ResourceScriptFile.Events.DidMergeToVM);
386
386
  }
387
387
  }
388
388
 
389
389
  hasDivergedFromVM(): boolean {
390
- return Boolean(this.hasDivergedFromVMInternal);
390
+ return Boolean(this.#hasDivergedFromVMInternal);
391
391
  }
392
392
 
393
393
  isDivergingFromVM(): boolean {
394
- return Boolean(this.isDivergingFromVMInternal);
394
+ return Boolean(this.#isDivergingFromVMInternal);
395
395
  }
396
396
 
397
397
  isMergingToVM(): boolean {
398
- return Boolean(this.isMergingToVMInternal);
398
+ return Boolean(this.#isMergingToVMInternal);
399
399
  }
400
400
 
401
401
  checkMapping(): void {
402
- if (!this.scriptInternal || typeof this.scriptSource !== 'undefined') {
402
+ if (!this.scriptInternal || typeof this.#scriptSource !== 'undefined') {
403
403
  this.mappingCheckedForTest();
404
404
  return;
405
405
  }
406
406
  this.scriptInternal.requestContent().then(deferredContent => {
407
- this.scriptSource = deferredContent.content;
407
+ this.#scriptSource = deferredContent.content;
408
408
  this.update().then(() => this.mappingCheckedForTest());
409
409
  });
410
410
  }
@@ -413,9 +413,9 @@ export class ResourceScriptFile extends Common.ObjectWrapper.ObjectWrapper<Resou
413
413
  }
414
414
 
415
415
  dispose(): void {
416
- this.uiSourceCodeInternal.removeEventListener(
416
+ this.#uiSourceCodeInternal.removeEventListener(
417
417
  Workspace.UISourceCode.Events.WorkingCopyChanged, this.workingCopyChanged, this);
418
- this.uiSourceCodeInternal.removeEventListener(
418
+ this.#uiSourceCodeInternal.removeEventListener(
419
419
  Workspace.UISourceCode.Events.WorkingCopyCommitted, this.workingCopyCommitted, this);
420
420
  }
421
421
 
@@ -435,7 +435,7 @@ export class ResourceScriptFile extends Common.ObjectWrapper.ObjectWrapper<Resou
435
435
  }
436
436
 
437
437
  get uiSourceCode(): Workspace.UISourceCode.UISourceCode {
438
- return this.uiSourceCodeInternal;
438
+ return this.#uiSourceCodeInternal;
439
439
  }
440
440
  }
441
441