devtools-tracing 1.0.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.
- package/generate.ts +643 -0
- package/index.ts +16 -0
- package/lib/front_end/core/common/App.ts +7 -0
- package/lib/front_end/core/common/AppProvider.ts +32 -0
- package/lib/front_end/core/common/Base64.ts +47 -0
- package/lib/front_end/core/common/CharacterIdMap.ts +30 -0
- package/lib/front_end/core/common/Color.ts +2506 -0
- package/lib/front_end/core/common/ColorConverter.ts +402 -0
- package/lib/front_end/core/common/ColorUtils.ts +252 -0
- package/lib/front_end/core/common/Console.ts +114 -0
- package/lib/front_end/core/common/Debouncer.ts +15 -0
- package/lib/front_end/core/common/EventTarget.ts +52 -0
- package/lib/front_end/core/common/Gzip.ts +74 -0
- package/lib/front_end/core/common/JavaScriptMetaData.ts +29 -0
- package/lib/front_end/core/common/Lazy.ts +31 -0
- package/lib/front_end/core/common/Linkifier.ts +55 -0
- package/lib/front_end/core/common/MapWithDefault.ts +26 -0
- package/lib/front_end/core/common/Mutex.ts +55 -0
- package/lib/front_end/core/common/Object.ts +145 -0
- package/lib/front_end/core/common/ParsedURL.ts +554 -0
- package/lib/front_end/core/common/Progress.ts +180 -0
- package/lib/front_end/core/common/QueryParamHandler.ts +7 -0
- package/lib/front_end/core/common/ResolverBase.ts +85 -0
- package/lib/front_end/core/common/ResourceType.ts +588 -0
- package/lib/front_end/core/common/ReturnToPanel.ts +17 -0
- package/lib/front_end/core/common/Revealer.ts +192 -0
- package/lib/front_end/core/common/Runnable.ts +41 -0
- package/lib/front_end/core/common/SegmentedRange.ts +87 -0
- package/lib/front_end/core/common/SettingRegistration.ts +339 -0
- package/lib/front_end/core/common/Settings.ts +1497 -0
- package/lib/front_end/core/common/SimpleHistoryManager.ts +124 -0
- package/lib/front_end/core/common/StringOutputStream.ts +26 -0
- package/lib/front_end/core/common/TextDictionary.ts +48 -0
- package/lib/front_end/core/common/Throttler.ts +99 -0
- package/lib/front_end/core/common/Trie.ts +152 -0
- package/lib/front_end/core/common/Worker.ts +60 -0
- package/lib/front_end/core/common/common.ts +81 -0
- package/lib/front_end/core/host/AidaClient.ts +733 -0
- package/lib/front_end/core/host/GdpClient.ts +316 -0
- package/lib/front_end/core/host/InspectorFrontendHost.ts +648 -0
- package/lib/front_end/core/host/InspectorFrontendHostAPI.ts +551 -0
- package/lib/front_end/core/host/Platform.ts +76 -0
- package/lib/front_end/core/host/ResourceLoader.ts +282 -0
- package/lib/front_end/core/host/UserMetrics.ts +1230 -0
- package/lib/front_end/core/host/host.ts +23 -0
- package/lib/front_end/core/i18n/ByteUtilities.ts +82 -0
- package/lib/front_end/core/i18n/DevToolsLocale.ts +87 -0
- package/lib/front_end/core/i18n/NumberFormatter.ts +82 -0
- package/lib/front_end/core/i18n/i18n.ts +17 -0
- package/lib/front_end/core/i18n/i18nImpl.ts +204 -0
- package/lib/front_end/core/i18n/i18nTypes.ts +10 -0
- package/lib/front_end/core/i18n/locales.js +14 -0
- package/lib/front_end/core/i18n/time-utilities.ts +174 -0
- package/lib/front_end/core/platform/ArrayUtilities.ts +271 -0
- package/lib/front_end/core/platform/Brand.ts +23 -0
- package/lib/front_end/core/platform/Constructor.ts +10 -0
- package/lib/front_end/core/platform/DOMUtilities.ts +138 -0
- package/lib/front_end/core/platform/DateUtilities.ts +15 -0
- package/lib/front_end/core/platform/DevToolsPath.ts +53 -0
- package/lib/front_end/core/platform/KeyboardUtilities.ts +38 -0
- package/lib/front_end/core/platform/MapUtilities.ts +95 -0
- package/lib/front_end/core/platform/MimeType.ts +175 -0
- package/lib/front_end/core/platform/NumberUtilities.ts +80 -0
- package/lib/front_end/core/platform/StringUtilities.ts +588 -0
- package/lib/front_end/core/platform/Timing.ts +17 -0
- package/lib/front_end/core/platform/TypedArrayUtilities.ts +189 -0
- package/lib/front_end/core/platform/TypescriptUtilities.ts +86 -0
- package/lib/front_end/core/platform/UIString.ts +39 -0
- package/lib/front_end/core/platform/UserVisibleError.ts +28 -0
- package/lib/front_end/core/platform/platform.ts +45 -0
- package/lib/front_end/core/protocol_client/ConnectionTransport.ts +26 -0
- package/lib/front_end/core/protocol_client/InspectorBackend.ts +1050 -0
- package/lib/front_end/core/protocol_client/NodeURL.ts +42 -0
- package/lib/front_end/core/protocol_client/protocol_client.ts +13 -0
- package/lib/front_end/core/root/Runtime.ts +609 -0
- package/lib/front_end/core/root/root.ts +6 -0
- package/lib/front_end/core/sdk/AccessibilityModel.ts +353 -0
- package/lib/front_end/core/sdk/AnimationModel.ts +1041 -0
- package/lib/front_end/core/sdk/AutofillModel.ts +184 -0
- package/lib/front_end/core/sdk/CPUProfilerModel.ts +148 -0
- package/lib/front_end/core/sdk/CPUThrottlingManager.ts +282 -0
- package/lib/front_end/core/sdk/CSSContainerQuery.ts +139 -0
- package/lib/front_end/core/sdk/CSSFontFace.ts +40 -0
- package/lib/front_end/core/sdk/CSSLayer.ts +30 -0
- package/lib/front_end/core/sdk/CSSMatchedStyles.ts +1646 -0
- package/lib/front_end/core/sdk/CSSMedia.ts +121 -0
- package/lib/front_end/core/sdk/CSSMetadata.ts +1647 -0
- package/lib/front_end/core/sdk/CSSModel.ts +1128 -0
- package/lib/front_end/core/sdk/CSSProperty.ts +384 -0
- package/lib/front_end/core/sdk/CSSPropertyParser.ts +681 -0
- package/lib/front_end/core/sdk/CSSPropertyParserMatchers.ts +1395 -0
- package/lib/front_end/core/sdk/CSSQuery.ts +72 -0
- package/lib/front_end/core/sdk/CSSRule.ts +465 -0
- package/lib/front_end/core/sdk/CSSScope.ts +30 -0
- package/lib/front_end/core/sdk/CSSStartingStyle.ts +29 -0
- package/lib/front_end/core/sdk/CSSStyleDeclaration.ts +313 -0
- package/lib/front_end/core/sdk/CSSStyleSheetHeader.ts +196 -0
- package/lib/front_end/core/sdk/CSSSupports.ts +33 -0
- package/lib/front_end/core/sdk/CategorizedBreakpoint.ts +64 -0
- package/lib/front_end/core/sdk/ChildTargetManager.ts +314 -0
- package/lib/front_end/core/sdk/CompilerSourceMappingContentProvider.ts +62 -0
- package/lib/front_end/core/sdk/Connections.ts +293 -0
- package/lib/front_end/core/sdk/ConsoleModel.ts +808 -0
- package/lib/front_end/core/sdk/ConsoleModelTypes.ts +15 -0
- package/lib/front_end/core/sdk/Cookie.ts +319 -0
- package/lib/front_end/core/sdk/CookieModel.ts +239 -0
- package/lib/front_end/core/sdk/CookieParser.ts +185 -0
- package/lib/front_end/core/sdk/DOMDebuggerModel.ts +787 -0
- package/lib/front_end/core/sdk/DOMModel.ts +1961 -0
- package/lib/front_end/core/sdk/DebuggerModel.ts +1605 -0
- package/lib/front_end/core/sdk/EmulationModel.ts +648 -0
- package/lib/front_end/core/sdk/EnhancedTracesParser.ts +515 -0
- package/lib/front_end/core/sdk/EventBreakpointsModel.ts +183 -0
- package/lib/front_end/core/sdk/FrameAssociated.ts +11 -0
- package/lib/front_end/core/sdk/FrameManager.ts +259 -0
- package/lib/front_end/core/sdk/HeapProfilerModel.ts +225 -0
- package/lib/front_end/core/sdk/HttpReasonPhraseStrings.ts +77 -0
- package/lib/front_end/core/sdk/IOModel.ts +91 -0
- package/lib/front_end/core/sdk/IsolateManager.ts +257 -0
- package/lib/front_end/core/sdk/IssuesModel.ts +70 -0
- package/lib/front_end/core/sdk/LayerTreeBase.ts +169 -0
- package/lib/front_end/core/sdk/LogModel.ts +56 -0
- package/lib/front_end/core/sdk/NetworkManager.ts +2823 -0
- package/lib/front_end/core/sdk/NetworkRequest.ts +2253 -0
- package/lib/front_end/core/sdk/OverlayColorGenerator.ts +52 -0
- package/lib/front_end/core/sdk/OverlayModel.ts +1011 -0
- package/lib/front_end/core/sdk/OverlayPersistentHighlighter.ts +522 -0
- package/lib/front_end/core/sdk/PageLoad.ts +35 -0
- package/lib/front_end/core/sdk/PageResourceLoader.ts +435 -0
- package/lib/front_end/core/sdk/PaintProfiler.ts +110 -0
- package/lib/front_end/core/sdk/PerformanceMetricsModel.ts +84 -0
- package/lib/front_end/core/sdk/PreloadingModel.ts +863 -0
- package/lib/front_end/core/sdk/RehydratingConnection.ts +386 -0
- package/lib/front_end/core/sdk/RehydratingObject.ts +66 -0
- package/lib/front_end/core/sdk/RemoteObject.ts +1160 -0
- package/lib/front_end/core/sdk/Resource.ts +232 -0
- package/lib/front_end/core/sdk/ResourceTreeModel.ts +1160 -0
- package/lib/front_end/core/sdk/RuntimeModel.ts +732 -0
- package/lib/front_end/core/sdk/SDKModel.ts +65 -0
- package/lib/front_end/core/sdk/ScopeTreeCache.ts +45 -0
- package/lib/front_end/core/sdk/ScreenCaptureModel.ts +255 -0
- package/lib/front_end/core/sdk/Script.ts +534 -0
- package/lib/front_end/core/sdk/SecurityOriginManager.ts +76 -0
- package/lib/front_end/core/sdk/ServerSentEvents.ts +80 -0
- package/lib/front_end/core/sdk/ServerSentEventsProtocol.ts +122 -0
- package/lib/front_end/core/sdk/ServerTiming.ts +260 -0
- package/lib/front_end/core/sdk/ServiceWorkerCacheModel.ts +377 -0
- package/lib/front_end/core/sdk/ServiceWorkerManager.ts +605 -0
- package/lib/front_end/core/sdk/SourceMap.ts +867 -0
- package/lib/front_end/core/sdk/SourceMapCache.ts +54 -0
- package/lib/front_end/core/sdk/SourceMapFunctionRanges.ts +156 -0
- package/lib/front_end/core/sdk/SourceMapManager.ts +239 -0
- package/lib/front_end/core/sdk/SourceMapScopeChainEntry.ts +189 -0
- package/lib/front_end/core/sdk/SourceMapScopesInfo.ts +508 -0
- package/lib/front_end/core/sdk/StorageBucketsModel.ts +204 -0
- package/lib/front_end/core/sdk/StorageKeyManager.ts +98 -0
- package/lib/front_end/core/sdk/Target.ts +332 -0
- package/lib/front_end/core/sdk/TargetManager.ts +453 -0
- package/lib/front_end/core/sdk/TraceObject.ts +61 -0
- package/lib/front_end/core/sdk/WebAuthnModel.ts +104 -0
- package/lib/front_end/core/sdk/sdk.ts +174 -0
- package/lib/front_end/entrypoints/formatter_worker/FormatterActions.ts +59 -0
- package/lib/front_end/generated/InspectorBackendCommands.js +1617 -0
- package/lib/front_end/generated/SupportedCSSProperties.js +7512 -0
- package/lib/front_end/generated/protocol-proxy-api.d.ts +5022 -0
- package/lib/front_end/generated/protocol.ts +22014 -0
- package/lib/front_end/models/cpu_profile/CPUProfileDataModel.ts +571 -0
- package/lib/front_end/models/cpu_profile/ProfileTreeModel.ts +103 -0
- package/lib/front_end/models/cpu_profile/cpu_profile.ts +11 -0
- package/lib/front_end/models/formatter/FormatterWorkerPool.ts +219 -0
- package/lib/front_end/models/formatter/ScriptFormatter.ts +112 -0
- package/lib/front_end/models/formatter/formatter.ts +8 -0
- package/lib/front_end/models/text_utils/CodeMirrorUtils.ts +37 -0
- package/lib/front_end/models/text_utils/ContentData.ts +199 -0
- package/lib/front_end/models/text_utils/ContentProvider.ts +68 -0
- package/lib/front_end/models/text_utils/StaticContentProvider.ts +49 -0
- package/lib/front_end/models/text_utils/StreamingContentData.ts +108 -0
- package/lib/front_end/models/text_utils/Text.ts +90 -0
- package/lib/front_end/models/text_utils/TextCursor.ts +44 -0
- package/lib/front_end/models/text_utils/TextRange.ts +266 -0
- package/lib/front_end/models/text_utils/TextUtils.ts +401 -0
- package/lib/front_end/models/text_utils/WasmDisassembly.ts +87 -0
- package/lib/front_end/models/text_utils/text_utils.ts +27 -0
- package/lib/front_end/models/trace/EntityMapper.ts +141 -0
- package/lib/front_end/models/trace/EventsSerializer.ts +101 -0
- package/lib/front_end/models/trace/LanternComputationData.ts +438 -0
- package/lib/front_end/models/trace/ModelImpl.ts +236 -0
- package/lib/front_end/models/trace/Name.ts +136 -0
- package/lib/front_end/models/trace/Processor.ts +652 -0
- package/lib/front_end/models/trace/Styles.ts +1138 -0
- package/lib/front_end/models/trace/extras/FilmStrip.ts +78 -0
- package/lib/front_end/models/trace/extras/MainThreadActivity.ts +86 -0
- package/lib/front_end/models/trace/extras/ScriptDuplication.ts +236 -0
- package/lib/front_end/models/trace/extras/StackTraceForEvent.ts +203 -0
- package/lib/front_end/models/trace/extras/ThirdParties.ts +164 -0
- package/lib/front_end/models/trace/extras/TraceFilter.ts +62 -0
- package/lib/front_end/models/trace/extras/TraceTree.ts +701 -0
- package/lib/front_end/models/trace/extras/extras.ts +11 -0
- package/lib/front_end/models/trace/handlers/AnimationFramesHandler.ts +128 -0
- package/lib/front_end/models/trace/handlers/AnimationHandler.ts +36 -0
- package/lib/front_end/models/trace/handlers/AsyncJSCallsHandler.ts +239 -0
- package/lib/front_end/models/trace/handlers/AuctionWorkletsHandler.ts +183 -0
- package/lib/front_end/models/trace/handlers/DOMStatsHandler.ts +31 -0
- package/lib/front_end/models/trace/handlers/ExtensionTraceDataHandler.ts +306 -0
- package/lib/front_end/models/trace/handlers/FlowsHandler.ts +175 -0
- package/lib/front_end/models/trace/handlers/FramesHandler.ts +571 -0
- package/lib/front_end/models/trace/handlers/GPUHandler.ts +50 -0
- package/lib/front_end/models/trace/handlers/ImagePaintingHandler.ts +183 -0
- package/lib/front_end/models/trace/handlers/InitiatorsHandler.ts +193 -0
- package/lib/front_end/models/trace/handlers/InvalidationsHandler.ts +168 -0
- package/lib/front_end/models/trace/handlers/LargestImagePaintHandler.ts +109 -0
- package/lib/front_end/models/trace/handlers/LargestTextPaintHandler.ts +35 -0
- package/lib/front_end/models/trace/handlers/LayerTreeHandler.ts +123 -0
- package/lib/front_end/models/trace/handlers/LayoutShiftsHandler.ts +573 -0
- package/lib/front_end/models/trace/handlers/MemoryHandler.ts +31 -0
- package/lib/front_end/models/trace/handlers/MetaHandler.ts +525 -0
- package/lib/front_end/models/trace/handlers/ModelHandlers.ts +34 -0
- package/lib/front_end/models/trace/handlers/NetworkRequestsHandler.ts +672 -0
- package/lib/front_end/models/trace/handlers/PageFramesHandler.ts +52 -0
- package/lib/front_end/models/trace/handlers/PageLoadMetricsHandler.ts +460 -0
- package/lib/front_end/models/trace/handlers/RendererHandler.ts +428 -0
- package/lib/front_end/models/trace/handlers/SamplesHandler.ts +271 -0
- package/lib/front_end/models/trace/handlers/ScreenshotsHandler.ts +122 -0
- package/lib/front_end/models/trace/handlers/ScriptsHandler.ts +336 -0
- package/lib/front_end/models/trace/handlers/SelectorStatsHandler.ts +110 -0
- package/lib/front_end/models/trace/handlers/Threads.ts +139 -0
- package/lib/front_end/models/trace/handlers/UserInteractionsHandler.ts +400 -0
- package/lib/front_end/models/trace/handlers/UserTimingsHandler.ts +233 -0
- package/lib/front_end/models/trace/handlers/WarningsHandler.ts +162 -0
- package/lib/front_end/models/trace/handlers/WorkersHandler.ts +45 -0
- package/lib/front_end/models/trace/handlers/handlers.ts +8 -0
- package/lib/front_end/models/trace/handlers/helpers.ts +196 -0
- package/lib/front_end/models/trace/handlers/types.ts +75 -0
- package/lib/front_end/models/trace/helpers/Extensions.ts +54 -0
- package/lib/front_end/models/trace/helpers/Network.ts +129 -0
- package/lib/front_end/models/trace/helpers/SamplesIntegrator.ts +544 -0
- package/lib/front_end/models/trace/helpers/SyntheticEvents.ts +87 -0
- package/lib/front_end/models/trace/helpers/Timing.ts +248 -0
- package/lib/front_end/models/trace/helpers/Trace.ts +928 -0
- package/lib/front_end/models/trace/helpers/TreeHelpers.ts +320 -0
- package/lib/front_end/models/trace/helpers/helpers.ts +11 -0
- package/lib/front_end/models/trace/insights/CLSCulprits.ts +668 -0
- package/lib/front_end/models/trace/insights/Cache.ts +269 -0
- package/lib/front_end/models/trace/insights/Common.ts +453 -0
- package/lib/front_end/models/trace/insights/DOMSize.ts +223 -0
- package/lib/front_end/models/trace/insights/DocumentLatency.ts +319 -0
- package/lib/front_end/models/trace/insights/DuplicatedJavaScript.ts +126 -0
- package/lib/front_end/models/trace/insights/FontDisplay.ts +119 -0
- package/lib/front_end/models/trace/insights/ForcedReflow.ts +220 -0
- package/lib/front_end/models/trace/insights/INPBreakdown.ts +171 -0
- package/lib/front_end/models/trace/insights/ImageDelivery.ts +348 -0
- package/lib/front_end/models/trace/insights/LCPBreakdown.ts +268 -0
- package/lib/front_end/models/trace/insights/LCPDiscovery.ts +237 -0
- package/lib/front_end/models/trace/insights/LegacyJavaScript.ts +138 -0
- package/lib/front_end/models/trace/insights/Models.ts +22 -0
- package/lib/front_end/models/trace/insights/ModernHTTP.ts +257 -0
- package/lib/front_end/models/trace/insights/NetworkDependencyTree.ts +726 -0
- package/lib/front_end/models/trace/insights/RenderBlocking.ts +257 -0
- package/lib/front_end/models/trace/insights/SlowCSSSelector.ts +175 -0
- package/lib/front_end/models/trace/insights/Statistics.ts +101 -0
- package/lib/front_end/models/trace/insights/ThirdParties.ts +130 -0
- package/lib/front_end/models/trace/insights/Viewport.ts +138 -0
- package/lib/front_end/models/trace/insights/insights.ts +10 -0
- package/lib/front_end/models/trace/insights/types.ts +157 -0
- package/lib/front_end/models/trace/lantern/core/LanternError.ts +7 -0
- package/lib/front_end/models/trace/lantern/core/NetworkAnalyzer.ts +619 -0
- package/lib/front_end/models/trace/lantern/core/core.ts +6 -0
- package/lib/front_end/models/trace/lantern/graph/BaseNode.ts +345 -0
- package/lib/front_end/models/trace/lantern/graph/CPUNode.ts +80 -0
- package/lib/front_end/models/trace/lantern/graph/NetworkNode.ts +101 -0
- package/lib/front_end/models/trace/lantern/graph/PageDependencyGraph.ts +636 -0
- package/lib/front_end/models/trace/lantern/graph/graph.ts +8 -0
- package/lib/front_end/models/trace/lantern/lantern.ts +17 -0
- package/lib/front_end/models/trace/lantern/metrics/FirstContentfulPaint.ts +187 -0
- package/lib/front_end/models/trace/lantern/metrics/Interactive.ts +88 -0
- package/lib/front_end/models/trace/lantern/metrics/LargestContentfulPaint.ts +92 -0
- package/lib/front_end/models/trace/lantern/metrics/MaxPotentialFID.ts +72 -0
- package/lib/front_end/models/trace/lantern/metrics/Metric.ts +126 -0
- package/lib/front_end/models/trace/lantern/metrics/SpeedIndex.ts +126 -0
- package/lib/front_end/models/trace/lantern/metrics/TBTUtils.ts +82 -0
- package/lib/front_end/models/trace/lantern/metrics/TotalBlockingTime.ts +112 -0
- package/lib/front_end/models/trace/lantern/metrics/metrics.ts +12 -0
- package/lib/front_end/models/trace/lantern/simulation/ConnectionPool.ts +150 -0
- package/lib/front_end/models/trace/lantern/simulation/Constants.ts +46 -0
- package/lib/front_end/models/trace/lantern/simulation/DNSCache.ts +61 -0
- package/lib/front_end/models/trace/lantern/simulation/SimulationTimingMap.ts +196 -0
- package/lib/front_end/models/trace/lantern/simulation/Simulator.ts +556 -0
- package/lib/front_end/models/trace/lantern/simulation/TCPConnection.ts +192 -0
- package/lib/front_end/models/trace/lantern/simulation/simulation.ts +10 -0
- package/lib/front_end/models/trace/lantern/types/Lantern.ts +220 -0
- package/lib/front_end/models/trace/lantern/types/types.ts +5 -0
- package/lib/front_end/models/trace/trace.ts +33 -0
- package/lib/front_end/models/trace/types/Configuration.ts +110 -0
- package/lib/front_end/models/trace/types/Extensions.ts +136 -0
- package/lib/front_end/models/trace/types/File.ts +281 -0
- package/lib/front_end/models/trace/types/Overlays.ts +138 -0
- package/lib/front_end/models/trace/types/Timing.ts +30 -0
- package/lib/front_end/models/trace/types/TraceEvents.ts +3277 -0
- package/lib/front_end/models/trace/types/types.ts +10 -0
- package/lib/front_end/third_party/i18n/LICENSE +202 -0
- package/lib/front_end/third_party/i18n/README.chromium +15 -0
- package/lib/front_end/third_party/i18n/i18n-impl.ts +61 -0
- package/lib/front_end/third_party/i18n/i18n.ts +11 -0
- package/lib/front_end/third_party/i18n/localized-string-set.ts +129 -0
- package/lib/front_end/third_party/intl-messageformat/LICENSE +33 -0
- package/lib/front_end/third_party/intl-messageformat/README.chromium +24 -0
- package/lib/front_end/third_party/intl-messageformat/intl-messageformat-tsconfig.json +16 -0
- package/lib/front_end/third_party/intl-messageformat/intl-messageformat.ts +6 -0
- package/lib/front_end/third_party/intl-messageformat/package/LICENSE.md +33 -0
- package/lib/front_end/third_party/intl-messageformat/package/README.md +3 -0
- package/lib/front_end/third_party/intl-messageformat/package/index.d.ts +6 -0
- package/lib/front_end/third_party/intl-messageformat/package/index.d.ts.map +1 -0
- package/lib/front_end/third_party/intl-messageformat/package/index.js +13 -0
- package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.esm.d.ts +5 -0
- package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.esm.js +1710 -0
- package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.iife.js +1815 -0
- package/lib/front_end/third_party/intl-messageformat/package/lib/index.d.ts +6 -0
- package/lib/front_end/third_party/intl-messageformat/package/lib/index.d.ts.map +1 -0
- package/lib/front_end/third_party/intl-messageformat/package/lib/index.js +10 -0
- package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.d.ts +34 -0
- package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.d.ts.map +1 -0
- package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.js +229 -0
- package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.d.ts +28 -0
- package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.d.ts.map +1 -0
- package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.js +48 -0
- package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.d.ts +34 -0
- package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.d.ts.map +1 -0
- package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.js +179 -0
- package/lib/front_end/third_party/intl-messageformat/package/package.json +42 -0
- package/lib/front_end/third_party/intl-messageformat/package/src/core.d.ts +34 -0
- package/lib/front_end/third_party/intl-messageformat/package/src/core.d.ts.map +1 -0
- package/lib/front_end/third_party/intl-messageformat/package/src/core.js +230 -0
- package/lib/front_end/third_party/intl-messageformat/package/src/error.d.ts +28 -0
- package/lib/front_end/third_party/intl-messageformat/package/src/error.d.ts.map +1 -0
- package/lib/front_end/third_party/intl-messageformat/package/src/error.js +51 -0
- package/lib/front_end/third_party/intl-messageformat/package/src/formatters.d.ts +34 -0
- package/lib/front_end/third_party/intl-messageformat/package/src/formatters.d.ts.map +1 -0
- package/lib/front_end/third_party/intl-messageformat/package/src/formatters.js +182 -0
- package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/error.d.ts +79 -0
- package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/index.d.ts +15 -0
- package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/parser.d.ts +153 -0
- package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/types.d.ts +139 -0
- package/lib/front_end/third_party/legacy-javascript/LICENSE +202 -0
- package/lib/front_end/third_party/legacy-javascript/README.chromium +13 -0
- package/lib/front_end/third_party/legacy-javascript/legacy-javascript-tsconfig.json +8 -0
- package/lib/front_end/third_party/legacy-javascript/legacy-javascript.ts +3 -0
- package/lib/front_end/third_party/legacy-javascript/lib/legacy-javascript.d.ts +18 -0
- package/lib/front_end/third_party/legacy-javascript/lib/legacy-javascript.js +943 -0
- package/lib/front_end/third_party/legacy-javascript/package.json +8 -0
- package/lib/front_end/third_party/legacy-javascript/rebuild.sh +9 -0
- package/lib/front_end/third_party/third-party-web/LICENSE +20 -0
- package/lib/front_end/third_party/third-party-web/README.chromium +13 -0
- package/lib/front_end/third_party/third-party-web/lib/nostats-subset.d.ts +2 -0
- package/lib/front_end/third_party/third-party-web/lib/nostats-subset.js +149 -0
- package/lib/front_end/third_party/third-party-web/package/LICENSE +20 -0
- package/lib/front_end/third_party/third-party-web/package/README.md +929 -0
- package/lib/front_end/third_party/third-party-web/package/dist/entities-httparchive-nostats.json +1 -0
- package/lib/front_end/third_party/third-party-web/package/dist/entities-httparchive.json +1 -0
- package/lib/front_end/third_party/third-party-web/package/dist/entities-nostats.json +1 -0
- package/lib/front_end/third_party/third-party-web/package/dist/entities.json +1 -0
- package/lib/front_end/third_party/third-party-web/package/facades.md +46 -0
- package/lib/front_end/third_party/third-party-web/package/httparchive-nostats-subset.d.ts +1 -0
- package/lib/front_end/third_party/third-party-web/package/httparchive-nostats-subset.js +1 -0
- package/lib/front_end/third_party/third-party-web/package/httparchive-subset.d.ts +1 -0
- package/lib/front_end/third_party/third-party-web/package/httparchive-subset.js +1 -0
- package/lib/front_end/third_party/third-party-web/package/lib/__snapshots__/index.test.js.snap +1006 -0
- package/lib/front_end/third_party/third-party-web/package/lib/create-entity-finder-api.js +139 -0
- package/lib/front_end/third_party/third-party-web/package/lib/create-entity-finder-api.test.js +44 -0
- package/lib/front_end/third_party/third-party-web/package/lib/entities.test.js +27 -0
- package/lib/front_end/third_party/third-party-web/package/lib/index.d.ts +34 -0
- package/lib/front_end/third_party/third-party-web/package/lib/index.js +3 -0
- package/lib/front_end/third_party/third-party-web/package/lib/index.test.js +246 -0
- package/lib/front_end/third_party/third-party-web/package/lib/markdown/faqs.partial.md +36 -0
- package/lib/front_end/third_party/third-party-web/package/lib/markdown/goals.partial.md +9 -0
- package/lib/front_end/third_party/third-party-web/package/lib/markdown/methodology.partial.md +5 -0
- package/lib/front_end/third_party/third-party-web/package/lib/markdown/template.md +151 -0
- package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-02-01.md +1 -0
- package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-03-01.md +1 -0
- package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-05-06.md +1 -0
- package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-05-13.md +14 -0
- package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2021-01-01.md +1 -0
- package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2024-07-01.md +3 -0
- package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive-nostats.d.ts +1 -0
- package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive-nostats.js +3 -0
- package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive.d.ts +1 -0
- package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive.js +3 -0
- package/lib/front_end/third_party/third-party-web/package/lib/subsets/nostats.d.ts +1 -0
- package/lib/front_end/third_party/third-party-web/package/lib/subsets/nostats.js +3 -0
- package/lib/front_end/third_party/third-party-web/package/nostats-subset.d.ts +1 -0
- package/lib/front_end/third_party/third-party-web/package/nostats-subset.js +1 -0
- package/lib/front_end/third_party/third-party-web/package/package.json +46 -0
- package/lib/front_end/third_party/third-party-web/package.json +8 -0
- package/lib/front_end/third_party/third-party-web/rebuild.sh +13 -0
- package/lib/front_end/third_party/third-party-web/third-party-web-tsconfig.json +8 -0
- package/lib/front_end/third_party/third-party-web/third-party-web.ts +3 -0
- package/package.json +24 -0
- package/patches/chrome-devtools-frontend+1.0.1533544.patch +187 -0
|
@@ -0,0 +1,681 @@
|
|
|
1
|
+
// Copyright 2020 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
|
+
|
|
5
|
+
import type * as Platform from '../../core/platform/platform.js';
|
|
6
|
+
import * as CodeMirror from '../../third_party/codemirror.next/codemirror.next.js';
|
|
7
|
+
|
|
8
|
+
import {TextMatcher} from './CSSPropertyParserMatchers.js';
|
|
9
|
+
|
|
10
|
+
const globalValues = new Set<string>(['inherit', 'initial', 'unset']);
|
|
11
|
+
|
|
12
|
+
const tagRegexp = /[\x20-\x7E]{4}/;
|
|
13
|
+
const numRegexp = /[+-]?(?:\d*\.)?\d+(?:[eE]\d+)?/;
|
|
14
|
+
const fontVariationSettingsRegexp =
|
|
15
|
+
new RegExp(`(?:'(${tagRegexp.source})')|(?:"(${tagRegexp.source})")\\s+(${numRegexp.source})`);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Extracts information about font variation settings assuming
|
|
19
|
+
* value is valid according to the spec: https://drafts.csswg.org/css-fonts-4/#font-variation-settings-def
|
|
20
|
+
*/
|
|
21
|
+
export function parseFontVariationSettings(value: string): Array<{
|
|
22
|
+
tag: string,
|
|
23
|
+
value: number,
|
|
24
|
+
}> {
|
|
25
|
+
if (globalValues.has(value.trim()) || value.trim() === 'normal') {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
const results = [];
|
|
29
|
+
for (const setting of splitByComma(stripComments(value))) {
|
|
30
|
+
const match = setting.match(fontVariationSettingsRegexp);
|
|
31
|
+
if (match) {
|
|
32
|
+
results.push({
|
|
33
|
+
tag: match[1] || match[2],
|
|
34
|
+
value: parseFloat(match[3]),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return results;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// "str" or 'str'
|
|
42
|
+
const fontFamilyRegexp = /^"(.+)"|'(.+)'$/;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Extracts font families assuming the value is valid according to
|
|
46
|
+
* the spec: https://drafts.csswg.org/css-fonts-4/#font-family-prop
|
|
47
|
+
*/
|
|
48
|
+
export function parseFontFamily(value: string): string[] {
|
|
49
|
+
if (globalValues.has(value.trim())) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
const results = [];
|
|
53
|
+
for (const family of splitByComma(stripComments(value))) {
|
|
54
|
+
const match = family.match(fontFamilyRegexp);
|
|
55
|
+
if (match) {
|
|
56
|
+
// Either the 1st or 2nd group matches if the value is in quotes
|
|
57
|
+
results.push(match[1] || match[2]);
|
|
58
|
+
} else {
|
|
59
|
+
// Value without without quotes.
|
|
60
|
+
results.push(family);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return results;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Splits a list of values by comma and trims parts
|
|
68
|
+
*/
|
|
69
|
+
export function splitByComma(value: string): string[] {
|
|
70
|
+
return value.split(',').map(part => part.trim());
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function stripComments(value: string): string {
|
|
74
|
+
return value.replaceAll(/(\/\*(?:.|\s)*?\*\/)/g, '');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function nodeText(node: CodeMirror.SyntaxNode, text: string): string {
|
|
78
|
+
return nodeTextRange(node, node, text);
|
|
79
|
+
}
|
|
80
|
+
function nodeTextRange(from: CodeMirror.SyntaxNode, to: CodeMirror.SyntaxNode, text: string): string {
|
|
81
|
+
return text.substring(from.from, to.to);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export class SyntaxTree {
|
|
85
|
+
readonly propertyValue: string;
|
|
86
|
+
readonly rule: string;
|
|
87
|
+
readonly tree: CodeMirror.SyntaxNode;
|
|
88
|
+
readonly trailingNodes: CodeMirror.SyntaxNode[];
|
|
89
|
+
readonly propertyName: string|undefined;
|
|
90
|
+
constructor(
|
|
91
|
+
propertyValue: string, rule: string, tree: CodeMirror.SyntaxNode, propertyName?: string,
|
|
92
|
+
trailingNodes: CodeMirror.SyntaxNode[] = []) {
|
|
93
|
+
this.propertyName = propertyName;
|
|
94
|
+
this.propertyValue = propertyValue;
|
|
95
|
+
this.rule = rule;
|
|
96
|
+
this.tree = tree;
|
|
97
|
+
this.trailingNodes = trailingNodes;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
text(node?: CodeMirror.SyntaxNode|null): string {
|
|
101
|
+
if (node === null) {
|
|
102
|
+
return '';
|
|
103
|
+
}
|
|
104
|
+
return nodeText(node ?? this.tree, this.rule);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
textRange(from: CodeMirror.SyntaxNode|undefined, to: CodeMirror.SyntaxNode|undefined): string {
|
|
108
|
+
if (!from || !to) {
|
|
109
|
+
return '';
|
|
110
|
+
}
|
|
111
|
+
return nodeTextRange(from, to, this.rule);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
subtree(node: CodeMirror.SyntaxNode): SyntaxTree {
|
|
115
|
+
return new SyntaxTree(this.propertyValue, this.rule, node);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface SyntaxNodeRef {
|
|
120
|
+
node: CodeMirror.SyntaxNode;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export abstract class TreeWalker {
|
|
124
|
+
readonly ast: SyntaxTree;
|
|
125
|
+
constructor(ast: SyntaxTree) {
|
|
126
|
+
this.ast = ast;
|
|
127
|
+
}
|
|
128
|
+
static walkExcludingSuccessors<T extends TreeWalker, ArgTs extends unknown[]>(
|
|
129
|
+
this: {new(ast: SyntaxTree, ...args: ArgTs): T}, propertyValue: SyntaxTree, ...args: ArgTs): T {
|
|
130
|
+
const instance = new this(propertyValue, ...args);
|
|
131
|
+
if (propertyValue.tree.name === 'Declaration') {
|
|
132
|
+
instance.iterateDeclaration(propertyValue.tree);
|
|
133
|
+
} else {
|
|
134
|
+
instance.iterateExcludingSuccessors(propertyValue.tree);
|
|
135
|
+
}
|
|
136
|
+
return instance;
|
|
137
|
+
}
|
|
138
|
+
static walk<T extends TreeWalker, ArgTs extends unknown[]>(
|
|
139
|
+
this: {new(ast: SyntaxTree, ...args: ArgTs): T}, propertyValue: SyntaxTree, ...args: ArgTs): T {
|
|
140
|
+
const instance = new this(propertyValue, ...args);
|
|
141
|
+
if (propertyValue.tree.name === 'Declaration') {
|
|
142
|
+
instance.iterateDeclaration(propertyValue.tree);
|
|
143
|
+
} else {
|
|
144
|
+
instance.iterate(propertyValue.tree);
|
|
145
|
+
}
|
|
146
|
+
return instance;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
iterateDeclaration(tree: CodeMirror.SyntaxNode): void {
|
|
150
|
+
if (tree.name !== 'Declaration') {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (this.enter(tree)) {
|
|
154
|
+
for (const sibling of ASTUtils.siblings(ASTUtils.declValue(tree))) {
|
|
155
|
+
sibling.cursor().iterate(this.enter.bind(this), this.leave.bind(this));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
this.leave(tree);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
protected iterate(tree: CodeMirror.SyntaxNode): void {
|
|
162
|
+
// Includes siblings of tree.
|
|
163
|
+
for (const sibling of ASTUtils.siblings(tree)) {
|
|
164
|
+
sibling.cursor().iterate(this.enter.bind(this), this.leave.bind(this));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
protected iterateExcludingSuccessors(tree: CodeMirror.SyntaxNode): void {
|
|
169
|
+
tree.cursor().iterate(this.enter.bind(this), this.leave.bind(this));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
protected enter(_node: SyntaxNodeRef): boolean {
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
protected leave(_node: SyntaxNodeRef): void {
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export interface Match {
|
|
181
|
+
readonly text: string;
|
|
182
|
+
readonly node: CodeMirror.SyntaxNode;
|
|
183
|
+
computedText?(): string|null;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface Matcher<MatchT extends Match> {
|
|
187
|
+
readonly matchType: Platform.Constructor.ConstructorOrAbstract<MatchT>;
|
|
188
|
+
accepts(propertyName: string): boolean;
|
|
189
|
+
matches(node: CodeMirror.SyntaxNode, matching: BottomUpTreeMatching): MatchT|null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
193
|
+
export function matcherBase<MatchT extends Match>(matchT: Platform.Constructor.ConstructorOrAbstract<MatchT>) {
|
|
194
|
+
class MatcherBase implements Matcher<MatchT> {
|
|
195
|
+
matchType = matchT;
|
|
196
|
+
accepts(_propertyName: string): boolean {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
matches(_node: CodeMirror.SyntaxNode, _matching: BottomUpTreeMatching): MatchT|null {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return MatcherBase;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
type MatchKey = Platform.Brand.Brand<string, 'MatchKey'>;
|
|
208
|
+
export class BottomUpTreeMatching extends TreeWalker {
|
|
209
|
+
readonly #matchers: Array<Matcher<Match>> = [];
|
|
210
|
+
readonly #matchedNodes = new Map<MatchKey, Match>();
|
|
211
|
+
readonly computedText: ComputedText;
|
|
212
|
+
|
|
213
|
+
#key(node: CodeMirror.SyntaxNode): MatchKey {
|
|
214
|
+
return `${node.from}:${node.to}` as MatchKey;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
constructor(ast: SyntaxTree, matchers: Array<Matcher<Match>>) {
|
|
218
|
+
super(ast);
|
|
219
|
+
this.computedText = new ComputedText(ast.rule.substring(ast.tree.from));
|
|
220
|
+
this.#matchers.push(...matchers.filter(m => !ast.propertyName || m.accepts(ast.propertyName)));
|
|
221
|
+
this.#matchers.push(new TextMatcher());
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
protected override leave({node}: SyntaxNodeRef): void {
|
|
225
|
+
for (const matcher of this.#matchers) {
|
|
226
|
+
const match = matcher.matches(node, this);
|
|
227
|
+
if (match) {
|
|
228
|
+
this.computedText.push(match, node.from - this.ast.tree.from);
|
|
229
|
+
this.#matchedNodes.set(this.#key(node), match);
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
matchText(node: CodeMirror.SyntaxNode): void {
|
|
236
|
+
const matchers = this.#matchers.splice(0);
|
|
237
|
+
this.#matchers.push(new TextMatcher());
|
|
238
|
+
this.iterateExcludingSuccessors(node);
|
|
239
|
+
this.#matchers.push(...matchers);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
hasMatches(...matchTypes: Array<Platform.Constructor.Constructor<Match>>): boolean {
|
|
243
|
+
return Boolean(this.#matchedNodes.values().find(match => matchTypes.some(matchType => match instanceof matchType)));
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
getMatch(node: CodeMirror.SyntaxNode): Match|undefined {
|
|
247
|
+
return this.#matchedNodes.get(this.#key(node));
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
hasUnresolvedSubstitutions(node: CodeMirror.SyntaxNode): boolean {
|
|
251
|
+
return this.hasUnresolvedSubstitutionsRange(node, node);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
hasUnresolvedSubstitutionsRange(from: CodeMirror.SyntaxNode, to: CodeMirror.SyntaxNode): boolean {
|
|
255
|
+
return this.computedText.hasUnresolvedSubstitutions(from.from - this.ast.tree.from, to.to - this.ast.tree.from);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
getComputedText(node: CodeMirror.SyntaxNode, substitutionHook?: (match: Match) => string | null): string {
|
|
259
|
+
return this.getComputedTextRange(node, node, substitutionHook);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
getLonghandValuesCount(): number {
|
|
263
|
+
const [from, to] = ASTUtils.range(ASTUtils.siblings(ASTUtils.declValue(this.ast.tree)));
|
|
264
|
+
if (!from || !to) {
|
|
265
|
+
return 0;
|
|
266
|
+
}
|
|
267
|
+
return this.computedText.countTopLevelValues(from.from - this.ast.tree.from, to.to - this.ast.tree.from);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
getComputedLonghandName(to: CodeMirror.SyntaxNode): number {
|
|
271
|
+
const from = ASTUtils.declValue(this.ast.tree) ?? this.ast.tree;
|
|
272
|
+
return this.computedText.countTopLevelValues(from.from - this.ast.tree.from, to.from - this.ast.tree.from);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
getComputedPropertyValueText(substitutionHook?: (match: Match) => string | null): string {
|
|
276
|
+
const [from, to] = ASTUtils.range(ASTUtils.siblings(ASTUtils.declValue(this.ast.tree)));
|
|
277
|
+
return this.getComputedTextRange(from ?? this.ast.tree, to ?? this.ast.tree, substitutionHook);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
getComputedTextRange(
|
|
281
|
+
from: CodeMirror.SyntaxNode|undefined, to: CodeMirror.SyntaxNode|undefined,
|
|
282
|
+
substitutionHook?: (match: Match) => string | null): string {
|
|
283
|
+
if (!from || !to) {
|
|
284
|
+
return '';
|
|
285
|
+
}
|
|
286
|
+
return this.computedText.get(from.from - this.ast.tree.from, to.to - this.ast.tree.from, substitutionHook);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
type MatchWithComputedText = Match&{computedText: NonNullable<Match['computedText']>};
|
|
291
|
+
class ComputedTextChunk {
|
|
292
|
+
#cachedComputedText: string|null = null;
|
|
293
|
+
#topLevelValueCount: number|null = null;
|
|
294
|
+
constructor(readonly match: MatchWithComputedText, readonly offset: number) {
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
get end(): number {
|
|
298
|
+
return this.offset + this.length;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
get length(): number {
|
|
302
|
+
return this.match.text.length;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
get computedText(): string|null {
|
|
306
|
+
if (this.#cachedComputedText === null) {
|
|
307
|
+
this.#cachedComputedText = this.match.computedText();
|
|
308
|
+
}
|
|
309
|
+
return this.#cachedComputedText;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// If the match is top-level, i.e. is an outermost sub-expression in the property value, count the number of outermost
|
|
313
|
+
// sub-expressions after applying any potential substitutions.
|
|
314
|
+
get topLevelValueCount(): number {
|
|
315
|
+
if (this.match.node.parent?.name !== 'Declaration') {
|
|
316
|
+
// Not a top-level match.
|
|
317
|
+
return 0;
|
|
318
|
+
}
|
|
319
|
+
const computedText = this.computedText;
|
|
320
|
+
if (computedText === '') {
|
|
321
|
+
// Substitutions elided the match altogether.
|
|
322
|
+
return 0;
|
|
323
|
+
}
|
|
324
|
+
if (this.#topLevelValueCount === null) {
|
|
325
|
+
// computedText may be null, in which case the match text was not replaced.
|
|
326
|
+
this.#topLevelValueCount =
|
|
327
|
+
ASTUtils
|
|
328
|
+
.siblings(ASTUtils.declValue(tokenizeDeclaration('--p', computedText ?? this.match.text)?.tree ?? null))
|
|
329
|
+
.length;
|
|
330
|
+
}
|
|
331
|
+
return this.#topLevelValueCount;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* This class constructs the "computed" text from the input property text, i.e., it will strip comments and substitute
|
|
337
|
+
* var() functions if possible. It's intended for use during the bottom-up tree matching process. The original text is
|
|
338
|
+
* not modified. Instead, computed text slices are produced on the fly. During bottom-up matching, the sequence of
|
|
339
|
+
* top-level comments and var() matches will be recorded. This produces an ordered sequence of text pieces that need to
|
|
340
|
+
* be substituted into the original text. When a computed text slice is requested, it is generated by piecing together
|
|
341
|
+
* original and computed slices as required.
|
|
342
|
+
**/
|
|
343
|
+
export class ComputedText {
|
|
344
|
+
readonly #chunks: ComputedTextChunk[] = [];
|
|
345
|
+
readonly text: string;
|
|
346
|
+
readonly #topLevelValueCounts = new Map<string, number>();
|
|
347
|
+
|
|
348
|
+
#sorted = true;
|
|
349
|
+
constructor(text: string) {
|
|
350
|
+
this.text = text;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
clear(): void {
|
|
354
|
+
this.#chunks.splice(0);
|
|
355
|
+
this.#topLevelValueCounts.clear();
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
get chunkCount(): number {
|
|
359
|
+
return this.#chunks.length;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
#sortIfNecessary(): void {
|
|
363
|
+
if (this.#sorted) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
// Sort intervals by offset, with longer intervals first if the offset is identical.
|
|
367
|
+
this.#chunks.sort((a, b) => {
|
|
368
|
+
if (a.offset < b.offset) {
|
|
369
|
+
return -1;
|
|
370
|
+
}
|
|
371
|
+
if (b.offset < a.offset) {
|
|
372
|
+
return 1;
|
|
373
|
+
}
|
|
374
|
+
if (a.end > b.end) {
|
|
375
|
+
return -1;
|
|
376
|
+
}
|
|
377
|
+
if (a.end < b.end) {
|
|
378
|
+
return 1;
|
|
379
|
+
}
|
|
380
|
+
return 0;
|
|
381
|
+
});
|
|
382
|
+
this.#sorted = true;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// Add another substitutable match. The match will either be appended to the list of existing matches or it will
|
|
386
|
+
// be substituted for the last match(es) if it encompasses them.
|
|
387
|
+
push(match: Match, offset: number): void {
|
|
388
|
+
function hasComputedText(match: Match): match is MatchWithComputedText {
|
|
389
|
+
return Boolean(match.computedText);
|
|
390
|
+
}
|
|
391
|
+
if (!hasComputedText(match) || offset < 0 || offset >= this.text.length) {
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
const chunk = new ComputedTextChunk(match, offset);
|
|
395
|
+
if (chunk.end > this.text.length) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
this.#sorted = false;
|
|
399
|
+
this.#chunks.push(chunk);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
* #range(begin: number, end: number): Generator<ComputedTextChunk> {
|
|
403
|
+
this.#sortIfNecessary();
|
|
404
|
+
let i = this.#chunks.findIndex(c => c.offset >= begin);
|
|
405
|
+
while (i >= 0 && i < this.#chunks.length && this.#chunks[i].end > begin && begin < end) {
|
|
406
|
+
if (this.#chunks[i].end > end) {
|
|
407
|
+
i++;
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
yield this.#chunks[i];
|
|
411
|
+
begin = this.#chunks[i].end;
|
|
412
|
+
while (begin < end && i < this.#chunks.length && this.#chunks[i].offset < begin) {
|
|
413
|
+
i++;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
hasUnresolvedSubstitutions(begin: number, end: number): boolean {
|
|
419
|
+
for (const chunk of this.#range(begin, end)) {
|
|
420
|
+
if (chunk.computedText === null) {
|
|
421
|
+
return true;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
* #getPieces(begin: number, end: number): Generator<string|ComputedTextChunk> {
|
|
428
|
+
for (const chunk of this.#range(begin, end)) {
|
|
429
|
+
const piece = this.text.substring(begin, Math.min(chunk.offset, end));
|
|
430
|
+
yield piece;
|
|
431
|
+
if (end >= chunk.end) {
|
|
432
|
+
yield chunk;
|
|
433
|
+
}
|
|
434
|
+
begin = chunk.end;
|
|
435
|
+
}
|
|
436
|
+
if (begin < end) {
|
|
437
|
+
const piece = this.text.substring(begin, end);
|
|
438
|
+
yield piece;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// Get a slice of the computed text corresponding to the property text in the range [begin, end). The slice may not
|
|
443
|
+
// start within a substitution chunk, e.g., it's invalid to request the computed text for the property value text
|
|
444
|
+
// slice "1px var(--".
|
|
445
|
+
get(begin: number, end: number, substitutionHook?: (match: Match) => string | null): string {
|
|
446
|
+
const pieces: string[] = [];
|
|
447
|
+
const getText = (piece: string|ComputedTextChunk): string => {
|
|
448
|
+
if (typeof piece === 'string') {
|
|
449
|
+
return piece;
|
|
450
|
+
}
|
|
451
|
+
const substitution = substitutionHook?.(piece.match) ?? null;
|
|
452
|
+
if (substitution !== null) {
|
|
453
|
+
return getText(substitution);
|
|
454
|
+
}
|
|
455
|
+
return piece.computedText ?? piece.match.text;
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
for (const piece of this.#getPieces(begin, end)) {
|
|
459
|
+
const text = getText(piece);
|
|
460
|
+
if (text.length === 0) {
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
if (pieces.length > 0 && requiresSpace(pieces[pieces.length - 1], text)) {
|
|
464
|
+
pieces.push(' ');
|
|
465
|
+
}
|
|
466
|
+
pieces.push(text);
|
|
467
|
+
}
|
|
468
|
+
return pieces.join('');
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
#countTopLevelValuesInStringPiece(piece: string): number {
|
|
472
|
+
let count = this.#topLevelValueCounts.get(piece);
|
|
473
|
+
if (count === undefined) {
|
|
474
|
+
count = ASTUtils.siblings(ASTUtils.declValue(tokenizeDeclaration('--p', piece)?.tree ?? null)).length;
|
|
475
|
+
this.#topLevelValueCounts.set(piece, count);
|
|
476
|
+
}
|
|
477
|
+
return count;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
countTopLevelValues(begin: number, end: number): number {
|
|
481
|
+
const pieces = Array.from(this.#getPieces(begin, end));
|
|
482
|
+
const counts = pieces.map(
|
|
483
|
+
chunk =>
|
|
484
|
+
(chunk instanceof ComputedTextChunk ? chunk.topLevelValueCount :
|
|
485
|
+
this.#countTopLevelValuesInStringPiece(chunk)));
|
|
486
|
+
const count = counts.reduce((sum, v) => sum + v, 0);
|
|
487
|
+
return count;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* This function determines whether concatenating two pieces of text requires any spacing in between. For example, there
|
|
493
|
+
* shouldn't be any space between 'var' and '(', but there should be a space between '1px' and 'solid'. The node
|
|
494
|
+
* sequences that make up the pieces of text may contain non-text nodes/trees. Any such element in between the texts is
|
|
495
|
+
* ignored for the spacing requirement.
|
|
496
|
+
**/
|
|
497
|
+
export function requiresSpace(a: string, b: string): boolean;
|
|
498
|
+
export function requiresSpace(a: Node[], b: Node[]): boolean;
|
|
499
|
+
export function requiresSpace(a: Node[]|string|undefined, b: Node[]|string|undefined): boolean {
|
|
500
|
+
const tail = Array.isArray(a) ? a.findLast(node => node.textContent)?.textContent : a;
|
|
501
|
+
const head = Array.isArray(b) ? b.find(node => node.textContent)?.textContent : b;
|
|
502
|
+
const trailingChar = tail ? tail[tail.length - 1] : '';
|
|
503
|
+
const leadingChar = head ? head[0] : '';
|
|
504
|
+
|
|
505
|
+
const noSpaceAfter = ['', '(', '{', '}', ';', '['];
|
|
506
|
+
const noSpaceBefore = ['', '(', ')', ',', ':', '*', '{', ';', ']'];
|
|
507
|
+
return !/\s/.test(trailingChar) && !/\s/.test(leadingChar) && !noSpaceAfter.includes(trailingChar) &&
|
|
508
|
+
!noSpaceBefore.includes(leadingChar);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
export const CSSControlMap = Map<string, HTMLElement[]>;
|
|
512
|
+
export type CSSControlMap = Map<string, HTMLElement[]>;
|
|
513
|
+
export namespace ASTUtils {
|
|
514
|
+
export function siblings(node: CodeMirror.SyntaxNode|null): CodeMirror.SyntaxNode[] {
|
|
515
|
+
const result = [];
|
|
516
|
+
while (node) {
|
|
517
|
+
result.push(node);
|
|
518
|
+
node = node.nextSibling;
|
|
519
|
+
}
|
|
520
|
+
return result;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
export function children(node: CodeMirror.SyntaxNode|null): CodeMirror.SyntaxNode[] {
|
|
524
|
+
return siblings(node?.firstChild ?? null);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
export function range(node: CodeMirror.SyntaxNode[]):
|
|
528
|
+
[CodeMirror.SyntaxNode|undefined, CodeMirror.SyntaxNode|undefined] {
|
|
529
|
+
return [node[0], node[node.length - 1]];
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
export function declValue(node: CodeMirror.SyntaxNode|null): CodeMirror.SyntaxNode|null {
|
|
533
|
+
if (node?.name !== 'Declaration') {
|
|
534
|
+
return null;
|
|
535
|
+
}
|
|
536
|
+
return children(node).find(node => node.name === ':')?.nextSibling ?? null;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
export function* stripComments(nodes: CodeMirror.SyntaxNode[]): Generator<CodeMirror.SyntaxNode> {
|
|
540
|
+
for (const node of nodes) {
|
|
541
|
+
if (node.type.name !== 'Comment') {
|
|
542
|
+
yield node;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
export function split(nodes: CodeMirror.SyntaxNode[]): CodeMirror.SyntaxNode[][] {
|
|
548
|
+
const result = [];
|
|
549
|
+
let current = [];
|
|
550
|
+
for (const node of nodes) {
|
|
551
|
+
if (node.name === ',') {
|
|
552
|
+
result.push(current);
|
|
553
|
+
current = [];
|
|
554
|
+
} else {
|
|
555
|
+
current.push(node);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
if (nodes.length > 0) {
|
|
559
|
+
result.push(current);
|
|
560
|
+
}
|
|
561
|
+
return result;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
export function callArgs(node: CodeMirror.SyntaxNode|null): CodeMirror.SyntaxNode[][] {
|
|
565
|
+
const args = children(node?.getChild('ArgList') ?? null);
|
|
566
|
+
const openParen = args.splice(0, 1)[0];
|
|
567
|
+
const closingParen = args.pop();
|
|
568
|
+
|
|
569
|
+
if (openParen?.name !== '(' || closingParen?.name !== ')') {
|
|
570
|
+
return [];
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
return split(args);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
export function equals(a: CodeMirror.SyntaxNode, b: CodeMirror.SyntaxNode): boolean {
|
|
577
|
+
return a.name === b.name && a.from === b.from && a.to === b.to;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
function declaration(rule: string): CodeMirror.SyntaxNode|null {
|
|
582
|
+
const cssParser = CodeMirror.css.cssLanguage.parser;
|
|
583
|
+
return cssParser.parse(rule).topNode.getChild('RuleSet')?.getChild('Block')?.getChild('Declaration') ?? null;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
export function tokenizeDeclaration(propertyName: string, propertyValue: string): SyntaxTree|null {
|
|
587
|
+
const name = tokenizePropertyName(propertyName);
|
|
588
|
+
if (!name) {
|
|
589
|
+
return null;
|
|
590
|
+
}
|
|
591
|
+
const rule = `*{${name}: ${propertyValue};}`;
|
|
592
|
+
const decl = declaration(rule);
|
|
593
|
+
if (!decl || decl.type.isError) {
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
const childNodes = ASTUtils.children(decl);
|
|
598
|
+
if (childNodes.length < 2) {
|
|
599
|
+
return null;
|
|
600
|
+
}
|
|
601
|
+
const [varName, colon, tree] = childNodes;
|
|
602
|
+
if (!varName || varName.type.isError || !colon || colon.type.isError || tree?.type.isError) {
|
|
603
|
+
return null;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
// It's possible that there are nodes following the declaration when there are comments or syntax errors. We want to
|
|
607
|
+
// render any comments, so pick up any trailing nodes following the declaration excluding the final semicolon and
|
|
608
|
+
// brace.
|
|
609
|
+
const trailingNodes = ASTUtils.siblings(decl).slice(1);
|
|
610
|
+
const [semicolon, brace] = trailingNodes.splice(trailingNodes.length - 2, 2);
|
|
611
|
+
if (semicolon?.name !== ';' && brace?.name !== '}') {
|
|
612
|
+
return null;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
const ast = new SyntaxTree(propertyValue, rule, decl, name, trailingNodes);
|
|
616
|
+
if (ast.text(varName) !== name || colon.name !== ':') {
|
|
617
|
+
return null;
|
|
618
|
+
}
|
|
619
|
+
return ast;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
export function tokenizePropertyName(name: string): string|null {
|
|
623
|
+
const rule = `*{${name}: inherit;}`;
|
|
624
|
+
const decl = declaration(rule);
|
|
625
|
+
if (!decl || decl.type.isError) {
|
|
626
|
+
return null;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
const propertyName = decl.getChild('PropertyName') ?? decl.getChild('VariableName');
|
|
630
|
+
if (!propertyName) {
|
|
631
|
+
return null;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
return nodeText(propertyName, rule);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
export function matchDeclaration(name: string, value: string, matchers: Array<Matcher<Match>>): BottomUpTreeMatching|
|
|
638
|
+
null {
|
|
639
|
+
const ast = tokenizeDeclaration(name, value);
|
|
640
|
+
const matchedResult = ast && BottomUpTreeMatching.walk(ast, matchers);
|
|
641
|
+
ast?.trailingNodes.forEach(n => matchedResult?.matchText(n));
|
|
642
|
+
return matchedResult;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
export class TreeSearch extends TreeWalker {
|
|
646
|
+
#found: CodeMirror.SyntaxNode|null = null;
|
|
647
|
+
#predicate: (node: CodeMirror.SyntaxNode) => boolean;
|
|
648
|
+
|
|
649
|
+
constructor(ast: SyntaxTree, predicate: (node: CodeMirror.SyntaxNode) => boolean) {
|
|
650
|
+
super(ast);
|
|
651
|
+
this.#predicate = predicate;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
protected override enter({node}: SyntaxNodeRef): boolean {
|
|
655
|
+
if (this.#found) {
|
|
656
|
+
return false;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
if (this.#predicate(node)) {
|
|
660
|
+
this.#found = this.#found ?? node;
|
|
661
|
+
return false;
|
|
662
|
+
}
|
|
663
|
+
return true;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
static find(ast: SyntaxTree, predicate: (node: CodeMirror.SyntaxNode) => boolean): CodeMirror.SyntaxNode|null {
|
|
667
|
+
return TreeSearch.walk(ast, predicate).#found;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
static findAll(ast: SyntaxTree, predicate: (node: CodeMirror.SyntaxNode) => boolean): CodeMirror.SyntaxNode[] {
|
|
671
|
+
const foundNodes: CodeMirror.SyntaxNode[] = [];
|
|
672
|
+
TreeSearch.walk(ast, (node: CodeMirror.SyntaxNode) => {
|
|
673
|
+
if (predicate(node)) {
|
|
674
|
+
foundNodes.push(node);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
return false;
|
|
678
|
+
});
|
|
679
|
+
return foundNodes;
|
|
680
|
+
}
|
|
681
|
+
}
|