chrome-devtools-frontend 1.0.950971 → 1.0.952403
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/config/gni/devtools_grd_files.gni +6 -3
- package/extension-api/ExtensionAPI.d.ts +1 -1
- package/front_end/.eslintrc.js +6 -0
- package/front_end/Tests.js +10 -0
- package/front_end/core/common/App.ts +0 -3
- package/front_end/core/common/AppProvider.ts +0 -3
- package/front_end/core/common/JavaScriptMetaData.ts +0 -3
- package/front_end/core/common/QueryParamHandler.ts +0 -3
- package/front_end/core/common/Runnable.ts +0 -3
- package/front_end/core/common/SimpleHistoryManager.ts +0 -3
- package/front_end/core/host/UserMetrics.ts +2 -1
- package/front_end/core/i18n/locales/en-US.json +186 -183
- package/front_end/core/i18n/locales/en-XL.json +186 -183
- package/front_end/core/root/Runtime.ts +4 -12
- package/front_end/core/sdk/CSSRule.ts +1 -1
- package/front_end/core/sdk/DOMModel.ts +12 -37
- package/front_end/core/sdk/OverlayModel.ts +18 -34
- package/front_end/core/sdk/OverlayPersistentHighlighter.ts +0 -12
- package/front_end/core/sdk/PageResourceLoader.ts +2 -1
- package/front_end/core/sdk/RuntimeModel.ts +0 -1
- package/front_end/core/sdk/SourceMap.ts +1 -1
- package/front_end/core/sdk/TracingManager.ts +0 -3
- package/front_end/entrypoints/formatter_worker/AcornTokenizer.ts +39 -39
- package/front_end/entrypoints/formatter_worker/CSSFormatter.ts +54 -54
- package/front_end/entrypoints/formatter_worker/ESTreeWalker.ts +20 -20
- package/front_end/entrypoints/formatter_worker/FormattedContentBuilder.ts +54 -54
- package/front_end/entrypoints/formatter_worker/HTMLFormatter.ts +145 -144
- package/front_end/entrypoints/formatter_worker/JavaScriptFormatter.ts +40 -40
- package/front_end/entrypoints/heap_snapshot_worker/AllocationProfile.ts +65 -70
- package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +203 -204
- package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshotLoader.ts +109 -108
- package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshotWorkerDispatcher.ts +18 -18
- package/front_end/entrypoints/inspector_main/InspectorMain.ts +30 -30
- package/front_end/entrypoints/inspector_main/RenderingOptions.ts +25 -25
- package/front_end/entrypoints/main/ExecutionContextSelector.ts +52 -55
- package/front_end/entrypoints/main/MainImpl.ts +49 -49
- package/front_end/entrypoints/node_app/NodeConnectionsPanel.ts +43 -43
- package/front_end/entrypoints/node_app/NodeMain.ts +38 -38
- package/front_end/generated/InspectorBackendCommands.js +5 -1
- package/front_end/generated/protocol.d.ts +16 -0
- package/front_end/legacy/legacy-defs.d.ts +0 -21
- package/front_end/models/bindings/CSSWorkspaceBinding.ts +0 -3
- package/front_end/models/bindings/DebuggerLanguagePlugins.ts +1 -2
- package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +1 -4
- package/front_end/models/bindings/FileUtils.ts +0 -4
- package/front_end/models/bindings/IgnoreListManager.ts +1 -2
- package/front_end/models/bindings/NetworkProject.ts +1 -2
- package/front_end/models/extensions/ExtensionAPI.ts +2 -2
- package/front_end/models/extensions/ExtensionTraceProvider.ts +0 -3
- package/front_end/models/heap_snapshot_model/HeapSnapshotModel.ts +1 -1
- package/front_end/models/issues_manager/ClientHintIssue.ts +95 -0
- package/front_end/models/issues_manager/ContentSecurityPolicyIssue.ts +6 -6
- package/front_end/models/issues_manager/ContrastCheckTrigger.ts +15 -15
- package/front_end/models/issues_manager/CorsIssue.ts +9 -9
- package/front_end/models/issues_manager/CrossOriginEmbedderPolicyIssue.ts +5 -5
- package/front_end/models/issues_manager/DeprecationIssue.ts +7 -7
- package/front_end/models/issues_manager/GenericIssue.ts +5 -5
- package/front_end/models/issues_manager/HeavyAdIssue.ts +5 -5
- package/front_end/models/issues_manager/Issue.ts +10 -10
- package/front_end/models/issues_manager/IssueResolver.ts +11 -10
- package/front_end/models/issues_manager/IssuesManager.ts +61 -56
- package/front_end/models/issues_manager/LowTextContrastIssue.ts +4 -4
- package/front_end/models/issues_manager/MixedContentIssue.ts +7 -7
- package/front_end/models/issues_manager/NavigatorUserAgentIssue.ts +7 -7
- package/front_end/models/issues_manager/QuirksModeIssue.ts +4 -4
- package/front_end/models/issues_manager/SameSiteCookieIssue.ts +17 -18
- package/front_end/models/issues_manager/SharedArrayBufferIssue.ts +5 -5
- package/front_end/models/issues_manager/SourceFrameIssuesManager.ts +32 -31
- package/front_end/models/issues_manager/TrustedWebActivityIssue.ts +5 -5
- package/front_end/models/issues_manager/WasmCrossOriginModuleSharingIssue.ts +5 -5
- package/front_end/models/issues_manager/descriptions/clientHintMetaTagAllowListInvalidOrigin.md +4 -0
- package/front_end/models/issues_manager/descriptions/clientHintMetaTagModifiedHTML.md +4 -0
- package/front_end/models/issues_manager/issues_manager.ts +2 -0
- package/front_end/models/timeline_model/TimelineModel.ts +1 -1
- package/front_end/models/timeline_model/TracingLayerTree.ts +0 -1
- package/front_end/panels/accessibility/ARIAMetadata.ts +0 -1
- package/front_end/panels/accessibility/AXBreadcrumbsPane.ts +2 -2
- package/front_end/panels/accessibility/AccessibilityNodeView.ts +1 -2
- package/front_end/panels/animation/AnimationTimeline.ts +0 -1
- package/front_end/panels/application/ApplicationPanelCacheSection.ts +3 -4
- package/front_end/panels/application/ServiceWorkerUpdateCycleView.ts +0 -2
- package/front_end/panels/application/StorageView.ts +2 -6
- package/front_end/panels/application/{BackForwardCacheStrings.ts → components/BackForwardCacheStrings.ts} +2 -2
- package/front_end/panels/application/{BackForwardCacheView.ts → components/BackForwardCacheView.ts} +96 -62
- package/front_end/panels/application/components/EndpointsGrid.ts +12 -12
- package/front_end/panels/application/components/FrameDetailsView.ts +108 -110
- package/front_end/panels/application/components/OriginTrialTreeView.ts +45 -45
- package/front_end/panels/application/components/PermissionsPolicySection.ts +19 -19
- package/front_end/panels/application/components/ReportsGrid.ts +30 -30
- package/front_end/panels/application/components/StackTrace.ts +48 -47
- package/front_end/panels/application/components/TrustTokensView.ts +31 -31
- package/front_end/panels/application/{backForwardCacheView.css → components/backForwardCacheView.css} +9 -0
- package/front_end/panels/application/components/components.ts +2 -0
- package/front_end/panels/console/ConsoleView.ts +1 -1
- package/front_end/panels/console/ConsoleViewMessage.ts +1 -25
- package/front_end/panels/console/consoleView.css +5 -0
- package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +41 -52
- package/front_end/panels/css_overview/CSSOverviewController.ts +2 -2
- package/front_end/panels/css_overview/CSSOverviewPanel.ts +18 -27
- package/front_end/panels/css_overview/CSSOverviewProcessingView.ts +2 -2
- package/front_end/panels/css_overview/CSSOverviewSidebarPanel.ts +6 -6
- package/front_end/panels/css_overview/components/CSSOverviewStartView.ts +4 -4
- package/front_end/panels/elements/ComputedStyleModel.ts +2 -2
- package/front_end/panels/elements/ElementsPanel.ts +1 -5
- package/front_end/panels/elements/ElementsTreeElement.ts +2 -6
- package/front_end/panels/elements/ElementsTreeOutline.ts +2 -2
- package/front_end/panels/elements/StylesSidebarPane.ts +1 -1
- package/front_end/panels/elements/components/AccessibilityTreeNode.ts +17 -17
- package/front_end/panels/elements/components/AdornerManager.ts +21 -21
- package/front_end/panels/elements/components/AdornerSettingsPane.ts +14 -14
- package/front_end/panels/elements/components/CSSQuery.ts +16 -16
- package/front_end/panels/elements/components/ComputedStyleProperty.ts +14 -14
- package/front_end/panels/elements/components/ComputedStyleTrace.ts +15 -15
- package/front_end/panels/elements/components/ElementsBreadcrumbs.ts +78 -78
- package/front_end/panels/elements/components/ElementsPanelLink.ts +16 -16
- package/front_end/panels/elements/components/LayoutPane.ts +47 -47
- package/front_end/panels/elements/components/NodeText.ts +18 -18
- package/front_end/panels/elements/components/QueryContainer.ts +40 -40
- package/front_end/panels/elements/components/StylePropertyEditor.ts +18 -18
- package/front_end/panels/emulation/components/DeviceSizeInputElement.ts +4 -4
- package/front_end/panels/event_listeners/EventListenersUtils.ts +2 -1
- package/front_end/panels/issues/AffectedBlockedByResponseView.ts +4 -4
- package/front_end/panels/issues/AffectedCookiesView.ts +4 -5
- package/front_end/panels/issues/AffectedDirectivesView.ts +19 -19
- package/front_end/panels/issues/AffectedDocumentsInQuirksModeView.ts +7 -8
- package/front_end/panels/issues/AffectedElementsView.ts +4 -4
- package/front_end/panels/issues/AffectedElementsWithLowContrastView.ts +7 -8
- package/front_end/panels/issues/AffectedHeavyAdView.ts +8 -8
- package/front_end/panels/issues/AffectedResourcesView.ts +25 -26
- package/front_end/panels/issues/AffectedSharedArrayBufferIssueDetailsView.ts +8 -8
- package/front_end/panels/issues/AffectedSourcesView.ts +4 -4
- package/front_end/panels/issues/AffectedTrustedWebActivityIssueDetailsView.ts +4 -4
- package/front_end/panels/issues/AttributionReportingIssueDetailsView.ts +17 -17
- package/front_end/panels/issues/CSPViolationsListView.ts +22 -23
- package/front_end/panels/issues/CSPViolationsView.ts +17 -17
- package/front_end/panels/issues/ComboBoxOfCheckBoxes.ts +13 -13
- package/front_end/panels/issues/CorsIssueDetailsView.ts +23 -23
- package/front_end/panels/issues/GenericIssueDetailsView.ts +4 -4
- package/front_end/panels/issues/HiddenIssuesRow.ts +7 -7
- package/front_end/panels/issues/IssueAggregator.ts +95 -95
- package/front_end/panels/issues/IssueKindView.ts +14 -14
- package/front_end/panels/issues/IssueView.ts +98 -98
- package/front_end/panels/issues/IssuesPane.ts +102 -102
- package/front_end/panels/issues/WasmCrossOriginModuleSharingAffectedResourcesView.ts +5 -5
- package/front_end/panels/issues/components/HideIssuesMenu.ts +10 -10
- package/front_end/panels/layer_viewer/Layers3DView.ts +3 -9
- package/front_end/panels/lighthouse/LighthouseController.ts +4 -5
- package/front_end/panels/media/PlayerListView.ts +160 -97
- package/front_end/panels/media/PlayerMessagesView.ts +1 -0
- package/front_end/panels/media/TickingFlameChart.ts +1 -2
- package/front_end/panels/media/playerListView.css +58 -0
- package/front_end/panels/network/NetworkLogView.ts +2 -6
- package/front_end/panels/network/NetworkLogViewColumns.ts +1 -1
- package/front_end/panels/network/NetworkWaterfallColumn.ts +2 -4
- package/front_end/panels/network/components/RequestTrustTokensView.ts +40 -40
- package/front_end/panels/network/components/WebBundleInfoView.ts +9 -9
- package/front_end/panels/performance_monitor/PerformanceMonitor.ts +92 -37
- package/front_end/panels/performance_monitor/performanceMonitor.css +32 -0
- package/front_end/panels/profiler/HeapProfileView.ts +1 -1
- package/front_end/panels/profiler/HeapSnapshotDataGrids.ts +0 -1
- package/front_end/panels/profiler/HeapSnapshotView.ts +1 -2
- package/front_end/panels/protocol_monitor/ProtocolMonitor.ts +2 -2
- package/front_end/panels/search/SearchConfig.ts +0 -6
- package/front_end/panels/security/SecurityModel.ts +2 -4
- package/front_end/panels/security/SecurityPanel.ts +2 -2
- package/front_end/panels/settings/KeybindsSettingsTab.ts +4 -0
- package/front_end/panels/settings/components/SyncSection.ts +14 -14
- package/front_end/panels/settings/emulation/components/UserAgentClientHintsForm.ts +96 -96
- package/front_end/panels/sources/BreakpointEditDialog.ts +4 -3
- package/front_end/panels/sources/FilteredUISourceCodeListProvider.ts +2 -2
- package/front_end/panels/sources/NavigatorView.ts +4 -10
- package/front_end/panels/sources/ScopeChainSidebarPane.ts +2 -3
- package/front_end/panels/sources/SourceMapNamesResolver.ts +3 -3
- package/front_end/panels/sources/SourcesPanel.ts +1 -3
- package/front_end/panels/sources/SourcesView.ts +0 -3
- package/front_end/panels/sources/TabbedEditorContainer.ts +1 -4
- package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +2 -5
- package/front_end/panels/timeline/TimelineFlameChartNetworkDataProvider.ts +0 -1
- package/front_end/panels/timeline/TimelineFlameChartView.ts +1 -2
- package/front_end/panels/timeline/TimelineLoader.ts +0 -3
- package/front_end/panels/timeline/TimelinePanel.ts +2 -3
- package/front_end/panels/timeline/TimelineTreeView.ts +1 -1
- package/front_end/panels/timeline/TimelineUIUtils.ts +1 -1
- package/front_end/panels/timeline/components/WebVitalsLane.ts +77 -76
- package/front_end/panels/timeline/components/WebVitalsTimeline.ts +133 -133
- package/front_end/panels/timeline/components/WebVitalsTooltip.ts +9 -9
- package/front_end/panels/webauthn/WebauthnPane.ts +203 -205
- package/front_end/third_party/codemirror.next/bundle.ts +3 -3
- package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
- package/front_end/third_party/codemirror.next/chunk/markdown.js +2 -1
- package/front_end/third_party/codemirror.next/codemirror.next.d.ts +10 -1
- package/front_end/third_party/codemirror.next/codemirror.next.js +2 -1
- package/front_end/third_party/codemirror.next/package.json +3 -3
- package/front_end/third_party/diff/DiffWrapper.ts +7 -0
- package/front_end/third_party/puppeteer/package/README.md +11 -11
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api-docs-entry.d.ts +4 -5
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/AriaQueryHandler.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/AriaQueryHandler.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Browser.d.ts +4 -6
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/BrowserConnector.d.ts +1 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Connection.d.ts +1 -4
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Coverage.d.ts +1 -4
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/DOMWorld.d.ts +9 -7
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/DOMWorld.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/DOMWorld.js +21 -12
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/DOMWorld.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Dialog.d.ts +1 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/EvalTypes.d.ts +1 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/ExecutionContext.d.ts +3 -5
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/FileChooser.d.ts +1 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/FrameManager.d.ts +8 -10
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/FrameManager.js +3 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/FrameManager.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPRequest.d.ts +50 -11
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPRequest.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPRequest.js +70 -33
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPRequest.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPResponse.d.ts +12 -5
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPResponse.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPResponse.js +25 -5
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPResponse.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Input.d.ts +2 -4
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/JSHandle.d.ts +39 -6
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/JSHandle.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/JSHandle.js +36 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/JSHandle.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/LifecycleWatcher.d.ts +3 -4
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/LifecycleWatcher.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/LifecycleWatcher.js +2 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/LifecycleWatcher.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkEventManager.d.ts +46 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkEventManager.d.ts.map +1 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkEventManager.js +124 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkEventManager.js.map +1 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkManager.d.ts +27 -10
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkManager.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkManager.js +144 -74
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkManager.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Puppeteer.d.ts +5 -6
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/QueryHandler.d.ts +1 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Target.d.ts +4 -6
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/WebWorker.d.ts +3 -5
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserRunner.d.ts +4 -5
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserRunner.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserRunner.js +43 -17
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserRunner.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/LaunchOptions.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Launcher.d.ts +1 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Launcher.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Launcher.js +101 -34
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Launcher.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/NodeWebSocketTransport.d.ts +1 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/PipeTransport.d.ts +1 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Puppeteer.d.ts +5 -7
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api-docs-entry.d.ts +4 -5
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/AriaQueryHandler.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/AriaQueryHandler.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Browser.d.ts +4 -6
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Browser.js +2 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/BrowserConnector.d.ts +1 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/BrowserConnector.js +3 -5
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Connection.d.ts +1 -4
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Coverage.d.ts +1 -4
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Coverage.js +1 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/DOMWorld.d.ts +9 -7
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/DOMWorld.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/DOMWorld.js +24 -17
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/DOMWorld.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Dialog.d.ts +1 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/EvalTypes.d.ts +1 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/ExecutionContext.d.ts +3 -5
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/FileChooser.d.ts +1 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/FrameManager.d.ts +8 -10
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/FrameManager.js +7 -8
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/FrameManager.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPRequest.d.ts +50 -11
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPRequest.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPRequest.js +70 -34
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPRequest.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPResponse.d.ts +12 -5
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPResponse.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPResponse.js +26 -7
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPResponse.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Input.d.ts +2 -4
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/JSHandle.d.ts +39 -6
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/JSHandle.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/JSHandle.js +38 -4
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/JSHandle.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/LifecycleWatcher.d.ts +3 -4
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/LifecycleWatcher.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/LifecycleWatcher.js +4 -4
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/LifecycleWatcher.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkEventManager.d.ts +46 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkEventManager.d.ts.map +1 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkEventManager.js +120 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkEventManager.js.map +1 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkManager.d.ts +27 -10
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkManager.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkManager.js +144 -75
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkManager.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Page.js +12 -14
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Puppeteer.d.ts +5 -6
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Puppeteer.js +3 -4
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/QueryHandler.d.ts +1 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Target.d.ts +4 -6
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/WebWorker.d.ts +3 -5
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/WebWorker.js +1 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/helper.js +3 -5
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/initialize-node.js +1 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserFetcher.js +10 -12
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserRunner.d.ts +4 -5
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserRunner.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserRunner.js +43 -20
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserRunner.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/LaunchOptions.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Launcher.d.ts +1 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Launcher.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Launcher.js +104 -40
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Launcher.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/NodeWebSocketTransport.d.ts +1 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/PipeTransport.d.ts +1 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/PipeTransport.js +1 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Puppeteer.d.ts +5 -7
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Puppeteer.js +1 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/install.js +3 -5
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node-puppeteer-core.js +1 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node.js +1 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/web.js +1 -2
- package/front_end/third_party/puppeteer/package/lib/types.d.ts +173 -36
- package/front_end/third_party/puppeteer/package/package.json +3 -3
- package/front_end/ui/components/adorners/Adorner.ts +2 -2
- package/front_end/ui/components/buttons/Button.ts +9 -9
- package/front_end/ui/components/data_grid/DataGrid.ts +64 -64
- package/front_end/ui/components/data_grid/DataGridController.ts +22 -22
- package/front_end/ui/components/data_grid/DataGridUtils.ts +3 -0
- package/front_end/ui/components/diff_view/DiffView.ts +6 -6
- package/front_end/ui/components/expandable_list/ExpandableList.ts +5 -5
- package/front_end/ui/components/icon_button/Icon.ts +4 -4
- package/front_end/ui/components/icon_button/IconButton.ts +4 -4
- package/front_end/ui/components/issue_counter/IssueCounter.ts +3 -3
- package/front_end/ui/components/issue_counter/IssueLinkIcon.ts +11 -11
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspector.ts +50 -50
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspectorController.ts +6 -6
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspectorPane.ts +4 -4
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryNavigator.ts +12 -12
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryValueInterpreter.ts +11 -11
- package/front_end/ui/components/linear_memory_inspector/LinearMemoryViewer.ts +40 -39
- package/front_end/ui/components/linear_memory_inspector/ValueInterpreterDisplay.ts +18 -18
- package/front_end/ui/components/linear_memory_inspector/ValueInterpreterSettings.ts +6 -6
- package/front_end/ui/components/linkifier/LinkifierImpl.ts +4 -4
- package/front_end/ui/components/markdown_view/MarkdownImage.ts +5 -5
- package/front_end/ui/components/markdown_view/MarkdownLink.ts +2 -2
- package/front_end/ui/components/markdown_view/MarkdownView.ts +4 -5
- package/front_end/ui/components/panel_feedback/FeedbackButton.ts +2 -2
- package/front_end/ui/components/panel_feedback/PanelFeedback.ts +2 -2
- package/front_end/ui/components/panel_feedback/PreviewToggle.ts +4 -4
- package/front_end/ui/components/render_coordinator/RenderCoordinator.ts +22 -22
- package/front_end/ui/components/report_view/ReportView.ts +16 -16
- package/front_end/ui/components/request_link_icon/RequestLinkIcon.ts +14 -14
- package/front_end/ui/components/settings/SettingCheckbox.ts +5 -5
- package/front_end/ui/components/survey_link/SurveyLink.ts +8 -8
- package/front_end/ui/components/text_editor/TextEditor.ts +9 -9
- package/front_end/ui/components/text_editor/cursor_tooltip.ts +7 -1
- package/front_end/ui/components/text_prompt/TextPrompt.ts +18 -18
- package/front_end/ui/components/tree_outline/TreeOutline.ts +69 -70
- package/front_end/ui/legacy/ContextFlavorListener.ts +0 -4
- package/front_end/ui/legacy/ContextMenu.ts +2 -3
- package/front_end/ui/legacy/InspectorView.ts +1 -1
- package/front_end/ui/legacy/ReportView.ts +3 -4
- package/front_end/ui/legacy/SearchableView.ts +14 -6
- package/front_end/ui/legacy/SplitWidget.ts +2 -3
- package/front_end/ui/legacy/SuggestBox.ts +0 -3
- package/front_end/ui/legacy/TextPrompt.ts +1 -1
- package/front_end/ui/legacy/UIUtils.ts +1 -1
- package/front_end/ui/legacy/XLink.ts +1 -1
- package/front_end/ui/legacy/components/color_picker/Spectrum.ts +2 -2
- package/front_end/ui/legacy/components/data_grid/DataGrid.ts +9 -9
- package/front_end/ui/legacy/components/data_grid/dataGrid.css +7 -7
- package/front_end/ui/legacy/components/inline_editor/CSSShadowEditor.ts +1 -1
- package/front_end/ui/legacy/components/perf_ui/FlameChart.ts +1 -5
- package/front_end/ui/legacy/components/source_frame/JSONView.ts +1 -1
- package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +13 -13
- package/front_end/ui/legacy/components/source_frame/XMLView.ts +2 -2
- package/front_end/ui/legacy/components/utils/Linkifier.ts +2 -2
- package/front_end/ui/legacy/themeColors.css +2 -0
- package/front_end/ui/legacy/theme_support/theme_support_impl.ts +42 -4
- package/package.json +1 -1
- package/scripts/eslint_rules/lib/use_private_class_members.js +41 -0
- package/scripts/eslint_rules/tests/use_private_class_members_test.js +62 -0
- package/scripts/migration/class-fields/migrate.js +2 -3
- package/scripts/migration/class-fields/migrate.sh +1 -3
- package/scripts/migration/class-fields/package.json +1 -1
- package/config/gni/all_devtools_files.gni +0 -255
- package/scripts/build/devtools_file_hashes.py +0 -82
- package/scripts/devtools_run/devtools_run_cli +0 -49
- package/scripts/devtools_run/package.json +0 -13
- package/scripts/unzip.py +0 -20
- package/scripts/visualize_deps/jquery_svg.html +0 -57
- package/scripts/visualize_deps/run_visualize.js +0 -119
|
@@ -10,107 +10,107 @@ import {AbortTokenization, createTokenizer} from './FormatterWorker.js';
|
|
|
10
10
|
import {JavaScriptFormatter} from './JavaScriptFormatter.js';
|
|
11
11
|
|
|
12
12
|
export class HTMLFormatter {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
readonly #builder: FormattedContentBuilder;
|
|
14
|
+
readonly #jsFormatter: JavaScriptFormatter;
|
|
15
|
+
readonly #cssFormatter: CSSFormatter;
|
|
16
|
+
#text?: string;
|
|
17
|
+
#lineEndings?: number[];
|
|
18
|
+
#model?: HTMLModel;
|
|
19
19
|
|
|
20
20
|
constructor(builder: FormattedContentBuilder) {
|
|
21
|
-
this
|
|
22
|
-
this
|
|
23
|
-
this
|
|
21
|
+
this.#builder = builder;
|
|
22
|
+
this.#jsFormatter = new JavaScriptFormatter(builder);
|
|
23
|
+
this.#cssFormatter = new CSSFormatter(builder);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
format(text: string, lineEndings: number[]): void {
|
|
27
|
-
this
|
|
28
|
-
this
|
|
29
|
-
this
|
|
30
|
-
this
|
|
27
|
+
this.#text = text;
|
|
28
|
+
this.#lineEndings = lineEndings;
|
|
29
|
+
this.#model = new HTMLModel(text);
|
|
30
|
+
this.#walk(this.#model.document());
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
if (!this
|
|
33
|
+
#formatTokensTill(element: FormatterElement, offset: number): void {
|
|
34
|
+
if (!this.#model) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
let nextToken = this
|
|
38
|
+
let nextToken = this.#model.peekToken();
|
|
39
39
|
while (nextToken && nextToken.startOffset < offset) {
|
|
40
|
-
const token = (this
|
|
41
|
-
this
|
|
42
|
-
nextToken = this
|
|
40
|
+
const token = (this.#model.nextToken() as Token);
|
|
41
|
+
this.#formatToken(element, token);
|
|
42
|
+
nextToken = this.#model.peekToken();
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
#walk(element: FormatterElement): void {
|
|
47
47
|
if (!element.openTag || !element.closeTag) {
|
|
48
48
|
throw new Error('Element is missing open or close tag');
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
if (element.parent) {
|
|
52
|
-
this
|
|
52
|
+
this.#formatTokensTill(element.parent, element.openTag.startOffset);
|
|
53
53
|
}
|
|
54
|
-
this
|
|
55
|
-
this
|
|
56
|
-
this
|
|
54
|
+
this.#beforeOpenTag(element);
|
|
55
|
+
this.#formatTokensTill(element, element.openTag.endOffset);
|
|
56
|
+
this.#afterOpenTag(element);
|
|
57
57
|
for (let i = 0; i < element.children.length; ++i) {
|
|
58
|
-
this
|
|
58
|
+
this.#walk(element.children[i]);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
this
|
|
62
|
-
this
|
|
63
|
-
this
|
|
64
|
-
this
|
|
61
|
+
this.#formatTokensTill(element, element.closeTag.startOffset);
|
|
62
|
+
this.#beforeCloseTag(element);
|
|
63
|
+
this.#formatTokensTill(element, element.closeTag.endOffset);
|
|
64
|
+
this.#afterCloseTag(element);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
if (!this
|
|
67
|
+
#beforeOpenTag(element: FormatterElement): void {
|
|
68
|
+
if (!this.#model) {
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
if (!element.children.length || element === this
|
|
72
|
+
if (!element.children.length || element === this.#model.document()) {
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
|
-
this
|
|
75
|
+
this.#builder.addNewLine();
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
if (!this
|
|
78
|
+
#afterOpenTag(element: FormatterElement): void {
|
|
79
|
+
if (!this.#model) {
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
if (!element.children.length || element === this
|
|
83
|
+
if (!element.children.length || element === this.#model.document()) {
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
|
-
this
|
|
87
|
-
this
|
|
86
|
+
this.#builder.increaseNestingLevel();
|
|
87
|
+
this.#builder.addNewLine();
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
if (!this
|
|
90
|
+
#beforeCloseTag(element: FormatterElement): void {
|
|
91
|
+
if (!this.#model) {
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
if (!element.children.length || element === this
|
|
95
|
+
if (!element.children.length || element === this.#model.document()) {
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
this
|
|
99
|
-
this
|
|
98
|
+
this.#builder.decreaseNestingLevel();
|
|
99
|
+
this.#builder.addNewLine();
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
this
|
|
102
|
+
#afterCloseTag(_element: FormatterElement): void {
|
|
103
|
+
this.#builder.addNewLine();
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
#formatToken(element: FormatterElement, token: Token): void {
|
|
107
107
|
if (Platform.StringUtilities.isWhitespace(token.value)) {
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
110
|
if (hasTokenInSet(token.type, 'comment') || hasTokenInSet(token.type, 'meta')) {
|
|
111
|
-
this
|
|
112
|
-
this
|
|
113
|
-
this
|
|
111
|
+
this.#builder.addNewLine();
|
|
112
|
+
this.#builder.addToken(token.value.trim(), token.startOffset);
|
|
113
|
+
this.#builder.addNewLine();
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -121,33 +121,33 @@ export class HTMLFormatter {
|
|
|
121
121
|
const isBodyToken =
|
|
122
122
|
element.openTag.endOffset <= token.startOffset && token.startOffset < element.closeTag.startOffset;
|
|
123
123
|
if (isBodyToken && element.name === 'style') {
|
|
124
|
-
this
|
|
125
|
-
this
|
|
126
|
-
this
|
|
127
|
-
this
|
|
124
|
+
this.#builder.addNewLine();
|
|
125
|
+
this.#builder.increaseNestingLevel();
|
|
126
|
+
this.#cssFormatter.format(this.#text || '', this.#lineEndings || [], token.startOffset, token.endOffset);
|
|
127
|
+
this.#builder.decreaseNestingLevel();
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
130
|
if (isBodyToken && element.name === 'script') {
|
|
131
|
-
this
|
|
132
|
-
this
|
|
133
|
-
if (this
|
|
134
|
-
this
|
|
131
|
+
this.#builder.addNewLine();
|
|
132
|
+
this.#builder.increaseNestingLevel();
|
|
133
|
+
if (this.#scriptTagIsJavaScript(element)) {
|
|
134
|
+
this.#jsFormatter.format(this.#text || '', this.#lineEndings || [], token.startOffset, token.endOffset);
|
|
135
135
|
} else {
|
|
136
|
-
this
|
|
137
|
-
this
|
|
136
|
+
this.#builder.addToken(token.value, token.startOffset);
|
|
137
|
+
this.#builder.addNewLine();
|
|
138
138
|
}
|
|
139
|
-
this
|
|
139
|
+
this.#builder.decreaseNestingLevel();
|
|
140
140
|
return;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
if (!isBodyToken && hasTokenInSet(token.type, 'attribute')) {
|
|
144
|
-
this
|
|
144
|
+
this.#builder.addSoftSpace();
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
this
|
|
147
|
+
this.#builder.addToken(token.value, token.startOffset);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
#scriptTagIsJavaScript(element: FormatterElement): boolean {
|
|
151
151
|
if (!element.openTag) {
|
|
152
152
|
return true;
|
|
153
153
|
}
|
|
@@ -200,37 +200,37 @@ function hasTokenInSet(tokenTypes: Set<string>, type: string): boolean {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
export class HTMLModel {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
203
|
+
#state: ParseState;
|
|
204
|
+
readonly #documentInternal: FormatterElement;
|
|
205
|
+
#stack: FormatterElement[];
|
|
206
|
+
readonly #tokens: Token[];
|
|
207
|
+
#tokenIndex: number;
|
|
208
|
+
#attributes: Map<string, string>;
|
|
209
|
+
#attributeName: string;
|
|
210
|
+
#tagName: string;
|
|
211
|
+
#isOpenTag: boolean;
|
|
212
|
+
#tagStartOffset?: number|null;
|
|
213
|
+
#tagEndOffset?: number|null;
|
|
214
214
|
|
|
215
215
|
constructor(text: string) {
|
|
216
|
-
this
|
|
217
|
-
this
|
|
218
|
-
this
|
|
219
|
-
this
|
|
216
|
+
this.#state = ParseState.Initial;
|
|
217
|
+
this.#documentInternal = new FormatterElement('document');
|
|
218
|
+
this.#documentInternal.openTag = new Tag('document', 0, 0, new Map(), true, false);
|
|
219
|
+
this.#documentInternal.closeTag = new Tag('document', text.length, text.length, new Map(), false, false);
|
|
220
220
|
|
|
221
|
-
this
|
|
221
|
+
this.#stack = [this.#documentInternal];
|
|
222
222
|
|
|
223
|
-
this
|
|
224
|
-
this
|
|
225
|
-
this
|
|
223
|
+
this.#tokens = [];
|
|
224
|
+
this.#tokenIndex = 0;
|
|
225
|
+
this.#build(text);
|
|
226
226
|
|
|
227
|
-
this
|
|
228
|
-
this
|
|
229
|
-
this
|
|
230
|
-
this
|
|
227
|
+
this.#attributes = new Map();
|
|
228
|
+
this.#attributeName = '';
|
|
229
|
+
this.#tagName = '';
|
|
230
|
+
this.#isOpenTag = false;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
|
|
233
|
+
#build(text: string): void {
|
|
234
234
|
const tokenizer = createTokenizer('text/html');
|
|
235
235
|
let lastOffset = 0;
|
|
236
236
|
const lowerCaseText = text.toLowerCase();
|
|
@@ -240,7 +240,7 @@ export class HTMLModel {
|
|
|
240
240
|
if (lastOffset >= text.length) {
|
|
241
241
|
break;
|
|
242
242
|
}
|
|
243
|
-
const element = this
|
|
243
|
+
const element = this.#stack[this.#stack.length - 1];
|
|
244
244
|
if (!element) {
|
|
245
245
|
break;
|
|
246
246
|
}
|
|
@@ -257,16 +257,16 @@ export class HTMLModel {
|
|
|
257
257
|
const tokenStart = element.openTag.endOffset;
|
|
258
258
|
const tokenEnd = lastOffset;
|
|
259
259
|
const tokenValue = text.substring(tokenStart, tokenEnd);
|
|
260
|
-
this
|
|
260
|
+
this.#tokens.push(new Token(tokenValue, new Set(), tokenStart, tokenEnd));
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
while (this
|
|
264
|
-
const element = this
|
|
263
|
+
while (this.#stack.length > 1) {
|
|
264
|
+
const element = this.#stack[this.#stack.length - 1];
|
|
265
265
|
if (!element) {
|
|
266
266
|
break;
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
-
this
|
|
269
|
+
this.#popElement(new Tag(element.name, text.length, text.length, new Map(), false, false));
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
function processToken(
|
|
@@ -278,10 +278,10 @@ export class HTMLModel {
|
|
|
278
278
|
|
|
279
279
|
const tokenType = type ? new Set<string>(type.split(' ')) : new Set<string>();
|
|
280
280
|
const token = new Token(tokenValue, tokenType, tokenStart, tokenEnd);
|
|
281
|
-
this
|
|
282
|
-
this
|
|
281
|
+
this.#tokens.push(token);
|
|
282
|
+
this.#updateDOM(token);
|
|
283
283
|
|
|
284
|
-
const element = this
|
|
284
|
+
const element = this.#stack[this.#stack.length - 1];
|
|
285
285
|
if (element && (element.name === 'script' || element.name === 'style') && element.openTag &&
|
|
286
286
|
element.openTag.endOffset === lastOffset) {
|
|
287
287
|
return AbortTokenization;
|
|
@@ -291,124 +291,125 @@ export class HTMLModel {
|
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
|
|
294
|
+
#updateDOM(token: Token): void {
|
|
295
295
|
const value = token.value;
|
|
296
296
|
const type = token.type;
|
|
297
|
-
switch (this
|
|
297
|
+
switch (this.#state) {
|
|
298
298
|
case ParseState.Initial:
|
|
299
299
|
if (hasTokenInSet(type, 'bracket') && (value === '<' || value === '</')) {
|
|
300
|
-
this
|
|
301
|
-
this
|
|
300
|
+
this.#onStartTag(token);
|
|
301
|
+
this.#state = ParseState.Tag;
|
|
302
302
|
}
|
|
303
303
|
return;
|
|
304
304
|
case ParseState.Tag:
|
|
305
305
|
if (hasTokenInSet(type, 'tag') && !hasTokenInSet(type, 'bracket')) {
|
|
306
|
-
this
|
|
306
|
+
this.#tagName = value.trim().toLowerCase();
|
|
307
307
|
} else if (hasTokenInSet(type, 'attribute')) {
|
|
308
|
-
this
|
|
309
|
-
this
|
|
310
|
-
this
|
|
308
|
+
this.#attributeName = value.trim().toLowerCase();
|
|
309
|
+
this.#attributes.set(this.#attributeName, '');
|
|
310
|
+
this.#state = ParseState.AttributeName;
|
|
311
311
|
} else if (hasTokenInSet(type, 'bracket') && (value === '>' || value === '/>')) {
|
|
312
|
-
this
|
|
313
|
-
this
|
|
312
|
+
this.#onEndTag(token);
|
|
313
|
+
this.#state = ParseState.Initial;
|
|
314
314
|
}
|
|
315
315
|
return;
|
|
316
316
|
case ParseState.AttributeName:
|
|
317
317
|
if (!type.size && value === '=') {
|
|
318
|
-
this
|
|
318
|
+
this.#state = ParseState.AttributeValue;
|
|
319
319
|
} else if (hasTokenInSet(type, 'bracket') && (value === '>' || value === '/>')) {
|
|
320
|
-
this
|
|
321
|
-
this
|
|
320
|
+
this.#onEndTag(token);
|
|
321
|
+
this.#state = ParseState.Initial;
|
|
322
322
|
}
|
|
323
323
|
return;
|
|
324
324
|
case ParseState.AttributeValue:
|
|
325
325
|
if (hasTokenInSet(type, 'string')) {
|
|
326
|
-
this
|
|
327
|
-
this
|
|
326
|
+
this.#attributes.set(this.#attributeName, value);
|
|
327
|
+
this.#state = ParseState.Tag;
|
|
328
328
|
} else if (hasTokenInSet(type, 'bracket') && (value === '>' || value === '/>')) {
|
|
329
|
-
this
|
|
330
|
-
this
|
|
329
|
+
this.#onEndTag(token);
|
|
330
|
+
this.#state = ParseState.Initial;
|
|
331
331
|
}
|
|
332
332
|
return;
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
-
|
|
337
|
-
this
|
|
338
|
-
this
|
|
339
|
-
this
|
|
340
|
-
this
|
|
341
|
-
this
|
|
342
|
-
this
|
|
336
|
+
#onStartTag(token: Token): void {
|
|
337
|
+
this.#tagName = '';
|
|
338
|
+
this.#tagStartOffset = token.startOffset;
|
|
339
|
+
this.#tagEndOffset = null;
|
|
340
|
+
this.#attributes = new Map();
|
|
341
|
+
this.#attributeName = '';
|
|
342
|
+
this.#isOpenTag = token.value === '<';
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
|
|
346
|
-
this
|
|
347
|
-
const selfClosingTag = token.value === '/>' || SelfClosingTags.has(this
|
|
345
|
+
#onEndTag(token: Token): void {
|
|
346
|
+
this.#tagEndOffset = token.endOffset;
|
|
347
|
+
const selfClosingTag = token.value === '/>' || SelfClosingTags.has(this.#tagName);
|
|
348
348
|
const tag = new Tag(
|
|
349
|
-
this
|
|
350
|
-
|
|
349
|
+
this.#tagName, this.#tagStartOffset || 0, this.#tagEndOffset, this.#attributes, this.#isOpenTag,
|
|
350
|
+
selfClosingTag);
|
|
351
|
+
this.#onTagComplete(tag);
|
|
351
352
|
}
|
|
352
353
|
|
|
353
|
-
|
|
354
|
+
#onTagComplete(tag: Tag): void {
|
|
354
355
|
if (tag.isOpenTag) {
|
|
355
|
-
const topElement = this
|
|
356
|
+
const topElement = this.#stack[this.#stack.length - 1];
|
|
356
357
|
if (topElement) {
|
|
357
358
|
const tagSet = AutoClosingTags.get(topElement.name);
|
|
358
|
-
if (topElement !== this
|
|
359
|
-
this
|
|
359
|
+
if (topElement !== this.#documentInternal && topElement.openTag && topElement.openTag.selfClosingTag) {
|
|
360
|
+
this.#popElement(autocloseTag(topElement, topElement.openTag.endOffset));
|
|
360
361
|
} else if (tagSet && tagSet.has(tag.name)) {
|
|
361
|
-
this
|
|
362
|
+
this.#popElement(autocloseTag(topElement, tag.startOffset));
|
|
362
363
|
}
|
|
363
|
-
this
|
|
364
|
+
this.#pushElement(tag);
|
|
364
365
|
}
|
|
365
366
|
return;
|
|
366
367
|
}
|
|
367
368
|
|
|
368
|
-
let lastTag = this
|
|
369
|
-
while (this
|
|
370
|
-
this
|
|
371
|
-
lastTag = this
|
|
369
|
+
let lastTag = this.#stack[this.#stack.length - 1];
|
|
370
|
+
while (this.#stack.length > 1 && lastTag && lastTag.name !== tag.name) {
|
|
371
|
+
this.#popElement(autocloseTag(lastTag, tag.startOffset));
|
|
372
|
+
lastTag = this.#stack[this.#stack.length - 1];
|
|
372
373
|
}
|
|
373
|
-
if (this
|
|
374
|
+
if (this.#stack.length === 1) {
|
|
374
375
|
return;
|
|
375
376
|
}
|
|
376
|
-
this
|
|
377
|
+
this.#popElement(tag);
|
|
377
378
|
|
|
378
379
|
function autocloseTag(element: FormatterElement, offset: number): Tag {
|
|
379
380
|
return new Tag(element.name, offset, offset, new Map(), false, false);
|
|
380
381
|
}
|
|
381
382
|
}
|
|
382
383
|
|
|
383
|
-
|
|
384
|
-
const element = this
|
|
384
|
+
#popElement(closeTag: Tag): void {
|
|
385
|
+
const element = this.#stack.pop();
|
|
385
386
|
if (!element) {
|
|
386
387
|
return;
|
|
387
388
|
}
|
|
388
389
|
element.closeTag = closeTag;
|
|
389
390
|
}
|
|
390
391
|
|
|
391
|
-
|
|
392
|
-
const topElement = this
|
|
392
|
+
#pushElement(openTag: Tag): void {
|
|
393
|
+
const topElement = this.#stack[this.#stack.length - 1];
|
|
393
394
|
const newElement = new FormatterElement(openTag.name);
|
|
394
395
|
if (topElement) {
|
|
395
396
|
newElement.parent = topElement;
|
|
396
397
|
topElement.children.push(newElement);
|
|
397
398
|
}
|
|
398
399
|
newElement.openTag = openTag;
|
|
399
|
-
this
|
|
400
|
+
this.#stack.push(newElement);
|
|
400
401
|
}
|
|
401
402
|
|
|
402
403
|
peekToken(): Token|null {
|
|
403
|
-
return this
|
|
404
|
+
return this.#tokenIndex < this.#tokens.length ? this.#tokens[this.#tokenIndex] : null;
|
|
404
405
|
}
|
|
405
406
|
|
|
406
407
|
nextToken(): Token|null {
|
|
407
|
-
return this
|
|
408
|
+
return this.#tokens[this.#tokenIndex++];
|
|
408
409
|
}
|
|
409
410
|
|
|
410
411
|
document(): FormatterElement {
|
|
411
|
-
return this
|
|
412
|
+
return this.#documentInternal;
|
|
412
413
|
}
|
|
413
414
|
}
|
|
414
415
|
|
|
@@ -36,30 +36,30 @@ import {ESTreeWalker} from './ESTreeWalker.js';
|
|
|
36
36
|
import type {FormattedContentBuilder} from './FormattedContentBuilder.js';
|
|
37
37
|
|
|
38
38
|
export class JavaScriptFormatter {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
readonly #builder: FormattedContentBuilder;
|
|
40
|
+
#tokenizer!: AcornTokenizer;
|
|
41
|
+
#content!: string;
|
|
42
|
+
#fromOffset!: number;
|
|
43
|
+
#lastLineNumber!: number;
|
|
44
|
+
#toOffset?: number;
|
|
45
45
|
constructor(builder: FormattedContentBuilder) {
|
|
46
|
-
this
|
|
46
|
+
this.#builder = builder;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
format(text: string, lineEndings: number[], fromOffset: number, toOffset: number): void {
|
|
50
|
-
this
|
|
51
|
-
this
|
|
52
|
-
this
|
|
53
|
-
this
|
|
54
|
-
this
|
|
55
|
-
const ast = Acorn.parse(this
|
|
50
|
+
this.#fromOffset = fromOffset;
|
|
51
|
+
this.#toOffset = toOffset;
|
|
52
|
+
this.#content = text.substring(this.#fromOffset, this.#toOffset);
|
|
53
|
+
this.#lastLineNumber = 0;
|
|
54
|
+
this.#tokenizer = new AcornTokenizer(this.#content);
|
|
55
|
+
const ast = Acorn.parse(this.#content, {
|
|
56
56
|
ranges: false,
|
|
57
57
|
preserveParens: true,
|
|
58
58
|
allowImportExportEverywhere: true,
|
|
59
59
|
ecmaVersion: ECMA_VERSION,
|
|
60
60
|
allowHashBang: true,
|
|
61
61
|
});
|
|
62
|
-
const walker = new ESTreeWalker(this
|
|
62
|
+
const walker = new ESTreeWalker(this.#beforeVisit.bind(this), this.#afterVisit.bind(this));
|
|
63
63
|
// @ts-ignore Technically, the acorn Node type is a subclass of Acorn.ESTree.Node.
|
|
64
64
|
// However, the acorn package currently exports its type without specifying
|
|
65
65
|
// this relationship. So while this is allowed on runtime, we can't properly
|
|
@@ -67,55 +67,55 @@ export class JavaScriptFormatter {
|
|
|
67
67
|
walker.walk(ast);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
#push(token: Acorn.Token|Acorn.Comment|null, format: string): void {
|
|
71
71
|
for (let i = 0; i < format.length; ++i) {
|
|
72
72
|
if (format[i] === 's') {
|
|
73
|
-
this
|
|
73
|
+
this.#builder.addSoftSpace();
|
|
74
74
|
} else if (format[i] === 'S') {
|
|
75
|
-
this
|
|
75
|
+
this.#builder.addHardSpace();
|
|
76
76
|
} else if (format[i] === 'n') {
|
|
77
|
-
this
|
|
77
|
+
this.#builder.addNewLine();
|
|
78
78
|
} else if (format[i] === '>') {
|
|
79
|
-
this
|
|
79
|
+
this.#builder.increaseNestingLevel();
|
|
80
80
|
} else if (format[i] === '<') {
|
|
81
|
-
this
|
|
81
|
+
this.#builder.decreaseNestingLevel();
|
|
82
82
|
} else if (format[i] === 't') {
|
|
83
|
-
if (this
|
|
84
|
-
this
|
|
83
|
+
if (this.#tokenizer.tokenLineStart() - this.#lastLineNumber > 1) {
|
|
84
|
+
this.#builder.addNewLine(true);
|
|
85
85
|
}
|
|
86
|
-
this
|
|
86
|
+
this.#lastLineNumber = this.#tokenizer.tokenLineEnd();
|
|
87
87
|
if (token) {
|
|
88
|
-
this
|
|
88
|
+
this.#builder.addToken(this.#content.substring(token.start, token.end), this.#fromOffset + token.start);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
#beforeVisit(node: Acorn.ESTree.Node): undefined {
|
|
95
95
|
if (!node.parent) {
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
98
|
let token;
|
|
99
|
-
while ((token = this
|
|
100
|
-
const token = (this
|
|
99
|
+
while ((token = this.#tokenizer.peekToken()) && token.start < node.start) {
|
|
100
|
+
const token = (this.#tokenizer.nextToken() as TokenOrComment);
|
|
101
101
|
// @ts-ignore Same reason as above about Acorn types and ESTree types
|
|
102
|
-
const format = this
|
|
103
|
-
this
|
|
102
|
+
const format = this.#formatToken(node.parent, token);
|
|
103
|
+
this.#push(token, format);
|
|
104
104
|
}
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
#afterVisit(node: Acorn.ESTree.Node): void {
|
|
109
109
|
let token;
|
|
110
|
-
while ((token = this
|
|
111
|
-
const token = (this
|
|
112
|
-
const format = this
|
|
113
|
-
this
|
|
110
|
+
while ((token = this.#tokenizer.peekToken()) && token.start < node.end) {
|
|
111
|
+
const token = (this.#tokenizer.nextToken() as TokenOrComment);
|
|
112
|
+
const format = this.#formatToken(node, token);
|
|
113
|
+
this.#push(token, format);
|
|
114
114
|
}
|
|
115
|
-
this
|
|
115
|
+
this.#push(null, this.#finishNode(node));
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
#inForLoopHeader(node: Acorn.ESTree.Node): boolean {
|
|
119
119
|
const parent = node.parent;
|
|
120
120
|
if (!parent) {
|
|
121
121
|
return false;
|
|
@@ -131,7 +131,7 @@ export class JavaScriptFormatter {
|
|
|
131
131
|
return false;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
#formatToken(node: Acorn.ESTree.Node, tokenOrComment: TokenOrComment): string {
|
|
135
135
|
const AT = AcornTokenizer;
|
|
136
136
|
if (AT.lineComment(tokenOrComment)) {
|
|
137
137
|
return 'tn';
|
|
@@ -241,7 +241,7 @@ export class JavaScriptFormatter {
|
|
|
241
241
|
// it exists. We can't fix that, unless we use proper typechecking
|
|
242
242
|
allVariablesInitialized = allVariablesInitialized && Boolean(declarations[i].init);
|
|
243
243
|
}
|
|
244
|
-
return !this
|
|
244
|
+
return !this.#inForLoopHeader(node) && allVariablesInitialized ? 'nSSts' : 'ts';
|
|
245
245
|
}
|
|
246
246
|
} else if (node.type === 'PropertyDefinition') {
|
|
247
247
|
if (AT.punctuator(token, '=')) {
|
|
@@ -356,13 +356,13 @@ export class JavaScriptFormatter {
|
|
|
356
356
|
return AT.keyword(token) && !AT.keyword(token, 'this') ? 'ts' : 't';
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
-
|
|
359
|
+
#finishNode(node: Acorn.ESTree.Node): string {
|
|
360
360
|
if (node.type === 'WithStatement') {
|
|
361
361
|
if (node.body && node.body.type !== 'BlockStatement') {
|
|
362
362
|
return 'n<';
|
|
363
363
|
}
|
|
364
364
|
} else if (node.type === 'VariableDeclaration') {
|
|
365
|
-
if (!this
|
|
365
|
+
if (!this.#inForLoopHeader(node)) {
|
|
366
366
|
return 'n';
|
|
367
367
|
}
|
|
368
368
|
} else if (node.type === 'ForStatement' || node.type === 'ForOfStatement' || node.type === 'ForInStatement') {
|