chrome-devtools-frontend 1.0.1704172 → 1.0.1706026

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 (100) hide show
  1. package/AUTHORS +1 -0
  2. package/docs/architecture_of_devtools.md +1 -1
  3. package/docs/cookbook/localization.md +2 -2
  4. package/eslint.config.mjs +1 -0
  5. package/front_end/Images/src/nodejsHex.svg +28 -0
  6. package/front_end/core/common/README.md +4 -3
  7. package/front_end/core/sdk/CPUThrottlingManager.ts +14 -10
  8. package/front_end/core/sdk/DOMModel.ts +65 -20
  9. package/front_end/core/sdk/DebuggerModel.ts +0 -4
  10. package/front_end/core/sdk/PageResourceLoader.ts +12 -11
  11. package/front_end/core/sdk/SourceMap.ts +7 -5
  12. package/front_end/core/sdk/SourceMapFunctionRanges.ts +22 -37
  13. package/front_end/core/sdk/SourceMapScopeChainEntry.ts +3 -3
  14. package/front_end/core/sdk/SourceMapScopesInfo.ts +50 -62
  15. package/front_end/entrypoints/formatter_actions/formatter_actions.ts +18 -0
  16. package/front_end/entrypoints/formatter_worker/Substitute.ts +9 -8
  17. package/front_end/entrypoints/formatter_worker/formatter_worker-entrypoint.ts +9 -4
  18. package/front_end/entrypoints/heap_snapshot_worker/ContextAnalyzer.ts +140 -20
  19. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshotLoader.ts +16 -5
  20. package/front_end/entrypoints/inspector_main/nodeIcon.css +1 -1
  21. package/front_end/foundation/Universe.ts +9 -0
  22. package/front_end/generated/InspectorBackendCommands.ts +4 -3
  23. package/front_end/generated/protocol.ts +17 -1
  24. package/front_end/models/ai_assistance/AiConversation.ts +16 -3
  25. package/front_end/models/ai_assistance/skills/accessibility.md +8 -7
  26. package/front_end/models/formatter/FormatterWorkerPool.ts +14 -4
  27. package/front_end/models/javascript_metadata/NativeFunctions.ts +6 -2
  28. package/front_end/models/source_map_scopes/NamesResolver.ts +69 -42
  29. package/front_end/models/source_map_scopes/ScopeChainModel.ts +13 -45
  30. package/front_end/models/source_map_scopes/ScopeChainResolver.ts +101 -0
  31. package/front_end/models/source_map_scopes/source_map_scopes.ts +2 -0
  32. package/front_end/panels/application/BackgroundServiceView.ts +1 -0
  33. package/front_end/panels/application/components/AdsView.ts +6 -6
  34. package/front_end/panels/application/components/BackForwardCacheView.ts +1 -1
  35. package/front_end/panels/console/ConsolePrompt.ts +2 -1
  36. package/front_end/panels/elements/CSSRuleValidator.ts +3 -0
  37. package/front_end/panels/elements/ClassesPaneWidget.ts +4 -1
  38. package/front_end/panels/elements/LayoutPane.ts +17 -20
  39. package/front_end/panels/network/NetworkLogViewColumns.ts +10 -3
  40. package/front_end/panels/network/ShowMoreDetailsWidget.ts +1 -1
  41. package/front_end/panels/security/SecurityPanel.ts +14 -7
  42. package/front_end/panels/sources/BreakpointEditDialog.ts +13 -1
  43. package/front_end/panels/sources/DebuggerPlugin.ts +69 -58
  44. package/front_end/panels/sources/EditingLocationHistoryManager.ts +6 -6
  45. package/front_end/panels/sources/OpenFileQuickOpen.ts +2 -2
  46. package/front_end/panels/sources/Plugin.ts +3 -2
  47. package/front_end/panels/sources/ResourceOriginPlugin.ts +14 -17
  48. package/front_end/panels/sources/ScopeChainSidebarPane.ts +2 -2
  49. package/front_end/panels/sources/SourcesPanel.ts +1 -1
  50. package/front_end/panels/sources/SourcesView.ts +25 -82
  51. package/front_end/panels/sources/TabbedEditorContainer.ts +75 -21
  52. package/front_end/panels/sources/UISourceCodeFrame.ts +22 -13
  53. package/front_end/panels/sources/sourcesView.css +17 -27
  54. package/front_end/panels/timeline/overlays/components/EntryLabelOverlay.ts +1 -0
  55. package/front_end/third_party/chromium/README.chromium +1 -1
  56. package/front_end/third_party/source-map-scopes-codec/README.chromium +2 -2
  57. package/front_end/third_party/source-map-scopes-codec/package/CONTRIBUTING.md +14 -1
  58. package/front_end/third_party/source-map-scopes-codec/package/README.md +8 -6
  59. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts +4 -1
  60. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts.map +1 -1
  61. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts +3 -1
  62. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts.map +1 -1
  63. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts.map +1 -1
  64. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/scopes.d.ts +4 -3
  65. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/scopes.d.ts.map +1 -1
  66. package/front_end/third_party/source-map-scopes-codec/package/deno.json +6 -2
  67. package/front_end/third_party/source-map-scopes-codec/package/package.json +1 -1
  68. package/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js +18 -2
  69. package/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js.map +1 -1
  70. package/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.ts +22 -3
  71. package/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js +33 -5
  72. package/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js.map +1 -1
  73. package/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.ts +41 -5
  74. package/front_end/third_party/source-map-scopes-codec/package/src/codec.js +0 -2
  75. package/front_end/third_party/source-map-scopes-codec/package/src/codec.js.map +1 -1
  76. package/front_end/third_party/source-map-scopes-codec/package/src/codec.ts +4 -3
  77. package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js +99 -36
  78. package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js.map +1 -1
  79. package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.ts +143 -49
  80. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js +3 -1
  81. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js.map +1 -1
  82. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.ts +3 -1
  83. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js +40 -18
  84. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js.map +1 -1
  85. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.ts +51 -21
  86. package/front_end/third_party/source-map-scopes-codec/package/src/scopes.ts +4 -3
  87. package/front_end/third_party/source-map-scopes-codec/package/src/vlq.js +18 -4
  88. package/front_end/third_party/source-map-scopes-codec/package/src/vlq.js.map +1 -1
  89. package/front_end/third_party/source-map-scopes-codec/package/src/vlq.ts +18 -4
  90. package/front_end/ui/comments/CommentOverlayManager.ts +23 -10
  91. package/front_end/ui/components/text_editor/javascript.ts +128 -52
  92. package/front_end/ui/legacy/README.md +12 -12
  93. package/front_end/ui/legacy/SearchableView.ts +125 -74
  94. package/front_end/ui/legacy/components/source_frame/FontView.ts +5 -5
  95. package/front_end/ui/legacy/components/source_frame/ImageView.ts +13 -13
  96. package/front_end/ui/legacy/components/source_frame/ResourceSourceFrame.ts +2 -6
  97. package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +3 -2
  98. package/mcp/mcp.ts +1 -0
  99. package/package.json +1 -1
  100. package/front_end/Images/nodeIcon.avif +0 -0
@@ -7,7 +7,7 @@ import * as Workspace from '../../models/workspace/workspace.js';
7
7
  import type * as CodeMirror from '../../third_party/codemirror.next/codemirror.next.js';
8
8
  import * as SourceFrame from '../../ui/legacy/components/source_frame/source_frame.js';
9
9
 
10
- import type {SourcesView} from './SourcesView.js';
10
+ import type {TabbedEditorContainer} from './TabbedEditorContainer.js';
11
11
  import type {UISourceCodeFrame} from './UISourceCodeFrame.js';
12
12
 
13
13
  export const HistoryDepth = 20;
@@ -17,7 +17,7 @@ export class EditingLocationHistoryManager {
17
17
  private current = -1;
18
18
  private revealingCount = 0;
19
19
 
20
- constructor(private readonly sourcesView: SourcesView) {
20
+ constructor(private readonly editorContainer: TabbedEditorContainer) {
21
21
  }
22
22
 
23
23
  trackSourceFrameCursorJumps(sourceFrame: UISourceCodeFrame): void {
@@ -66,12 +66,12 @@ export class EditingLocationHistoryManager {
66
66
  }
67
67
  }
68
68
 
69
- private async reveal(entry: EditingLocationHistoryEntry): Promise<void> {
69
+ private reveal(entry: EditingLocationHistoryEntry): void {
70
70
  const uiSourceCode = Workspace.Workspace.WorkspaceImpl.instance().uiSourceCode(entry.projectId, entry.url);
71
71
  if (uiSourceCode) {
72
72
  this.revealingCount++;
73
73
  try {
74
- await this.sourcesView.showSourceLocation(uiSourceCode, entry.position, false, true);
74
+ this.editorContainer.showSourceLocation(uiSourceCode, entry.position, false, true);
75
75
  } finally {
76
76
  this.revealingCount--;
77
77
  }
@@ -81,14 +81,14 @@ export class EditingLocationHistoryManager {
81
81
  rollback(): void {
82
82
  if (this.current > 0) {
83
83
  this.current--;
84
- void this.reveal(this.entries[this.current]);
84
+ this.reveal(this.entries[this.current]);
85
85
  }
86
86
  }
87
87
 
88
88
  rollover(): void {
89
89
  if (this.current < this.entries.length - 1) {
90
90
  this.current++;
91
- void this.reveal(this.entries[this.current]);
91
+ this.reveal(this.entries[this.current]);
92
92
  }
93
93
  }
94
94
 
@@ -11,13 +11,13 @@ import {PanelUtils} from '../../panels/utils/utils.js';
11
11
  import {Directives, html, type TemplateResult} from '../../ui/lit/lit.js';
12
12
 
13
13
  import {FilteredUISourceCodeListProvider} from './FilteredUISourceCodeListProvider.js';
14
- import {SourcesView} from './SourcesView.js';
14
+ import {TabbedEditorContainer} from './TabbedEditorContainer.js';
15
15
 
16
16
  const {styleMap} = Directives;
17
17
 
18
18
  export class OpenFileQuickOpen extends FilteredUISourceCodeListProvider {
19
19
  override attach(): void {
20
- this.setDefaultScores(SourcesView.defaultUISourceCodeScores());
20
+ this.setDefaultScores(TabbedEditorContainer.defaultUISourceCodeScores());
21
21
  super.attach();
22
22
  }
23
23
 
@@ -7,6 +7,7 @@ import type * as CodeMirror from '../../third_party/codemirror.next/codemirror.n
7
7
  import type * as TextEditor from '../../ui/components/text_editor/text_editor.js';
8
8
  import type * as SourceFrame from '../../ui/legacy/components/source_frame/source_frame.js';
9
9
  import type * as UI from '../../ui/legacy/legacy.js';
10
+ import type {LitTemplate} from '../../ui/lit/lit.js';
10
11
 
11
12
  export class Plugin {
12
13
  constructor(
@@ -21,7 +22,7 @@ export class Plugin {
21
22
  willHide(): void {
22
23
  }
23
24
 
24
- rightToolbarItems(): UI.Toolbar.ToolbarItem[] {
25
+ rightToolbarItems(): Array<UI.Toolbar.ToolbarItem|LitTemplate> {
25
26
  return [];
26
27
  }
27
28
 
@@ -30,7 +31,7 @@ export class Plugin {
30
31
  * TODO(szuend): It is OK to asyncify this function (similar to {rightToolbarItems}),
31
32
  * but it is currently not strictly necessary.
32
33
  */
33
- leftToolbarItems(): UI.Toolbar.ToolbarItem[] {
34
+ leftToolbarItems(): Array<UI.Toolbar.ToolbarItem|LitTemplate> {
34
35
  return [];
35
36
  }
36
37
 
@@ -1,14 +1,12 @@
1
1
  // Copyright 2018 The Chromium Authors
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
- /* eslint-disable @devtools/no-imperative-dom-api */
5
-
6
4
  import * as i18n from '../../core/i18n/i18n.js';
7
5
  import * as Bindings from '../../models/bindings/bindings.js';
8
6
  import type * as Workspace from '../../models/workspace/workspace.js';
9
7
  import * as uiI18n from '../../ui/i18n/i18n.js';
10
8
  import * as Components from '../../ui/legacy/components/utils/utils.js';
11
- import * as UI from '../../ui/legacy/legacy.js';
9
+ import {html, type LitTemplate, nothing} from '../../ui/lit/lit.js';
12
10
 
13
11
  import {Plugin} from './Plugin.js';
14
12
 
@@ -35,12 +33,12 @@ export class ResourceOriginPlugin extends Plugin {
35
33
  return contentType.hasScripts() || contentType.isFromSourceMap();
36
34
  }
37
35
 
38
- override rightToolbarItems(): UI.Toolbar.ToolbarItem[] {
36
+ override rightToolbarItems(): LitTemplate[] {
39
37
  const debuggerWorkspaceBinding = Bindings.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance();
40
38
 
41
39
  // Handle source mapped scripts and stylesheets.
42
40
  if (this.uiSourceCode.contentType().isFromSourceMap()) {
43
- const links = [];
41
+ const links: Array<HTMLElement|LitTemplate> = [];
44
42
  for (const script of debuggerWorkspaceBinding.scriptsForUISourceCode(this.uiSourceCode)) {
45
43
  const uiSourceCode = debuggerWorkspaceBinding.uiSourceCodeForScript(script);
46
44
  if (!uiSourceCode) {
@@ -55,21 +53,17 @@ export class ResourceOriginPlugin extends Plugin {
55
53
  links.push(link);
56
54
  }
57
55
  for (const originURL of Bindings.SASSSourceMapping.SASSSourceMapping.uiSourceOrigin(this.uiSourceCode)) {
58
- const link = Components.Linkifier.Linkifier.linkifyURL(originURL);
59
- link.tabIndex = 0;
60
- links.push(link);
56
+ links.push(Components.Linkifier.Linkifier.renderLinkifiedUrl(originURL, {tabStop: true}));
61
57
  }
62
58
  if (links.length === 0) {
63
59
  return [];
64
60
  }
65
- const element = document.createElement('span');
66
- links.forEach((link, index) => {
67
- if (index > 0) {
68
- element.append(', ');
69
- }
70
- element.append(link);
71
- });
72
- return [new UI.Toolbar.ToolbarItem(uiI18n.getFormatLocalizedString(str_, UIStrings.fromS, {PH1: element}))];
61
+ const linksTemplate =
62
+ html`<span>${links.map((link, index) => html`${index > 0 ? ', ' : nothing}${link}`)}</span>`;
63
+ return [
64
+ html`<div class="toolbar-item">${
65
+ uiI18n.getFormatLocalizedStringTemplate(str_, UIStrings.fromS, {PH1: linksTemplate})}</div>`,
66
+ ];
73
67
  }
74
68
 
75
69
  // Handle anonymous scripts with an originStackTrace.
@@ -77,7 +71,10 @@ export class ResourceOriginPlugin extends Plugin {
77
71
  if (script.originStackTrace?.callFrames.length) {
78
72
  const link = this.#linkifier.linkifyStackTraceTopFrame(script.debuggerModel.target(), script.originStackTrace);
79
73
  link.tabIndex = 0;
80
- return [new UI.Toolbar.ToolbarItem(uiI18n.getFormatLocalizedString(str_, UIStrings.fromS, {PH1: link}))];
74
+ return [
75
+ html`<div class="toolbar-item">${
76
+ uiI18n.getFormatLocalizedStringTemplate(str_, UIStrings.fromS, {PH1: link})}</div>`,
77
+ ];
81
78
  }
82
79
  }
83
80
 
@@ -31,7 +31,6 @@
31
31
  import * as i18n from '../../core/i18n/i18n.js';
32
32
  import type * as SDK from '../../core/sdk/sdk.js';
33
33
  import * as Protocol from '../../generated/protocol.js';
34
- import * as Bindings from '../../models/bindings/bindings.js';
35
34
  import * as SourceMapScopes from '../../models/source_map_scopes/source_map_scopes.js';
36
35
  import * as StackTrace from '../../models/stack_trace/stack_trace.js';
37
36
  import * as ObjectUI from '../../ui/legacy/components/object_ui/object_ui.js';
@@ -214,8 +213,9 @@ export class ScopeChainSidebarPane extends UI.Widget.VBox implements UI.ContextF
214
213
  this.#linkifier.reset();
215
214
 
216
215
  if (callFrame) {
216
+ // TODO(crbug.com/458180550): Receive the ScopeChainResolver via constructor.
217
217
  const scopeChainModel = new SourceMapScopes.ScopeChainModel.ScopeChainModel(
218
- callFrame.sdkFrame, Bindings.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance());
218
+ callFrame.sdkFrame, SourceMapScopes.ScopeChainResolver.ScopeChainResolver.instance());
219
219
  this.#scopeChainModel = scopeChainModel;
220
220
  this.#scopeChainModel.addEventListener(SourceMapScopes.ScopeChainModel.Events.SCOPE_CHAIN_UPDATED, event => {
221
221
  if (this.#scopeChainModel === scopeChainModel) {
@@ -421,7 +421,7 @@ export class SourcesPanel extends UI.Panel.Panel implements
421
421
  } // Do not force layout.
422
422
  }
423
423
 
424
- override searchableView(): UI.SearchableView.SearchableView {
424
+ override searchableView(): UI.SearchableView.SearchableView|null {
425
425
  return this.#sourcesView.searchableView();
426
426
  }
427
427
 
@@ -19,11 +19,9 @@ import * as UI from '../../ui/legacy/legacy.js';
19
19
  import {html, type LitTemplate, nothing, render} from '../../ui/lit/lit.js';
20
20
  import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
21
21
 
22
- import {EditingLocationHistoryManager} from './EditingLocationHistoryManager.js';
23
22
  import sourcesViewStyles from './sourcesView.css.js';
24
23
  import {
25
24
  type EditorSelectedEvent,
26
- type SerializedHistoryItem,
27
25
  TabbedEditorContainer,
28
26
  } from './TabbedEditorContainer.js';
29
27
  import {Events as UISourceCodeFrameEvents, UISourceCodeFrame} from './UISourceCodeFrame.js';
@@ -74,8 +72,8 @@ const {widget, widgetRef} = UI.Widget;
74
72
  export interface ViewInput {
75
73
  searchProvider: UI.SearchableView.Searchable;
76
74
  replaceProvider: UI.SearchableView.Replaceable;
77
- searchableViewId: string;
78
- scriptViewToolbarItems: UI.Toolbar.ToolbarItem[]|LitTemplate;
75
+ isSearchReplaceable: boolean;
76
+ scriptViewToolbarItems: LitTemplate;
79
77
  isNavigatorSidebarOpen: boolean;
80
78
  isDebuggerSidebarOpen: boolean;
81
79
  isDebuggerSidebarButtonEnabled: boolean;
@@ -86,15 +84,12 @@ export interface ViewInput {
86
84
  onToggleDebuggerSidebar?: () => void;
87
85
  breakpointsActive: boolean;
88
86
  uiSourceCodes: ReadonlySet<Workspace.UISourceCode.UISourceCode>;
89
- historyManager: EditingLocationHistoryManager;
90
- previouslyViewedFilesSetting: Common.Settings.Setting<SerializedHistoryItem[]>;
91
87
  onEditorSelected: (event: EditorSelectedEvent) => void;
92
88
  onEditorClosed: (uiSourceCode: Workspace.UISourceCode.UISourceCode) => void;
93
89
  }
94
90
 
95
91
  export interface ViewOutput {
96
92
  editorContainer?: TabbedEditorContainer;
97
- searchableView?: UI.SearchableView.SearchableView;
98
93
  }
99
94
 
100
95
  export type View = (input: ViewInput, output: ViewOutput, target: HTMLElement) => void;
@@ -147,17 +142,16 @@ export const DEFAULT_VIEW: View = (input, output, target): void => {
147
142
  render(html`
148
143
  <style>${sourcesViewStyles}</style>
149
144
  <devtools-widget class="vbox flex-auto"
150
- ${widget(element => {
151
- const searchableView = new UI.SearchableView.SearchableView(input.searchProvider, input.replaceProvider, input.searchableViewId, element);
152
- searchableView.setMinimalSearchQuerySize(0);
153
- return searchableView;
145
+ ${widget(UI.SearchableView.SearchableView, {
146
+ searchProvider: input.searchProvider,
147
+ replaceProvider: input.replaceProvider,
148
+ settingName: 'sources-view-search-config',
149
+ minimalSearchQuerySize: 0,
150
+ replaceable: input.isSearchReplaceable,
154
151
  })}
155
- ${widgetRef(UI.SearchableView.SearchableView, e => { output.searchableView = e; })}
156
152
  >
157
153
  <devtools-widget class="vbox flex-auto ${input.breakpointsActive ? '' : 'breakpoints-deactivated'}"
158
154
  ${widget(TabbedEditorContainer, {
159
- historyManager: input.historyManager,
160
- previouslyViewedFilesSetting: input.previouslyViewedFilesSetting,
161
155
  leftToolbarItems,
162
156
  rightToolbarItems,
163
157
  uiSourceCodes: input.uiSourceCodes,
@@ -168,10 +162,8 @@ export const DEFAULT_VIEW: View = (input, output, target): void => {
168
162
  </devtools-widget>
169
163
  </devtools-widget>
170
164
  <div class="sources-toolbar" jslog=${VisualLogging.toolbar('bottom')}>
171
- <devtools-toolbar class="script-view-toolbar" style="flex: auto;">
172
- ${Array.isArray(input.scriptViewToolbarItems)
173
- ? input.scriptViewToolbarItems.map(item => item.element)
174
- : input.scriptViewToolbarItems}
165
+ <devtools-toolbar class="script-view-toolbar">
166
+ ${input.scriptViewToolbarItems}
175
167
  </devtools-toolbar>
176
168
  <devtools-toolbar class="bottom-toolbar">
177
169
  ${bottomToolbarContent}
@@ -193,11 +185,10 @@ const SourcesViewBase: Common.ObjectWrapper.EventMixin<EventTypes, typeof UI.Wid
193
185
 
194
186
  export class SourcesView extends SourcesViewBase implements UI.SearchableView.Searchable,
195
187
  UI.SearchableView.Replaceable {
196
- #searchableView!: UI.SearchableView.SearchableView;
197
188
  editorContainer?: TabbedEditorContainer;
198
189
  #uiSourceCodes = new Set<Workspace.UISourceCode.UISourceCode>();
199
- private readonly historyManager: EditingLocationHistoryManager;
200
- #scriptViewToolbarItems: UI.Toolbar.ToolbarItem[]|LitTemplate = [];
190
+ #scriptViewToolbarItems: LitTemplate = nothing;
191
+ #isSearchReplaceable = false;
201
192
  private toolbarChangedListener: Common.EventTarget.EventDescriptor|null;
202
193
  private searchView?: UISourceCodeFrame;
203
194
  private searchConfig?: UI.SearchableView.SearchConfig;
@@ -215,7 +206,6 @@ export class SourcesView extends SourcesViewBase implements UI.SearchableView.Se
215
206
  #breakpointsActive = true;
216
207
  #editorContainerPromise: Promise<TabbedEditorContainer>;
217
208
  #editorContainerResolve!: (container: TabbedEditorContainer) => void;
218
- readonly previouslyViewedFilesSetting: Common.Settings.Setting<SerializedHistoryItem[]>;
219
209
 
220
210
  constructor(element?: HTMLElement, view: View = DEFAULT_VIEW) {
221
211
  super(element, {jslog: `${VisualLogging.pane('editor').track({keydown: 'Escape'})}`});
@@ -227,12 +217,8 @@ export class SourcesView extends SourcesViewBase implements UI.SearchableView.Se
227
217
 
228
218
  const workspace = Workspace.Workspace.WorkspaceImpl.instance();
229
219
 
230
- this.historyManager = new EditingLocationHistoryManager(this);
231
-
232
220
  this.toolbarChangedListener = null;
233
221
 
234
- this.previouslyViewedFilesSetting =
235
- Common.Settings.Settings.instance().createLocalSetting('previously-viewed-files', []);
236
222
  this.requestUpdate();
237
223
 
238
224
  UI.UIUtils.startBatchUpdate();
@@ -280,7 +266,7 @@ export class SourcesView extends SourcesViewBase implements UI.SearchableView.Se
280
266
  const input: ViewInput = {
281
267
  searchProvider: this,
282
268
  replaceProvider: this,
283
- searchableViewId: 'sources-view-search-config',
269
+ isSearchReplaceable: this.#isSearchReplaceable,
284
270
  scriptViewToolbarItems: this.#scriptViewToolbarItems,
285
271
  isNavigatorSidebarOpen: this.#isNavigatorSidebarOpen,
286
272
  isDebuggerSidebarOpen: this.#isDebuggerSidebarOpen,
@@ -292,8 +278,6 @@ export class SourcesView extends SourcesViewBase implements UI.SearchableView.Se
292
278
  onToggleDebuggerSidebar: this.#onToggleDebuggerSidebar,
293
279
  breakpointsActive: this.#breakpointsActive,
294
280
  uiSourceCodes: new Set(this.#uiSourceCodes),
295
- historyManager: this.historyManager,
296
- previouslyViewedFilesSetting: this.previouslyViewedFilesSetting,
297
281
  onEditorSelected: this.editorSelected.bind(this),
298
282
  onEditorClosed: this.editorClosed.bind(this),
299
283
  };
@@ -303,17 +287,9 @@ export class SourcesView extends SourcesViewBase implements UI.SearchableView.Se
303
287
  set editorContainer(value: TabbedEditorContainer) {
304
288
  that.setEditorContainer(value);
305
289
  },
306
- set searchableView(value: UI.SearchableView.SearchableView) {
307
- that.#searchableView = value;
308
- },
309
290
  };
310
291
 
311
- this.#view(input, output, this.element);
312
- }
313
-
314
- override onDetach(): void {
315
- super.onDetach();
316
- this.editorContainer?.detachEditors();
292
+ this.#view(input, output, this.contentElement);
317
293
  }
318
294
 
319
295
  setEditorContainer(editorContainer: TabbedEditorContainer): void {
@@ -326,19 +302,6 @@ export class SourcesView extends SourcesViewBase implements UI.SearchableView.Se
326
302
  }
327
303
  }
328
304
 
329
- static defaultUISourceCodeScores(): Map<Workspace.UISourceCode.UISourceCode, number> {
330
- const defaultScores = new Map<Workspace.UISourceCode.UISourceCode, number>();
331
- const sourcesView = UI.Context.Context.instance().flavor(SourcesView);
332
- if (sourcesView) {
333
- const uiSourceCodes = sourcesView.editorContainer?.historyUISourceCodes() ?? [];
334
- for (let i = 1; i < uiSourceCodes.length; ++i) // Skip current element
335
- {
336
- defaultScores.set(uiSourceCodes[i], uiSourceCodes.length - i);
337
- }
338
- }
339
- return defaultScores;
340
- }
341
-
342
305
  set onToggleNavigatorSidebar(callback: () => void) {
343
306
  this.#onToggleNavigatorSidebar = callback;
344
307
  this.requestUpdate();
@@ -398,11 +361,8 @@ export class SourcesView extends SourcesViewBase implements UI.SearchableView.Se
398
361
  super.willHide();
399
362
  }
400
363
 
401
- searchableView(): UI.SearchableView.SearchableView {
402
- if (!this.#searchableView) {
403
- this.performUpdate();
404
- }
405
- return this.#searchableView;
364
+ searchableView(): UI.SearchableView.SearchableView|null {
365
+ return UI.SearchableView.SearchableView.fromElement(this.contentElement.querySelector('devtools-widget'));
406
366
  }
407
367
 
408
368
  visibleView(): UI.Widget.Widget|null {
@@ -431,11 +391,11 @@ export class SourcesView extends SourcesViewBase implements UI.SearchableView.Se
431
391
  }
432
392
 
433
393
  onJumpToPreviousLocation(): void {
434
- this.historyManager.rollback();
394
+ this.editorContainer?.rollback();
435
395
  }
436
396
 
437
397
  onJumpToNextLocation(): void {
438
- this.historyManager.rollover();
398
+ this.editorContainer?.rollover();
439
399
  }
440
400
 
441
401
  #onScopeChange(): void {
@@ -488,9 +448,6 @@ export class SourcesView extends SourcesViewBase implements UI.SearchableView.Se
488
448
 
489
449
  private removeUISourceCodes(uiSourceCodes: Workspace.UISourceCode.UISourceCode[]): void {
490
450
  uiSourceCodes.forEach(ui => this.#uiSourceCodes.delete(ui));
491
- for (let i = 0; i < uiSourceCodes.length; ++i) {
492
- this.historyManager.removeHistoryForSourceCode(uiSourceCodes[i]);
493
- }
494
451
  this.requestUpdate();
495
452
  }
496
453
 
@@ -504,11 +461,11 @@ export class SourcesView extends SourcesViewBase implements UI.SearchableView.Se
504
461
  const view = this.visibleView();
505
462
  if (view instanceof UI.View.SimpleView) {
506
463
  void view.toolbarItems().then(items => {
507
- this.#scriptViewToolbarItems = items;
464
+ this.#scriptViewToolbarItems = Array.isArray(items) ? html`${items.map(item => item.element)}` : items;
508
465
  this.requestUpdate();
509
466
  });
510
467
  } else {
511
- this.#scriptViewToolbarItems = [];
468
+ this.#scriptViewToolbarItems = nothing;
512
469
  this.requestUpdate();
513
470
  }
514
471
  }
@@ -519,20 +476,7 @@ export class SourcesView extends SourcesViewBase implements UI.SearchableView.Se
519
476
  if (!this.editorContainer) {
520
477
  await this.#editorContainerPromise;
521
478
  }
522
- const currentFrame = this.currentSourceFrame();
523
- if (currentFrame) {
524
- this.historyManager.updateCurrentState(currentFrame.uiSourceCode(),
525
- currentFrame.textEditor.state.selection.main.head);
526
- }
527
- this.editorContainer?.showFile(uiSourceCode);
528
- const currentSourceFrame = this.currentSourceFrame();
529
- if (currentSourceFrame && location) {
530
- currentSourceFrame.revealPosition(location, !omitHighlight);
531
- }
532
- const visibleView = this.visibleView();
533
- if (!omitFocus && visibleView) {
534
- visibleView.focus();
535
- }
479
+ this.editorContainer?.showSourceLocation(uiSourceCode, location, omitFocus, omitHighlight);
536
480
  }
537
481
 
538
482
  viewForFile(uiSourceCode: Workspace.UISourceCode.UISourceCode): UI.Widget.Widget|undefined {
@@ -544,8 +488,6 @@ export class SourcesView extends SourcesViewBase implements UI.SearchableView.Se
544
488
  }
545
489
 
546
490
  private editorClosed(uiSourceCode: Workspace.UISourceCode.UISourceCode): void {
547
- this.historyManager.removeHistoryForSourceCode(uiSourceCode);
548
-
549
491
  let wasSelected = false;
550
492
  if (!this.editorContainer?.currentFile()) {
551
493
  wasSelected = true;
@@ -554,7 +496,7 @@ export class SourcesView extends SourcesViewBase implements UI.SearchableView.Se
554
496
  // SourcesNavigator does not need to update on EditorClosed.
555
497
  this.removeToolbarChangedListener();
556
498
  this.updateScriptViewToolbarItems();
557
- this.searchableView().resetSearch();
499
+ this.searchableView()?.resetSearch();
558
500
 
559
501
  const data = {
560
502
  uiSourceCode,
@@ -573,8 +515,9 @@ export class SourcesView extends SourcesViewBase implements UI.SearchableView.Se
573
515
  currentSourceFrame.setSearchableView(this.searchableView());
574
516
  }
575
517
 
576
- this.searchableView().setReplaceable(Boolean(currentSourceFrame?.canEditSource()));
577
- this.searchableView().refreshSearch();
518
+ this.#isSearchReplaceable = Boolean(currentSourceFrame?.canEditSource());
519
+ this.requestUpdate();
520
+ this.searchableView()?.refreshSearch();
578
521
  this.updateToolbarChangedListener();
579
522
  this.updateScriptViewToolbarItems();
580
523
 
@@ -22,8 +22,7 @@ import * as PanelCommon from '../common/common.js';
22
22
  import * as Snippets from '../snippets/snippets.js';
23
23
 
24
24
  import * as Components from './components/components.js';
25
- import type {EditingLocationHistoryManager} from './EditingLocationHistoryManager.js';
26
- import {SourcesView} from './SourcesView.js';
25
+ import {EditingLocationHistoryManager} from './EditingLocationHistoryManager.js';
27
26
  import {UISourceCodeFrame} from './UISourceCodeFrame.js';
28
27
 
29
28
  const UIStrings = {
@@ -103,8 +102,8 @@ interface TabInfo {
103
102
  export interface TabbedEditorViewInput {
104
103
  openTabs: TabInfo[];
105
104
  activeTabId?: string;
106
- leftToolbarItems: Array<UI.Toolbar.ToolbarItem|LitTemplate>;
107
- rightToolbarItems: Array<UI.Toolbar.ToolbarItem|LitTemplate>;
105
+ leftToolbarItems: LitTemplate[];
106
+ rightToolbarItems: LitTemplate[];
108
107
  tabDelegate: UI.TabbedPane.TabbedPaneTabDelegate;
109
108
  shortcuts: Array<{
110
109
  description: Platform.UIString.LocalizedString,
@@ -254,17 +253,17 @@ export const DEFAULT_VIEW: View = (input, _output, target) => {
254
253
  @select=${input.onSelect}
255
254
  >
256
255
  <devtools-toolbar class="tabbed-pane-left-toolbar" slot="left">
257
- ${input.leftToolbarItems.map(item => item instanceof UI.Toolbar.ToolbarItem ? item.element : item)}
256
+ ${input.leftToolbarItems}
258
257
  </devtools-toolbar>
259
258
  <devtools-toolbar class="tabbed-pane-right-toolbar" slot="right">
260
- ${input.rightToolbarItems.map(item => item instanceof UI.Toolbar.ToolbarItem ? item.element : item)}
259
+ ${input.rightToolbarItems}
261
260
  </devtools-toolbar>
262
261
  ${repeat(input.openTabs, tab => tab.tabId, tab => html`
263
262
  <div id=${tab.tabId}
263
+ class="vbox flex-auto"
264
264
  title=${tab.title}
265
265
  ?closeable=${tab.isCloseable}
266
- ?selected=${input.activeTabId === tab.tabId}
267
- style="display: flex; flex: auto;">
266
+ ?selected=${input.activeTabId === tab.tabId}>
268
267
  ${renderTabIcon(tab)}
269
268
  ${renderTabSuffix(tab, input)}
270
269
  ${tab.widget ? html`${widget(UI.Widget.WrapperWidget, {widget: tab.widget})}` : nothing}
@@ -386,13 +385,10 @@ export class TabbedEditorContainer extends TabbedEditorContainerBase {
386
385
  };
387
386
  this.#view(input, undefined, this.contentElement);
388
387
  }
389
- #historyManager!: EditingLocationHistoryManager;
390
- set historyManager(historyManager: EditingLocationHistoryManager) {
391
- this.#historyManager = historyManager;
392
- }
388
+ #historyManager: EditingLocationHistoryManager;
393
389
 
394
- #leftToolbarItems: Array<UI.Toolbar.ToolbarItem|LitTemplate> = [];
395
- set leftToolbarItems(items: Array<UI.Toolbar.ToolbarItem|LitTemplate>) {
390
+ #leftToolbarItems: LitTemplate[] = [];
391
+ set leftToolbarItems(items: LitTemplate[]) {
396
392
  if (this.#leftToolbarItems === items) {
397
393
  return;
398
394
  }
@@ -400,8 +396,8 @@ export class TabbedEditorContainer extends TabbedEditorContainerBase {
400
396
  this.#scheduleUpdate();
401
397
  }
402
398
 
403
- #rightToolbarItems: Array<UI.Toolbar.ToolbarItem|LitTemplate> = [];
404
- set rightToolbarItems(items: Array<UI.Toolbar.ToolbarItem|LitTemplate>) {
399
+ #rightToolbarItems: LitTemplate[] = [];
400
+ set rightToolbarItems(items: LitTemplate[]) {
405
401
  if (this.#rightToolbarItems === items) {
406
402
  return;
407
403
  }
@@ -439,8 +435,8 @@ export class TabbedEditorContainer extends TabbedEditorContainerBase {
439
435
  private tabIds: Map<Workspace.UISourceCode.UISourceCode, string>;
440
436
  private files: Map<string, Workspace.UISourceCode.UISourceCode>;
441
437
  readonly #loadErrorFiles = new Set<Workspace.UISourceCode.UISourceCode>();
442
- #previouslyViewedFilesSetting!: Common.Settings.Setting<SerializedHistoryItem[]>;
443
- history!: History;
438
+ #previouslyViewedFilesSetting: Common.Settings.Setting<SerializedHistoryItem[]>;
439
+ history: History;
444
440
  set previouslyViewedFilesSetting(setting: Common.Settings.Setting<SerializedHistoryItem[]>) {
445
441
  if (this.#previouslyViewedFilesSetting === setting) {
446
442
  return;
@@ -461,6 +457,10 @@ export class TabbedEditorContainer extends TabbedEditorContainerBase {
461
457
  super(element);
462
458
  this.#view = view;
463
459
  this.#tabDelegate = new EditorContainerTabDelegate(this);
460
+ this.#historyManager = new EditingLocationHistoryManager(this);
461
+ this.#previouslyViewedFilesSetting =
462
+ Common.Settings.Settings.instance().createLocalSetting('previously-viewed-files', []);
463
+ this.history = History.fromObject(this.#previouslyViewedFilesSetting.get());
464
464
 
465
465
  this.tabIds = new Map();
466
466
  this.files = new Map();
@@ -478,6 +478,33 @@ export class TabbedEditorContainer extends TabbedEditorContainerBase {
478
478
  Persistence.NetworkPersistenceManager.Events.REQUEST_FOR_HEADER_OVERRIDES_FILE_CHANGED,
479
479
  this.#onRequestsForHeaderOverridesFileChanged, this);
480
480
  }
481
+
482
+ override wasShown(): void {
483
+ super.wasShown();
484
+ UI.Context.Context.instance().setFlavor(TabbedEditorContainer, this);
485
+ }
486
+
487
+ override willHide(): void {
488
+ UI.Context.Context.instance().setFlavor(TabbedEditorContainer, null);
489
+ super.willHide();
490
+ }
491
+
492
+ override onDetach(): void {
493
+ super.onDetach();
494
+ this.detachEditors();
495
+ }
496
+
497
+ static defaultUISourceCodeScores(): Map<Workspace.UISourceCode.UISourceCode, number> {
498
+ const defaultScores = new Map<Workspace.UISourceCode.UISourceCode, number>();
499
+ const editorContainer = UI.Context.Context.instance().flavor(TabbedEditorContainer);
500
+ if (editorContainer) {
501
+ const uiSourceCodes = editorContainer.historyUISourceCodes();
502
+ for (let i = 1; i < uiSourceCodes.length; ++i) { // Skip current element
503
+ defaultScores.set(uiSourceCodes[i], uiSourceCodes.length - i);
504
+ }
505
+ }
506
+ return defaultScores;
507
+ }
481
508
  #tabsHistory: string[] = [];
482
509
  #appendHistory(tabId: string): void {
483
510
  this.#tabsHistory.unshift(tabId);
@@ -556,16 +583,41 @@ export class TabbedEditorContainer extends TabbedEditorContainerBase {
556
583
  return Array.from(this.files.values()).map(getViewByUISourceCode).filter(Boolean) as UI.Widget.Widget[];
557
584
  }
558
585
 
586
+ showSourceLocation(uiSourceCode: Workspace.UISourceCode.UISourceCode,
587
+ location?: SourceFrame.SourceFrame.RevealPosition, omitFocus?: boolean,
588
+ omitHighlight?: boolean): void {
589
+ const currentFrame = this.currentView instanceof UISourceCodeFrame ? this.currentView : null;
590
+ if (currentFrame) {
591
+ this.#historyManager.updateCurrentState(currentFrame.uiSourceCode(),
592
+ currentFrame.textEditor.state.selection.main.head);
593
+ }
594
+ this.showFile(uiSourceCode);
595
+ const currentSourceFrame = this.currentView instanceof UISourceCodeFrame ? this.currentView : null;
596
+ if (currentSourceFrame && location) {
597
+ currentSourceFrame.revealPosition(location, !omitHighlight);
598
+ }
599
+ if (!omitFocus && this.visibleView) {
600
+ this.visibleView.focus();
601
+ }
602
+ }
603
+
604
+ rollback(): void {
605
+ this.#historyManager.rollback();
606
+ }
607
+
608
+ rollover(): void {
609
+ this.#historyManager.rollover();
610
+ }
611
+
559
612
  showFile(uiSourceCode: Workspace.UISourceCode.UISourceCode): void {
560
613
  const binding = Persistence.Persistence.PersistenceImpl.instance().binding(uiSourceCode);
561
614
  uiSourceCode = binding ? binding.fileSystem : uiSourceCode;
562
615
 
563
- const frame = UI.Context.Context.instance().flavor(SourcesView);
564
616
  // If the content has already been set and the current frame is showing
565
617
  // the incoming uiSourceCode, then fire the event that the file has been loaded.
566
618
  // Otherwise, this event will fire as soon as the content has been set.
567
- if (frame?.currentSourceFrame()?.contentSet && this.#currentFile === uiSourceCode &&
568
- frame?.currentUISourceCode() === uiSourceCode) {
619
+ if (this.currentView instanceof UISourceCodeFrame && this.currentView.contentSet &&
620
+ this.#currentFile === uiSourceCode) {
569
621
  window.dispatchEvent(new CustomEvent('source-file-loaded',
570
622
  {bubbles: true, cancelable: true, detail: uiSourceCode.displayName(true)}));
571
623
  } else {
@@ -872,6 +924,7 @@ export class TabbedEditorContainer extends TabbedEditorContainerBase {
872
924
  removeUISourceCodes(uiSourceCodes: Workspace.UISourceCode.UISourceCode[]): void {
873
925
  const tabIds = [];
874
926
  for (const uiSourceCode of uiSourceCodes) {
927
+ this.#historyManager.removeHistoryForSourceCode(uiSourceCode);
875
928
  const tabId = this.tabIds.get(uiSourceCode);
876
929
  if (tabId) {
877
930
  tabIds.push(tabId);
@@ -995,6 +1048,7 @@ export class TabbedEditorContainer extends TabbedEditorContainerBase {
995
1048
  this.files.delete(tabId);
996
1049
 
997
1050
  if (uiSourceCode) {
1051
+ this.#historyManager.removeHistoryForSourceCode(uiSourceCode);
998
1052
  this.removeUISourceCodeListeners(uiSourceCode);
999
1053
  this.removeSourceFrame(uiSourceCode);
1000
1054