chrome-devtools-frontend 1.0.1585664 → 1.0.1587572

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 (48) hide show
  1. package/front_end/core/common/Srcset.ts +61 -0
  2. package/front_end/core/common/common.ts +2 -0
  3. package/front_end/entrypoint_template.html +5 -1
  4. package/front_end/generated/InspectorBackendCommands.ts +1 -1
  5. package/front_end/generated/protocol.ts +2 -0
  6. package/front_end/models/ai_assistance/AiConversation.ts +6 -2
  7. package/front_end/models/javascript_metadata/NativeFunctions.js +2 -2
  8. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +1 -0
  9. package/front_end/panels/application/ServiceWorkerCacheViews.ts +1 -2
  10. package/front_end/panels/console/PromptBuilder.ts +15 -3
  11. package/front_end/panels/elements/ElementsPanel.ts +114 -15
  12. package/front_end/panels/elements/ElementsTreeElement.ts +4 -56
  13. package/front_end/panels/network/NetworkItemView.ts +4 -3
  14. package/front_end/panels/network/{components/RequestHeadersView.ts → RequestHeadersView.ts} +112 -184
  15. package/front_end/panels/network/components/RequestHeaderSection.ts +3 -0
  16. package/front_end/panels/network/components/components.ts +0 -2
  17. package/front_end/panels/network/network.ts +3 -0
  18. package/front_end/panels/sources/CallStackSidebarPane.ts +3 -7
  19. package/front_end/panels/utils/utils.ts +13 -5
  20. package/front_end/third_party/chromium/README.chromium +1 -1
  21. package/front_end/third_party/puppeteer/README.chromium +2 -2
  22. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/FrameManager.js +1 -1
  23. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/FrameManager.js.map +1 -1
  24. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/util.d.ts.map +1 -1
  25. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/util.js +7 -7
  26. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/util.js.map +1 -1
  27. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +3 -3
  28. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +3 -3
  29. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
  30. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
  31. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +7 -7
  32. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/FrameManager.js +1 -1
  33. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/FrameManager.js.map +1 -1
  34. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/util.d.ts.map +1 -1
  35. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/util.js +7 -7
  36. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/util.js.map +1 -1
  37. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +3 -3
  38. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +3 -3
  39. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
  40. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
  41. package/front_end/third_party/puppeteer/package/package.json +2 -2
  42. package/front_end/third_party/puppeteer/package/src/cdp/FrameManager.ts +1 -1
  43. package/front_end/third_party/puppeteer/package/src/common/util.ts +9 -8
  44. package/front_end/third_party/puppeteer/package/src/revisions.ts +3 -3
  45. package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
  46. package/front_end/ui/legacy/UIUtils.ts +31 -14
  47. package/front_end/ui/legacy/components/utils/JSPresentationUtils.ts +135 -142
  48. package/package.json +1 -1
@@ -1,7 +1,6 @@
1
1
  // Copyright 2021 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
4
 
6
5
  /*
7
6
  * Copyright (C) 2011 Google Inc. All rights reserved.
@@ -38,12 +37,15 @@ import * as i18n from '../../../../core/i18n/i18n.js';
38
37
  import * as SDK from '../../../../core/sdk/sdk.js';
39
38
  import * as StackTrace from '../../../../models/stack_trace/stack_trace.js';
40
39
  import * as Workspace from '../../../../models/workspace/workspace.js';
40
+ import {Directives, html, nothing, render, type TemplateResult} from '../../../lit/lit.js';
41
41
  import * as VisualLogging from '../../../visual_logging/visual_logging.js';
42
42
  import * as UI from '../../legacy.js';
43
43
 
44
44
  import jsUtilsStyles from './jsUtils.css.js';
45
45
  import {Linkifier} from './Linkifier.js';
46
46
 
47
+ const {classMap} = Directives;
48
+
47
49
  const UIStrings = {
48
50
  /**
49
51
  * @description Text to stop preventing the debugger from stepping into library code
@@ -89,128 +91,110 @@ function populateContextMenu(link: Element, event: Event): void {
89
91
  void contextMenu.show();
90
92
  }
91
93
 
92
- function buildStackTraceRows(
93
- stackTrace: StackTrace.StackTrace.StackTrace,
94
- tabStops: boolean|undefined,
95
- showColumnNumber?: boolean,
96
- ): Array<StackTraceRegularRow|StackTraceAsyncRow> {
97
- const stackTraceRows: Array<StackTraceRegularRow|StackTraceAsyncRow> = [];
98
-
99
- function buildStackTraceRowsHelper(
100
- fragment: StackTrace.StackTrace.Fragment|StackTrace.StackTrace.AsyncFragment,
101
- previousFragment: StackTrace.StackTrace.Fragment|undefined = undefined): void {
102
- let asyncRow: StackTraceAsyncRow|null = null;
103
- const isAsync = 'description' in fragment;
104
- if (previousFragment && isAsync) {
105
- asyncRow = {
106
- asyncDescription: UI.UIUtils.asyncStackTraceLabel(
107
- fragment.description, previousFragment.frames.map(f => ({functionName: f.name ?? ''}))),
108
- };
109
- stackTraceRows.push(asyncRow);
110
- }
111
- let previousStackFrameWasBreakpointCondition = false;
112
- for (const frame of fragment.frames) {
113
- const functionName = UI.UIUtils.beautifyFunctionName(frame.name ?? '');
114
- const link = Linkifier.linkifyStackTraceFrame(frame, {
115
- showColumnNumber,
116
- tabStop: Boolean(tabStops),
117
- inlineFrameIndex: 0,
118
- revealBreakpoint: previousStackFrameWasBreakpointCondition,
119
- maxLength: UI.UIUtils.MaxLengthForDisplayedURLsInConsole,
120
- });
121
- link.setAttribute('jslog', `${VisualLogging.link('stack-trace').track({click: true})}`);
122
- link.addEventListener('contextmenu', populateContextMenu.bind(null, link));
123
-
124
- stackTraceRows.push({functionName, link});
125
- previousStackFrameWasBreakpointCondition = [
126
- SDK.DebuggerModel.COND_BREAKPOINT_SOURCE_URL,
127
- SDK.DebuggerModel.LOGPOINT_SOURCE_URL,
128
- ].includes(frame.url ?? '');
129
- }
130
- }
131
-
132
- buildStackTraceRowsHelper(stackTrace.syncFragment);
133
- let previousFragment = stackTrace.syncFragment;
134
- for (const asyncFragment of stackTrace.asyncFragments) {
135
- if (asyncFragment.frames.length) {
136
- buildStackTraceRowsHelper(asyncFragment, previousFragment);
137
- }
138
- previousFragment = asyncFragment;
139
- }
140
- return stackTraceRows;
94
+ export interface ViewInput {
95
+ stackTrace?: StackTrace.StackTrace.StackTrace;
96
+ tabStops?: boolean;
97
+ widthConstrained?: boolean;
98
+ showColumnNumber?: boolean;
99
+ expandable?: boolean;
100
+ expanded?: boolean;
101
+ showIgnoreListed?: boolean;
102
+ onExpand: () => void;
103
+ onShowMore: () => void;
104
+ onShowLess: () => void;
141
105
  }
142
106
 
143
- function renderStackTraceTable(
144
- container: Element, parent: Element, expandable: boolean,
145
- stackTraceRows: Array<StackTraceRegularRow|StackTraceAsyncRow>): void {
146
- container.removeChildren();
107
+ export type View = (input: ViewInput, output: object, target: HTMLElement) => void;
147
108
 
148
- // The tableSection groups one or more synchronous call frames together.
149
- // Wherever there is an asynchronous call, a new section is created.
150
- let tableSection: Element|null = null;
151
- let firstRow = true;
152
- for (const item of stackTraceRows) {
153
- if (!tableSection || 'asyncDescription' in item) {
154
- tableSection = container.createChild('tbody');
155
- }
109
+ export const DEFAULT_VIEW: View = (input, output, target) => {
110
+ let renderExpandButton = Boolean(input.expandable);
111
+ const maybeRenderExpandButton = (): TemplateResult => {
112
+ // clang-format off
113
+ const result = html`
114
+ ${renderExpandButton ? html`
115
+ <button class="arrow-icon-button" jslog=${VisualLogging.expand().track({click: true})} @click=${input.onExpand}>
116
+ <span class="arrow-icon"></span>
117
+ </button>
118
+ ` : '\n'}`;
119
+ // clang-format on
120
+ renderExpandButton = false;
121
+ return result;
122
+ };
156
123
 
157
- const row = tableSection.createChild('tr');
158
- if (firstRow && expandable) {
159
- const button = row.createChild('td').createChild('button', 'arrow-icon-button');
160
- button.createChild('span', 'arrow-icon');
161
- parent.classList.add('expandable');
162
- container.classList.add('expandable');
163
- button.addEventListener('click', () => {
164
- button.setAttribute('jslog', `${VisualLogging.expand().track({click: true})}`);
165
- parent.classList.toggle('expanded');
166
- container.classList.toggle('expanded');
167
- });
168
- firstRow = false;
169
- } else {
170
- row.createChild('td').textContent = '\n';
171
- }
172
- if ('asyncDescription' in item) {
173
- row.createChild('td', 'stack-preview-async-description').textContent = item.asyncDescription;
174
- row.createChild('td');
175
- row.createChild('td');
176
- row.classList.add('stack-preview-async-row');
177
- } else {
178
- row.createChild('td', 'function-name').textContent = item.functionName;
179
- row.createChild('td').textContent = ' @ ';
180
- row.createChild('td', 'link').appendChild(item.link);
181
- }
182
- }
183
-
184
- tableSection = container.createChild('tfoot');
185
- const showAllRow = tableSection.createChild('tr', 'show-all-link');
186
- showAllRow.createChild('td');
187
- const cell = showAllRow.createChild('td');
188
- cell.colSpan = 4;
189
- const showAllLink = cell.createChild('span', 'link');
190
- // Don't directly put the text of the link in the DOM, as it will likely be
191
- // invisible and it may be confusing if it is copied to the clipboard.
192
- showAllLink.createChild('span', 'css-inserted-text')
193
- .setAttribute('data-inserted-text', i18nString(UIStrings.showMoreFrames));
194
- showAllLink.addEventListener('click', () => {
195
- container.classList.add('show-hidden-rows');
196
- parent.classList.add('show-hidden-rows');
197
- // If we are in a popup, this will trigger a re-layout
198
- UI.GlassPane.GlassPane.containerMoved(container);
199
- }, false);
200
- const showLessRow = tableSection.createChild('tr', 'show-less-link');
201
- showLessRow.createChild('td');
202
- const showLesscell = showLessRow.createChild('td');
203
- showLesscell.colSpan = 4;
204
- const showLessLink = showLesscell.createChild('span', 'link');
205
- showLessLink.createChild('span', 'css-inserted-text')
206
- .setAttribute('data-inserted-text', i18nString(UIStrings.showLess));
207
- showLessLink.addEventListener('click', () => {
208
- container.classList.remove('show-hidden-rows');
209
- parent.classList.remove('show-hidden-rows');
210
- // If we are in a popup, this will trigger a re-layout
211
- UI.GlassPane.GlassPane.containerMoved(container);
212
- }, false);
213
- }
124
+ const classes = {
125
+ 'stack-preview-container': true,
126
+ 'width-constrained': Boolean(input.widthConstrained),
127
+ expandable: Boolean(input.expandable),
128
+ expanded: Boolean(input.expanded),
129
+ 'show-hidden-rows': Boolean(input.showIgnoreListed),
130
+ };
131
+ const {stackTrace} = input;
132
+ // clang-format off
133
+ render(html`
134
+ <style>${jsUtilsStyles}</style>
135
+ <table class=${classMap(classes)}>
136
+ ${stackTrace ? html`
137
+ ${[stackTrace.syncFragment, ...stackTrace.asyncFragments].map(fragment => html`
138
+ <tbody>
139
+ ${'description' in fragment ? html`
140
+ <tr class="stack-preview-async-row">
141
+ <td>${maybeRenderExpandButton()}</td>
142
+ <td class="stack-preview-async-description">
143
+ ${UI.UIUtils.asyncFragmentLabel(stackTrace, fragment as StackTrace.StackTrace.AsyncFragment)}
144
+ </td>
145
+ <td></td>
146
+ <td></td>
147
+ </tr>
148
+ ` : nothing}
149
+ ${fragment.frames.map((frame, i) => {
150
+ const previousStackFrameWasBreakpointCondition = i > 0 && [
151
+ SDK.DebuggerModel.COND_BREAKPOINT_SOURCE_URL,
152
+ SDK.DebuggerModel.LOGPOINT_SOURCE_URL,
153
+ ].includes(fragment.frames[i - 1].url ?? '');
154
+ const link = Linkifier.linkifyStackTraceFrame(frame, {
155
+ showColumnNumber: Boolean(input.showColumnNumber),
156
+ tabStop: Boolean(input.tabStops),
157
+ inlineFrameIndex: 0,
158
+ revealBreakpoint: previousStackFrameWasBreakpointCondition,
159
+ maxLength: UI.UIUtils.MaxLengthForDisplayedURLsInConsole,
160
+ });
161
+ link.setAttribute('jslog', `${VisualLogging.link('stack-trace').track({click: true})}`);
162
+ link.addEventListener('contextmenu', populateContextMenu.bind(null, link));
163
+ return html`
164
+ <tr>
165
+ <td>${maybeRenderExpandButton()}</td>
166
+ <td class="function-name">
167
+ ${UI.UIUtils.beautifyFunctionName(frame.name ?? '')}
168
+ </td>
169
+ <td> @ </td>
170
+ <td class="link">${link}</td>
171
+ </tr>
172
+ `;})}
173
+ </tbody>
174
+ `)}
175
+ <tfoot>
176
+ <tr class="show-all-link">
177
+ <td></td>
178
+ <td colspan="3">
179
+ <span class="link" @click=${input.onShowMore}>
180
+ <span class="css-inserted-text" data-inserted-text=${i18nString(UIStrings.showMoreFrames)}></span>
181
+ </span>
182
+ </td>
183
+ </tr>
184
+ <tr class="show-less-link">
185
+ <td></td>
186
+ <td colspan="3">
187
+ <span class="link" @click=${input.onShowLess}>
188
+ <span class="css-inserted-text" data-inserted-text=${i18nString(UIStrings.showLess)}></span>
189
+ </span>
190
+ </td>
191
+ </tr>
192
+ </tfoot>
193
+ ` : nothing}
194
+ </table>
195
+ `, target);
196
+ // clang-format on
197
+ };
214
198
 
215
199
  export interface Options {
216
200
  tabStops?: boolean;
@@ -222,27 +206,17 @@ export interface Options {
222
206
  expandable?: boolean;
223
207
  }
224
208
 
225
- interface StackTraceRegularRow {
226
- functionName: string;
227
- link: HTMLElement;
228
- }
229
-
230
- interface StackTraceAsyncRow {
231
- asyncDescription: string;
232
- }
233
-
234
209
  export class StackTracePreviewContent extends UI.Widget.Widget {
210
+ readonly #view: View;
211
+
235
212
  #stackTrace?: StackTrace.StackTrace.StackTrace;
236
213
  #options: Options = {};
214
+ #expanded = false;
215
+ #showIgnoreListed = false;
237
216
 
238
- readonly #table: HTMLElement;
239
-
240
- constructor(element?: HTMLElement) {
217
+ constructor(element?: HTMLElement, view = DEFAULT_VIEW) {
241
218
  super(element, {useShadowDom: true, classes: ['monospace', 'stack-preview-container']});
242
-
243
- UI.DOMUtilities.appendStyle(this.element.shadowRoot as ShadowRoot, jsUtilsStyles);
244
-
245
- this.#table = this.contentElement.createChild('table', 'stack-preview-container');
219
+ this.#view = view;
246
220
  }
247
221
 
248
222
  hasContent(): boolean {
@@ -254,13 +228,20 @@ export class StackTracePreviewContent extends UI.Widget.Widget {
254
228
  }
255
229
 
256
230
  override performUpdate(): void {
257
- if (!this.#stackTrace) {
258
- return;
259
- }
231
+ this.element.classList.toggle('expandable', this.#options.expandable);
232
+ this.element.classList.toggle('expanded', this.#expanded);
233
+ this.element.classList.toggle('show-hidden-rows', this.#showIgnoreListed);
260
234
 
261
- const stackTraceRows =
262
- buildStackTraceRows(this.#stackTrace, this.#options.tabStops, this.#options.showColumnNumber);
263
- renderStackTraceTable(this.#table, this.element, this.#options.expandable ?? false, stackTraceRows);
235
+ const input: ViewInput = {
236
+ stackTrace: this.#stackTrace,
237
+ ...this.#options,
238
+ expanded: this.#expanded,
239
+ showIgnoreListed: this.#showIgnoreListed,
240
+ onExpand: this.#onExpand.bind(this),
241
+ onShowMore: this.#onShowMoreLess.bind(this, true),
242
+ onShowLess: this.#onShowMoreLess.bind(this, false),
243
+ };
244
+ this.#view(input, {}, this.contentElement);
264
245
  }
265
246
 
266
247
  get linkElements(): readonly HTMLElement[] {
@@ -269,7 +250,6 @@ export class StackTracePreviewContent extends UI.Widget.Widget {
269
250
 
270
251
  set options(options: Options) {
271
252
  this.#options = options;
272
- this.#table.classList.toggle('width-constrained', this.#options.widthConstrained ?? false);
273
253
  this.requestUpdate();
274
254
  }
275
255
 
@@ -281,4 +261,17 @@ export class StackTracePreviewContent extends UI.Widget.Widget {
281
261
  this.#stackTrace.addEventListener(StackTrace.StackTrace.Events.UPDATED, this.requestUpdate, this);
282
262
  this.requestUpdate();
283
263
  }
264
+
265
+ #onShowMoreLess(more: boolean): void {
266
+ this.#showIgnoreListed = more;
267
+ this.requestUpdate();
268
+
269
+ // If we are in a popup, this will trigger a re-layout
270
+ void this.updateComplete.then(() => UI.GlassPane.GlassPane.containerMoved(this.contentElement));
271
+ }
272
+
273
+ #onExpand(): void {
274
+ this.#expanded = !this.#expanded;
275
+ this.requestUpdate();
276
+ }
284
277
  }
package/package.json CHANGED
@@ -105,5 +105,5 @@
105
105
  "flat-cache": "6.1.12"
106
106
  }
107
107
  },
108
- "version": "1.0.1585664"
108
+ "version": "1.0.1587572"
109
109
  }