lighthouse 11.7.0-dev.20240406 → 11.7.0-dev.20240408

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 (61) hide show
  1. package/core/computed/metrics/cumulative-layout-shift.js +2 -2
  2. package/core/computed/trace-engine-result.js +1 -1
  3. package/core/config/default-config.js +0 -5
  4. package/core/gather/gatherers/trace-elements.d.ts +0 -10
  5. package/core/gather/gatherers/trace-elements.js +0 -19
  6. package/package.json +2 -2
  7. package/shared/localization/locales/ar-XB.json +0 -18
  8. package/shared/localization/locales/ar.json +0 -18
  9. package/shared/localization/locales/bg.json +0 -18
  10. package/shared/localization/locales/ca.json +0 -18
  11. package/shared/localization/locales/cs.json +0 -18
  12. package/shared/localization/locales/da.json +0 -18
  13. package/shared/localization/locales/de.json +0 -18
  14. package/shared/localization/locales/el.json +0 -18
  15. package/shared/localization/locales/en-GB.json +0 -18
  16. package/shared/localization/locales/en-US.json +0 -18
  17. package/shared/localization/locales/en-XA.json +0 -18
  18. package/shared/localization/locales/en-XL.json +0 -18
  19. package/shared/localization/locales/es-419.json +0 -18
  20. package/shared/localization/locales/es.json +0 -18
  21. package/shared/localization/locales/fi.json +0 -18
  22. package/shared/localization/locales/fil.json +0 -18
  23. package/shared/localization/locales/fr.json +0 -18
  24. package/shared/localization/locales/he.json +0 -18
  25. package/shared/localization/locales/hi.json +0 -18
  26. package/shared/localization/locales/hr.json +0 -18
  27. package/shared/localization/locales/hu.json +0 -18
  28. package/shared/localization/locales/id.json +0 -18
  29. package/shared/localization/locales/it.json +0 -18
  30. package/shared/localization/locales/ja.json +0 -18
  31. package/shared/localization/locales/ko.json +0 -18
  32. package/shared/localization/locales/lt.json +0 -18
  33. package/shared/localization/locales/lv.json +0 -18
  34. package/shared/localization/locales/nl.json +0 -18
  35. package/shared/localization/locales/no.json +0 -18
  36. package/shared/localization/locales/pl.json +0 -18
  37. package/shared/localization/locales/pt-PT.json +0 -18
  38. package/shared/localization/locales/pt.json +0 -18
  39. package/shared/localization/locales/ro.json +0 -18
  40. package/shared/localization/locales/ru.json +0 -18
  41. package/shared/localization/locales/sk.json +0 -18
  42. package/shared/localization/locales/sl.json +0 -18
  43. package/shared/localization/locales/sr-Latn.json +0 -18
  44. package/shared/localization/locales/sr.json +0 -18
  45. package/shared/localization/locales/sv.json +0 -18
  46. package/shared/localization/locales/ta.json +0 -18
  47. package/shared/localization/locales/te.json +0 -18
  48. package/shared/localization/locales/th.json +0 -18
  49. package/shared/localization/locales/tr.json +0 -18
  50. package/shared/localization/locales/uk.json +0 -18
  51. package/shared/localization/locales/vi.json +0 -18
  52. package/shared/localization/locales/zh-HK.json +0 -18
  53. package/shared/localization/locales/zh-TW.json +0 -18
  54. package/shared/localization/locales/zh.json +0 -18
  55. package/types/artifacts.d.ts +1 -13
  56. package/core/audits/layout-shift-elements.d.ts +0 -16
  57. package/core/audits/layout-shift-elements.js +0 -101
  58. package/core/audits/seo/plugins.d.ts +0 -15
  59. package/core/audits/seo/plugins.js +0 -150
  60. package/core/gather/gatherers/seo/embedded-content.d.ts +0 -10
  61. package/core/gather/gatherers/seo/embedded-content.js +0 -63
@@ -1,101 +0,0 @@
1
- /**
2
- * @license Copyright 2020 Google LLC
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
-
6
- import {Audit} from './audit.js';
7
- import * as i18n from '../lib/i18n/i18n.js';
8
- import {CumulativeLayoutShift as CumulativeLayoutShiftComputed} from '../computed/metrics/cumulative-layout-shift.js';
9
- import CumulativeLayoutShift from './metrics/cumulative-layout-shift.js';
10
-
11
- const UIStrings = {
12
- /** Descriptive title of a diagnostic audit that provides the top elements affected by layout shifts. */
13
- title: 'Avoid large layout shifts',
14
- /** Description of a diagnostic audit that provides the top elements affected by layout shifts. "windowing" means the metric value is calculated using the subset of events in a small window of time during the run. "normalization" is a good substitute for "windowing". The last sentence starting with 'Learn' becomes link text to additional documentation. */
15
- description: 'These DOM elements were most affected by layout shifts. Some layout shifts may not be included in the CLS metric value due to [windowing](https://web.dev/articles/cls#what_is_cls). [Learn how to improve CLS](https://web.dev/articles/optimize-cls)',
16
- /** Label for a column in a data table; entries in this column will be the amount that the corresponding element affected by layout shifts. */
17
- columnContribution: 'Layout shift impact',
18
- };
19
-
20
- const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
21
-
22
- class LayoutShiftElements extends Audit {
23
- /**
24
- * @return {LH.Audit.Meta}
25
- */
26
- static get meta() {
27
- return {
28
- id: 'layout-shift-elements',
29
- title: str_(UIStrings.title),
30
- description: str_(UIStrings.description),
31
- scoreDisplayMode: Audit.SCORING_MODES.METRIC_SAVINGS,
32
- guidanceLevel: 2,
33
- requiredArtifacts: ['traces', 'TraceElements'],
34
- };
35
- }
36
-
37
- /**
38
- * @param {LH.Artifacts} artifacts
39
- * @param {LH.Audit.Context} context
40
- * @return {Promise<LH.Audit.Product>}
41
- */
42
- static async audit(artifacts, context) {
43
- const {cumulativeLayoutShift: clsSavings, impactByNodeId} =
44
- await CumulativeLayoutShiftComputed.request(artifacts.traces[Audit.DEFAULT_PASS], context);
45
-
46
- /** @type {Array<{node: LH.Audit.Details.ItemValue, score: number}>} */
47
- const clsElementData = artifacts.TraceElements
48
- .filter(element => element.traceEventType === 'layout-shift-element')
49
- .map(element => ({
50
- node: Audit.makeNodeItem(element.node),
51
- score: impactByNodeId.get(element.nodeId) || 0,
52
- }));
53
-
54
- if (clsElementData.length < impactByNodeId.size) {
55
- const displayedNodeImpact = clsElementData.reduce((sum, {score}) => sum += score, 0);
56
-
57
- // This is not necessarily the same as CLS due to normalization.
58
- const totalNodeImpact = Array.from(impactByNodeId.values())
59
- .reduce((sum, score) => sum + score);
60
-
61
- clsElementData.push({
62
- node: {
63
- type: 'code',
64
- value: str_(i18n.UIStrings.otherResourceType),
65
- },
66
- score: totalNodeImpact - displayedNodeImpact,
67
- });
68
- }
69
-
70
- /** @type {LH.Audit.Details.Table['headings']} */
71
- const headings = [
72
- {key: 'node', valueType: 'node', label: str_(i18n.UIStrings.columnElement)},
73
- {key: 'score', valueType: 'numeric',
74
- granularity: 0.001, label: str_(UIStrings.columnContribution)},
75
- ];
76
-
77
- const details = Audit.makeTableDetails(headings, clsElementData);
78
-
79
- let displayValue;
80
- if (impactByNodeId.size > 0) {
81
- displayValue = str_(i18n.UIStrings.displayValueElementsFound,
82
- {nodeCount: impactByNodeId.size});
83
- }
84
-
85
- const passed = clsSavings <= CumulativeLayoutShift.defaultOptions.p10;
86
-
87
- return {
88
- score: passed ? 1 : 0,
89
- scoreDisplayMode: passed ? Audit.SCORING_MODES.INFORMATIVE : undefined,
90
- metricSavings: {
91
- CLS: clsSavings,
92
- },
93
- notApplicable: details.items.length === 0,
94
- displayValue,
95
- details,
96
- };
97
- }
98
- }
99
-
100
- export default LayoutShiftElements;
101
- export {UIStrings};
@@ -1,15 +0,0 @@
1
- export default Plugins;
2
- declare class Plugins extends Audit {
3
- /**
4
- * @param {LH.Artifacts} artifacts
5
- * @return {LH.Audit.Product}
6
- */
7
- static audit(artifacts: LH.Artifacts): LH.Audit.Product;
8
- }
9
- export namespace UIStrings {
10
- const title: string;
11
- const failureTitle: string;
12
- const description: string;
13
- }
14
- import { Audit } from '../audit.js';
15
- //# sourceMappingURL=plugins.d.ts.map
@@ -1,150 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2018 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- import {Audit} from '../audit.js';
8
- import * as i18n from '../../lib/i18n/i18n.js';
9
-
10
- const JAVA_APPLET_TYPE = 'application/x-java-applet';
11
- const JAVA_BEAN_TYPE = 'application/x-java-bean';
12
- const TYPE_BLOCKLIST = new Set([
13
- 'application/x-shockwave-flash',
14
- // See https://docs.oracle.com/cd/E19683-01/816-0378/using_tags/index.html
15
- JAVA_APPLET_TYPE,
16
- JAVA_BEAN_TYPE,
17
- // See https://msdn.microsoft.com/es-es/library/cc265156(v=vs.95).aspx
18
- 'application/x-silverlight',
19
- 'application/x-silverlight-2',
20
- ]);
21
- const FILE_EXTENSION_BLOCKLIST = new Set([
22
- 'swf',
23
- 'flv',
24
- 'class',
25
- 'xap',
26
- ]);
27
- const SOURCE_PARAMS = new Set([
28
- 'code',
29
- 'movie',
30
- 'source',
31
- 'src',
32
- ]);
33
-
34
- const UIStrings = {
35
- /** Title of a Lighthouse audit that provides detail on the browser plugins used by the page. This descriptive title is shown when there is no plugin content on the page that would restrict search indexing. */
36
- title: 'Document avoids plugins',
37
- /** Descriptive title of a Lighthouse audit that provides detail on the browser plugins used by the page. This title is shown when there is plugin content on the page. */
38
- failureTitle: 'Document uses plugins',
39
- /** Description of a Lighthouse audit that tells the user *why* they need to avoid using browser plugins in their content. This is displayed after a user expands the section to see more. No character length limits. The last sentence starting with 'Learn' becomes link text to additional documentation. */
40
- description: 'Search engines can\'t index plugin content, and ' +
41
- 'many devices restrict plugins or don\'t support them. ' +
42
- '[Learn more about avoiding plugins](https://developer.chrome.com/docs/lighthouse/seo/plugins/).',
43
- };
44
-
45
- const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
46
-
47
- /**
48
- * Verifies if given MIME type matches any known plugin MIME type
49
- * @param {string} type
50
- * @return {boolean}
51
- */
52
- function isPluginType(type) {
53
- type = type.trim().toLowerCase();
54
-
55
- return TYPE_BLOCKLIST.has(type) ||
56
- type.startsWith(JAVA_APPLET_TYPE) || // e.g. "application/x-java-applet;jpi-version=1.4"
57
- type.startsWith(JAVA_BEAN_TYPE);
58
- }
59
-
60
- /**
61
- * Verifies if given url points to a file that has a known plugin extension
62
- * @param {string} url
63
- * @return {boolean}
64
- */
65
- function isPluginURL(url) {
66
- try {
67
- // in order to support relative URLs we need to provied a base URL
68
- const filePath = new URL(url, 'http://example.com').pathname;
69
- const parts = filePath.split('.');
70
-
71
- if (parts.length < 2) {
72
- return false;
73
- }
74
- const part = parts[parts.length - 1];
75
- return FILE_EXTENSION_BLOCKLIST.has(part.trim().toLowerCase());
76
- } catch (e) {
77
- return false;
78
- }
79
- }
80
-
81
- class Plugins extends Audit {
82
- /**
83
- * @return {LH.Audit.Meta}
84
- */
85
- static get meta() {
86
- return {
87
- id: 'plugins',
88
- title: str_(UIStrings.title),
89
- failureTitle: str_(UIStrings.failureTitle),
90
- description: str_(UIStrings.description),
91
- requiredArtifacts: ['EmbeddedContent'],
92
- };
93
- }
94
-
95
- /**
96
- * @param {LH.Artifacts} artifacts
97
- * @return {LH.Audit.Product}
98
- */
99
- static audit(artifacts) {
100
- const plugins = artifacts.EmbeddedContent
101
- .filter(item => {
102
- if (item.tagName === 'APPLET') {
103
- return true;
104
- }
105
-
106
- if (
107
- (item.tagName === 'EMBED' || item.tagName === 'OBJECT') &&
108
- item.type &&
109
- isPluginType(item.type)
110
- ) {
111
- return true;
112
- }
113
-
114
- const embedSrc = item.src || item.code;
115
- if (item.tagName === 'EMBED' && embedSrc && isPluginURL(embedSrc)) {
116
- return true;
117
- }
118
-
119
- if (item.tagName === 'OBJECT' && item.data && isPluginURL(item.data)) {
120
- return true;
121
- }
122
-
123
- const failingParams = item.params.filter(param =>
124
- SOURCE_PARAMS.has(param.name.trim().toLowerCase()) && isPluginURL(param.value)
125
- );
126
-
127
- return failingParams.length > 0;
128
- })
129
- .map(plugin => {
130
- return {
131
- source: Audit.makeNodeItem(plugin.node),
132
- };
133
- });
134
-
135
- /** @type {LH.Audit.Details.Table['headings']} */
136
- const headings = [
137
- {key: 'source', valueType: 'code', label: 'Element source'},
138
- ];
139
-
140
- const details = Audit.makeTableDetails(headings, plugins);
141
-
142
- return {
143
- score: Number(plugins.length === 0),
144
- details,
145
- };
146
- }
147
- }
148
-
149
- export default Plugins;
150
- export {UIStrings};
@@ -1,10 +0,0 @@
1
- export default EmbeddedContent;
2
- declare class EmbeddedContent extends BaseGatherer {
3
- /**
4
- * @param {LH.Gatherer.Context} passContext
5
- * @return {Promise<LH.Artifacts['EmbeddedContent']>}
6
- */
7
- getArtifact(passContext: LH.Gatherer.Context): Promise<LH.Artifacts['EmbeddedContent']>;
8
- }
9
- import BaseGatherer from '../../base-gatherer.js';
10
- //# sourceMappingURL=embedded-content.d.ts.map
@@ -1,63 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2018 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- /* globals getElementsInDocument getNodeDetails */
8
-
9
- import BaseGatherer from '../../base-gatherer.js';
10
- import {pageFunctions} from '../../../lib/page-functions.js';
11
-
12
- /**
13
- * @return {LH.Artifacts.EmbeddedContentInfo[]}
14
- */
15
- function getEmbeddedContent() {
16
- const functions = /** @type {typeof pageFunctions} */ ({
17
- // @ts-expect-error - getElementsInDocument put into scope via stringification
18
- getElementsInDocument,
19
- // @ts-expect-error - getNodeDetails put into scope via stringification
20
- getNodeDetails,
21
- });
22
-
23
- const selector = 'object, embed, applet';
24
- const elements = functions.getElementsInDocument(selector);
25
- return elements
26
- .map(node => ({
27
- tagName: node.tagName,
28
- type: node.getAttribute('type'),
29
- src: node.getAttribute('src'),
30
- data: node.getAttribute('data'),
31
- code: node.getAttribute('code'),
32
- params: Array.from(node.children)
33
- .filter(el => el.tagName === 'PARAM')
34
- .map(el => ({
35
- name: el.getAttribute('name') || '',
36
- value: el.getAttribute('value') || '',
37
- })),
38
- node: functions.getNodeDetails(node),
39
- }));
40
- }
41
-
42
- class EmbeddedContent extends BaseGatherer {
43
- /** @type {LH.Gatherer.GathererMeta} */
44
- meta = {
45
- supportedModes: ['snapshot', 'navigation'],
46
- };
47
-
48
- /**
49
- * @param {LH.Gatherer.Context} passContext
50
- * @return {Promise<LH.Artifacts['EmbeddedContent']>}
51
- */
52
- getArtifact(passContext) {
53
- return passContext.driver.executionContext.evaluate(getEmbeddedContent, {
54
- args: [],
55
- deps: [
56
- pageFunctions.getElementsInDocument,
57
- pageFunctions.getNodeDetails,
58
- ],
59
- });
60
- }
61
- }
62
-
63
- export default EmbeddedContent;