chrome-devtools-frontend 1.0.1679704 → 1.0.1681498

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 (125) hide show
  1. package/AUTHORS +1 -0
  2. package/front_end/core/platform/TypescriptUtilities.ts +0 -9
  3. package/front_end/core/platform/platform.ts +1 -1
  4. package/front_end/core/sdk/ConsoleModel.ts +6 -3
  5. package/front_end/core/sdk/DOMModel.ts +110 -0
  6. package/front_end/core/sdk/EmulationModel.ts +4 -2
  7. package/front_end/core/sdk/NetworkManager.ts +15 -9
  8. package/front_end/core/sdk/OverlayModel.ts +3 -2
  9. package/front_end/core/sdk/PageResourceLoader.ts +4 -3
  10. package/front_end/core/sdk/RuntimeModel.ts +5 -3
  11. package/front_end/core/sdk/SDKSettings.ts +66 -0
  12. package/front_end/entrypoints/inspector_main/RenderingOptions.ts +4 -2
  13. package/front_end/entrypoints/inspector_main/inspector_main-meta.ts +32 -0
  14. package/front_end/entrypoints/main/MainImpl.ts +1 -1
  15. package/front_end/entrypoints/main/main-meta.ts +82 -0
  16. package/front_end/entrypoints/shell/shell.ts +0 -3
  17. package/front_end/entrypoints/trace_app/trace_app.ts +0 -3
  18. package/front_end/generated/InspectorBackendCommands.ts +3 -1
  19. package/front_end/generated/SupportedCSSProperties.ts +20 -0
  20. package/front_end/generated/protocol-mapping.d.ts +7 -0
  21. package/front_end/generated/protocol-proxy-api.d.ts +5 -0
  22. package/front_end/generated/protocol.ts +15 -3
  23. package/front_end/models/ai_code_completion/debug.ts +6 -3
  24. package/front_end/models/ai_code_generation/debug.ts +6 -3
  25. package/front_end/models/badges/UserBadges.ts +9 -2
  26. package/front_end/models/emulation/DeviceModeModel.ts +16 -27
  27. package/front_end/models/emulation/EmulatedDevices.ts +30 -125
  28. package/front_end/models/extensions/ExtensionAPI.ts +34 -23
  29. package/front_end/models/logs/NetworkLog.ts +3 -3
  30. package/front_end/models/logs/logs-meta.ts +0 -60
  31. package/front_end/models/persistence/NetworkPersistenceManager.ts +7 -1
  32. package/front_end/panels/application/ServiceWorkersView.ts +1 -1
  33. package/front_end/panels/application/StorageView.ts +2 -0
  34. package/front_end/panels/common/BadgeNotification.ts +1 -1
  35. package/front_end/panels/common/ExtensionPanel.ts +12 -7
  36. package/front_end/panels/common/ExtensionServer.ts +76 -16
  37. package/front_end/panels/common/GdpSignUpDialog.ts +1 -1
  38. package/front_end/panels/console/ConsoleView.ts +4 -2
  39. package/front_end/panels/console/ConsoleViewMessage.ts +3 -2
  40. package/front_end/panels/console/console-meta.ts +19 -5
  41. package/front_end/panels/elements/CSSRuleValidator.ts +12 -12
  42. package/front_end/panels/elements/CSSSpecificityBreakdown.ts +1 -1
  43. package/front_end/panels/elements/ClassesPaneWidget.ts +6 -6
  44. package/front_end/panels/elements/ColorSwatchPopoverIcon.ts +1 -1
  45. package/front_end/panels/elements/ComputedStyleWidget.ts +4 -5
  46. package/front_end/panels/elements/DOMTreeContextMenu.ts +538 -0
  47. package/front_end/panels/elements/ElementIssueUtils.ts +20 -20
  48. package/front_end/panels/elements/ElementStatePaneWidget.ts +6 -6
  49. package/front_end/panels/elements/ElementsPanel.ts +10 -10
  50. package/front_end/panels/elements/ElementsTreeElement.ts +47 -514
  51. package/front_end/panels/elements/ElementsTreeOutline.ts +168 -297
  52. package/front_end/panels/elements/EventListenersWidget.ts +8 -8
  53. package/front_end/panels/elements/LayersWidget.ts +4 -4
  54. package/front_end/panels/elements/LayoutPane.ts +11 -11
  55. package/front_end/panels/elements/MarkerDecorator.ts +3 -3
  56. package/front_end/panels/elements/PlatformFontsWidget.ts +8 -8
  57. package/front_end/panels/elements/PropertiesWidget.ts +4 -4
  58. package/front_end/panels/elements/PropertyRenderer.ts +2 -2
  59. package/front_end/panels/elements/ShortcutTreeElement.ts +1 -1
  60. package/front_end/panels/elements/StylePropertiesSection.ts +14 -14
  61. package/front_end/panels/elements/StylePropertyTreeElement.ts +21 -21
  62. package/front_end/panels/elements/StylesSidebarPane.ts +14 -14
  63. package/front_end/panels/elements/components/AccessibilityTreeNode.ts +1 -1
  64. package/front_end/panels/elements/components/CSSHintDetailsView.ts +1 -1
  65. package/front_end/panels/elements/components/CSSVariableValueView.ts +3 -3
  66. package/front_end/panels/elements/components/ElementsBreadcrumbsUtils.ts +2 -2
  67. package/front_end/panels/elements/components/ElementsTreeExpandButton.ts +1 -1
  68. package/front_end/panels/elements/elements-meta.ts +13 -13
  69. package/front_end/panels/elements/elements.ts +3 -0
  70. package/front_end/panels/issues/AffectedCookiesView.ts +2 -0
  71. package/front_end/panels/issues/AffectedElementsView.ts +5 -0
  72. package/front_end/panels/issues/CorsIssueDetailsView.ts +13 -9
  73. package/front_end/panels/issues/IssueView.ts +7 -2
  74. package/front_end/panels/layer_viewer/LayerDetailsView.ts +11 -7
  75. package/front_end/panels/layer_viewer/LayerTreeOutline.ts +2 -0
  76. package/front_end/panels/mobile_throttling/NetworkPanelIndicator.ts +3 -1
  77. package/front_end/panels/network/NetworkConfigView.ts +2 -1
  78. package/front_end/panels/network/NetworkLogView.ts +5 -2
  79. package/front_end/panels/network/NetworkOverview.ts +11 -5
  80. package/front_end/panels/network/NetworkPanel.ts +3 -2
  81. package/front_end/panels/network/NetworkWaterfallColumn.ts +16 -3
  82. package/front_end/panels/network/RequestHeadersView.ts +4 -4
  83. package/front_end/panels/network/components/ResponseHeaderSection.ts +6 -2
  84. package/front_end/panels/network/network-meta.ts +117 -0
  85. package/front_end/panels/profiler/HeapDetachedElementsDataGrid.ts +2 -1
  86. package/front_end/panels/profiler/ProfileLauncherView.ts +19 -16
  87. package/front_end/panels/profiler/ProfileSidebarTreeElement.ts +1 -1
  88. package/front_end/panels/security/security.ts +6 -0
  89. package/front_end/panels/settings/components/SyncSection.ts +1 -1
  90. package/front_end/panels/settings/emulation/DevicesSettingsTab.ts +0 -3
  91. package/front_end/panels/sources/NavigatorView.ts +6 -2
  92. package/front_end/panels/sources/SourcesNavigator.ts +8 -4
  93. package/front_end/panels/sources/SourcesPanel.ts +4 -2
  94. package/front_end/panels/sources/SourcesSearchScope.ts +3 -1
  95. package/front_end/panels/sources/SourcesView.ts +8 -107
  96. package/front_end/panels/sources/TabbedEditorContainer.ts +110 -7
  97. package/front_end/panels/sources/UISourceCodeFrame.ts +2 -2
  98. package/front_end/panels/sources/sources-meta.ts +16 -0
  99. package/front_end/panels/timeline/TimelineLoader.ts +1 -1
  100. package/front_end/panels/timeline/TimelineUIUtils.ts +6 -0
  101. package/front_end/panels/timeline/components/LayoutShiftDetails.ts +4 -3
  102. package/front_end/panels/timeline/components/LiveMetricsView.ts +1 -1
  103. package/front_end/panels/timeline/components/MetricCard.ts +4 -3
  104. package/front_end/panels/timeline/components/NetworkRequestDetails.ts +5 -2
  105. package/front_end/panels/timeline/components/TimelineRangeSummaryView.ts +1 -1
  106. package/front_end/panels/timeline/components/TimelineSummary.ts +8 -5
  107. package/front_end/panels/web_audio/WebAudioView.ts +8 -0
  108. package/front_end/third_party/chromium/README.chromium +1 -1
  109. package/front_end/third_party/web-vitals/rebuild.sh +1 -1
  110. package/front_end/ui/legacy/TabbedPane.ts +34 -2
  111. package/front_end/ui/legacy/components/color_picker/ContrastDetails.ts +11 -11
  112. package/front_end/ui/legacy/components/color_picker/FormatPickerContextMenu.ts +1 -1
  113. package/front_end/ui/legacy/components/color_picker/Spectrum.ts +19 -20
  114. package/front_end/ui/legacy/components/object_ui/ObjectPopoverHelper.ts +2 -2
  115. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +164 -325
  116. package/front_end/ui/legacy/components/quick_open/CommandMenu.ts +5 -5
  117. package/front_end/ui/legacy/components/quick_open/FilteredListWidget.ts +7 -7
  118. package/front_end/ui/legacy/components/quick_open/QuickOpen.ts +1 -1
  119. package/front_end/ui/legacy/components/quick_open/quick_open-meta.ts +2 -2
  120. package/front_end/ui/visual_logging/KnownContextValues.ts +40 -0
  121. package/mcp/mcp.ts +0 -3
  122. package/package.json +1 -1
  123. package/front_end/core/sdk/sdk-meta.ts +0 -178
  124. package/front_end/models/badges/badges-meta.ts +0 -27
  125. package/front_end/models/persistence/persistence-meta.ts +0 -69
@@ -161,7 +161,6 @@ const str_ = i18n.i18n.registerUIStrings('ui/legacy/components/object_ui/ObjectP
161
161
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
162
162
  export const EXPANDABLE_MAX_DEPTH = 100;
163
163
 
164
- const objectPropertiesSectionMap = new WeakMap<Element, ObjectPropertiesSection>();
165
164
  // TODO(crbug.com/457388389): This cache is a temporary workaround for the <devtools-tree> migration.
166
165
  // It can be removed once the entire ObjectPropertiesSection is fully migrated to Lit and
167
166
  // the legacy TreeOutline/TreeElement dependencies are removed.
@@ -621,7 +620,7 @@ export abstract class ObjectTreeNodeBase extends Common.ObjectWrapper.ObjectWrap
621
620
  propertiesMode: ObjectPropertiesMode.OWN_AND_INTERNAL_AND_INHERITED,
622
621
  }));
623
622
  properties?.push(...this.extraProperties);
624
- properties?.sort((a, b) => ObjectPropertiesSection.compareProperties(a, b, this.sortPropertiesAlphabetically));
623
+ properties?.sort((a, b) => compareProperties(a, b, this.sortPropertiesAlphabetically));
625
624
  const accessors = properties && ObjectTreeNodeBase.getGettersAndSetters(properties, this.options);
626
625
 
627
626
  const internalProperties =
@@ -751,7 +750,7 @@ export class ArrayGroupTreeNode extends ObjectTreeNodeBase {
751
750
  ...this.options,
752
751
  }));
753
752
  properties?.push(...this.extraProperties);
754
- properties?.sort((a, b) => ObjectPropertiesSection.compareProperties(a, b, this.sortPropertiesAlphabetically));
753
+ properties?.sort((a, b) => compareProperties(a, b, this.sortPropertiesAlphabetically));
755
754
  const accessors = properties && ObjectTreeNodeBase.getGettersAndSetters(properties, this.options);
756
755
  return {properties, accessors};
757
756
  }
@@ -929,267 +928,179 @@ export class ObjectTreeNode extends ObjectTreeNodeBase {
929
928
  }
930
929
  }
931
930
 
932
- export const getObjectPropertiesSectionFrom = (element: Element): ObjectPropertiesSection|undefined => {
933
- return objectPropertiesSectionMap.get(element);
934
- };
935
-
936
- export class ObjectPropertiesSection extends UI.TreeOutline.TreeOutlineInShadow {
937
- readonly root: ObjectTree;
938
- readonly #objectTreeElement: RootElement;
939
- titleElement: Element;
940
- skipProtoInternal?: boolean;
941
-
942
- constructor(object: SDK.RemoteObject.RemoteObject, title?: string|Element|null,
943
- linkifier?: Components.Linkifier.Linkifier, showOverflow?: boolean, editable = true,
944
- search?: UI.TreeOutline.TreeSearch<ObjectTreeNodeBase>) {
945
- super();
946
- this.root = new ObjectTree(object, {
947
- readOnly: !editable,
948
- propertiesMode: ObjectPropertiesMode.OWN_AND_INTERNAL_AND_INHERITED,
949
- search,
950
- });
951
- if (!showOverflow) {
952
- this.setHideOverflow(true);
953
- }
954
- this.setFocusable(true);
955
- this.setShowSelectionOnKeyboardFocus(true);
956
- this.#objectTreeElement = new RootElement(this.root, linkifier);
957
- this.appendChild(this.#objectTreeElement);
958
- if (typeof title === 'string' || !title) {
959
- this.titleElement = this.element.createChild('span');
960
- this.titleElement.textContent = title ? Platform.StringUtilities.escapeUnicodeAsText(title) : '';
961
- } else {
962
- this.titleElement = title;
963
- this.element.appendChild(title);
964
- }
965
- if (this.titleElement instanceof HTMLElement && !this.titleElement.hasAttribute('tabIndex')) {
966
- this.titleElement.tabIndex = -1;
967
- }
968
-
969
- objectPropertiesSectionMap.set(this.element, this);
970
- this.registerRequiredCSS(objectValueStyles, objectPropertiesSectionStyles);
971
- this.rootElement().childrenListElement.classList.add('source-code', 'object-properties-section');
931
+ // The RemoteObjectProperty overload is kept for web test compatibility for now.
932
+ export function compareProperties(propertyA: ObjectTreeNode|SDK.RemoteObject.RemoteObjectProperty,
933
+ propertyB: ObjectTreeNode|SDK.RemoteObject.RemoteObjectProperty,
934
+ sortPropertiesAlphabetically = true): number {
935
+ if (propertyA instanceof ObjectTreeNode) {
936
+ propertyA = propertyA.property;
937
+ }
938
+ if (propertyB instanceof ObjectTreeNode) {
939
+ propertyB = propertyB.property;
972
940
  }
973
941
 
974
- // The RemoteObjectProperty overload is kept for web test compatibility for now.
975
- static compareProperties(propertyA: ObjectTreeNode|SDK.RemoteObject.RemoteObjectProperty,
976
- propertyB: ObjectTreeNode|SDK.RemoteObject.RemoteObjectProperty,
977
- sortPropertiesAlphabetically = true): number {
978
- if (propertyA instanceof ObjectTreeNode) {
979
- propertyA = propertyA.property;
980
- }
981
- if (propertyB instanceof ObjectTreeNode) {
982
- propertyB = propertyB.property;
983
- }
942
+ if (!propertyA.synthetic && propertyB.synthetic) {
943
+ return 1;
944
+ }
945
+ if (!propertyB.synthetic && propertyA.synthetic) {
946
+ return -1;
947
+ }
948
+ if (!propertyA.isOwn && propertyB.isOwn) {
949
+ return 1;
950
+ }
951
+ if (!propertyB.isOwn && propertyA.isOwn) {
952
+ return -1;
953
+ }
954
+ if (!propertyA.enumerable && propertyB.enumerable) {
955
+ return 1;
956
+ }
957
+ if (!propertyB.enumerable && propertyA.enumerable) {
958
+ return -1;
959
+ }
960
+ if (propertyA.symbol && !propertyB.symbol) {
961
+ return 1;
962
+ }
963
+ if (propertyB.symbol && !propertyA.symbol) {
964
+ return -1;
965
+ }
966
+ if (propertyA.private && !propertyB.private) {
967
+ return 1;
968
+ }
969
+ if (propertyB.private && !propertyA.private) {
970
+ return -1;
971
+ }
984
972
 
985
- if (!propertyA.synthetic && propertyB.synthetic) {
986
- return 1;
987
- }
988
- if (!propertyB.synthetic && propertyA.synthetic) {
989
- return -1;
990
- }
991
- if (!propertyA.isOwn && propertyB.isOwn) {
992
- return 1;
993
- }
994
- if (!propertyB.isOwn && propertyA.isOwn) {
995
- return -1;
996
- }
997
- if (!propertyA.enumerable && propertyB.enumerable) {
998
- return 1;
999
- }
1000
- if (!propertyB.enumerable && propertyA.enumerable) {
1001
- return -1;
1002
- }
1003
- if (propertyA.symbol && !propertyB.symbol) {
1004
- return 1;
1005
- }
1006
- if (propertyB.symbol && !propertyA.symbol) {
1007
- return -1;
1008
- }
1009
- if (propertyA.private && !propertyB.private) {
973
+ if (sortPropertiesAlphabetically) {
974
+ const nameA = propertyA.name;
975
+ const nameB = propertyB.name;
976
+ if (nameA.startsWith('_') && !nameB.startsWith('_')) {
1010
977
  return 1;
1011
978
  }
1012
- if (propertyB.private && !propertyA.private) {
979
+ if (nameB.startsWith('_') && !nameA.startsWith('_')) {
1013
980
  return -1;
1014
981
  }
1015
-
1016
- if (sortPropertiesAlphabetically) {
1017
- const nameA = propertyA.name;
1018
- const nameB = propertyB.name;
1019
- if (nameA.startsWith('_') && !nameB.startsWith('_')) {
1020
- return 1;
1021
- }
1022
- if (nameB.startsWith('_') && !nameA.startsWith('_')) {
1023
- return -1;
1024
- }
1025
- return Platform.StringUtilities.naturalOrderComparator(nameA, nameB);
1026
- }
1027
-
1028
- return 0;
1029
- }
1030
-
1031
- static valueElementForFunctionDescription(description?: string, includePreview?: boolean, defaultName?: string,
1032
- details?: SDK.DebuggerModel.FunctionDetails|null,
1033
- linkify?: boolean): LitTemplate {
1034
- const contents =
1035
- (description: string, defaultName: string): {prefix: string, abbreviation: string, body: string} => {
1036
- const text = description.replace(/^function [gs]et /, 'function ')
1037
- .replace(/^function [gs]et\(/, 'function\(')
1038
- .replace(/^[gs]et /, '');
1039
-
1040
- // This set of best-effort regular expressions captures common function descriptions.
1041
- // Ideally, some parser would provide prefix, arguments, function body text separately.
1042
- const asyncMatch = text.match(/^(async\s+function)/);
1043
- const isGenerator = text.startsWith('function*');
1044
- const isGeneratorShorthand = text.startsWith('*');
1045
- const isBasic = !isGenerator && text.startsWith('function');
1046
- const isClass = text.startsWith('class ') || text.startsWith('class{');
1047
- const firstArrowIndex = text.indexOf('=>');
1048
- const isArrow = !asyncMatch && !isGenerator && !isBasic && !isClass && firstArrowIndex > 0;
1049
-
1050
- if (isClass) {
1051
- const body = text.substring('class'.length);
1052
- const classNameMatch = /^[^{\s]+/.exec(body.trim());
1053
- let className: string = defaultName;
1054
- if (classNameMatch) {
1055
- className = classNameMatch[0].trim() || defaultName;
1056
- }
1057
- return {prefix: 'class', body, abbreviation: className};
1058
- }
1059
- if (asyncMatch) {
1060
- const body = text.substring(asyncMatch[1].length);
1061
- return {prefix: 'async \u0192', body, abbreviation: nameAndArguments(body)};
1062
- }
1063
- if (isGenerator) {
1064
- const body = text.substring('function*'.length);
1065
- return {prefix: '\u0192*', body, abbreviation: nameAndArguments(body)};
1066
- }
1067
- if (isGeneratorShorthand) {
1068
- const body = text.substring('*'.length);
1069
- return {prefix: '\u0192*', body, abbreviation: nameAndArguments(body)};
1070
- }
1071
- if (isBasic) {
1072
- const body = text.substring('function'.length);
1073
- return {prefix: '\u0192', body, abbreviation: nameAndArguments(body)};
1074
- }
1075
- if (isArrow) {
1076
- const maxArrowFunctionCharacterLength = 60;
1077
- let abbreviation: string = text;
1078
- if (defaultName) {
1079
- abbreviation = defaultName + '()';
1080
- } else if (text.length > maxArrowFunctionCharacterLength) {
1081
- abbreviation = text.substring(0, firstArrowIndex + 2) + ' {…}';
1082
- }
1083
- return {prefix: '', body: text, abbreviation};
1084
- }
1085
- return {prefix: '\u0192', body: text, abbreviation: nameAndArguments(text)};
1086
- };
1087
-
1088
- const {prefix, body, abbreviation} = contents(description ?? '', defaultName ?? '');
1089
- const maxFunctionBodyLength = 200;
1090
-
1091
- const location = details?.location;
1092
- const clickHandler = linkify && location ? (event: Event) => {
1093
- void Common.Revealer.reveal(location);
1094
- event.consume(true);
1095
- } : undefined;
1096
-
1097
- const classes = classMap({
1098
- 'object-value-function': true,
1099
- linkified: Boolean(linkify && location),
1100
- });
1101
- const title = description ? Platform.StringUtilities.trimEndWithMaxLength(description, 500) : undefined;
1102
-
1103
- return html`<span
1104
- class=${classes}
1105
- @click=${clickHandler || nothing}
1106
- title=${ifDefined(title)}>${prefix && html`<span class=object-value-function-prefix>${prefix} </span>`}${
1107
- includePreview ? Platform.StringUtilities.trimEndWithMaxLength(body.trim(), maxFunctionBodyLength) :
1108
- abbreviation.replace(/\n/g, ' ')}</span>`;
1109
-
1110
- function nameAndArguments(contents: string): string {
1111
- const startOfArgumentsIndex = contents.indexOf('(');
1112
- const endOfArgumentsMatch = contents.match(/\)\s*{/);
1113
- if (startOfArgumentsIndex !== -1 && endOfArgumentsMatch?.index !== undefined &&
1114
- endOfArgumentsMatch.index > startOfArgumentsIndex) {
1115
- const name = contents.substring(0, startOfArgumentsIndex).trim() || (defaultName ?? '');
1116
- const args = contents.substring(startOfArgumentsIndex, endOfArgumentsMatch.index + 1);
1117
- return name + args;
1118
- }
1119
- return defaultName + '()';
1120
- }
982
+ return Platform.StringUtilities.naturalOrderComparator(nameA, nameB);
1121
983
  }
1122
984
 
1123
- static getMemoryIcon(object: SDK.RemoteObject.RemoteObject, expression?: string): LitTemplate {
1124
- // Directly set styles on memory icon, so that the memory icon is also
1125
- // styled within the context of code mirror.
1126
- // clang-format off
1127
- return !object.isLinearMemoryInspectable() ? nothing : html`<devtools-icon
1128
- name=memory
1129
- style="width: var(--sys-size-8); height: 13px; vertical-align: sub; cursor: pointer;"
1130
- @click=${(event: Event) => {
1131
- event.consume();
1132
- void Common.Revealer.reveal(new SDK.RemoteObject.LinearMemoryInspectable(object, expression));
1133
- }}
1134
- jslog=${VisualLogging.action('open-memory-inspector').track({click: true})}
1135
- title=${i18nString(UIStrings.openInMemoryInpector)}
1136
- aria-label=${i18nString(UIStrings.openInMemoryInpector)}></devtools-icon>`;
1137
- // clang-format on
1138
- }
1139
-
1140
- static appendMemoryIcon(element: Element, object: SDK.RemoteObject.RemoteObject, expression?: string): void {
1141
- const fragment = document.createDocumentFragment();
1142
- // eslint-disable-next-line @devtools/no-lit-render-outside-of-view
1143
- render(ObjectPropertiesSection.getMemoryIcon(object, expression), fragment);
1144
- element.appendChild(fragment);
1145
- }
985
+ return 0;
986
+ }
1146
987
 
1147
- static isDisplayableProperty(property: SDK.RemoteObject.RemoteObjectProperty,
1148
- parentProperty?: SDK.RemoteObject.RemoteObjectProperty): boolean {
1149
- if (!parentProperty?.synthetic) {
1150
- return true;
988
+ export function valueElementForFunctionDescription(description?: string, includePreview?: boolean, defaultName?: string,
989
+ details?: SDK.DebuggerModel.FunctionDetails|null,
990
+ linkify?: boolean): LitTemplate {
991
+ const contents = (description: string, defaultName: string): {prefix: string, abbreviation: string, body: string} => {
992
+ const text = description.replace(/^function [gs]et /, 'function ')
993
+ .replace(/^function [gs]et\(/, 'function\(')
994
+ .replace(/^[gs]et /, '');
995
+
996
+ // This set of best-effort regular expressions captures common function descriptions.
997
+ // Ideally, some parser would provide prefix, arguments, function body text separately.
998
+ const asyncMatch = text.match(/^(async\s+function)/);
999
+ const isGenerator = text.startsWith('function*');
1000
+ const isGeneratorShorthand = text.startsWith('*');
1001
+ const isBasic = !isGenerator && text.startsWith('function');
1002
+ const isClass = text.startsWith('class ') || text.startsWith('class{');
1003
+ const firstArrowIndex = text.indexOf('=>');
1004
+ const isArrow = !asyncMatch && !isGenerator && !isBasic && !isClass && firstArrowIndex > 0;
1005
+
1006
+ if (isClass) {
1007
+ const body = text.substring('class'.length);
1008
+ const classNameMatch = /^[^{\s]+/.exec(body.trim());
1009
+ let className: string = defaultName;
1010
+ if (classNameMatch) {
1011
+ className = classNameMatch[0].trim() || defaultName;
1012
+ }
1013
+ return {prefix: 'class', body, abbreviation: className};
1014
+ }
1015
+ if (asyncMatch) {
1016
+ const body = text.substring(asyncMatch[1].length);
1017
+ return {prefix: 'async \u0192', body, abbreviation: nameAndArguments(body)};
1018
+ }
1019
+ if (isGenerator) {
1020
+ const body = text.substring('function*'.length);
1021
+ return {prefix: '\u0192*', body, abbreviation: nameAndArguments(body)};
1022
+ }
1023
+ if (isGeneratorShorthand) {
1024
+ const body = text.substring('*'.length);
1025
+ return {prefix: '\u0192*', body, abbreviation: nameAndArguments(body)};
1026
+ }
1027
+ if (isBasic) {
1028
+ const body = text.substring('function'.length);
1029
+ return {prefix: '\u0192', body, abbreviation: nameAndArguments(body)};
1030
+ }
1031
+ if (isArrow) {
1032
+ const maxArrowFunctionCharacterLength = 60;
1033
+ let abbreviation: string = text;
1034
+ if (defaultName) {
1035
+ abbreviation = defaultName + '()';
1036
+ } else if (text.length > maxArrowFunctionCharacterLength) {
1037
+ abbreviation = text.substring(0, firstArrowIndex + 2) + ' {…}';
1038
+ }
1039
+ return {prefix: '', body: text, abbreviation};
1151
1040
  }
1152
- const name = property.name;
1153
- const useless = (parentProperty.name === '[[Entries]]' && (name === 'length' || name === '__proto__'));
1154
- return !useless;
1155
- }
1041
+ return {prefix: '\u0192', body: text, abbreviation: nameAndArguments(text)};
1042
+ };
1156
1043
 
1157
- skipProto(): void {
1158
- this.skipProtoInternal = true;
1159
- }
1044
+ const {prefix, body, abbreviation} = contents(description ?? '', defaultName ?? '');
1045
+ const maxFunctionBodyLength = 200;
1160
1046
 
1161
- expand(): void {
1162
- this.#objectTreeElement.expand();
1163
- }
1047
+ const location = details?.location;
1048
+ const clickHandler = linkify && location ? (event: Event) => {
1049
+ void Common.Revealer.reveal(location);
1050
+ event.consume(true);
1051
+ } : undefined;
1164
1052
 
1165
- objectTreeElement(): UI.TreeOutline.TreeElement {
1166
- return this.#objectTreeElement;
1167
- }
1053
+ const classes = classMap({
1054
+ 'object-value-function': true,
1055
+ linkified: Boolean(linkify && location),
1056
+ });
1057
+ const title = description ? Platform.StringUtilities.trimEndWithMaxLength(description, 500) : undefined;
1168
1058
 
1169
- enableContextMenu(): void {
1170
- this.element.addEventListener('contextmenu', this.contextMenuEventFired.bind(this), false);
1059
+ return html`<span
1060
+ class=${classes}
1061
+ @click=${clickHandler || nothing}
1062
+ title=${ifDefined(title)}>${prefix && html`<span class=object-value-function-prefix>${prefix} </span>`}${
1063
+ includePreview ? Platform.StringUtilities.trimEndWithMaxLength(body.trim(), maxFunctionBodyLength) :
1064
+ abbreviation.replace(/\n/g, ' ')}</span>`;
1065
+
1066
+ function nameAndArguments(contents: string): string {
1067
+ const startOfArgumentsIndex = contents.indexOf('(');
1068
+ const endOfArgumentsMatch = contents.match(/\)\s*{/);
1069
+ if (startOfArgumentsIndex !== -1 && endOfArgumentsMatch?.index !== undefined &&
1070
+ endOfArgumentsMatch.index > startOfArgumentsIndex) {
1071
+ const name = contents.substring(0, startOfArgumentsIndex).trim() || (defaultName ?? '');
1072
+ const args = contents.substring(startOfArgumentsIndex, endOfArgumentsMatch.index + 1);
1073
+ return name + args;
1074
+ }
1075
+ return defaultName + '()';
1171
1076
  }
1077
+ }
1172
1078
 
1173
- private contextMenuEventFired(event: Event): void {
1174
- const contextMenu = new UI.ContextMenu.ContextMenu(event);
1175
- contextMenu.appendApplicableItems(this.root);
1176
- if (this.root.object instanceof SDK.RemoteObject.LocalJSONObject) {
1177
- contextMenu.viewSection().appendItem(
1178
- i18nString(UIStrings.expandRecursively),
1179
- this.#objectTreeElement.expandRecursively.bind(this.#objectTreeElement, EXPANDABLE_MAX_DEPTH),
1180
- {jslogContext: 'expand-recursively'});
1181
- contextMenu.viewSection().appendItem(i18nString(UIStrings.collapseChildren),
1182
- this.#objectTreeElement.collapseChildren.bind(this.#objectTreeElement),
1183
- {jslogContext: 'collapse-children'});
1184
- }
1185
- void contextMenu.show();
1186
- }
1079
+ export function getMemoryIcon(object: SDK.RemoteObject.RemoteObject, expression?: string): LitTemplate {
1080
+ // Directly set styles on memory icon, so that the memory icon is also
1081
+ // styled within the context of code mirror.
1082
+ // clang-format off
1083
+ return !object.isLinearMemoryInspectable() ? nothing : html`<devtools-icon
1084
+ name=memory
1085
+ style="width: var(--sys-size-8); height: 13px; vertical-align: sub; cursor: pointer;"
1086
+ @click=${(event: Event) => {
1087
+ event.consume();
1088
+ void Common.Revealer.reveal(new SDK.RemoteObject.LinearMemoryInspectable(object, expression));
1089
+ }}
1090
+ jslog=${VisualLogging.action('open-memory-inspector').track({click: true})}
1091
+ title=${i18nString(UIStrings.openInMemoryInpector)}
1092
+ aria-label=${i18nString(UIStrings.openInMemoryInpector)}></devtools-icon>`;
1093
+ // clang-format on
1094
+ }
1187
1095
 
1188
- titleLessMode(): void {
1189
- this.#objectTreeElement.listItemElement.classList.add('hidden');
1190
- this.#objectTreeElement.childrenListElement.classList.add('title-less-mode');
1191
- this.#objectTreeElement.expand();
1096
+ function isDisplayableProperty(property: SDK.RemoteObject.RemoteObjectProperty,
1097
+ parentProperty?: SDK.RemoteObject.RemoteObjectProperty): boolean {
1098
+ if (!parentProperty?.synthetic) {
1099
+ return true;
1192
1100
  }
1101
+ const name = property.name;
1102
+ const useless = (parentProperty.name === '[[Entries]]' && (name === 'length' || name === '__proto__'));
1103
+ return !useless;
1193
1104
  }
1194
1105
 
1195
1106
  export class ObjectPropertiesSectionWidget extends UI.Widget.Widget {
@@ -1611,74 +1522,6 @@ export const OBJECT_PROPERTIES_SECTION_DEFAULT_VIEW: ObjectPropertiesSectionView
1611
1522
  target);
1612
1523
  };
1613
1524
 
1614
- class RootElement extends UI.TreeOutline.TreeElement {
1615
- private readonly object: ObjectTree;
1616
- private readonly linkifier: Components.Linkifier.Linkifier|undefined;
1617
- private readonly emptyPlaceholder: string|null|undefined;
1618
- override toggleOnClick: boolean;
1619
- constructor(object: ObjectTree, linkifier?: Components.Linkifier.Linkifier, emptyPlaceholder?: string|null) {
1620
- const contentElement = document.createElement('slot');
1621
- super(contentElement);
1622
-
1623
- this.object = object;
1624
- this.object.addEventListener(ObjectTreeNodeBase.Events.CHILDREN_CHANGED, this.onpopulate, this);
1625
- this.linkifier = linkifier;
1626
- this.emptyPlaceholder = emptyPlaceholder;
1627
-
1628
- this.setExpandable(true);
1629
- this.selectable = true;
1630
- this.toggleOnClick = true;
1631
- this.listItemElement.classList.add('object-properties-section-root-element');
1632
- this.listItemElement.addEventListener('contextmenu', this.onContextMenu.bind(this), false);
1633
- if (object.expanded) {
1634
- this.expand();
1635
- }
1636
- }
1637
-
1638
- override onexpand(): void {
1639
- this.object.expanded = true;
1640
- if (this.treeOutline) {
1641
- this.treeOutline.element.classList.add('expanded');
1642
- }
1643
- }
1644
-
1645
- override oncollapse(): void {
1646
- this.object.expanded = false;
1647
- if (this.treeOutline) {
1648
- this.treeOutline.element.classList.remove('expanded');
1649
- }
1650
- }
1651
-
1652
- override ondblclick(_e: Event): boolean {
1653
- return true;
1654
- }
1655
-
1656
- private onContextMenu(event: Event): void {
1657
- const contextMenu = new UI.ContextMenu.ContextMenu(event);
1658
- populateObjectTreeContextMenu(
1659
- contextMenu,
1660
- this.object,
1661
- this.expandRecursively.bind(this, EXPANDABLE_MAX_DEPTH),
1662
- this.collapseChildren.bind(this),
1663
- () => {
1664
- this.object.sortPropertiesAlphabetically = !this.object.sortPropertiesAlphabetically;
1665
- },
1666
- () => {
1667
- this.object.includeNullOrUndefinedValues = !this.object.includeNullOrUndefinedValues;
1668
- },
1669
- );
1670
- void contextMenu.show();
1671
- }
1672
-
1673
- override async onpopulate(): Promise<void> {
1674
- this.removeChildren();
1675
- const treeOutline = (this.treeOutline as ObjectPropertiesSection | null);
1676
- const skipProto = treeOutline ? Boolean(treeOutline.skipProtoInternal) : false;
1677
- return await ObjectPropertyTreeElement.populate(this, this.object, skipProto, false, this.linkifier,
1678
- this.emptyPlaceholder);
1679
- }
1680
- }
1681
-
1682
1525
  export function renderPropertyName(name: string|null, isPrivate?: boolean, title?: string): TemplateResult {
1683
1526
  if (name === null) {
1684
1527
  return html`<span class="name" title=${ifDefined(title)}></span>`;
@@ -1701,8 +1544,7 @@ export async function formatObjectAsFunction(func: SDK.RemoteObject.RemoteObject
1701
1544
  // The includePreview flag is false for formats such as console.dir().
1702
1545
  const defaultName = details?.functionName ?? (includePreview ? '' : 'anonymous');
1703
1546
 
1704
- return ObjectPropertiesSection.valueElementForFunctionDescription(func.description, includePreview, defaultName,
1705
- details, linkify);
1547
+ return valueElementForFunctionDescription(func.description, includePreview, defaultName, details, linkify);
1706
1548
  }
1707
1549
 
1708
1550
  export function renderPropertyValue(value: SDK.RemoteObject.RemoteObject, wasThrown: boolean, showPreview: boolean,
@@ -1770,7 +1612,7 @@ export function renderPropertyValue(value: SDK.RemoteObject.RemoteObject, wasThr
1770
1612
  title = tooLong ? undefined : text;
1771
1613
  content = tooLong ? widget(ExpandableTextPropertyValue, {text}) : renderTrustedType(description, className);
1772
1614
  } else if (isFunction) {
1773
- content = ObjectPropertiesSection.valueElementForFunctionDescription(description);
1615
+ content = valueElementForFunctionDescription(description);
1774
1616
  } else if (description.length > maxRenderableStringLength) {
1775
1617
  title = description;
1776
1618
  content = widget(ExpandableTextPropertyValue, {text: description});
@@ -1780,8 +1622,7 @@ export function renderPropertyValue(value: SDK.RemoteObject.RemoteObject, wasThr
1780
1622
  const previewContent = hasPreview ?
1781
1623
  new RemoteObjectPreviewFormatter().renderObjectPreview(value.preview, includeNullOrUndefined) :
1782
1624
  description;
1783
- content = html`${previewContent}${
1784
- isSyntheticProperty ? nothing : ObjectPropertiesSection.getMemoryIcon(value, variableName)}`;
1625
+ content = html`${previewContent}${isSyntheticProperty ? nothing : getMemoryIcon(value, variableName)}`;
1785
1626
  }
1786
1627
 
1787
1628
  if (wasThrown) {
@@ -1951,7 +1792,7 @@ export const OBJECT_PROPERTY_DEFAULT_VIEW: ObjectPropertyView = (input, output,
1951
1792
  Platform.StringUtilities.trimMiddle(property.value.description ?? '',
1952
1793
  maxRenderableStringLength)}${
1953
1794
  property.synthetic ? nothing :
1954
- ObjectPropertiesSection.getMemoryIcon(property.value)}</span>` :
1795
+ getMemoryIcon(property.value)}</span>` :
1955
1796
  value()
1956
1797
  }</devtools-highlight>
1957
1798
  <datalist id=${completionsId}>${repeat(input.completions, c => html`<option>${c}</option>`)}</datalist>
@@ -2184,7 +2025,7 @@ export class ObjectPropertyTreeElement extends UI.TreeOutline.TreeElement {
2184
2025
  for (const childNode of ObjectPropertyTreeElement.createNodes(
2185
2026
  value, skipProto, skipGettersAndSetters, linkifier, emptyPlaceholder,
2186
2027
  property => treeElement instanceof ObjectPropertyTreeElement &&
2187
- !ObjectPropertiesSection.isDisplayableProperty(property, treeElement.property?.property))) {
2028
+ !isDisplayableProperty(property, treeElement.property?.property))) {
2188
2029
  treeElement.appendChild(childNode);
2189
2030
  }
2190
2031
  }
@@ -2224,7 +2065,7 @@ export class ObjectPropertyTreeElement extends UI.TreeOutline.TreeElement {
2224
2065
  empty = false;
2225
2066
  }
2226
2067
  const sortPropertiesAlphabetically = properties?.[0]?.parent?.sortPropertiesAlphabetically ?? true;
2227
- properties?.sort((a, b) => ObjectPropertiesSection.compareProperties(a, b, sortPropertiesAlphabetically));
2068
+ properties?.sort((a, b) => compareProperties(a, b, sortPropertiesAlphabetically));
2228
2069
 
2229
2070
  const entriesProperty = internalProperties?.find(({property}) => property.name === '[[Entries]]');
2230
2071
  if (entriesProperty) {
@@ -2285,7 +2126,7 @@ export class ObjectPropertyTreeElement extends UI.TreeOutline.TreeElement {
2285
2126
  for (const childNode of this.createPropertyNodes(
2286
2127
  children, skipProto, skipGettersAndSetters, linkifier, emptyPlaceholder,
2287
2128
  property => treeNode instanceof ObjectPropertyTreeElement &&
2288
- !ObjectPropertiesSection.isDisplayableProperty(property, treeNode.property?.property))) {
2129
+ !isDisplayableProperty(property, treeNode.property?.property))) {
2289
2130
  treeNode.appendChild(childNode);
2290
2131
  }
2291
2132
  }
@@ -2344,12 +2185,10 @@ export class ObjectPropertyTreeElement extends UI.TreeOutline.TreeElement {
2344
2185
  }
2345
2186
 
2346
2187
  override async onpopulate(): Promise<void> {
2347
- const treeOutline = (this.treeOutline as ObjectPropertiesSection | null);
2348
- const skipProto = treeOutline ? Boolean(treeOutline.skipProtoInternal) : false;
2349
2188
  this.removeChildren();
2350
2189
 
2351
2190
  if (this.property.object) {
2352
- await ObjectPropertyTreeElement.populate(this, this.property, skipProto, false, this.linkifier);
2191
+ await ObjectPropertyTreeElement.populate(this, this.property, false, false, this.linkifier);
2353
2192
  if (this.childCount() > this.maxNumPropertiesToShow) {
2354
2193
  this.createShowAllPropertiesButton();
2355
2194
  }
@@ -19,23 +19,23 @@ import {QuickOpenImpl} from './QuickOpen.js';
19
19
 
20
20
  const UIStrings = {
21
21
  /**
22
- * @description Message to display if a setting change requires a reload of DevTools
22
+ * @description Warning message displayed when a setting change requires reloading DevTools.
23
23
  */
24
24
  settingsChangedReloadDevTools: 'Settings changed. To apply, reload DevTools.',
25
25
  /**
26
- * @description Text in Command Menu of the Command Menu
26
+ * @description Message shown when no commands match the query in the command menu.
27
27
  */
28
28
  noCommandsFound: 'No commands found',
29
29
  /**
30
- * @description Text for command prefix of run a command
30
+ * @description Prefix text for the prompt in the command menu.
31
31
  */
32
32
  run: 'Run',
33
33
  /**
34
- * @description Text for command suggestion of run a command
34
+ * @description Suggestion placeholder text for the prompt in the command menu.
35
35
  */
36
36
  command: 'Command',
37
37
  /**
38
- * @description Text for help title of run command menu
38
+ * @description Title for the command menu entry in the help menu.
39
39
  */
40
40
  runCommand: 'Run command',
41
41
  } as const;
@@ -18,28 +18,28 @@ import filteredListWidgetStyles from './filteredListWidget.css.js';
18
18
 
19
19
  const UIStrings = {
20
20
  /**
21
- * @description Aria label for quick open dialog prompt
21
+ * @description Accessible name for the input prompt in the quick open dialog.
22
22
  */
23
23
  quickOpenPrompt: 'Quick open prompt',
24
24
  /**
25
- * @description Title of quick open dialog
25
+ * @description Title for the quick open dialog.
26
26
  */
27
27
  quickOpen: 'Quick open',
28
28
  /**
29
- * @description Text to show no results have been found
29
+ * @description Message displayed when a search returns no matching items.
30
30
  */
31
31
  noResultsFound: 'No results found',
32
32
  /**
33
- * @description Aria alert to read the item in list when navigating with screen readers
34
- * @example {name} PH1
33
+ * @description Announcement for screen readers when navigating items in a list.
34
+ * @example {Show Console} PH1
35
35
  * @example {2} PH2
36
36
  * @example {5} PH3
37
37
  */
38
38
  sItemSOfS: '{PH1}, item {PH2} of {PH3}',
39
39
  /**
40
- * @description Text that should be read out by screen readers when a new badge is available
40
+ * @description Text announced by screen readers when an item has a new feature badge.
41
41
  */
42
- newFeature: 'This is a new feature',
42
+ newFeature: 'New feature',
43
43
  } as const;
44
44
  const str_ = i18n.i18n.registerUIStrings('ui/legacy/components/quick_open/FilteredListWidget.ts', UIStrings);
45
45
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);