chrome-devtools-frontend 1.0.1543082 → 1.0.1543472

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/AUTHORS +1 -0
  2. package/front_end/core/common/Gzip.ts +4 -4
  3. package/front_end/core/common/common.ts +0 -2
  4. package/front_end/core/root/DevToolsContext.ts +60 -0
  5. package/front_end/core/root/root.ts +6 -1
  6. package/front_end/core/sdk/TargetManager.ts +5 -6
  7. package/front_end/entrypoints/inspector_main/InspectorMain.ts +1 -13
  8. package/front_end/entrypoints/main/MainImpl.ts +3 -5
  9. package/front_end/foundation/Universe.ts +13 -1
  10. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +11 -8
  11. package/front_end/models/trace/handlers/SamplesHandler.ts +64 -6
  12. package/front_end/models/trace/types/TraceEvents.ts +16 -0
  13. package/front_end/models/workspace/IgnoreListManager.ts +10 -9
  14. package/front_end/models/workspace/WorkspaceImpl.ts +5 -10
  15. package/front_end/panels/application/ApplicationPanelSidebar.ts +0 -1
  16. package/front_end/panels/application/OpenedWindowDetailsView.ts +0 -2
  17. package/front_end/panels/application/ServiceWorkersView.ts +0 -2
  18. package/front_end/panels/application/StorageView.ts +0 -1
  19. package/front_end/panels/application/components/FrameDetailsView.ts +468 -447
  20. package/front_end/panels/console/ConsoleView.ts +9 -7
  21. package/front_end/panels/console/ConsoleViewMessage.ts +19 -9
  22. package/front_end/panels/explain/components/ConsoleInsight.ts +314 -310
  23. package/front_end/panels/settings/SettingsScreen.ts +3 -6
  24. package/front_end/panels/settings/components/SyncSection.ts +218 -226
  25. package/front_end/panels/settings/components/syncSection.css +81 -80
  26. package/front_end/panels/sources/DebuggerPlugin.ts +3 -1
  27. package/front_end/panels/sources/ResourceOriginPlugin.ts +7 -3
  28. package/front_end/panels/timeline/TimelinePanel.ts +0 -21
  29. package/front_end/ui/components/docs/component_docs.ts +0 -4
  30. package/front_end/ui/components/report_view/ReportView.ts +4 -1
  31. package/front_end/ui/legacy/ReportView.ts +0 -5
  32. package/front_end/ui/legacy/TextPrompt.ts +65 -19
  33. package/front_end/ui/legacy/components/object_ui/JavaScriptREPL.ts +8 -4
  34. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +90 -92
  35. package/front_end/ui/legacy/components/object_ui/RemoteObjectPreviewFormatter.ts +114 -184
  36. package/front_end/ui/legacy/components/utils/Linkifier.ts +1 -1
  37. package/front_end/ui/{components/docs/theme_colors/basic.ts → legacy/theme_support/ThemeColors.docs.ts} +33 -23
  38. package/package.json +1 -1
  39. package/front_end/core/common/QueryParamHandler.ts +0 -7
  40. package/front_end/ui/components/docs/input/basic.html +0 -31
  41. package/front_end/ui/components/docs/input/basic.ts +0 -12
  42. package/front_end/ui/components/docs/report/basic.html +0 -27
  43. package/front_end/ui/components/docs/report/basic.ts +0 -48
  44. package/front_end/ui/components/docs/theme_colors/basic.html +0 -56
  45. package/front_end/ui/components/docs/toggle_dark_mode.ts +0 -36
  46. package/front_end/ui/components/docs/toggle_fonts.ts +0 -74
  47. package/front_end/ui/components/docs/user_agent_client_hints/basic.html +0 -25
  48. package/front_end/ui/components/docs/user_agent_client_hints/basic.ts +0 -26
@@ -48,9 +48,9 @@ import {CustomPreviewComponent} from './CustomPreviewComponent.js';
48
48
  import {JavaScriptREPL} from './JavaScriptREPL.js';
49
49
  import objectPropertiesSectionStyles from './objectPropertiesSection.css.js';
50
50
  import objectValueStyles from './objectValue.css.js';
51
- import {createSpansForNodeTitle, RemoteObjectPreviewFormatter} from './RemoteObjectPreviewFormatter.js';
51
+ import {RemoteObjectPreviewFormatter, renderNodeTitle} from './RemoteObjectPreviewFormatter.js';
52
52
 
53
- const {ifDefined} = Directives;
53
+ const {repeat, ifDefined} = Directives;
54
54
  const UIStrings = {
55
55
  /**
56
56
  * @description Text in Object Properties Section
@@ -653,7 +653,8 @@ export class ObjectPropertiesSection extends UI.TreeOutline.TreeOutlineInShadow
653
653
  valueElement.classList.add('object-value-' + (subtype || type));
654
654
  if (value.preview && showPreview) {
655
655
  const previewFormatter = new RemoteObjectPreviewFormatter();
656
- previewFormatter.appendObjectPreview(valueElement, value.preview, false /* isEntry */);
656
+ /* eslint-disable-next-line @devtools/no-lit-render-outside-of-view */
657
+ render(previewFormatter.renderObjectPreview(value.preview), valueElement);
657
658
  propertyValue = valueElement;
658
659
  UI.Tooltip.Tooltip.install(propertyValue as HTMLElement, description || '');
659
660
  } else if (description.length > maxRenderableStringLength) {
@@ -721,7 +722,8 @@ export class ObjectPropertiesSection extends UI.TreeOutline.TreeOutlineInShadow
721
722
  function createNodeElement(): HTMLElement {
722
723
  const valueElement = document.createElement('span');
723
724
  valueElement.classList.add('object-value-node');
724
- createSpansForNodeTitle(valueElement, (description));
725
+ /* eslint-disable-next-line @devtools/no-lit-render-outside-of-view */
726
+ render(renderNodeTitle(description), valueElement);
725
727
  valueElement.addEventListener('click', event => {
726
728
  void Common.Revealer.reveal(value);
727
729
  event.consume(true);
@@ -914,6 +916,45 @@ export class RootElement extends UI.TreeOutline.TreeElement {
914
916
  **/
915
917
  export const InitialVisibleChildrenLimit = 200;
916
918
 
919
+ export interface TreeElementViewInput {
920
+ onAutoComplete(expression: string, filter: string, force: boolean): unknown;
921
+ completions: string[];
922
+ expandedValueElement: HTMLElement|undefined;
923
+ expanded: boolean;
924
+ editing: boolean;
925
+ editingEnded(): unknown;
926
+ editingCommitted(detail: string): unknown;
927
+ node: ObjectTreeNode;
928
+ nameElement: HTMLElement;
929
+ valueElement: HTMLElement;
930
+ }
931
+ type TreeElementView = (input: TreeElementViewInput, output: object, target: HTMLElement) => void;
932
+ export const TREE_ELEMENT_DEFAULT_VIEW: TreeElementView = (input, output, target) => {
933
+ const isInternalEntries = input.node.property.synthetic && input.node.name === '[[Entries]]';
934
+ if (isInternalEntries) {
935
+ render(html`<span class=name-and-value>${input.nameElement}</span>`, target);
936
+ } else {
937
+ const completionsId = `completions-${input.node.parent?.object?.objectId?.replaceAll('.', '-')}-${input.node.name}`;
938
+ const onAutoComplete = async(e: UI.TextPrompt.TextPromptElement.BeforeAutoCompleteEvent): Promise<void> => {
939
+ if (!(e.target instanceof UI.TextPrompt.TextPromptElement)) {
940
+ return;
941
+ }
942
+ input.onAutoComplete(e.detail.expression, e.detail.filter, e.detail.force);
943
+ };
944
+ // clang-format off
945
+ render(html`<span class=name-and-value>${input.nameElement}<span class='separator'>: </span><devtools-prompt
946
+ @commit=${(e: UI.TextPrompt.TextPromptElement.CommitEvent) => input.editingCommitted(e.detail)}
947
+ @cancel=${() => input.editingEnded()}
948
+ @beforeautocomplete=${onAutoComplete}
949
+ completions=${completionsId}
950
+ placeholder=${i18nString(UIStrings.stringIsTooLargeToEdit)}
951
+ ?editing=${input.editing}>
952
+ ${input.expanded && input.expandedValueElement || input.valueElement}
953
+ <datalist id=${completionsId}>${repeat(input.completions, c => html`<option>${c}</option>`)}</datalist>
954
+ </devtools-prompt></span><span>`, target);
955
+ // clang-format on
956
+ }
957
+ };
917
958
  export class ObjectPropertyTreeElement extends UI.TreeOutline.TreeElement {
918
959
  property: ObjectTreeNode;
919
960
  override toggleOnClick: boolean;
@@ -922,16 +963,19 @@ export class ObjectPropertyTreeElement extends UI.TreeOutline.TreeElement {
922
963
  private readonly maxNumPropertiesToShow: number;
923
964
  nameElement!: HTMLElement;
924
965
  valueElement!: HTMLElement;
925
- private rowContainer!: HTMLElement;
926
966
  readOnly!: boolean;
927
967
  private prompt!: ObjectPropertyPrompt|undefined;
928
968
  private editableDiv!: HTMLElement;
929
969
  propertyValue?: HTMLElement;
930
- expandedValueElement?: Element|null;
931
- constructor(property: ObjectTreeNode, linkifier?: Components.Linkifier.Linkifier) {
970
+ expandedValueElement?: HTMLElement;
971
+ #editing = false;
972
+ readonly #view: TreeElementView;
973
+ #completions: string[] = [];
974
+ constructor(property: ObjectTreeNode, linkifier?: Components.Linkifier.Linkifier, view = TREE_ELEMENT_DEFAULT_VIEW) {
932
975
  // Pass an empty title, the title gets made later in onattach.
933
976
  super();
934
977
 
978
+ this.#view = view;
935
979
  this.property = property;
936
980
  this.toggleOnClick = true;
937
981
  this.highlightChanges = [];
@@ -1168,29 +1212,19 @@ export class ObjectPropertyTreeElement extends UI.TreeOutline.TreeElement {
1168
1212
  }
1169
1213
 
1170
1214
  override onexpand(): void {
1171
- this.showExpandedValueElement(true);
1215
+ this.performUpdate();
1172
1216
  }
1173
1217
 
1174
1218
  override oncollapse(): void {
1175
- this.showExpandedValueElement(false);
1219
+ this.performUpdate();
1176
1220
  }
1177
1221
 
1178
- private showExpandedValueElement(value: boolean): void {
1179
- if (!this.expandedValueElement) {
1180
- return;
1181
- }
1182
- if (value) {
1183
- this.rowContainer.replaceChild(this.expandedValueElement, this.valueElement);
1184
- } else {
1185
- this.rowContainer.replaceChild(this.valueElement, this.expandedValueElement);
1186
- }
1187
- }
1188
-
1189
- private createExpandedValueElement(value: SDK.RemoteObject.RemoteObject, isSyntheticProperty: boolean): Element|null {
1222
+ private createExpandedValueElement(value: SDK.RemoteObject.RemoteObject, isSyntheticProperty: boolean): HTMLElement
1223
+ |undefined {
1190
1224
  const needsAlternateValue = value.hasChildren && !value.customPreview() && value.subtype !== 'node' &&
1191
1225
  value.type !== 'function' && (value.type !== 'object' || value.preview);
1192
1226
  if (!needsAlternateValue) {
1193
- return null;
1227
+ return undefined;
1194
1228
  }
1195
1229
 
1196
1230
  const valueElement = document.createElement('span');
@@ -1264,24 +1298,29 @@ export class ObjectPropertyTreeElement extends UI.TreeOutline.TreeElement {
1264
1298
  this.expandedValueElement =
1265
1299
  this.createExpandedValueElement(this.property.object, this.property.property.synthetic);
1266
1300
  }
1301
+ this.performUpdate();
1302
+ }
1267
1303
 
1268
- const adorner: Element|string = '';
1269
- let container: Element;
1270
-
1271
- if (isInternalEntries) {
1272
- container = UI.Fragment.html`
1273
- <span class='name-and-value'>${adorner}${this.nameElement}</span>
1274
- `;
1275
- } else {
1276
- container = UI.Fragment.html`
1277
- <span class='name-and-value'>${adorner}${this.nameElement}<span class='separator'>: </span>${
1278
- this.valueElement}</span>
1279
- `;
1280
- }
1304
+ async #updateCompletions(expression: string, filter: string, force: boolean): Promise<void> {
1305
+ const suggestions = await TextEditor.JavaScript.completeInContext(expression, filter, force);
1306
+ this.#completions = suggestions.map(v => v.text);
1307
+ this.performUpdate();
1308
+ }
1281
1309
 
1282
- this.listItemElement.removeChildren();
1283
- this.rowContainer = (container as HTMLElement);
1284
- this.listItemElement.appendChild(this.rowContainer);
1310
+ performUpdate(): void {
1311
+ const input: TreeElementViewInput = {
1312
+ expandedValueElement: this.expandedValueElement,
1313
+ expanded: this.expanded,
1314
+ editing: this.#editing,
1315
+ editingEnded: this.editingEnded.bind(this),
1316
+ editingCommitted: this.editingCommitted.bind(this),
1317
+ node: this.property,
1318
+ nameElement: this.nameElement,
1319
+ valueElement: this.valueElement,
1320
+ completions: this.#editing ? this.#completions : [],
1321
+ onAutoComplete: this.#updateCompletions.bind(this),
1322
+ };
1323
+ this.#view(input, {}, this.listItemElement);
1285
1324
  }
1286
1325
 
1287
1326
  getContextMenu(event: Event): UI.ContextMenu.ContextMenu {
@@ -1325,69 +1364,28 @@ export class ObjectPropertyTreeElement extends UI.TreeOutline.TreeElement {
1325
1364
  void contextMenu.show();
1326
1365
  }
1327
1366
 
1328
- private startEditing(): void {
1329
- const treeOutline = (this.treeOutline as ObjectPropertiesSectionsTreeOutline | null);
1330
- if (this.prompt || !treeOutline || !treeOutline.editable || this.readOnly) {
1331
- return;
1332
- }
1333
- this.editableDiv = this.rowContainer.createChild('span', 'editable-div');
1334
-
1335
- if (this.property.object) {
1336
- let text: string|(string | undefined) = this.property.object.description;
1337
- if (this.property.object.type === 'string' && typeof text === 'string') {
1338
- text = `"${text}"`;
1339
- }
1340
-
1341
- this.editableDiv.setTextContentTruncatedIfNeeded(text, i18nString(UIStrings.stringIsTooLargeToEdit));
1342
- }
1343
-
1344
- const originalContent = this.editableDiv.textContent || '';
1345
-
1346
- // Lie about our children to prevent expanding on double click and to collapse subproperties.
1347
- this.setExpandable(false);
1348
- this.listItemElement.classList.add('editing-sub-part');
1349
- this.valueElement.classList.add('hidden');
1350
-
1351
- this.prompt = new ObjectPropertyPrompt();
1352
-
1353
- const proxyElement =
1354
- this.prompt.attachAndStartEditing(this.editableDiv, this.editingCommitted.bind(this, originalContent));
1355
- proxyElement.classList.add('property-prompt');
1356
-
1357
- const selection = this.listItemElement.getComponentSelection();
1367
+ get editing(): boolean {
1368
+ return this.#editing;
1369
+ }
1358
1370
 
1359
- if (selection) {
1360
- selection.selectAllChildren(this.editableDiv);
1371
+ private startEditing(): void {
1372
+ if (!this.readOnly) {
1373
+ this.#editing = true;
1374
+ this.performUpdate();
1361
1375
  }
1362
- proxyElement.addEventListener('keydown', this.promptKeyDown.bind(this, originalContent), false);
1363
1376
  }
1364
1377
 
1365
1378
  private editingEnded(): void {
1366
- if (this.prompt) {
1367
- this.prompt.detach();
1368
- delete this.prompt;
1369
- }
1370
- this.editableDiv.remove();
1379
+ this.#completions = [];
1380
+ this.#editing = false;
1381
+ this.performUpdate();
1371
1382
  this.updateExpandable();
1372
- this.listItemElement.scrollLeft = 0;
1373
- this.listItemElement.classList.remove('editing-sub-part');
1374
1383
  this.select();
1375
1384
  }
1376
1385
 
1377
- private editingCancelled(): void {
1378
- this.valueElement.classList.remove('hidden');
1379
- this.editingEnded();
1380
- }
1381
-
1382
- private async editingCommitted(originalContent: string): Promise<void> {
1383
- const userInput = this.prompt ? this.prompt.text() : '';
1384
- if (userInput === originalContent) {
1385
- this.editingCancelled(); // nothing changed, so cancel
1386
- return;
1387
- }
1388
-
1386
+ private async editingCommitted(newContent: string): Promise<void> {
1389
1387
  this.editingEnded();
1390
- await this.applyExpression(userInput);
1388
+ await this.applyExpression(newContent);
1391
1389
  }
1392
1390
 
1393
1391
  private promptKeyDown(originalContent: string, event: Event): void {
@@ -1399,7 +1397,7 @@ export class ObjectPropertyTreeElement extends UI.TreeOutline.TreeElement {
1399
1397
  }
1400
1398
  if (keyboardEvent.key === Platform.KeyboardUtilities.ESCAPE_KEY) {
1401
1399
  keyboardEvent.consume();
1402
- this.editingCancelled();
1400
+ this.editingEnded();
1403
1401
  return;
1404
1402
  }
1405
1403
  }