chrome-devtools-frontend 1.0.941095 → 1.0.943017

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 (254) hide show
  1. package/WATCHLISTS +1 -1
  2. package/config/gni/all_devtools_files.gni +0 -62
  3. package/config/gni/devtools_grd_files.gni +55 -19
  4. package/config/gni/devtools_image_files.gni +2 -3
  5. package/front_end/.eslintrc.js +12 -1
  6. package/front_end/Images/src/feedback_button_icon.svg +3 -0
  7. package/front_end/Images/src/{feedback_thin_16x16_icon.svg → survey_feedback_icon.svg} +1 -1
  8. package/front_end/Tests.js +1 -32
  9. package/front_end/core/common/Color.ts +5 -0
  10. package/front_end/core/i18n/locales/en-US.json +20 -29
  11. package/front_end/core/i18n/locales/en-XL.json +20 -29
  12. package/front_end/core/sdk/CPUProfilerModel.ts +7 -9
  13. package/front_end/core/sdk/ConsoleModel.ts +26 -28
  14. package/front_end/core/sdk/DebuggerModel.ts +4 -14
  15. package/front_end/core/sdk/sdk-meta.ts +17 -3
  16. package/front_end/entrypoints/devtools_app/devtools_app.json +1 -11
  17. package/front_end/entrypoints/inspector/inspector.json +1 -3
  18. package/front_end/entrypoints/js_app/js_app.json +1 -3
  19. package/front_end/entrypoints/main/MainImpl.ts +26 -0
  20. package/front_end/entrypoints/node_app/node_app.json +1 -3
  21. package/front_end/entrypoints/shell/shell.js +0 -11
  22. package/front_end/entrypoints/shell/shell.json +1 -5
  23. package/front_end/entrypoints/worker_app/worker_app.json +1 -7
  24. package/front_end/generated/InspectorBackendCommands.js +19 -0
  25. package/front_end/generated/protocol-mapping.d.ts +31 -1
  26. package/front_end/generated/protocol-proxy-api.d.ts +34 -2
  27. package/front_end/generated/protocol.d.ts +81 -6
  28. package/front_end/global_typings/global_defs.d.ts +5 -0
  29. package/front_end/legacy_test_runner/bindings_test_runner/IsolatedFilesystemTestRunner.js +2 -2
  30. package/front_end/legacy_test_runner/console_test_runner/console_test_runner.js +14 -2
  31. package/front_end/legacy_test_runner/legacy_test_runner.ts +10 -1
  32. package/front_end/legacy_test_runner/test_runner/TestRunner.js +11 -0
  33. package/front_end/models/formatter/SourceFormatter.ts +0 -10
  34. package/front_end/models/workspace/UISourceCode.ts +9 -42
  35. package/front_end/panels/animation/AnimationTimeline.ts +3 -3
  36. package/front_end/panels/application/ApplicationPanelSidebar.ts +3 -3
  37. package/front_end/panels/application/BackForwardCacheStrings.ts +3 -1
  38. package/front_end/panels/application/application-meta.ts +0 -3
  39. package/front_end/panels/application/components/EndpointsGrid.ts +1 -1
  40. package/front_end/panels/application/components/ReportsGrid.ts +1 -1
  41. package/front_end/panels/console/ConsolePinPane.ts +21 -26
  42. package/front_end/panels/coverage/CoverageDecorationManager.ts +4 -5
  43. package/front_end/panels/coverage/CoverageView.ts +2 -105
  44. package/front_end/panels/css_overview/components/CSSOverviewStartView.ts +11 -56
  45. package/front_end/panels/css_overview/components/cssOverviewStartView.css +1 -8
  46. package/front_end/panels/elements/ElementsTreeElement.ts +4 -9
  47. package/front_end/panels/elements/components/StylePropertyEditor.ts +2 -0
  48. package/front_end/panels/elements/components/adornerSettingsPane.css +0 -4
  49. package/front_end/panels/emulation/DeviceModeToolbar.ts +3 -1
  50. package/front_end/panels/emulation/DeviceModeView.ts +2 -1
  51. package/front_end/panels/emulation/InspectedPagePlaceholder.ts +3 -1
  52. package/front_end/panels/emulation/MediaQueryInspector.ts +3 -1
  53. package/front_end/panels/emulation/emulation-meta.ts +2 -4
  54. package/front_end/panels/issues/issues-meta.ts +0 -2
  55. package/front_end/panels/js_profiler/js_profiler-meta.ts +0 -3
  56. package/front_end/panels/layers/module.json +0 -1
  57. package/front_end/panels/lighthouse/LighthousePanel.ts +2 -4
  58. package/front_end/panels/lighthouse/LighthouseReportRenderer.ts +1 -4
  59. package/front_end/panels/lighthouse/lighthouseStartView.css +4 -0
  60. package/front_end/panels/lighthouse/module.json +0 -6
  61. package/front_end/panels/media/media-meta.ts +0 -3
  62. package/front_end/panels/network/ResourceWebSocketFrameView.ts +2 -1
  63. package/front_end/panels/network/network-meta.ts +0 -3
  64. package/front_end/panels/profiler/CPUProfileView.ts +10 -3
  65. package/front_end/panels/profiler/profiler-meta.ts +0 -2
  66. package/front_end/panels/screencast/screencast-meta.ts +0 -3
  67. package/front_end/panels/security/security-meta.ts +0 -3
  68. package/front_end/panels/sources/BreakpointEditDialog.ts +16 -30
  69. package/front_end/panels/sources/CSSPlugin.ts +310 -331
  70. package/front_end/panels/sources/CallStackSidebarPane.ts +28 -34
  71. package/front_end/panels/sources/CoveragePlugin.ts +121 -6
  72. package/front_end/panels/sources/DebuggerPlugin.ts +1166 -1243
  73. package/front_end/panels/sources/EditingLocationHistoryManager.ts +71 -101
  74. package/front_end/panels/sources/GoToLineQuickOpen.ts +4 -3
  75. package/front_end/panels/sources/InplaceFormatterEditorAction.ts +3 -3
  76. package/front_end/panels/sources/JavaScriptCompilerPlugin.ts +26 -23
  77. package/front_end/panels/sources/Plugin.ts +20 -4
  78. package/front_end/panels/sources/ProfilePlugin.ts +185 -0
  79. package/front_end/panels/sources/ScriptFormatterEditorAction.ts +3 -3
  80. package/front_end/panels/sources/ScriptOriginPlugin.ts +0 -10
  81. package/front_end/panels/sources/SnippetsPlugin.ts +1 -10
  82. package/front_end/panels/sources/SourcesPanel.ts +6 -5
  83. package/front_end/panels/sources/SourcesView.ts +10 -8
  84. package/front_end/panels/sources/TabbedEditorContainer.ts +31 -27
  85. package/front_end/panels/sources/UISourceCodeFrame.ts +335 -470
  86. package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +3 -2
  87. package/front_end/panels/sources/sources-legacy.ts +0 -6
  88. package/front_end/panels/sources/sources-meta.ts +1 -4
  89. package/front_end/panels/sources/sources.ts +0 -2
  90. package/front_end/panels/timeline/timeline-meta.ts +0 -5
  91. package/front_end/third_party/codemirror.next/bundle.ts +9 -13
  92. package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
  93. package/front_end/third_party/codemirror.next/chunk/javascript.js +2 -2
  94. package/front_end/third_party/codemirror.next/chunk/markdown.js +2 -6
  95. package/front_end/third_party/codemirror.next/chunk/php.js +2 -6
  96. package/front_end/third_party/codemirror.next/chunk/python.js +1 -1
  97. package/front_end/third_party/codemirror.next/chunk/wast.js +1 -1
  98. package/front_end/third_party/codemirror.next/chunk/xml.js +2 -2
  99. package/front_end/third_party/codemirror.next/codemirror.next.d.ts +279 -198
  100. package/front_end/third_party/codemirror.next/codemirror.next.js +1 -1
  101. package/front_end/third_party/codemirror.next/package.json +13 -11
  102. package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +1128 -1158
  103. package/front_end/third_party/lighthouse/locales/ar-XB.json +211 -79
  104. package/front_end/third_party/lighthouse/locales/ar.json +213 -81
  105. package/front_end/third_party/lighthouse/locales/bg.json +211 -79
  106. package/front_end/third_party/lighthouse/locales/ca.json +212 -80
  107. package/front_end/third_party/lighthouse/locales/cs.json +211 -79
  108. package/front_end/third_party/lighthouse/locales/da.json +211 -79
  109. package/front_end/third_party/lighthouse/locales/de.json +211 -79
  110. package/front_end/third_party/lighthouse/locales/el.json +213 -81
  111. package/front_end/third_party/lighthouse/locales/en-GB.json +211 -79
  112. package/front_end/third_party/lighthouse/locales/en-US.json +186 -75
  113. package/front_end/third_party/lighthouse/locales/en-XA.json +211 -79
  114. package/front_end/third_party/lighthouse/locales/en-XL.json +186 -75
  115. package/front_end/third_party/lighthouse/locales/es-419.json +211 -79
  116. package/front_end/third_party/lighthouse/locales/es.json +212 -80
  117. package/front_end/third_party/lighthouse/locales/fi.json +211 -79
  118. package/front_end/third_party/lighthouse/locales/fil.json +211 -79
  119. package/front_end/third_party/lighthouse/locales/fr.json +211 -79
  120. package/front_end/third_party/lighthouse/locales/he.json +212 -80
  121. package/front_end/third_party/lighthouse/locales/hi.json +214 -82
  122. package/front_end/third_party/lighthouse/locales/hr.json +211 -79
  123. package/front_end/third_party/lighthouse/locales/hu.json +211 -79
  124. package/front_end/third_party/lighthouse/locales/id.json +211 -79
  125. package/front_end/third_party/lighthouse/locales/it.json +211 -79
  126. package/front_end/third_party/lighthouse/locales/ja.json +211 -79
  127. package/front_end/third_party/lighthouse/locales/ko.json +211 -79
  128. package/front_end/third_party/lighthouse/locales/lt.json +211 -79
  129. package/front_end/third_party/lighthouse/locales/lv.json +214 -82
  130. package/front_end/third_party/lighthouse/locales/nl.json +211 -79
  131. package/front_end/third_party/lighthouse/locales/no.json +211 -79
  132. package/front_end/third_party/lighthouse/locales/pl.json +211 -79
  133. package/front_end/third_party/lighthouse/locales/pt-PT.json +211 -79
  134. package/front_end/third_party/lighthouse/locales/pt.json +211 -79
  135. package/front_end/third_party/lighthouse/locales/ro.json +212 -80
  136. package/front_end/third_party/lighthouse/locales/ru.json +211 -79
  137. package/front_end/third_party/lighthouse/locales/sk.json +211 -79
  138. package/front_end/third_party/lighthouse/locales/sl.json +211 -79
  139. package/front_end/third_party/lighthouse/locales/sr-Latn.json +211 -79
  140. package/front_end/third_party/lighthouse/locales/sr.json +211 -79
  141. package/front_end/third_party/lighthouse/locales/sv.json +211 -79
  142. package/front_end/third_party/lighthouse/locales/ta.json +218 -86
  143. package/front_end/third_party/lighthouse/locales/te.json +251 -119
  144. package/front_end/third_party/lighthouse/locales/th.json +211 -79
  145. package/front_end/third_party/lighthouse/locales/tr.json +211 -79
  146. package/front_end/third_party/lighthouse/locales/uk.json +212 -80
  147. package/front_end/third_party/lighthouse/locales/vi.json +211 -79
  148. package/front_end/third_party/lighthouse/locales/zh-HK.json +211 -79
  149. package/front_end/third_party/lighthouse/locales/zh-TW.json +211 -79
  150. package/front_end/third_party/lighthouse/locales/zh.json +211 -79
  151. package/front_end/third_party/lighthouse/report/bundle.d.ts +72 -34
  152. package/front_end/third_party/lighthouse/report/bundle.js +698 -492
  153. package/front_end/third_party/lighthouse/report-assets/report-generator.js +1 -2
  154. package/front_end/third_party/lighthouse/report-assets/report.js +40 -35
  155. package/front_end/third_party/lighthouse/report-assets/standalone-template.html +2 -4
  156. package/front_end/ui/components/code_highlighter/CodeHighlighter.ts +60 -68
  157. package/front_end/ui/components/data_grid/dataGrid.css +12 -10
  158. package/front_end/ui/components/docs/css_overview/start_view.html +25 -0
  159. package/front_end/ui/components/docs/css_overview/start_view.ts +14 -0
  160. package/front_end/ui/components/docs/icon_button/basic.ts +3 -3
  161. package/front_end/ui/components/docs/panel_feedback/button.html +25 -0
  162. package/front_end/ui/components/docs/panel_feedback/button.ts +18 -0
  163. package/front_end/ui/components/helpers/get-stylesheet.ts +0 -14
  164. package/front_end/ui/components/markdown_view/MarkdownImagesMap.ts +1 -1
  165. package/front_end/ui/components/panel_feedback/FeedbackButton.ts +67 -0
  166. package/front_end/ui/components/panel_feedback/panel_feedback.ts +1 -0
  167. package/front_end/ui/components/survey_link/SurveyLink.ts +1 -1
  168. package/front_end/ui/components/text_editor/TextEditor.ts +79 -36
  169. package/front_end/ui/components/text_editor/config.ts +42 -26
  170. package/front_end/ui/components/text_editor/javascript.ts +2 -3
  171. package/front_end/ui/components/text_editor/position.ts +17 -0
  172. package/front_end/ui/components/text_editor/text_editor.ts +1 -0
  173. package/front_end/ui/components/text_editor/theme.ts +5 -1
  174. package/front_end/ui/legacy/Dialog.ts +3 -1
  175. package/front_end/ui/legacy/DropTarget.ts +2 -1
  176. package/front_end/ui/legacy/EmptyWidget.ts +2 -1
  177. package/front_end/ui/legacy/FilterBar.ts +2 -1
  178. package/front_end/ui/legacy/GlassPane.ts +4 -2
  179. package/front_end/ui/legacy/Infobar.ts +5 -8
  180. package/front_end/ui/legacy/InspectorView.ts +6 -1
  181. package/front_end/ui/legacy/ListWidget.ts +2 -1
  182. package/front_end/ui/legacy/PopoverHelper.ts +2 -1
  183. package/front_end/ui/legacy/ProgressIndicator.ts +2 -1
  184. package/front_end/ui/legacy/RemoteDebuggingTerminatedScreen.ts +2 -1
  185. package/front_end/ui/legacy/ReportView.ts +2 -1
  186. package/front_end/ui/legacy/RootView.ts +2 -1
  187. package/front_end/ui/legacy/SearchableView.ts +2 -1
  188. package/front_end/ui/legacy/ShortcutRegistry.ts +11 -7
  189. package/front_end/ui/legacy/SoftContextMenu.ts +2 -1
  190. package/front_end/ui/legacy/SoftDropDown.ts +4 -2
  191. package/front_end/ui/legacy/SplitWidget.ts +2 -1
  192. package/front_end/ui/legacy/SuggestBox.ts +2 -1
  193. package/front_end/ui/legacy/TabbedPane.ts +2 -1
  194. package/front_end/ui/legacy/TargetCrashedScreen.ts +2 -1
  195. package/front_end/ui/legacy/TextPrompt.ts +2 -1
  196. package/front_end/ui/legacy/Toolbar.ts +3 -2
  197. package/front_end/ui/legacy/Treeoutline.ts +3 -2
  198. package/front_end/ui/legacy/UIUtils.ts +16 -13
  199. package/front_end/ui/legacy/ViewManager.ts +2 -1
  200. package/front_end/ui/legacy/Widget.ts +1 -1
  201. package/front_end/ui/legacy/components/object_ui/object_ui-meta.ts +0 -3
  202. package/front_end/ui/legacy/components/perf_ui/ChartViewport.ts +2 -1
  203. package/front_end/ui/legacy/components/perf_ui/FilmStripView.ts +3 -1
  204. package/front_end/ui/legacy/components/perf_ui/FlameChart.ts +2 -1
  205. package/front_end/ui/legacy/components/perf_ui/LineLevelProfile.ts +35 -131
  206. package/front_end/ui/legacy/components/perf_ui/OverviewGrid.ts +2 -1
  207. package/front_end/ui/legacy/components/perf_ui/TimelineGrid.ts +3 -1
  208. package/front_end/ui/legacy/components/perf_ui/TimelineOverviewPane.ts +2 -1
  209. package/front_end/ui/legacy/components/perf_ui/perf_ui-meta.ts +0 -2
  210. package/front_end/ui/legacy/components/quick_open/filteredListWidget.css +2 -2
  211. package/front_end/ui/legacy/components/source_frame/BinaryResourceViewFactory.ts +3 -6
  212. package/front_end/ui/legacy/components/source_frame/FontView.ts +1 -0
  213. package/front_end/ui/legacy/components/source_frame/ImageView.ts +1 -0
  214. package/front_end/ui/legacy/components/source_frame/JSONView.ts +1 -0
  215. package/front_end/ui/legacy/components/source_frame/ResourceSourceFrame.ts +19 -14
  216. package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +501 -252
  217. package/front_end/ui/legacy/components/source_frame/XMLView.ts +2 -0
  218. package/front_end/ui/legacy/components/source_frame/module.json +0 -3
  219. package/front_end/ui/legacy/components/source_frame/source_frame-legacy.ts +0 -11
  220. package/front_end/ui/legacy/components/source_frame/source_frame.ts +0 -2
  221. package/front_end/ui/legacy/components/text_editor/CodeMirrorTextEditor.ts +2 -0
  222. package/front_end/ui/legacy/components/text_editor/cmdevtools.css +3 -1
  223. package/front_end/ui/legacy/components/text_editor/module.json +0 -3
  224. package/front_end/ui/legacy/components/utils/Linkifier.ts +7 -15
  225. package/front_end/ui/legacy/radioButton.css +1 -13
  226. package/front_end/ui/legacy/textButton.css +5 -4
  227. package/front_end/ui/legacy/themeColors.css +36 -0
  228. package/front_end/ui/legacy/theme_support/theme_support_impl.ts +7 -9
  229. package/front_end/ui/legacy/utils/append-style.ts +9 -4
  230. package/front_end/ui/legacy/utils/create-shadow-root-with-core-styles.ts +2 -2
  231. package/front_end/ui/legacy/utils/inject-core-styles.ts +7 -4
  232. package/package.json +1 -1
  233. package/scripts/build/generate_css_js_files.js +23 -9
  234. package/scripts/build/ninja/generate_css.gni +10 -1
  235. package/scripts/eslint_rules/lib/check_css_import.js +2 -2
  236. package/scripts/eslint_rules/tests/check_css_import_test.js +12 -0
  237. package/front_end/Images/radioDot-dark-theme.png +0 -0
  238. package/front_end/Images/radioDot.png +0 -0
  239. package/front_end/emulated_devices/module.json +0 -6
  240. package/front_end/panels/application/module.json +0 -7
  241. package/front_end/panels/emulation/module.json +0 -11
  242. package/front_end/panels/issues/module.json +0 -6
  243. package/front_end/panels/js_profiler/module.json +0 -5
  244. package/front_end/panels/layer_viewer/module.json +0 -6
  245. package/front_end/panels/media/module.json +0 -6
  246. package/front_end/panels/network/module.json +0 -6
  247. package/front_end/panels/profiler/module.json +0 -6
  248. package/front_end/panels/screencast/module.json +0 -6
  249. package/front_end/panels/security/module.json +0 -5
  250. package/front_end/panels/timeline/module.json +0 -8
  251. package/front_end/third_party/lighthouse/report-assets/report.css +0 -1774
  252. package/front_end/ui/legacy/components/perf_ui/module.json +0 -13
  253. package/front_end/ui/legacy/components/source_frame/SourcesTextEditor.ts +0 -1030
  254. package/front_end/ui/legacy/module.json +0 -41
@@ -21,13 +21,11 @@ limitations under the License.
21
21
  <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
22
22
  <link rel="icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAEhklEQVR4AWJxL/BhIAesev1U5tcflpncgNrKIsqNIwzC9feMpDUzs70kOczMzMzJJcxwCTMzncPMnOwtzBwzMzPb0vRfeZPp0VhPS5I39V5fdiXV1/VD+9QC7OVn9BsyH1XIoEI1PfmJvLFowVV564+34DFUHudbmfDh4kVXh//7XwE+WjS/YfXZe3yr4j2rqj1AIhSB7hZ8ZtPZu/zw8cK523U4wE1/rvPfWrz4zs0m9ZdC9yUJAlASdBAgocRegfF/f3/h/PuaFsxMdwjAR0vm1+06eMMfIrhLqTWqdH4EumU2SPfMhigJAlRQbZrgrRsl9U+Y2DYDFCz3ILC9kiAiqSrMwbWT0nceEnR+9Kggc2zjOJCASDENkg0a5HfZZgDP81CM3CrQs2Z1+o7DJ6ePr8sK0AOCHv5Jjdt3evyYSaZ351VIStIxPRAUtrBYbxC6w+BZ0ivVSBKkIhJhemSyZpfB00EiPO2VjzYkxhcqXQqCWCShGplvi3y0QxqbuBurMjyJeWnkHZuAEgIQGsUBqwrfjZ+IlBgKyRJzVVYF8O6qFWdh86YzQzMrZigYmxAyfvHgLZQ/LC1CbeniW2Hkqr/PH16SgvGuf2/uzNMBwJA/njxizGPtSyAf7EziJCMGRDRdhoAC4PL1A/SrKQMAAQkEfpJAcRQdrBJ7gNwjSpJsdwK+CANBkqa1LgQB4IicV9nYUct7gaxuDJUErQIiEAiMxLVOFlKzIktPpT0ggpdpC/8YAHnxbgkUY4tAAFSR7AAXNyAAWHJrA/kHGjzg5nleuwFO7Nd/IoDw4Pm58+4jNLmYG0wRA5bErc2Mr3Y+dXTDW1VvwqbJkzMCHQ4S1GTCBOIgUHJrGdEwqzR+jAp/o2qAZelUDoQnruEEdDclJI6576AlNVfc+22XN/+Y1vnJD0Yind6UpEEvn/Hqq15EYjCW7jZCJEpnNvDgkyelDjs106kuux2AAXCSobULOWP8mLhYlpoDMK4qAFXJGk+grtH8YXVz5KJblqaG1+VUdTc0I290bmUQAriGITRbdQnom0aoFj8kx1+wMD2ifncAXUQE4SkDqN1hE0jEophs1SUwZAOhUAiMCLwRtamtTZtbbmZErSAUHbSysaoEmnrsakiMiUAURi283gN6wans9oX8rOCrj7/JP35DFD+iQ7Au/K2KE1jzx6ujjUnXFH9KjEq6ZlhsTBICrNLJf47Pv/pkHzvup1w4dmUbEei0+bcXRqJuh5kVARQ8byyYxOwNGr7A87xh1tp8sGT+uMInrwi++Xj7TQz2d27NvwEkrOflAFQGIDA5khASBCGdO2/Z/MnLPwYfv5TFhjW7QhVKAB6afwe2LpFlFsCnlQEosgQgDsdOG1/LKeNqJS4JCSPJ/i+TakwEARor7gER1Iva5JmPOJK0RUqmoPnnlzFCtmIAhAAQEIQRgDaiYPIauNXcnDlRIrWNFY3hm7PG9YRqr7IV7HrCgAC17befjEvRq2nGhAHtBqDpOuI/I1diUUAMYIxEdyejBJqLnNoszGZtfiX/CztGv2mq+sdaAAAAAElFTkSuQmCC">
23
23
  <title>Lighthouse Report</title>
24
- <style>/*%%LIGHTHOUSE_CSS%%*/</style>
24
+ <style>body {margin: 0}</style>
25
25
  </head>
26
- <body class="lh-root lh-vars">
26
+ <body>
27
27
  <noscript>Lighthouse report requires JavaScript. Please enable.</noscript>
28
28
 
29
- <main><!-- report populated here --></main>
30
-
31
29
  <div id="lh-log"></div>
32
30
 
33
31
  <script>window.__LIGHTHOUSE_JSON__ = %%LIGHTHOUSE_JSON%%;</script>
@@ -2,56 +2,50 @@
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
4
 
5
- import type * as CodeMirror from '../../../third_party/codemirror.next/codemirror.next.js';
6
-
7
- let highlightStyle: CodeMirror.HighlightStyle|null = null;
8
-
9
- function importCM(): Promise<typeof CodeMirror> {
10
- return import('../../../third_party/codemirror.next/codemirror.next.js');
11
- }
12
-
13
- export function getHighlightStyle(modCM: typeof CodeMirror): CodeMirror.HighlightStyle {
14
- if (!highlightStyle) {
15
- const t = modCM.tags;
16
- highlightStyle = modCM.HighlightStyle.define([
17
- {tag: t.variableName, class: 'token-variable'},
18
- {tag: t.propertyName, class: 'token-property'},
19
- {tag: [t.typeName, t.className, t.namespace, t.macroName], class: 'token-type'},
20
- {tag: [t.special(t.name), t.constant(t.className)], class: 'token-variable-special'},
21
- {tag: t.definition(t.name), class: 'token-definition'},
22
- {tag: t.standard(t.variableName), class: 'token-builtin'},
23
-
24
- {tag: [t.number, t.literal, t.unit], class: 'token-number'},
25
- {tag: t.string, class: 'token-string'},
26
- {tag: [t.special(t.string), t.regexp, t.escape], class: 'token-string-special'},
27
- {tag: [t.atom, t.labelName, t.bool], class: 'token-atom'},
28
-
29
- {tag: t.keyword, class: 'token-keyword'},
30
- {tag: [t.comment, t.quote], class: 'token-comment'},
31
- {tag: t.meta, class: 'token-meta'},
32
- {tag: t.invalid, class: 'token-invalid'},
33
-
34
- {tag: t.tagName, class: 'token-tag'},
35
- {tag: t.attributeName, class: 'token-attribute'},
36
- {tag: t.attributeValue, class: 'token-attribute-value'},
37
-
38
- {tag: t.inserted, class: 'token-inserted'},
39
- {tag: t.deleted, class: 'token-deleted'},
40
- {tag: t.heading, class: 'token-heading'},
41
- {tag: t.link, class: 'token-link'},
42
- {tag: t.strikethrough, class: 'token-strikethrough'},
43
- {tag: t.strong, class: 'token-strong'},
44
- {tag: t.emphasis, class: 'token-emphasis'},
45
- ]);
46
- }
47
- return highlightStyle;
48
- }
5
+ import * as CodeMirror from '../../../third_party/codemirror.next/codemirror.next.js';
6
+
7
+ const t = CodeMirror.tags;
8
+
9
+ export const highlightStyle: CodeMirror.HighlightStyle = CodeMirror.HighlightStyle.define([
10
+ {tag: t.variableName, class: 'token-variable'},
11
+ {tag: t.propertyName, class: 'token-property'},
12
+ {tag: [t.typeName, t.className, t.namespace, t.macroName], class: 'token-type'},
13
+ {tag: [t.special(t.name), t.constant(t.className)], class: 'token-variable-special'},
14
+ {tag: t.definition(t.name), class: 'token-definition'},
15
+ {tag: t.standard(t.variableName), class: 'token-builtin'},
16
+
17
+ {tag: [t.number, t.literal, t.unit], class: 'token-number'},
18
+ {tag: t.string, class: 'token-string'},
19
+ {tag: [t.special(t.string), t.regexp, t.escape], class: 'token-string-special'},
20
+ {tag: [t.atom, t.labelName, t.bool], class: 'token-atom'},
21
+
22
+ {tag: t.keyword, class: 'token-keyword'},
23
+ {tag: [t.comment, t.quote], class: 'token-comment'},
24
+ {tag: t.meta, class: 'token-meta'},
25
+ {tag: t.invalid, class: 'token-invalid'},
26
+
27
+ {tag: t.tagName, class: 'token-tag'},
28
+ {tag: t.attributeName, class: 'token-attribute'},
29
+ {tag: t.attributeValue, class: 'token-attribute-value'},
30
+
31
+ {tag: t.inserted, class: 'token-inserted'},
32
+ {tag: t.deleted, class: 'token-deleted'},
33
+ {tag: t.heading, class: 'token-heading'},
34
+ {tag: t.link, class: 'token-link'},
35
+ {tag: t.strikethrough, class: 'token-strikethrough'},
36
+ {tag: t.strong, class: 'token-strong'},
37
+ {tag: t.emphasis, class: 'token-emphasis'},
38
+ ]);
49
39
 
50
40
  export async function create(code: string, mimeType: string): Promise<CodeHighlighter> {
51
- const CM = await importCM();
52
41
  const language = await languageFromMIME(mimeType);
53
- const tree = language ? language.language.parser.parse(code) : new CM.Tree(CM.NodeType.none, [], [], code.length);
54
- return new CodeHighlighter(code, tree, CM);
42
+ let tree: CodeMirror.Tree;
43
+ if (language) {
44
+ tree = language.language.parser.parse(code);
45
+ } else {
46
+ tree = new CodeMirror.Tree(CodeMirror.NodeType.none, [], [], code.length);
47
+ }
48
+ return new CodeHighlighter(code, tree);
55
49
  }
56
50
 
57
51
  export async function highlightNode(node: Element, mimeType: string): Promise<void> {
@@ -71,57 +65,55 @@ export async function highlightNode(node: Element, mimeType: string): Promise<vo
71
65
  }
72
66
 
73
67
  export async function languageFromMIME(mimeType: string): Promise<CodeMirror.LanguageSupport|null> {
74
- const CM = await importCM();
75
-
76
68
  switch (mimeType) {
77
69
  case 'text/javascript':
78
- return (await CM.javascript()).javascript();
70
+ return CodeMirror.javascript.javascript();
79
71
  case 'text/jsx':
80
- return (await CM.javascript()).javascript({jsx: true});
72
+ return CodeMirror.javascript.javascript({jsx: true});
81
73
  case 'text/typescript':
82
- return (await CM.javascript()).javascript({typescript: true});
74
+ return CodeMirror.javascript.javascript({typescript: true});
83
75
  case 'text/typescript-jsx':
84
- return (await CM.javascript()).javascript({typescript: true, jsx: true});
76
+ return CodeMirror.javascript.javascript({typescript: true, jsx: true});
85
77
 
86
78
  case 'text/css':
87
79
  case 'text/x-scss':
88
- return (await CM.css()).css();
80
+ return CodeMirror.css.css();
89
81
 
90
82
  case 'text/html':
91
- return (await CM.html()).html();
83
+ return CodeMirror.html.html();
92
84
 
93
85
  case 'application/xml':
94
- return (await CM.xml()).xml();
86
+ return (await CodeMirror.xml()).xml();
95
87
 
96
88
  case 'text/webassembly':
97
- return (await CM.wast()).wast();
89
+ return (await CodeMirror.wast()).wast();
98
90
 
99
91
  case 'text/x-c++src':
100
- return (await CM.cpp()).cpp();
92
+ return (await CodeMirror.cpp()).cpp();
101
93
 
102
94
  case 'text/x-java':
103
- return (await CM.java()).java();
95
+ return (await CodeMirror.java()).java();
104
96
 
105
97
  case 'application/json':
106
- return (await CM.json()).json();
98
+ return (await CodeMirror.json()).json();
107
99
 
108
100
  case 'application/x-httpd-php':
109
- return (await CM.php()).php();
101
+ return (await CodeMirror.php()).php();
110
102
 
111
103
  case 'text/x-python':
112
- return (await CM.python()).python();
104
+ return (await CodeMirror.python()).python();
113
105
 
114
106
  case 'text/markdown':
115
- return (await CM.markdown()).markdown();
107
+ return (await CodeMirror.markdown()).markdown();
116
108
 
117
109
  case 'text/x-sh':
118
- return new CM.LanguageSupport(await CM.shell());
110
+ return new CodeMirror.LanguageSupport(await CodeMirror.shell());
119
111
 
120
112
  case 'text/x-coffeescript':
121
- return new CM.LanguageSupport(await CM.coffeescript());
113
+ return new CodeMirror.LanguageSupport(await CodeMirror.coffeescript());
122
114
 
123
115
  case 'text/x-clojure':
124
- return new CM.LanguageSupport(await CM.clojure());
116
+ return new CodeMirror.LanguageSupport(await CodeMirror.clojure());
125
117
 
126
118
  default:
127
119
  return null;
@@ -129,7 +121,7 @@ export async function languageFromMIME(mimeType: string): Promise<CodeMirror.Lan
129
121
  }
130
122
 
131
123
  export class CodeHighlighter {
132
- constructor(readonly code: string, readonly tree: CodeMirror.Tree, private readonly modCM: typeof CodeMirror) {
124
+ constructor(readonly code: string, readonly tree: CodeMirror.Tree) {
133
125
  }
134
126
 
135
127
  highlight(token: (text: string, style: string) => void): void {
@@ -144,7 +136,7 @@ export class CodeHighlighter {
144
136
  pos = to;
145
137
  }
146
138
  };
147
- this.modCM.highlightTree(this.tree, getHighlightStyle(this.modCM).match, (from, to, style) => {
139
+ CodeMirror.highlightTree(this.tree, highlightStyle.match, (from, to, style) => {
148
140
  flush(from, '');
149
141
  flush(to, style);
150
142
  }, from, to);
@@ -120,21 +120,23 @@ th.firstVisibleColumn {
120
120
  }
121
121
 
122
122
  [aria-sort="descending"]::after {
123
- content: " ";
124
- border-left: 0.3em solid transparent;
125
- border-right: 0.3em solid transparent;
126
- border-top: 0.3em solid var(--color-text-primary);
123
+ content: "";
124
+ width: 0;
125
+ border-left: 0.4em solid transparent;
126
+ border-right: 0.4em solid transparent;
127
+ border-top: 0.4em solid var(--color-text-secondary);
127
128
  position: absolute;
128
129
  right: 0.5em;
129
- top: 0.6em;
130
+ top: 0.85em;
130
131
  }
131
132
 
132
133
  [aria-sort="ascending"]::after {
133
- content: " ";
134
- border-bottom: 0.3em solid var(--color-text-primary);
135
- border-left: 0.3em solid transparent;
136
- border-right: 0.3em solid transparent;
134
+ content: "";
135
+ width: 0;
136
+ border-bottom: 0.4em solid var(--color-text-secondary);
137
+ border-left: 0.4em solid transparent;
138
+ border-right: 0.4em solid transparent;
137
139
  position: absolute;
138
140
  right: 0.5em;
139
- top: 0.6em;
141
+ top: 0.7em;
140
142
  }
@@ -0,0 +1,25 @@
1
+ <!--
2
+ Copyright 2021 The Chromium Authors. All rights reserved.
3
+ Use of this source code is governed by a BSD-style license that can be
4
+ found in the LICENSE file.
5
+ -->
6
+ <!DOCTYPE html>
7
+ <html>
8
+ <head>
9
+ <meta charset="UTF-8" />
10
+ <meta name="viewport" content="width=device-width" />
11
+ <title>CSS Overview Start View</title>
12
+ <style>
13
+ #container {
14
+ width: 80%;
15
+ border: 1px solid black;
16
+ padding: 10px;
17
+ }
18
+ </style>
19
+ </head>
20
+ <body>
21
+ <div id="container">
22
+ </div>
23
+ <script type="module" src="./start_view.js"></script>
24
+ </body>
25
+ </html>
@@ -0,0 +1,14 @@
1
+ // Copyright 2021 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ import * as FrontendHelpers from '../../../../../test/unittests/front_end/helpers/EnvironmentHelpers.js';
6
+ import * as CSSOverviewComponents from '../../../../panels/css_overview/components/components.js';
7
+ import * as ComponentHelpers from '../../helpers/helpers.js';
8
+
9
+ await ComponentHelpers.ComponentServerSetup.setup();
10
+ await FrontendHelpers.initializeGlobalVars();
11
+
12
+ const component = new CSSOverviewComponents.CSSOverviewStartView.CSSOverviewStartView();
13
+
14
+ document.getElementById('container')?.appendChild(component);
@@ -12,18 +12,18 @@ function appendComponent(data: IconButton.IconButton.IconButtonData) {
12
12
 
13
13
  appendComponent({
14
14
  clickHandler: (): void => {},
15
- groups: [{iconName: 'feedback_thin_16x16_icon', iconColor: 'black', text: '1 item'}],
15
+ groups: [{iconName: 'survey_feedback_icon', iconColor: 'black', text: '1 item'}],
16
16
  });
17
17
 
18
18
  appendComponent({
19
19
  clickHandler: (): void => {},
20
- groups: [{iconName: 'feedback_thin_16x16_icon', iconColor: 'black', text: '1 item'}],
20
+ groups: [{iconName: 'survey_feedback_icon', iconColor: 'black', text: '1 item'}],
21
21
  });
22
22
 
23
23
  appendComponent({
24
24
  clickHandler: (): void => {},
25
25
  groups: [
26
- {iconName: 'feedback_thin_16x16_icon', iconColor: 'blue', text: 'Test'},
26
+ {iconName: 'survey_feedback_icon', iconColor: 'blue', text: 'Test'},
27
27
  {iconName: 'warning_icon', iconColor: '', text: '1'},
28
28
  ],
29
29
  });
@@ -0,0 +1,25 @@
1
+ <!--
2
+ Copyright 2021 The Chromium Authors. All rights reserved.
3
+ Use of this source code is governed by a BSD-style license that can be
4
+ found in the LICENSE file.
5
+ -->
6
+ <!DOCTYPE html>
7
+ <html>
8
+ <head>
9
+ <meta charset="UTF-8" />
10
+ <meta name="viewport" content="width=device-width" />
11
+ <title>Feedback button</title>
12
+ <style>
13
+ #container {
14
+ width: 80%;
15
+ border: 1px solid black;
16
+ padding: 10px;
17
+ }
18
+ </style>
19
+ </head>
20
+ <body>
21
+ <div id="container">
22
+ </div>
23
+ <script type="module" src="./button.js"></script>
24
+ </body>
25
+ </html>
@@ -0,0 +1,18 @@
1
+ // Copyright 2021 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ import * as FrontendHelpers from '../../../../../test/unittests/front_end/helpers/EnvironmentHelpers.js';
6
+ import * as PanelFeedback from '../../../components/panel_feedback/panel_feedback.js';
7
+ import * as ComponentHelpers from '../../helpers/helpers.js';
8
+
9
+ await ComponentHelpers.ComponentServerSetup.setup();
10
+ await FrontendHelpers.initializeGlobalVars();
11
+
12
+ const component = new PanelFeedback.FeedbackButton.FeedbackButton();
13
+
14
+ component.data = {
15
+ feedbackUrl: 'https://www.example.com',
16
+ };
17
+
18
+ document.getElementById('container')?.appendChild(component);
@@ -41,20 +41,6 @@ export function legacyGetStyleSheets(path: string): CSSStyleSheet[] {
41
41
  * them through to the right place, respecting Karma's ROOT_DIRECTORY setting.
42
42
  */
43
43
  export const CSS_RESOURCES_TO_LOAD_INTO_RUNTIME = [
44
- 'ui/legacy/inspectorCommon.css',
45
- 'ui/legacy/textButton.css',
46
- 'ui/legacy/themeColors.css',
47
- 'ui/legacy/inspectorSyntaxHighlight.css',
48
- 'ui/legacy/progressIndicator.css',
49
44
  'panels/application/serviceWorkerUpdateCycleView.css',
50
- 'ui/legacy/tabbedPane.css',
51
- 'ui/legacy/glassPane.css',
52
- 'ui/legacy/suggestBox.css',
53
- 'ui/legacy/treeoutline.css',
54
- 'ui/legacy/softContextMenu.css',
55
- 'ui/legacy/splitWidget.css',
56
45
  'ui/legacy/components/source_frame/jsonView.css',
57
- 'ui/legacy/searchableView.css',
58
- 'ui/legacy/toolbar.css',
59
- 'ui/legacy/inspectorViewTabbedPane.css',
60
46
  ];
@@ -22,7 +22,7 @@ export interface ImageData {
22
22
  * [
23
23
  * 'feedbackIcon',
24
24
  * {
25
- * src: 'Images/feedback_thin_16x16_icon.svg',
25
+ * src: 'Images/survey_feedback_icon.svg',
26
26
  * isIcon: true,
27
27
  * width: '20px',
28
28
  * height: '20px',
@@ -0,0 +1,67 @@
1
+ // Copyright 2021 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ import * as Host from '../../../core/host/host.js';
6
+ import * as i18n from '../../../core/i18n/i18n.js';
7
+ import * as ComponentHelpers from '../../components/helpers/helpers.js';
8
+ import * as LitHtml from '../../lit-html/lit-html.js';
9
+ import * as Buttons from '../buttons/buttons.js';
10
+
11
+ const UIStrings = {
12
+ /**
13
+ * @description The title of the button that leads to the feedback form.
14
+ */
15
+ feedback: 'Feedback',
16
+ };
17
+
18
+ const str_ = i18n.i18n.registerUIStrings('ui/components/panel_feedback/FeedbackButton.ts', UIStrings);
19
+ const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
20
+
21
+ const feedbackIconUrl = new URL('../../../Images/feedback_button_icon.svg', import.meta.url).toString();
22
+
23
+ export interface FeedbackButtonData {
24
+ feedbackUrl: string;
25
+ }
26
+ export class FeedbackButton extends HTMLElement {
27
+ static readonly litTagName = LitHtml.literal`devtools-feedback-button`;
28
+ readonly #shadow = this.attachShadow({mode: 'open'});
29
+ readonly #boundRender = this.render.bind(this);
30
+
31
+ #props: FeedbackButtonData = {
32
+ feedbackUrl: '',
33
+ };
34
+
35
+ set data(data: FeedbackButtonData) {
36
+ this.#props = data;
37
+ ComponentHelpers.ScheduledRender.scheduleRender(this, this.#boundRender);
38
+ }
39
+
40
+ #onFeedbackClick(): void {
41
+ Host.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(this.#props.feedbackUrl);
42
+ }
43
+
44
+ private render(): void {
45
+ if (!ComponentHelpers.ScheduledRender.isScheduledRender(this)) {
46
+ throw new Error('FeedbackButton render was not scheduled');
47
+ }
48
+
49
+ // clang-format off
50
+ LitHtml.render(LitHtml.html`
51
+ <${Buttons.Button.Button.litTagName}
52
+ @click=${this.#onFeedbackClick}
53
+ .iconUrl=${feedbackIconUrl}
54
+ .variant=${Buttons.Button.Variant.SECONDARY}
55
+ >${i18nString(UIStrings.feedback)}</${Buttons.Button.Button.litTagName}>
56
+ `, this.#shadow, {host: this});
57
+ // clang-format on
58
+ }
59
+ }
60
+
61
+ ComponentHelpers.CustomElements.defineComponent('devtools-feedback-button', FeedbackButton);
62
+
63
+ declare global {
64
+ interface HTMLElementTagNameMap {
65
+ 'devtools-feedback-button': FeedbackButton;
66
+ }
67
+ }
@@ -2,4 +2,5 @@
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
4
 
5
+ export * as FeedbackButton from './FeedbackButton.js';
5
6
  export * as PanelFeedback from './PanelFeedback.js';
@@ -124,7 +124,7 @@ export class SurveyLink extends HTMLElement {
124
124
  // eslint-disable-next-line rulesdir/ban_style_tags_in_lit_html
125
125
  const output = LitHtml.html`
126
126
  <button class="link ${linkState}" tabindex=${ariaDisabled ? '-1' : '0'} .disabled=${ariaDisabled} aria-disabled=${ariaDisabled} @click=${this.sendSurvey}>
127
- <${IconButton.Icon.Icon.litTagName} class="link-icon" .data=${{iconName: 'feedback_thin_16x16_icon', color: 'var(--color-link)', width: 'var(--issue-link-icon-size, 16px)', height: 'var(--issue-link-icon-size, 16px)'} as IconButton.Icon.IconData}></${IconButton.Icon.Icon.litTagName}><!--
127
+ <${IconButton.Icon.Icon.litTagName} class="link-icon" .data=${{iconName: 'feedback_button_icon', color: 'var(--color-link)', width: 'var(--issue-link-icon-size, 16px)', height: 'var(--issue-link-icon-size, 16px)'} as IconButton.Icon.IconData}></${IconButton.Icon.Icon.litTagName}><!--
128
128
  -->${linkText}
129
129
  </button>
130
130
  `;
@@ -8,7 +8,8 @@ import * as LitHtml from '../../lit-html/lit-html.js';
8
8
  import * as CodeHighlighter from '../code_highlighter/code_highlighter.js';
9
9
  import * as ComponentHelpers from '../helpers/helpers.js';
10
10
 
11
- import {baseConfiguration, dynamicSetting} from './config.js';
11
+ import {baseConfiguration, dynamicSetting, DynamicSetting} from './config.js';
12
+ import {toLineColumn, toOffset} from './position.js';
12
13
 
13
14
  declare global {
14
15
  interface HTMLElementTagNameMap {
@@ -21,6 +22,7 @@ export class TextEditor extends HTMLElement {
21
22
 
22
23
  private readonly shadow = this.attachShadow({mode: 'open'});
23
24
  private activeEditor: CodeMirror.EditorView|undefined = undefined;
25
+ private dynamicSettings: readonly DynamicSetting<unknown>[] = DynamicSetting.none;
24
26
  private activeSettingListeners: [Common.Settings.Setting<unknown>, (event: {data: unknown}) => void][] = [];
25
27
  private pendingState: CodeMirror.EditorState|undefined;
26
28
 
@@ -32,10 +34,17 @@ export class TextEditor extends HTMLElement {
32
34
 
33
35
  private createEditor(): CodeMirror.EditorView {
34
36
  this.activeEditor = new CodeMirror.EditorView({
35
- state: this.updateDynamicSettings(this.state),
37
+ state: this.state,
36
38
  parent: this.shadow,
37
39
  root: this.shadow,
40
+ dispatch: (tr: CodeMirror.Transaction): void => {
41
+ this.editor.update([tr]);
42
+ if (tr.reconfigured) {
43
+ this.ensureSettingListeners();
44
+ }
45
+ },
38
46
  });
47
+ this.ensureSettingListeners();
39
48
  return this.activeEditor;
40
49
  }
41
50
 
@@ -43,6 +52,10 @@ export class TextEditor extends HTMLElement {
43
52
  return this.activeEditor || this.createEditor();
44
53
  }
45
54
 
55
+ dispatch(spec: CodeMirror.TransactionSpec): void {
56
+ return this.editor.dispatch(spec);
57
+ }
58
+
46
59
  get state(): CodeMirror.EditorState {
47
60
  if (this.activeEditor) {
48
61
  return this.activeEditor.state;
@@ -65,7 +78,6 @@ export class TextEditor extends HTMLElement {
65
78
  if (!this.activeEditor) {
66
79
  this.createEditor();
67
80
  }
68
- this.registerSettingHandlers();
69
81
  }
70
82
 
71
83
  disconnectedCallback(): void {
@@ -73,63 +85,94 @@ export class TextEditor extends HTMLElement {
73
85
  this.pendingState = this.activeEditor.state;
74
86
  this.activeEditor.destroy();
75
87
  this.activeEditor = undefined;
88
+ this.ensureSettingListeners();
76
89
  }
77
- for (const [setting, listener] of this.activeSettingListeners) {
78
- setting.removeChangeListener(listener);
79
- }
80
- this.activeSettingListeners = [];
81
90
  }
82
91
 
83
- private updateDynamicSettings(state: CodeMirror.EditorState): CodeMirror.EditorState {
84
- const settings = Common.Settings.Settings.instance();
85
- const changes = [];
86
- for (const opt of state.facet(dynamicSetting)) {
87
- const mustUpdate = opt.sync(state, settings.moduleSetting(opt.settingName).get());
88
- if (mustUpdate) {
89
- changes.push(mustUpdate);
90
- }
92
+ focus(): void {
93
+ if (this.activeEditor) {
94
+ this.activeEditor.focus();
91
95
  }
92
- return changes.length ? state.update({effects: changes}).state : state;
93
96
  }
94
97
 
95
- private registerSettingHandlers(): void {
98
+ private ensureSettingListeners(): void {
99
+ const dynamicSettings = this.activeEditor ? this.activeEditor.state.facet(dynamicSetting) : DynamicSetting.none;
100
+ if (dynamicSettings === this.dynamicSettings) {
101
+ return;
102
+ }
103
+ this.dynamicSettings = dynamicSettings;
104
+
105
+ for (const [setting, listener] of this.activeSettingListeners) {
106
+ setting.removeChangeListener(listener);
107
+ }
108
+ this.activeSettingListeners = [];
109
+
96
110
  const settings = Common.Settings.Settings.instance();
97
- for (const opt of this.state.facet(dynamicSetting)) {
111
+ for (const dynamicSetting of dynamicSettings) {
98
112
  const handler = ({data}: {data: unknown}): void => {
99
- const change = opt.sync(this.state, data);
113
+ const change = dynamicSetting.sync(this.state, data);
100
114
  if (change && this.activeEditor) {
101
115
  this.activeEditor.dispatch({effects: change});
102
116
  }
103
117
  };
104
- const setting = settings.moduleSetting(opt.settingName);
118
+ const setting = settings.moduleSetting(dynamicSetting.settingName);
105
119
  setting.addChangeListener(handler);
106
120
  this.activeSettingListeners.push([setting, handler]);
107
121
  }
108
122
  }
109
123
 
110
- revealPosition(position: number): void {
124
+ revealPosition(selection: CodeMirror.EditorSelection, highlight: boolean = true): void {
111
125
  const view = this.activeEditor;
112
126
  if (!view) {
113
127
  return;
114
128
  }
115
129
 
116
- const line = view.state.doc.lineAt(position);
130
+ const line = view.state.doc.lineAt(selection.main.head);
131
+ const effects: CodeMirror.StateEffect<unknown>[] = [];
132
+ if (highlight) {
133
+ effects.push(
134
+ view.state.field(highlightState, false) ?
135
+ setHighlightLine.of(line.from) :
136
+ CodeMirror.StateEffect.appendConfig.of(highlightState.init(() => highlightDeco(line.from))));
137
+ }
138
+ const editorRect = view.scrollDOM.getBoundingClientRect();
139
+ const targetPos = view.coordsAtPos(selection.main.head);
140
+ if (!targetPos || targetPos.top < editorRect.top || targetPos.bottom > editorRect.bottom) {
141
+ effects.push(CodeMirror.EditorView.centerOn.of(selection.main));
142
+ }
143
+
117
144
  view.dispatch({
118
- selection: CodeMirror.EditorSelection.cursor(position),
119
- scrollIntoView: true,
120
- effects:
121
- [view.state.field(highlightState, false) ?
122
- setHighlightLine.of(line.from) :
123
- CodeMirror.StateEffect.appendConfig.of(highlightState.init(() => highlightDeco(line.from)))],
145
+ selection,
146
+ effects,
147
+ userEvent: 'select.reveal',
124
148
  });
125
- const {id} = view.state.field(highlightState);
126
- // Reset the highlight state if, after 2 seconds (the animation
127
- // duration) it is still showing this highlight.
128
- setTimeout(() => {
129
- if (view.state.field(highlightState).id === id) {
130
- view.dispatch({effects: setHighlightLine.of(null)});
131
- }
132
- }, 2000);
149
+ if (highlight) {
150
+ const {id} = view.state.field(highlightState);
151
+ // Reset the highlight state if, after 2 seconds (the animation
152
+ // duration) it is still showing this highlight.
153
+ setTimeout(() => {
154
+ if (view.state.field(highlightState).id === id) {
155
+ view.dispatch({effects: setHighlightLine.of(null)});
156
+ }
157
+ }, 2000);
158
+ }
159
+ }
160
+
161
+ createSelection(head: {lineNumber: number, columnNumber: number}, anchor?: {
162
+ lineNumber: number,
163
+ columnNumber: number,
164
+ }): CodeMirror.EditorSelection {
165
+ const {doc} = this.state;
166
+ const headPos = toOffset(doc, head);
167
+ return CodeMirror.EditorSelection.single(anchor ? toOffset(doc, anchor) : headPos, headPos);
168
+ }
169
+
170
+ toLineColumn(pos: number): {lineNumber: number, columnNumber: number} {
171
+ return toLineColumn(this.state.doc, pos);
172
+ }
173
+
174
+ toOffset(pos: {lineNumber: number, columnNumber: number}): number {
175
+ return toOffset(this.state.doc, pos);
133
176
  }
134
177
  }
135
178