chrome-devtools-frontend 1.0.1646286 → 1.0.1649421

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 (57) hide show
  1. package/SECURITY.md +1 -1
  2. package/extension-api/ExtensionAPI.d.ts +26 -0
  3. package/front_end/core/common/Debouncer.ts +9 -1
  4. package/front_end/core/sdk/CSSMatchedStyles.ts +3 -1
  5. package/front_end/core/sdk/CSSMetadata.ts +1 -0
  6. package/front_end/core/sdk/CSSPropertyParserMatchers.ts +65 -0
  7. package/front_end/generated/InspectorBackendCommands.ts +2 -1
  8. package/front_end/generated/SupportedCSSProperties.js +739 -21
  9. package/front_end/generated/protocol.ts +26 -0
  10. package/front_end/models/ai_assistance/AiAgent2.ts +14 -9
  11. package/front_end/models/ai_assistance/agents/AiAgent.ts +10 -3
  12. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +7 -0
  13. package/front_end/models/ai_assistance/agents/StorageAgent.ts +45 -0
  14. package/front_end/models/ai_assistance/ai_assistance.ts +4 -0
  15. package/front_end/models/ai_assistance/skills/Skill.ts +1 -1
  16. package/front_end/models/ai_assistance/skills/SkillRegistry.ts +2 -0
  17. package/front_end/models/ai_assistance/skills/network.md +16 -0
  18. package/front_end/models/ai_assistance/skills/styling.md +1 -1
  19. package/front_end/models/ai_assistance/tools/GetNetworkRequestDetails.ts +118 -0
  20. package/front_end/models/ai_assistance/tools/ListNetworkRequests.ts +124 -0
  21. package/front_end/models/ai_assistance/tools/Tool.ts +2 -0
  22. package/front_end/models/ai_assistance/tools/ToolRegistry.ts +4 -0
  23. package/front_end/models/emulation/EmulatedDevices.ts +430 -12
  24. package/front_end/models/extensions/ExtensionAPI.ts +47 -21
  25. package/front_end/models/javascript_metadata/NativeFunctions.js +5 -1
  26. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +40 -1
  27. package/front_end/panels/ai_assistance/ai_assistance.ts +1 -0
  28. package/front_end/panels/ai_assistance/components/AIv2MarkdownRenderer.ts +228 -0
  29. package/front_end/panels/ai_assistance/components/ChatMessage.ts +39 -2
  30. package/front_end/panels/application/ApplicationPanelSidebar.ts +4 -0
  31. package/front_end/panels/application/CookieItemsView.ts +55 -6
  32. package/front_end/panels/application/DOMStorageItemsView.ts +43 -8
  33. package/front_end/panels/application/KeyValueStorageItemsView.ts +17 -9
  34. package/front_end/panels/application/WebMCPTreeElement.ts +8 -0
  35. package/front_end/panels/elements/StylePropertyTreeElement.ts +73 -16
  36. package/front_end/panels/elements/StylesAiCodeCompletionProvider.ts +9 -1
  37. package/front_end/panels/elements/StylesSidebarPane.ts +22 -8
  38. package/front_end/panels/layer_viewer/PaintProfilerView.ts +309 -182
  39. package/front_end/panels/layer_viewer/paintProfiler.css +27 -23
  40. package/front_end/panels/layers/LayerPaintProfilerView.ts +86 -29
  41. package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +210 -356
  42. package/front_end/panels/sources/watchExpressionsSidebarPane.css +7 -0
  43. package/front_end/panels/timeline/TimelinePaintProfilerView.ts +5 -5
  44. package/front_end/panels/timeline/components/NetworkTrackWidget.ts +122 -0
  45. package/front_end/panels/timeline/components/components.ts +2 -0
  46. package/front_end/panels/timeline/components/networkTrackWidget.css +31 -0
  47. package/front_end/panels/timeline/timeline.ts +2 -0
  48. package/front_end/third_party/chromium/README.chromium +1 -1
  49. package/front_end/ui/components/buttons/FloatingButton.ts +17 -2
  50. package/front_end/ui/components/buttons/floatingButton.css +2 -2
  51. package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +1 -1
  52. package/front_end/ui/legacy/TextPrompt.ts +24 -18
  53. package/front_end/ui/legacy/Treeoutline.ts +31 -4
  54. package/front_end/ui/legacy/components/cookie_table/CookiesTable.ts +50 -24
  55. package/front_end/ui/legacy/components/utils/Linkifier.ts +10 -0
  56. package/front_end/ui/visual_logging/KnownContextValues.ts +13 -0
  57. package/package.json +1 -1
@@ -5,6 +5,7 @@
5
5
  import type * as Platform from '../../core/platform/platform.js';
6
6
  import {createIcon} from '../../ui/kit/kit.js';
7
7
  import * as UI from '../../ui/legacy/legacy.js';
8
+ import {html, render} from '../../ui/lit/lit.js';
8
9
 
9
10
  import {ApplicationPanelTreeElement} from './ApplicationPanelTreeElement.js';
10
11
  import type {ResourcesPanel} from './ResourcesPanel.js';
@@ -17,6 +18,13 @@ export class WebMCPTreeElement extends ApplicationPanelTreeElement {
17
18
  super(storagePanel, 'WebMCP', false, 'web-mcp');
18
19
  const icon = createIcon('document');
19
20
  this.setLeadingIcons([icon]);
21
+ const newBadge = UI.UIUtils.maybeCreateNewBadge('web-mcp');
22
+ if (newBadge) {
23
+ const fragment = document.createDocumentFragment();
24
+ // eslint-disable-next-line @devtools/no-lit-render-outside-of-view
25
+ render(html`<div class="trailing-icons icons-container">${newBadge}</div>`, fragment);
26
+ this.listItemElement.appendChild(fragment);
27
+ }
20
28
  }
21
29
 
22
30
  override get itemURL(): Platform.DevToolsPath.UrlString {
@@ -316,6 +316,21 @@ export class CSSWideKeywordRenderer extends rendererBase(SDK.CSSPropertyParserMa
316
316
  }
317
317
  }
318
318
 
319
+ function handleVarDefinitionActivate(variable: string|SDK.CSSMatchedStyles.CSSValueSource,
320
+ stylesContainer: StylesContainer): void {
321
+ Host.userMetrics.actionTaken(Host.UserMetrics.Action.CustomPropertyLinkClicked);
322
+ Host.userMetrics.swatchActivated(Host.UserMetrics.SwatchType.VAR_LINK);
323
+
324
+ if (typeof variable === 'string') {
325
+ stylesContainer.jumpToProperty(variable) ||
326
+ stylesContainer.jumpToProperty('initial-value', variable, REGISTERED_PROPERTY_SECTION_NAME);
327
+ } else if (variable.declaration instanceof SDK.CSSProperty.CSSProperty) {
328
+ stylesContainer.revealProperty(variable.declaration);
329
+ } else if (variable.declaration instanceof SDK.CSSMatchedStyles.CSSRegisteredProperty) {
330
+ stylesContainer.jumpToProperty('initial-value', variable.name, REGISTERED_PROPERTY_SECTION_NAME);
331
+ }
332
+ }
333
+
319
334
  // clang-format off
320
335
  export class VariableRenderer extends rendererBase(SDK.CSSPropertyParserMatchers.VariableMatch) {
321
336
  // clang-format on
@@ -344,7 +359,8 @@ export class VariableRenderer extends rendererBase(SDK.CSSPropertyParserMatchers
344
359
  const {declaration, value: variableValue} = match.resolveVariable() ?? {};
345
360
  const fromFallback = variableValue === undefined;
346
361
  const computedValue = variableValue ?? match.fallbackValue();
347
- const onLinkActivate = (name: string): void => this.#handleVarDefinitionActivate(declaration ?? name);
362
+ const onLinkActivate = (name: string): void =>
363
+ handleVarDefinitionActivate(declaration ?? name, this.#stylesContainer);
348
364
  const varSwatch = document.createElement('span');
349
365
 
350
366
  const substitution = context.tracing?.substitution({match, context});
@@ -416,19 +432,59 @@ export class VariableRenderer extends rendererBase(SDK.CSSPropertyParserMatchers
416
432
 
417
433
  return [colorSwatch, varSwatch];
418
434
  }
435
+ }
419
436
 
420
- #handleVarDefinitionActivate(variable: string|SDK.CSSMatchedStyles.CSSValueSource): void {
421
- Host.userMetrics.actionTaken(Host.UserMetrics.Action.CustomPropertyLinkClicked);
422
- Host.userMetrics.swatchActivated(Host.UserMetrics.SwatchType.VAR_LINK);
437
+ // clang-format off
438
+ export class VariableNameRenderer extends rendererBase(SDK.CSSPropertyParserMatchers.VariableNameMatch) {
439
+ // clang-format on
440
+ readonly #stylesContainer: StylesContainer;
441
+ readonly #treeElement: StylePropertyTreeElement|null;
442
+ readonly #matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles;
443
+ constructor(stylesContainer: StylesContainer, treeElement: StylePropertyTreeElement|null,
444
+ matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles) {
445
+ super();
446
+ this.#treeElement = treeElement;
447
+ this.#stylesContainer = stylesContainer;
448
+ this.#matchedStyles = matchedStyles;
449
+ }
423
450
 
424
- if (typeof variable === 'string') {
425
- this.#stylesContainer.jumpToProperty(variable) ||
426
- this.#stylesContainer.jumpToProperty('initial-value', variable, REGISTERED_PROPERTY_SECTION_NAME);
427
- } else if (variable.declaration instanceof SDK.CSSProperty.CSSProperty) {
428
- this.#stylesContainer.revealProperty(variable.declaration);
429
- } else if (variable.declaration instanceof SDK.CSSMatchedStyles.CSSRegisteredProperty) {
430
- this.#stylesContainer.jumpToProperty('initial-value', variable.name, REGISTERED_PROPERTY_SECTION_NAME);
451
+ override render(match: SDK.CSSPropertyParserMatchers.VariableNameMatch, context: RenderingContext): Node[] {
452
+ if (this.#treeElement?.property.ownerStyle.parentRule instanceof SDK.CSSRule.CSSFunctionRule) {
453
+ return Renderer.render(ASTUtils.children(match.node), context).nodes;
431
454
  }
455
+
456
+ const {declaration, value: variableValue} = match.resolveVariable() ?? {};
457
+ const isDefined = variableValue !== undefined;
458
+ const onLinkActivate = (name: string): void =>
459
+ handleVarDefinitionActivate(declaration ?? name, this.#stylesContainer);
460
+ const varSwatch = document.createElement('span');
461
+
462
+ const tooltipContents =
463
+ this.#stylesContainer.getVariablePopoverContents(this.#matchedStyles, match.text, variableValue ?? null);
464
+ const tooltipId = this.#treeElement?.getTooltipId('custom-property-var');
465
+ const tooltip = tooltipId ? {tooltipId} : undefined;
466
+ // clang-format off
467
+ render(html`
468
+ <devtools-link-swatch class=css-var-link .data=${{
469
+ tooltip,
470
+ text: match.text,
471
+ isDefined,
472
+ onLinkActivate,
473
+ }}>
474
+ </devtools-link-swatch>
475
+ ${tooltipId ? html`
476
+ <devtools-tooltip
477
+ id=${tooltipId}
478
+ variant=rich
479
+ jslogContext=elements.css-var
480
+ >
481
+ ${tooltipContents}
482
+ </devtools-tooltip>
483
+ ` : ''}
484
+ `, varSwatch);
485
+ // clang-format on
486
+
487
+ return [varSwatch];
432
488
  }
433
489
  }
434
490
 
@@ -2007,6 +2063,7 @@ export function getPropertyRenderers(
2007
2063
  Array<MatchRenderer<SDK.CSSPropertyParser.Match>> {
2008
2064
  return [
2009
2065
  new VariableRenderer(stylesContainer, treeElement, matchedStyles, computedStyles, computedStyleExtraFields),
2066
+ new VariableNameRenderer(stylesContainer, treeElement, matchedStyles),
2010
2067
  new ColorRenderer(stylesContainer, treeElement),
2011
2068
  new ColorMixRenderer(stylesContainer, matchedStyles, computedStyles, computedStyleExtraFields, treeElement),
2012
2069
  new ContrastColorRenderer(stylesContainer, treeElement),
@@ -2026,10 +2083,10 @@ export function getPropertyRenderers(
2026
2083
  new EnvFunctionRenderer(treeElement, matchedStyles, computedStyles, computedStyleExtraFields),
2027
2084
  new PositionTryRenderer(matchedStyles),
2028
2085
  new LengthRenderer(stylesContainer, propertyName, treeElement),
2029
- new MathFunctionRenderer(
2030
- stylesContainer, matchedStyles, computedStyles, computedStyleExtraFields, propertyName, treeElement),
2031
- new CustomFunctionRenderer(
2032
- stylesContainer, matchedStyles, computedStyles, computedStyleExtraFields, propertyName, treeElement),
2086
+ new MathFunctionRenderer(stylesContainer, matchedStyles, computedStyles, computedStyleExtraFields, propertyName,
2087
+ treeElement),
2088
+ new CustomFunctionRenderer(stylesContainer, matchedStyles, computedStyles, computedStyleExtraFields, propertyName,
2089
+ treeElement),
2033
2090
  new AutoBaseRenderer(computedStyles, computedStyleExtraFields),
2034
2091
  new BinOpRenderer(),
2035
2092
  new RelativeColorChannelRenderer(treeElement),
@@ -2082,7 +2139,7 @@ export class StylePropertyTreeElement extends UI.TreeOutline.TreeElement {
2082
2139
  this.#parentSection = section;
2083
2140
  this.isShorthand = isShorthand;
2084
2141
  this.newProperty = newProperty;
2085
- this.#lazyRender = stylesContainer.shouldRenderLazily();
2142
+ this.#lazyRender = !this.newProperty && stylesContainer.shouldRenderLazily();
2086
2143
  if (this.newProperty) {
2087
2144
  this.listItemElement.textContent = '';
2088
2145
  }
@@ -137,7 +137,15 @@ export class StylesAiCodeCompletionProvider {
137
137
  }
138
138
  currentPropertyString = currentPropertyString + text;
139
139
  prefix = prefix + text;
140
- const suffix = content.substring(propertyEndOffset);
140
+ let suffix = content.substring(propertyEndOffset);
141
+
142
+ const maxLength = TextEditor.AiCodeCompletionProvider.MAX_PREFIX_SUFFIX_LENGTH;
143
+ if (prefix.length > maxLength) {
144
+ prefix = prefix.substring(prefix.length - maxLength);
145
+ }
146
+ if (suffix.length > maxLength) {
147
+ suffix = suffix.substring(0, maxLength);
148
+ }
141
149
 
142
150
  const startTime = performance.now();
143
151
  // TODO(b/476098133): Consider adjusting cursor position
@@ -2038,11 +2038,23 @@ export class CSSPropertyPrompt extends UI.TextPrompt.TextPrompt {
2038
2038
  override onInput(event: Event): void {
2039
2039
  super.onInput(event);
2040
2040
  if (this.aiCodeCompletionProvider) {
2041
- this.#updateAiCodeSuggestion();
2042
- this.#debouncedTriggerAiCodeCompletion();
2041
+ const inputEvent = event as InputEvent;
2042
+ const isDeletion = inputEvent.inputType?.startsWith('delete');
2043
+ if (isDeletion) {
2044
+ this.#debouncedTriggerAiCodeCompletion.cancel();
2045
+ this.setAiAutoCompletion(null);
2046
+ } else {
2047
+ this.#updateAiCodeSuggestion();
2048
+ this.#debouncedTriggerAiCodeCompletion();
2049
+ }
2043
2050
  }
2044
2051
  }
2045
2052
 
2053
+ override detach(): void {
2054
+ this.#debouncedTriggerAiCodeCompletion.cancel();
2055
+ super.detach();
2056
+ }
2057
+
2046
2058
  #handleEscape(keyboardEvent: KeyboardEvent): boolean {
2047
2059
  if (!this.aiCodeCompletionProvider || !this.treeElement.section().activeAiSuggestion) {
2048
2060
  return false;
@@ -2050,12 +2062,13 @@ export class CSSPropertyPrompt extends UI.TextPrompt.TextPrompt {
2050
2062
  keyboardEvent.preventDefault();
2051
2063
  if (this.isSuggestBoxVisible()) {
2052
2064
  this.suggestBox?.hide();
2053
- // Required for ensuring the suggestion is not cleared.
2054
- keyboardEvent.consume(true);
2055
- return true;
2065
+ } else {
2066
+ this.setAiAutoCompletion(null);
2056
2067
  }
2057
- this.setAiAutoCompletion(null);
2058
- return false;
2068
+ // Consume the event to prevent it from bubbling up to cancel the editing session,
2069
+ // and return true to prevent TextPrompt from processing it.
2070
+ keyboardEvent.consume(true);
2071
+ return true;
2059
2072
  }
2060
2073
 
2061
2074
  private handleNameOrValueUpDown(event: Event): boolean {
@@ -2331,6 +2344,7 @@ export class CSSPropertyPrompt extends UI.TextPrompt.TextPrompt {
2331
2344
  if (!args) {
2332
2345
  this.treeElement.section().activeAiSuggestion = undefined;
2333
2346
  this.activeAiSuggestionInfo = undefined;
2347
+ this.applySuggestion(null);
2334
2348
  return;
2335
2349
  }
2336
2350
 
@@ -2417,7 +2431,7 @@ export class CSSPropertyPrompt extends UI.TextPrompt.TextPrompt {
2417
2431
  }
2418
2432
 
2419
2433
  private acceptCodeComplete(): boolean {
2420
- if (this.isSuggestBoxVisible()) {
2434
+ if (this.isSuggestBoxVisible() || this.currentSuggestion()) {
2421
2435
  // accept the suggestion from the traditional autocomplete menu
2422
2436
  this.acceptAutoComplete();
2423
2437