lighthouse 13.6.0-dev.20261112 → 13.6.0-dev.20261117

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/.agents/skills/update-ard-port/SKILL.md +1 -1
  2. package/cli/bin.js +8 -3
  3. package/cli/open-file.js +1 -1
  4. package/cli/printer.js +1 -1
  5. package/cli/run.d.ts +7 -0
  6. package/cli/run.js +42 -5
  7. package/cli/sentry-prompt.js +2 -1
  8. package/cli/test/smokehouse/frontends/smokehouse-bin.js +1 -1
  9. package/cli/test/smokehouse/lighthouse-runners/cli.js +1 -2
  10. package/cli/test/smokehouse/report-assert.js +1 -2
  11. package/cli/test/smokehouse/smokehouse.js +1 -2
  12. package/core/audits/autocomplete.js +1 -2
  13. package/core/audits/baseline.d.ts +3 -0
  14. package/core/audits/bootup-time.js +1 -2
  15. package/core/audits/errors-in-console.js +1 -2
  16. package/core/audits/mainthread-work-breakdown.js +1 -2
  17. package/core/audits/metrics.d.ts +2 -2
  18. package/core/audits/metrics.js +1 -1
  19. package/core/computed/computed-artifact.js +1 -2
  20. package/core/computed/entity-classification.d.ts +3 -3
  21. package/core/computed/entity-classification.js +5 -3
  22. package/core/computed/js-bundles.js +1 -2
  23. package/core/computed/lcp-network-record.js +1 -1
  24. package/core/computed/load-simulator.d.ts +5 -3
  25. package/core/computed/load-simulator.js +9 -2
  26. package/core/computed/metrics/lcp-breakdown.d.ts +19 -0
  27. package/core/computed/metrics/lcp-breakdown.js +71 -8
  28. package/core/computed/metrics/responsiveness.d.ts +5 -3
  29. package/core/computed/metrics/responsiveness.js +1 -1
  30. package/core/computed/metrics/time-to-first-byte.js +3 -1
  31. package/core/computed/metrics/timing-summary.d.ts +7 -5
  32. package/core/computed/metrics/timing-summary.js +3 -4
  33. package/core/computed/navigation-insights.d.ts +5 -3
  34. package/core/computed/navigation-insights.js +1 -1
  35. package/core/computed/network-analysis.js +1 -2
  36. package/core/computed/page-dependency-graph.d.ts +5 -3
  37. package/core/computed/page-dependency-graph.js +5 -2
  38. package/core/computed/trace-engine-result.d.ts +7 -5
  39. package/core/computed/trace-engine-result.js +9 -14
  40. package/core/computed/unused-css.d.ts +2 -2
  41. package/core/computed/unused-css.js +1 -1
  42. package/core/config/config.js +1 -2
  43. package/core/gather/base-artifacts.js +1 -2
  44. package/core/gather/driver/environment.js +1 -2
  45. package/core/gather/driver/navigation.js +1 -2
  46. package/core/gather/driver/network-monitor.js +1 -2
  47. package/core/gather/driver/prepare.js +1 -2
  48. package/core/gather/driver/storage.js +1 -2
  49. package/core/gather/driver/target-manager.js +1 -2
  50. package/core/gather/driver/wait-for-condition.js +1 -2
  51. package/core/gather/driver.js +1 -2
  52. package/core/gather/gatherers/agentic/ard.js +1 -1
  53. package/core/gather/gatherers/agentic/llms-txt.js +1 -2
  54. package/core/gather/gatherers/image-elements.js +1 -2
  55. package/core/gather/gatherers/seo/robots-txt.js +1 -2
  56. package/core/gather/gatherers/stacks.js +1 -2
  57. package/core/gather/gatherers/stylesheets.js +1 -2
  58. package/core/gather/navigation-runner.js +1 -1
  59. package/core/gather/runner-helpers.js +1 -2
  60. package/core/gather/session.js +1 -2
  61. package/core/gather/snapshot-runner.js +1 -2
  62. package/core/gather/timespan-runner.js +1 -2
  63. package/core/lib/asset-saver.js +1 -2
  64. package/core/lib/baseline/web-features-data.json +12 -3
  65. package/core/lib/baseline/web-features-metadata.json +1 -1
  66. package/core/lib/csp-evaluator.js +1 -1
  67. package/core/lib/deprecations-strings.d.ts +0 -2
  68. package/core/lib/deprecations-strings.js +1 -18
  69. package/core/lib/i18n/i18n.js +1 -2
  70. package/core/lib/lighthouse-logger.d.ts +127 -0
  71. package/core/lib/lighthouse-logger.js +319 -0
  72. package/core/lib/median-run.d.ts +16 -6
  73. package/core/lib/median-run.js +13 -6
  74. package/core/lib/network-recorder.js +1 -2
  75. package/core/lib/network-request.d.ts +2 -2
  76. package/core/lib/network-request.js +1 -1
  77. package/core/lib/page-functions.js +2 -2
  78. package/core/lib/script-helpers.d.ts +23 -8
  79. package/core/lib/script-helpers.js +7 -6
  80. package/core/lib/sentry-reporter.d.ts +59 -0
  81. package/core/lib/sentry-reporter.js +281 -0
  82. package/core/lib/sentry.d.ts +7 -7
  83. package/core/lib/sentry.js +23 -40
  84. package/core/lib/stack-packs.js +1 -1
  85. package/core/lib/timing-trace-saver.d.ts +2 -2
  86. package/core/lib/timing-trace-saver.js +1 -1
  87. package/core/lib/tracehouse/task-summary.d.ts +16 -4
  88. package/core/lib/tracehouse/task-summary.js +6 -5
  89. package/core/lib/tracehouse/trace-processor.d.ts +6 -6
  90. package/core/lib/tracehouse/trace-processor.js +1 -1
  91. package/core/lib/traces/metric-trace-events.js +1 -2
  92. package/core/lib/url-utils.d.ts +4 -4
  93. package/core/lib/url-utils.js +1 -1
  94. package/core/runner.js +1 -2
  95. package/dist/report/bundle.esm.js +10 -10
  96. package/dist/report/flow.js +12 -12
  97. package/dist/report/standalone.js +11 -11
  98. package/package.json +19 -21
  99. package/report/renderer/text-encoding.d.ts +3 -5
  100. package/report/renderer/text-encoding.js +19 -33
  101. package/report/types/augment-dom.d.ts +0 -4
  102. package/shared/localization/locales/ar-XB.json +3 -0
  103. package/shared/localization/locales/ar.json +3 -0
  104. package/shared/localization/locales/bg.json +3 -0
  105. package/shared/localization/locales/ca.json +75 -72
  106. package/shared/localization/locales/cs.json +3 -0
  107. package/shared/localization/locales/da.json +3 -0
  108. package/shared/localization/locales/de.json +3 -0
  109. package/shared/localization/locales/el.json +3 -0
  110. package/shared/localization/locales/en-GB.json +3 -0
  111. package/shared/localization/locales/es-419.json +3 -0
  112. package/shared/localization/locales/es.json +3 -0
  113. package/shared/localization/locales/fi.json +3 -0
  114. package/shared/localization/locales/fil.json +3 -0
  115. package/shared/localization/locales/fr.json +3 -0
  116. package/shared/localization/locales/he.json +3 -0
  117. package/shared/localization/locales/hi.json +11 -8
  118. package/shared/localization/locales/hr.json +3 -0
  119. package/shared/localization/locales/hu.json +3 -0
  120. package/shared/localization/locales/id.json +3 -0
  121. package/shared/localization/locales/it.json +3 -0
  122. package/shared/localization/locales/ja.json +3 -0
  123. package/shared/localization/locales/ko.json +3 -0
  124. package/shared/localization/locales/lt.json +3 -0
  125. package/shared/localization/locales/lv.json +5 -2
  126. package/shared/localization/locales/nl.json +3 -0
  127. package/shared/localization/locales/no.json +3 -0
  128. package/shared/localization/locales/pl.json +3 -0
  129. package/shared/localization/locales/pt-PT.json +3 -0
  130. package/shared/localization/locales/pt.json +32 -29
  131. package/shared/localization/locales/ro.json +3 -0
  132. package/shared/localization/locales/ru.json +3 -0
  133. package/shared/localization/locales/sk.json +3 -0
  134. package/shared/localization/locales/sl.json +3 -0
  135. package/shared/localization/locales/sr-Latn.json +3 -0
  136. package/shared/localization/locales/sr.json +3 -0
  137. package/shared/localization/locales/sv.json +3 -0
  138. package/shared/localization/locales/ta.json +3 -0
  139. package/shared/localization/locales/te.json +3 -0
  140. package/shared/localization/locales/th.json +3 -0
  141. package/shared/localization/locales/tr.json +3 -0
  142. package/shared/localization/locales/uk.json +3 -0
  143. package/shared/localization/locales/vi.json +3 -0
  144. package/shared/localization/locales/zh-HK.json +3 -0
  145. package/shared/localization/locales/zh-TW.json +3 -0
  146. package/shared/localization/locales/zh.json +3 -0
  147. package/third-party/ard/README.md +1 -1
  148. package/third-party/ard/ard.js +1 -1
  149. package/tsconfig.json +2 -42
  150. package/types/artifacts.d.ts +7 -1
  151. package/types/internal/test.d.ts +5 -0
  152. package/report/types/buffer.d.ts +0 -19
@@ -4,14 +4,13 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import log from 'lighthouse-logger';
8
-
7
+ import log from './lighthouse-logger.js';
9
8
  import {initializeConfig} from '../config/config.js';
10
9
 
11
- /** @typedef {import('@sentry/node').Breadcrumb} Breadcrumb */
12
- /** @typedef {import('@sentry/node').NodeClient} NodeClient */
13
- /** @typedef {import('@sentry/node').NodeOptions} NodeOptions */
14
- /** @typedef {import('@sentry/node').SeverityLevel} SeverityLevel */
10
+ /** @typedef {import('./sentry-reporter.js').Breadcrumb} Breadcrumb */
11
+ /** @typedef {import('./sentry-reporter.js').EnvironmentData} EnvironmentData */
12
+ /** @typedef {import('./sentry-reporter.js').SeverityLevel} SeverityLevel */
13
+ /** @typedef {import('./sentry-reporter.js').CaptureOptions} CaptureOptions */
15
14
 
16
15
  const SENTRY_URL = 'https://a6bb0da87ee048cc9ae2a345fc09ab2e:63a7029f46f74265981b7e005e0f69f8@sentry.io/174697';
17
16
 
@@ -26,8 +25,8 @@ const noop = () => { };
26
25
  */
27
26
  const sentryDelegate = {
28
27
  init,
29
- /** @type {(message: string, level?: SeverityLevel) => void} */
30
- captureMessage: noop,
28
+ /** @type {(message: string, levelOrOpts?: SeverityLevel|CaptureOptions) => Promise<void>} */
29
+ captureMessage: async () => { },
31
30
  /** @type {(breadcrumb: Breadcrumb) => void} */
32
31
  captureBreadcrumb: noop,
33
32
  /** @type {() => any} */
@@ -43,7 +42,7 @@ const sentryDelegate = {
43
42
 
44
43
  /**
45
44
  * When called, replaces noops with actual Sentry implementation.
46
- * @param {{url: string, flags: LH.CliFlags, config?: LH.Config, environmentData: NodeOptions}} opts
45
+ * @param {{url: string, flags: LH.CliFlags, config?: LH.Config, environmentData: EnvironmentData}} opts
47
46
  */
48
47
  async function init(opts) {
49
48
  // If error reporting is disabled, leave the functions as a noop
@@ -57,11 +56,8 @@ async function init(opts) {
57
56
  }
58
57
 
59
58
  try {
60
- const Sentry = await import('@sentry/node');
61
- Sentry.init({
62
- ...opts.environmentData,
63
- dsn: SENTRY_URL,
64
- });
59
+ const {createSentryReporter} = await import('./sentry-reporter.js');
60
+ const Sentry = createSentryReporter(SENTRY_URL, opts.environmentData);
65
61
 
66
62
  /** @type {LH.Config.Settings | LH.CliFlags} */
67
63
  let settings = opts.flags;
@@ -95,15 +91,16 @@ async function init(opts) {
95
91
  // Keep a record of exceptions per audit/gatherer so we can just report once
96
92
  const sentryExceptionCache = new Map();
97
93
  // Special case captureException to return a Promise so we don't process.exit too early
98
- sentryDelegate.captureException = async (err, opts = {}) => {
94
+ sentryDelegate.captureException = async (err, opts) => {
99
95
  // Ignore if there wasn't an error
100
96
  if (!err) return;
97
+ opts = opts || {};
101
98
 
102
99
  // Ignore expected errors
103
100
  // @ts-expect-error Non-standard property added to flag error as not needing capturing.
104
101
  if (err.expected) return;
105
102
 
106
- const tags = opts.tags || {};
103
+ const tags = {...opts.tags};
107
104
  if (tags.audit) {
108
105
  const key = `audit-${tags.audit}-${err.message}`;
109
106
  if (sentryExceptionCache.has(key)) return;
@@ -128,33 +125,19 @@ async function init(opts) {
128
125
  // @ts-expect-error - properties added to protocol method LighthouseErrors.
129
126
  fingerprint = ['{{ default }}', err.protocolMethod, protocolError];
130
127
 
131
- opts.tags = opts.tags || {};
132
128
  // @ts-expect-error - properties added to protocol method LighthouseErrors.
133
- opts.tags.protocolMethod = err.protocolMethod;
129
+ tags.protocolMethod = err.protocolMethod;
134
130
  }
135
131
 
136
- Sentry.withScope(scope => {
137
- if (opts.level) {
138
- // @ts-expect-error - allow any string.
139
- scope.setLevel(opts.level);
140
- }
141
- if (opts.tags) {
142
- scope.setTags(opts.tags);
143
- }
144
- if (fingerprint) {
145
- scope.setFingerprint(fingerprint);
146
- }
147
-
148
- // Add extra details
149
- let extra;
150
- if (opts.extra) extra = {...opts.extra};
151
- // @ts-expect-error Non-standard property
152
- if (err.extra) extra = {...extra, ...err.extra};
153
- if (extra) {
154
- scope.setExtras(extra);
155
- }
156
-
157
- Sentry.captureException(err);
132
+ // @ts-expect-error Non-standard property
133
+ const extra = {...opts.extra, ...err.extra};
134
+
135
+ await Sentry.captureException(err, {
136
+ // @ts-expect-error - allow any string.
137
+ level: opts.level,
138
+ tags,
139
+ extra,
140
+ fingerprint,
158
141
  });
159
142
  };
160
143
  } catch (e) {
@@ -4,9 +4,9 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import log from 'lighthouse-logger';
8
7
  import stackPacks from 'lighthouse-stack-packs';
9
8
 
9
+ import log from './lighthouse-logger.js';
10
10
  import * as i18n from './i18n/i18n.js';
11
11
 
12
12
  /**
@@ -14,8 +14,8 @@
14
14
  export function generateTraceEvents(entries: LH.Artifacts.MeasureEntry[], threadId?: number | undefined): import("..").TraceEvent[];
15
15
  /**
16
16
  * Writes a trace file to disk
17
- * @param {LH.Result} lhr
17
+ * @param {Pick<LH.Result, 'timing'>} lhr
18
18
  * @return {string}
19
19
  */
20
- export function createTraceString(lhr: LH.Result): string;
20
+ export function createTraceString(lhr: Pick<LH.Result, "timing">): string;
21
21
  //# sourceMappingURL=timing-trace-saver.d.ts.map
@@ -75,7 +75,7 @@ function generateTraceEvents(entries, threadId = 0) {
75
75
 
76
76
  /**
77
77
  * Writes a trace file to disk
78
- * @param {LH.Result} lhr
78
+ * @param {Pick<LH.Result, 'timing'>} lhr
79
79
  * @return {string}
80
80
  */
81
81
  function createTraceString(lhr) {
@@ -3,15 +3,27 @@
3
3
  */
4
4
  export function getJavaScriptURLs(records: LH.Artifacts.NetworkRequest[]): Set<string>;
5
5
  /**
6
- * @param {LH.Artifacts.TaskNode} task
6
+ * @param {{attributableURLs: string[], event?: {name: string}}} task
7
7
  * @param {Set<string>} jsURLs
8
8
  * @return {string}
9
9
  */
10
- export function getAttributableURLForTask(task: LH.Artifacts.TaskNode, jsURLs: Set<string>): string;
10
+ export function getAttributableURLForTask(task: {
11
+ attributableURLs: string[];
12
+ event?: {
13
+ name: string;
14
+ };
15
+ }, jsURLs: Set<string>): string;
11
16
  /**
12
- * @param {LH.Artifacts.TaskNode[]} tasks
17
+ * @param {Array<{attributableURLs: string[], selfTime: number, group: LH.Artifacts.TaskNode['group'], event?: {name: string}}>} tasks
13
18
  * @param {Array<LH.Artifacts.NetworkRequest>} networkRecords
14
19
  * @return {Map<string, Record<string, number>>}
15
20
  */
16
- export function getExecutionTimingsByURL(tasks: LH.Artifacts.TaskNode[], networkRecords: Array<LH.Artifacts.NetworkRequest>): Map<string, Record<string, number>>;
21
+ export function getExecutionTimingsByURL(tasks: Array<{
22
+ attributableURLs: string[];
23
+ selfTime: number;
24
+ group: LH.Artifacts.TaskNode["group"];
25
+ event?: {
26
+ name: string;
27
+ };
28
+ }>, networkRecords: Array<LH.Artifacts.NetworkRequest>): Map<string, Record<string, number>>;
17
29
  //# sourceMappingURL=task-summary.d.ts.map
@@ -38,7 +38,7 @@ function getJavaScriptURLs(records) {
38
38
  }
39
39
 
40
40
  /**
41
- * @param {LH.Artifacts.TaskNode} task
41
+ * @param {{attributableURLs: string[], event?: {name: string}}} task
42
42
  * @param {Set<string>} jsURLs
43
43
  * @return {string}
44
44
  */
@@ -49,16 +49,17 @@ function getAttributableURLForTask(task, jsURLs) {
49
49
  // If we can't find what URL was responsible for this execution, attribute it to the root page
50
50
  // or Chrome depending on the type of work.
51
51
  if (!attributableURL || attributableURL === 'about:blank') {
52
- if (BROWSER_TASK_NAMES_SET.has(task.event.name)) attributableURL = 'Browser';
53
- else if (BROWSER_GC_TASK_NAMES_SET.has(task.event.name)) attributableURL = 'Browser GC';
54
- else attributableURL = 'Unattributable';
52
+ if (task.event && BROWSER_TASK_NAMES_SET.has(task.event.name)) attributableURL = 'Browser';
53
+ else if (task.event && BROWSER_GC_TASK_NAMES_SET.has(task.event.name)) {
54
+ attributableURL = 'Browser GC';
55
+ } else attributableURL = 'Unattributable';
55
56
  }
56
57
 
57
58
  return attributableURL;
58
59
  }
59
60
 
60
61
  /**
61
- * @param {LH.Artifacts.TaskNode[]} tasks
62
+ * @param {Array<{attributableURLs: string[], selfTime: number, group: LH.Artifacts.TaskNode['group'], event?: {name: string}}>} tasks
62
63
  * @param {Array<LH.Artifacts.NetworkRequest>} networkRecords
63
64
  * @return {Map<string, Record<string, number>>}
64
65
  */
@@ -91,7 +91,7 @@ export class TraceProcessor {
91
91
  * @param {LH.TraceEvent[]} traceEvents
92
92
  * @param {(e: LH.TraceEvent) => boolean} filter
93
93
  */
94
- static filteredTraceSort(traceEvents: LH.TraceEvent[], filter: (e: LH.TraceEvent) => boolean): import("../..").TraceEvent[];
94
+ static filteredTraceSort(traceEvents: LH.TraceEvent[], filter: (e: LH.TraceEvent) => boolean): import("../../index.js").TraceEvent[];
95
95
  /**
96
96
  * There should *always* be at least one top level event, having 0 typically means something is
97
97
  * drastically wrong with the trace and we should just give up early and loudly.
@@ -283,12 +283,12 @@ export class TraceProcessor {
283
283
  }): {
284
284
  timings: TraceNavigationTimesForFrame;
285
285
  timestamps: TraceNavigationTimesForFrame;
286
- timeOriginEvt: import("../..").TraceEvent;
287
- firstPaintEvt: import("../..").TraceEvent | undefined;
288
- firstContentfulPaintEvt: import("../..").TraceEvent;
286
+ timeOriginEvt: import("../../index.js").TraceEvent;
287
+ firstPaintEvt: import("../../index.js").TraceEvent | undefined;
288
+ firstContentfulPaintEvt: import("../../index.js").TraceEvent;
289
289
  largestContentfulPaintEvt: LCPEvent | undefined;
290
- loadEvt: import("../..").TraceEvent | undefined;
291
- domContentLoadedEvt: import("../..").TraceEvent | undefined;
290
+ loadEvt: import("../../index.js").TraceEvent | undefined;
291
+ domContentLoadedEvt: import("../../index.js").TraceEvent | undefined;
292
292
  lcpInvalidated: boolean;
293
293
  lcpImageUrl: string | undefined;
294
294
  };
@@ -21,7 +21,7 @@
21
21
  /** @typedef {Omit<LH.TraceEvent, 'name'|'args'> & {name: 'largestContentfulPaint::Invalidate'|'largestContentfulPaint::Candidate', args: {data?: {size?: number, nodeId?: number, type?: string}, frame: string}}} LCPEvent */
22
22
  /** @typedef {Omit<LH.TraceEvent, 'name'|'args'> & {name: 'largestContentfulPaint::Candidate', args: {data: {size: number, nodeId?: number, type?: string}, frame: string}}} LCPCandidateEvent */
23
23
 
24
- import log from 'lighthouse-logger';
24
+ import log from '../lighthouse-logger.js';
25
25
 
26
26
  const ACCEPTABLE_NAVIGATION_URL_REGEX = /^(chrome|https?):/;
27
27
 
@@ -4,8 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import log from 'lighthouse-logger';
8
-
7
+ import log from '../lighthouse-logger.js';
9
8
  import {TraceProcessor} from '../tracehouse/trace-processor.js';
10
9
 
11
10
  /**
@@ -38,13 +38,13 @@ declare class UrlUtils {
38
38
  static rootDomainsMatch(urlA: string | URL, urlB: string | URL): boolean;
39
39
  /**
40
40
  * @param {string} url
41
- * @param {{numPathParts: number, preserveQuery: boolean, preserveHost: boolean}=} options
41
+ * @param {{numPathParts?: number, preserveQuery?: boolean, preserveHost?: boolean}=} options
42
42
  * @return {string}
43
43
  */
44
44
  static getURLDisplayName(url: string, options?: {
45
- numPathParts: number;
46
- preserveQuery: boolean;
47
- preserveHost: boolean;
45
+ numPathParts?: number;
46
+ preserveQuery?: boolean;
47
+ preserveHost?: boolean;
48
48
  } | undefined): string;
49
49
  /**
50
50
  * Limits data URIs to 100 characters, returns all other strings untouched.
@@ -140,7 +140,7 @@ class UrlUtils {
140
140
 
141
141
  /**
142
142
  * @param {string} url
143
- * @param {{numPathParts: number, preserveQuery: boolean, preserveHost: boolean}=} options
143
+ * @param {{numPathParts?: number, preserveQuery?: boolean, preserveHost?: boolean}=} options
144
144
  * @return {string}
145
145
  */
146
146
  static getURLDisplayName(url, options) {
package/core/runner.js CHANGED
@@ -8,8 +8,7 @@ import fs from 'fs';
8
8
  import path from 'path';
9
9
 
10
10
 
11
- import log from 'lighthouse-logger';
12
-
11
+ import log from './lib/lighthouse-logger.js';
13
12
  import {ReportScoring} from './scoring.js';
14
13
  import {Audit} from './audits/audit.js';
15
14
  import * as format from '../shared/localization/format.js';