devtools-tracing 1.1.1 → 1.2.0

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 (528) hide show
  1. package/.claude/settings.local.json +14 -0
  2. package/dist/index.d.ts +4 -0
  3. package/dist/index.js +28854 -0
  4. package/package.json +11 -8
  5. package/generate.ts +0 -649
  6. package/index.ts +0 -17
  7. package/lib/extension-api/ExtensionAPI.d.ts +0 -357
  8. package/lib/front_end/core/common/App.ts +0 -7
  9. package/lib/front_end/core/common/AppProvider.ts +0 -32
  10. package/lib/front_end/core/common/Base64.ts +0 -47
  11. package/lib/front_end/core/common/CharacterIdMap.ts +0 -30
  12. package/lib/front_end/core/common/Color.ts +0 -2506
  13. package/lib/front_end/core/common/ColorConverter.ts +0 -402
  14. package/lib/front_end/core/common/ColorUtils.ts +0 -252
  15. package/lib/front_end/core/common/Console.ts +0 -114
  16. package/lib/front_end/core/common/Debouncer.ts +0 -15
  17. package/lib/front_end/core/common/EventTarget.ts +0 -52
  18. package/lib/front_end/core/common/Gzip.ts +0 -74
  19. package/lib/front_end/core/common/JavaScriptMetaData.ts +0 -29
  20. package/lib/front_end/core/common/Lazy.ts +0 -31
  21. package/lib/front_end/core/common/Linkifier.ts +0 -55
  22. package/lib/front_end/core/common/MapWithDefault.ts +0 -26
  23. package/lib/front_end/core/common/Mutex.ts +0 -55
  24. package/lib/front_end/core/common/Object.ts +0 -145
  25. package/lib/front_end/core/common/ParsedURL.ts +0 -554
  26. package/lib/front_end/core/common/Progress.ts +0 -180
  27. package/lib/front_end/core/common/QueryParamHandler.ts +0 -7
  28. package/lib/front_end/core/common/ResolverBase.ts +0 -85
  29. package/lib/front_end/core/common/ResourceType.ts +0 -588
  30. package/lib/front_end/core/common/ReturnToPanel.ts +0 -17
  31. package/lib/front_end/core/common/Revealer.ts +0 -192
  32. package/lib/front_end/core/common/Runnable.ts +0 -41
  33. package/lib/front_end/core/common/SegmentedRange.ts +0 -87
  34. package/lib/front_end/core/common/SettingRegistration.ts +0 -339
  35. package/lib/front_end/core/common/Settings.ts +0 -1497
  36. package/lib/front_end/core/common/SimpleHistoryManager.ts +0 -124
  37. package/lib/front_end/core/common/StringOutputStream.ts +0 -26
  38. package/lib/front_end/core/common/TextDictionary.ts +0 -48
  39. package/lib/front_end/core/common/Throttler.ts +0 -99
  40. package/lib/front_end/core/common/Trie.ts +0 -152
  41. package/lib/front_end/core/common/Worker.ts +0 -60
  42. package/lib/front_end/core/common/common.ts +0 -81
  43. package/lib/front_end/core/host/AidaClient.ts +0 -733
  44. package/lib/front_end/core/host/GdpClient.ts +0 -316
  45. package/lib/front_end/core/host/InspectorFrontendHost.ts +0 -648
  46. package/lib/front_end/core/host/InspectorFrontendHostAPI.ts +0 -551
  47. package/lib/front_end/core/host/Platform.ts +0 -76
  48. package/lib/front_end/core/host/ResourceLoader.ts +0 -282
  49. package/lib/front_end/core/host/UserMetrics.ts +0 -1230
  50. package/lib/front_end/core/host/host.ts +0 -23
  51. package/lib/front_end/core/i18n/ByteUtilities.ts +0 -82
  52. package/lib/front_end/core/i18n/DevToolsLocale.ts +0 -87
  53. package/lib/front_end/core/i18n/NumberFormatter.ts +0 -82
  54. package/lib/front_end/core/i18n/i18n.ts +0 -17
  55. package/lib/front_end/core/i18n/i18nImpl.ts +0 -204
  56. package/lib/front_end/core/i18n/i18nTypes.ts +0 -10
  57. package/lib/front_end/core/i18n/locales.js +0 -14
  58. package/lib/front_end/core/i18n/time-utilities.ts +0 -174
  59. package/lib/front_end/core/platform/ArrayUtilities.ts +0 -271
  60. package/lib/front_end/core/platform/Brand.ts +0 -23
  61. package/lib/front_end/core/platform/Constructor.ts +0 -10
  62. package/lib/front_end/core/platform/DOMUtilities.ts +0 -138
  63. package/lib/front_end/core/platform/DateUtilities.ts +0 -15
  64. package/lib/front_end/core/platform/DevToolsPath.ts +0 -53
  65. package/lib/front_end/core/platform/KeyboardUtilities.ts +0 -38
  66. package/lib/front_end/core/platform/MapUtilities.ts +0 -95
  67. package/lib/front_end/core/platform/MimeType.ts +0 -175
  68. package/lib/front_end/core/platform/NumberUtilities.ts +0 -80
  69. package/lib/front_end/core/platform/StringUtilities.ts +0 -588
  70. package/lib/front_end/core/platform/Timing.ts +0 -17
  71. package/lib/front_end/core/platform/TypedArrayUtilities.ts +0 -189
  72. package/lib/front_end/core/platform/TypescriptUtilities.ts +0 -86
  73. package/lib/front_end/core/platform/UIString.ts +0 -39
  74. package/lib/front_end/core/platform/UserVisibleError.ts +0 -28
  75. package/lib/front_end/core/platform/platform.ts +0 -45
  76. package/lib/front_end/core/protocol_client/ConnectionTransport.ts +0 -26
  77. package/lib/front_end/core/protocol_client/InspectorBackend.ts +0 -1050
  78. package/lib/front_end/core/protocol_client/NodeURL.ts +0 -42
  79. package/lib/front_end/core/protocol_client/protocol_client.ts +0 -13
  80. package/lib/front_end/core/root/Runtime.ts +0 -609
  81. package/lib/front_end/core/root/root.ts +0 -6
  82. package/lib/front_end/core/sdk/AccessibilityModel.ts +0 -353
  83. package/lib/front_end/core/sdk/AnimationModel.ts +0 -1041
  84. package/lib/front_end/core/sdk/AutofillModel.ts +0 -184
  85. package/lib/front_end/core/sdk/CPUProfilerModel.ts +0 -148
  86. package/lib/front_end/core/sdk/CPUThrottlingManager.ts +0 -282
  87. package/lib/front_end/core/sdk/CSSContainerQuery.ts +0 -139
  88. package/lib/front_end/core/sdk/CSSFontFace.ts +0 -40
  89. package/lib/front_end/core/sdk/CSSLayer.ts +0 -30
  90. package/lib/front_end/core/sdk/CSSMatchedStyles.ts +0 -1646
  91. package/lib/front_end/core/sdk/CSSMedia.ts +0 -121
  92. package/lib/front_end/core/sdk/CSSMetadata.ts +0 -1647
  93. package/lib/front_end/core/sdk/CSSModel.ts +0 -1128
  94. package/lib/front_end/core/sdk/CSSProperty.ts +0 -384
  95. package/lib/front_end/core/sdk/CSSPropertyParser.ts +0 -681
  96. package/lib/front_end/core/sdk/CSSPropertyParserMatchers.ts +0 -1395
  97. package/lib/front_end/core/sdk/CSSQuery.ts +0 -72
  98. package/lib/front_end/core/sdk/CSSRule.ts +0 -465
  99. package/lib/front_end/core/sdk/CSSScope.ts +0 -30
  100. package/lib/front_end/core/sdk/CSSStartingStyle.ts +0 -29
  101. package/lib/front_end/core/sdk/CSSStyleDeclaration.ts +0 -313
  102. package/lib/front_end/core/sdk/CSSStyleSheetHeader.ts +0 -196
  103. package/lib/front_end/core/sdk/CSSSupports.ts +0 -33
  104. package/lib/front_end/core/sdk/CategorizedBreakpoint.ts +0 -64
  105. package/lib/front_end/core/sdk/ChildTargetManager.ts +0 -314
  106. package/lib/front_end/core/sdk/CompilerSourceMappingContentProvider.ts +0 -62
  107. package/lib/front_end/core/sdk/Connections.ts +0 -293
  108. package/lib/front_end/core/sdk/ConsoleModel.ts +0 -808
  109. package/lib/front_end/core/sdk/ConsoleModelTypes.ts +0 -15
  110. package/lib/front_end/core/sdk/Cookie.ts +0 -319
  111. package/lib/front_end/core/sdk/CookieModel.ts +0 -239
  112. package/lib/front_end/core/sdk/CookieParser.ts +0 -185
  113. package/lib/front_end/core/sdk/DOMDebuggerModel.ts +0 -787
  114. package/lib/front_end/core/sdk/DOMModel.ts +0 -1961
  115. package/lib/front_end/core/sdk/DebuggerModel.ts +0 -1605
  116. package/lib/front_end/core/sdk/EmulationModel.ts +0 -648
  117. package/lib/front_end/core/sdk/EnhancedTracesParser.ts +0 -515
  118. package/lib/front_end/core/sdk/EventBreakpointsModel.ts +0 -183
  119. package/lib/front_end/core/sdk/FrameAssociated.ts +0 -11
  120. package/lib/front_end/core/sdk/FrameManager.ts +0 -259
  121. package/lib/front_end/core/sdk/HeapProfilerModel.ts +0 -225
  122. package/lib/front_end/core/sdk/HttpReasonPhraseStrings.ts +0 -77
  123. package/lib/front_end/core/sdk/IOModel.ts +0 -91
  124. package/lib/front_end/core/sdk/IsolateManager.ts +0 -257
  125. package/lib/front_end/core/sdk/IssuesModel.ts +0 -70
  126. package/lib/front_end/core/sdk/LayerTreeBase.ts +0 -169
  127. package/lib/front_end/core/sdk/LogModel.ts +0 -56
  128. package/lib/front_end/core/sdk/NetworkManager.ts +0 -2823
  129. package/lib/front_end/core/sdk/NetworkRequest.ts +0 -2253
  130. package/lib/front_end/core/sdk/OverlayColorGenerator.ts +0 -52
  131. package/lib/front_end/core/sdk/OverlayModel.ts +0 -1011
  132. package/lib/front_end/core/sdk/OverlayPersistentHighlighter.ts +0 -522
  133. package/lib/front_end/core/sdk/PageLoad.ts +0 -35
  134. package/lib/front_end/core/sdk/PageResourceLoader.ts +0 -435
  135. package/lib/front_end/core/sdk/PaintProfiler.ts +0 -110
  136. package/lib/front_end/core/sdk/PerformanceMetricsModel.ts +0 -84
  137. package/lib/front_end/core/sdk/PreloadingModel.ts +0 -863
  138. package/lib/front_end/core/sdk/RehydratingConnection.ts +0 -386
  139. package/lib/front_end/core/sdk/RehydratingObject.ts +0 -66
  140. package/lib/front_end/core/sdk/RemoteObject.ts +0 -1160
  141. package/lib/front_end/core/sdk/Resource.ts +0 -232
  142. package/lib/front_end/core/sdk/ResourceTreeModel.ts +0 -1160
  143. package/lib/front_end/core/sdk/RuntimeModel.ts +0 -732
  144. package/lib/front_end/core/sdk/SDKModel.ts +0 -65
  145. package/lib/front_end/core/sdk/ScopeTreeCache.ts +0 -45
  146. package/lib/front_end/core/sdk/ScreenCaptureModel.ts +0 -255
  147. package/lib/front_end/core/sdk/Script.ts +0 -534
  148. package/lib/front_end/core/sdk/SecurityOriginManager.ts +0 -76
  149. package/lib/front_end/core/sdk/ServerSentEvents.ts +0 -80
  150. package/lib/front_end/core/sdk/ServerSentEventsProtocol.ts +0 -122
  151. package/lib/front_end/core/sdk/ServerTiming.ts +0 -260
  152. package/lib/front_end/core/sdk/ServiceWorkerCacheModel.ts +0 -377
  153. package/lib/front_end/core/sdk/ServiceWorkerManager.ts +0 -605
  154. package/lib/front_end/core/sdk/SourceMap.ts +0 -867
  155. package/lib/front_end/core/sdk/SourceMapCache.ts +0 -54
  156. package/lib/front_end/core/sdk/SourceMapFunctionRanges.ts +0 -156
  157. package/lib/front_end/core/sdk/SourceMapManager.ts +0 -239
  158. package/lib/front_end/core/sdk/SourceMapScopeChainEntry.ts +0 -189
  159. package/lib/front_end/core/sdk/SourceMapScopesInfo.ts +0 -508
  160. package/lib/front_end/core/sdk/StorageBucketsModel.ts +0 -204
  161. package/lib/front_end/core/sdk/StorageKeyManager.ts +0 -98
  162. package/lib/front_end/core/sdk/Target.ts +0 -332
  163. package/lib/front_end/core/sdk/TargetManager.ts +0 -453
  164. package/lib/front_end/core/sdk/TraceObject.ts +0 -61
  165. package/lib/front_end/core/sdk/WebAuthnModel.ts +0 -104
  166. package/lib/front_end/core/sdk/sdk.ts +0 -174
  167. package/lib/front_end/entrypoints/formatter_worker/FormatterActions.ts +0 -59
  168. package/lib/front_end/generated/InspectorBackendCommands.js +0 -1617
  169. package/lib/front_end/generated/SupportedCSSProperties.js +0 -7512
  170. package/lib/front_end/generated/protocol-proxy-api.d.ts +0 -5022
  171. package/lib/front_end/generated/protocol.ts +0 -22014
  172. package/lib/front_end/models/bindings/CSSWorkspaceBinding.ts +0 -318
  173. package/lib/front_end/models/bindings/CompilerScriptMapping.ts +0 -536
  174. package/lib/front_end/models/bindings/ContentProviderBasedProject.ts +0 -187
  175. package/lib/front_end/models/bindings/DebuggerLanguagePlugins.ts +0 -1197
  176. package/lib/front_end/models/bindings/DebuggerWorkspaceBinding.ts +0 -733
  177. package/lib/front_end/models/bindings/DefaultScriptMapping.ts +0 -141
  178. package/lib/front_end/models/bindings/FileUtils.ts +0 -228
  179. package/lib/front_end/models/bindings/LiveLocation.ts +0 -81
  180. package/lib/front_end/models/bindings/NetworkProject.ts +0 -157
  181. package/lib/front_end/models/bindings/PresentationConsoleMessageHelper.ts +0 -312
  182. package/lib/front_end/models/bindings/ResourceMapping.ts +0 -539
  183. package/lib/front_end/models/bindings/ResourceScriptMapping.ts +0 -491
  184. package/lib/front_end/models/bindings/ResourceUtils.ts +0 -103
  185. package/lib/front_end/models/bindings/SASSSourceMapping.ts +0 -222
  186. package/lib/front_end/models/bindings/StylesSourceMapping.ts +0 -316
  187. package/lib/front_end/models/bindings/TempFile.ts +0 -67
  188. package/lib/front_end/models/bindings/bindings.ts +0 -39
  189. package/lib/front_end/models/cpu_profile/CPUProfileDataModel.ts +0 -571
  190. package/lib/front_end/models/cpu_profile/ProfileTreeModel.ts +0 -103
  191. package/lib/front_end/models/cpu_profile/cpu_profile.ts +0 -11
  192. package/lib/front_end/models/formatter/FormatterWorkerPool.ts +0 -219
  193. package/lib/front_end/models/formatter/ScriptFormatter.ts +0 -112
  194. package/lib/front_end/models/formatter/formatter.ts +0 -8
  195. package/lib/front_end/models/source_map_scopes/NamesResolver.ts +0 -765
  196. package/lib/front_end/models/source_map_scopes/ScopeChainModel.ts +0 -84
  197. package/lib/front_end/models/source_map_scopes/source_map_scopes.ts +0 -11
  198. package/lib/front_end/models/stack_trace/StackTrace.ts +0 -53
  199. package/lib/front_end/models/stack_trace/StackTraceImpl.ts +0 -85
  200. package/lib/front_end/models/stack_trace/StackTraceModel.ts +0 -128
  201. package/lib/front_end/models/stack_trace/Trie.ts +0 -163
  202. package/lib/front_end/models/stack_trace/stack_trace.ts +0 -9
  203. package/lib/front_end/models/stack_trace/stack_trace_impl.ts +0 -13
  204. package/lib/front_end/models/text_utils/CodeMirrorUtils.ts +0 -37
  205. package/lib/front_end/models/text_utils/ContentData.ts +0 -199
  206. package/lib/front_end/models/text_utils/ContentProvider.ts +0 -68
  207. package/lib/front_end/models/text_utils/StaticContentProvider.ts +0 -49
  208. package/lib/front_end/models/text_utils/StreamingContentData.ts +0 -108
  209. package/lib/front_end/models/text_utils/Text.ts +0 -90
  210. package/lib/front_end/models/text_utils/TextCursor.ts +0 -44
  211. package/lib/front_end/models/text_utils/TextRange.ts +0 -266
  212. package/lib/front_end/models/text_utils/TextUtils.ts +0 -401
  213. package/lib/front_end/models/text_utils/WasmDisassembly.ts +0 -87
  214. package/lib/front_end/models/text_utils/text_utils.ts +0 -27
  215. package/lib/front_end/models/trace/EntityMapper.ts +0 -141
  216. package/lib/front_end/models/trace/EventsSerializer.ts +0 -101
  217. package/lib/front_end/models/trace/LanternComputationData.ts +0 -438
  218. package/lib/front_end/models/trace/ModelImpl.ts +0 -236
  219. package/lib/front_end/models/trace/Name.ts +0 -136
  220. package/lib/front_end/models/trace/Processor.ts +0 -652
  221. package/lib/front_end/models/trace/Styles.ts +0 -1138
  222. package/lib/front_end/models/trace/extras/FilmStrip.ts +0 -78
  223. package/lib/front_end/models/trace/extras/MainThreadActivity.ts +0 -86
  224. package/lib/front_end/models/trace/extras/ScriptDuplication.ts +0 -236
  225. package/lib/front_end/models/trace/extras/StackTraceForEvent.ts +0 -203
  226. package/lib/front_end/models/trace/extras/ThirdParties.ts +0 -164
  227. package/lib/front_end/models/trace/extras/TraceFilter.ts +0 -62
  228. package/lib/front_end/models/trace/extras/TraceTree.ts +0 -701
  229. package/lib/front_end/models/trace/extras/extras.ts +0 -11
  230. package/lib/front_end/models/trace/handlers/AnimationFramesHandler.ts +0 -128
  231. package/lib/front_end/models/trace/handlers/AnimationHandler.ts +0 -36
  232. package/lib/front_end/models/trace/handlers/AsyncJSCallsHandler.ts +0 -239
  233. package/lib/front_end/models/trace/handlers/AuctionWorkletsHandler.ts +0 -183
  234. package/lib/front_end/models/trace/handlers/DOMStatsHandler.ts +0 -31
  235. package/lib/front_end/models/trace/handlers/ExtensionTraceDataHandler.ts +0 -306
  236. package/lib/front_end/models/trace/handlers/FlowsHandler.ts +0 -175
  237. package/lib/front_end/models/trace/handlers/FramesHandler.ts +0 -571
  238. package/lib/front_end/models/trace/handlers/GPUHandler.ts +0 -50
  239. package/lib/front_end/models/trace/handlers/ImagePaintingHandler.ts +0 -183
  240. package/lib/front_end/models/trace/handlers/InitiatorsHandler.ts +0 -193
  241. package/lib/front_end/models/trace/handlers/InvalidationsHandler.ts +0 -168
  242. package/lib/front_end/models/trace/handlers/LargestImagePaintHandler.ts +0 -109
  243. package/lib/front_end/models/trace/handlers/LargestTextPaintHandler.ts +0 -35
  244. package/lib/front_end/models/trace/handlers/LayerTreeHandler.ts +0 -123
  245. package/lib/front_end/models/trace/handlers/LayoutShiftsHandler.ts +0 -573
  246. package/lib/front_end/models/trace/handlers/MemoryHandler.ts +0 -31
  247. package/lib/front_end/models/trace/handlers/MetaHandler.ts +0 -525
  248. package/lib/front_end/models/trace/handlers/ModelHandlers.ts +0 -34
  249. package/lib/front_end/models/trace/handlers/NetworkRequestsHandler.ts +0 -672
  250. package/lib/front_end/models/trace/handlers/PageFramesHandler.ts +0 -52
  251. package/lib/front_end/models/trace/handlers/PageLoadMetricsHandler.ts +0 -460
  252. package/lib/front_end/models/trace/handlers/RendererHandler.ts +0 -428
  253. package/lib/front_end/models/trace/handlers/SamplesHandler.ts +0 -271
  254. package/lib/front_end/models/trace/handlers/ScreenshotsHandler.ts +0 -122
  255. package/lib/front_end/models/trace/handlers/ScriptsHandler.ts +0 -336
  256. package/lib/front_end/models/trace/handlers/SelectorStatsHandler.ts +0 -110
  257. package/lib/front_end/models/trace/handlers/Threads.ts +0 -139
  258. package/lib/front_end/models/trace/handlers/UserInteractionsHandler.ts +0 -400
  259. package/lib/front_end/models/trace/handlers/UserTimingsHandler.ts +0 -233
  260. package/lib/front_end/models/trace/handlers/WarningsHandler.ts +0 -162
  261. package/lib/front_end/models/trace/handlers/WorkersHandler.ts +0 -45
  262. package/lib/front_end/models/trace/handlers/handlers.ts +0 -8
  263. package/lib/front_end/models/trace/handlers/helpers.ts +0 -196
  264. package/lib/front_end/models/trace/handlers/types.ts +0 -75
  265. package/lib/front_end/models/trace/helpers/Extensions.ts +0 -54
  266. package/lib/front_end/models/trace/helpers/Network.ts +0 -129
  267. package/lib/front_end/models/trace/helpers/SamplesIntegrator.ts +0 -544
  268. package/lib/front_end/models/trace/helpers/SyntheticEvents.ts +0 -87
  269. package/lib/front_end/models/trace/helpers/Timing.ts +0 -248
  270. package/lib/front_end/models/trace/helpers/Trace.ts +0 -928
  271. package/lib/front_end/models/trace/helpers/TreeHelpers.ts +0 -320
  272. package/lib/front_end/models/trace/helpers/helpers.ts +0 -11
  273. package/lib/front_end/models/trace/insights/CLSCulprits.ts +0 -668
  274. package/lib/front_end/models/trace/insights/Cache.ts +0 -269
  275. package/lib/front_end/models/trace/insights/Common.ts +0 -453
  276. package/lib/front_end/models/trace/insights/DOMSize.ts +0 -223
  277. package/lib/front_end/models/trace/insights/DocumentLatency.ts +0 -319
  278. package/lib/front_end/models/trace/insights/DuplicatedJavaScript.ts +0 -126
  279. package/lib/front_end/models/trace/insights/FontDisplay.ts +0 -119
  280. package/lib/front_end/models/trace/insights/ForcedReflow.ts +0 -220
  281. package/lib/front_end/models/trace/insights/INPBreakdown.ts +0 -171
  282. package/lib/front_end/models/trace/insights/ImageDelivery.ts +0 -348
  283. package/lib/front_end/models/trace/insights/LCPBreakdown.ts +0 -268
  284. package/lib/front_end/models/trace/insights/LCPDiscovery.ts +0 -237
  285. package/lib/front_end/models/trace/insights/LegacyJavaScript.ts +0 -138
  286. package/lib/front_end/models/trace/insights/Models.ts +0 -22
  287. package/lib/front_end/models/trace/insights/ModernHTTP.ts +0 -257
  288. package/lib/front_end/models/trace/insights/NetworkDependencyTree.ts +0 -726
  289. package/lib/front_end/models/trace/insights/RenderBlocking.ts +0 -257
  290. package/lib/front_end/models/trace/insights/SlowCSSSelector.ts +0 -175
  291. package/lib/front_end/models/trace/insights/Statistics.ts +0 -101
  292. package/lib/front_end/models/trace/insights/ThirdParties.ts +0 -130
  293. package/lib/front_end/models/trace/insights/Viewport.ts +0 -138
  294. package/lib/front_end/models/trace/insights/insights.ts +0 -10
  295. package/lib/front_end/models/trace/insights/types.ts +0 -157
  296. package/lib/front_end/models/trace/lantern/core/LanternError.ts +0 -7
  297. package/lib/front_end/models/trace/lantern/core/NetworkAnalyzer.ts +0 -619
  298. package/lib/front_end/models/trace/lantern/core/core.ts +0 -6
  299. package/lib/front_end/models/trace/lantern/graph/BaseNode.ts +0 -345
  300. package/lib/front_end/models/trace/lantern/graph/CPUNode.ts +0 -80
  301. package/lib/front_end/models/trace/lantern/graph/NetworkNode.ts +0 -101
  302. package/lib/front_end/models/trace/lantern/graph/PageDependencyGraph.ts +0 -636
  303. package/lib/front_end/models/trace/lantern/graph/graph.ts +0 -8
  304. package/lib/front_end/models/trace/lantern/lantern.ts +0 -17
  305. package/lib/front_end/models/trace/lantern/metrics/FirstContentfulPaint.ts +0 -187
  306. package/lib/front_end/models/trace/lantern/metrics/Interactive.ts +0 -88
  307. package/lib/front_end/models/trace/lantern/metrics/LargestContentfulPaint.ts +0 -92
  308. package/lib/front_end/models/trace/lantern/metrics/MaxPotentialFID.ts +0 -72
  309. package/lib/front_end/models/trace/lantern/metrics/Metric.ts +0 -126
  310. package/lib/front_end/models/trace/lantern/metrics/SpeedIndex.ts +0 -126
  311. package/lib/front_end/models/trace/lantern/metrics/TBTUtils.ts +0 -82
  312. package/lib/front_end/models/trace/lantern/metrics/TotalBlockingTime.ts +0 -112
  313. package/lib/front_end/models/trace/lantern/metrics/metrics.ts +0 -12
  314. package/lib/front_end/models/trace/lantern/simulation/ConnectionPool.ts +0 -150
  315. package/lib/front_end/models/trace/lantern/simulation/Constants.ts +0 -46
  316. package/lib/front_end/models/trace/lantern/simulation/DNSCache.ts +0 -61
  317. package/lib/front_end/models/trace/lantern/simulation/SimulationTimingMap.ts +0 -196
  318. package/lib/front_end/models/trace/lantern/simulation/Simulator.ts +0 -556
  319. package/lib/front_end/models/trace/lantern/simulation/TCPConnection.ts +0 -192
  320. package/lib/front_end/models/trace/lantern/simulation/simulation.ts +0 -10
  321. package/lib/front_end/models/trace/lantern/types/Lantern.ts +0 -220
  322. package/lib/front_end/models/trace/lantern/types/types.ts +0 -5
  323. package/lib/front_end/models/trace/trace.ts +0 -33
  324. package/lib/front_end/models/trace/types/Configuration.ts +0 -110
  325. package/lib/front_end/models/trace/types/Extensions.ts +0 -136
  326. package/lib/front_end/models/trace/types/File.ts +0 -281
  327. package/lib/front_end/models/trace/types/Overlays.ts +0 -138
  328. package/lib/front_end/models/trace/types/Timing.ts +0 -30
  329. package/lib/front_end/models/trace/types/TraceEvents.ts +0 -3277
  330. package/lib/front_end/models/trace/types/types.ts +0 -10
  331. package/lib/front_end/models/trace_source_maps_resolver/SourceMapsResolver.ts +0 -240
  332. package/lib/front_end/models/trace_source_maps_resolver/trace_source_maps_resolver.ts +0 -5
  333. package/lib/front_end/models/workspace/FileManager.ts +0 -97
  334. package/lib/front_end/models/workspace/IgnoreListManager.ts +0 -628
  335. package/lib/front_end/models/workspace/SearchConfig.ts +0 -149
  336. package/lib/front_end/models/workspace/UISourceCode.ts +0 -698
  337. package/lib/front_end/models/workspace/WorkspaceImpl.ts +0 -339
  338. package/lib/front_end/models/workspace/workspace.ts +0 -17
  339. package/lib/front_end/panels/timeline/TimelineUIUtils.ts +0 -1029
  340. package/lib/front_end/panels/timeline/extensions/ExtensionUI.ts +0 -49
  341. package/lib/front_end/panels/timeline/extensions/extensions.ts +0 -9
  342. package/lib/front_end/third_party/codemirror.next/LICENSE +0 -21
  343. package/lib/front_end/third_party/codemirror.next/README.chromium +0 -30
  344. package/lib/front_end/third_party/codemirror.next/bundle-tsconfig.json +0 -24
  345. package/lib/front_end/third_party/codemirror.next/bundle.ts +0 -135
  346. package/lib/front_end/third_party/codemirror.next/chunk/angular.js +0 -2
  347. package/lib/front_end/third_party/codemirror.next/chunk/angular.js.map +0 -1
  348. package/lib/front_end/third_party/codemirror.next/chunk/codemirror.js +0 -2
  349. package/lib/front_end/third_party/codemirror.next/chunk/codemirror.js.map +0 -1
  350. package/lib/front_end/third_party/codemirror.next/chunk/cpp.js +0 -2
  351. package/lib/front_end/third_party/codemirror.next/chunk/cpp.js.map +0 -1
  352. package/lib/front_end/third_party/codemirror.next/chunk/css.js +0 -2
  353. package/lib/front_end/third_party/codemirror.next/chunk/html.js +0 -4
  354. package/lib/front_end/third_party/codemirror.next/chunk/java.js +0 -2
  355. package/lib/front_end/third_party/codemirror.next/chunk/java.js.map +0 -1
  356. package/lib/front_end/third_party/codemirror.next/chunk/javascript.js +0 -2
  357. package/lib/front_end/third_party/codemirror.next/chunk/legacy.js +0 -2
  358. package/lib/front_end/third_party/codemirror.next/chunk/legacy.js.map +0 -1
  359. package/lib/front_end/third_party/codemirror.next/chunk/less.js +0 -2
  360. package/lib/front_end/third_party/codemirror.next/chunk/less.js.map +0 -1
  361. package/lib/front_end/third_party/codemirror.next/chunk/markdown.js +0 -2
  362. package/lib/front_end/third_party/codemirror.next/chunk/markdown.js.map +0 -1
  363. package/lib/front_end/third_party/codemirror.next/chunk/php.js +0 -2
  364. package/lib/front_end/third_party/codemirror.next/chunk/php.js.map +0 -1
  365. package/lib/front_end/third_party/codemirror.next/chunk/python.js +0 -2
  366. package/lib/front_end/third_party/codemirror.next/chunk/python.js.map +0 -1
  367. package/lib/front_end/third_party/codemirror.next/chunk/sass.js +0 -2
  368. package/lib/front_end/third_party/codemirror.next/chunk/sass.js.map +0 -1
  369. package/lib/front_end/third_party/codemirror.next/chunk/svelte.js +0 -2
  370. package/lib/front_end/third_party/codemirror.next/chunk/svelte.js.map +0 -1
  371. package/lib/front_end/third_party/codemirror.next/chunk/vue.js +0 -2
  372. package/lib/front_end/third_party/codemirror.next/chunk/vue.js.map +0 -1
  373. package/lib/front_end/third_party/codemirror.next/chunk/wast.js +0 -2
  374. package/lib/front_end/third_party/codemirror.next/chunk/wast.js.map +0 -1
  375. package/lib/front_end/third_party/codemirror.next/chunk/xml.js +0 -2
  376. package/lib/front_end/third_party/codemirror.next/chunk/xml.js.map +0 -1
  377. package/lib/front_end/third_party/codemirror.next/codemirror.next.d.ts +0 -8057
  378. package/lib/front_end/third_party/codemirror.next/codemirror.next.js +0 -2
  379. package/lib/front_end/third_party/codemirror.next/codemirror.next.js.map +0 -1
  380. package/lib/front_end/third_party/codemirror.next/package.json +0 -43
  381. package/lib/front_end/third_party/codemirror.next/rebuild.sh +0 -6
  382. package/lib/front_end/third_party/codemirror.next/rollup.config.mjs +0 -49
  383. package/lib/front_end/third_party/i18n/LICENSE +0 -202
  384. package/lib/front_end/third_party/i18n/README.chromium +0 -15
  385. package/lib/front_end/third_party/i18n/i18n-impl.ts +0 -61
  386. package/lib/front_end/third_party/i18n/i18n.ts +0 -11
  387. package/lib/front_end/third_party/i18n/localized-string-set.ts +0 -129
  388. package/lib/front_end/third_party/intl-messageformat/LICENSE +0 -33
  389. package/lib/front_end/third_party/intl-messageformat/README.chromium +0 -24
  390. package/lib/front_end/third_party/intl-messageformat/intl-messageformat-tsconfig.json +0 -16
  391. package/lib/front_end/third_party/intl-messageformat/intl-messageformat.ts +0 -6
  392. package/lib/front_end/third_party/intl-messageformat/package/LICENSE.md +0 -33
  393. package/lib/front_end/third_party/intl-messageformat/package/README.md +0 -3
  394. package/lib/front_end/third_party/intl-messageformat/package/index.d.ts +0 -6
  395. package/lib/front_end/third_party/intl-messageformat/package/index.d.ts.map +0 -1
  396. package/lib/front_end/third_party/intl-messageformat/package/index.js +0 -13
  397. package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.esm.d.ts +0 -5
  398. package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.esm.js +0 -1710
  399. package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.iife.js +0 -1815
  400. package/lib/front_end/third_party/intl-messageformat/package/lib/index.d.ts +0 -6
  401. package/lib/front_end/third_party/intl-messageformat/package/lib/index.d.ts.map +0 -1
  402. package/lib/front_end/third_party/intl-messageformat/package/lib/index.js +0 -10
  403. package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.d.ts +0 -34
  404. package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.d.ts.map +0 -1
  405. package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.js +0 -229
  406. package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.d.ts +0 -28
  407. package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.d.ts.map +0 -1
  408. package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.js +0 -48
  409. package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.d.ts +0 -34
  410. package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.d.ts.map +0 -1
  411. package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.js +0 -179
  412. package/lib/front_end/third_party/intl-messageformat/package/package.json +0 -42
  413. package/lib/front_end/third_party/intl-messageformat/package/src/core.d.ts +0 -34
  414. package/lib/front_end/third_party/intl-messageformat/package/src/core.d.ts.map +0 -1
  415. package/lib/front_end/third_party/intl-messageformat/package/src/core.js +0 -230
  416. package/lib/front_end/third_party/intl-messageformat/package/src/error.d.ts +0 -28
  417. package/lib/front_end/third_party/intl-messageformat/package/src/error.d.ts.map +0 -1
  418. package/lib/front_end/third_party/intl-messageformat/package/src/error.js +0 -51
  419. package/lib/front_end/third_party/intl-messageformat/package/src/formatters.d.ts +0 -34
  420. package/lib/front_end/third_party/intl-messageformat/package/src/formatters.d.ts.map +0 -1
  421. package/lib/front_end/third_party/intl-messageformat/package/src/formatters.js +0 -182
  422. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/error.d.ts +0 -79
  423. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/index.d.ts +0 -15
  424. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/parser.d.ts +0 -153
  425. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/types.d.ts +0 -139
  426. package/lib/front_end/third_party/legacy-javascript/LICENSE +0 -202
  427. package/lib/front_end/third_party/legacy-javascript/README.chromium +0 -13
  428. package/lib/front_end/third_party/legacy-javascript/legacy-javascript-tsconfig.json +0 -8
  429. package/lib/front_end/third_party/legacy-javascript/legacy-javascript.ts +0 -3
  430. package/lib/front_end/third_party/legacy-javascript/lib/legacy-javascript.d.ts +0 -18
  431. package/lib/front_end/third_party/legacy-javascript/lib/legacy-javascript.js +0 -943
  432. package/lib/front_end/third_party/legacy-javascript/package.json +0 -8
  433. package/lib/front_end/third_party/legacy-javascript/rebuild.sh +0 -9
  434. package/lib/front_end/third_party/source-map-scopes-codec/LICENSE +0 -26
  435. package/lib/front_end/third_party/source-map-scopes-codec/README.chromium +0 -31
  436. package/lib/front_end/third_party/source-map-scopes-codec/package/CONTRIBUTING.md +0 -33
  437. package/lib/front_end/third_party/source-map-scopes-codec/package/LICENSE +0 -26
  438. package/lib/front_end/third_party/source-map-scopes-codec/package/README.md +0 -64
  439. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts +0 -62
  440. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts.map +0 -1
  441. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts +0 -37
  442. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts.map +0 -1
  443. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts +0 -29
  444. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts.map +0 -1
  445. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts +0 -8
  446. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts.map +0 -1
  447. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts +0 -6
  448. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts.map +0 -1
  449. package/lib/front_end/third_party/source-map-scopes-codec/package/deno.json +0 -21
  450. package/lib/front_end/third_party/source-map-scopes-codec/package/package.json +0 -14
  451. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js +0 -196
  452. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js.map +0 -1
  453. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.ts +0 -262
  454. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js +0 -235
  455. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js.map +0 -1
  456. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.ts +0 -359
  457. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.js +0 -39
  458. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.js.map +0 -1
  459. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.ts +0 -53
  460. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js +0 -438
  461. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js.map +0 -1
  462. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.ts +0 -539
  463. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js +0 -23
  464. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js.map +0 -1
  465. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.ts +0 -35
  466. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js +0 -257
  467. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js.map +0 -1
  468. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.ts +0 -348
  469. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.js +0 -8
  470. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.js.map +0 -1
  471. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.ts +0 -20
  472. package/lib/front_end/third_party/source-map-scopes-codec/package/src/scopes-tsconfig.json +0 -8
  473. package/lib/front_end/third_party/source-map-scopes-codec/package/src/scopes.d.ts +0 -184
  474. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.js +0 -9
  475. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.js.map +0 -1
  476. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.ts +0 -12
  477. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.js +0 -82
  478. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.js.map +0 -1
  479. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.ts +0 -99
  480. package/lib/front_end/third_party/source-map-scopes-codec/source-map-scopes-codec.ts +0 -5
  481. package/lib/front_end/third_party/third-party-web/LICENSE +0 -20
  482. package/lib/front_end/third_party/third-party-web/README.chromium +0 -13
  483. package/lib/front_end/third_party/third-party-web/lib/nostats-subset.d.ts +0 -2
  484. package/lib/front_end/third_party/third-party-web/lib/nostats-subset.js +0 -149
  485. package/lib/front_end/third_party/third-party-web/package/LICENSE +0 -20
  486. package/lib/front_end/third_party/third-party-web/package/README.md +0 -929
  487. package/lib/front_end/third_party/third-party-web/package/dist/entities-httparchive-nostats.json +0 -1
  488. package/lib/front_end/third_party/third-party-web/package/dist/entities-httparchive.json +0 -1
  489. package/lib/front_end/third_party/third-party-web/package/dist/entities-nostats.json +0 -1
  490. package/lib/front_end/third_party/third-party-web/package/dist/entities.json +0 -1
  491. package/lib/front_end/third_party/third-party-web/package/facades.md +0 -46
  492. package/lib/front_end/third_party/third-party-web/package/httparchive-nostats-subset.d.ts +0 -1
  493. package/lib/front_end/third_party/third-party-web/package/httparchive-nostats-subset.js +0 -1
  494. package/lib/front_end/third_party/third-party-web/package/httparchive-subset.d.ts +0 -1
  495. package/lib/front_end/third_party/third-party-web/package/httparchive-subset.js +0 -1
  496. package/lib/front_end/third_party/third-party-web/package/lib/__snapshots__/index.test.js.snap +0 -1006
  497. package/lib/front_end/third_party/third-party-web/package/lib/create-entity-finder-api.js +0 -139
  498. package/lib/front_end/third_party/third-party-web/package/lib/create-entity-finder-api.test.js +0 -44
  499. package/lib/front_end/third_party/third-party-web/package/lib/entities.test.js +0 -27
  500. package/lib/front_end/third_party/third-party-web/package/lib/index.d.ts +0 -34
  501. package/lib/front_end/third_party/third-party-web/package/lib/index.js +0 -3
  502. package/lib/front_end/third_party/third-party-web/package/lib/index.test.js +0 -246
  503. package/lib/front_end/third_party/third-party-web/package/lib/markdown/faqs.partial.md +0 -36
  504. package/lib/front_end/third_party/third-party-web/package/lib/markdown/goals.partial.md +0 -9
  505. package/lib/front_end/third_party/third-party-web/package/lib/markdown/methodology.partial.md +0 -5
  506. package/lib/front_end/third_party/third-party-web/package/lib/markdown/template.md +0 -151
  507. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-02-01.md +0 -1
  508. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-03-01.md +0 -1
  509. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-05-06.md +0 -1
  510. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-05-13.md +0 -14
  511. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2021-01-01.md +0 -1
  512. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2024-07-01.md +0 -3
  513. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive-nostats.d.ts +0 -1
  514. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive-nostats.js +0 -3
  515. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive.d.ts +0 -1
  516. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive.js +0 -3
  517. package/lib/front_end/third_party/third-party-web/package/lib/subsets/nostats.d.ts +0 -1
  518. package/lib/front_end/third_party/third-party-web/package/lib/subsets/nostats.js +0 -3
  519. package/lib/front_end/third_party/third-party-web/package/nostats-subset.d.ts +0 -1
  520. package/lib/front_end/third_party/third-party-web/package/nostats-subset.js +0 -1
  521. package/lib/front_end/third_party/third-party-web/package/package.json +0 -46
  522. package/lib/front_end/third_party/third-party-web/package.json +0 -8
  523. package/lib/front_end/third_party/third-party-web/rebuild.sh +0 -13
  524. package/lib/front_end/third_party/third-party-web/third-party-web-tsconfig.json +0 -8
  525. package/lib/front_end/third_party/third-party-web/third-party-web.ts +0 -3
  526. package/lib/front_end/ui/legacy/theme_support/ThemeSupport.ts +0 -222
  527. package/lib/front_end/ui/legacy/theme_support/theme_support.ts +0 -5
  528. package/patches/chrome-devtools-frontend+1.0.1533544.patch +0 -1716
@@ -1,1395 +0,0 @@
1
- // Copyright 2023 The Chromium Authors
2
- // Use of this source code is governed by a BSD-style license that can be
3
- // found in the LICENSE file.
4
- /* eslint-disable @devtools/no-imperative-dom-api */
5
-
6
- import * as Common from '../../core/common/common.js';
7
- import type * as Platform from '../../core/platform/platform.js';
8
- import type * as CodeMirror from '../../third_party/codemirror.next/codemirror.next.js';
9
-
10
- import type {CSSMatchedStyles, CSSValueSource, CSSVariableValue} from './CSSMatchedStyles.js';
11
- import {
12
- CSSMetadata,
13
- cssMetadata,
14
- type CSSWideKeyword,
15
- CubicBezierKeywordValues,
16
- } from './CSSMetadata.js';
17
- import type {CSSProperty} from './CSSProperty.js';
18
- import {
19
- ASTUtils,
20
- type BottomUpTreeMatching,
21
- type Match,
22
- matchDeclaration,
23
- matcherBase,
24
- type SyntaxTree,
25
- tokenizeDeclaration
26
- } from './CSSPropertyParser.js';
27
- import type {CSSStyleDeclaration} from './CSSStyleDeclaration.js';
28
-
29
- export class BaseVariableMatch implements Match {
30
- constructor(
31
- readonly text: string,
32
- readonly node: CodeMirror.SyntaxNode,
33
- readonly name: string,
34
- readonly fallback: CodeMirror.SyntaxNode[]|undefined,
35
- readonly matching: BottomUpTreeMatching,
36
- readonly computedTextCallback: (match: BaseVariableMatch, matching: BottomUpTreeMatching) => string | null,
37
- ) {
38
- }
39
-
40
- computedText(): string|null {
41
- return this.computedTextCallback(this, this.matching);
42
- }
43
-
44
- fallbackValue(): string|null {
45
- // Fallback can be missing but it can be also be empty: var(--v,)
46
- if (!this.fallback) {
47
- return null;
48
- }
49
- if (this.fallback.length === 0) {
50
- return '';
51
- }
52
- if (this.matching.hasUnresolvedSubstitutionsRange(this.fallback[0], this.fallback[this.fallback.length - 1])) {
53
- return null;
54
- }
55
- return this.matching.getComputedTextRange(this.fallback[0], this.fallback[this.fallback.length - 1]);
56
- }
57
- }
58
-
59
- // This matcher provides matching for var() functions and basic computedText support. Computed text is resolved by a
60
- // callback. This matcher is intended to be used directly only in environments where CSSMatchedStyles is not available.
61
- // A more ergonomic version of this matcher exists in VariableMatcher, which uses CSSMatchedStyles to correctly resolve
62
- // variable references automatically.
63
- // clang-format off
64
- export class BaseVariableMatcher extends matcherBase(BaseVariableMatch) {
65
- // clang-format on
66
- readonly #computedTextCallback: (match: BaseVariableMatch, matching: BottomUpTreeMatching) => string | null;
67
- constructor(computedTextCallback: (match: BaseVariableMatch, matching: BottomUpTreeMatching) => string | null) {
68
- super();
69
- this.#computedTextCallback = computedTextCallback;
70
- }
71
-
72
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): BaseVariableMatch|null {
73
- const callee = node.getChild('Callee');
74
- if (node.name !== 'CallExpression' || !callee || (matching.ast.text(callee) !== 'var')) {
75
- return null;
76
- }
77
-
78
- const args = ASTUtils.callArgs(node).map(args => Array.from(ASTUtils.stripComments(args)));
79
- if (args.length < 1 || args[0].length !== 1) {
80
- return null;
81
- }
82
- const nameNode = args[0][0];
83
- const fallback = args.length === 2 ? args[1] : undefined;
84
-
85
- if (nameNode?.name !== 'VariableName') {
86
- return null;
87
- }
88
-
89
- const varName = matching.ast.text(nameNode);
90
- if (!varName.startsWith('--')) {
91
- return null;
92
- }
93
-
94
- return new BaseVariableMatch(
95
- matching.ast.text(node), node, varName, fallback, matching, this.#computedTextCallback);
96
- }
97
- }
98
-
99
- export class VariableMatch extends BaseVariableMatch {
100
- constructor(
101
- text: string,
102
- node: CodeMirror.SyntaxNode,
103
- name: string,
104
- fallback: CodeMirror.SyntaxNode[]|undefined,
105
- matching: BottomUpTreeMatching,
106
- readonly matchedStyles: CSSMatchedStyles,
107
- readonly style: CSSStyleDeclaration,
108
- ) {
109
- super(text, node, name, fallback, matching, () => this.resolveVariable()?.value ?? this.fallbackValue());
110
- }
111
-
112
- resolveVariable(): CSSVariableValue|null {
113
- return this.matchedStyles.computeCSSVariable(this.style, this.name);
114
- }
115
- }
116
-
117
- // clang-format off
118
- export class VariableMatcher extends matcherBase(VariableMatch) {
119
- // clang-format on
120
- constructor(readonly matchedStyles: CSSMatchedStyles, readonly style: CSSStyleDeclaration) {
121
- super();
122
- }
123
-
124
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): VariableMatch|null {
125
- const match = new BaseVariableMatcher(() => null).matches(node, matching);
126
- return match ?
127
- new VariableMatch(
128
- match.text, match.node, match.name, match.fallback, match.matching, this.matchedStyles, this.style) :
129
- null;
130
- }
131
- }
132
-
133
- export class AttributeMatch extends BaseVariableMatch {
134
- constructor(
135
- text: string,
136
- node: CodeMirror.SyntaxNode,
137
- name: string,
138
- fallback: CodeMirror.SyntaxNode[]|undefined,
139
- matching: BottomUpTreeMatching,
140
- readonly type: string|null,
141
- readonly isCSSTokens: boolean,
142
- readonly isValidType: boolean,
143
- readonly rawValue: string|null,
144
- readonly substitutionText: string|null,
145
- readonly matchedStyles: CSSMatchedStyles,
146
- readonly style: CSSStyleDeclaration,
147
- computedTextCallback: (match: AttributeMatch, matching: BottomUpTreeMatching) => string | null,
148
- ) {
149
- super(text, node, name, fallback, matching, (_, matching) => computedTextCallback(this, matching));
150
- }
151
-
152
- rawAttributeValue(): string|null {
153
- return this.rawValue;
154
- }
155
-
156
- cssType(): string {
157
- return this.type ?? RAW_STRING_TYPE;
158
- }
159
-
160
- resolveAttributeValue(): string|null {
161
- return this.matchedStyles.computeAttribute(
162
- this.style, this.name, {type: this.cssType(), isCSSTokens: this.isCSSTokens});
163
- }
164
- }
165
-
166
- let cssEvaluationElement: HTMLElement|null = null;
167
- function getCssEvaluationElement(): HTMLElement {
168
- const id = 'css-evaluation-element';
169
- if (!cssEvaluationElement) {
170
- cssEvaluationElement = document.getElementById(id);
171
- if (!cssEvaluationElement) {
172
- cssEvaluationElement = document.createElement('div');
173
- cssEvaluationElement.setAttribute('id', id);
174
- cssEvaluationElement.setAttribute('style', 'hidden: true; --evaluation: attr(data-custom-expr type(*))');
175
- document.body.appendChild(cssEvaluationElement);
176
- }
177
- }
178
- return cssEvaluationElement;
179
- }
180
-
181
- /**
182
- * These functions use an element in the frontend to evaluate CSS. The advantage
183
- * of this is that it is synchronous and doesn't require a CDP method. The
184
- * disadvantage is it lacks context that would allow substitutions such as
185
- * `var()` and `calc()` to be resolved correctly, and if the user is doing
186
- * remote debugging there is a possibility that the CSS behavior is different
187
- * between the two browser versions. We use it for type checking after
188
- * substitutions (but not for actual evaluation) and for applying units.
189
- **/
190
- export function localEvalCSS(value: string, type: string): string|null {
191
- const element = getCssEvaluationElement();
192
- element.setAttribute('data-value', value);
193
- element.setAttribute('data-custom-expr', `attr(data-value ${type})`);
194
- return element.computedStyleMap().get('--evaluation')?.toString() ?? null;
195
- }
196
-
197
- /**
198
- * It is important to establish whether a type is valid, because if it is not,
199
- * the current behavior of blink is to ignore the fallback and parse as a
200
- * raw string, returning '' if the attribute is not set.
201
- **/
202
- export function isValidCSSType(type: string): boolean {
203
- const element = getCssEvaluationElement();
204
- element.setAttribute('data-custom-expr', `attr(data-nonexistent ${type}, "good")`);
205
- return '"good"' === (element.computedStyleMap().get('--evaluation')?.toString() ?? null);
206
- }
207
-
208
- export function defaultValueForCSSType(type: string|null): string|null {
209
- const element = getCssEvaluationElement();
210
- element.setAttribute('data-custom-expr', `attr(data-nonexistent ${type ?? ''})`);
211
- return element.computedStyleMap().get('--evaluation')?.toString() ?? null;
212
- }
213
-
214
- export const RAW_STRING_TYPE = 'raw-string';
215
-
216
- // This matcher provides matching for attr() functions and basic computedText support. Computed text is resolved by a
217
- // callback.
218
- // clang-format off
219
- export class AttributeMatcher extends matcherBase(AttributeMatch) {
220
- // clang-format on
221
- constructor(
222
- private readonly matchedStyles: CSSMatchedStyles,
223
- private readonly style: CSSStyleDeclaration,
224
- private readonly computedTextCallback?: (match: AttributeMatch, matching: BottomUpTreeMatching) => string | null,
225
-
226
- ) {
227
- super();
228
- }
229
-
230
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): AttributeMatch|null {
231
- const callee = node.getChild('Callee');
232
- if (node.name !== 'CallExpression' || !callee || (matching.ast.text(callee) !== 'attr')) {
233
- return null;
234
- }
235
-
236
- const args = ASTUtils.callArgs(node).map(args => Array.from(ASTUtils.stripComments(args)));
237
- if (args.length < 1) {
238
- return null;
239
- }
240
- const nameNode = args[0][0];
241
-
242
- if (args[0].length < 1 || args[0].length > 2 || nameNode?.name !== 'ValueName') {
243
- return null;
244
- }
245
-
246
- const fallback = args.length === 2 ? args[1] : undefined;
247
- let type: string|null = null;
248
- let isCSSTokens = false;
249
- if (args[0].length === 2) {
250
- const typeNode = args[0][1] as CodeMirror.SyntaxNode;
251
- type = matching.ast.text(typeNode);
252
- if (typeNode.name === 'CallExpression') {
253
- if (matching.ast.text(typeNode.getChild('Callee')) !== 'type') {
254
- return null;
255
- }
256
- isCSSTokens = true;
257
- } else if (typeNode.name !== 'ValueName' && type !== '%') {
258
- return null;
259
- }
260
- }
261
-
262
- const isValidType = type === null || isValidCSSType(type);
263
- isCSSTokens = isCSSTokens && isValidType;
264
-
265
- const attrName = matching.ast.text(nameNode);
266
-
267
- const rawValue = this.matchedStyles.rawAttributeValueFromStyle(this.style, attrName);
268
- let substitutionText: string|null = null;
269
- if (rawValue !== null) {
270
- substitutionText = isCSSTokens ? rawValue : localEvalCSS(rawValue, type ?? RAW_STRING_TYPE);
271
- } else if (!fallback) {
272
- // In the case of unspecified type, there is a default value
273
- substitutionText = defaultValueForCSSType(type);
274
- }
275
-
276
- return new AttributeMatch(
277
- matching.ast.text(node), node, attrName, fallback, matching, type, isCSSTokens, isValidType, rawValue,
278
- substitutionText, this.matchedStyles, this.style, this.computedTextCallback ?? defaultComputeText);
279
-
280
- function defaultComputeText(match: AttributeMatch, _matching: BottomUpTreeMatching): string|null {
281
- // Don't fall back if the type is invalid.
282
- return match.resolveAttributeValue() ??
283
- (isValidType ? match.fallbackValue() : defaultValueForCSSType(match.type));
284
- }
285
- }
286
- }
287
-
288
- export class BinOpMatch implements Match {
289
- constructor(readonly text: string, readonly node: CodeMirror.SyntaxNode) {
290
- }
291
- }
292
-
293
- // clang-format off
294
- export class BinOpMatcher extends matcherBase(BinOpMatch) {
295
- // clang-format on
296
- override accepts(): boolean {
297
- return true;
298
- }
299
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): BinOpMatch|null {
300
- return node.name === 'BinaryExpression' ? new BinOpMatch(matching.ast.text(node), node) : null;
301
- }
302
- }
303
-
304
- export class TextMatch implements Match {
305
- computedText?: () => string;
306
- constructor(readonly text: string, readonly node: CodeMirror.SyntaxNode) {
307
- if (node.name === 'Comment') {
308
- this.computedText = () => '';
309
- }
310
- }
311
- render(): Node[] {
312
- const span = document.createElement('span');
313
- span.appendChild(document.createTextNode(this.text));
314
- return [span];
315
- }
316
- }
317
-
318
- // clang-format off
319
- export class TextMatcher extends matcherBase(TextMatch) {
320
- // clang-format on
321
- override accepts(): boolean {
322
- return true;
323
- }
324
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): TextMatch|null {
325
- if (!node.firstChild || node.name === 'NumberLiteral' /* may have a Unit child */) {
326
- // Leaf node, just emit text
327
- const text = matching.ast.text(node);
328
- if (text.length) {
329
- return new TextMatch(text, node);
330
- }
331
- }
332
- return null;
333
- }
334
- }
335
-
336
- export class AngleMatch implements Match {
337
- constructor(readonly text: string, readonly node: CodeMirror.SyntaxNode) {
338
- }
339
-
340
- computedText(): string {
341
- return this.text;
342
- }
343
- }
344
-
345
- // clang-format off
346
- export class AngleMatcher extends matcherBase(AngleMatch) {
347
- // clang-format on
348
- override accepts(propertyName: string): boolean {
349
- return cssMetadata().isAngleAwareProperty(propertyName);
350
- }
351
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): AngleMatch|null {
352
- if (node.name !== 'NumberLiteral') {
353
- return null;
354
- }
355
- const unit = node.getChild('Unit');
356
- // TODO(crbug/1138628) handle unitless 0
357
- if (!unit || !['deg', 'grad', 'rad', 'turn'].includes(matching.ast.text(unit))) {
358
- return null;
359
- }
360
-
361
- return new AngleMatch(matching.ast.text(node), node);
362
- }
363
- }
364
-
365
- function literalToNumber(node: CodeMirror.SyntaxNode, ast: SyntaxTree): number|null {
366
- if (node.type.name !== 'NumberLiteral') {
367
- return null;
368
- }
369
- const text = ast.text(node);
370
-
371
- return Number(text.substring(0, text.length - ast.text(node.getChild('Unit')).length));
372
- }
373
-
374
- export class ColorMixMatch implements Match {
375
- constructor(
376
- readonly text: string, readonly node: CodeMirror.SyntaxNode, readonly space: CodeMirror.SyntaxNode[],
377
- readonly color1: CodeMirror.SyntaxNode[], readonly color2: CodeMirror.SyntaxNode[]) {
378
- }
379
- }
380
-
381
- // clang-format off
382
- export class ColorMixMatcher extends matcherBase(ColorMixMatch) {
383
- // clang-format on
384
- override accepts(propertyName: string): boolean {
385
- return cssMetadata().isColorAwareProperty(propertyName);
386
- }
387
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): ColorMixMatch|null {
388
- if (node.name !== 'CallExpression' || matching.ast.text(node.getChild('Callee')) !== 'color-mix') {
389
- return null;
390
- }
391
-
392
- const computedValueTree = tokenizeDeclaration('--property', matching.getComputedText(node));
393
- if (!computedValueTree) {
394
- return null;
395
- }
396
-
397
- const value = ASTUtils.declValue(computedValueTree.tree);
398
- if (!value) {
399
- return null;
400
- }
401
- const computedValueArgs = ASTUtils.callArgs(value);
402
- if (computedValueArgs.length !== 3) {
403
- return null;
404
- }
405
-
406
- const [space, color1, color2] = computedValueArgs;
407
- // Verify that all arguments are there, and that the space starts with a literal `in`.
408
- if (space.length < 2 || computedValueTree.text(ASTUtils.stripComments(space).next().value) !== 'in' ||
409
- color1.length < 1 || color2.length < 1) {
410
- return null;
411
- }
412
-
413
- // Verify there's at most one percentage value for each color.
414
- const p1 =
415
- color1.filter(n => n.type.name === 'NumberLiteral' && computedValueTree.text(n.getChild('Unit')) === '%');
416
- const p2 =
417
- color2.filter(n => n.type.name === 'NumberLiteral' && computedValueTree.text(n.getChild('Unit')) === '%');
418
- if (p1.length > 1 || p2.length > 1) {
419
- return null;
420
- }
421
-
422
- // Verify that if both colors carry percentages, they aren't both zero (which is an invalid property value).
423
- if (p1[0] && p2[0] && (literalToNumber(p1[0], computedValueTree) ?? 0) === 0 &&
424
- (literalToNumber(p2[0], computedValueTree) ?? 0) === 0) {
425
- return null;
426
- }
427
-
428
- const args = ASTUtils.callArgs(node);
429
- if (args.length !== 3) {
430
- return null;
431
- }
432
- return new ColorMixMatch(matching.ast.text(node), node, args[0], args[1], args[2]);
433
- }
434
- }
435
-
436
- // clang-format off
437
- export class URLMatch implements Match {
438
- constructor(
439
- readonly url: Platform.DevToolsPath.UrlString, readonly text: string, readonly node: CodeMirror.SyntaxNode) {
440
- }
441
- }
442
-
443
- // clang-format off
444
- export class URLMatcher extends matcherBase(URLMatch) {
445
- // clang-format on
446
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): URLMatch|null {
447
- if (node.name !== 'CallLiteral') {
448
- return null;
449
- }
450
- const callee = node.getChild('CallTag');
451
- if (!callee || matching.ast.text(callee) !== 'url') {
452
- return null;
453
- }
454
- const [, lparenNode, urlNode, rparenNode] = ASTUtils.siblings(callee);
455
- if (matching.ast.text(lparenNode) !== '(' ||
456
- (urlNode.name !== 'ParenthesizedContent' && urlNode.name !== 'StringLiteral') ||
457
- matching.ast.text(rparenNode) !== ')') {
458
- return null;
459
- }
460
-
461
- const text = matching.ast.text(urlNode);
462
- const url = (urlNode.name === 'StringLiteral' ? text.substr(1, text.length - 2) : text.trim()) as
463
- Platform.DevToolsPath.UrlString;
464
- return new URLMatch(url, matching.ast.text(node), node);
465
- }
466
- }
467
-
468
- export class LinearGradientMatch implements Match {
469
- constructor(readonly text: string, readonly node: CodeMirror.SyntaxNode) {
470
- }
471
- }
472
-
473
- // clang-format off
474
- export class LinearGradientMatcher extends matcherBase(LinearGradientMatch) {
475
- // clang-format on
476
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): Match|null {
477
- const text = matching.ast.text(node);
478
- if (node.name === 'CallExpression' && matching.ast.text(node.getChild('Callee')) === 'linear-gradient') {
479
- return new LinearGradientMatch(text, node);
480
- }
481
- return null;
482
- }
483
- override accepts(propertyName: string): boolean {
484
- return ['background', 'background-image', '-webkit-mask-image'].includes(propertyName);
485
- }
486
- }
487
-
488
- interface RelativeColor {
489
- colorSpace: Common.Color.Format;
490
- baseColor: ColorMatch;
491
- }
492
-
493
- export class ColorMatch implements Match {
494
- computedText: (() => string | null)|undefined;
495
- constructor(
496
- readonly text: string, readonly node: CodeMirror.SyntaxNode,
497
- private readonly currentColorCallback?: () => string | null, readonly relativeColor?: RelativeColor) {
498
- this.computedText = currentColorCallback;
499
- }
500
- }
501
-
502
- // clang-format off
503
- export class ColorMatcher extends matcherBase(ColorMatch) {
504
- constructor(private readonly currentColorCallback?: () => string|null) {
505
- super();
506
- }
507
- // clang-format on
508
- override accepts(propertyName: string): boolean {
509
- return cssMetadata().isColorAwareProperty(propertyName);
510
- }
511
-
512
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): ColorMatch|null {
513
- const text = matching.ast.text(node);
514
- if (node.name === 'ColorLiteral') {
515
- return new ColorMatch(text, node);
516
- }
517
- if (node.name === 'ValueName') {
518
- if (Common.Color.Nicknames.has(text)) {
519
- return new ColorMatch(text, node);
520
- }
521
- if (text.toLowerCase() === 'currentcolor' && this.currentColorCallback) {
522
- const callback = this.currentColorCallback;
523
- return new ColorMatch(text, node, () => callback() ?? text);
524
- }
525
- }
526
- if (node.name === 'CallExpression') {
527
- const callee = node.getChild('Callee');
528
- const colorFunc = matching.ast.text(callee).toLowerCase();
529
- if (callee && colorFunc.match(/^(rgba?|hsla?|hwba?|lab|lch|oklab|oklch|color)$/)) {
530
- const args = ASTUtils.children(node.getChild('ArgList'));
531
- // args are the tokens for the parthesized expression following the function name, so in a well-formed case
532
- // should at least contain the open and closing parens.
533
- const colorText = args.length >= 2 ? matching.getComputedTextRange(args[0], args[args.length - 1]) : '';
534
- // colorText holds the fully substituted parenthesized expression, so colorFunc + colorText is the color
535
- // function call.
536
- const isRelativeColorSyntax = Boolean(
537
- colorText.match(/^[^)]*\(\W*from\W+/) && !matching.hasUnresolvedSubstitutions(node) &&
538
- CSS.supports('color', colorFunc + colorText));
539
- if (!isRelativeColorSyntax) {
540
- return new ColorMatch(text, node);
541
- }
542
-
543
- const tokenized = matchDeclaration('--color', '--colorFunc' + colorText, [new ColorMatcher()]);
544
- if (!tokenized) {
545
- return null;
546
- }
547
-
548
- const [colorArgs] = ASTUtils.callArgs(ASTUtils.declValue(tokenized.ast.tree));
549
- // getComputedText already removed comments and such, so there must be 5 or 6 args:
550
- // rgb(from red c0 c1 c2) or color(from yellow srgb c0 c1 c2)
551
- // If any of the C is a calc expression that is a single root node. If the value contains an alpha channel that
552
- // is parsed as a BinOp into c2.
553
- if (colorArgs.length !== (colorFunc === 'color' ? 6 : 5)) {
554
- return null;
555
- }
556
- const colorSpace = Common.Color.getFormat(colorFunc !== 'color' ? colorFunc : matching.ast.text(colorArgs[2]));
557
- if (!colorSpace) {
558
- return null;
559
- }
560
-
561
- const baseColor = tokenized.getMatch(colorArgs[1]);
562
- if (tokenized.ast.text(colorArgs[0]) !== 'from' || !(baseColor instanceof ColorMatch)) {
563
- return null;
564
- }
565
-
566
- return new ColorMatch(text, node, undefined, {colorSpace, baseColor});
567
- }
568
- }
569
- return null;
570
- }
571
- }
572
-
573
- function isRelativeColorChannelName(channel: string): channel is Common.Color.ColorChannel {
574
- const maybeChannel = channel as Common.Color.ColorChannel;
575
- switch (maybeChannel) {
576
- case Common.Color.ColorChannel.A:
577
- case Common.Color.ColorChannel.ALPHA:
578
- case Common.Color.ColorChannel.B:
579
- case Common.Color.ColorChannel.C:
580
- case Common.Color.ColorChannel.G:
581
- case Common.Color.ColorChannel.H:
582
- case Common.Color.ColorChannel.L:
583
- case Common.Color.ColorChannel.R:
584
- case Common.Color.ColorChannel.S:
585
- case Common.Color.ColorChannel.W:
586
- case Common.Color.ColorChannel.X:
587
- case Common.Color.ColorChannel.Y:
588
- case Common.Color.ColorChannel.Z:
589
- return true;
590
- }
591
- // This assignment catches missed values in the switch above.
592
- const catchFallback: never = maybeChannel; // eslint-disable-line @typescript-eslint/no-unused-vars
593
- return false;
594
- }
595
-
596
- export class RelativeColorChannelMatch implements Match {
597
- constructor(readonly text: Common.Color.ColorChannel, readonly node: CodeMirror.SyntaxNode) {
598
- }
599
-
600
- getColorChannelValue(relativeColor: RelativeColor): number|null {
601
- const color = Common.Color.parse(relativeColor.baseColor.text)?.as(relativeColor.colorSpace);
602
- if (color instanceof Common.Color.ColorFunction) {
603
- switch (this.text) {
604
- case Common.Color.ColorChannel.R:
605
- return color.isXYZ() ? null : color.p0;
606
- case Common.Color.ColorChannel.G:
607
- return color.isXYZ() ? null : color.p1;
608
- case Common.Color.ColorChannel.B:
609
- return color.isXYZ() ? null : color.p2;
610
- case Common.Color.ColorChannel.X:
611
- return color.isXYZ() ? color.p0 : null;
612
- case Common.Color.ColorChannel.Y:
613
- return color.isXYZ() ? color.p1 : null;
614
- case Common.Color.ColorChannel.Z:
615
- return color.isXYZ() ? color.p2 : null;
616
- case Common.Color.ColorChannel.ALPHA:
617
- return color.alpha;
618
- }
619
- } else if (color instanceof Common.Color.Legacy) {
620
- switch (this.text) {
621
- case Common.Color.ColorChannel.R:
622
- return color.rgba()[0];
623
- case Common.Color.ColorChannel.G:
624
- return color.rgba()[1];
625
- case Common.Color.ColorChannel.B:
626
- return color.rgba()[2];
627
- case Common.Color.ColorChannel.ALPHA:
628
- return color.rgba()[3];
629
- }
630
- } else if (color && this.text in color) {
631
- return color[this.text as keyof typeof color] as number;
632
- }
633
- return null;
634
- }
635
-
636
- computedText(): string {
637
- return this.text;
638
- }
639
- }
640
-
641
- // clang-format off
642
- export class RelativeColorChannelMatcher extends matcherBase(RelativeColorChannelMatch) {
643
- // clang-format on
644
- override accepts(propertyName: string): boolean {
645
- return cssMetadata().isColorAwareProperty(propertyName);
646
- }
647
-
648
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): RelativeColorChannelMatch|null {
649
- const text = matching.ast.text(node);
650
- if (node.name === 'ValueName' && isRelativeColorChannelName(text)) {
651
- return new RelativeColorChannelMatch(text, node);
652
- }
653
- return null;
654
- }
655
- }
656
-
657
- export class LightDarkColorMatch implements Match {
658
- constructor(
659
- readonly text: string, readonly node: CodeMirror.SyntaxNode, readonly light: CodeMirror.SyntaxNode[],
660
- readonly dark: CodeMirror.SyntaxNode[], readonly style: CSSStyleDeclaration) {
661
- }
662
- }
663
-
664
- // clang-format off
665
- export class LightDarkColorMatcher extends matcherBase(LightDarkColorMatch) {
666
- // clang-format on
667
- constructor(readonly style: CSSStyleDeclaration) {
668
- super();
669
- }
670
- override accepts(propertyName: string): boolean {
671
- return cssMetadata().isColorAwareProperty(propertyName);
672
- }
673
-
674
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): LightDarkColorMatch|null {
675
- if (node.name !== 'CallExpression' || matching.ast.text(node.getChild('Callee')) !== 'light-dark') {
676
- return null;
677
- }
678
- const args = ASTUtils.callArgs(node);
679
- if (args.length !== 2 || args[0].length === 0 || args[1].length === 0) {
680
- return null;
681
- }
682
- return new LightDarkColorMatch(matching.ast.text(node), node, args[0], args[1], this.style);
683
- }
684
- }
685
-
686
- export class AutoBaseMatch implements Match {
687
- constructor(
688
- readonly text: string, readonly node: CodeMirror.SyntaxNode, readonly auto: CodeMirror.SyntaxNode[],
689
- readonly base: CodeMirror.SyntaxNode[]) {
690
- }
691
- }
692
-
693
- // clang-format off
694
- export class AutoBaseMatcher extends matcherBase(AutoBaseMatch) {
695
- // clang-format on
696
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): AutoBaseMatch|null {
697
- if (node.name !== 'CallExpression' || matching.ast.text(node.getChild('Callee')) !== '-internal-auto-base') {
698
- return null;
699
- }
700
-
701
- const args = ASTUtils.callArgs(node);
702
- if (args.length !== 2 || args[0].length === 0 || args[1].length === 0) {
703
- return null;
704
- }
705
-
706
- return new AutoBaseMatch(matching.ast.text(node), node, args[0], args[1]);
707
- }
708
- }
709
-
710
- export const enum LinkableNameProperties {
711
- ANIMATION = 'animation',
712
- ANIMATION_NAME = 'animation-name',
713
- FONT_PALETTE = 'font-palette',
714
- POSITION_TRY_FALLBACKS = 'position-try-fallbacks',
715
- POSITION_TRY = 'position-try',
716
- }
717
-
718
- const enum AnimationLonghandPart {
719
- DIRECTION = 'direction',
720
- FILL_MODE = 'fill-mode',
721
- PLAY_STATE = 'play-state',
722
- ITERATION_COUNT = 'iteration-count',
723
- EASING_FUNCTION = 'easing-function',
724
- }
725
-
726
- export class LinkableNameMatch implements Match {
727
- constructor(
728
- readonly text: string, readonly node: CodeMirror.SyntaxNode, readonly propertyName: LinkableNameProperties) {
729
- }
730
- }
731
-
732
- // clang-format off
733
- export class LinkableNameMatcher extends matcherBase(LinkableNameMatch) {
734
- // clang-format on
735
- private static isLinkableNameProperty(propertyName: string): propertyName is LinkableNameProperties {
736
- const names: string[] = [
737
- LinkableNameProperties.ANIMATION,
738
- LinkableNameProperties.ANIMATION_NAME,
739
- LinkableNameProperties.FONT_PALETTE,
740
- LinkableNameProperties.POSITION_TRY_FALLBACKS,
741
- LinkableNameProperties.POSITION_TRY,
742
- ];
743
- return names.includes(propertyName);
744
- }
745
-
746
- static readonly identifierAnimationLonghandMap = new Map<string, AnimationLonghandPart>(
747
- Object.entries({
748
- normal: AnimationLonghandPart.DIRECTION,
749
- alternate: AnimationLonghandPart.DIRECTION,
750
- reverse: AnimationLonghandPart.DIRECTION,
751
- 'alternate-reverse': AnimationLonghandPart.DIRECTION,
752
- none: AnimationLonghandPart.FILL_MODE,
753
- forwards: AnimationLonghandPart.FILL_MODE,
754
- backwards: AnimationLonghandPart.FILL_MODE,
755
- both: AnimationLonghandPart.FILL_MODE,
756
- running: AnimationLonghandPart.PLAY_STATE,
757
- paused: AnimationLonghandPart.PLAY_STATE,
758
- infinite: AnimationLonghandPart.ITERATION_COUNT,
759
- linear: AnimationLonghandPart.EASING_FUNCTION,
760
- ease: AnimationLonghandPart.EASING_FUNCTION,
761
- 'ease-in': AnimationLonghandPart.EASING_FUNCTION,
762
- 'ease-out': AnimationLonghandPart.EASING_FUNCTION,
763
- 'ease-in-out': AnimationLonghandPart.EASING_FUNCTION,
764
- steps: AnimationLonghandPart.EASING_FUNCTION,
765
- 'step-start': AnimationLonghandPart.EASING_FUNCTION,
766
- 'step-end': AnimationLonghandPart.EASING_FUNCTION,
767
- }),
768
- );
769
-
770
- private matchAnimationNameInShorthand(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): LinkableNameMatch|
771
- null {
772
- // Order is important within each animation definition for distinguishing <keyframes-name> values from other keywords.
773
- // When parsing, keywords that are valid for properties other than animation-name
774
- // whose values were not found earlier in the shorthand must be accepted for those properties rather than for animation-name.
775
- // See the details in: https://w3c.github.io/csswg-drafts/css-animations/#animation.
776
- const text = matching.ast.text(node);
777
- // This is not a known identifier, so return it as `animation-name`.
778
- if (!LinkableNameMatcher.identifierAnimationLonghandMap.has(text)) {
779
- return new LinkableNameMatch(text, node, LinkableNameProperties.ANIMATION);
780
- }
781
- // There can be multiple `animation` declarations splitted by a comma.
782
- // So, we find the declaration nodes that are related to the node argument.
783
- const declarations = ASTUtils.split(ASTUtils.siblings(ASTUtils.declValue(matching.ast.tree)));
784
- const currentDeclarationNodes = declarations.find(
785
- declaration => declaration[0].from <= node.from && declaration[declaration.length - 1].to >= node.to);
786
- if (!currentDeclarationNodes) {
787
- return null;
788
- }
789
-
790
- // We reparse here until the node argument since a variable might be
791
- // providing a meaningful value such as a timing keyword,
792
- // that might change the meaning of the node.
793
- const computedText = matching.getComputedTextRange(currentDeclarationNodes[0], node);
794
- const tokenized = tokenizeDeclaration('--p', computedText);
795
- if (!tokenized) {
796
- return null;
797
- }
798
-
799
- const identifierCategory =
800
- LinkableNameMatcher.identifierAnimationLonghandMap.get(text); // The category of the node argument
801
- for (let itNode: typeof tokenized.tree|null = ASTUtils.declValue(tokenized.tree); itNode?.nextSibling;
802
- itNode = itNode.nextSibling) {
803
- // Run through all the nodes that come before node argument
804
- // and check whether a value in the same category is found.
805
- // if so, it means our identifier is an `animation-name` keyword.
806
- if (itNode.name === 'ValueName') {
807
- const categoryValue = LinkableNameMatcher.identifierAnimationLonghandMap.get(tokenized.text(itNode));
808
- if (categoryValue && categoryValue === identifierCategory) {
809
- return new LinkableNameMatch(text, node, LinkableNameProperties.ANIMATION);
810
- }
811
- }
812
- }
813
-
814
- return null;
815
- }
816
-
817
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): LinkableNameMatch|null {
818
- const {propertyName} = matching.ast;
819
- const text = matching.ast.text(node);
820
- const parentNode = node.parent;
821
- if (!parentNode) {
822
- return null;
823
- }
824
-
825
- if (!(propertyName && LinkableNameMatcher.isLinkableNameProperty(propertyName))) {
826
- return null;
827
- }
828
-
829
- const isParentADeclaration = parentNode.name === 'Declaration';
830
- const isInsideVarCall = parentNode.name === 'ArgList' && parentNode.prevSibling?.name === 'Callee' &&
831
- matching.ast.text(parentNode.prevSibling) === 'var';
832
- const isAParentDeclarationOrVarCall = isParentADeclaration || isInsideVarCall;
833
- // `position-try-fallbacks` and `position-try` only accept names with dashed ident.
834
- const shouldMatchOnlyVariableName = propertyName === LinkableNameProperties.POSITION_TRY ||
835
- propertyName === LinkableNameProperties.POSITION_TRY_FALLBACKS;
836
- // We only mark top level nodes or nodes that are inside `var()` expressions as linkable names.
837
- if (!propertyName || (node.name !== 'ValueName' && node.name !== 'VariableName') ||
838
- !isAParentDeclarationOrVarCall || (node.name === 'ValueName' && shouldMatchOnlyVariableName)) {
839
- return null;
840
- }
841
-
842
- if (propertyName === 'animation') {
843
- return this.matchAnimationNameInShorthand(node, matching);
844
- }
845
-
846
- // The assertion here is safe since this matcher only runs for
847
- // properties with names inside `LinkableNameProperties` (See the `accepts` function.)
848
- return new LinkableNameMatch(text, node, propertyName as LinkableNameProperties);
849
- }
850
- }
851
-
852
- export class BezierMatch implements Match {
853
- constructor(readonly text: string, readonly node: CodeMirror.SyntaxNode) {
854
- }
855
- }
856
-
857
- // clang-format off
858
- export class BezierMatcher extends matcherBase(BezierMatch) {
859
- // clang-format on
860
- override accepts(propertyName: string): boolean {
861
- return cssMetadata().isBezierAwareProperty(propertyName);
862
- }
863
-
864
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): Match|null {
865
- const text = matching.ast.text(node);
866
-
867
- const isCubicBezierKeyword = node.name === 'ValueName' && CubicBezierKeywordValues.has(text);
868
- const isCubicBezierOrLinearFunction = node.name === 'CallExpression' &&
869
- ['cubic-bezier', 'linear'].includes(matching.ast.text(node.getChild('Callee')));
870
-
871
- if (!isCubicBezierKeyword && !isCubicBezierOrLinearFunction) {
872
- return null;
873
- }
874
- return new BezierMatch(text, node);
875
- }
876
- }
877
-
878
- export class StringMatch implements Match {
879
- constructor(readonly text: string, readonly node: CodeMirror.SyntaxNode) {
880
- }
881
- }
882
-
883
- // clang-format off
884
- export class StringMatcher extends matcherBase(StringMatch) {
885
- // clang-format on
886
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): Match|null {
887
- return node.name === 'StringLiteral' ? new StringMatch(matching.ast.text(node), node) : null;
888
- }
889
- }
890
-
891
- export const enum ShadowType {
892
- BOX_SHADOW = 'boxShadow',
893
- TEXT_SHADOW = 'textShadow',
894
- }
895
- export class ShadowMatch implements Match {
896
- constructor(readonly text: string, readonly node: CodeMirror.SyntaxNode, readonly shadowType: ShadowType) {
897
- }
898
- }
899
-
900
- // clang-format off
901
- export class ShadowMatcher extends matcherBase(ShadowMatch) {
902
- // clang-format on
903
- override accepts(propertyName: string): boolean {
904
- return cssMetadata().isShadowProperty(propertyName);
905
- }
906
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): ShadowMatch|null {
907
- if (node.name !== 'Declaration') {
908
- return null;
909
- }
910
- const valueNodes = ASTUtils.siblings(ASTUtils.declValue(node));
911
- if (valueNodes.length === 0) {
912
- return null;
913
- }
914
- const valueText = matching.ast.textRange(valueNodes[0], valueNodes[valueNodes.length - 1]);
915
- return new ShadowMatch(
916
- valueText, node, matching.ast.propertyName === 'text-shadow' ? ShadowType.TEXT_SHADOW : ShadowType.BOX_SHADOW);
917
- }
918
- }
919
-
920
- export class FontMatch implements Match {
921
- constructor(readonly text: string, readonly node: CodeMirror.SyntaxNode) {
922
- }
923
- }
924
-
925
- // clang-format off
926
- export class FontMatcher extends matcherBase(FontMatch) {
927
- // clang-format on
928
- override accepts(propertyName: string): boolean {
929
- return cssMetadata().isFontAwareProperty(propertyName);
930
- }
931
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): Match|null {
932
- if (node.name !== 'Declaration') {
933
- return null;
934
- }
935
- const valueNodes = ASTUtils.siblings(ASTUtils.declValue(node));
936
- if (valueNodes.length === 0) {
937
- return null;
938
- }
939
- const validNodes = matching.ast.propertyName === 'font-family' ? ['ValueName', 'StringLiteral', 'Comment', ','] :
940
- ['Comment', 'ValueName', 'NumberLiteral'];
941
-
942
- if (valueNodes.some(node => !validNodes.includes(node.name))) {
943
- return null;
944
- }
945
- const valueText = matching.ast.textRange(valueNodes[0], valueNodes[valueNodes.length - 1]);
946
- return new FontMatch(valueText, node);
947
- }
948
- }
949
-
950
- export class LengthMatch implements Match {
951
- constructor(readonly text: string, readonly node: CodeMirror.SyntaxNode, readonly unit: string) {
952
- }
953
- }
954
-
955
- // clang-format off
956
- export class LengthMatcher extends matcherBase(LengthMatch) {
957
- // clang-format on
958
- static readonly LENGTH_UNITS = new Set([
959
- 'em', 'ex', 'ch', 'cap', 'ic', 'lh', 'rem', 'rex', 'rch', 'rlh', 'ric', 'rcap', 'pt', 'pc',
960
- 'in', 'cm', 'mm', 'Q', 'vw', 'vh', 'vi', 'vb', 'vmin', 'vmax', 'dvw', 'dvh', 'dvi', 'dvb',
961
- 'dvmin', 'dvmax', 'svw', 'svh', 'svi', 'svb', 'svmin', 'svmax', 'lvw', 'lvh', 'lvi', 'lvb', 'lvmin', 'lvmax',
962
- 'cqw', 'cqh', 'cqi', 'cqb', 'cqmin', 'cqmax', 'cqem', 'cqlh', 'cqex', 'cqch', '%'
963
- ]);
964
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): LengthMatch|null {
965
- if (node.name !== 'NumberLiteral') {
966
- return null;
967
- }
968
- const unit = matching.ast.text(node.getChild('Unit'));
969
- if (!LengthMatcher.LENGTH_UNITS.has(unit)) {
970
- return null;
971
- }
972
- const text = matching.ast.text(node);
973
- return new LengthMatch(text, node, unit);
974
- }
975
- }
976
-
977
- export const enum SelectFunction {
978
- MIN = 'min',
979
- MAX = 'max',
980
- CLAMP = 'clamp',
981
- }
982
- export const enum ArithmeticFunction {
983
- CALC = 'calc',
984
- SIBLING_COUNT = 'sibling-count',
985
- SIBLING_INDEX = 'sibling-index',
986
- }
987
- type MathFunction = SelectFunction|ArithmeticFunction;
988
-
989
- export class BaseFunctionMatch<T extends string> implements Match {
990
- constructor(
991
- readonly text: string, readonly node: CodeMirror.SyntaxNode, readonly func: T,
992
- readonly args: CodeMirror.SyntaxNode[][]) {
993
- }
994
- }
995
-
996
- export class MathFunctionMatch extends BaseFunctionMatch<MathFunction> {
997
- isArithmeticFunctionCall(): boolean {
998
- const func = this.func as ArithmeticFunction;
999
- switch (func) {
1000
- case ArithmeticFunction.CALC:
1001
- case ArithmeticFunction.SIBLING_COUNT:
1002
- case ArithmeticFunction.SIBLING_INDEX:
1003
- return true;
1004
- }
1005
- // This assignment catches missed values in the switch above.
1006
- const catchFallback: never = func; // eslint-disable-line @typescript-eslint/no-unused-vars
1007
- return false;
1008
- }
1009
- }
1010
-
1011
- // clang-format off
1012
- export class MathFunctionMatcher extends matcherBase(MathFunctionMatch) {
1013
- // clang-format on
1014
- private static getFunctionType(callee: string|null): MathFunction|null {
1015
- const maybeFunc = callee as MathFunction | null;
1016
- switch (maybeFunc) {
1017
- case null:
1018
- case SelectFunction.MIN:
1019
- case SelectFunction.MAX:
1020
- case SelectFunction.CLAMP:
1021
- case ArithmeticFunction.CALC:
1022
- case ArithmeticFunction.SIBLING_COUNT:
1023
- case ArithmeticFunction.SIBLING_INDEX:
1024
- return maybeFunc;
1025
- }
1026
- // This assignment catches missed values in the switch above.
1027
- const catchFallback: never = maybeFunc; // eslint-disable-line @typescript-eslint/no-unused-vars
1028
- return null;
1029
- }
1030
-
1031
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): MathFunctionMatch|null {
1032
- if (node.name !== 'CallExpression') {
1033
- return null;
1034
- }
1035
- const callee = MathFunctionMatcher.getFunctionType(matching.ast.text(node.getChild('Callee')));
1036
- if (!callee) {
1037
- return null;
1038
- }
1039
- const args = ASTUtils.callArgs(node);
1040
- if (args.some(arg => arg.length === 0 || matching.hasUnresolvedSubstitutionsRange(arg[0], arg[arg.length - 1]))) {
1041
- return null;
1042
- }
1043
- const text = matching.ast.text(node);
1044
- const match = new MathFunctionMatch(text, node, callee, args);
1045
- if (!match.isArithmeticFunctionCall() && args.length === 0) {
1046
- return null;
1047
- }
1048
- return match;
1049
- }
1050
- }
1051
-
1052
- export class CustomFunctionMatch extends BaseFunctionMatch<string> {}
1053
-
1054
- // clang-format off
1055
- export class CustomFunctionMatcher extends matcherBase(CustomFunctionMatch) {
1056
- // clang-format on
1057
-
1058
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): CustomFunctionMatch|null {
1059
- if (node.name !== 'CallExpression') {
1060
- return null;
1061
- }
1062
- const callee = matching.ast.text(node.getChild('VariableName'));
1063
- if (!callee?.startsWith('--')) {
1064
- return null;
1065
- }
1066
- const args = ASTUtils.callArgs(node);
1067
- if (args.some(arg => arg.length === 0 || matching.hasUnresolvedSubstitutionsRange(arg[0], arg[arg.length - 1]))) {
1068
- return null;
1069
- }
1070
- const text = matching.ast.text(node);
1071
- return new CustomFunctionMatch(text, node, callee, args);
1072
- }
1073
- }
1074
-
1075
- export class FlexGridMatch implements Match {
1076
- constructor(readonly text: string, readonly node: CodeMirror.SyntaxNode, readonly isFlex: boolean) {
1077
- }
1078
- }
1079
-
1080
- // clang-format off
1081
- export class FlexGridMatcher extends matcherBase(FlexGridMatch) {
1082
- // clang-format on
1083
- static readonly FLEX = ['flex', 'inline-flex', 'block flex', 'inline flex'];
1084
- static readonly GRID = ['grid', 'inline-grid', 'block grid', 'inline grid'];
1085
- override accepts(propertyName: string): boolean {
1086
- return propertyName === 'display';
1087
- }
1088
-
1089
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): FlexGridMatch|null {
1090
- if (node.name !== 'Declaration') {
1091
- return null;
1092
- }
1093
- const valueNodes = ASTUtils.siblings(ASTUtils.declValue(node));
1094
- if (valueNodes.length < 1) {
1095
- return null;
1096
- }
1097
- const values = valueNodes.filter(node => node.name !== 'Important')
1098
- .map(node => matching.getComputedText(node).trim())
1099
- .filter(value => value);
1100
- const text = values.join(' ');
1101
- if (FlexGridMatcher.FLEX.includes(text)) {
1102
- return new FlexGridMatch(matching.ast.text(node), node, true);
1103
- }
1104
- if (FlexGridMatcher.GRID.includes(text)) {
1105
- return new FlexGridMatch(matching.ast.text(node), node, false);
1106
- }
1107
- return null;
1108
- }
1109
- }
1110
-
1111
- export class GridTemplateMatch implements Match {
1112
- constructor(readonly text: string, readonly node: CodeMirror.SyntaxNode, readonly lines: CodeMirror.SyntaxNode[][]) {
1113
- }
1114
- }
1115
-
1116
- // clang-format off
1117
- export class GridTemplateMatcher extends matcherBase(GridTemplateMatch) {
1118
- // clang-format on
1119
- override accepts(propertyName: string): boolean {
1120
- return cssMetadata().isGridAreaDefiningProperty(propertyName);
1121
- }
1122
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): GridTemplateMatch|null {
1123
- if (node.name !== 'Declaration' || matching.hasUnresolvedSubstitutions(node)) {
1124
- return null;
1125
- }
1126
-
1127
- const lines: CodeMirror.SyntaxNode[][] = [];
1128
- let curLine: CodeMirror.SyntaxNode[] = [];
1129
- // The following two states are designed to consume different cases of LineNames:
1130
- // 1. no LineNames in between StringLiterals;
1131
- // 2. one LineNames in between, which means the LineNames belongs to the current line;
1132
- // 3. two LineNames in between, which means the second LineNames starts a new line.
1133
- // `hasLeadingLineNames` tracks if the current row already starts with a LineNames and
1134
- // with no following StringLiteral yet, which means that the next StringLiteral should
1135
- // be appended to the same `curLine`, instead of creating a new line.
1136
- let hasLeadingLineNames = false;
1137
- // `needClosingLineNames` tracks if the current row can still consume an optional LineNames,
1138
- // which will decide if we should start a new line or not when a LineNames is encountered.
1139
- let needClosingLineNames = false;
1140
- /**
1141
- * Gather row definitions of [<line-names>? <string> <track-size>? <line-names>?], which
1142
- * be rendered into separate lines.
1143
- **/
1144
- function parseNodes(nodes: CodeMirror.SyntaxNode[], varParsingMode = false): void {
1145
- for (const curNode of nodes) {
1146
- if (matching.getMatch(curNode) instanceof BaseVariableMatch) {
1147
- const computedValueTree = tokenizeDeclaration('--property', matching.getComputedText(curNode));
1148
- if (!computedValueTree) {
1149
- continue;
1150
- }
1151
- const varNodes = ASTUtils.siblings(ASTUtils.declValue(computedValueTree.tree));
1152
- if (varNodes.length === 0) {
1153
- continue;
1154
- }
1155
- if ((varNodes[0].name === 'StringLiteral' && !hasLeadingLineNames) ||
1156
- (varNodes[0].name === 'BracketedValue' && !needClosingLineNames)) {
1157
- // The variable value either starts with a string, or with a line name that belongs to a new row;
1158
- // therefore we start a new line with the variable.
1159
- lines.push(curLine);
1160
- curLine = [curNode];
1161
- } else {
1162
- curLine.push(curNode);
1163
- }
1164
- // We parse computed nodes of this variable to correctly advance local states, but
1165
- // these computed nodes won't be added to the lines.
1166
- parseNodes(varNodes, true);
1167
- } else if (curNode.name === 'BinaryExpression') {
1168
- parseNodes(ASTUtils.siblings(curNode.firstChild));
1169
- } else if (curNode.name === 'StringLiteral') {
1170
- if (!varParsingMode) {
1171
- if (hasLeadingLineNames) {
1172
- curLine.push(curNode);
1173
- } else {
1174
- lines.push(curLine);
1175
- curLine = [curNode];
1176
- }
1177
- }
1178
- needClosingLineNames = true;
1179
- hasLeadingLineNames = false;
1180
- } else if (curNode.name === 'BracketedValue') {
1181
- if (!varParsingMode) {
1182
- if (needClosingLineNames) {
1183
- curLine.push(curNode);
1184
- } else {
1185
- lines.push(curLine);
1186
- curLine = [curNode];
1187
- }
1188
- }
1189
- hasLeadingLineNames = !needClosingLineNames;
1190
- needClosingLineNames = !needClosingLineNames;
1191
- } else if (!varParsingMode) {
1192
- curLine.push(curNode);
1193
- }
1194
- }
1195
- }
1196
-
1197
- const valueNodes = ASTUtils.siblings(ASTUtils.declValue(node));
1198
- if (valueNodes.length === 0) {
1199
- return null;
1200
- }
1201
- parseNodes(valueNodes);
1202
- lines.push(curLine);
1203
- const valueText = matching.ast.textRange(valueNodes[0], valueNodes[valueNodes.length - 1]);
1204
- return new GridTemplateMatch(valueText, node, lines.filter(line => line.length > 0));
1205
- }
1206
- }
1207
- export class AnchorFunctionMatch implements Match {
1208
- constructor(readonly text: string, readonly node: CodeMirror.SyntaxNode, readonly functionName: string|null) {
1209
- }
1210
- }
1211
-
1212
- // clang-format off
1213
- export class AnchorFunctionMatcher extends matcherBase(AnchorFunctionMatch) {
1214
- // clang-format on
1215
- anchorFunction(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): string|null {
1216
- if (node.name !== 'CallExpression') {
1217
- return null;
1218
- }
1219
- const calleeText = matching.ast.text(node.getChild('Callee'));
1220
- if (calleeText === 'anchor' || calleeText === 'anchor-size') {
1221
- return calleeText;
1222
- }
1223
- return null;
1224
- }
1225
-
1226
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): AnchorFunctionMatch|null {
1227
- if (node.name === 'VariableName') {
1228
- // Double-dashed anchor reference to be rendered with a link to its matching anchor.
1229
- let parent = node.parent;
1230
- if (!parent || parent.name !== 'ArgList') {
1231
- return null;
1232
- }
1233
- parent = parent.parent;
1234
- if (!parent || !this.anchorFunction(parent, matching)) {
1235
- return null;
1236
- }
1237
- return new AnchorFunctionMatch(matching.ast.text(node), node, null);
1238
- }
1239
- const calleeText = this.anchorFunction(node, matching);
1240
- if (!calleeText) {
1241
- return null;
1242
- }
1243
- // Match if the anchor/anchor-size function implicitly references an anchor.
1244
- const args = ASTUtils.children(node.getChild('ArgList'));
1245
- if (calleeText === 'anchor' && args.length <= 2) {
1246
- return null;
1247
- }
1248
- if (args.find(arg => arg.name === 'VariableName')) {
1249
- // We have an explicit anchor reference, no need to render swatch.
1250
- return null;
1251
- }
1252
- return new AnchorFunctionMatch(matching.ast.text(node), node, calleeText);
1253
- }
1254
- }
1255
-
1256
- /** For linking `position-anchor: --anchor-name`. **/
1257
- export class PositionAnchorMatch implements Match {
1258
- constructor(readonly text: string, readonly matching: BottomUpTreeMatching, readonly node: CodeMirror.SyntaxNode) {
1259
- }
1260
- }
1261
-
1262
- // clang-format off
1263
- export class PositionAnchorMatcher extends matcherBase(PositionAnchorMatch) {
1264
- // clang-format on
1265
- override accepts(propertyName: string): boolean {
1266
- return propertyName === 'position-anchor';
1267
- }
1268
-
1269
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): PositionAnchorMatch|null {
1270
- if (node.name !== 'VariableName') {
1271
- return null;
1272
- }
1273
-
1274
- const dashedIdentifier = matching.ast.text(node);
1275
- return new PositionAnchorMatch(dashedIdentifier, matching, node);
1276
- }
1277
- }
1278
-
1279
- export class CSSWideKeywordMatch implements Match {
1280
- constructor(
1281
- readonly text: CSSWideKeyword, readonly node: CodeMirror.SyntaxNode, readonly property: CSSProperty,
1282
- readonly matchedStyles: CSSMatchedStyles) {
1283
- }
1284
- resolveProperty(): CSSValueSource|null {
1285
- return this.matchedStyles.resolveGlobalKeyword(this.property, this.text);
1286
- }
1287
- computedText?(): string|null {
1288
- return this.resolveProperty()?.value ?? null;
1289
- }
1290
- }
1291
-
1292
- // clang-format off
1293
- export class CSSWideKeywordMatcher extends matcherBase(CSSWideKeywordMatch) {
1294
- // clang-format on
1295
- constructor(readonly property: CSSProperty, readonly matchedStyles: CSSMatchedStyles) {
1296
- super();
1297
- }
1298
-
1299
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): CSSWideKeywordMatch|null {
1300
- const parentNode = node.parent;
1301
- if (node.name !== 'ValueName' || parentNode?.name !== 'Declaration') {
1302
- return null;
1303
- }
1304
-
1305
- if (Array.from(ASTUtils.stripComments(ASTUtils.siblings(ASTUtils.declValue(parentNode))))
1306
- .some(child => !ASTUtils.equals(child, node))) {
1307
- return null;
1308
- }
1309
-
1310
- const text = matching.ast.text(node);
1311
- if (!CSSMetadata.isCSSWideKeyword(text)) {
1312
- return null;
1313
- }
1314
-
1315
- return new CSSWideKeywordMatch(text, node, this.property, this.matchedStyles);
1316
- }
1317
- }
1318
-
1319
- export class PositionTryMatch implements Match {
1320
- constructor(
1321
- readonly text: string, readonly node: CodeMirror.SyntaxNode, readonly preamble: CodeMirror.SyntaxNode[],
1322
- readonly fallbacks: CodeMirror.SyntaxNode[][]) {
1323
- }
1324
- }
1325
-
1326
- // clang-format off
1327
- export class PositionTryMatcher extends matcherBase(PositionTryMatch) {
1328
- // clang-format on
1329
- override accepts(propertyName: string): boolean {
1330
- return propertyName === LinkableNameProperties.POSITION_TRY ||
1331
- propertyName === LinkableNameProperties.POSITION_TRY_FALLBACKS;
1332
- }
1333
-
1334
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): PositionTryMatch|null {
1335
- if (node.name !== 'Declaration') {
1336
- return null;
1337
- }
1338
-
1339
- let preamble: CodeMirror.SyntaxNode[] = [];
1340
- const valueNodes = ASTUtils.siblings(ASTUtils.declValue(node));
1341
- const fallbacks = ASTUtils.split(valueNodes);
1342
- if (matching.ast.propertyName === LinkableNameProperties.POSITION_TRY) {
1343
- for (const [i, n] of fallbacks[0].entries()) {
1344
- const computedText = matching.getComputedText(n);
1345
- if (CSSMetadata.isCSSWideKeyword(computedText)) {
1346
- return null;
1347
- }
1348
- if (CSSMetadata.isPositionTryOrderKeyword(computedText)) {
1349
- preamble = fallbacks[0].splice(0, i + 1);
1350
- break;
1351
- }
1352
- }
1353
- }
1354
-
1355
- const valueText = matching.ast.textRange(valueNodes[0], valueNodes[valueNodes.length - 1]);
1356
- return new PositionTryMatch(valueText, node, preamble, fallbacks);
1357
- }
1358
- }
1359
-
1360
- export class EnvFunctionMatch implements Match {
1361
- constructor(
1362
- readonly text: string, readonly node: CodeMirror.SyntaxNode, readonly varName: string,
1363
- readonly value: string|null, readonly varNameIsValid: boolean) {
1364
- }
1365
-
1366
- computedText(): string|null {
1367
- return this.value;
1368
- }
1369
- }
1370
-
1371
- // clang-format off
1372
- export class EnvFunctionMatcher extends matcherBase(EnvFunctionMatch) {
1373
- // clang-format on
1374
- constructor(readonly matchedStyles: CSSMatchedStyles) {
1375
- super();
1376
- }
1377
-
1378
- override matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): EnvFunctionMatch|null {
1379
- if (node.name !== 'CallExpression' || matching.ast.text(node.getChild('Callee')) !== 'env') {
1380
- return null;
1381
- }
1382
-
1383
- const [valueNodes, ...fallbackNodes] = ASTUtils.callArgs(node);
1384
- if (!valueNodes?.length) {
1385
- return null;
1386
- }
1387
-
1388
- const fallbackValue =
1389
- fallbackNodes.length > 0 ? matching.getComputedTextRange(...ASTUtils.range(fallbackNodes.flat())) : undefined;
1390
- const varName = matching.getComputedTextRange(...ASTUtils.range(valueNodes)).trim();
1391
- const value = this.matchedStyles.environmentVariable(varName);
1392
-
1393
- return new EnvFunctionMatch(matching.ast.text(node), node, varName, value ?? fallbackValue ?? null, Boolean(value));
1394
- }
1395
- }