chrome-devtools-frontend 1.0.1689415 → 1.0.1690116

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 (197) hide show
  1. package/eslint.config.mjs +8 -2
  2. package/front_end/core/common/Object.ts +10 -4
  3. package/front_end/core/i18n/collect-ui-strings.js +5 -5
  4. package/front_end/core/i18n/generate-locales-js.js +1 -1
  5. package/front_end/core/i18n/i18n.ts +6 -0
  6. package/front_end/core/root/Runtime.ts +0 -5
  7. package/front_end/core/sdk/CSSMetadata.ts +3 -5
  8. package/front_end/core/sdk/DOMModel.ts +46 -11
  9. package/front_end/core/sdk/EmulationModel.ts +18 -0
  10. package/front_end/core/sdk/SDKSettings.ts +9 -0
  11. package/front_end/core/sdk/Script.ts +0 -1
  12. package/front_end/core/sdk/SecurityOrigin.ts +135 -25
  13. package/front_end/core/sdk/Target.ts +1 -5
  14. package/front_end/models/ai_assistance/AiUtils.ts +0 -10
  15. package/front_end/models/ai_assistance/agents/AccessibilityAgent.ts +6 -10
  16. package/front_end/models/ai_assistance/agents/StylingAgent.ts +0 -1
  17. package/front_end/models/ai_assistance/injected.ts +0 -2
  18. package/front_end/models/javascript_metadata/NativeFunctions.ts +1 -1
  19. package/front_end/models/trace/insights/CLSCulprits.ts +1 -2
  20. package/front_end/models/trace/insights/Cache.ts +1 -3
  21. package/front_end/models/trace/insights/CharacterSet.ts +1 -3
  22. package/front_end/models/trace/insights/DOMSize.ts +1 -3
  23. package/front_end/models/trace/insights/DocumentLatency.ts +1 -3
  24. package/front_end/models/trace/insights/DuplicatedJavaScript.ts +1 -3
  25. package/front_end/models/trace/insights/FontDisplay.ts +1 -2
  26. package/front_end/models/trace/insights/ForcedReflow.ts +1 -2
  27. package/front_end/models/trace/insights/INPBreakdown.ts +1 -3
  28. package/front_end/models/trace/insights/ImageDelivery.ts +1 -3
  29. package/front_end/models/trace/insights/LCPBreakdown.ts +1 -3
  30. package/front_end/models/trace/insights/LCPDiscovery.ts +1 -3
  31. package/front_end/models/trace/insights/LegacyJavaScript.ts +1 -3
  32. package/front_end/models/trace/insights/ModernHTTP.ts +1 -2
  33. package/front_end/models/trace/insights/NetworkDependencyTree.ts +1 -2
  34. package/front_end/models/trace/insights/RenderBlocking.ts +1 -3
  35. package/front_end/models/trace/insights/SlowCSSSelector.ts +1 -3
  36. package/front_end/models/trace/insights/ThirdParties.ts +1 -3
  37. package/front_end/models/trace/insights/Viewport.ts +1 -2
  38. package/front_end/panels/accessibility/ARIAAttributesView.ts +1 -1
  39. package/front_end/panels/accessibility/AccessibilityAnnouncementRecordingView.ts +3 -3
  40. package/front_end/panels/accessibility/AccessibilityNodeView.ts +1 -2
  41. package/front_end/panels/accessibility/AccessibilityStrings.ts +7 -3
  42. package/front_end/panels/ai_assistance/components/AIv2MarkdownRenderer.ts +2 -2
  43. package/front_end/panels/ai_assistance/components/AccessibilityAgentMarkdownRenderer.ts +1 -3
  44. package/front_end/panels/animation/AnimationGroupPreviewUI.ts +1 -1
  45. package/front_end/panels/animation/AnimationTimeline.ts +1 -1
  46. package/front_end/panels/animation/AnimationUI.ts +1 -1
  47. package/front_end/panels/application/AppManifestView.ts +6 -2
  48. package/front_end/panels/application/ApplicationPanelSidebar.ts +2 -4
  49. package/front_end/panels/application/BounceTrackingMitigationsTreeElement.ts +1 -1
  50. package/front_end/panels/application/FrameDetailsView.ts +1 -1
  51. package/front_end/panels/application/IndexedDBViews.ts +3 -2
  52. package/front_end/panels/application/ReportingApiTreeElement.ts +1 -1
  53. package/front_end/panels/application/ReportingApiView.ts +2 -2
  54. package/front_end/panels/application/ServiceWorkerUpdateCycleView.ts +1 -1
  55. package/front_end/panels/application/ServiceWorkersView.ts +1 -1
  56. package/front_end/panels/application/StorageBucketsTreeElement.ts +1 -1
  57. package/front_end/panels/application/StorageItemsToolbar.ts +6 -2
  58. package/front_end/panels/application/StorageView.ts +9 -8
  59. package/front_end/panels/application/TrustTokensTreeElement.ts +1 -1
  60. package/front_end/panels/application/WebMCPView.ts +2 -1
  61. package/front_end/panels/application/components/BounceTrackingMitigationsView.ts +1 -1
  62. package/front_end/panels/application/components/CrashReportContextGrid.ts +1 -1
  63. package/front_end/panels/application/components/EndpointsGrid.ts +1 -1
  64. package/front_end/panels/application/components/ReportsGrid.ts +1 -1
  65. package/front_end/panels/application/components/TrustTokensView.ts +1 -1
  66. package/front_end/panels/application/preloading/components/MismatchedPreloadingGrid.ts +1 -1
  67. package/front_end/panels/application/preloading/components/PreloadingGrid.ts +1 -1
  68. package/front_end/panels/application/preloading/components/RuleSetGrid.ts +7 -2
  69. package/front_end/panels/application/serviceWorkerUpdateCycleView.css +2 -0
  70. package/front_end/panels/autofill/AutofillView.ts +2 -2
  71. package/front_end/panels/browser_debugger/CategorizedBreakpointsSidebarPane.ts +2 -3
  72. package/front_end/panels/browser_debugger/DOMBreakpointsSidebarPane.ts +1 -1
  73. package/front_end/panels/changes/ChangesSidebar.ts +56 -15
  74. package/front_end/panels/changes/ChangesView.ts +1 -1
  75. package/front_end/panels/console/ConsolePrompt.ts +6 -2
  76. package/front_end/panels/console/ConsoleSidebar.ts +6 -2
  77. package/front_end/panels/elements/ElementsTreeElement.ts +12 -0
  78. package/front_end/panels/elements/ElementsTreeOutline.ts +400 -128
  79. package/front_end/panels/elements/PropertyRenderer.ts +22 -15
  80. package/front_end/panels/elements/StandaloneStylesContainer.ts +6 -2
  81. package/front_end/panels/elements/StylePropertyTreeElement.ts +75 -26
  82. package/front_end/panels/elements/StylesSidebarPane.ts +6 -2
  83. package/front_end/panels/elements/elementsTreeOutline.css +4 -0
  84. package/front_end/panels/emulation/DeviceModeView.ts +6 -1
  85. package/front_end/panels/emulation/InspectedPagePlaceholder.ts +6 -2
  86. package/front_end/panels/layer_viewer/LayerDetailsView.ts +6 -2
  87. package/front_end/panels/layer_viewer/LayerTreeOutline.ts +7 -2
  88. package/front_end/panels/layer_viewer/Layers3DView.ts +8 -1
  89. package/front_end/panels/layer_viewer/PaintProfilerView.ts +6 -2
  90. package/front_end/panels/lighthouse/lighthousePanel.css +5 -5
  91. package/front_end/panels/lighthouse/lighthouseStartView.css +13 -13
  92. package/front_end/panels/linear_memory_inspector/LinearMemoryInspectorPane.ts +6 -2
  93. package/front_end/panels/linear_memory_inspector/components/LinearMemoryInspector.ts +6 -2
  94. package/front_end/panels/mobile_throttling/NetworkThrottlingSelector.ts +6 -2
  95. package/front_end/panels/mobile_throttling/ThrottlingManager.ts +25 -54
  96. package/front_end/panels/network/NetworkLogView.ts +8 -3
  97. package/front_end/panels/network/components/RequestHeadersView.css +5 -0
  98. package/front_end/panels/network/networkLogView.css +4 -0
  99. package/front_end/panels/network/requestInitiatorViewTree.css +2 -0
  100. package/front_end/panels/performance_monitor/performanceMonitor.css +3 -3
  101. package/front_end/panels/profiler/HeapDetachedElementsView.ts +7 -2
  102. package/front_end/panels/profiler/HeapProfileView.ts +7 -2
  103. package/front_end/panels/profiler/HeapSnapshotDataGrids.ts +8 -4
  104. package/front_end/panels/profiler/HeapSnapshotGridNodes.ts +8 -4
  105. package/front_end/panels/profiler/HeapSnapshotView.ts +15 -6
  106. package/front_end/panels/profiler/HeapTimelineOverview.ts +6 -2
  107. package/front_end/panels/profiler/ProfileFlameChartDataProvider.ts +12 -5
  108. package/front_end/panels/profiler/ProfileLauncherView.ts +6 -2
  109. package/front_end/panels/profiler/profilesPanel.css +8 -9
  110. package/front_end/panels/profiler/profilesSidebarTree.css +13 -13
  111. package/front_end/panels/protocol_monitor/JSONEditor.css +2 -2
  112. package/front_end/panels/protocol_monitor/JSONEditor.ts +6 -1
  113. package/front_end/panels/protocol_monitor/protocolMonitor.css +2 -2
  114. package/front_end/panels/sources/SourcesView.ts +7 -2
  115. package/front_end/panels/sources/TabbedEditorContainer.ts +6 -2
  116. package/front_end/panels/sources/UISourceCodeFrame.ts +10 -3
  117. package/front_end/panels/timeline/AnimationsTrackAppender.ts +1 -1
  118. package/front_end/panels/timeline/AnnotationHelpers.ts +9 -9
  119. package/front_end/panels/timeline/CountersGraph.ts +8 -8
  120. package/front_end/panels/timeline/EventsTimelineTreeView.ts +3 -3
  121. package/front_end/panels/timeline/ExtensionTrackAppender.ts +1 -1
  122. package/front_end/panels/timeline/GPUTrackAppender.ts +1 -1
  123. package/front_end/panels/timeline/InteractionsTrackAppender.ts +1 -1
  124. package/front_end/panels/timeline/IsolateSelector.ts +2 -2
  125. package/front_end/panels/timeline/LayoutShiftsTrackAppender.ts +3 -3
  126. package/front_end/panels/timeline/NetworkTrackAppender.ts +1 -1
  127. package/front_end/panels/timeline/StatusDialog.ts +5 -6
  128. package/front_end/panels/timeline/ThirdPartyTreeView.ts +4 -4
  129. package/front_end/panels/timeline/ThreadAppender.ts +12 -14
  130. package/front_end/panels/timeline/TimelineController.ts +5 -8
  131. package/front_end/panels/timeline/TimelineDetailsView.ts +13 -9
  132. package/front_end/panels/timeline/TimelineEventOverview.ts +4 -4
  133. package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +17 -17
  134. package/front_end/panels/timeline/TimelineFlameChartView.ts +8 -3
  135. package/front_end/panels/timeline/TimelineHistoryManager.ts +8 -8
  136. package/front_end/panels/timeline/TimelineLoader.ts +1 -1
  137. package/front_end/panels/timeline/TimelineMiniMap.ts +7 -2
  138. package/front_end/panels/timeline/TimelinePanel.ts +57 -59
  139. package/front_end/panels/timeline/TimelineSelectorStatsView.ts +27 -27
  140. package/front_end/panels/timeline/TimelineTreeView.ts +46 -44
  141. package/front_end/panels/timeline/TimelineUIUtils.ts +142 -116
  142. package/front_end/panels/timeline/TimingsTrackAppender.ts +1 -1
  143. package/front_end/panels/timeline/TrackConfigBanner.ts +4 -4
  144. package/front_end/panels/timeline/UIDevtoolsUtils.ts +15 -15
  145. package/front_end/panels/timeline/components/insights/Table.ts +1 -1
  146. package/front_end/panels/timeline/enable-easter-egg.js +1 -1
  147. package/front_end/panels/timeline/timeline-meta.ts +30 -30
  148. package/front_end/panels/timeline/timelineFlameChartView.css +10 -10
  149. package/front_end/panels/timeline/timelineFlamechartPopover.css +5 -5
  150. package/front_end/panels/timeline/timelineHistoryManager.css +7 -7
  151. package/front_end/panels/timeline/timelinePaintProfiler.css +2 -2
  152. package/front_end/panels/timeline/utils/IgnoreList.ts +4 -4
  153. package/front_end/third_party/chromium/README.chromium +1 -1
  154. package/front_end/ui/comments/CommentAnchorResolver.ts +12 -3
  155. package/front_end/ui/comments/CommentOverlayManager.ts +9 -1
  156. package/front_end/ui/components/buttons/Button.docs.ts +1 -1
  157. package/front_end/ui/components/buttons/button.css +21 -0
  158. package/front_end/ui/components/report_view/ReportView.docs.ts +1 -1
  159. package/front_end/ui/components/snackbars/Snackbars.docs.ts +1 -1
  160. package/front_end/ui/components/spinners/Spinner.ts +1 -1
  161. package/front_end/ui/components/spinners/Spinners.docs.ts +1 -1
  162. package/front_end/ui/components/suggestion_input/SuggestionInput.ts +1 -2
  163. package/front_end/ui/components/switch/Switch.docs.ts +1 -1
  164. package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +10 -8
  165. package/front_end/ui/components/text_editor/AiCodeGenerationProvider.ts +2 -1
  166. package/front_end/ui/components/text_editor/ExecutionPositionHighlighter.ts +2 -2
  167. package/front_end/ui/components/text_editor/TextEditor.ts +19 -0
  168. package/front_end/ui/components/text_editor/config.ts +109 -96
  169. package/front_end/ui/components/text_editor/cursor_tooltip.ts +1 -1
  170. package/front_end/ui/components/text_editor/theme.ts +1 -1
  171. package/front_end/ui/components/tooltips/Tooltip.docs.ts +1 -1
  172. package/front_end/ui/components/tooltips/Tooltip.ts +1 -1
  173. package/front_end/ui/components/tree_outline/TreeOutlineUtils.ts +4 -1
  174. package/front_end/ui/kit/cards/Card.ts +1 -1
  175. package/front_end/ui/kit/icons/Icon.ts +1 -1
  176. package/front_end/ui/kit/link/Link.docs.ts +1 -1
  177. package/front_end/ui/kit/link/Link.ts +1 -1
  178. package/front_end/ui/legacy/ContextMenu.docs.ts +1 -1
  179. package/front_end/ui/legacy/Dialog.ts +10 -2
  180. package/front_end/ui/legacy/FilterBar.ts +6 -1
  181. package/front_end/ui/legacy/RadioButton.docs.ts +1 -1
  182. package/front_end/ui/legacy/SelectMenu.docs.ts +1 -1
  183. package/front_end/ui/legacy/Slider.docs.ts +1 -1
  184. package/front_end/ui/legacy/SplitWidget.ts +5 -1
  185. package/front_end/ui/legacy/TabbedPane.ts +5 -1
  186. package/front_end/ui/legacy/components/color_picker/Spectrum.ts +6 -1
  187. package/front_end/ui/legacy/components/data_grid/ViewportDataGrid.ts +6 -2
  188. package/front_end/ui/legacy/components/inline_editor/BezierEditor.ts +6 -1
  189. package/front_end/ui/legacy/components/inline_editor/CSSShadowEditor.ts +6 -2
  190. package/front_end/ui/legacy/components/object_ui/objectPropertiesSection.css +2 -0
  191. package/front_end/ui/legacy/components/perf_ui/FilmStripView.ts +6 -1
  192. package/front_end/ui/legacy/components/perf_ui/FlameChart.ts +6 -2
  193. package/front_end/ui/legacy/components/perf_ui/TimelineOverviewPane.ts +8 -4
  194. package/front_end/ui/legacy/components/quick_open/FilteredListWidget.ts +8 -3
  195. package/front_end/ui/legacy/components/quick_open/QuickOpen.ts +6 -1
  196. package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +7 -2
  197. package/package.json +2 -2
@@ -33,14 +33,16 @@ export enum AiCodeCompletionTeaserMode {
33
33
  ONLY_SHOW_ON_EMPTY = 'onlyShowOnEmpty',
34
34
  }
35
35
 
36
- export const setAiCodeCompletionTeaserMode = CodeMirror.StateEffect.define<AiCodeCompletionTeaserMode>();
37
-
38
- export const aiCodeCompletionTeaserModeState = CodeMirror.StateField.define<AiCodeCompletionTeaserMode>({
39
- create: () => AiCodeCompletionTeaserMode.OFF,
40
- update(value, tr) {
41
- return tr.effects.find(effect => effect.is(setAiCodeCompletionTeaserMode))?.value ?? value;
42
- },
43
- });
36
+ export const setAiCodeCompletionTeaserMode: CodeMirror.StateEffectType<AiCodeCompletionTeaserMode> =
37
+ CodeMirror.StateEffect.define<AiCodeCompletionTeaserMode>();
38
+
39
+ export const aiCodeCompletionTeaserModeState: CodeMirror.StateField<AiCodeCompletionTeaserMode> =
40
+ CodeMirror.StateField.define<AiCodeCompletionTeaserMode>({
41
+ create: () => AiCodeCompletionTeaserMode.OFF,
42
+ update(value, tr) {
43
+ return tr.effects.find(effect => effect.is(setAiCodeCompletionTeaserMode))?.value ?? value;
44
+ },
45
+ });
44
46
 
45
47
  export interface AiCodeCompletionConfig {
46
48
  completionContext: {
@@ -31,7 +31,8 @@ export enum AiCodeGenerationTeaserMode {
31
31
  DISMISSED = 'dismissed',
32
32
  }
33
33
 
34
- export const setAiCodeGenerationTeaserMode = CodeMirror.StateEffect.define<AiCodeGenerationTeaserMode>();
34
+ export const setAiCodeGenerationTeaserMode: CodeMirror.StateEffectType<AiCodeGenerationTeaserMode> =
35
+ CodeMirror.StateEffect.define<AiCodeGenerationTeaserMode>();
35
36
 
36
37
  const aiCodeGenerationTeaserModeState = CodeMirror.StateField.define<AiCodeGenerationTeaserMode>({
37
38
  create: () => AiCodeGenerationTeaserMode.ACTIVE,
@@ -12,7 +12,7 @@ import * as CodeMirror from '../../../third_party/codemirror.next/codemirror.nex
12
12
  * view.dispatch({effects: setHighlightedPosition.of(position)});
13
13
  * ```
14
14
  */
15
- export const setHighlightedPosition = CodeMirror.StateEffect.define<number>();
15
+ export const setHighlightedPosition: CodeMirror.StateEffectType<number> = CodeMirror.StateEffect.define<number>();
16
16
 
17
17
  /**
18
18
  * The CodeMirror effect used to clear the highlighted execution position.
@@ -22,7 +22,7 @@ export const setHighlightedPosition = CodeMirror.StateEffect.define<number>();
22
22
  * view.dispatch({effects: clearHighlightedPosition.of()});
23
23
  * ```
24
24
  */
25
- export const clearHighlightedPosition = CodeMirror.StateEffect.define<void>();
25
+ export const clearHighlightedPosition: CodeMirror.StateEffectType<void> = CodeMirror.StateEffect.define<void>();
26
26
 
27
27
  /**
28
28
  * Constructs a CodeMirror extension that can be used to decorate the current execution
@@ -38,6 +38,20 @@ export class TextEditor extends HTMLElement {
38
38
  };
39
39
  #devtoolsResizeObserver = new ResizeObserver(this.#resizeListener);
40
40
 
41
+ static get observedAttributes(): string[] {
42
+ return ['data-file-path'];
43
+ }
44
+
45
+ attributeChangedCallback(name: string, _oldValue: string|null, newValue: string|null): void {
46
+ if (name === 'data-file-path' && this.#activeEditor) {
47
+ if (newValue !== null) {
48
+ this.#activeEditor.dom.setAttribute('data-file-path', newValue);
49
+ } else {
50
+ this.#activeEditor.dom.removeAttribute('data-file-path');
51
+ }
52
+ }
53
+ }
54
+
41
55
  constructor(pendingState?: CodeMirror.EditorState) {
42
56
  super();
43
57
  this.#pendingState = pendingState;
@@ -59,6 +73,11 @@ export class TextEditor extends HTMLElement {
59
73
  scrollTo: this.#lastScrollSnapshot,
60
74
  });
61
75
 
76
+ const filePath = this.getAttribute('data-file-path');
77
+ if (filePath) {
78
+ this.#activeEditor.dom.setAttribute('data-file-path', filePath);
79
+ }
80
+
62
81
  this.#activeEditor.scrollDOM.addEventListener('scroll', () => {
63
82
  if (!this.#activeEditor) {
64
83
  return;
@@ -37,7 +37,8 @@ const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
37
37
 
38
38
  const empty: CM.Extension = [];
39
39
 
40
- export const dynamicSetting = CM.Facet.define<DynamicSetting<unknown>>();
40
+ export const dynamicSetting: CM.Facet<DynamicSetting<unknown>, ReadonlyArray<DynamicSetting<unknown>>> =
41
+ CM.Facet.define<DynamicSetting<unknown>>();
41
42
 
42
43
  // The code below is used to wire up dynamic settings to editors. When
43
44
  // you include the result of calling `instance()` in an editor
@@ -46,7 +47,7 @@ export const dynamicSetting = CM.Facet.define<DynamicSetting<unknown>>();
46
47
  // appropriate.
47
48
 
48
49
  export class DynamicSetting<T> {
49
- compartment = new CM.Compartment();
50
+ compartment: CM.Compartment = new CM.Compartment();
50
51
  readonly setting: string|Common.Settings.SettingDescriptor<T>;
51
52
 
52
53
  constructor(
@@ -90,11 +91,12 @@ export class DynamicSetting<T> {
90
91
  static none: ReadonlyArray<DynamicSetting<unknown>> = [];
91
92
  }
92
93
 
93
- export const tabMovesFocus = DynamicSetting.bool('text-editor-tab-moves-focus', [], CM.keymap.of([{
94
- key: 'Tab',
95
- run: (view: CM.EditorView) => view.state.doc.length ? CM.indentMore(view) : false,
96
- shift: (view: CM.EditorView) => view.state.doc.length ? CM.indentLess(view) : false,
97
- }]));
94
+ export const tabMovesFocus: DynamicSetting<boolean> =
95
+ DynamicSetting.bool('text-editor-tab-moves-focus', [], CM.keymap.of([{
96
+ key: 'Tab',
97
+ run: (view: CM.EditorView) => view.state.doc.length ? CM.indentMore(view) : false,
98
+ shift: (view: CM.EditorView) => view.state.doc.length ? CM.indentLess(view) : false,
99
+ }]));
98
100
 
99
101
  const disableConservativeCompletion = CM.StateEffect.define();
100
102
 
@@ -103,7 +105,7 @@ const disableConservativeCompletion = CM.StateEffect.define();
103
105
  * and accepting of completions with Enter until the user selects a
104
106
  * completion beyond the initially selected one. Used in the console.
105
107
  **/
106
- export const conservativeCompletion = CM.StateField.define<boolean>({
108
+ export const conservativeCompletion: CM.StateField<boolean> = CM.StateField.define<boolean>({
107
109
  create() {
108
110
  return true;
109
111
  },
@@ -180,36 +182,36 @@ function announceSelectedCompletionInfo(view: CM.EditorView): void {
180
182
  UI.ARIAUtils.LiveAnnouncer.alert(ariaMessage);
181
183
  }
182
184
 
183
- export const autocompletion = new DynamicSetting<boolean>(
185
+ export const autocompletion: DynamicSetting<boolean> = new DynamicSetting<boolean>(
184
186
  'text-editor-autocompletion',
185
- (activateOnTyping: boolean) =>
186
- [CM.autocompletion({
187
- activateOnTyping,
188
- icons: false,
189
- optionClass: (option: CM.Completion) => option.type === 'secondary' ? 'cm-secondaryCompletion' : '',
190
- tooltipClass: (state: CM.EditorState) => {
191
- return state.field(conservativeCompletion, false) ? 'cm-conservativeCompletion' : '';
192
- },
193
- defaultKeymap: false,
194
- updateSyncTime: 100,
195
- }),
196
- CM.Prec.highest(CM.keymap.of([
197
- {key: 'End', run: acceptCompletionIfAtEndOfLine},
198
- {key: 'ArrowRight', run: acceptCompletionIfAtEndOfLine},
199
- {key: 'Ctrl-Space', run: CM.startCompletion},
200
- {key: 'Escape', run: CM.closeCompletion},
201
- {key: 'ArrowDown', run: moveCompletionSelectionIfNotConservative(true)},
202
- {key: 'ArrowUp', run: moveCompletionSelectionBackwardWrapper()},
203
- {mac: 'Ctrl-n', run: moveCompletionSelectionIfNotConservative(true)},
204
- {mac: 'Ctrl-p', run: moveCompletionSelectionBackwardWrapper()},
205
- {key: 'PageDown', run: CM.moveCompletionSelection(true, 'page')},
206
- {key: 'PageUp', run: CM.moveCompletionSelection(false, 'page')},
207
- {key: 'Enter', run: acceptCompletionIfNotConservative},
208
- ]))]);
209
-
210
- export const bracketMatching = DynamicSetting.bool('text-editor-bracket-matching', CM.bracketMatching());
211
-
212
- export const codeFolding = DynamicSetting.bool('text-editor-code-folding', [
187
+ (activateOnTyping: boolean) => [CM.autocompletion({
188
+ activateOnTyping,
189
+ icons: false,
190
+ optionClass: (option: CM.Completion) => option.type === 'secondary' ? 'cm-secondaryCompletion' : '',
191
+ tooltipClass: (state: CM.EditorState) => {
192
+ return state.field(conservativeCompletion, false) ? 'cm-conservativeCompletion' : '';
193
+ },
194
+ defaultKeymap: false,
195
+ updateSyncTime: 100,
196
+ }),
197
+ CM.Prec.highest(CM.keymap.of([
198
+ {key: 'End', run: acceptCompletionIfAtEndOfLine},
199
+ {key: 'ArrowRight', run: acceptCompletionIfAtEndOfLine},
200
+ {key: 'Ctrl-Space', run: CM.startCompletion},
201
+ {key: 'Escape', run: CM.closeCompletion},
202
+ {key: 'ArrowDown', run: moveCompletionSelectionIfNotConservative(true)},
203
+ {key: 'ArrowUp', run: moveCompletionSelectionBackwardWrapper()},
204
+ {mac: 'Ctrl-n', run: moveCompletionSelectionIfNotConservative(true)},
205
+ {mac: 'Ctrl-p', run: moveCompletionSelectionBackwardWrapper()},
206
+ {key: 'PageDown', run: CM.moveCompletionSelection(true, 'page')},
207
+ {key: 'PageUp', run: CM.moveCompletionSelection(false, 'page')},
208
+ {key: 'Enter', run: acceptCompletionIfNotConservative},
209
+ ]))]);
210
+
211
+ export const bracketMatching: DynamicSetting<boolean> =
212
+ DynamicSetting.bool('text-editor-bracket-matching', CM.bracketMatching());
213
+
214
+ export const codeFolding: DynamicSetting<boolean> = DynamicSetting.bool('text-editor-code-folding', [
213
215
  CM.foldGutter({
214
216
  markerDOM(open: boolean): HTMLElement {
215
217
  const iconName = open ? 'triangle-down' : 'triangle-right';
@@ -247,7 +249,8 @@ function detectIndentation(doc: CM.Text): string {
247
249
  return indentUnit ?? Common.Settings.Settings.instance().moduleSetting('text-editor-indent').get();
248
250
  }
249
251
 
250
- export const autoDetectIndent = DynamicSetting.bool('text-editor-auto-detect-indent', AutoDetectIndent);
252
+ export const autoDetectIndent: DynamicSetting<boolean> =
253
+ DynamicSetting.bool('text-editor-auto-detect-indent', AutoDetectIndent);
251
254
 
252
255
  function matcher(decorator: CM.MatchDecorator): CM.Extension {
253
256
  return CM.ViewPlugin.define(
@@ -291,17 +294,19 @@ const showTrailingWhitespace = matcher(new CM.MatchDecorator({
291
294
  boundary: /\S/,
292
295
  }));
293
296
 
294
- export const showWhitespace = new DynamicSetting<string>('show-whitespaces-in-editor', value => {
295
- if (value === 'all') {
296
- return showAllWhitespace;
297
- }
298
- if (value === 'trailing') {
299
- return showTrailingWhitespace;
300
- }
301
- return empty;
302
- });
297
+ export const showWhitespace: DynamicSetting<string> =
298
+ new DynamicSetting<string>('show-whitespaces-in-editor', value => {
299
+ if (value === 'all') {
300
+ return showAllWhitespace;
301
+ }
302
+ if (value === 'trailing') {
303
+ return showTrailingWhitespace;
304
+ }
305
+ return empty;
306
+ });
303
307
 
304
- export const allowScrollPastEof = DynamicSetting.bool('allow-scroll-past-eof', CM.scrollPastEnd());
308
+ export const allowScrollPastEof: DynamicSetting<boolean> =
309
+ DynamicSetting.bool('allow-scroll-past-eof', CM.scrollPastEnd());
305
310
 
306
311
  const cachedIndentUnit: Record<string, CM.Extension> = Object.create(null);
307
312
 
@@ -313,11 +318,12 @@ function getIndentUnit(indent: string): CM.Extension {
313
318
  return value;
314
319
  }
315
320
 
316
- export const indentUnit = new DynamicSetting<string>('text-editor-indent', getIndentUnit);
321
+ export const indentUnit: DynamicSetting<string> = new DynamicSetting<string>('text-editor-indent', getIndentUnit);
317
322
 
318
- export const domWordWrap = DynamicSetting.bool('dom-word-wrap', CM.EditorView.lineWrapping);
323
+ export const domWordWrap: DynamicSetting<boolean> = DynamicSetting.bool('dom-word-wrap', CM.EditorView.lineWrapping);
319
324
 
320
- export const sourcesWordWrap = DynamicSetting.bool('sources.word-wrap', CM.EditorView.lineWrapping);
325
+ export const sourcesWordWrap: DynamicSetting<boolean> =
326
+ DynamicSetting.bool('sources.word-wrap', CM.EditorView.lineWrapping);
321
327
 
322
328
  function detectLineSeparator(text: string): CM.Extension {
323
329
  if (/\r\n/.test(text) && !/(^|[^\r])\n/.test(text)) {
@@ -344,8 +350,8 @@ function themeIsDark(): boolean {
344
350
  return setting === 'systemPreferred' ? window.matchMedia('(prefers-color-scheme: dark)').matches : setting === 'dark';
345
351
  }
346
352
 
347
- export const dummyDarkTheme = CM.EditorView.theme({}, {dark: true});
348
- export const themeSelection = new CM.Compartment();
353
+ export const dummyDarkTheme: CM.Extension = CM.EditorView.theme({}, {dark: true});
354
+ export const themeSelection: CM.Compartment = new CM.Compartment();
349
355
 
350
356
  export function theme(): CM.Extension {
351
357
  return [editorTheme, themeIsDark() ? themeSelection.of(dummyDarkTheme) : themeSelection.of([])];
@@ -385,7 +391,7 @@ export function baseConfiguration(text: string|CM.Text): CM.Extension {
385
391
  ];
386
392
  }
387
393
 
388
- export const closeBrackets = DynamicSetting.bool('text-editor-bracket-closing', [
394
+ export const closeBrackets: DynamicSetting<boolean> = DynamicSetting.bool('text-editor-bracket-closing', [
389
395
  CM.html.autoCloseTags,
390
396
  CM.closeBrackets(),
391
397
  CM.keymap.of(CM.closeBracketsKeymap),
@@ -448,7 +454,7 @@ class CompletionHint extends CM.WidgetType {
448
454
  }
449
455
  }
450
456
 
451
- export const showCompletionHint = CM.ViewPlugin.fromClass(class {
457
+ export class CompletionHintPlugin {
452
458
  decorations: CM.DecorationSet = CM.Decoration.none;
453
459
  currentHint: string|null = null;
454
460
 
@@ -489,7 +495,12 @@ export const showCompletionHint = CM.ViewPlugin.fromClass(class {
489
495
  }
490
496
  return label.slice(partBefore ? partBefore[0].length : 0);
491
497
  }
492
- }, {decorations: p => p.decorations});
498
+ }
499
+
500
+ export const showCompletionHint: CM.ViewPlugin<CompletionHintPlugin> = CM.ViewPlugin.fromClass(
501
+ CompletionHintPlugin,
502
+ {decorations: p => p.decorations},
503
+ );
493
504
 
494
505
  export function contentIncludingHint(view: CM.EditorView): string {
495
506
  const plugin = view.plugin(showCompletionHint);
@@ -501,7 +512,8 @@ export function contentIncludingHint(view: CM.EditorView): string {
501
512
  return content;
502
513
  }
503
514
 
504
- export const setAiAutoCompleteSuggestion = CM.StateEffect.define<ActiveSuggestion|null>();
515
+ export const setAiAutoCompleteSuggestion: CM.StateEffectType<ActiveSuggestion|null> =
516
+ CM.StateEffect.define<ActiveSuggestion|null>();
505
517
 
506
518
  export const enum AiSuggestionSource {
507
519
  COMPLETION = 'completion',
@@ -519,52 +531,53 @@ export interface ActiveSuggestion {
519
531
  source: AiSuggestionSource;
520
532
  }
521
533
 
522
- export const aiAutoCompleteSuggestionState = CM.StateField.define<ActiveSuggestion|null>({
523
- create: () => null,
524
- update(value, tr) {
525
- for (const effect of tr.effects) {
526
- if (effect.is(setAiAutoCompleteSuggestion)) {
527
- if (effect.value) {
528
- return effect.value;
534
+ export const aiAutoCompleteSuggestionState: CM.StateField<ActiveSuggestion|null> =
535
+ CM.StateField.define<ActiveSuggestion|null>({
536
+ create: () => null,
537
+ update(value, tr) {
538
+ for (const effect of tr.effects) {
539
+ if (effect.is(setAiAutoCompleteSuggestion)) {
540
+ if (effect.value) {
541
+ return effect.value;
542
+ }
543
+ value?.clearCachedRequest?.();
544
+ return null;
545
+ }
529
546
  }
530
- value?.clearCachedRequest?.();
531
- return null;
532
- }
533
- }
534
547
 
535
- if (!value) {
536
- return value;
537
- }
548
+ if (!value) {
549
+ return value;
550
+ }
538
551
 
539
- // A suggestion from an effect can be stale if the document was changed
540
- // between when the request was sent and the response was received.
541
- // We check if the position is still valid before trying to map it.
542
- if (value.from > tr.state.doc.length) {
543
- value.clearCachedRequest?.();
544
- return null;
545
- }
552
+ // A suggestion from an effect can be stale if the document was changed
553
+ // between when the request was sent and the response was received.
554
+ // We check if the position is still valid before trying to map it.
555
+ if (value.from > tr.state.doc.length) {
556
+ value.clearCachedRequest?.();
557
+ return null;
558
+ }
546
559
 
547
- // If deletion occurs, set to null. Otherwise, the mapping might fail if
548
- // the position is inside the deleted range.
549
- if (tr.docChanged && tr.state.doc.length < tr.startState.doc.length) {
550
- value.clearCachedRequest?.();
551
- return null;
552
- }
560
+ // If deletion occurs, set to null. Otherwise, the mapping might fail if
561
+ // the position is inside the deleted range.
562
+ if (tr.docChanged && tr.state.doc.length < tr.startState.doc.length) {
563
+ value.clearCachedRequest?.();
564
+ return null;
565
+ }
553
566
 
554
- const from = tr.changes.mapPos(value.from);
555
- const {head} = tr.state.selection.main;
567
+ const from = tr.changes.mapPos(value.from);
568
+ const {head} = tr.state.selection.main;
556
569
 
557
- // If a change happened before the position from which suggestion was generated, set to null.
558
- if (tr.docChanged && head < from) {
559
- value.clearCachedRequest?.();
560
- return null;
561
- }
570
+ // If a change happened before the position from which suggestion was generated, set to null.
571
+ if (tr.docChanged && head < from) {
572
+ value.clearCachedRequest?.();
573
+ return null;
574
+ }
562
575
 
563
- // Check if what's typed after the AI suggestion is a prefix of the AI suggestion.
564
- const typedText = tr.state.doc.sliceString(from, head);
565
- return value.text.startsWith(typedText) ? value : null;
566
- },
567
- });
576
+ // Check if what's typed after the AI suggestion is a prefix of the AI suggestion.
577
+ const typedText = tr.state.doc.sliceString(from, head);
578
+ return value.text.startsWith(typedText) ? value : null;
579
+ },
580
+ });
568
581
 
569
582
  export function hasActiveAiSuggestion(state: CM.EditorState): boolean {
570
583
  return state.field(aiAutoCompleteSuggestionState) !== null;
@@ -5,7 +5,7 @@
5
5
  import * as CodeMirror from '../../../third_party/codemirror.next/codemirror.next.js';
6
6
 
7
7
  export type ArgumentHintsTooltip = [CodeMirror.StateField<CodeMirror.Tooltip|null>, CodeMirror.ViewPlugin<object>];
8
- export const closeTooltip = CodeMirror.StateEffect.define<null>();
8
+ export const closeTooltip: CodeMirror.StateEffectType<null> = CodeMirror.StateEffect.define<null>();
9
9
 
10
10
  export function cursorTooltip(
11
11
  source: (state: CodeMirror.EditorState, pos: number) => Promise<(() => CodeMirror.TooltipView)|null>,
@@ -4,7 +4,7 @@
4
4
 
5
5
  import * as CM from '../../../third_party/codemirror.next/codemirror.next.js';
6
6
 
7
- export const editorTheme = CM.EditorView.theme({
7
+ export const editorTheme: CM.Extension = CM.EditorView.theme({
8
8
  '&.cm-editor': {
9
9
  color: 'color: var(--sys-color-on-subtle)',
10
10
  cursor: 'auto',
@@ -8,7 +8,7 @@ import {Tooltip} from './tooltips.js';
8
8
 
9
9
  const {html} = Lit;
10
10
 
11
- export function render(container: HTMLElement) {
11
+ export function render(container: HTMLElement): void {
12
12
  Lit.render(
13
13
  html`
14
14
  <div style="position: relative; z-index: 0;">
@@ -228,7 +228,7 @@ export interface TooltipProperties {
228
228
  * as well, `"trigger"` takes precedence.
229
229
  */
230
230
  export class Tooltip extends HTMLElement {
231
- static readonly observedAttributes = ['id', 'variant', 'jslogcontext', 'trigger'];
231
+ static readonly observedAttributes = ['id', 'variant', 'jslogcontext', 'trigger'] as const;
232
232
  static lastOpenedTooltipId: string|null = null;
233
233
 
234
234
  readonly #shadow = this.attachShadow({mode: 'open'});
@@ -64,7 +64,10 @@ class TrackDOMNodeToTreeNode extends Lit.Directive.Directive {
64
64
  }
65
65
  }
66
66
 
67
- export const trackDOMNodeToTreeNode = Lit.Directive.directive(TrackDOMNodeToTreeNode);
67
+ export const trackDOMNodeToTreeNode: <TreeNodeDataType>(
68
+ weakmap: WeakMap<HTMLLIElement, TreeNode<TreeNodeDataType>>,
69
+ treeNode: TreeNode<TreeNodeDataType>,
70
+ ) => Lit.DirectiveResult<typeof TrackDOMNodeToTreeNode> = Lit.Directive.directive(TrackDOMNodeToTreeNode);
68
71
 
69
72
  /**
70
73
  * Finds the next sibling of the node's parent, recursing up the tree if
@@ -44,7 +44,7 @@ import cardStyles from './card.css.js';
44
44
  * @attribute heading - The heading text.
45
45
  */
46
46
  export class Card extends HTMLElement {
47
- static readonly observedAttributes = ['heading'];
47
+ static readonly observedAttributes: string[] = ['heading'];
48
48
 
49
49
  readonly #shadow = this.attachShadow({mode: 'open'});
50
50
 
@@ -68,7 +68,7 @@ export type IconData = IconWithName|{
68
68
  * should not be used in newly written code.
69
69
  */
70
70
  export class Icon extends HTMLElement {
71
- static readonly observedAttributes = ['name'];
71
+ static readonly observedAttributes: string[] = ['name'];
72
72
 
73
73
  readonly #shadowRoot;
74
74
  readonly #icon;
@@ -8,7 +8,7 @@ import * as Lit from '../../lit/lit.js';
8
8
 
9
9
  const {html} = Lit;
10
10
 
11
- export function render(container: HTMLElement) {
11
+ export function render(container: HTMLElement): void {
12
12
  // We should stop the click as we have the wiring only in a
13
13
  // full DevTools env
14
14
  Lit.render(html`<devtools-link @click=${(ev: Event) => ev.consume()}>I am a link</devtools-link>`, container);
@@ -32,7 +32,7 @@ import linkStyles from './link.css.js';
32
32
  export class Link extends HTMLElement {
33
33
  readonly #shadow = this.attachShadow({mode: 'open'});
34
34
 
35
- static readonly observedAttributes = ['href', 'jslogcontext'];
35
+ static readonly observedAttributes: string[] = ['href', 'jslogcontext'];
36
36
 
37
37
  connectedCallback(): void {
38
38
  if (!this.hasAttribute('tabindex')) {
@@ -8,7 +8,7 @@ import {ContextMenu} from './legacy.js';
8
8
 
9
9
  const {html} = Lit;
10
10
 
11
- export function render(container: HTMLElement) {
11
+ export function render(container: HTMLElement): void {
12
12
  const menuDocs = container.createChild('div', 'menu-docs');
13
13
  const style = document.createElement('style');
14
14
  style.textContent = `
@@ -27,7 +27,11 @@ const UIStrings = {
27
27
  const str_ = i18n.i18n.registerUIStrings('ui/legacy/Dialog.ts', UIStrings);
28
28
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
29
29
 
30
- export class Dialog extends Common.ObjectWrapper.eventMixin<EventTypes, typeof GlassPane>(GlassPane) {
30
+ const DialogBase: Common.ObjectWrapper.EventMixin<EventTypes, typeof GlassPane> = Common.ObjectWrapper.eventMixin(
31
+ GlassPane,
32
+ );
33
+
34
+ export class Dialog extends DialogBase {
31
35
  private tabIndexBehavior = OutsideTabIndexBehavior.DISABLE_ALL_OUTSIDE_TAB_INDEX;
32
36
  private tabIndexMap = new Map<HTMLElement, number>();
33
37
  private focusRestorer: WidgetFocusRestorer|null = null;
@@ -253,7 +257,11 @@ export const enum OutsideTabIndexBehavior {
253
257
  PRESERVE_TAB_INDEX = 'PreserveTabIndex',
254
258
  }
255
259
 
256
- export class DialogWidget extends Common.ObjectWrapper.eventMixin<EventTypes, typeof Widget>(Widget) {
260
+ const DialogWidgetBase: Common.ObjectWrapper.EventMixin<EventTypes, typeof Widget> = Common.ObjectWrapper.eventMixin(
261
+ Widget,
262
+ );
263
+
264
+ export class DialogWidget extends DialogWidgetBase {
257
265
  #open = false;
258
266
  #jslogContext = '';
259
267
  #dialogStack = false;
@@ -44,7 +44,12 @@ const UIStrings = {
44
44
  } as const;
45
45
  const str_ = i18n.i18n.registerUIStrings('ui/legacy/FilterBar.ts', UIStrings);
46
46
  const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
47
- export class FilterBar extends Common.ObjectWrapper.eventMixin<FilterBarEventTypes, typeof HBox>(HBox) {
47
+ const FilterBarBase: Common.ObjectWrapper.EventMixin<FilterBarEventTypes, typeof HBox> =
48
+ Common.ObjectWrapper.eventMixin(
49
+ HBox,
50
+ );
51
+
52
+ export class FilterBar extends FilterBarBase {
48
53
  private enabled: boolean;
49
54
  private readonly stateSetting: Common.Settings.Setting<boolean>;
50
55
  readonly #filterButton: ToolbarSettingToggle;
@@ -4,7 +4,7 @@
4
4
 
5
5
  import {UIUtils} from './legacy.js';
6
6
 
7
- export function render(container: HTMLElement) {
7
+ export function render(container: HTMLElement): void {
8
8
  const styleElement = document.createElement('style');
9
9
  styleElement.textContent = 'fieldset { label { display: block; } }';
10
10
  container.appendChild(styleElement);
@@ -9,7 +9,7 @@ import {UIUtils} from './legacy.js';
9
9
 
10
10
  const {html} = Lit;
11
11
 
12
- export function render(container: HTMLElement) {
12
+ export function render(container: HTMLElement): void {
13
13
  function createDivWithP(text: string): HTMLDivElement {
14
14
  const div = document.createElement('div');
15
15
  div.style.paddingLeft = '25px';
@@ -4,7 +4,7 @@
4
4
 
5
5
  import {UIUtils} from './legacy.js';
6
6
 
7
- export function render(container: HTMLElement) {
7
+ export function render(container: HTMLElement): void {
8
8
  function sliderExample({min, max, tabIndex, disabled}: {
9
9
  min: number,
10
10
  max: number,
@@ -16,7 +16,11 @@ import {ToolbarButton} from './Toolbar.js';
16
16
  import {type AnyWidget, registerWidgetConfig, Widget, widgetConfig, WidgetElement} from './Widget.js';
17
17
  import {Events as ZoomManagerEvents, ZoomManager} from './ZoomManager.js';
18
18
 
19
- export class SplitWidget extends Common.ObjectWrapper.eventMixin<EventTypes, typeof Widget>(Widget) {
19
+ const SplitWidgetBase: Common.ObjectWrapper.EventMixin<EventTypes, typeof Widget> = Common.ObjectWrapper.eventMixin(
20
+ Widget,
21
+ );
22
+
23
+ export class SplitWidget extends SplitWidgetBase {
20
24
  #sidebarElement: HTMLElement;
21
25
  #mainElement: HTMLElement;
22
26
  #resizerElement: HTMLElement;
@@ -79,7 +79,11 @@ export interface TabInfo {
79
79
  selected?: boolean;
80
80
  }
81
81
 
82
- export class TabbedPane extends Common.ObjectWrapper.eventMixin<EventTypes, typeof VBox>(VBox) {
82
+ const TabbedPaneBase: Common.ObjectWrapper.EventMixin<EventTypes, typeof VBox> = Common.ObjectWrapper.eventMixin(
83
+ VBox,
84
+ );
85
+
86
+ export class TabbedPane extends TabbedPaneBase {
83
87
  readonly #headerElement: HTMLElement;
84
88
  protected readonly headerContentsElement: HTMLElement;
85
89
  tabSlider: HTMLDivElement;
@@ -208,7 +208,12 @@ function getColorFromHsva(gamut: SpectrumGamut, hsva: Common.ColorUtils.Color4D)
208
208
  }
209
209
  }
210
210
 
211
- export class Spectrum extends Common.ObjectWrapper.eventMixin<EventTypes, typeof UI.Widget.VBox>(UI.Widget.VBox) {
211
+ const SpectrumBase: Common.ObjectWrapper.EventMixin<EventTypes, typeof UI.Widget.VBox> =
212
+ Common.ObjectWrapper.eventMixin(
213
+ UI.Widget.VBox,
214
+ );
215
+
216
+ export class Spectrum extends SpectrumBase {
212
217
  #color?: Common.Color.Color;
213
218
  private gamut: SpectrumGamut = SpectrumGamut.SRGB;
214
219
  private colorElement: HTMLElement;
@@ -11,8 +11,12 @@ import {type DataGridData, DataGridImpl, DataGridNode, Events as DataGridEvents,
11
11
 
12
12
  let nextId = 0;
13
13
 
14
- export class ViewportDataGrid<T> extends Common.ObjectWrapper.eventMixin<EventTypes, typeof DataGridImpl>(
15
- DataGridImpl)<ViewportDataGridNode<T>> {
14
+ const ViewportDataGridBase: Common.ObjectWrapper.EventMixin<EventTypes, typeof DataGridImpl> =
15
+ Common.ObjectWrapper.eventMixin(
16
+ DataGridImpl,
17
+ );
18
+
19
+ export class ViewportDataGrid<T> extends ViewportDataGridBase<ViewportDataGridNode<T>> {
16
20
  private readonly onScrollBound: (event: Event|null) => void;
17
21
  private visibleNodes: Array<ViewportDataGridNode<T>>;
18
22
  /**