lighthouse 9.5.0-dev.20230122 → 9.5.0-dev.20230124

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 (131) hide show
  1. package/.codecov.yml +0 -5
  2. package/core/audits/audit.js +1 -1
  3. package/core/audits/bf-cache.js +1 -1
  4. package/core/audits/byte-efficiency/legacy-javascript.d.ts +1 -0
  5. package/core/audits/byte-efficiency/legacy-javascript.js +7 -3
  6. package/core/audits/dobetterweb/uses-http2.d.ts +5 -2
  7. package/core/audits/dobetterweb/uses-http2.js +12 -7
  8. package/core/audits/screenshot-thumbnails.d.ts +2 -1
  9. package/core/audits/screenshot-thumbnails.js +14 -9
  10. package/core/audits/third-party-facades.d.ts +3 -2
  11. package/core/audits/third-party-facades.js +12 -9
  12. package/core/audits/third-party-summary.d.ts +7 -6
  13. package/core/audits/third-party-summary.js +16 -14
  14. package/core/audits/valid-source-maps.d.ts +5 -3
  15. package/core/audits/valid-source-maps.js +11 -9
  16. package/core/computed/entity-classification.d.ts +29 -0
  17. package/core/computed/entity-classification.js +102 -0
  18. package/core/computed/processed-navigation.d.ts +12 -6
  19. package/core/computed/processed-navigation.js +19 -6
  20. package/core/computed/resource-summary.d.ts +4 -2
  21. package/core/computed/resource-summary.js +8 -5
  22. package/core/lib/url-utils.js +1 -1
  23. package/core/runner.d.ts +10 -0
  24. package/core/runner.js +48 -0
  25. package/core/util.cjs +43 -10
  26. package/core/util.d.cts +114 -2
  27. package/dist/report/bundle.esm.js +858 -883
  28. package/dist/report/flow.js +33 -23
  29. package/dist/report/standalone.js +27 -17
  30. package/flow-report/assets/standalone-flow-template.html +1 -1
  31. package/flow-report/src/common.tsx +1 -1
  32. package/flow-report/src/i18n/i18n.d.ts +103 -100
  33. package/flow-report/src/i18n/i18n.tsx +23 -18
  34. package/flow-report/src/sidebar/sidebar.tsx +3 -3
  35. package/flow-report/src/summary/category.tsx +7 -7
  36. package/flow-report/src/summary/summary.tsx +2 -2
  37. package/flow-report/src/topbar.tsx +4 -28
  38. package/package.json +5 -5
  39. package/readme.md +1 -1
  40. package/report/assets/standalone-template.html +1 -1
  41. package/report/assets/styles.css +3 -3
  42. package/report/assets/templates.html +4 -28
  43. package/report/renderer/category-renderer.js +19 -17
  44. package/report/renderer/components.js +119 -202
  45. package/report/renderer/crc-details-renderer.js +7 -6
  46. package/report/renderer/details-renderer.js +7 -6
  47. package/report/renderer/dom.js +1 -1
  48. package/report/renderer/element-screenshot-renderer.js +3 -3
  49. package/report/renderer/{i18n.d.ts → i18n-formatter.d.ts} +3 -9
  50. package/report/renderer/{i18n.js → i18n-formatter.js} +2 -11
  51. package/report/renderer/performance-category-renderer.js +17 -15
  52. package/report/renderer/pwa-category-renderer.js +5 -4
  53. package/report/renderer/report-globals.d.ts +21 -0
  54. package/report/renderer/report-globals.js +49 -0
  55. package/report/renderer/report-renderer.js +22 -24
  56. package/report/renderer/report-ui-features.js +9 -8
  57. package/report/renderer/report-utils.d.ts +116 -0
  58. package/report/renderer/{util.js → report-utils.js} +100 -415
  59. package/report/renderer/snippet-renderer.js +3 -2
  60. package/report/test/renderer/category-renderer-test.js +10 -5
  61. package/report/test/renderer/crc-details-renderer-test.js +8 -4
  62. package/report/test/renderer/details-renderer-test.js +8 -4
  63. package/report/test/renderer/dom-test.js +8 -4
  64. package/report/test/renderer/element-screenshot-renderer-test.js +9 -5
  65. package/report/test/renderer/{i18n-test.js → i18n-formatter-test.js} +15 -21
  66. package/report/test/renderer/performance-category-renderer-test.js +15 -10
  67. package/report/test/renderer/pwa-category-renderer-test.js +11 -6
  68. package/report/test/renderer/report-renderer-test.js +2 -2
  69. package/report/test/renderer/report-ui-features-test.js +3 -3
  70. package/report/test/renderer/{util-test.js → report-utils-test.js} +37 -235
  71. package/report/test/renderer/snippet-renderer-test.js +8 -4
  72. package/report/test-assets/lhr-3.0.0.json +2332 -0
  73. package/report/test-assets/lhr-4.3.0.json +4754 -0
  74. package/report/test-assets/lhr-5.0.0.json +5994 -0
  75. package/report/test-assets/lhr-6.0.0.json +7222 -0
  76. package/report/test-assets/lhr-8.5.0.json +8679 -0
  77. package/shared/localization/format.js +5 -2
  78. package/shared/localization/locales/ar-XB.json +50 -50
  79. package/shared/localization/locales/ar.json +50 -50
  80. package/shared/localization/locales/bg.json +50 -50
  81. package/shared/localization/locales/ca.json +50 -50
  82. package/shared/localization/locales/cs.json +50 -50
  83. package/shared/localization/locales/da.json +50 -50
  84. package/shared/localization/locales/de.json +50 -50
  85. package/shared/localization/locales/el.json +50 -50
  86. package/shared/localization/locales/en-GB.json +50 -50
  87. package/shared/localization/locales/en-US.json +55 -55
  88. package/shared/localization/locales/en-XA.json +50 -50
  89. package/shared/localization/locales/en-XL.json +55 -55
  90. package/shared/localization/locales/es-419.json +50 -50
  91. package/shared/localization/locales/es.json +50 -50
  92. package/shared/localization/locales/fi.json +50 -50
  93. package/shared/localization/locales/fil.json +50 -50
  94. package/shared/localization/locales/fr.json +50 -50
  95. package/shared/localization/locales/he.json +50 -50
  96. package/shared/localization/locales/hi.json +50 -50
  97. package/shared/localization/locales/hr.json +50 -50
  98. package/shared/localization/locales/hu.json +50 -50
  99. package/shared/localization/locales/id.json +50 -50
  100. package/shared/localization/locales/it.json +50 -50
  101. package/shared/localization/locales/ja.json +50 -50
  102. package/shared/localization/locales/ko.json +50 -50
  103. package/shared/localization/locales/lt.json +50 -50
  104. package/shared/localization/locales/lv.json +50 -50
  105. package/shared/localization/locales/nl.json +50 -50
  106. package/shared/localization/locales/no.json +50 -50
  107. package/shared/localization/locales/pl.json +50 -50
  108. package/shared/localization/locales/pt-PT.json +50 -50
  109. package/shared/localization/locales/pt.json +50 -50
  110. package/shared/localization/locales/ro.json +50 -50
  111. package/shared/localization/locales/ru.json +50 -50
  112. package/shared/localization/locales/sk.json +50 -50
  113. package/shared/localization/locales/sl.json +50 -50
  114. package/shared/localization/locales/sr-Latn.json +50 -50
  115. package/shared/localization/locales/sr.json +50 -50
  116. package/shared/localization/locales/sv.json +50 -50
  117. package/shared/localization/locales/ta.json +50 -50
  118. package/shared/localization/locales/te.json +50 -50
  119. package/shared/localization/locales/th.json +50 -50
  120. package/shared/localization/locales/tr.json +50 -50
  121. package/shared/localization/locales/uk.json +50 -50
  122. package/shared/localization/locales/vi.json +50 -50
  123. package/shared/localization/locales/zh-HK.json +50 -50
  124. package/shared/localization/locales/zh-TW.json +50 -50
  125. package/shared/localization/locales/zh.json +50 -50
  126. package/shared/test/util-test.js +214 -0
  127. package/shared/util.d.ts +122 -0
  128. package/shared/util.js +332 -0
  129. package/types/artifacts.d.ts +14 -0
  130. package/types/lhr/lhr.d.ts +33 -0
  131. package/report/renderer/util.d.ts +0 -230
@@ -56,6 +56,8 @@ interface Result {
56
56
  };
57
57
  /** An array containing the result of all stack packs. */
58
58
  stackPacks?: Result.StackPack[];
59
+ /** All the origins encountered during this Lighthouse run, and information about what web property (aka "entity") they belong to. Won't be present for snapshot mode. */
60
+ entities?: Result.Entities;
59
61
  /** Screenshot taken of the full page, with node rects referencing audit results. If there was an error with collection, this is null. If disabled via the disableFullPageScreenshot setting, this is undefined. */
60
62
  fullPageScreenshot?: Result.FullPageScreenshot | null;
61
63
  }
@@ -151,6 +153,37 @@ declare module Result {
151
153
  nodes: Record<string, AuditDetails.Rect>;
152
154
  }
153
155
 
156
+ /**
157
+ * Entity classification for the run, for resolving URLs/items to entities in report.
158
+ * The two lookup tables (LUT) below provide space-optimized, O(1) index lookup into entities.list.
159
+ */
160
+ interface Entities {
161
+ /** All entities (1st and 3rd party) discovered during the run */
162
+ list: Array<LhrEntity>;
163
+ /** Name of the first-party entity */
164
+ firstParty?: string;
165
+ /** Entity-name to entity index lookup table */
166
+ entityIndexByName: Record<string, number>;
167
+ /** URL origin to entity index lookup table */
168
+ entityIndexByOrigin: Record<string, number>;
169
+ }
170
+
171
+ /**
172
+ * An entity that's either recognized by third-party-web or made up by Lighthouse.
173
+ */
174
+ interface LhrEntity {
175
+ /** Name of the entity. Maps to third-party-web unique name for recognized entities and a root domain name for the unrecognized. */
176
+ name: string;
177
+ /** Homepage URL for a recognized entity, if available in third-party-web. */
178
+ homepage?: string;
179
+ /** Category name that the entity belongs to, if available. */
180
+ category?: string;
181
+ /** Is this entity the first party? */
182
+ isFirstParty?: boolean;
183
+ /** Is this entity recognized by third-party-web? */
184
+ isUnrecognized?: boolean;
185
+ }
186
+
154
187
  /**
155
188
  * Info about an `LH.IcuMessage` value that was localized to a string when
156
189
  * included in the LHR. Value is either a
@@ -1,230 +0,0 @@
1
- export type I18n<T> = import('./i18n').I18n<T>;
2
- export class Util {
3
- /** @type {I18n<typeof UIStrings>} */
4
- static i18n: I18n<typeof UIStrings>;
5
- static get PASS_THRESHOLD(): number;
6
- static get MS_DISPLAY_VALUE(): string;
7
- /**
8
- * If LHR is older than 10.0 it will not have the `finalDisplayedUrl` property.
9
- * Old LHRs should have the `finalUrl` property which will work fine for the report.
10
- *
11
- * @param {LH.Result} lhr
12
- */
13
- static getFinalDisplayedUrl(lhr: LH.Result): string;
14
- /**
15
- * If LHR is older than 10.0 it will not have the `mainDocumentUrl` property.
16
- * Old LHRs should have the `finalUrl` property which is the same as `mainDocumentUrl`.
17
- *
18
- * @param {LH.Result} lhr
19
- */
20
- static getMainDocumentUrl(lhr: LH.Result): string | undefined;
21
- /**
22
- * Returns a new LHR that's reshaped for slightly better ergonomics within the report rendereer.
23
- * Also, sets up the localized UI strings used within renderer and makes changes to old LHRs to be
24
- * compatible with current renderer.
25
- * The LHR passed in is not mutated.
26
- * TODO(team): we all agree the LHR shape change is technical debt we should fix
27
- * @param {LH.Result} result
28
- * @return {LH.ReportResult}
29
- */
30
- static prepareReportResult(result: LH.Result): LH.ReportResult;
31
- /**
32
- * @param {LH.Result} lhr
33
- * @return {LH.Result.FullPageScreenshot=}
34
- */
35
- static getFullPageScreenshot(lhr: LH.Result): LH.Result.FullPageScreenshot | undefined;
36
- /**
37
- * Used to determine if the "passed" for the purposes of showing up in the "failed" or "passed"
38
- * sections of the report.
39
- *
40
- * @param {{score: (number|null), scoreDisplayMode: string}} audit
41
- * @return {boolean}
42
- */
43
- static showAsPassed(audit: {
44
- score: (number | null);
45
- scoreDisplayMode: string;
46
- }): boolean;
47
- /**
48
- * Convert a score to a rating label.
49
- * TODO: Return `'error'` for `score === null && !scoreDisplayMode`.
50
- *
51
- * @param {number|null} score
52
- * @param {string=} scoreDisplayMode
53
- * @return {string}
54
- */
55
- static calculateRating(score: number | null, scoreDisplayMode?: string | undefined): string;
56
- /**
57
- * Split a string by markdown code spans (enclosed in `backticks`), splitting
58
- * into segments that were enclosed in backticks (marked as `isCode === true`)
59
- * and those that outside the backticks (`isCode === false`).
60
- * @param {string} text
61
- * @return {Array<{isCode: true, text: string}|{isCode: false, text: string}>}
62
- */
63
- static splitMarkdownCodeSpans(text: string): Array<{
64
- isCode: true;
65
- text: string;
66
- } | {
67
- isCode: false;
68
- text: string;
69
- }>;
70
- /**
71
- * Split a string on markdown links (e.g. [some link](https://...)) into
72
- * segments of plain text that weren't part of a link (marked as
73
- * `isLink === false`), and segments with text content and a URL that did make
74
- * up a link (marked as `isLink === true`).
75
- * @param {string} text
76
- * @return {Array<{isLink: true, text: string, linkHref: string}|{isLink: false, text: string}>}
77
- */
78
- static splitMarkdownLink(text: string): Array<{
79
- isLink: true;
80
- text: string;
81
- linkHref: string;
82
- } | {
83
- isLink: false;
84
- text: string;
85
- }>;
86
- /**
87
- * @param {URL} parsedUrl
88
- * @param {{numPathParts?: number, preserveQuery?: boolean, preserveHost?: boolean}=} options
89
- * @return {string}
90
- */
91
- static getURLDisplayName(parsedUrl: URL, options?: {
92
- numPathParts?: number | undefined;
93
- preserveQuery?: boolean | undefined;
94
- preserveHost?: boolean | undefined;
95
- } | undefined): string;
96
- /**
97
- * Split a URL into a file, hostname and origin for easy display.
98
- * @param {string} url
99
- * @return {{file: string, hostname: string, origin: string}}
100
- */
101
- static parseURL(url: string): {
102
- file: string;
103
- hostname: string;
104
- origin: string;
105
- };
106
- /**
107
- * @param {string|URL} value
108
- * @return {!URL}
109
- */
110
- static createOrReturnURL(value: string | URL): URL;
111
- /**
112
- * Gets the tld of a domain
113
- *
114
- * @param {string} hostname
115
- * @return {string} tld
116
- */
117
- static getTld(hostname: string): string;
118
- /**
119
- * Returns a primary domain for provided hostname (e.g. www.example.com -> example.com).
120
- * @param {string|URL} url hostname or URL object
121
- * @return {string}
122
- */
123
- static getRootDomain(url: string | URL): string;
124
- /**
125
- * @param {LH.Result['configSettings']} settings
126
- * @return {!{deviceEmulation: string, screenEmulation?: string, networkThrottling: string, cpuThrottling: string, summary: string}}
127
- */
128
- static getEmulationDescriptions(settings: LH.Result['configSettings']): {
129
- deviceEmulation: string;
130
- screenEmulation?: string | undefined;
131
- networkThrottling: string;
132
- cpuThrottling: string;
133
- summary: string;
134
- };
135
- /**
136
- * Returns only lines that are near a message, or the first few lines if there are
137
- * no line messages.
138
- * @param {LH.Audit.Details.SnippetValue['lines']} lines
139
- * @param {LH.Audit.Details.SnippetValue['lineMessages']} lineMessages
140
- * @param {number} surroundingLineCount Number of lines to include before and after
141
- * the message. If this is e.g. 2 this function might return 5 lines.
142
- */
143
- static filterRelevantLines(lines: LH.Audit.Details.SnippetValue['lines'], lineMessages: LH.Audit.Details.SnippetValue['lineMessages'], surroundingLineCount: number): {
144
- content: string;
145
- lineNumber: number;
146
- truncated?: boolean | undefined;
147
- }[];
148
- /**
149
- * @param {string} categoryId
150
- */
151
- static isPluginCategory(categoryId: string): boolean;
152
- /**
153
- * @param {LH.Result.GatherMode} gatherMode
154
- */
155
- static shouldDisplayAsFraction(gatherMode: LH.Result.GatherMode): boolean;
156
- /**
157
- * @param {LH.ReportResult.Category} category
158
- */
159
- static calculateCategoryFraction(category: LH.ReportResult.Category): {
160
- numPassed: number;
161
- numPassableAudits: number;
162
- numInformative: number;
163
- totalWeight: number;
164
- };
165
- }
166
- export namespace Util {
167
- export const reportJson: LH.ReportResult | null;
168
- /**
169
- * An always-increasing counter for making unique SVG ID suffixes.
170
- */
171
- export function getUniqueSuffix(): number;
172
- export function resetUniqueSuffix(): void;
173
- export { UIStrings };
174
- }
175
- export namespace UIStrings {
176
- const varianceDisclaimer: string;
177
- const calculatorLink: string;
178
- const showRelevantAudits: string;
179
- const opportunityResourceColumnLabel: string;
180
- const opportunitySavingsColumnLabel: string;
181
- const errorMissingAuditInfo: string;
182
- const errorLabel: string;
183
- const warningHeader: string;
184
- const warningAuditsGroupTitle: string;
185
- const passedAuditsGroupTitle: string;
186
- const notApplicableAuditsGroupTitle: string;
187
- const manualAuditsGroupTitle: string;
188
- const toplevelWarningsMessage: string;
189
- const crcInitialNavigation: string;
190
- const crcLongestDurationLabel: string;
191
- const snippetExpandButtonLabel: string;
192
- const snippetCollapseButtonLabel: string;
193
- const lsPerformanceCategoryDescription: string;
194
- const labDataTitle: string;
195
- const thirdPartyResourcesLabel: string;
196
- const viewTreemapLabel: string;
197
- const viewTraceLabel: string;
198
- const viewOriginalTraceLabel: string;
199
- const dropdownPrintSummary: string;
200
- const dropdownPrintExpanded: string;
201
- const dropdownCopyJSON: string;
202
- const dropdownSaveHTML: string;
203
- const dropdownSaveJSON: string;
204
- const dropdownViewer: string;
205
- const dropdownSaveGist: string;
206
- const dropdownDarkTheme: string;
207
- const runtimeSettingsDevice: string;
208
- const runtimeSettingsNetworkThrottling: string;
209
- const runtimeSettingsCPUThrottling: string;
210
- const runtimeSettingsUANetwork: string;
211
- const runtimeSettingsBenchmark: string;
212
- const runtimeSettingsAxeVersion: string;
213
- const runtimeSettingsScreenEmulation: string;
214
- const footerIssue: string;
215
- const runtimeNoEmulation: string;
216
- const runtimeMobileEmulation: string;
217
- const runtimeDesktopEmulation: string;
218
- const runtimeUnknown: string;
219
- const runtimeSingleLoad: string;
220
- const runtimeAnalysisWindow: string;
221
- const runtimeSingleLoadTooltip: string;
222
- const throttlingProvided: string;
223
- const show: string;
224
- const hide: string;
225
- const expandView: string;
226
- const collapseView: string;
227
- const runtimeSlow4g: string;
228
- const runtimeCustom: string;
229
- }
230
- //# sourceMappingURL=util.d.ts.map