chrome-devtools-frontend 1.0.1526203 → 1.0.1528866
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/docs/ui_engineering.md +159 -0
- package/eslint.config.mjs +6 -1
- package/front_end/core/i18n/i18nImpl.ts +5 -0
- package/front_end/core/protocol_client/protocol_client.ts +1 -1
- package/front_end/core/root/Runtime.ts +28 -4
- package/front_end/core/sdk/CSSMatchedStyles.ts +50 -7
- package/front_end/core/sdk/CSSRule.ts +35 -6
- package/front_end/core/sdk/ChildTargetManager.ts +2 -0
- package/front_end/core/sdk/Connections.ts +2 -1
- package/front_end/core/sdk/DOMModel.ts +4 -0
- package/front_end/core/sdk/DebuggerModel.ts +5 -1
- package/front_end/core/sdk/NetworkManager.ts +214 -31
- package/front_end/core/sdk/PreloadingModel.ts +82 -17
- package/front_end/core/sdk/RehydratingConnection.snapshot.txt +1 -1
- package/front_end/core/sdk/RehydratingConnection.ts +29 -4
- package/front_end/core/sdk/ScopeTreeCache.ts +8 -3
- package/front_end/core/sdk/SourceMap.ts +37 -11
- package/front_end/core/sdk/SourceMapManager.ts +13 -2
- package/front_end/core/sdk/SourceMapScopesInfo.ts +17 -0
- package/front_end/core/sdk/TargetManager.ts +0 -22
- package/front_end/core/sdk/TraceObject.ts +8 -7
- package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +81 -0
- package/front_end/entrypoints/inspector_main/InspectorMain.ts +3 -1
- package/front_end/entrypoints/main/GlobalAiButton.ts +1 -0
- package/front_end/entrypoints/main/MainImpl.ts +20 -25
- package/front_end/generated/InspectorBackendCommands.js +4 -3
- package/front_end/generated/protocol-mapping.d.ts +3 -1
- package/front_end/generated/protocol-proxy-api.d.ts +3 -1
- package/front_end/generated/protocol.ts +17 -3
- package/front_end/models/ai_assistance/BuiltInAi.ts +111 -0
- package/front_end/models/ai_assistance/ai_assistance.ts +53 -24
- package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.snapshot.txt +105 -0
- package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.ts +6 -1
- package/front_end/models/extensions/ExtensionView.ts +3 -0
- package/front_end/models/javascript_metadata/NativeFunctions.js +23 -27
- package/front_end/models/live-metrics/web-vitals-injected/web-vitals-injected.ts +31 -29
- package/front_end/models/persistence/EditFileSystemView.ts +1 -0
- package/front_end/models/source_map_scopes/NamesResolver.ts +5 -11
- package/front_end/models/stack_trace/Trie.ts +9 -0
- package/front_end/models/trace/lantern/types/Lantern.ts +1 -1
- package/front_end/panels/accessibility/AXBreadcrumbsPane.ts +1 -0
- package/front_end/panels/accessibility/AccessibilitySidebarView.ts +1 -0
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +120 -113
- package/front_end/panels/ai_assistance/PatchWidget.ts +9 -8
- package/front_end/panels/ai_assistance/SelectWorkspaceDialog.ts +2 -0
- package/front_end/panels/ai_assistance/components/ChatView.ts +29 -29
- package/front_end/panels/ai_assistance/components/UserActionRow.ts +1 -0
- package/front_end/panels/animation/AnimationTimeline.ts +1 -0
- package/front_end/panels/application/CookieItemsView.ts +1 -0
- package/front_end/panels/application/KeyValueStorageItemsView.ts +1 -0
- package/front_end/panels/application/ServiceWorkerCacheViews.ts +2 -0
- package/front_end/panels/application/preloading/components/PreloadingDetailsReportView.ts +11 -5
- package/front_end/panels/application/preloading/components/PreloadingMismatchedHeadersGrid.ts +2 -2
- package/front_end/panels/application/preloading/components/PreloadingString.ts +7 -5
- package/front_end/panels/application/preloading/components/UsedPreloadingView.ts +22 -10
- package/front_end/panels/changes/CombinedDiffView.ts +1 -0
- package/front_end/panels/console/ConsoleInsightTeaser.ts +106 -0
- package/front_end/panels/console/ConsolePanel.ts +2 -0
- package/front_end/panels/console/ConsolePrompt.ts +12 -2
- package/front_end/panels/console/ConsoleSidebar.ts +1 -1
- package/front_end/panels/console/ConsoleView.ts +12 -0
- package/front_end/panels/console/ConsoleViewMessage.ts +27 -0
- package/front_end/panels/{explain → console}/PromptBuilder.ts +12 -7
- package/front_end/panels/console/console.ts +6 -0
- package/front_end/panels/console/consoleInsightTeaser.css +55 -0
- package/front_end/panels/coverage/CoverageListView.ts +141 -277
- package/front_end/panels/coverage/CoverageView.ts +330 -324
- package/front_end/panels/coverage/coverageView.css +17 -0
- package/front_end/panels/elements/ComputedStyleWidget.ts +1 -0
- package/front_end/panels/elements/LayoutPane.ts +1 -0
- package/front_end/panels/elements/NodeStackTraceWidget.ts +1 -0
- package/front_end/panels/elements/StylePropertyTreeElement.ts +5 -1
- package/front_end/panels/elements/stylePropertiesTreeOutline.css +17 -0
- package/front_end/panels/emulation/DeviceModeView.ts +2 -0
- package/front_end/panels/explain/ActionDelegate.ts +1 -2
- package/front_end/panels/explain/components/ConsoleInsight.ts +14 -12
- package/front_end/panels/explain/explain.ts +0 -1
- package/front_end/panels/js_timeline/js_timeline-meta.ts +1 -1
- package/front_end/panels/layer_viewer/Layers3DView.ts +2 -0
- package/front_end/panels/lighthouse/LighthouseReportSelector.ts +1 -0
- package/front_end/panels/linear_memory_inspector/LinearMemoryInspectorPane.ts +12 -19
- package/front_end/panels/linear_memory_inspector/components/LinearMemoryInspector.ts +27 -43
- package/front_end/panels/media/MainView.ts +1 -0
- package/front_end/panels/media/TickingFlameChart.ts +2 -0
- package/front_end/panels/network/BlockedURLsPane.ts +111 -85
- package/front_end/panels/network/EventSourceMessagesView.ts +1 -0
- package/front_end/panels/network/NetworkItemView.ts +1 -0
- package/front_end/panels/network/NetworkLogView.ts +9 -7
- package/front_end/panels/network/NetworkOverview.ts +1 -0
- package/front_end/panels/network/RequestCookiesView.ts +1 -0
- package/front_end/panels/network/RequestHTMLView.ts +1 -0
- package/front_end/panels/network/RequestInitiatorView.ts +1 -0
- package/front_end/panels/network/RequestPayloadView.ts +1 -0
- package/front_end/panels/network/RequestPreviewView.ts +1 -0
- package/front_end/panels/network/RequestResponseView.ts +2 -1
- package/front_end/panels/network/RequestTimingView.ts +2 -0
- package/front_end/panels/network/ResourceDirectSocketChunkView.ts +1 -0
- package/front_end/panels/network/ResourceWebSocketFrameView.ts +1 -0
- package/front_end/panels/network/components/RequestHeadersView.ts +2 -0
- package/front_end/panels/network/components/RequestTrustTokensView.ts +2 -0
- package/front_end/panels/performance_monitor/PerformanceMonitor.ts +2 -0
- package/front_end/panels/profiler/HeapSnapshotDataGrids.ts +2 -0
- package/front_end/panels/profiler/HeapSnapshotView.ts +7 -0
- package/front_end/panels/profiler/IsolateSelector.ts +1 -0
- package/front_end/panels/profiler/LiveHeapProfileView.ts +1 -0
- package/front_end/panels/profiler/ProfileView.ts +1 -0
- package/front_end/panels/protocol_monitor/ProtocolMonitor.ts +1 -0
- package/front_end/panels/recorder/RecorderPanel.ts +2 -0
- package/front_end/panels/screencast/ScreencastView.ts +1 -0
- package/front_end/panels/search/SearchView.ts +1 -0
- package/front_end/panels/settings/AISettingsTab.ts +3 -3
- package/front_end/panels/settings/WorkspaceSettingsTab.ts +2 -0
- package/front_end/panels/settings/emulation/components/UserAgentClientHintsForm.ts +2 -2
- package/front_end/panels/sources/AiCodeCompletionPlugin.ts +12 -0
- package/front_end/panels/sources/BreakpointsView.ts +1 -0
- package/front_end/panels/sources/DebuggerPlugin.ts +1 -0
- package/front_end/panels/sources/UISourceCodeFrame.ts +17 -2
- package/front_end/panels/timeline/README.md +2 -2
- package/front_end/panels/timeline/TimelineFlameChartDataProvider.ts +1 -1
- package/front_end/panels/timeline/TimelineFlameChartView.ts +4 -3
- package/front_end/panels/timeline/TimelineLayersView.ts +1 -0
- package/front_end/panels/timeline/TimelinePaintProfilerView.ts +114 -37
- package/front_end/panels/timeline/TimelinePanel.ts +43 -62
- package/front_end/panels/timeline/TimelineTreeView.ts +1 -0
- package/front_end/panels/timeline/components/LiveMetricsView.ts +4 -8
- package/front_end/panels/timeline/components/Sidebar.ts +2 -0
- package/front_end/panels/timeline/components/SidebarSingleInsightSet.ts +1 -1
- package/front_end/panels/timeline/components/insights/BaseInsightComponent.ts +7 -7
- package/front_end/panels/timeline/overlays/OverlaysImpl.ts +1 -1
- package/front_end/panels/timeline/overlays/components/EntryLabelOverlay.ts +4 -4
- package/front_end/panels/web_audio/WebAudioView.ts +1 -0
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/third_party/lighthouse/README.chromium +2 -2
- package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +1530 -2426
- package/front_end/third_party/lighthouse/locales/ar-XB.json +107 -455
- package/front_end/third_party/lighthouse/locales/ar.json +107 -455
- package/front_end/third_party/lighthouse/locales/bg.json +96 -444
- package/front_end/third_party/lighthouse/locales/ca.json +96 -444
- package/front_end/third_party/lighthouse/locales/cs.json +96 -444
- package/front_end/third_party/lighthouse/locales/da.json +96 -444
- package/front_end/third_party/lighthouse/locales/de.json +96 -444
- package/front_end/third_party/lighthouse/locales/el.json +96 -444
- package/front_end/third_party/lighthouse/locales/en-GB.json +96 -444
- package/front_end/third_party/lighthouse/locales/en-US.json +116 -467
- package/front_end/third_party/lighthouse/locales/en-XA.json +93 -441
- package/front_end/third_party/lighthouse/locales/en-XL.json +116 -467
- package/front_end/third_party/lighthouse/locales/es-419.json +96 -444
- package/front_end/third_party/lighthouse/locales/es.json +96 -444
- package/front_end/third_party/lighthouse/locales/fi.json +96 -444
- package/front_end/third_party/lighthouse/locales/fil.json +96 -444
- package/front_end/third_party/lighthouse/locales/fr.json +96 -444
- package/front_end/third_party/lighthouse/locales/he.json +118 -466
- package/front_end/third_party/lighthouse/locales/hi.json +96 -444
- package/front_end/third_party/lighthouse/locales/hr.json +100 -448
- package/front_end/third_party/lighthouse/locales/hu.json +96 -444
- package/front_end/third_party/lighthouse/locales/id.json +96 -444
- package/front_end/third_party/lighthouse/locales/it.json +96 -444
- package/front_end/third_party/lighthouse/locales/ja.json +96 -444
- package/front_end/third_party/lighthouse/locales/ko.json +97 -445
- package/front_end/third_party/lighthouse/locales/lt.json +96 -444
- package/front_end/third_party/lighthouse/locales/lv.json +97 -445
- package/front_end/third_party/lighthouse/locales/nl.json +96 -444
- package/front_end/third_party/lighthouse/locales/no.json +96 -444
- package/front_end/third_party/lighthouse/locales/pl.json +96 -444
- package/front_end/third_party/lighthouse/locales/pt-PT.json +96 -444
- package/front_end/third_party/lighthouse/locales/pt.json +97 -445
- package/front_end/third_party/lighthouse/locales/ro.json +97 -445
- package/front_end/third_party/lighthouse/locales/ru.json +96 -444
- package/front_end/third_party/lighthouse/locales/sk.json +96 -444
- package/front_end/third_party/lighthouse/locales/sl.json +96 -444
- package/front_end/third_party/lighthouse/locales/sr-Latn.json +96 -444
- package/front_end/third_party/lighthouse/locales/sr.json +96 -444
- package/front_end/third_party/lighthouse/locales/sv.json +96 -444
- package/front_end/third_party/lighthouse/locales/ta.json +96 -444
- package/front_end/third_party/lighthouse/locales/te.json +97 -445
- package/front_end/third_party/lighthouse/locales/th.json +96 -444
- package/front_end/third_party/lighthouse/locales/tr.json +96 -444
- package/front_end/third_party/lighthouse/locales/uk.json +96 -444
- package/front_end/third_party/lighthouse/locales/vi.json +96 -444
- package/front_end/third_party/lighthouse/locales/zh-HK.json +96 -444
- package/front_end/third_party/lighthouse/locales/zh-TW.json +97 -445
- package/front_end/third_party/lighthouse/locales/zh.json +96 -444
- package/front_end/third_party/lighthouse/report/bundle.d.ts +8 -14
- package/front_end/third_party/lighthouse/report/bundle.js +10 -49
- package/front_end/third_party/lighthouse/report-assets/report-generator.mjs +1 -1
- package/front_end/third_party/web-vitals/README.chromium +5 -8
- package/front_end/third_party/web-vitals/package/README.md +191 -152
- package/front_end/third_party/web-vitals/package/dist/modules/attribution/index.d.ts +0 -1
- package/front_end/third_party/web-vitals/package/dist/modules/attribution/index.js +0 -1
- package/front_end/third_party/web-vitals/package/dist/modules/attribution/onCLS.d.ts +2 -2
- package/front_end/third_party/web-vitals/package/dist/modules/attribution/onCLS.js +45 -26
- package/front_end/third_party/web-vitals/package/dist/modules/attribution/onFCP.d.ts +2 -2
- package/front_end/third_party/web-vitals/package/dist/modules/attribution/onFCP.js +3 -3
- package/front_end/third_party/web-vitals/package/dist/modules/attribution/onINP.d.ts +10 -10
- package/front_end/third_party/web-vitals/package/dist/modules/attribution/onINP.js +307 -206
- package/front_end/third_party/web-vitals/package/dist/modules/attribution/onLCP.d.ts +2 -2
- package/front_end/third_party/web-vitals/package/dist/modules/attribution/onLCP.js +69 -49
- package/front_end/third_party/web-vitals/package/dist/modules/attribution/onTTFB.d.ts +2 -2
- package/front_end/third_party/web-vitals/package/dist/modules/attribution/onTTFB.js +2 -2
- package/front_end/third_party/web-vitals/package/dist/modules/index.d.ts +0 -1
- package/front_end/third_party/web-vitals/package/dist/modules/index.js +0 -1
- package/front_end/third_party/web-vitals/package/dist/modules/lib/InteractionManager.d.ts +33 -0
- package/front_end/third_party/web-vitals/package/dist/modules/lib/InteractionManager.js +111 -0
- package/front_end/third_party/web-vitals/package/dist/modules/lib/LCPEntryManager.d.ts +4 -0
- package/front_end/third_party/web-vitals/package/dist/modules/{attribution/deprecated.js → lib/LCPEntryManager.js} +6 -7
- package/front_end/third_party/web-vitals/package/dist/modules/lib/LayoutShiftManager.d.ts +6 -0
- package/front_end/third_party/web-vitals/package/dist/modules/lib/LayoutShiftManager.js +44 -0
- package/front_end/third_party/web-vitals/package/dist/modules/lib/bindReporter.js +1 -1
- package/front_end/third_party/web-vitals/package/dist/modules/lib/generateUniqueID.js +1 -1
- package/front_end/third_party/web-vitals/package/dist/modules/lib/getActivationStart.js +1 -1
- package/front_end/third_party/web-vitals/package/dist/modules/lib/getNavigationEntry.js +5 -7
- package/front_end/third_party/web-vitals/package/dist/modules/lib/getSelector.d.ts +1 -1
- package/front_end/third_party/web-vitals/package/dist/modules/lib/getSelector.js +9 -12
- package/front_end/third_party/web-vitals/package/dist/modules/lib/getVisibilityWatcher.d.ts +1 -0
- package/front_end/third_party/web-vitals/package/dist/modules/lib/getVisibilityWatcher.js +52 -33
- package/front_end/third_party/web-vitals/package/dist/modules/lib/initMetric.d.ts +0 -2
- package/front_end/third_party/web-vitals/package/dist/modules/lib/initMetric.js +2 -2
- package/front_end/third_party/web-vitals/package/dist/modules/lib/initUnique.d.ts +6 -0
- package/front_end/third_party/web-vitals/package/dist/modules/{deprecated.js → lib/initUnique.js} +11 -4
- package/front_end/third_party/web-vitals/package/dist/modules/lib/observe.js +3 -6
- package/front_end/third_party/web-vitals/package/dist/modules/lib/polyfills/interactionCountPolyfill.js +6 -6
- package/front_end/third_party/web-vitals/package/dist/modules/lib/{whenIdle.d.ts → whenIdleOrHidden.d.ts} +1 -1
- package/front_end/third_party/web-vitals/package/dist/modules/lib/{whenIdle.js → whenIdleOrHidden.js} +10 -8
- package/front_end/third_party/web-vitals/package/dist/modules/onCLS.js +17 -35
- package/front_end/third_party/web-vitals/package/dist/modules/onFCP.js +3 -5
- package/front_end/third_party/web-vitals/package/dist/modules/onINP.d.ts +9 -7
- package/front_end/third_party/web-vitals/package/dist/modules/onINP.js +27 -19
- package/front_end/third_party/web-vitals/package/dist/modules/onLCP.js +33 -26
- package/front_end/third_party/web-vitals/package/dist/modules/onTTFB.js +2 -4
- package/front_end/third_party/web-vitals/package/dist/modules/types/base.d.ts +6 -5
- package/front_end/third_party/web-vitals/package/dist/modules/types/cls.d.ts +5 -3
- package/front_end/third_party/web-vitals/package/dist/modules/types/inp.d.ts +80 -33
- package/front_end/third_party/web-vitals/package/dist/modules/types/lcp.d.ts +6 -2
- package/front_end/third_party/web-vitals/package/dist/modules/types.d.ts +28 -4
- package/front_end/third_party/web-vitals/package/dist/modules/types.js +0 -1
- package/front_end/third_party/web-vitals/package/package.json +4 -10
- package/front_end/third_party/web-vitals/package/src/attribution/index.ts +0 -1
- package/front_end/third_party/web-vitals/package/src/attribution/onCLS.ts +58 -33
- package/front_end/third_party/web-vitals/package/src/attribution/onFCP.ts +4 -4
- package/front_end/third_party/web-vitals/package/src/attribution/onINP.ts +382 -258
- package/front_end/third_party/web-vitals/package/src/attribution/onLCP.ts +96 -69
- package/front_end/third_party/web-vitals/package/src/attribution/onTTFB.ts +3 -3
- package/front_end/third_party/web-vitals/package/src/index.ts +0 -1
- package/front_end/third_party/web-vitals/package/src/lib/InteractionManager.ts +146 -0
- package/front_end/third_party/web-vitals/package/src/{attribution/deprecated.ts → lib/LCPEntryManager.ts} +6 -9
- package/front_end/third_party/web-vitals/package/src/lib/LayoutShiftManager.ts +50 -0
- package/front_end/third_party/web-vitals/package/src/lib/bindReporter.ts +1 -1
- package/front_end/third_party/web-vitals/package/src/lib/generateUniqueID.ts +1 -1
- package/front_end/third_party/web-vitals/package/src/lib/getActivationStart.ts +1 -1
- package/front_end/third_party/web-vitals/package/src/lib/getNavigationEntry.ts +5 -8
- package/front_end/third_party/web-vitals/package/src/lib/getSelector.ts +12 -12
- package/front_end/third_party/web-vitals/package/src/lib/getVisibilityWatcher.ts +57 -35
- package/front_end/third_party/web-vitals/package/src/lib/initMetric.ts +2 -2
- package/front_end/third_party/web-vitals/package/src/{deprecated.ts → lib/initUnique.ts} +14 -8
- package/front_end/third_party/web-vitals/package/src/lib/observe.ts +3 -11
- package/front_end/third_party/web-vitals/package/src/lib/polyfills/interactionCountPolyfill.ts +12 -6
- package/front_end/third_party/web-vitals/package/src/lib/{whenIdle.ts → whenIdleOrHidden.ts} +10 -8
- package/front_end/third_party/web-vitals/package/src/onCLS.ts +17 -38
- package/front_end/third_party/web-vitals/package/src/onFCP.ts +3 -6
- package/front_end/third_party/web-vitals/package/src/onINP.ts +33 -28
- package/front_end/third_party/web-vitals/package/src/onLCP.ts +36 -29
- package/front_end/third_party/web-vitals/package/src/onTTFB.ts +2 -5
- package/front_end/third_party/web-vitals/package/src/types/base.ts +5 -5
- package/front_end/third_party/web-vitals/package/src/types/cls.ts +5 -3
- package/front_end/third_party/web-vitals/package/src/types/inp.ts +88 -33
- package/front_end/third_party/web-vitals/package/src/types/lcp.ts +6 -2
- package/front_end/third_party/web-vitals/package/src/types.ts +47 -4
- package/front_end/third_party/web-vitals/patches/0001-Add-onEachInteraction-to-onINP-options.patch +75 -0
- package/front_end/third_party/web-vitals/rebuild.sh +32 -18
- package/front_end/third_party/web-vitals/web-vitals-tsconfig.json +5 -10
- package/front_end/third_party/web-vitals/web-vitals.ts +0 -2
- package/front_end/ui/components/buttons/Button.ts +1 -1
- package/front_end/ui/components/docs/console_insight/basic.ts +3 -2
- package/front_end/ui/components/legacy_wrapper/LegacyWrapper.ts +2 -0
- package/front_end/ui/components/text_editor/TextEditor.ts +0 -2
- package/front_end/ui/legacy/EmptyWidget.ts +11 -1
- package/front_end/ui/legacy/InspectorView.ts +2 -0
- package/front_end/ui/legacy/SplitWidget.ts +2 -0
- package/front_end/ui/legacy/TabbedPane.ts +1 -0
- package/front_end/ui/legacy/TargetCrashedScreen.ts +1 -0
- package/front_end/ui/legacy/Toolbar.ts +25 -4
- package/front_end/ui/legacy/UIUtils.ts +28 -13
- package/front_end/ui/legacy/ViewManager.ts +1 -0
- package/front_end/ui/legacy/Widget.ts +5 -0
- package/front_end/ui/legacy/components/color_picker/FormatPickerContextMenu.ts +7 -20
- package/front_end/ui/legacy/components/color_picker/Spectrum.ts +2 -0
- package/front_end/ui/legacy/components/cookie_table/CookiesTable.ts +1 -0
- package/front_end/ui/legacy/components/data_grid/DataGridElement.ts +1 -1
- package/front_end/ui/legacy/components/inline_editor/BezierEditor.ts +1 -0
- package/front_end/ui/legacy/components/perf_ui/ChartViewport.ts +1 -0
- package/front_end/ui/legacy/components/quick_open/FilteredListWidget.ts +1 -0
- package/front_end/ui/legacy/components/source_frame/FontView.ts +1 -0
- package/front_end/ui/legacy/components/source_frame/ImageView.ts +1 -0
- package/front_end/ui/legacy/components/source_frame/JSONView.ts +1 -0
- package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +1 -0
- package/front_end/ui/legacy/components/source_frame/StreamingContentHexView.ts +9 -8
- package/front_end/ui/visual_logging/KnownContextValues.ts +17 -0
- package/mcp/README.md +7 -0
- package/mcp/mcp.ts +8 -0
- package/package.json +1 -1
- package/front_end/models/live-metrics/web-vitals-injected/OnEachInteraction.ts +0 -34
- package/front_end/third_party/web-vitals/package/attribution.d.ts +0 -16
- package/front_end/third_party/web-vitals/package/attribution.js +0 -18
- package/front_end/third_party/web-vitals/package/dist/modules/attribution/deprecated.d.ts +0 -7
- package/front_end/third_party/web-vitals/package/dist/modules/attribution/onFID.d.ts +0 -11
- package/front_end/third_party/web-vitals/package/dist/modules/attribution/onFID.js +0 -46
- package/front_end/third_party/web-vitals/package/dist/modules/deprecated.d.ts +0 -5
- package/front_end/third_party/web-vitals/package/dist/modules/lib/interactions.d.ts +0 -31
- package/front_end/third_party/web-vitals/package/dist/modules/lib/interactions.js +0 -107
- package/front_end/third_party/web-vitals/package/dist/modules/lib/onHidden.d.ts +0 -1
- package/front_end/third_party/web-vitals/package/dist/modules/lib/onHidden.js +0 -22
- package/front_end/third_party/web-vitals/package/dist/modules/lib/polyfills/firstInputPolyfill.d.ts +0 -7
- package/front_end/third_party/web-vitals/package/dist/modules/lib/polyfills/firstInputPolyfill.js +0 -147
- package/front_end/third_party/web-vitals/package/dist/modules/lib/polyfills/getFirstHiddenTimePolyfill.d.ts +0 -1
- package/front_end/third_party/web-vitals/package/dist/modules/lib/polyfills/getFirstHiddenTimePolyfill.js +0 -25
- package/front_end/third_party/web-vitals/package/dist/modules/onFID.d.ts +0 -13
- package/front_end/third_party/web-vitals/package/dist/modules/onFID.js +0 -70
- package/front_end/third_party/web-vitals/package/dist/modules/types/fid.d.ts +0 -46
- package/front_end/third_party/web-vitals/package/dist/modules/types/fid.js +0 -16
- package/front_end/third_party/web-vitals/package/src/attribution/onFID.ts +0 -62
- package/front_end/third_party/web-vitals/package/src/lib/interactions.ts +0 -139
- package/front_end/third_party/web-vitals/package/src/lib/onHidden.ts +0 -23
- package/front_end/third_party/web-vitals/package/src/lib/polyfills/firstInputPolyfill.ts +0 -174
- package/front_end/third_party/web-vitals/package/src/onFID.ts +0 -105
- package/front_end/third_party/web-vitals/package/src/types/fid.ts +0 -65
- package/front_end/ui/components/text_editor/textEditor.css +0 -18
- package/front_end/ui/legacy/inlineButton.css +0 -22
- /package/front_end/entrypoints/{rehydrated_devtools_app/rehydrated_devtools_app.ts → trace_app/trace_app.ts} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Name: Web Vitals
|
|
2
2
|
Short Name: Web Vitals
|
|
3
3
|
URL: https://github.com/GoogleChrome/web-vitals
|
|
4
|
-
Version:
|
|
4
|
+
Version: 5.1.0
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
License File: package/LICENSE
|
|
7
|
-
Revision:
|
|
7
|
+
Revision: 1b872cf5f2159e8ace0e98d55d8eb54fb09adfbe
|
|
8
8
|
Update Mechanism: Manual
|
|
9
9
|
Security Critical: no
|
|
10
10
|
Shipped: yes
|
|
@@ -14,15 +14,12 @@ Essential metrics for a healthy site.
|
|
|
14
14
|
|
|
15
15
|
## Bumping.
|
|
16
16
|
|
|
17
|
+
First, go update rebuild.sh to specify the version you want. Then run the rebuild script:
|
|
18
|
+
|
|
17
19
|
```bash
|
|
18
20
|
./front_end/third_party/web-vitals/rebuild.sh
|
|
19
|
-
|
|
20
|
-
# Also, consider commenting out roll script to just recompile without a bump, however this will reset some edits 2,3 listed below.
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## DevTools edits to web-vitals
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
2. Some lines are manually commented out in `attribution/onINP.js`'s `saveInteractionTarget`. b/376777343 Unknown if needed in v5.
|
|
27
|
-
3. Some lines are added in `onHidden.js` to resolve a memory leak. Not needed in v5. b/425309898#comment4
|
|
28
|
-
4. (Not part of package, but..) There's a hack to clear `interactionTargetElement` in our own web-vitals-injected that won't be necessary in v5.
|
|
25
|
+
Local patches are kept in the "patches" folder. See the note in rebuild.sh for how to change these patches.
|
|
@@ -42,17 +42,13 @@ The library supports all of the [Core Web Vitals](https://web.dev/articles/vital
|
|
|
42
42
|
|
|
43
43
|
- [First Contentful Paint (FCP)](https://web.dev/articles/fcp)
|
|
44
44
|
- [Time to First Byte (TTFB)](https://web.dev/articles/ttfb)
|
|
45
|
-
- [First Input Delay (FID)](https://web.dev/articles/fid)
|
|
46
45
|
|
|
47
|
-
>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<a name="installation"><a>
|
|
51
|
-
<a name="load-the-library"><a>
|
|
46
|
+
<a name="installation"></a>
|
|
47
|
+
<a name="load-the-library"></a>
|
|
52
48
|
|
|
53
49
|
## Install and load the library
|
|
54
50
|
|
|
55
|
-
<a name="import-web-vitals-from-npm"
|
|
51
|
+
<a name="import-web-vitals-from-npm"></a>
|
|
56
52
|
|
|
57
53
|
The `web-vitals` library uses the `buffered` flag for [PerformanceObserver](https://developer.mozilla.org/docs/Web/API/PerformanceObserver/observe), allowing it to access performance entries that occurred before the library was loaded.
|
|
58
54
|
|
|
@@ -79,16 +75,9 @@ To load the "standard" build, import modules from the `web-vitals` package in yo
|
|
|
79
75
|
|
|
80
76
|
```js
|
|
81
77
|
import {onLCP, onINP, onCLS} from 'web-vitals';
|
|
82
|
-
|
|
83
|
-
onCLS(console.log);
|
|
84
|
-
onINP(console.log);
|
|
85
|
-
onLCP(console.log);
|
|
86
78
|
```
|
|
87
79
|
|
|
88
|
-
>
|
|
89
|
-
> In version 2, these functions were named `getXXX()` rather than `onXXX()`. They've [been renamed](https://github.com/GoogleChrome/web-vitals/pull/222) in version 3 to reduce confusion (see [#217](https://github.com/GoogleChrome/web-vitals/pull/217) for details) and will continue to be available using the `getXXX()` until at least version 4. Users are encouraged to switch to the new names, though, for future compatibility.
|
|
90
|
-
|
|
91
|
-
<a name="attribution-build"><a>
|
|
80
|
+
<a name="attribution-build"></a>
|
|
92
81
|
|
|
93
82
|
**2. The "attribution" build**
|
|
94
83
|
|
|
@@ -96,20 +85,20 @@ Measuring the Web Vitals scores for your real users is a great first step toward
|
|
|
96
85
|
|
|
97
86
|
The "attribution" build helps you do that by including additional diagnostic information with each metric to help you identify the root cause of poor performance as well as prioritize the most important things to fix.
|
|
98
87
|
|
|
99
|
-
The "attribution" build is slightly larger than the "standard" build (by about
|
|
88
|
+
The "attribution" build is slightly larger than the "standard" build (by about 1.5K, brotli'd), so while the code size is still small, it's only recommended if you're actually using these features.
|
|
100
89
|
|
|
101
90
|
To load the "attribution" build, change any `import` statements that reference `web-vitals` to `web-vitals/attribution`:
|
|
102
91
|
|
|
103
92
|
```diff
|
|
104
|
-
|
|
105
|
-
|
|
93
|
+
import {onLCP, onINP, onCLS} from 'web-vitals';
|
|
94
|
+
import {onLCP, onINP, onCLS} from 'web-vitals/attribution';
|
|
106
95
|
```
|
|
107
96
|
|
|
108
97
|
Usage for each of the imported function is identical to the standard build, but when importing from the attribution build, the [metric](#metric) objects will contain an additional [`attribution`](#attribution) property.
|
|
109
98
|
|
|
110
99
|
See [Send attribution data](#send-attribution-data) for usage examples, and the [`attribution` reference](#attribution) for details on what values are added for each metric.
|
|
111
100
|
|
|
112
|
-
<a name="load-web-vitals-from-a-cdn"
|
|
101
|
+
<a name="load-web-vitals-from-a-cdn"></a>
|
|
113
102
|
|
|
114
103
|
### From a CDN
|
|
115
104
|
|
|
@@ -124,7 +113,7 @@ _**Important!** The [unpkg.com](https://unpkg.com), [jsDelivr](https://www.jsdel
|
|
|
124
113
|
```html
|
|
125
114
|
<!-- Append the `?module` param to load the module version of `web-vitals` -->
|
|
126
115
|
<script type="module">
|
|
127
|
-
import {onCLS, onINP, onLCP} from 'https://unpkg.com/web-vitals@
|
|
116
|
+
import {onCLS, onINP, onLCP} from 'https://unpkg.com/web-vitals@5?module';
|
|
128
117
|
|
|
129
118
|
onCLS(console.log);
|
|
130
119
|
onINP(console.log);
|
|
@@ -132,13 +121,15 @@ _**Important!** The [unpkg.com](https://unpkg.com), [jsDelivr](https://www.jsdel
|
|
|
132
121
|
</script>
|
|
133
122
|
```
|
|
134
123
|
|
|
124
|
+
Note: When the web-vitals code is isolated from the application code in this way, there is less need to depend on dynamic imports so this code uses a regular `import` line.
|
|
125
|
+
|
|
135
126
|
**Load the "standard" build** _(using a classic script)_
|
|
136
127
|
|
|
137
128
|
```html
|
|
138
129
|
<script>
|
|
139
130
|
(function () {
|
|
140
131
|
var script = document.createElement('script');
|
|
141
|
-
script.src = 'https://unpkg.com/web-vitals@
|
|
132
|
+
script.src = 'https://unpkg.com/web-vitals@5/dist/web-vitals.iife.js';
|
|
142
133
|
script.onload = function () {
|
|
143
134
|
// When loading `web-vitals` using a classic script, all the public
|
|
144
135
|
// methods can be found on the `webVitals` global namespace.
|
|
@@ -160,7 +151,7 @@ _**Important!** The [unpkg.com](https://unpkg.com), [jsDelivr](https://www.jsdel
|
|
|
160
151
|
onCLS,
|
|
161
152
|
onINP,
|
|
162
153
|
onLCP,
|
|
163
|
-
} from 'https://unpkg.com/web-vitals@
|
|
154
|
+
} from 'https://unpkg.com/web-vitals@5/dist/web-vitals.attribution.js?module';
|
|
164
155
|
|
|
165
156
|
onCLS(console.log);
|
|
166
157
|
onINP(console.log);
|
|
@@ -175,7 +166,7 @@ _**Important!** The [unpkg.com](https://unpkg.com), [jsDelivr](https://www.jsdel
|
|
|
175
166
|
(function () {
|
|
176
167
|
var script = document.createElement('script');
|
|
177
168
|
script.src =
|
|
178
|
-
'https://unpkg.com/web-vitals@
|
|
169
|
+
'https://unpkg.com/web-vitals@5/dist/web-vitals.attribution.iife.js';
|
|
179
170
|
script.onload = function () {
|
|
180
171
|
// When loading `web-vitals` using a classic script, all the public
|
|
181
172
|
// methods can be found on the `webVitals` global namespace.
|
|
@@ -210,8 +201,8 @@ Note that some of these metrics will not report until the user has interacted wi
|
|
|
210
201
|
|
|
211
202
|
Also, in some cases a metric callback may never be called:
|
|
212
203
|
|
|
213
|
-
-
|
|
214
|
-
- CLS, FCP,
|
|
204
|
+
- INP is not reported if the user never interacts with the page.
|
|
205
|
+
- CLS, FCP, and LCP are not reported if the page was loaded in the background.
|
|
215
206
|
|
|
216
207
|
In other cases, a metric callback may be called more than once:
|
|
217
208
|
|
|
@@ -225,8 +216,7 @@ In other cases, a metric callback may be called more than once:
|
|
|
225
216
|
|
|
226
217
|
In most cases, you only want the `callback` function to be called when the metric is ready to be reported. However, it is possible to report every change (e.g. each larger layout shift as it happens) by setting `reportAllChanges` to `true` in the optional, [configuration object](#reportopts) (second parameter).
|
|
227
218
|
|
|
228
|
-
> [!IMPORTANT]
|
|
229
|
-
> `reportAllChanges` only reports when the **metric changes**, not for each **input to the metric**. For example, a new layout shift that does not increase the CLS metric will not be reported even with `reportAllChanges` set to `true` because the CLS metric has not changed. Similarly, for INP, each interaction is not reported even with `reportAllChanges` set to `true`—just when an interaction causes an increase to INP.
|
|
219
|
+
> [!IMPORTANT] > `reportAllChanges` only reports when the **metric changes**, not for each **input to the metric**. For example, a new layout shift that does not increase the CLS metric will not be reported even with `reportAllChanges` set to `true` because the CLS metric has not changed. Similarly, for INP, each interaction is not reported even with `reportAllChanges` set to `true`—just when an interaction causes an increase to INP.
|
|
230
220
|
|
|
231
221
|
This can be useful when debugging, but in general using `reportAllChanges` is not needed (or recommended) for measuring these metrics in production.
|
|
232
222
|
|
|
@@ -266,19 +256,23 @@ In addition to using the `id` field to group multiple deltas for the same metric
|
|
|
266
256
|
|
|
267
257
|
The following example measures each of the Core Web Vitals metrics and reports them to a hypothetical `/analytics` endpoint, as soon as each is ready to be sent.
|
|
268
258
|
|
|
269
|
-
The `sendToAnalytics()` function uses the [`navigator.sendBeacon()`](https://developer.mozilla.org/docs/Web/API/Navigator/sendBeacon) method
|
|
259
|
+
The `sendToAnalytics()` function uses the [`navigator.sendBeacon()`](https://developer.mozilla.org/docs/Web/API/Navigator/sendBeacon) method, which is widely available across browsers, and supports sending data as the page is being unloaded.
|
|
270
260
|
|
|
271
261
|
```js
|
|
272
262
|
import {onCLS, onINP, onLCP} from 'web-vitals';
|
|
273
263
|
|
|
274
264
|
function sendToAnalytics(metric) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
265
|
+
const body = JSON.stringify({
|
|
266
|
+
name: metric.name,
|
|
267
|
+
value: metric.value,
|
|
268
|
+
id: metric.id,
|
|
269
|
+
|
|
270
|
+
// Include additional data as needed...
|
|
271
|
+
});
|
|
278
272
|
|
|
279
|
-
// Use `navigator.sendBeacon()`
|
|
280
|
-
|
|
281
|
-
|
|
273
|
+
// Use `navigator.sendBeacon()` to send the data, which supports
|
|
274
|
+
// sending while the page is unloading.
|
|
275
|
+
navigator.sendBeacon('/analytics', body);
|
|
282
276
|
}
|
|
283
277
|
|
|
284
278
|
onCLS(sendToAnalytics);
|
|
@@ -396,9 +390,9 @@ function flushQueue() {
|
|
|
396
390
|
// Note: JSON.stringify will likely include more data than you need.
|
|
397
391
|
const body = JSON.stringify([...queue]);
|
|
398
392
|
|
|
399
|
-
// Use `navigator.sendBeacon()`
|
|
400
|
-
|
|
401
|
-
|
|
393
|
+
// Use `navigator.sendBeacon()` to send the data, which supports
|
|
394
|
+
// sending while the page is unloading.
|
|
395
|
+
navigator.sendBeacon('/analytics', body);
|
|
402
396
|
|
|
403
397
|
queue.clear();
|
|
404
398
|
}
|
|
@@ -419,7 +413,7 @@ addEventListener('visibilitychange', () => {
|
|
|
419
413
|
> [!NOTE]
|
|
420
414
|
> See [the Page Lifecycle guide](https://developers.google.com/web/updates/2018/07/page-lifecycle-api#legacy-lifecycle-apis-to-avoid) for an explanation of why `visibilitychange` is recommended over events like `beforeunload` and `unload`.
|
|
421
415
|
|
|
422
|
-
<a name="bundle-versions"
|
|
416
|
+
<a name="bundle-versions"></a>
|
|
423
417
|
|
|
424
418
|
## Build options
|
|
425
419
|
|
|
@@ -481,7 +475,7 @@ The following table lists all the builds distributed with the `web-vitals` packa
|
|
|
481
475
|
</tr>
|
|
482
476
|
</table>
|
|
483
477
|
|
|
484
|
-
<a name="which-build-is-right-for-you"
|
|
478
|
+
<a name="which-build-is-right-for-you"></a>
|
|
485
479
|
|
|
486
480
|
### Which build is right for you?
|
|
487
481
|
|
|
@@ -504,7 +498,7 @@ interface Metric {
|
|
|
504
498
|
/**
|
|
505
499
|
* The name of the metric (in acronym form).
|
|
506
500
|
*/
|
|
507
|
-
name: 'CLS' | 'FCP' | '
|
|
501
|
+
name: 'CLS' | 'FCP' | 'INP' | 'LCP' | 'TTFB';
|
|
508
502
|
|
|
509
503
|
/**
|
|
510
504
|
* The current value of the metric.
|
|
@@ -583,18 +577,6 @@ interface FCPMetric extends Metric {
|
|
|
583
577
|
}
|
|
584
578
|
```
|
|
585
579
|
|
|
586
|
-
##### `FIDMetric`
|
|
587
|
-
|
|
588
|
-
> [!CAUTION]
|
|
589
|
-
> This interface is deprecated and will be removed in the next major release.
|
|
590
|
-
|
|
591
|
-
```ts
|
|
592
|
-
interface FIDMetric extends Metric {
|
|
593
|
-
name: 'FID';
|
|
594
|
-
entries: PerformanceEventTiming[];
|
|
595
|
-
}
|
|
596
|
-
```
|
|
597
|
-
|
|
598
580
|
##### `INPMetric`
|
|
599
581
|
|
|
600
582
|
```ts
|
|
@@ -647,6 +629,35 @@ _See also [Rating Thresholds](#rating-thresholds)._
|
|
|
647
629
|
```ts
|
|
648
630
|
interface ReportOpts {
|
|
649
631
|
reportAllChanges?: boolean;
|
|
632
|
+
}
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
Metric-specific subclasses:
|
|
636
|
+
|
|
637
|
+
##### `INPReportOpts`
|
|
638
|
+
|
|
639
|
+
```ts
|
|
640
|
+
interface INPReportOpts extends ReportOpts {
|
|
641
|
+
durationThreshold?: number;
|
|
642
|
+
}
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
#### `AttributionReportOpts`
|
|
646
|
+
|
|
647
|
+
A subclass of `ReportOpts` used for each metric function exported in the [attribution build](#attribution).
|
|
648
|
+
|
|
649
|
+
```ts
|
|
650
|
+
interface AttributionReportOpts extends ReportOpts {
|
|
651
|
+
generateTarget?: (el: Node | null) => string | null | undefined;
|
|
652
|
+
}
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
Metric-specific subclasses:
|
|
656
|
+
|
|
657
|
+
##### `INPAttributionReportOpts`
|
|
658
|
+
|
|
659
|
+
```ts
|
|
660
|
+
interface INPAttributionReportOpts extends AttributionReportOpts {
|
|
650
661
|
durationThreshold?: number;
|
|
651
662
|
}
|
|
652
663
|
```
|
|
@@ -688,11 +699,11 @@ function onCLS(callback: (metric: CLSMetric) => void, opts?: ReportOpts): void;
|
|
|
688
699
|
|
|
689
700
|
Calculates the [CLS](https://web.dev/articles/cls) value for the current page and calls the `callback` function once the value is ready to be reported, along with all `layout-shift` performance entries that were used in the metric value calculation. The reported value is a [double](https://heycam.github.io/webidl/#idl-double) (corresponding to a [layout shift score](https://web.dev/articles/cls#layout_shift_score)).
|
|
690
701
|
|
|
691
|
-
If the `reportAllChanges` [configuration option](#reportopts) is set to `true`, the `callback` function will be called as soon as the value is initially determined as well as any time the value changes throughout the page lifespan (Note [not necessarily for every layout shift](#report-the-value-on-every-change)).
|
|
692
|
-
|
|
693
702
|
> [!IMPORTANT]
|
|
694
703
|
> CLS should be continually monitored for changes throughout the entire lifespan of a page—including if the user returns to the page after it's been hidden/backgrounded. However, since browsers often [will not fire additional callbacks once the user has backgrounded a page](https://developer.chrome.com/blog/page-lifecycle-api/#advice-hidden), `callback` is always called when the page's visibility state changes to hidden. As a result, the `callback` function might be called multiple times during the same page load (see [Reporting only the delta of changes](#report-only-the-delta-of-changes) for how to manage this).
|
|
695
704
|
|
|
705
|
+
If the `reportAllChanges` [configuration option](#reportopts) is set to `true`, the `callback` function will be called as soon as the value is initially determined as well as any time the value changes throughout the page lifespan (though [not necessarily for every layout shift](#report-the-value-on-every-change)). Note that regardless of whether `reportAllChanges` is used, the final reported value will be the same.
|
|
706
|
+
|
|
696
707
|
#### `onFCP()`
|
|
697
708
|
|
|
698
709
|
```ts
|
|
@@ -701,35 +712,24 @@ function onFCP(callback: (metric: FCPMetric) => void, opts?: ReportOpts): void;
|
|
|
701
712
|
|
|
702
713
|
Calculates the [FCP](https://web.dev/articles/fcp) value for the current page and calls the `callback` function once the value is ready, along with the relevant `paint` performance entry used to determine the value. The reported value is a [`DOMHighResTimeStamp`](https://developer.mozilla.org/docs/Web/API/DOMHighResTimeStamp).
|
|
703
714
|
|
|
704
|
-
#### `onFID()`
|
|
705
|
-
|
|
706
|
-
> [!CAUTION]
|
|
707
|
-
> This function is deprecated and will be removed in the next major release.
|
|
708
|
-
|
|
709
|
-
```ts
|
|
710
|
-
function onFID(callback: (metric: FIDMetric) => void, opts?: ReportOpts): void;
|
|
711
|
-
```
|
|
712
|
-
|
|
713
|
-
Calculates the [FID](https://web.dev/articles/fid) value for the current page and calls the `callback` function once the value is ready, along with the relevant `first-input` performance entry used to determine the value. The reported value is a [`DOMHighResTimeStamp`](https://developer.mozilla.org/docs/Web/API/DOMHighResTimeStamp).
|
|
714
|
-
|
|
715
|
-
> [!IMPORTANT]
|
|
716
|
-
> Since FID is only reported after the user interacts with the page, it's possible that it will not be reported for some page loads.
|
|
717
|
-
|
|
718
715
|
#### `onINP()`
|
|
719
716
|
|
|
720
717
|
```ts
|
|
721
|
-
function onINP(
|
|
718
|
+
function onINP(
|
|
719
|
+
callback: (metric: INPMetric) => void,
|
|
720
|
+
opts?: INPReportOpts,
|
|
721
|
+
): void;
|
|
722
722
|
```
|
|
723
723
|
|
|
724
724
|
Calculates the [INP](https://web.dev/articles/inp) value for the current page and calls the `callback` function once the value is ready, along with the `event` performance entries reported for that interaction. The reported value is a [`DOMHighResTimeStamp`](https://developer.mozilla.org/docs/Web/API/DOMHighResTimeStamp).
|
|
725
725
|
|
|
726
|
-
A custom `durationThreshold` [configuration option](#reportopts) can optionally be passed to control what `event-timing` entries are considered for INP reporting. The default threshold is `40`, which means INP scores of less than 40 are reported as 0. Note that this will not affect your 75th percentile INP value unless that value is also less than 40 (well below the recommended [good](https://web.dev/articles/inp#what_is_a_good_inp_score) threshold).
|
|
727
|
-
|
|
728
|
-
If the `reportAllChanges` [configuration option](#reportopts) is set to `true`, the `callback` function will be called as soon as the value is initially determined as well as any time the value changes throughout the page lifespan (Note [not necessarily for every interaction](#report-the-value-on-every-change)).
|
|
729
|
-
|
|
730
726
|
> [!IMPORTANT]
|
|
731
727
|
> INP should be continually monitored for changes throughout the entire lifespan of a page—including if the user returns to the page after it's been hidden/backgrounded. However, since browsers often [will not fire additional callbacks once the user has backgrounded a page](https://developer.chrome.com/blog/page-lifecycle-api/#advice-hidden), `callback` is always called when the page's visibility state changes to hidden. As a result, the `callback` function might be called multiple times during the same page load (see [Reporting only the delta of changes](#report-only-the-delta-of-changes) for how to manage this).
|
|
732
728
|
|
|
729
|
+
A custom `durationThreshold` [configuration option](#reportopts) can optionally be passed to control the minimum duration filter for `event-timing`. Events which are faster than this threshold are not reported. Note that the `first-input` entry is always observed, regardless of duration, to ensure you always have some INP score. The default threshold, after the library is initialized, is `40` milliseconds (the `event-timing` default of `104` milliseconds applies to all events emitted before the library is initialised). This default threshold of `40` is chosen to strike a balance between usefulness and performance. Running this callback for any interaction that spans just one or two frames is likely not worth the insight that could be gained.
|
|
730
|
+
|
|
731
|
+
If the `reportAllChanges` [configuration option](#reportopts) is set to `true`, the `callback` function will be called as soon as the value is initially determined as well as any time the value changes throughout the page lifespan (though [not necessarily for every interaction](#report-the-value-on-every-change)). Note that regardless of whether `reportAllChanges` is used, the final reported value will be the same.
|
|
732
|
+
|
|
733
733
|
#### `onLCP()`
|
|
734
734
|
|
|
735
735
|
```ts
|
|
@@ -738,7 +738,7 @@ function onLCP(callback: (metric: LCPMetric) => void, opts?: ReportOpts): void;
|
|
|
738
738
|
|
|
739
739
|
Calculates the [LCP](https://web.dev/articles/lcp) value for the current page and calls the `callback` function once the value is ready (along with the relevant `largest-contentful-paint` performance entry used to determine the value). The reported value is a [`DOMHighResTimeStamp`](https://developer.mozilla.org/docs/Web/API/DOMHighResTimeStamp).
|
|
740
740
|
|
|
741
|
-
If the `reportAllChanges` [configuration option](#reportopts) is set to `true`, the `callback` function will be called any time a new `largest-contentful-paint` performance entry is dispatched, or once the final value of the metric has been determined.
|
|
741
|
+
If the `reportAllChanges` [configuration option](#reportopts) is set to `true`, the `callback` function will be called any time a new `largest-contentful-paint` performance entry is dispatched, or once the final value of the metric has been determined. Note that regardless of whether `reportAllChanges` is used, the final reported value will be the same.
|
|
742
742
|
|
|
743
743
|
#### `onTTFB()`
|
|
744
744
|
|
|
@@ -788,20 +788,44 @@ console.log(LCPThresholds); // [ 2500, 4000 ]
|
|
|
788
788
|
|
|
789
789
|
### Attribution:
|
|
790
790
|
|
|
791
|
-
|
|
791
|
+
In the [attribution build](#attribution-build) each of the metric functions has two primary differences from their standard build counterparts:
|
|
792
|
+
|
|
793
|
+
1. Their callback is invoked with a `MetricWithAttribution` objects instead of a `Metric` object. Each `MetricWithAttribution` extends the `Metric` object and adds an additional `attribution` object, which contains potentially-helpful debugging information that can be sent along with the metric values for the current page visit in order to help identify issues happening to real-users in the field.
|
|
794
|
+
|
|
795
|
+
2. They accept an `AttributionReportOpts` objects instead of a `ReportOpts` object. The `AttributionReportOpts` object supports an additional, optional, `generateTarget()` function that lets developers customize how DOM elements are stringified for reporting purposes. When passed, the return value of the `generateTarget()` function will be used for any "target" properties in the following attribution objects: [`CLSAttribution`](#CLSAttribution), [`INPAttribution`](#INPAttribution), and [`LCPAttribution`](#LCPAttribution). If `null` or `undefined` is returned by the `generateTarget()` function, or no function is given, then the default selector function will be used.
|
|
792
796
|
|
|
793
|
-
|
|
797
|
+
```ts
|
|
798
|
+
interface AttributionReportOpts extends ReportOpts {
|
|
799
|
+
generateTarget?: (el: Node | null) => string | null | undefined;
|
|
800
|
+
}
|
|
801
|
+
```
|
|
794
802
|
|
|
795
|
-
|
|
803
|
+
For example, if a web page has unique `data-name` attibute on many elements, you may prefer to use those over the built-in selector-style strings that are generated by default.
|
|
804
|
+
|
|
805
|
+
```js
|
|
806
|
+
function customGenerateTarget(el) {
|
|
807
|
+
if (el.dataset.name) {
|
|
808
|
+
return el.dataset.name;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
// Otherwise use default selector function
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
onLCP(sendToAnalytics, {generateTarget: customGenerateTarget});
|
|
815
|
+
```
|
|
816
|
+
|
|
817
|
+
The next sections document the shape of the `attribution` object for each of the metrics:
|
|
796
818
|
|
|
797
819
|
#### `CLSAttribution`
|
|
798
820
|
|
|
799
821
|
```ts
|
|
800
822
|
interface CLSAttribution {
|
|
801
823
|
/**
|
|
802
|
-
*
|
|
803
|
-
* shifted when the single largest layout shift
|
|
804
|
-
* CLS score occurred.
|
|
824
|
+
* By default, a selector identifying the first element (in document order)
|
|
825
|
+
* that shifted when the single largest layout shift that contributed to the
|
|
826
|
+
* page's CLS score occurred. If the `generateTarget` configuration option
|
|
827
|
+
* was passed, then this will instead be the return value of that function,
|
|
828
|
+
* falling back to the default if that returns null or undefined.
|
|
805
829
|
*/
|
|
806
830
|
largestShiftTarget?: string;
|
|
807
831
|
/**
|
|
@@ -867,77 +891,26 @@ interface FCPAttribution {
|
|
|
867
891
|
}
|
|
868
892
|
```
|
|
869
893
|
|
|
870
|
-
#### `FIDAttribution`
|
|
871
|
-
|
|
872
|
-
> [!CAUTION]
|
|
873
|
-
> This interface is deprecated and will be removed in the next major release.
|
|
874
|
-
|
|
875
|
-
```ts
|
|
876
|
-
interface FIDAttribution {
|
|
877
|
-
/**
|
|
878
|
-
* A selector identifying the element that the user interacted with. This
|
|
879
|
-
* element will be the `target` of the `event` dispatched.
|
|
880
|
-
*/
|
|
881
|
-
eventTarget: string;
|
|
882
|
-
/**
|
|
883
|
-
* The time when the user interacted. This time will match the `timeStamp`
|
|
884
|
-
* value of the `event` dispatched.
|
|
885
|
-
*/
|
|
886
|
-
eventTime: number;
|
|
887
|
-
/**
|
|
888
|
-
* The `type` of the `event` dispatched from the user interaction.
|
|
889
|
-
*/
|
|
890
|
-
eventType: string;
|
|
891
|
-
/**
|
|
892
|
-
* The `PerformanceEventTiming` entry corresponding to FID.
|
|
893
|
-
*/
|
|
894
|
-
eventEntry: PerformanceEventTiming;
|
|
895
|
-
/**
|
|
896
|
-
* The loading state of the document at the time when the first interaction
|
|
897
|
-
* occurred (see `LoadState` for details). If the first interaction occurred
|
|
898
|
-
* while the document was loading and executing script (e.g. usually in the
|
|
899
|
-
* `dom-interactive` phase) it can result in long input delays.
|
|
900
|
-
*/
|
|
901
|
-
loadState: LoadState;
|
|
902
|
-
}
|
|
903
|
-
```
|
|
904
|
-
|
|
905
894
|
#### `INPAttribution`
|
|
906
895
|
|
|
907
896
|
```ts
|
|
908
897
|
interface INPAttribution {
|
|
909
898
|
/**
|
|
910
|
-
*
|
|
911
|
-
* as part of the frame where the INP candidate interaction
|
|
912
|
-
* If this value is an empty string, that generally means the
|
|
913
|
-
* removed from the DOM after the interaction.
|
|
899
|
+
* By default, a selector identifying the element that the user first
|
|
900
|
+
* interacted with as part of the frame where the INP candidate interaction
|
|
901
|
+
* occurred. If this value is an empty string, that generally means the
|
|
902
|
+
* element was removed from the DOM after the interaction. If the
|
|
903
|
+
* `generateTarget` configuration option was passed, then this will instead
|
|
904
|
+
* be the return value of that function, falling back to the default if that
|
|
905
|
+
* returns null or undefined.
|
|
914
906
|
*/
|
|
915
907
|
interactionTarget: string;
|
|
916
|
-
/**
|
|
917
|
-
* A reference to the HTML element identified by `interactionTarget`.
|
|
918
|
-
* NOTE: for attribution purpose, a selector identifying the element is
|
|
919
|
-
* typically more useful than the element itself. However, the element is
|
|
920
|
-
* also made available in case additional context is needed.
|
|
921
|
-
*/
|
|
922
|
-
interactionTargetElement: Node | undefined;
|
|
923
908
|
/**
|
|
924
909
|
* The time when the user first interacted during the frame where the INP
|
|
925
910
|
* candidate interaction occurred (if more than one interaction occurred
|
|
926
911
|
* within the frame, only the first time is reported).
|
|
927
912
|
*/
|
|
928
913
|
interactionTime: DOMHighResTimeStamp;
|
|
929
|
-
/**
|
|
930
|
-
* The best-guess timestamp of the next paint after the interaction.
|
|
931
|
-
* In general, this timestamp is the same as the `startTime + duration` of
|
|
932
|
-
* the event timing entry. However, since `duration` values are rounded to
|
|
933
|
-
* the nearest 8ms, it can sometimes appear that the paint occurred before
|
|
934
|
-
* processing ended (which cannot happen). This value clamps the paint time
|
|
935
|
-
* so it's always after `processingEnd` from the Event Timing API and
|
|
936
|
-
* `renderStart` from the Long Animation Frame API (where available).
|
|
937
|
-
* It also averages the duration values for all entries in the same
|
|
938
|
-
* animation frame, which should be closer to the "real" value.
|
|
939
|
-
*/
|
|
940
|
-
nextPaintTime: DOMHighResTimeStamp;
|
|
941
914
|
/**
|
|
942
915
|
* The type of interaction, based on the event type of the `event` entry
|
|
943
916
|
* that corresponds to the interaction (i.e. the first `event` entry
|
|
@@ -946,20 +919,19 @@ interface INPAttribution {
|
|
|
946
919
|
* and for "keydown" or "keyup" events this will be "keyboard".
|
|
947
920
|
*/
|
|
948
921
|
interactionType: 'pointer' | 'keyboard';
|
|
922
|
+
/**
|
|
923
|
+
* The best-guess timestamp of the next paint after the interaction.
|
|
924
|
+
* In general, this timestamp is the same as the `startTime + duration` of
|
|
925
|
+
* the event timing entry. However, since duration values are rounded to the
|
|
926
|
+
* nearest 8ms (and can be rounded down), this value is clamped to always be
|
|
927
|
+
* reported after the processing times.
|
|
928
|
+
*/
|
|
929
|
+
nextPaintTime: DOMHighResTimeStamp;
|
|
949
930
|
/**
|
|
950
931
|
* An array of Event Timing entries that were processed within the same
|
|
951
932
|
* animation frame as the INP candidate interaction.
|
|
952
933
|
*/
|
|
953
934
|
processedEventEntries: PerformanceEventTiming[];
|
|
954
|
-
/**
|
|
955
|
-
* If the browser supports the Long Animation Frame API, this array will
|
|
956
|
-
* include any `long-animation-frame` entries that intersect with the INP
|
|
957
|
-
* candidate interaction's `startTime` and the `processingEnd` time of the
|
|
958
|
-
* last event processed within that animation frame. If the browser does not
|
|
959
|
-
* support the Long Animation Frame API or no `long-animation-frame` entries
|
|
960
|
-
* are detect, this array will be empty.
|
|
961
|
-
*/
|
|
962
|
-
longAnimationFrameEntries: PerformanceLongAnimationFrameTiming[];
|
|
963
935
|
/**
|
|
964
936
|
* The time from when the user interacted with the page until when the
|
|
965
937
|
* browser was first able to start processing event listeners for that
|
|
@@ -988,6 +960,68 @@ interface INPAttribution {
|
|
|
988
960
|
* (e.g. usually in the `dom-interactive` phase) it can result in long delays.
|
|
989
961
|
*/
|
|
990
962
|
loadState: LoadState;
|
|
963
|
+
/**
|
|
964
|
+
* If the browser supports the Long Animation Frame API, this array will
|
|
965
|
+
* include any `long-animation-frame` entries that intersect with the INP
|
|
966
|
+
* candidate interaction's `startTime` and the `processingEnd` time of the
|
|
967
|
+
* last event processed within that animation frame. If the browser does not
|
|
968
|
+
* support the Long Animation Frame API or no `long-animation-frame` entries
|
|
969
|
+
* are detected, this array will be empty.
|
|
970
|
+
*/
|
|
971
|
+
longAnimationFrameEntries: PerformanceLongAnimationFrameTiming[];
|
|
972
|
+
/**
|
|
973
|
+
* Summary information about the longest script entry intersecting the INP
|
|
974
|
+
* duration. Note, only script entries above 5 milliseconds are reported by
|
|
975
|
+
* the Long Animation Frame API.
|
|
976
|
+
*/
|
|
977
|
+
longestScript?: INPLongestScriptSummary;
|
|
978
|
+
/**
|
|
979
|
+
* The total duration of Long Animation Frame scripts that intersect the INP
|
|
980
|
+
* duration excluding any forced style and layout (that is included in
|
|
981
|
+
* totalStyleAndLayout). Note, this is limited to scripts > 5 milliseconds.
|
|
982
|
+
*/
|
|
983
|
+
totalScriptDuration?: number;
|
|
984
|
+
/**
|
|
985
|
+
* The total style and layout duration from any Long Animation Frames
|
|
986
|
+
* intersecting the INP interaction. This includes any end-of-frame style and
|
|
987
|
+
* layout duration + any forced style and layout duration.
|
|
988
|
+
*/
|
|
989
|
+
totalStyleAndLayoutDuration?: number;
|
|
990
|
+
/**
|
|
991
|
+
* The off main-thread presentation delay from the end of the last Long
|
|
992
|
+
* Animation Frame (where available) until the INP end point.
|
|
993
|
+
*/
|
|
994
|
+
totalPaintDuration?: number;
|
|
995
|
+
/**
|
|
996
|
+
* The total unattributed time not included in any of the previous totals.
|
|
997
|
+
* This includes scripts < 5 milliseconds and other timings not attributed
|
|
998
|
+
* by Long Animation Frame (including when a frame is < 50ms and so has no
|
|
999
|
+
* Long Animation Frame).
|
|
1000
|
+
* When no Long Animation Frames are present this will be undefined, rather
|
|
1001
|
+
* than everything being unattributed to make it clearer when it's expected
|
|
1002
|
+
* to be small.
|
|
1003
|
+
*/
|
|
1004
|
+
totalUnattributedDuration?: number;
|
|
1005
|
+
}
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
#### `INPLongestScriptSummary`
|
|
1009
|
+
|
|
1010
|
+
```ts
|
|
1011
|
+
interface INPLongestScriptSummary {
|
|
1012
|
+
/**
|
|
1013
|
+
* The longest Long Animation Frame script entry that intersects the INP
|
|
1014
|
+
* interaction.
|
|
1015
|
+
*/
|
|
1016
|
+
entry: PerformanceScriptTiming;
|
|
1017
|
+
/**
|
|
1018
|
+
* The INP subpart where the longest script ran.
|
|
1019
|
+
*/
|
|
1020
|
+
subpart: 'input-delay' | 'processing-duration' | 'presentation-delay';
|
|
1021
|
+
/**
|
|
1022
|
+
* The amount of time the longest script intersected the INP duration.
|
|
1023
|
+
*/
|
|
1024
|
+
intersectingDuration: number;
|
|
991
1025
|
}
|
|
992
1026
|
```
|
|
993
1027
|
|
|
@@ -996,9 +1030,13 @@ interface INPAttribution {
|
|
|
996
1030
|
```ts
|
|
997
1031
|
interface LCPAttribution {
|
|
998
1032
|
/**
|
|
999
|
-
*
|
|
1033
|
+
* By default, a selector identifying the element corresponding to the
|
|
1034
|
+
* largest contentful paint for the page. If the `generateTarget`
|
|
1035
|
+
* configuration option was passed, then this will instead be the return
|
|
1036
|
+
* value of that function, falling back to the default if that returns null
|
|
1037
|
+
* or undefined.
|
|
1000
1038
|
*/
|
|
1001
|
-
|
|
1039
|
+
target?: string;
|
|
1002
1040
|
/**
|
|
1003
1041
|
* The URL (if applicable) of the LCP image resource. If the LCP element
|
|
1004
1042
|
* is a text node, this value will not be set.
|
|
@@ -1049,7 +1087,7 @@ interface LCPAttribution {
|
|
|
1049
1087
|
#### `TTFBAttribution`
|
|
1050
1088
|
|
|
1051
1089
|
```ts
|
|
1052
|
-
|
|
1090
|
+
interface TTFBAttribution {
|
|
1053
1091
|
/**
|
|
1054
1092
|
* The total time from when the user initiates loading the page to when the
|
|
1055
1093
|
* page starts to handle the request. Large values here are typically due
|
|
@@ -1089,13 +1127,14 @@ export interface TTFBAttribution {
|
|
|
1089
1127
|
|
|
1090
1128
|
## Browser Support
|
|
1091
1129
|
|
|
1092
|
-
The `web-vitals` code
|
|
1130
|
+
The `web-vitals` code is tested in Chrome, Firefox, and Safari. In addition, all JavaScript features used in the code are part of ([Baseline Widely Available](https://web.dev/baseline)), and thus should run without error in all versions of these browsers released within the last 30 months.
|
|
1131
|
+
|
|
1132
|
+
However, some of the APIs required to capture these metrics are currently only available in Chromium-based browsers (e.g. Chrome, Edge, Opera, Samsung Internet), which means in some browsers those metrics will not be reported.
|
|
1093
1133
|
|
|
1094
1134
|
Browser support for each function is as follows:
|
|
1095
1135
|
|
|
1096
1136
|
- `onCLS()`: Chromium
|
|
1097
1137
|
- `onFCP()`: Chromium, Firefox, Safari
|
|
1098
|
-
- `onFID()`: Chromium, Firefox _(Deprecated)_
|
|
1099
1138
|
- `onINP()`: Chromium
|
|
1100
1139
|
- `onLCP()`: Chromium, Firefox
|
|
1101
1140
|
- `onTTFB()`: Chromium, Firefox, Safari
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CLSMetricWithAttribution,
|
|
1
|
+
import { CLSMetricWithAttribution, AttributionReportOpts } from '../types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Calculates the [CLS](https://web.dev/articles/cls) value for the current page and
|
|
4
4
|
* calls the `callback` function once the value is ready to be reported, along
|
|
@@ -20,4 +20,4 @@ import { CLSMetricWithAttribution, ReportOpts } from '../types.js';
|
|
|
20
20
|
* hidden. As a result, the `callback` function might be called multiple times
|
|
21
21
|
* during the same page load._
|
|
22
22
|
*/
|
|
23
|
-
export declare const onCLS: (onReport: (metric: CLSMetricWithAttribution) => void, opts?:
|
|
23
|
+
export declare const onCLS: (onReport: (metric: CLSMetricWithAttribution) => void, opts?: AttributionReportOpts) => void;
|