chrome-devtools-frontend 1.0.1604514 → 1.0.1605219
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/AUTHORS +1 -0
- package/front_end/Tests.js +23 -7
- package/front_end/core/host/AidaClient.ts +114 -63
- package/front_end/core/host/AidaGcaTranslation.ts +6 -0
- package/front_end/core/host/GcaClient.ts +112 -0
- package/front_end/core/host/UserMetrics.ts +0 -1
- package/front_end/core/host/host.ts +2 -0
- package/front_end/core/root/ExperimentNames.ts +0 -1
- package/front_end/core/root/Runtime.ts +5 -0
- package/front_end/core/sdk/AutofillModel.ts +3 -2
- package/front_end/core/sdk/CSSModel.ts +3 -4
- package/front_end/core/sdk/CSSProperty.ts +1 -1
- package/front_end/core/sdk/ConsoleModel.ts +15 -13
- package/front_end/core/sdk/CookieModel.ts +5 -4
- package/front_end/core/sdk/DOMDebuggerModel.ts +20 -14
- package/front_end/core/sdk/DebuggerModel.ts +21 -36
- package/front_end/core/sdk/EventBreakpointsModel.ts +16 -6
- package/front_end/core/sdk/IsolateManager.ts +12 -7
- package/front_end/entrypoints/main/MainImpl.ts +0 -4
- package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +31 -17
- package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.snapshot.txt +1 -1
- package/front_end/models/emulation/DeviceModeModel.ts +21 -26
- package/front_end/models/trace/insights/LCPDiscovery.ts +14 -6
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +2 -17
- package/front_end/panels/ai_assistance/components/ChatMessage.ts +36 -20
- package/front_end/panels/ai_assistance/components/chatMessage.css +5 -1
- package/front_end/panels/application/ApplicationPanelSidebar.ts +6 -0
- package/front_end/panels/application/IndexedDBViews.ts +0 -9
- package/front_end/panels/application/WebMCPTreeElement.ts +35 -0
- package/front_end/panels/application/WebMCPView.ts +118 -0
- package/front_end/panels/application/application.ts +4 -0
- package/front_end/panels/application/webMCPView.css +65 -0
- package/front_end/panels/common/aiCodeCompletionSummaryToolbar.css +1 -1
- package/front_end/panels/console/consoleView.css +4 -0
- package/front_end/panels/elements/StylesAiCodeCompletionProvider.ts +23 -2
- package/front_end/panels/elements/StylesSidebarPane.ts +85 -20
- package/front_end/panels/elements/elementsPanel.css +14 -0
- package/front_end/panels/network/NetworkLogViewColumns.ts +3 -3
- package/front_end/panels/recorder/components/recordingView.css +0 -6
- package/front_end/panels/sensors/SensorsView.ts +28 -59
- package/front_end/panels/timeline/EventsTimelineTreeView.ts +2 -2
- package/front_end/panels/timeline/ThirdPartyTreeView.ts +35 -36
- package/front_end/panels/timeline/TimelineDetailsView.ts +47 -41
- package/front_end/panels/timeline/TimelineTreeView.ts +13 -13
- package/front_end/panels/timeline/components/LiveMetricsView.ts +839 -783
- package/front_end/panels/timeline/thirdPartyTreeView.css +2 -2
- package/front_end/ui/components/buttons/button.css +2 -2
- package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +0 -11
- package/front_end/ui/legacy/InspectorDrawerView.ts +206 -0
- package/front_end/ui/legacy/InspectorView.ts +41 -91
- package/front_end/ui/legacy/ViewManager.ts +14 -5
- package/front_end/ui/legacy/inspectorDrawerTabbedPane.css +5 -0
- package/front_end/ui/visual_logging/KnownContextValues.ts +2 -1
- package/package.json +1 -1
|
@@ -303,6 +303,802 @@ const UIStrings = {
|
|
|
303
303
|
const str_ = i18n.i18n.registerUIStrings('panels/timeline/components/LiveMetricsView.ts', UIStrings);
|
|
304
304
|
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
305
305
|
|
|
306
|
+
export interface ViewInput {
|
|
307
|
+
isNode: boolean;
|
|
308
|
+
lcpValue?: LiveMetrics.LcpValue;
|
|
309
|
+
clsValue?: LiveMetrics.ClsValue;
|
|
310
|
+
inpValue?: LiveMetrics.InpValue;
|
|
311
|
+
interactions: LiveMetrics.InteractionMap;
|
|
312
|
+
layoutShifts: LiveMetrics.LayoutShift[];
|
|
313
|
+
toggleRecordAction: UI.ActionRegistration.Action;
|
|
314
|
+
recordReloadAction: UI.ActionRegistration.Action;
|
|
315
|
+
cruxManager: CrUXManager.CrUXManager;
|
|
316
|
+
handlePageScopeSelected: (event: Menus.SelectMenu.SelectMenuItemSelectedEvent) => void;
|
|
317
|
+
handleDeviceOptionSelected: (event: Menus.SelectMenu.SelectMenuItemSelectedEvent) => void;
|
|
318
|
+
revealLayoutShiftCluster: (clusterIds: Set<LiveMetrics.LayoutShift['uniqueLayoutShiftId']>) => void;
|
|
319
|
+
revealInteraction: (interaction: LiveMetrics.Interaction) => void;
|
|
320
|
+
logExtraInteractionDetails: (interaction: LiveMetrics.Interaction) => void;
|
|
321
|
+
highlightedInteractionId?: string;
|
|
322
|
+
highlightedLayoutShiftClusterIds?: Set<string>;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export interface ViewOutput {
|
|
326
|
+
shouldKeepInteractionsScrolledToBottom?: () => boolean;
|
|
327
|
+
keepInteractionsScrolledToBottom?: () => void;
|
|
328
|
+
shouldKeepLayoutShiftsScrolledToBottom?: () => boolean;
|
|
329
|
+
keepLayoutShiftsScrolledToBottom?: () => void;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export type View = (input: ViewInput, output: ViewOutput, target: HTMLElement|DocumentFragment) => void;
|
|
333
|
+
|
|
334
|
+
function getLcpFieldPhases(cruxManager: CrUXManager.CrUXManager): LiveMetrics.LcpValue['phases']|null {
|
|
335
|
+
const ttfb =
|
|
336
|
+
cruxManager.getSelectedFieldMetricData('largest_contentful_paint_image_time_to_first_byte')?.percentiles?.p75;
|
|
337
|
+
const loadDelay =
|
|
338
|
+
cruxManager.getSelectedFieldMetricData('largest_contentful_paint_image_resource_load_delay')?.percentiles?.p75;
|
|
339
|
+
const loadDuration =
|
|
340
|
+
cruxManager.getSelectedFieldMetricData('largest_contentful_paint_image_resource_load_duration')?.percentiles?.p75;
|
|
341
|
+
const renderDelay =
|
|
342
|
+
cruxManager.getSelectedFieldMetricData('largest_contentful_paint_image_element_render_delay')?.percentiles?.p75;
|
|
343
|
+
|
|
344
|
+
if (typeof ttfb !== 'number' || typeof loadDelay !== 'number' || typeof loadDuration !== 'number' ||
|
|
345
|
+
typeof renderDelay !== 'number') {
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return {
|
|
350
|
+
timeToFirstByte: Trace.Types.Timing.Milli(ttfb),
|
|
351
|
+
resourceLoadDelay: Trace.Types.Timing.Milli(loadDelay),
|
|
352
|
+
resourceLoadTime: Trace.Types.Timing.Milli(loadDuration),
|
|
353
|
+
elementRenderDelay: Trace.Types.Timing.Milli(renderDelay),
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function getNetworkRecTitle(cruxManager: CrUXManager.CrUXManager): string|null {
|
|
358
|
+
const response = cruxManager.getSelectedFieldMetricData('round_trip_time');
|
|
359
|
+
if (!response?.percentiles) {
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const rtt = Number(response.percentiles.p75);
|
|
364
|
+
if (!Number.isFinite(rtt)) {
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (rtt < RTT_MINIMUM) {
|
|
369
|
+
return i18nString(UIStrings.tryDisablingThrottling);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
const conditions = SDK.NetworkManager.getRecommendedNetworkPreset(rtt);
|
|
373
|
+
if (!conditions) {
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const title = typeof conditions.title === 'function' ? conditions.title() : conditions.title;
|
|
378
|
+
return i18nString(UIStrings.tryUsingThrottling, {PH1: title});
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function getDeviceRec(cruxManager: CrUXManager.CrUXManager): string|null {
|
|
382
|
+
// `form_factors` metric is only populated if CrUX data is fetched for all devices.
|
|
383
|
+
const fractions =
|
|
384
|
+
cruxManager.getFieldResponse(cruxManager.fieldPageScope, 'ALL')?.record.metrics.form_factors?.fractions;
|
|
385
|
+
if (!fractions) {
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
return i18nString(UIStrings.percentDevices, {
|
|
390
|
+
PH1: Math.round(fractions.phone * 100),
|
|
391
|
+
PH2: Math.round(fractions.desktop * 100),
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function getPageScopeLabel(cruxManager: CrUXManager.CrUXManager, pageScope: CrUXManager.PageScope): string {
|
|
396
|
+
const key = cruxManager.pageResult?.[`${pageScope}-ALL` as const]?.record.key[pageScope];
|
|
397
|
+
if (key) {
|
|
398
|
+
return pageScope === 'url' ? i18nString(UIStrings.urlOptionWithKey, {PH1: key}) :
|
|
399
|
+
i18nString(UIStrings.originOptionWithKey, {PH1: key});
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const baseLabel = pageScope === 'url' ? i18nString(UIStrings.urlOption) : i18nString(UIStrings.originOption);
|
|
403
|
+
return i18nString(UIStrings.needsDataOption, {PH1: baseLabel});
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function getDeviceScopeDisplayName(deviceScope: CrUXManager.DeviceScope): string {
|
|
407
|
+
switch (deviceScope) {
|
|
408
|
+
case 'ALL':
|
|
409
|
+
return i18nString(UIStrings.allDevices);
|
|
410
|
+
case 'DESKTOP':
|
|
411
|
+
return i18nString(UIStrings.desktop);
|
|
412
|
+
case 'PHONE':
|
|
413
|
+
return i18nString(UIStrings.mobile);
|
|
414
|
+
case 'TABLET':
|
|
415
|
+
return i18nString(UIStrings.tablet);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function getLabelForDeviceOption(cruxManager: CrUXManager.CrUXManager, deviceOption: DeviceOption): string {
|
|
420
|
+
let baseLabel;
|
|
421
|
+
if (deviceOption === 'AUTO') {
|
|
422
|
+
const deviceScope = cruxManager.resolveDeviceOptionToScope(deviceOption);
|
|
423
|
+
const deviceScopeLabel = getDeviceScopeDisplayName(deviceScope);
|
|
424
|
+
baseLabel = i18nString(UIStrings.auto, {PH1: deviceScopeLabel});
|
|
425
|
+
} else {
|
|
426
|
+
baseLabel = getDeviceScopeDisplayName(deviceOption);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
if (!cruxManager.pageResult) {
|
|
430
|
+
return i18nString(UIStrings.loadingOption, {PH1: baseLabel});
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const result = cruxManager.getSelectedFieldResponse();
|
|
434
|
+
if (!result) {
|
|
435
|
+
return i18nString(UIStrings.needsDataOption, {PH1: baseLabel});
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
return baseLabel;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function getCollectionPeriodRange(cruxManager: CrUXManager.CrUXManager): string|null {
|
|
442
|
+
const selectedResponse = cruxManager.getSelectedFieldResponse();
|
|
443
|
+
if (!selectedResponse) {
|
|
444
|
+
return null;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
const {firstDate, lastDate} = selectedResponse.record.collectionPeriod;
|
|
448
|
+
|
|
449
|
+
const formattedFirstDate = new Date(
|
|
450
|
+
firstDate.year,
|
|
451
|
+
// CrUX month is 1-indexed but `Date` month is 0-indexed
|
|
452
|
+
firstDate.month - 1,
|
|
453
|
+
firstDate.day,
|
|
454
|
+
);
|
|
455
|
+
const formattedLastDate = new Date(
|
|
456
|
+
lastDate.year,
|
|
457
|
+
// CrUX month is 1-indexed but `Date` month is 0-indexed
|
|
458
|
+
lastDate.month - 1,
|
|
459
|
+
lastDate.day,
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
const options: Intl.DateTimeFormatOptions = {
|
|
463
|
+
year: 'numeric',
|
|
464
|
+
month: 'short',
|
|
465
|
+
day: 'numeric',
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
return i18nString(UIStrings.dateRange, {
|
|
469
|
+
PH1: formattedFirstDate.toLocaleDateString(undefined, options),
|
|
470
|
+
PH2: formattedLastDate.toLocaleDateString(undefined, options),
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function createMetricCardRef(cardData: Omit<MetricCardData, 'tooltipContainer'>):
|
|
475
|
+
ReturnType<typeof Lit.Directives.ref> {
|
|
476
|
+
return Lit.Directives.ref(el => {
|
|
477
|
+
if (el instanceof HTMLElement) {
|
|
478
|
+
(el as HTMLElement & {data: MetricCardData}).data = {
|
|
479
|
+
...cardData,
|
|
480
|
+
tooltipContainer: (el.closest('.metric-cards') as HTMLElement) || undefined,
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
function renderLcpCard(input: ViewInput): Lit.LitTemplate {
|
|
487
|
+
const fieldData = input.cruxManager.getSelectedFieldMetricData('largest_contentful_paint');
|
|
488
|
+
const nodeLink =
|
|
489
|
+
input.lcpValue?.nodeRef && PanelsCommon.DOMLinkifier.Linkifier.instance().linkify(input.lcpValue?.nodeRef);
|
|
490
|
+
const phases = input.lcpValue?.phases;
|
|
491
|
+
|
|
492
|
+
const fieldPhases = getLcpFieldPhases(input.cruxManager);
|
|
493
|
+
|
|
494
|
+
// clang-format off
|
|
495
|
+
return html`
|
|
496
|
+
<devtools-metric-card ${createMetricCardRef({
|
|
497
|
+
metric: 'LCP',
|
|
498
|
+
localValue: input.lcpValue?.value,
|
|
499
|
+
fieldValue: fieldData?.percentiles?.p75,
|
|
500
|
+
histogram: fieldData?.histogram,
|
|
501
|
+
warnings: input.lcpValue?.warnings,
|
|
502
|
+
phases: phases && [
|
|
503
|
+
[i18nString(UIStrings.timeToFirstByte), phases.timeToFirstByte, fieldPhases?.timeToFirstByte],
|
|
504
|
+
[i18nString(UIStrings.resourceLoadDelay), phases.resourceLoadDelay, fieldPhases?.resourceLoadDelay],
|
|
505
|
+
[i18nString(UIStrings.resourceLoadDuration), phases.resourceLoadTime, fieldPhases?.resourceLoadTime],
|
|
506
|
+
[i18nString(UIStrings.elementRenderDelay), phases.elementRenderDelay, fieldPhases?.elementRenderDelay],
|
|
507
|
+
],
|
|
508
|
+
})}>
|
|
509
|
+
${nodeLink ? html`
|
|
510
|
+
<div class="related-info" slot="extra-info">
|
|
511
|
+
<span class="related-info-label">${i18nString(UIStrings.lcpElement)}</span>
|
|
512
|
+
<span class="related-info-link">
|
|
513
|
+
${widget(PanelsCommon.DOMLinkifier.DOMNodeLink, {node: input.lcpValue?.nodeRef})}
|
|
514
|
+
</span>
|
|
515
|
+
</div>
|
|
516
|
+
`
|
|
517
|
+
: nothing}
|
|
518
|
+
</devtools-metric-card>
|
|
519
|
+
`;
|
|
520
|
+
// clang-format on
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function renderClsCard(input: ViewInput): Lit.LitTemplate {
|
|
524
|
+
const fieldData = input.cruxManager.getSelectedFieldMetricData('cumulative_layout_shift');
|
|
525
|
+
|
|
526
|
+
const clusterIds = new Set(input.clsValue?.clusterShiftIds || []);
|
|
527
|
+
const clusterIsVisible =
|
|
528
|
+
clusterIds.size > 0 && input.layoutShifts.some(layoutShift => clusterIds.has(layoutShift.uniqueLayoutShiftId));
|
|
529
|
+
|
|
530
|
+
// clang-format off
|
|
531
|
+
return html`
|
|
532
|
+
<devtools-metric-card ${createMetricCardRef({
|
|
533
|
+
metric: 'CLS',
|
|
534
|
+
localValue: input.clsValue?.value,
|
|
535
|
+
fieldValue: fieldData?.percentiles?.p75,
|
|
536
|
+
histogram: fieldData?.histogram,
|
|
537
|
+
warnings: input.clsValue?.warnings,
|
|
538
|
+
})}>
|
|
539
|
+
${clusterIsVisible ? html`
|
|
540
|
+
<div class="related-info" slot="extra-info">
|
|
541
|
+
<span class="related-info-label">${i18nString(UIStrings.worstCluster)}</span>
|
|
542
|
+
<button
|
|
543
|
+
class="link-to-log"
|
|
544
|
+
title=${i18nString(UIStrings.showClsCluster)}
|
|
545
|
+
@click=${() => input.revealLayoutShiftCluster(clusterIds)}
|
|
546
|
+
jslog=${VisualLogging.action('timeline.landing.show-cls-cluster').track({click: true})}
|
|
547
|
+
>${i18nString(UIStrings.numShifts, {shiftCount: clusterIds.size})}</button>
|
|
548
|
+
</div>
|
|
549
|
+
` : nothing}
|
|
550
|
+
</devtools-metric-card>
|
|
551
|
+
`;
|
|
552
|
+
// clang-format on
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
function renderInpCard(input: ViewInput): Lit.LitTemplate {
|
|
556
|
+
const fieldData = input.cruxManager.getSelectedFieldMetricData('interaction_to_next_paint');
|
|
557
|
+
const phases = input.inpValue?.phases;
|
|
558
|
+
const interaction = input.inpValue && input.interactions.get(input.inpValue.interactionId);
|
|
559
|
+
|
|
560
|
+
// clang-format off
|
|
561
|
+
return html`
|
|
562
|
+
<devtools-metric-card ${createMetricCardRef({
|
|
563
|
+
metric: 'INP',
|
|
564
|
+
localValue: input.inpValue?.value,
|
|
565
|
+
fieldValue: fieldData?.percentiles?.p75,
|
|
566
|
+
histogram: fieldData?.histogram,
|
|
567
|
+
warnings: input.inpValue?.warnings,
|
|
568
|
+
phases: phases && [
|
|
569
|
+
[i18nString(UIStrings.inputDelay), phases.inputDelay],
|
|
570
|
+
[i18nString(UIStrings.processingDuration), phases.processingDuration],
|
|
571
|
+
[i18nString(UIStrings.presentationDelay), phases.presentationDelay],
|
|
572
|
+
],
|
|
573
|
+
})}>
|
|
574
|
+
${interaction ? html`
|
|
575
|
+
<div class="related-info" slot="extra-info">
|
|
576
|
+
<span class="related-info-label">${i18nString(UIStrings.inpInteractionLink)}</span>
|
|
577
|
+
<button
|
|
578
|
+
class="link-to-log"
|
|
579
|
+
title=${i18nString(UIStrings.showInpInteraction)}
|
|
580
|
+
@click=${() => input.revealInteraction(interaction)}
|
|
581
|
+
jslog=${VisualLogging.action('timeline.landing.show-inp-interaction').track({click: true})}
|
|
582
|
+
>${interaction.interactionType}</button>
|
|
583
|
+
</div>
|
|
584
|
+
` : nothing}
|
|
585
|
+
</devtools-metric-card>
|
|
586
|
+
`;
|
|
587
|
+
// clang-format on
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function renderRecordAction(action: UI.ActionRegistration.Action): Lit.LitTemplate {
|
|
591
|
+
function onClick(): void {
|
|
592
|
+
void action.execute();
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// clang-format off
|
|
596
|
+
return html`
|
|
597
|
+
<div class="record-action">
|
|
598
|
+
<devtools-button @click=${onClick} .data=${{
|
|
599
|
+
variant: Buttons.Button.Variant.TEXT,
|
|
600
|
+
size: Buttons.Button.Size.REGULAR,
|
|
601
|
+
iconName: action.icon(),
|
|
602
|
+
title: action.title(),
|
|
603
|
+
jslogContext: action.id(),
|
|
604
|
+
} as Buttons.Button.ButtonData}>
|
|
605
|
+
${action.title()}
|
|
606
|
+
</devtools-button>
|
|
607
|
+
<span class="shortcut-label">${UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutTitleForAction(action.id())}</span>
|
|
608
|
+
</div>
|
|
609
|
+
`;
|
|
610
|
+
// clang-format on
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
function renderRecordingSettings(input: ViewInput): Lit.LitTemplate {
|
|
614
|
+
const fieldEnabled = input.cruxManager.getConfigSetting().get().enabled;
|
|
615
|
+
|
|
616
|
+
const deviceRec = getDeviceRec(input.cruxManager) || i18nString(UIStrings.notEnoughData);
|
|
617
|
+
const networkRec = getNetworkRecTitle(input.cruxManager) || i18nString(UIStrings.notEnoughData);
|
|
618
|
+
|
|
619
|
+
const recs = PanelsCommon.ThrottlingUtils.getThrottlingRecommendations();
|
|
620
|
+
|
|
621
|
+
// clang-format off
|
|
622
|
+
return html`
|
|
623
|
+
<h3 class="card-title">${i18nString(UIStrings.environmentSettings)}</h3>
|
|
624
|
+
<div class="device-toolbar-description">${md(i18nString(UIStrings.useDeviceToolbar))}</div>
|
|
625
|
+
${fieldEnabled ? html`
|
|
626
|
+
<ul class="environment-recs-list">
|
|
627
|
+
<li>${uiI18n.getFormatLocalizedStringTemplate(str_, UIStrings.device, {PH1: html`<span class="environment-rec">${deviceRec}</span>`})}</li>
|
|
628
|
+
<li>${uiI18n.getFormatLocalizedStringTemplate(str_, UIStrings.network, {PH1: html`<span class="environment-rec">${networkRec}</span>`})}</li>
|
|
629
|
+
</ul>
|
|
630
|
+
` : nothing}
|
|
631
|
+
<div class="environment-option">
|
|
632
|
+
${widget(CPUThrottlingSelector, {recommendedOption: recs.cpuOption})}
|
|
633
|
+
</div>
|
|
634
|
+
<div class="environment-option">
|
|
635
|
+
<devtools-network-throttling-selector .recommendedConditions=${recs.networkConditions}></devtools-network-throttling-selector>
|
|
636
|
+
</div>
|
|
637
|
+
<div class="environment-option">
|
|
638
|
+
<setting-checkbox
|
|
639
|
+
class="network-cache-setting"
|
|
640
|
+
.data=${{
|
|
641
|
+
setting: Common.Settings.Settings.instance().moduleSetting('cache-disabled'),
|
|
642
|
+
textOverride: i18nString(UIStrings.disableNetworkCache),
|
|
643
|
+
} as Settings.SettingCheckbox.SettingCheckboxData}
|
|
644
|
+
></setting-checkbox>
|
|
645
|
+
</div>
|
|
646
|
+
`;
|
|
647
|
+
// clang-format on
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
function renderPageScopeSetting(input: ViewInput): Lit.LitTemplate {
|
|
651
|
+
if (!input.cruxManager.getConfigSetting().get().enabled) {
|
|
652
|
+
return Lit.nothing;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
const urlLabel = getPageScopeLabel(input.cruxManager, 'url');
|
|
656
|
+
const originLabel = getPageScopeLabel(input.cruxManager, 'origin');
|
|
657
|
+
|
|
658
|
+
const buttonTitle = input.cruxManager.fieldPageScope === 'url' ? urlLabel : originLabel;
|
|
659
|
+
const accessibleTitle = i18nString(UIStrings.showFieldDataForPage, {PH1: buttonTitle});
|
|
660
|
+
|
|
661
|
+
// If there is no data at all we should force users to switch pages or reconfigure CrUX.
|
|
662
|
+
const shouldDisable = !input.cruxManager.pageResult?.['url-ALL'] && !input.cruxManager.pageResult?.['origin-ALL'];
|
|
663
|
+
|
|
664
|
+
/* eslint-disable @devtools/no-deprecated-component-usages */
|
|
665
|
+
return html`
|
|
666
|
+
<devtools-select-menu
|
|
667
|
+
id="page-scope-select"
|
|
668
|
+
class="field-data-option"
|
|
669
|
+
@selectmenuselected=${input.handlePageScopeSelected}
|
|
670
|
+
.showDivider=${true}
|
|
671
|
+
.showArrow=${true}
|
|
672
|
+
.sideButton=${false}
|
|
673
|
+
.showSelectedItem=${true}
|
|
674
|
+
.buttonTitle=${buttonTitle}
|
|
675
|
+
.disabled=${shouldDisable}
|
|
676
|
+
title=${accessibleTitle}
|
|
677
|
+
>
|
|
678
|
+
<devtools-menu-item
|
|
679
|
+
.value=${'url'}
|
|
680
|
+
.selected=${input.cruxManager.fieldPageScope === 'url'}
|
|
681
|
+
>
|
|
682
|
+
${urlLabel}
|
|
683
|
+
</devtools-menu-item>
|
|
684
|
+
<devtools-menu-item
|
|
685
|
+
.value=${'origin'}
|
|
686
|
+
.selected=${input.cruxManager.fieldPageScope === 'origin'}
|
|
687
|
+
>
|
|
688
|
+
${originLabel}
|
|
689
|
+
</devtools-menu-item>
|
|
690
|
+
</devtools-select-menu>
|
|
691
|
+
`;
|
|
692
|
+
/* eslint-enable @devtools/no-deprecated-component-usages */
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
function renderDeviceScopeSetting(input: ViewInput): Lit.LitTemplate {
|
|
696
|
+
if (!input.cruxManager.getConfigSetting().get().enabled) {
|
|
697
|
+
return Lit.nothing;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// If there is no data at all we should force users to try adjusting the page scope
|
|
701
|
+
// before coming back to this option.
|
|
702
|
+
const shouldDisable = !input.cruxManager.getFieldResponse(input.cruxManager.fieldPageScope, 'ALL');
|
|
703
|
+
|
|
704
|
+
const currentDeviceLabel = getLabelForDeviceOption(input.cruxManager, input.cruxManager.fieldDeviceOption);
|
|
705
|
+
|
|
706
|
+
// clang-format off
|
|
707
|
+
/* eslint-disable @devtools/no-deprecated-component-usages */
|
|
708
|
+
return html`
|
|
709
|
+
<devtools-select-menu
|
|
710
|
+
id="device-scope-select"
|
|
711
|
+
class="field-data-option"
|
|
712
|
+
@selectmenuselected=${input.handleDeviceOptionSelected}
|
|
713
|
+
.showDivider=${true}
|
|
714
|
+
.showArrow=${true}
|
|
715
|
+
.sideButton=${false}
|
|
716
|
+
.showSelectedItem=${true}
|
|
717
|
+
.buttonTitle=${i18nString(UIStrings.device, {PH1: currentDeviceLabel})}
|
|
718
|
+
.disabled=${shouldDisable}
|
|
719
|
+
title=${i18nString(UIStrings.showFieldDataForDevice, {PH1: currentDeviceLabel})}
|
|
720
|
+
>
|
|
721
|
+
${DEVICE_OPTION_LIST.map(deviceOption => {
|
|
722
|
+
return html`
|
|
723
|
+
<devtools-menu-item
|
|
724
|
+
.value=${deviceOption}
|
|
725
|
+
.selected=${input.cruxManager.fieldDeviceOption === deviceOption}
|
|
726
|
+
>
|
|
727
|
+
${getLabelForDeviceOption(input.cruxManager, deviceOption)}
|
|
728
|
+
</devtools-menu-item>
|
|
729
|
+
`;
|
|
730
|
+
})}
|
|
731
|
+
</devtools-select-menu>
|
|
732
|
+
`;
|
|
733
|
+
/* eslint-enable @devtools/no-deprecated-component-usages */
|
|
734
|
+
// clang-format on
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
function renderFieldDataHistoryLink(cruxManager: CrUXManager.CrUXManager): Lit.LitTemplate {
|
|
738
|
+
if (!cruxManager.getConfigSetting().get().enabled) {
|
|
739
|
+
return Lit.nothing;
|
|
740
|
+
}
|
|
741
|
+
const normalizedUrl = cruxManager.pageResult?.normalizedUrl;
|
|
742
|
+
if (!normalizedUrl) {
|
|
743
|
+
return Lit.nothing;
|
|
744
|
+
}
|
|
745
|
+
const tmp = new URL('https://cruxvis.withgoogle.com/');
|
|
746
|
+
tmp.searchParams.set('view', 'cwvsummary');
|
|
747
|
+
tmp.searchParams.set('url', normalizedUrl);
|
|
748
|
+
// identifier must be 'origin' or 'url'.
|
|
749
|
+
const identifier = cruxManager.fieldPageScope;
|
|
750
|
+
tmp.searchParams.set('identifier', identifier);
|
|
751
|
+
// device must be one 'PHONE', 'DESKTOP', 'TABLET', or 'ALL'.
|
|
752
|
+
const device = cruxManager.getSelectedDeviceScope();
|
|
753
|
+
tmp.searchParams.set('device', device);
|
|
754
|
+
const cruxVis = `${tmp.origin}/#/${tmp.search}`;
|
|
755
|
+
return html`
|
|
756
|
+
(<devtools-link href=${cruxVis}
|
|
757
|
+
class="local-field-link"
|
|
758
|
+
title=${i18nString(UIStrings.fieldDataHistoryTooltip)}
|
|
759
|
+
>${i18nString(UIStrings.fieldDataHistoryLink)}</devtools-link>)
|
|
760
|
+
`;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
function renderCollectionPeriod(cruxManager: CrUXManager.CrUXManager): Lit.LitTemplate {
|
|
764
|
+
const range = getCollectionPeriodRange(cruxManager);
|
|
765
|
+
|
|
766
|
+
const dateText = range || i18nString(UIStrings.notEnoughData);
|
|
767
|
+
|
|
768
|
+
const fieldDataHistoryLink = range ? renderFieldDataHistoryLink(cruxManager) : Lit.nothing;
|
|
769
|
+
|
|
770
|
+
const warnings = cruxManager.pageResult?.warnings || [];
|
|
771
|
+
|
|
772
|
+
return html`
|
|
773
|
+
<div class="field-data-message">
|
|
774
|
+
<div>${uiI18n.getFormatLocalizedStringTemplate(str_, UIStrings.collectionPeriod, {
|
|
775
|
+
PH1: html`<span class="collection-period-range">${dateText}</span>`,
|
|
776
|
+
})} ${fieldDataHistoryLink}</div>
|
|
777
|
+
${warnings.map(warning => html`
|
|
778
|
+
<div class="field-data-warning">${warning}</div>
|
|
779
|
+
`)}
|
|
780
|
+
</div>
|
|
781
|
+
`;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
function renderFieldDataMessage(cruxManager: CrUXManager.CrUXManager): Lit.LitTemplate {
|
|
785
|
+
if (cruxManager.getConfigSetting().get().enabled) {
|
|
786
|
+
return renderCollectionPeriod(cruxManager);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
// clang-format off
|
|
790
|
+
return html`
|
|
791
|
+
<div class="field-data-message">
|
|
792
|
+
${uiI18n.getFormatLocalizedStringTemplate(
|
|
793
|
+
str_,
|
|
794
|
+
UIStrings.seeHowYourLocalMetricsCompare,
|
|
795
|
+
{ PH1: html`<devtools-link href="https://developer.chrome.com/docs/crux">${i18n.i18n.lockedString('Chrome UX Report')}</devtools-link>` },
|
|
796
|
+
)}
|
|
797
|
+
</div>
|
|
798
|
+
`;
|
|
799
|
+
// clang-format on
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
const listIsScrolling = new WeakMap<HTMLElement, boolean>();
|
|
803
|
+
|
|
804
|
+
function shouldKeepScrolledToBottom(listEl: HTMLElement): boolean {
|
|
805
|
+
if (!listEl.checkVisibility()) {
|
|
806
|
+
return false;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
const isAtBottom = Math.abs(listEl.scrollHeight - listEl.clientHeight - listEl.scrollTop) <= 1;
|
|
810
|
+
|
|
811
|
+
// We shouldn't scroll to the bottom if the list wasn't already at the bottom.
|
|
812
|
+
// However, if a new item appears while the animation for a previous item is still going,
|
|
813
|
+
// then we should "finish" the scroll by sending another scroll command even if the scroll position
|
|
814
|
+
// the element hasn't scrolled all the way to the bottom yet.
|
|
815
|
+
return isAtBottom || Boolean(listIsScrolling.get(listEl));
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
function keepScrolledToBottom(listEl: HTMLElement): void {
|
|
819
|
+
requestAnimationFrame(() => {
|
|
820
|
+
listIsScrolling.set(listEl, true);
|
|
821
|
+
listEl.addEventListener('scrollend', () => {
|
|
822
|
+
listIsScrolling.set(listEl, false);
|
|
823
|
+
}, {once: true});
|
|
824
|
+
listEl.scrollTo({top: listEl.scrollHeight, behavior: 'smooth'});
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
function renderInteractionsLog(input: ViewInput, output: ViewOutput): Lit.LitTemplate {
|
|
829
|
+
if (!input.interactions.size) {
|
|
830
|
+
return Lit.nothing;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
// clang-format off
|
|
834
|
+
return html`
|
|
835
|
+
<ol class="log"
|
|
836
|
+
slot="interactions-log-content"
|
|
837
|
+
${Lit.Directives.ref(el => {
|
|
838
|
+
if (el instanceof HTMLElement) {
|
|
839
|
+
output.shouldKeepInteractionsScrolledToBottom = () => {
|
|
840
|
+
return shouldKeepScrolledToBottom(el);
|
|
841
|
+
};
|
|
842
|
+
output.keepInteractionsScrolledToBottom = () => {
|
|
843
|
+
keepScrolledToBottom(el);
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
})}
|
|
847
|
+
>
|
|
848
|
+
${input.interactions.values().map(interaction => {
|
|
849
|
+
const metricValue = renderMetricValue(
|
|
850
|
+
'timeline.landing.interaction-event-timing',
|
|
851
|
+
interaction.duration,
|
|
852
|
+
INP_THRESHOLDS,
|
|
853
|
+
v => i18n.TimeUtilities.preciseMillisToString(v),
|
|
854
|
+
{dim: true},
|
|
855
|
+
);
|
|
856
|
+
|
|
857
|
+
const isP98Excluded = input.inpValue && input.inpValue.value < interaction.duration;
|
|
858
|
+
const isInp = input.inpValue?.interactionId === interaction.interactionId;
|
|
859
|
+
|
|
860
|
+
return html`
|
|
861
|
+
<li id=${interaction.interactionId} class="log-item interaction" tabindex="-1">
|
|
862
|
+
<details>
|
|
863
|
+
<summary>
|
|
864
|
+
<span class="interaction-type">
|
|
865
|
+
${interaction.interactionType} ${isInp ?
|
|
866
|
+
html`<span class="interaction-inp-chip" title=${i18nString(UIStrings.inpInteraction)}>INP</span>`
|
|
867
|
+
: nothing}
|
|
868
|
+
</span>
|
|
869
|
+
<span class="interaction-node">
|
|
870
|
+
${widget(PanelsCommon.DOMLinkifier.DOMNodeLink, {node: interaction.nodeRef})}
|
|
871
|
+
</span>
|
|
872
|
+
${isP98Excluded ? html`<devtools-icon
|
|
873
|
+
class="interaction-info"
|
|
874
|
+
name="info"
|
|
875
|
+
title=${i18nString(UIStrings.interactionExcluded)}
|
|
876
|
+
></devtools-icon>` : nothing}
|
|
877
|
+
<span class="interaction-duration">${metricValue}</span>
|
|
878
|
+
</summary>
|
|
879
|
+
<div class="phase-table" role="table">
|
|
880
|
+
<div class="phase-table-row phase-table-header-row" role="row">
|
|
881
|
+
<div role="columnheader">${i18nString(UIStrings.phase)}</div>
|
|
882
|
+
<div role="columnheader">
|
|
883
|
+
${interaction.longAnimationFrameTimings.length ? html`
|
|
884
|
+
<button
|
|
885
|
+
class="log-extra-details-button"
|
|
886
|
+
title=${i18nString(UIStrings.logToConsole)}
|
|
887
|
+
@click=${() => input.logExtraInteractionDetails(interaction)}
|
|
888
|
+
>${i18nString(UIStrings.duration)}</button>
|
|
889
|
+
` : i18nString(UIStrings.duration)}
|
|
890
|
+
</div>
|
|
891
|
+
</div>
|
|
892
|
+
<div class="phase-table-row" role="row">
|
|
893
|
+
<div role="cell">${i18nString(UIStrings.inputDelay)}</div>
|
|
894
|
+
<div role="cell">${Math.round(interaction.phases.inputDelay)}</div>
|
|
895
|
+
</div>
|
|
896
|
+
<div class="phase-table-row" role="row">
|
|
897
|
+
<div role="cell">${i18nString(UIStrings.processingDuration)}</div>
|
|
898
|
+
<div role="cell">${Math.round(interaction.phases.processingDuration)}</div>
|
|
899
|
+
</div>
|
|
900
|
+
<div class="phase-table-row" role="row">
|
|
901
|
+
<div role="cell">${i18nString(UIStrings.presentationDelay)}</div>
|
|
902
|
+
<div role="cell">${Math.round(interaction.phases.presentationDelay)}</div>
|
|
903
|
+
</div>
|
|
904
|
+
</div>
|
|
905
|
+
</details>
|
|
906
|
+
</li>
|
|
907
|
+
`;
|
|
908
|
+
})}
|
|
909
|
+
</ol>
|
|
910
|
+
`;
|
|
911
|
+
// clang-format on
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
function renderLayoutShiftsLog(input: ViewInput, output: ViewOutput): Lit.LitTemplate {
|
|
915
|
+
if (!input.layoutShifts.length) {
|
|
916
|
+
return Lit.nothing;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
// clang-format off
|
|
920
|
+
return html`
|
|
921
|
+
<ol class="log"
|
|
922
|
+
slot="layout-shifts-log-content"
|
|
923
|
+
${Lit.Directives.ref(el => {
|
|
924
|
+
if (el instanceof HTMLElement) {
|
|
925
|
+
output.shouldKeepLayoutShiftsScrolledToBottom = () => {
|
|
926
|
+
return shouldKeepScrolledToBottom(el);
|
|
927
|
+
};
|
|
928
|
+
output.keepLayoutShiftsScrolledToBottom = () => {
|
|
929
|
+
keepScrolledToBottom(el);
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
})}
|
|
933
|
+
>
|
|
934
|
+
${input.layoutShifts.map(layoutShift => {
|
|
935
|
+
const metricValue = renderMetricValue(
|
|
936
|
+
'timeline.landing.layout-shift-event-score',
|
|
937
|
+
layoutShift.score,
|
|
938
|
+
CLS_THRESHOLDS,
|
|
939
|
+
// CLS value is 2 decimal places, but individual shift scores tend to be much smaller
|
|
940
|
+
// so we expand the precision here.
|
|
941
|
+
v => v.toFixed(4),
|
|
942
|
+
{dim: true},
|
|
943
|
+
);
|
|
944
|
+
|
|
945
|
+
return html`
|
|
946
|
+
<li id=${layoutShift.uniqueLayoutShiftId} class="log-item layout-shift" tabindex="-1">
|
|
947
|
+
<div class="layout-shift-score">Layout shift score: ${metricValue}</div>
|
|
948
|
+
<div class="layout-shift-nodes">
|
|
949
|
+
${layoutShift.affectedNodeRefs.map(node => html`
|
|
950
|
+
<div class="layout-shift-node">
|
|
951
|
+
${widget(PanelsCommon.DOMLinkifier.DOMNodeLink, {node})}
|
|
952
|
+
</div>
|
|
953
|
+
`)}
|
|
954
|
+
</div>
|
|
955
|
+
</li>
|
|
956
|
+
`;
|
|
957
|
+
})}
|
|
958
|
+
</ol>
|
|
959
|
+
`;
|
|
960
|
+
// clang-format on
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
function renderLogSection(input: ViewInput, output: ViewOutput): Lit.LitTemplate {
|
|
964
|
+
// clang-format off
|
|
965
|
+
return html`
|
|
966
|
+
<section
|
|
967
|
+
class="logs-section"
|
|
968
|
+
aria-label=${i18nString(UIStrings.eventLogs)}
|
|
969
|
+
>
|
|
970
|
+
<devtools-widget ${widget(LiveMetricsLogs)}
|
|
971
|
+
${widgetRef(LiveMetricsLogs, widget => {
|
|
972
|
+
if (input.highlightedInteractionId) {
|
|
973
|
+
widget.selectTab('interactions');
|
|
974
|
+
} else if (input.highlightedLayoutShiftClusterIds?.size) {
|
|
975
|
+
widget.selectTab('layout-shifts');
|
|
976
|
+
}
|
|
977
|
+
})}
|
|
978
|
+
>
|
|
979
|
+
${renderInteractionsLog(input, output)}
|
|
980
|
+
${renderLayoutShiftsLog(input, output)}
|
|
981
|
+
</devtools-widget>
|
|
982
|
+
</section>
|
|
983
|
+
`;
|
|
984
|
+
// clang-format on
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
function renderNodeView(input: ViewInput): Lit.LitTemplate {
|
|
988
|
+
return html`
|
|
989
|
+
<style>${liveMetricsViewStyles}</style>
|
|
990
|
+
<style>${metricValueStyles}</style>
|
|
991
|
+
<div class="node-view">
|
|
992
|
+
<main>
|
|
993
|
+
<h2 class="section-title">${i18nString(UIStrings.nodePerformanceTimeline)}</h2>
|
|
994
|
+
<div class="node-description">${i18nString(UIStrings.nodeClickToRecord)}</div>
|
|
995
|
+
<div class="record-action-card">${renderRecordAction(input.toggleRecordAction)}</div>
|
|
996
|
+
</main>
|
|
997
|
+
</div>
|
|
998
|
+
`;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
export const DEFAULT_VIEW: View = (input, output, target) => {
|
|
1002
|
+
if (input.isNode) {
|
|
1003
|
+
Lit.render(renderNodeView(input), target, {host: input});
|
|
1004
|
+
return;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
const fieldEnabled = input.cruxManager.getConfigSetting().get().enabled;
|
|
1008
|
+
const liveMetricsTitle =
|
|
1009
|
+
fieldEnabled ? i18nString(UIStrings.localAndFieldMetrics) : i18nString(UIStrings.localMetrics);
|
|
1010
|
+
|
|
1011
|
+
const helpLink = 'https://web.dev/articles/lab-and-field-data-differences#lab_data_versus_field_data' as
|
|
1012
|
+
Platform.DevToolsPath.UrlString;
|
|
1013
|
+
|
|
1014
|
+
// clang-format off
|
|
1015
|
+
const outputTemplate = html`
|
|
1016
|
+
<style>${liveMetricsViewStyles}</style>
|
|
1017
|
+
<style>${metricValueStyles}</style>
|
|
1018
|
+
<div class="container">
|
|
1019
|
+
<div class="live-metrics-view">
|
|
1020
|
+
<main class="live-metrics">
|
|
1021
|
+
<h2 class="section-title">${liveMetricsTitle}</h2>
|
|
1022
|
+
<div class="metric-cards">
|
|
1023
|
+
<div id="lcp">
|
|
1024
|
+
${renderLcpCard(input)}
|
|
1025
|
+
</div>
|
|
1026
|
+
<div id="cls">
|
|
1027
|
+
${renderClsCard(input)}
|
|
1028
|
+
</div>
|
|
1029
|
+
<div id="inp">
|
|
1030
|
+
${renderInpCard(input)}
|
|
1031
|
+
</div>
|
|
1032
|
+
</div>
|
|
1033
|
+
<devtools-link
|
|
1034
|
+
href=${helpLink}
|
|
1035
|
+
class="local-field-link"
|
|
1036
|
+
title=${i18nString(UIStrings.localFieldLearnMoreTooltip)}
|
|
1037
|
+
>${i18nString(UIStrings.localFieldLearnMoreLink)}</devtools-link>
|
|
1038
|
+
${renderLogSection(input, output)}
|
|
1039
|
+
</main>
|
|
1040
|
+
<aside class="next-steps" aria-labelledby="next-steps-section-title">
|
|
1041
|
+
<h2 id="next-steps-section-title" class="section-title">${i18nString(UIStrings.nextSteps)}</h2>
|
|
1042
|
+
<div id="field-setup" class="settings-card">
|
|
1043
|
+
<h3 class="card-title">${i18nString(UIStrings.fieldMetricsTitle)}</h3>
|
|
1044
|
+
${renderFieldDataMessage(input.cruxManager)}
|
|
1045
|
+
${renderPageScopeSetting(input)}
|
|
1046
|
+
${renderDeviceScopeSetting(input)}
|
|
1047
|
+
<div class="field-setup-buttons">
|
|
1048
|
+
<devtools-field-settings-dialog></devtools-field-settings-dialog>
|
|
1049
|
+
</div>
|
|
1050
|
+
</div>
|
|
1051
|
+
<div id="recording-settings" class="settings-card">
|
|
1052
|
+
${renderRecordingSettings(input)}
|
|
1053
|
+
</div>
|
|
1054
|
+
<div id="record" class="record-action-card">
|
|
1055
|
+
${renderRecordAction(input.toggleRecordAction)}
|
|
1056
|
+
</div>
|
|
1057
|
+
<div id="record-page-load" class="record-action-card">
|
|
1058
|
+
${renderRecordAction(input.recordReloadAction)}
|
|
1059
|
+
</div>
|
|
1060
|
+
</aside>
|
|
1061
|
+
</div>
|
|
1062
|
+
</div>
|
|
1063
|
+
`;
|
|
1064
|
+
Lit.render(outputTemplate, target, {host: input});
|
|
1065
|
+
|
|
1066
|
+
if (input.highlightedInteractionId) {
|
|
1067
|
+
const interactionEl = target.querySelector<HTMLElement>('#' + CSS.escape(input.highlightedInteractionId));
|
|
1068
|
+
if (interactionEl) {
|
|
1069
|
+
void RenderCoordinator.write(() => {
|
|
1070
|
+
interactionEl.scrollIntoView({
|
|
1071
|
+
block: 'center',
|
|
1072
|
+
});
|
|
1073
|
+
interactionEl.focus();
|
|
1074
|
+
UI.UIUtils.runCSSAnimationOnce(interactionEl, 'highlight');
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
if (input.highlightedLayoutShiftClusterIds?.size) {
|
|
1080
|
+
const layoutShiftEls: HTMLElement[] = [];
|
|
1081
|
+
for (const shiftId of input.highlightedLayoutShiftClusterIds) {
|
|
1082
|
+
const layoutShiftEl = target.querySelector<HTMLElement>('#' + CSS.escape(shiftId));
|
|
1083
|
+
if (layoutShiftEl) {
|
|
1084
|
+
layoutShiftEls.push(layoutShiftEl);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
if (layoutShiftEls.length) {
|
|
1089
|
+
void RenderCoordinator.write(() => {
|
|
1090
|
+
layoutShiftEls[0].scrollIntoView({
|
|
1091
|
+
block: 'start',
|
|
1092
|
+
});
|
|
1093
|
+
layoutShiftEls[0].focus();
|
|
1094
|
+
for (const layoutShiftEl of layoutShiftEls) {
|
|
1095
|
+
UI.UIUtils.runCSSAnimationOnce(layoutShiftEl, 'highlight');
|
|
1096
|
+
}
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
1101
|
+
|
|
306
1102
|
export class LiveMetricsView extends UI.Widget.Widget {
|
|
307
1103
|
isNode = Root.Runtime.Runtime.isNode();
|
|
308
1104
|
|
|
@@ -312,26 +1108,27 @@ export class LiveMetricsView extends UI.Widget.Widget {
|
|
|
312
1108
|
#interactions: LiveMetrics.InteractionMap = new Map();
|
|
313
1109
|
#layoutShifts: LiveMetrics.LayoutShift[] = [];
|
|
314
1110
|
|
|
1111
|
+
#highlightedInteractionId = '';
|
|
1112
|
+
#highlightedLayoutShiftClusterIds = new Set<string>();
|
|
1113
|
+
|
|
315
1114
|
#cruxManager = CrUXManager.CrUXManager.instance();
|
|
316
1115
|
|
|
317
1116
|
#toggleRecordAction: UI.ActionRegistration.Action;
|
|
318
1117
|
#recordReloadAction: UI.ActionRegistration.Action;
|
|
319
1118
|
|
|
320
|
-
#
|
|
321
|
-
#
|
|
322
|
-
#interactionsListEl?: HTMLElement;
|
|
323
|
-
#layoutShiftsListEl?: HTMLElement;
|
|
324
|
-
#listIsScrolling = false;
|
|
1119
|
+
#view: View;
|
|
1120
|
+
#viewOutput: ViewOutput = {};
|
|
325
1121
|
#deviceModeModel = EmulationModel.DeviceModeModel.DeviceModeModel.tryInstance();
|
|
326
1122
|
|
|
327
|
-
constructor(element?: HTMLElement) {
|
|
1123
|
+
constructor(element?: HTMLElement, view: View = DEFAULT_VIEW) {
|
|
328
1124
|
super(element, {useShadowDom: true});
|
|
1125
|
+
this.#view = view;
|
|
329
1126
|
|
|
330
1127
|
this.#toggleRecordAction = UI.ActionRegistry.ActionRegistry.instance().getAction('timeline.toggle-recording');
|
|
331
1128
|
this.#recordReloadAction = UI.ActionRegistry.ActionRegistry.instance().getAction('timeline.record-reload');
|
|
332
1129
|
}
|
|
333
1130
|
|
|
334
|
-
#onMetricStatus(event: {data: LiveMetrics.StatusEvent}): void {
|
|
1131
|
+
async #onMetricStatus(event: {data: LiveMetrics.StatusEvent}): Promise<void> {
|
|
335
1132
|
this.#lcpValue = event.data.lcp;
|
|
336
1133
|
this.#clsValue = event.data.cls;
|
|
337
1134
|
this.#inpValue = event.data.inp;
|
|
@@ -342,41 +1139,19 @@ export class LiveMetricsView extends UI.Widget.Widget {
|
|
|
342
1139
|
const hasNewInteraction = this.#interactions.size < event.data.interactions.size;
|
|
343
1140
|
this.#interactions = new Map(event.data.interactions);
|
|
344
1141
|
|
|
345
|
-
this.
|
|
1142
|
+
const shouldScrollInteractions = hasNewInteraction && this.#viewOutput.shouldKeepInteractionsScrolledToBottom?.();
|
|
1143
|
+
const shouldScrollLS = hasNewLS && this.#viewOutput.shouldKeepLayoutShiftsScrolledToBottom?.();
|
|
346
1144
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
if (hasNewLS && this.#layoutShiftsListEl) {
|
|
352
|
-
this.#keepScrolledToBottom(this.updateComplete, this.#layoutShiftsListEl);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
1145
|
+
this.requestUpdate();
|
|
1146
|
+
await this.updateComplete;
|
|
355
1147
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
return;
|
|
1148
|
+
if (shouldScrollInteractions) {
|
|
1149
|
+
this.#viewOutput.keepInteractionsScrolledToBottom?.();
|
|
359
1150
|
}
|
|
360
1151
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
// We shouldn't scroll to the bottom if the list wasn't already at the bottom.
|
|
364
|
-
// However, if a new item appears while the animation for a previous item is still going,
|
|
365
|
-
// then we should "finish" the scroll by sending another scroll command even if the scroll position
|
|
366
|
-
// the element hasn't scrolled all the way to the bottom yet.
|
|
367
|
-
if (!isAtBottom && !this.#listIsScrolling) {
|
|
368
|
-
return;
|
|
1152
|
+
if (shouldScrollLS) {
|
|
1153
|
+
this.#viewOutput.keepLayoutShiftsScrolledToBottom?.();
|
|
369
1154
|
}
|
|
370
|
-
|
|
371
|
-
void renderPromise.then(() => {
|
|
372
|
-
requestAnimationFrame(() => {
|
|
373
|
-
this.#listIsScrolling = true;
|
|
374
|
-
listEl.addEventListener('scrollend', () => {
|
|
375
|
-
this.#listIsScrolling = false;
|
|
376
|
-
}, {once: true});
|
|
377
|
-
listEl.scrollTo({top: listEl.scrollHeight, behavior: 'smooth'});
|
|
378
|
-
});
|
|
379
|
-
});
|
|
380
1155
|
}
|
|
381
1156
|
|
|
382
1157
|
#onFieldDataChanged(): void {
|
|
@@ -428,253 +1203,6 @@ export class LiveMetricsView extends UI.Widget.Widget {
|
|
|
428
1203
|
EmulationModel.DeviceModeModel.Events.UPDATED, this.#onEmulationChanged, this);
|
|
429
1204
|
}
|
|
430
1205
|
|
|
431
|
-
#getLcpFieldPhases(): LiveMetrics.LcpValue['phases']|null {
|
|
432
|
-
const ttfb = this.#cruxManager.getSelectedFieldMetricData('largest_contentful_paint_image_time_to_first_byte')
|
|
433
|
-
?.percentiles?.p75;
|
|
434
|
-
const loadDelay =
|
|
435
|
-
this.#cruxManager.getSelectedFieldMetricData('largest_contentful_paint_image_resource_load_delay')
|
|
436
|
-
?.percentiles?.p75;
|
|
437
|
-
const loadDuration =
|
|
438
|
-
this.#cruxManager.getSelectedFieldMetricData('largest_contentful_paint_image_resource_load_duration')
|
|
439
|
-
?.percentiles?.p75;
|
|
440
|
-
const renderDelay =
|
|
441
|
-
this.#cruxManager.getSelectedFieldMetricData('largest_contentful_paint_image_element_render_delay')
|
|
442
|
-
?.percentiles?.p75;
|
|
443
|
-
|
|
444
|
-
if (typeof ttfb !== 'number' || typeof loadDelay !== 'number' || typeof loadDuration !== 'number' ||
|
|
445
|
-
typeof renderDelay !== 'number') {
|
|
446
|
-
return null;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
return {
|
|
450
|
-
timeToFirstByte: Trace.Types.Timing.Milli(ttfb),
|
|
451
|
-
resourceLoadDelay: Trace.Types.Timing.Milli(loadDelay),
|
|
452
|
-
resourceLoadTime: Trace.Types.Timing.Milli(loadDuration),
|
|
453
|
-
elementRenderDelay: Trace.Types.Timing.Milli(renderDelay),
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
#renderLcpCard(): Lit.LitTemplate {
|
|
458
|
-
const fieldData = this.#cruxManager.getSelectedFieldMetricData('largest_contentful_paint');
|
|
459
|
-
const nodeLink =
|
|
460
|
-
this.#lcpValue?.nodeRef && PanelsCommon.DOMLinkifier.Linkifier.instance().linkify(this.#lcpValue?.nodeRef);
|
|
461
|
-
const phases = this.#lcpValue?.phases;
|
|
462
|
-
|
|
463
|
-
const fieldPhases = this.#getLcpFieldPhases();
|
|
464
|
-
|
|
465
|
-
// clang-format off
|
|
466
|
-
return html`
|
|
467
|
-
<devtools-metric-card .data=${{
|
|
468
|
-
metric: 'LCP',
|
|
469
|
-
localValue: this.#lcpValue?.value,
|
|
470
|
-
fieldValue: fieldData?.percentiles?.p75,
|
|
471
|
-
histogram: fieldData?.histogram,
|
|
472
|
-
tooltipContainer: this.#tooltipContainerEl,
|
|
473
|
-
warnings: this.#lcpValue?.warnings,
|
|
474
|
-
phases: phases && [
|
|
475
|
-
[i18nString(UIStrings.timeToFirstByte), phases.timeToFirstByte, fieldPhases?.timeToFirstByte],
|
|
476
|
-
[i18nString(UIStrings.resourceLoadDelay), phases.resourceLoadDelay, fieldPhases?.resourceLoadDelay],
|
|
477
|
-
[i18nString(UIStrings.resourceLoadDuration), phases.resourceLoadTime, fieldPhases?.resourceLoadTime],
|
|
478
|
-
[i18nString(UIStrings.elementRenderDelay), phases.elementRenderDelay, fieldPhases?.elementRenderDelay],
|
|
479
|
-
],
|
|
480
|
-
} as MetricCardData}>
|
|
481
|
-
${nodeLink ? html`
|
|
482
|
-
<div class="related-info" slot="extra-info">
|
|
483
|
-
<span class="related-info-label">${i18nString(UIStrings.lcpElement)}</span>
|
|
484
|
-
<span class="related-info-link">
|
|
485
|
-
${widget(PanelsCommon.DOMLinkifier.DOMNodeLink, {node: this.#lcpValue?.nodeRef})}
|
|
486
|
-
</span>
|
|
487
|
-
</div>
|
|
488
|
-
`
|
|
489
|
-
: nothing}
|
|
490
|
-
</devtools-metric-card>
|
|
491
|
-
`;
|
|
492
|
-
// clang-format on
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
#renderClsCard(): Lit.LitTemplate {
|
|
496
|
-
const fieldData = this.#cruxManager.getSelectedFieldMetricData('cumulative_layout_shift');
|
|
497
|
-
|
|
498
|
-
const clusterIds = new Set(this.#clsValue?.clusterShiftIds || []);
|
|
499
|
-
const clusterIsVisible =
|
|
500
|
-
clusterIds.size > 0 && this.#layoutShifts.some(layoutShift => clusterIds.has(layoutShift.uniqueLayoutShiftId));
|
|
501
|
-
|
|
502
|
-
// clang-format off
|
|
503
|
-
return html`
|
|
504
|
-
<devtools-metric-card .data=${{
|
|
505
|
-
metric: 'CLS',
|
|
506
|
-
localValue: this.#clsValue?.value,
|
|
507
|
-
fieldValue: fieldData?.percentiles?.p75,
|
|
508
|
-
histogram: fieldData?.histogram,
|
|
509
|
-
tooltipContainer: this.#tooltipContainerEl,
|
|
510
|
-
warnings: this.#clsValue?.warnings,
|
|
511
|
-
} as MetricCardData}>
|
|
512
|
-
${clusterIsVisible ? html`
|
|
513
|
-
<div class="related-info" slot="extra-info">
|
|
514
|
-
<span class="related-info-label">${i18nString(UIStrings.worstCluster)}</span>
|
|
515
|
-
<button
|
|
516
|
-
class="link-to-log"
|
|
517
|
-
title=${i18nString(UIStrings.showClsCluster)}
|
|
518
|
-
@click=${() => this.#revealLayoutShiftCluster(clusterIds)}
|
|
519
|
-
jslog=${VisualLogging.action('timeline.landing.show-cls-cluster').track({click: true})}
|
|
520
|
-
>${i18nString(UIStrings.numShifts, {shiftCount: clusterIds.size})}</button>
|
|
521
|
-
</div>
|
|
522
|
-
` : nothing}
|
|
523
|
-
</devtools-metric-card>
|
|
524
|
-
`;
|
|
525
|
-
// clang-format on
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
#renderInpCard(): Lit.LitTemplate {
|
|
529
|
-
const fieldData = this.#cruxManager.getSelectedFieldMetricData('interaction_to_next_paint');
|
|
530
|
-
const phases = this.#inpValue?.phases;
|
|
531
|
-
const interaction = this.#inpValue && this.#interactions.get(this.#inpValue.interactionId);
|
|
532
|
-
|
|
533
|
-
// clang-format off
|
|
534
|
-
return html`
|
|
535
|
-
<devtools-metric-card .data=${{
|
|
536
|
-
metric: 'INP',
|
|
537
|
-
localValue: this.#inpValue?.value,
|
|
538
|
-
fieldValue: fieldData?.percentiles?.p75,
|
|
539
|
-
histogram: fieldData?.histogram,
|
|
540
|
-
tooltipContainer: this.#tooltipContainerEl,
|
|
541
|
-
warnings: this.#inpValue?.warnings,
|
|
542
|
-
phases: phases && [
|
|
543
|
-
[i18nString(UIStrings.inputDelay), phases.inputDelay],
|
|
544
|
-
[i18nString(UIStrings.processingDuration), phases.processingDuration],
|
|
545
|
-
[i18nString(UIStrings.presentationDelay), phases.presentationDelay],
|
|
546
|
-
],
|
|
547
|
-
} as MetricCardData}>
|
|
548
|
-
${interaction ? html`
|
|
549
|
-
<div class="related-info" slot="extra-info">
|
|
550
|
-
<span class="related-info-label">${i18nString(UIStrings.inpInteractionLink)}</span>
|
|
551
|
-
<button
|
|
552
|
-
class="link-to-log"
|
|
553
|
-
title=${i18nString(UIStrings.showInpInteraction)}
|
|
554
|
-
@click=${() => this.#revealInteraction(interaction)}
|
|
555
|
-
jslog=${VisualLogging.action('timeline.landing.show-inp-interaction').track({click: true})}
|
|
556
|
-
>${interaction.interactionType}</button>
|
|
557
|
-
</div>
|
|
558
|
-
` : nothing}
|
|
559
|
-
</devtools-metric-card>
|
|
560
|
-
`;
|
|
561
|
-
// clang-format on
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
#renderRecordAction(action: UI.ActionRegistration.Action): Lit.LitTemplate {
|
|
565
|
-
function onClick(): void {
|
|
566
|
-
void action.execute();
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
// clang-format off
|
|
570
|
-
return html`
|
|
571
|
-
<div class="record-action">
|
|
572
|
-
<devtools-button @click=${onClick} .data=${{
|
|
573
|
-
variant: Buttons.Button.Variant.TEXT,
|
|
574
|
-
size: Buttons.Button.Size.REGULAR,
|
|
575
|
-
iconName: action.icon(),
|
|
576
|
-
title: action.title(),
|
|
577
|
-
jslogContext: action.id(),
|
|
578
|
-
} as Buttons.Button.ButtonData}>
|
|
579
|
-
${action.title()}
|
|
580
|
-
</devtools-button>
|
|
581
|
-
<span class="shortcut-label">${UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutTitleForAction(action.id())}</span>
|
|
582
|
-
</div>
|
|
583
|
-
`;
|
|
584
|
-
// clang-format on
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
#getNetworkRecTitle(): string|null {
|
|
588
|
-
const response = this.#cruxManager.getSelectedFieldMetricData('round_trip_time');
|
|
589
|
-
if (!response?.percentiles) {
|
|
590
|
-
return null;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
const rtt = Number(response.percentiles.p75);
|
|
594
|
-
if (!Number.isFinite(rtt)) {
|
|
595
|
-
return null;
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
if (rtt < RTT_MINIMUM) {
|
|
599
|
-
return i18nString(UIStrings.tryDisablingThrottling);
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
const conditions = SDK.NetworkManager.getRecommendedNetworkPreset(rtt);
|
|
603
|
-
if (!conditions) {
|
|
604
|
-
return null;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
const title = typeof conditions.title === 'function' ? conditions.title() : conditions.title;
|
|
608
|
-
return i18nString(UIStrings.tryUsingThrottling, {PH1: title});
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
#getDeviceRec(): string|null {
|
|
612
|
-
// `form_factors` metric is only populated if CrUX data is fetched for all devices.
|
|
613
|
-
const fractions = this.#cruxManager.getFieldResponse(this.#cruxManager.fieldPageScope, 'ALL')
|
|
614
|
-
?.record.metrics.form_factors?.fractions;
|
|
615
|
-
if (!fractions) {
|
|
616
|
-
return null;
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
return i18nString(UIStrings.percentDevices, {
|
|
620
|
-
PH1: Math.round(fractions.phone * 100),
|
|
621
|
-
PH2: Math.round(fractions.desktop * 100),
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
#renderRecordingSettings(): Lit.LitTemplate {
|
|
626
|
-
const fieldEnabled = this.#cruxManager.getConfigSetting().get().enabled;
|
|
627
|
-
|
|
628
|
-
const deviceRecEl = document.createElement('span');
|
|
629
|
-
deviceRecEl.classList.add('environment-rec');
|
|
630
|
-
deviceRecEl.textContent = this.#getDeviceRec() || i18nString(UIStrings.notEnoughData);
|
|
631
|
-
|
|
632
|
-
const networkRecEl = document.createElement('span');
|
|
633
|
-
networkRecEl.classList.add('environment-rec');
|
|
634
|
-
networkRecEl.textContent = this.#getNetworkRecTitle() || i18nString(UIStrings.notEnoughData);
|
|
635
|
-
|
|
636
|
-
const recs = PanelsCommon.ThrottlingUtils.getThrottlingRecommendations();
|
|
637
|
-
|
|
638
|
-
// clang-format off
|
|
639
|
-
return html`
|
|
640
|
-
<h3 class="card-title">${i18nString(UIStrings.environmentSettings)}</h3>
|
|
641
|
-
<div class="device-toolbar-description">${md(i18nString(UIStrings.useDeviceToolbar))}</div>
|
|
642
|
-
${fieldEnabled ? html`
|
|
643
|
-
<ul class="environment-recs-list">
|
|
644
|
-
<li>${uiI18n.getFormatLocalizedString(str_, UIStrings.device, {PH1: deviceRecEl})}</li>
|
|
645
|
-
<li>${uiI18n.getFormatLocalizedString(str_, UIStrings.network, {PH1: networkRecEl})}</li>
|
|
646
|
-
</ul>
|
|
647
|
-
` : nothing}
|
|
648
|
-
<div class="environment-option">
|
|
649
|
-
${widget(CPUThrottlingSelector, {recommendedOption: recs.cpuOption})}
|
|
650
|
-
</div>
|
|
651
|
-
<div class="environment-option">
|
|
652
|
-
<devtools-network-throttling-selector .recommendedConditions=${recs.networkConditions}></devtools-network-throttling-selector>
|
|
653
|
-
</div>
|
|
654
|
-
<div class="environment-option">
|
|
655
|
-
<setting-checkbox
|
|
656
|
-
class="network-cache-setting"
|
|
657
|
-
.data=${{
|
|
658
|
-
setting: Common.Settings.Settings.instance().moduleSetting('cache-disabled'),
|
|
659
|
-
textOverride: i18nString(UIStrings.disableNetworkCache),
|
|
660
|
-
} as Settings.SettingCheckbox.SettingCheckboxData}
|
|
661
|
-
></setting-checkbox>
|
|
662
|
-
</div>
|
|
663
|
-
`;
|
|
664
|
-
// clang-format on
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
#getPageScopeLabel(pageScope: CrUXManager.PageScope): string {
|
|
668
|
-
const key = this.#cruxManager.pageResult?.[`${pageScope}-ALL`]?.record.key[pageScope];
|
|
669
|
-
if (key) {
|
|
670
|
-
return pageScope === 'url' ? i18nString(UIStrings.urlOptionWithKey, {PH1: key}) :
|
|
671
|
-
i18nString(UIStrings.originOptionWithKey, {PH1: key});
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
const baseLabel = pageScope === 'url' ? i18nString(UIStrings.urlOption) : i18nString(UIStrings.originOption);
|
|
675
|
-
return i18nString(UIStrings.needsDataOption, {PH1: baseLabel});
|
|
676
|
-
}
|
|
677
|
-
|
|
678
1206
|
#onPageScopeMenuItemSelected(event: Menus.SelectMenu.SelectMenuItemSelectedEvent): void {
|
|
679
1207
|
if (event.itemValue === 'url') {
|
|
680
1208
|
this.#cruxManager.fieldPageScope = 'url';
|
|
@@ -684,273 +1212,16 @@ export class LiveMetricsView extends UI.Widget.Widget {
|
|
|
684
1212
|
this.requestUpdate();
|
|
685
1213
|
}
|
|
686
1214
|
|
|
687
|
-
#renderPageScopeSetting(): Lit.LitTemplate {
|
|
688
|
-
if (!this.#cruxManager.getConfigSetting().get().enabled) {
|
|
689
|
-
return Lit.nothing;
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
const urlLabel = this.#getPageScopeLabel('url');
|
|
693
|
-
const originLabel = this.#getPageScopeLabel('origin');
|
|
694
|
-
|
|
695
|
-
const buttonTitle = this.#cruxManager.fieldPageScope === 'url' ? urlLabel : originLabel;
|
|
696
|
-
const accessibleTitle = i18nString(UIStrings.showFieldDataForPage, {PH1: buttonTitle});
|
|
697
|
-
|
|
698
|
-
// If there is no data at all we should force users to switch pages or reconfigure CrUX.
|
|
699
|
-
const shouldDisable = !this.#cruxManager.pageResult?.['url-ALL'] && !this.#cruxManager.pageResult?.['origin-ALL'];
|
|
700
|
-
|
|
701
|
-
/* eslint-disable @devtools/no-deprecated-component-usages */
|
|
702
|
-
return html`
|
|
703
|
-
<devtools-select-menu
|
|
704
|
-
id="page-scope-select"
|
|
705
|
-
class="field-data-option"
|
|
706
|
-
@selectmenuselected=${this.#onPageScopeMenuItemSelected}
|
|
707
|
-
.showDivider=${true}
|
|
708
|
-
.showArrow=${true}
|
|
709
|
-
.sideButton=${false}
|
|
710
|
-
.showSelectedItem=${true}
|
|
711
|
-
.buttonTitle=${buttonTitle}
|
|
712
|
-
.disabled=${shouldDisable}
|
|
713
|
-
title=${accessibleTitle}
|
|
714
|
-
>
|
|
715
|
-
<devtools-menu-item
|
|
716
|
-
.value=${'url'}
|
|
717
|
-
.selected=${this.#cruxManager.fieldPageScope === 'url'}
|
|
718
|
-
>
|
|
719
|
-
${urlLabel}
|
|
720
|
-
</devtools-menu-item>
|
|
721
|
-
<devtools-menu-item
|
|
722
|
-
.value=${'origin'}
|
|
723
|
-
.selected=${this.#cruxManager.fieldPageScope === 'origin'}
|
|
724
|
-
>
|
|
725
|
-
${originLabel}
|
|
726
|
-
</devtools-menu-item>
|
|
727
|
-
</devtools-select-menu>
|
|
728
|
-
`;
|
|
729
|
-
/* eslint-enable @devtools/no-deprecated-component-usages */
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
#getDeviceScopeDisplayName(deviceScope: CrUXManager.DeviceScope): string {
|
|
733
|
-
switch (deviceScope) {
|
|
734
|
-
case 'ALL':
|
|
735
|
-
return i18nString(UIStrings.allDevices);
|
|
736
|
-
case 'DESKTOP':
|
|
737
|
-
return i18nString(UIStrings.desktop);
|
|
738
|
-
case 'PHONE':
|
|
739
|
-
return i18nString(UIStrings.mobile);
|
|
740
|
-
case 'TABLET':
|
|
741
|
-
return i18nString(UIStrings.tablet);
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
#getLabelForDeviceOption(deviceOption: DeviceOption): string {
|
|
746
|
-
let baseLabel;
|
|
747
|
-
if (deviceOption === 'AUTO') {
|
|
748
|
-
const deviceScope = this.#cruxManager.resolveDeviceOptionToScope(deviceOption);
|
|
749
|
-
const deviceScopeLabel = this.#getDeviceScopeDisplayName(deviceScope);
|
|
750
|
-
baseLabel = i18nString(UIStrings.auto, {PH1: deviceScopeLabel});
|
|
751
|
-
} else {
|
|
752
|
-
baseLabel = this.#getDeviceScopeDisplayName(deviceOption);
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
if (!this.#cruxManager.pageResult) {
|
|
756
|
-
return i18nString(UIStrings.loadingOption, {PH1: baseLabel});
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
const result = this.#cruxManager.getSelectedFieldResponse();
|
|
760
|
-
if (!result) {
|
|
761
|
-
return i18nString(UIStrings.needsDataOption, {PH1: baseLabel});
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
return baseLabel;
|
|
765
|
-
}
|
|
766
|
-
|
|
767
1215
|
#onDeviceOptionMenuItemSelected(event: Menus.SelectMenu.SelectMenuItemSelectedEvent): void {
|
|
768
1216
|
this.#cruxManager.fieldDeviceOption = event.itemValue as DeviceOption;
|
|
769
1217
|
this.requestUpdate();
|
|
770
1218
|
}
|
|
771
1219
|
|
|
772
|
-
#renderDeviceScopeSetting(): Lit.LitTemplate {
|
|
773
|
-
if (!this.#cruxManager.getConfigSetting().get().enabled) {
|
|
774
|
-
return Lit.nothing;
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
// If there is no data at all we should force users to try adjusting the page scope
|
|
778
|
-
// before coming back to this option.
|
|
779
|
-
const shouldDisable = !this.#cruxManager.getFieldResponse(this.#cruxManager.fieldPageScope, 'ALL');
|
|
780
|
-
|
|
781
|
-
const currentDeviceLabel = this.#getLabelForDeviceOption(this.#cruxManager.fieldDeviceOption);
|
|
782
|
-
|
|
783
|
-
// clang-format off
|
|
784
|
-
/* eslint-disable @devtools/no-deprecated-component-usages */
|
|
785
|
-
return html`
|
|
786
|
-
<devtools-select-menu
|
|
787
|
-
id="device-scope-select"
|
|
788
|
-
class="field-data-option"
|
|
789
|
-
@selectmenuselected=${this.#onDeviceOptionMenuItemSelected}
|
|
790
|
-
.showDivider=${true}
|
|
791
|
-
.showArrow=${true}
|
|
792
|
-
.sideButton=${false}
|
|
793
|
-
.showSelectedItem=${true}
|
|
794
|
-
.buttonTitle=${i18nString(UIStrings.device, {PH1: currentDeviceLabel})}
|
|
795
|
-
.disabled=${shouldDisable}
|
|
796
|
-
title=${i18nString(UIStrings.showFieldDataForDevice, {PH1: currentDeviceLabel})}
|
|
797
|
-
>
|
|
798
|
-
${DEVICE_OPTION_LIST.map(deviceOption => {
|
|
799
|
-
return html`
|
|
800
|
-
<devtools-menu-item
|
|
801
|
-
.value=${deviceOption}
|
|
802
|
-
.selected=${this.#cruxManager.fieldDeviceOption === deviceOption}
|
|
803
|
-
>
|
|
804
|
-
${this.#getLabelForDeviceOption(deviceOption)}
|
|
805
|
-
</devtools-menu-item>
|
|
806
|
-
`;
|
|
807
|
-
})}
|
|
808
|
-
</devtools-select-menu>
|
|
809
|
-
`;
|
|
810
|
-
/* eslint-enable @devtools/no-deprecated-component-usages */
|
|
811
|
-
// clang-format on
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
#getCollectionPeriodRange(): string|null {
|
|
815
|
-
const selectedResponse = this.#cruxManager.getSelectedFieldResponse();
|
|
816
|
-
if (!selectedResponse) {
|
|
817
|
-
return null;
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
const {firstDate, lastDate} = selectedResponse.record.collectionPeriod;
|
|
821
|
-
|
|
822
|
-
const formattedFirstDate = new Date(
|
|
823
|
-
firstDate.year,
|
|
824
|
-
// CrUX month is 1-indexed but `Date` month is 0-indexed
|
|
825
|
-
firstDate.month - 1,
|
|
826
|
-
firstDate.day,
|
|
827
|
-
);
|
|
828
|
-
const formattedLastDate = new Date(
|
|
829
|
-
lastDate.year,
|
|
830
|
-
// CrUX month is 1-indexed but `Date` month is 0-indexed
|
|
831
|
-
lastDate.month - 1,
|
|
832
|
-
lastDate.day,
|
|
833
|
-
);
|
|
834
|
-
|
|
835
|
-
const options: Intl.DateTimeFormatOptions = {
|
|
836
|
-
year: 'numeric',
|
|
837
|
-
month: 'short',
|
|
838
|
-
day: 'numeric',
|
|
839
|
-
};
|
|
840
|
-
|
|
841
|
-
return i18nString(UIStrings.dateRange, {
|
|
842
|
-
PH1: formattedFirstDate.toLocaleDateString(undefined, options),
|
|
843
|
-
PH2: formattedLastDate.toLocaleDateString(undefined, options),
|
|
844
|
-
});
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
#renderFieldDataHistoryLink(): Lit.LitTemplate {
|
|
848
|
-
if (!this.#cruxManager.getConfigSetting().get().enabled) {
|
|
849
|
-
return Lit.nothing;
|
|
850
|
-
}
|
|
851
|
-
const normalizedUrl = this.#cruxManager.pageResult?.normalizedUrl;
|
|
852
|
-
if (!normalizedUrl) {
|
|
853
|
-
return Lit.nothing;
|
|
854
|
-
}
|
|
855
|
-
const tmp = new URL('https://cruxvis.withgoogle.com/');
|
|
856
|
-
tmp.searchParams.set('view', 'cwvsummary');
|
|
857
|
-
tmp.searchParams.set('url', normalizedUrl);
|
|
858
|
-
// identifier must be 'origin' or 'url'.
|
|
859
|
-
const identifier = this.#cruxManager.fieldPageScope;
|
|
860
|
-
tmp.searchParams.set('identifier', identifier);
|
|
861
|
-
// device must be one 'PHONE', 'DESKTOP', 'TABLET', or 'ALL'.
|
|
862
|
-
const device = this.#cruxManager.getSelectedDeviceScope();
|
|
863
|
-
tmp.searchParams.set('device', device);
|
|
864
|
-
const cruxVis = `${tmp.origin}/#/${tmp.search}`;
|
|
865
|
-
return html`
|
|
866
|
-
(<devtools-link href=${cruxVis}
|
|
867
|
-
class="local-field-link"
|
|
868
|
-
title=${i18nString(UIStrings.fieldDataHistoryTooltip)}
|
|
869
|
-
>${i18nString(UIStrings.fieldDataHistoryLink)}</devtools-link>)
|
|
870
|
-
`;
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
#renderCollectionPeriod(): Lit.LitTemplate {
|
|
874
|
-
const range = this.#getCollectionPeriodRange();
|
|
875
|
-
|
|
876
|
-
const dateEl = document.createElement('span');
|
|
877
|
-
dateEl.classList.add('collection-period-range');
|
|
878
|
-
dateEl.textContent = range || i18nString(UIStrings.notEnoughData);
|
|
879
|
-
|
|
880
|
-
const message = uiI18n.getFormatLocalizedString(str_, UIStrings.collectionPeriod, {
|
|
881
|
-
PH1: dateEl,
|
|
882
|
-
});
|
|
883
|
-
|
|
884
|
-
const fieldDataHistoryLink = range ? this.#renderFieldDataHistoryLink() : Lit.nothing;
|
|
885
|
-
|
|
886
|
-
const warnings = this.#cruxManager.pageResult?.warnings || [];
|
|
887
|
-
|
|
888
|
-
return html`
|
|
889
|
-
<div class="field-data-message">
|
|
890
|
-
<div>${message} ${fieldDataHistoryLink}</div>
|
|
891
|
-
${warnings.map(warning => html`
|
|
892
|
-
<div class="field-data-warning">${warning}</div>
|
|
893
|
-
`)}
|
|
894
|
-
</div>
|
|
895
|
-
`;
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
#renderFieldDataMessage(): Lit.LitTemplate {
|
|
899
|
-
if (this.#cruxManager.getConfigSetting().get().enabled) {
|
|
900
|
-
return this.#renderCollectionPeriod();
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
// clang-format off
|
|
904
|
-
return html`
|
|
905
|
-
<div class="field-data-message">
|
|
906
|
-
${uiI18n.getFormatLocalizedStringTemplate(
|
|
907
|
-
str_,
|
|
908
|
-
UIStrings.seeHowYourLocalMetricsCompare,
|
|
909
|
-
{ PH1: html`<devtools-link href="https://developer.chrome.com/docs/crux">${i18n.i18n.lockedString('Chrome UX Report')}</devtools-link>` },
|
|
910
|
-
)}
|
|
911
|
-
</div>
|
|
912
|
-
`;
|
|
913
|
-
// clang-format on
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
#renderLogSection(): Lit.LitTemplate {
|
|
917
|
-
// clang-format off
|
|
918
|
-
return html`
|
|
919
|
-
<section
|
|
920
|
-
class="logs-section"
|
|
921
|
-
aria-label=${i18nString(UIStrings.eventLogs)}
|
|
922
|
-
>
|
|
923
|
-
<devtools-widget ${widget(LiveMetricsLogs)}
|
|
924
|
-
${widgetRef(LiveMetricsLogs, widget => {
|
|
925
|
-
this.#logsEl = widget;
|
|
926
|
-
})}
|
|
927
|
-
>
|
|
928
|
-
${this.#renderInteractionsLog()}
|
|
929
|
-
${this.#renderLayoutShiftsLog()}
|
|
930
|
-
</devtools-widget>
|
|
931
|
-
</section>
|
|
932
|
-
`;
|
|
933
|
-
// clang-format on
|
|
934
|
-
}
|
|
935
|
-
|
|
936
1220
|
async #revealInteraction(interaction: LiveMetrics.Interaction): Promise<void> {
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
const success = this.#logsEl.selectTab('interactions');
|
|
943
|
-
if (!success) {
|
|
944
|
-
return;
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
await RenderCoordinator.write(() => {
|
|
948
|
-
interactionEl.scrollIntoView({
|
|
949
|
-
block: 'center',
|
|
950
|
-
});
|
|
951
|
-
interactionEl.focus();
|
|
952
|
-
UI.UIUtils.runCSSAnimationOnce(interactionEl, 'highlight');
|
|
953
|
-
});
|
|
1221
|
+
this.#highlightedInteractionId = interaction.interactionId;
|
|
1222
|
+
this.requestUpdate();
|
|
1223
|
+
await this.updateComplete;
|
|
1224
|
+
this.#highlightedInteractionId = '';
|
|
954
1225
|
}
|
|
955
1226
|
|
|
956
1227
|
async #logExtraInteractionDetails(interaction: LiveMetrics.Interaction): Promise<void> {
|
|
@@ -960,250 +1231,35 @@ export class LiveMetricsView extends UI.Widget.Widget {
|
|
|
960
1231
|
}
|
|
961
1232
|
}
|
|
962
1233
|
|
|
963
|
-
#renderInteractionsLog(): Lit.LitTemplate {
|
|
964
|
-
if (!this.#interactions.size) {
|
|
965
|
-
return Lit.nothing;
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
// clang-format off
|
|
969
|
-
return html`
|
|
970
|
-
<ol class="log"
|
|
971
|
-
slot="interactions-log-content"
|
|
972
|
-
${Lit.Directives.ref(el => {
|
|
973
|
-
if (el instanceof HTMLElement) {
|
|
974
|
-
this.#interactionsListEl = el as HTMLElement;
|
|
975
|
-
}
|
|
976
|
-
})}
|
|
977
|
-
>
|
|
978
|
-
${this.#interactions.values().map(interaction => {
|
|
979
|
-
const metricValue = renderMetricValue(
|
|
980
|
-
'timeline.landing.interaction-event-timing',
|
|
981
|
-
interaction.duration,
|
|
982
|
-
INP_THRESHOLDS,
|
|
983
|
-
v => i18n.TimeUtilities.preciseMillisToString(v),
|
|
984
|
-
{dim: true},
|
|
985
|
-
);
|
|
986
|
-
|
|
987
|
-
const isP98Excluded = this.#inpValue && this.#inpValue.value < interaction.duration;
|
|
988
|
-
const isInp = this.#inpValue?.interactionId === interaction.interactionId;
|
|
989
|
-
|
|
990
|
-
return html`
|
|
991
|
-
<li id=${interaction.interactionId} class="log-item interaction" tabindex="-1">
|
|
992
|
-
<details>
|
|
993
|
-
<summary>
|
|
994
|
-
<span class="interaction-type">
|
|
995
|
-
${interaction.interactionType} ${isInp ?
|
|
996
|
-
html`<span class="interaction-inp-chip" title=${i18nString(UIStrings.inpInteraction)}>INP</span>`
|
|
997
|
-
: nothing}
|
|
998
|
-
</span>
|
|
999
|
-
<span class="interaction-node">
|
|
1000
|
-
${widget(PanelsCommon.DOMLinkifier.DOMNodeLink, {node: interaction.nodeRef})}
|
|
1001
|
-
</span>
|
|
1002
|
-
${isP98Excluded ? html`<devtools-icon
|
|
1003
|
-
class="interaction-info"
|
|
1004
|
-
name="info"
|
|
1005
|
-
title=${i18nString(UIStrings.interactionExcluded)}
|
|
1006
|
-
></devtools-icon>` : nothing}
|
|
1007
|
-
<span class="interaction-duration">${metricValue}</span>
|
|
1008
|
-
</summary>
|
|
1009
|
-
<div class="phase-table" role="table">
|
|
1010
|
-
<div class="phase-table-row phase-table-header-row" role="row">
|
|
1011
|
-
<div role="columnheader">${i18nString(UIStrings.phase)}</div>
|
|
1012
|
-
<div role="columnheader">
|
|
1013
|
-
${interaction.longAnimationFrameTimings.length ? html`
|
|
1014
|
-
<button
|
|
1015
|
-
class="log-extra-details-button"
|
|
1016
|
-
title=${i18nString(UIStrings.logToConsole)}
|
|
1017
|
-
@click=${() => this.#logExtraInteractionDetails(interaction)}
|
|
1018
|
-
>${i18nString(UIStrings.duration)}</button>
|
|
1019
|
-
` : i18nString(UIStrings.duration)}
|
|
1020
|
-
</div>
|
|
1021
|
-
</div>
|
|
1022
|
-
<div class="phase-table-row" role="row">
|
|
1023
|
-
<div role="cell">${i18nString(UIStrings.inputDelay)}</div>
|
|
1024
|
-
<div role="cell">${Math.round(interaction.phases.inputDelay)}</div>
|
|
1025
|
-
</div>
|
|
1026
|
-
<div class="phase-table-row" role="row">
|
|
1027
|
-
<div role="cell">${i18nString(UIStrings.processingDuration)}</div>
|
|
1028
|
-
<div role="cell">${Math.round(interaction.phases.processingDuration)}</div>
|
|
1029
|
-
</div>
|
|
1030
|
-
<div class="phase-table-row" role="row">
|
|
1031
|
-
<div role="cell">${i18nString(UIStrings.presentationDelay)}</div>
|
|
1032
|
-
<div role="cell">${Math.round(interaction.phases.presentationDelay)}</div>
|
|
1033
|
-
</div>
|
|
1034
|
-
</div>
|
|
1035
|
-
</details>
|
|
1036
|
-
</li>
|
|
1037
|
-
`;
|
|
1038
|
-
})}
|
|
1039
|
-
</ol>
|
|
1040
|
-
`;
|
|
1041
|
-
// clang-format on
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
1234
|
async #revealLayoutShiftCluster(clusterIds: Set<LiveMetrics.LayoutShift['uniqueLayoutShiftId']>): Promise<void> {
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
const layoutShiftEls: HTMLElement[] = [];
|
|
1050
|
-
for (const shiftId of clusterIds) {
|
|
1051
|
-
const layoutShiftEl = this.contentElement.querySelector<HTMLElement>('#' + CSS.escape(shiftId));
|
|
1052
|
-
if (layoutShiftEl) {
|
|
1053
|
-
layoutShiftEls.push(layoutShiftEl);
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
if (!layoutShiftEls.length) {
|
|
1058
|
-
return;
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
const success = this.#logsEl.selectTab('layout-shifts');
|
|
1062
|
-
if (!success) {
|
|
1063
|
-
return;
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
await RenderCoordinator.write(() => {
|
|
1067
|
-
layoutShiftEls[0].scrollIntoView({
|
|
1068
|
-
block: 'start',
|
|
1069
|
-
});
|
|
1070
|
-
layoutShiftEls[0].focus();
|
|
1071
|
-
for (const layoutShiftEl of layoutShiftEls) {
|
|
1072
|
-
UI.UIUtils.runCSSAnimationOnce(layoutShiftEl, 'highlight');
|
|
1073
|
-
}
|
|
1074
|
-
});
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
#renderLayoutShiftsLog(): Lit.LitTemplate {
|
|
1078
|
-
if (!this.#layoutShifts.length) {
|
|
1079
|
-
return Lit.nothing;
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
// clang-format off
|
|
1083
|
-
return html`
|
|
1084
|
-
<ol class="log"
|
|
1085
|
-
slot="layout-shifts-log-content"
|
|
1086
|
-
${Lit.Directives.ref(el => {
|
|
1087
|
-
if (el instanceof HTMLElement) {
|
|
1088
|
-
this.#layoutShiftsListEl = el as HTMLElement;
|
|
1089
|
-
}
|
|
1090
|
-
})}
|
|
1091
|
-
>
|
|
1092
|
-
${this.#layoutShifts.map(layoutShift => {
|
|
1093
|
-
const metricValue = renderMetricValue(
|
|
1094
|
-
'timeline.landing.layout-shift-event-score',
|
|
1095
|
-
layoutShift.score,
|
|
1096
|
-
CLS_THRESHOLDS,
|
|
1097
|
-
// CLS value is 2 decimal places, but individual shift scores tend to be much smaller
|
|
1098
|
-
// so we expand the precision here.
|
|
1099
|
-
v => v.toFixed(4),
|
|
1100
|
-
{dim: true},
|
|
1101
|
-
);
|
|
1102
|
-
|
|
1103
|
-
return html`
|
|
1104
|
-
<li id=${layoutShift.uniqueLayoutShiftId} class="log-item layout-shift" tabindex="-1">
|
|
1105
|
-
<div class="layout-shift-score">Layout shift score: ${metricValue}</div>
|
|
1106
|
-
<div class="layout-shift-nodes">
|
|
1107
|
-
${layoutShift.affectedNodeRefs.map(node => html`
|
|
1108
|
-
<div class="layout-shift-node">
|
|
1109
|
-
${widget(PanelsCommon.DOMLinkifier.DOMNodeLink, {node})}
|
|
1110
|
-
</div>
|
|
1111
|
-
`)}
|
|
1112
|
-
</div>
|
|
1113
|
-
</li>
|
|
1114
|
-
`;
|
|
1115
|
-
})}
|
|
1116
|
-
</ol>
|
|
1117
|
-
`;
|
|
1118
|
-
// clang-format on
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
#renderNodeView(): Lit.LitTemplate {
|
|
1122
|
-
return html`
|
|
1123
|
-
<style>${liveMetricsViewStyles}</style>
|
|
1124
|
-
<style>${metricValueStyles}</style>
|
|
1125
|
-
<div class="node-view">
|
|
1126
|
-
<main>
|
|
1127
|
-
<h2 class="section-title">${i18nString(UIStrings.nodePerformanceTimeline)}</h2>
|
|
1128
|
-
<div class="node-description">${i18nString(UIStrings.nodeClickToRecord)}</div>
|
|
1129
|
-
<div class="record-action-card">${this.#renderRecordAction(this.#toggleRecordAction)}</div>
|
|
1130
|
-
</main>
|
|
1131
|
-
</div>
|
|
1132
|
-
`;
|
|
1235
|
+
this.#highlightedLayoutShiftClusterIds = clusterIds;
|
|
1236
|
+
this.requestUpdate();
|
|
1237
|
+
await this.updateComplete;
|
|
1238
|
+
this.#highlightedLayoutShiftClusterIds = new Set();
|
|
1133
1239
|
}
|
|
1134
1240
|
|
|
1135
1241
|
override performUpdate(): void {
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1242
|
+
const viewInput: ViewInput = {
|
|
1243
|
+
isNode: this.isNode,
|
|
1244
|
+
lcpValue: this.#lcpValue,
|
|
1245
|
+
clsValue: this.#clsValue,
|
|
1246
|
+
inpValue: this.#inpValue,
|
|
1247
|
+
interactions: this.#interactions,
|
|
1248
|
+
layoutShifts: this.#layoutShifts,
|
|
1249
|
+
toggleRecordAction: this.#toggleRecordAction,
|
|
1250
|
+
recordReloadAction: this.#recordReloadAction,
|
|
1251
|
+
cruxManager: this.#cruxManager,
|
|
1252
|
+
handlePageScopeSelected: this.#onPageScopeMenuItemSelected.bind(this),
|
|
1253
|
+
handleDeviceOptionSelected: this.#onDeviceOptionMenuItemSelected.bind(this),
|
|
1254
|
+
revealLayoutShiftCluster: this.#revealLayoutShiftCluster.bind(this),
|
|
1255
|
+
revealInteraction: this.#revealInteraction.bind(this),
|
|
1256
|
+
logExtraInteractionDetails: this.#logExtraInteractionDetails.bind(this),
|
|
1257
|
+
highlightedInteractionId: this.#highlightedInteractionId,
|
|
1258
|
+
highlightedLayoutShiftClusterIds: this.#highlightedLayoutShiftClusterIds,
|
|
1259
|
+
};
|
|
1140
1260
|
|
|
1141
|
-
|
|
1142
|
-
const liveMetricsTitle =
|
|
1143
|
-
fieldEnabled ? i18nString(UIStrings.localAndFieldMetrics) : i18nString(UIStrings.localMetrics);
|
|
1144
|
-
|
|
1145
|
-
const helpLink = 'https://web.dev/articles/lab-and-field-data-differences#lab_data_versus_field_data' as
|
|
1146
|
-
Platform.DevToolsPath.UrlString;
|
|
1147
|
-
|
|
1148
|
-
// clang-format off
|
|
1149
|
-
const output = html`
|
|
1150
|
-
<style>${liveMetricsViewStyles}</style>
|
|
1151
|
-
<style>${metricValueStyles}</style>
|
|
1152
|
-
<div class="container">
|
|
1153
|
-
<div class="live-metrics-view">
|
|
1154
|
-
<main class="live-metrics">
|
|
1155
|
-
<h2 class="section-title">${liveMetricsTitle}</h2>
|
|
1156
|
-
<div class="metric-cards"
|
|
1157
|
-
${Lit.Directives.ref(el => {
|
|
1158
|
-
if (el instanceof HTMLElement) {
|
|
1159
|
-
this.#tooltipContainerEl = el;
|
|
1160
|
-
}
|
|
1161
|
-
})}
|
|
1162
|
-
>
|
|
1163
|
-
<div id="lcp">
|
|
1164
|
-
${this.#renderLcpCard()}
|
|
1165
|
-
</div>
|
|
1166
|
-
<div id="cls">
|
|
1167
|
-
${this.#renderClsCard()}
|
|
1168
|
-
</div>
|
|
1169
|
-
<div id="inp">
|
|
1170
|
-
${this.#renderInpCard()}
|
|
1171
|
-
</div>
|
|
1172
|
-
</div>
|
|
1173
|
-
<devtools-link
|
|
1174
|
-
href=${helpLink}
|
|
1175
|
-
class="local-field-link"
|
|
1176
|
-
title=${i18nString(UIStrings.localFieldLearnMoreTooltip)}
|
|
1177
|
-
>${i18nString(UIStrings.localFieldLearnMoreLink)}</devtools-link>
|
|
1178
|
-
${this.#renderLogSection()}
|
|
1179
|
-
</main>
|
|
1180
|
-
<aside class="next-steps" aria-labelledby="next-steps-section-title">
|
|
1181
|
-
<h2 id="next-steps-section-title" class="section-title">${i18nString(UIStrings.nextSteps)}</h2>
|
|
1182
|
-
<div id="field-setup" class="settings-card">
|
|
1183
|
-
<h3 class="card-title">${i18nString(UIStrings.fieldMetricsTitle)}</h3>
|
|
1184
|
-
${this.#renderFieldDataMessage()}
|
|
1185
|
-
${this.#renderPageScopeSetting()}
|
|
1186
|
-
${this.#renderDeviceScopeSetting()}
|
|
1187
|
-
<div class="field-setup-buttons">
|
|
1188
|
-
<devtools-field-settings-dialog></devtools-field-settings-dialog>
|
|
1189
|
-
</div>
|
|
1190
|
-
</div>
|
|
1191
|
-
<div id="recording-settings" class="settings-card">
|
|
1192
|
-
${this.#renderRecordingSettings()}
|
|
1193
|
-
</div>
|
|
1194
|
-
<div id="record" class="record-action-card">
|
|
1195
|
-
${this.#renderRecordAction(this.#toggleRecordAction)}
|
|
1196
|
-
</div>
|
|
1197
|
-
<div id="record-page-load" class="record-action-card">
|
|
1198
|
-
${this.#renderRecordAction(this.#recordReloadAction)}
|
|
1199
|
-
</div>
|
|
1200
|
-
</aside>
|
|
1201
|
-
</div>
|
|
1202
|
-
</div>
|
|
1203
|
-
`;
|
|
1204
|
-
Lit.render(output, this.contentElement, {host: this});
|
|
1261
|
+
this.#view(viewInput, this.#viewOutput, this.contentElement);
|
|
1205
1262
|
}
|
|
1206
|
-
// clang-format on
|
|
1207
1263
|
}
|
|
1208
1264
|
|
|
1209
1265
|
class LiveMetricsLogs extends UI.Widget.Widget {
|