chrome-devtools-frontend 1.0.1587572 → 1.0.1587905

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.
@@ -1,7 +1,7 @@
1
1
  Name: Dependencies sourced from the upstream `chromium` repository
2
2
  URL: https://chromium.googlesource.com/chromium/src
3
3
  Version: N/A
4
- Revision: ca9006bfc6f6f58d2fcd25b7c78dbd3b1289f949
4
+ Revision: e991bb058bdc3021ea1576fee0a80a7ecd0ef566
5
5
  Update Mechanism: Manual (https://crbug.com/428069060)
6
6
  License: BSD-3-Clause
7
7
  License File: LICENSE
@@ -40,6 +40,10 @@ const UIStrings = {
40
40
  * @description Placeholder for filter bars that shows before the user types in a filter keyword.
41
41
  */
42
42
  filter: 'Filter',
43
+ /**
44
+ * @description Tooltip shown when the user hovers over the regex icon to toggle regular-expression filtering.
45
+ */
46
+ useRegularExpression: 'Use regular expression',
43
47
  } as const;
44
48
  const str_ = i18n.i18n.registerUIStrings('ui/legacy/Toolbar.ts', UIStrings);
45
49
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
@@ -693,7 +697,6 @@ export namespace ToolbarButton {
693
697
  export class ToolbarInput extends ToolbarItem<ToolbarInput.EventTypes> {
694
698
  private prompt: TextPrompt;
695
699
  private readonly proxyElement: Element;
696
-
697
700
  constructor(
698
701
  placeholder: string, accessiblePlaceholder?: string, growFactor?: number, shrinkFactor?: number, tooltip?: string,
699
702
  completions?: ((arg0: string, arg1: string, arg2?: boolean|undefined) => Promise<Suggestion[]>),
@@ -759,6 +762,10 @@ export class ToolbarInput extends ToolbarItem<ToolbarInput.EventTypes> {
759
762
  this.updateEmptyStyles();
760
763
  }
761
764
 
765
+ protected insertTrailingElement(element: Element): void {
766
+ this.element.appendChild(element);
767
+ }
768
+
762
769
  override applyEnabledState(enabled: boolean): void {
763
770
  if (enabled) {
764
771
  this.element.classList.remove('disabled');
@@ -818,7 +825,8 @@ export class ToolbarFilter extends ToolbarInput {
818
825
  constructor(
819
826
  filterBy?: Common.UIString.LocalizedString, growFactor?: number, shrinkFactor?: number, tooltip?: string,
820
827
  completions?: ((arg0: string, arg1: string, arg2?: boolean|undefined) => Promise<Suggestion[]>),
821
- dynamicCompletions?: boolean, jslogContext?: string, element?: HTMLElement) {
828
+ dynamicCompletions?: boolean, jslogContext?: string, element?: HTMLElement, showRegexToggle?: boolean,
829
+ onRegexToggle?: () => void) {
822
830
  const filterPlaceholder = filterBy ? filterBy : i18nString(UIStrings.filter);
823
831
  super(
824
832
  filterPlaceholder, filterPlaceholder, growFactor, shrinkFactor, tooltip, completions, dynamicCompletions,
@@ -827,17 +835,36 @@ export class ToolbarFilter extends ToolbarInput {
827
835
  const filterIcon = createIcon('filter');
828
836
  this.element.prepend(filterIcon);
829
837
  this.element.classList.add('toolbar-filter');
838
+
839
+ if (showRegexToggle) {
840
+ const regexIconName = 'regular-expression';
841
+ const regexButton = new Buttons.Button.Button();
842
+ regexButton.data = {
843
+ variant: Buttons.Button.Variant.ICON_TOGGLE,
844
+ size: Buttons.Button.Size.SMALL,
845
+ iconName: regexIconName,
846
+ toggledIconName: regexIconName,
847
+ toggleType: Buttons.Button.ToggleType.PRIMARY,
848
+ toggled: false,
849
+ title: i18nString(UIStrings.useRegularExpression),
850
+ jslogContext: regexIconName,
851
+ };
852
+ ARIAUtils.setLabel(regexButton, i18nString(UIStrings.useRegularExpression));
853
+ regexButton.addEventListener('click', () => {
854
+ onRegexToggle?.();
855
+ });
856
+ this.insertTrailingElement(regexButton);
857
+ }
830
858
  }
831
859
  }
832
860
 
833
861
  export class ToolbarInputElement extends HTMLElement {
834
- static observedAttributes = ['value', 'disabled'];
862
+ static observedAttributes = ['value', 'disabled', 'regex'];
835
863
 
836
864
  item?: ToolbarInput;
837
865
  datalist: HTMLDataListElement|null = null;
838
866
  #value: string|undefined = undefined;
839
867
  #disabled = false;
840
-
841
868
  connectedCallback(): void {
842
869
  if (this.item) {
843
870
  return;
@@ -855,7 +882,8 @@ export class ToolbarInputElement extends HTMLElement {
855
882
  this.item = new ToolbarFilter(
856
883
  placeholder as Platform.UIString.LocalizedString, /* growFactor=*/ undefined,
857
884
  /* shrinkFactor=*/ undefined, tooltip, this.datalist ? this.#onAutocomplete.bind(this) : undefined,
858
- /* dynamicCompletions=*/ undefined, jslogContext || 'filter', this);
885
+ /* dynamicCompletions=*/ undefined, jslogContext || 'filter', this, this.hasAttribute('regex'),
886
+ this.#onRegexToggle.bind(this));
859
887
  } else {
860
888
  this.item = new ToolbarInput(
861
889
  placeholder, accessiblePlaceholder, /* growFactor=*/ undefined,
@@ -880,6 +908,10 @@ export class ToolbarInputElement extends HTMLElement {
880
908
  this.item?.focus();
881
909
  }
882
910
 
911
+ #onRegexToggle(): void {
912
+ this.dispatchEvent(new CustomEvent('regextoggle'));
913
+ }
914
+
883
915
  async #onAutocomplete(expression: string, prefix: string, force?: boolean): Promise<Suggestion[]> {
884
916
  if (!prefix && !force && expression || !this.datalist) {
885
917
  return [];
@@ -2034,8 +2034,8 @@ export class InterceptBindingDirective extends Lit.Directive.Directive {
2034
2034
  }
2035
2035
 
2036
2036
  /* eslint-disable-next-line @typescript-eslint/no-unsafe-function-type */
2037
- render(_listener: Function): undefined {
2038
- return undefined;
2037
+ render(listener: Function): Function {
2038
+ return listener;
2039
2039
  }
2040
2040
 
2041
2041
  static setEventListeners(templateElement: Element, renderedElement: Element): void {
@@ -2092,7 +2092,17 @@ export class HTMLElementWithLightDOMTemplate extends HTMLElement {
2092
2092
  }
2093
2093
 
2094
2094
  private static patchLitTemplate(template: Lit.LitTemplate): void {
2095
- const wrapper = Lit.Directive.directive(InterceptBindingDirective);
2095
+ const interceptingWrapper = Lit.Directive.directive(InterceptBindingDirective);
2096
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2097
+ const patchingWrapper = <Args extends any[], R>(fn: (...args: Args) => R): ((...args: Args) => R) => {
2098
+ return function(this: unknown, ...args: Args): R {
2099
+ const result = fn.apply(this, args);
2100
+ if (isLitTemplate(result)) {
2101
+ HTMLElementWithLightDOMTemplate.patchLitTemplate(result);
2102
+ }
2103
+ return result;
2104
+ };
2105
+ };
2096
2106
  if (template === Lit.nothing) {
2097
2107
  return;
2098
2108
  }
@@ -2104,10 +2114,19 @@ export class HTMLElementWithLightDOMTemplate extends HTMLElement {
2104
2114
  value['_$litType$'] === 1);
2105
2115
  }
2106
2116
 
2117
+ function isLitDirective(value: unknown): value is {values: unknown[]} {
2118
+ return Boolean(typeof value === 'object' && value && '_$litDirective$' in value && 'values' in value);
2119
+ }
2120
+
2121
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2122
+ function isCallable(value: unknown): value is(...args: any[]) => any {
2123
+ return typeof value === 'function';
2124
+ }
2125
+
2107
2126
  function patchValue(value: unknown): unknown {
2108
- if (typeof value === 'function') {
2127
+ if (isCallable(value)) {
2109
2128
  try {
2110
- return wrapper(value);
2129
+ return interceptingWrapper(value);
2111
2130
  } catch {
2112
2131
  return value;
2113
2132
  }
@@ -2116,6 +2135,17 @@ export class HTMLElementWithLightDOMTemplate extends HTMLElement {
2116
2135
  HTMLElementWithLightDOMTemplate.patchLitTemplate(value);
2117
2136
  return value;
2118
2137
  }
2138
+ if (isLitDirective(value)) {
2139
+ for (let i = 0; i < value.values.length; i++) {
2140
+ const subvalue = value.values[i];
2141
+ if (isCallable(subvalue)) {
2142
+ value.values[i] = patchingWrapper(subvalue);
2143
+ } else {
2144
+ value.values[i] = patchValue(subvalue);
2145
+ }
2146
+ }
2147
+ return value;
2148
+ }
2119
2149
  if (Array.isArray(value) || value instanceof Iterator) {
2120
2150
  return value.map(patchValue);
2121
2151
  }
package/package.json CHANGED
@@ -105,5 +105,5 @@
105
105
  "flat-cache": "6.1.12"
106
106
  }
107
107
  },
108
- "version": "1.0.1587572"
108
+ "version": "1.0.1587905"
109
109
  }