lighthouse 12.8.2-dev.20251006 → 12.8.2-dev.20251007

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 (70) hide show
  1. package/core/audits/insights/dom-size-insight.js +5 -1
  2. package/core/audits/insights/insight-audit.d.ts +4 -2
  3. package/core/audits/insights/insight-audit.js +22 -3
  4. package/core/audits/predictive-perf.js +2 -2
  5. package/core/audits/redirects.js +0 -1
  6. package/core/audits/seo/crawlable-anchors.js +2 -3
  7. package/core/computed/metrics/lcp-breakdown.d.ts +10 -5
  8. package/core/computed/metrics/lcp-breakdown.js +50 -23
  9. package/core/computed/metrics/time-to-first-byte.js +33 -10
  10. package/core/computed/metrics/timing-summary.js +3 -2
  11. package/core/gather/gatherers/anchor-elements.js +8 -24
  12. package/core/gather/gatherers/inspector-issues.js +1 -28
  13. package/core/gather/gatherers/trace-elements.d.ts +0 -9
  14. package/core/gather/gatherers/trace-elements.js +0 -36
  15. package/core/lib/network-request.d.ts +0 -7
  16. package/core/lib/network-request.js +0 -16
  17. package/package.json +2 -3
  18. package/shared/localization/locales/ar-XB.json +20 -11
  19. package/shared/localization/locales/ar.json +20 -11
  20. package/shared/localization/locales/bg.json +9 -0
  21. package/shared/localization/locales/ca.json +9 -0
  22. package/shared/localization/locales/cs.json +9 -0
  23. package/shared/localization/locales/da.json +9 -0
  24. package/shared/localization/locales/de.json +9 -0
  25. package/shared/localization/locales/el.json +9 -0
  26. package/shared/localization/locales/en-GB.json +9 -0
  27. package/shared/localization/locales/en-US.json +18 -18
  28. package/shared/localization/locales/en-XL.json +18 -18
  29. package/shared/localization/locales/es-419.json +9 -0
  30. package/shared/localization/locales/es.json +9 -0
  31. package/shared/localization/locales/fi.json +9 -0
  32. package/shared/localization/locales/fil.json +9 -0
  33. package/shared/localization/locales/fr.json +9 -0
  34. package/shared/localization/locales/he.json +31 -22
  35. package/shared/localization/locales/hi.json +9 -0
  36. package/shared/localization/locales/hr.json +9 -0
  37. package/shared/localization/locales/hu.json +9 -0
  38. package/shared/localization/locales/id.json +9 -0
  39. package/shared/localization/locales/it.json +9 -0
  40. package/shared/localization/locales/ja.json +9 -0
  41. package/shared/localization/locales/ko.json +10 -1
  42. package/shared/localization/locales/lt.json +9 -0
  43. package/shared/localization/locales/lv.json +10 -1
  44. package/shared/localization/locales/nl.json +9 -0
  45. package/shared/localization/locales/no.json +9 -0
  46. package/shared/localization/locales/pl.json +9 -0
  47. package/shared/localization/locales/pt-PT.json +9 -0
  48. package/shared/localization/locales/pt.json +9 -0
  49. package/shared/localization/locales/ro.json +10 -1
  50. package/shared/localization/locales/ru.json +9 -0
  51. package/shared/localization/locales/sk.json +9 -0
  52. package/shared/localization/locales/sl.json +9 -0
  53. package/shared/localization/locales/sr-Latn.json +9 -0
  54. package/shared/localization/locales/sr.json +9 -0
  55. package/shared/localization/locales/sv.json +9 -0
  56. package/shared/localization/locales/ta.json +9 -0
  57. package/shared/localization/locales/te.json +10 -1
  58. package/shared/localization/locales/th.json +9 -0
  59. package/shared/localization/locales/tr.json +9 -0
  60. package/shared/localization/locales/uk.json +9 -0
  61. package/shared/localization/locales/vi.json +9 -0
  62. package/shared/localization/locales/zh-HK.json +9 -0
  63. package/shared/localization/locales/zh-TW.json +10 -1
  64. package/shared/localization/locales/zh.json +9 -0
  65. package/types/artifacts.d.ts +4 -6
  66. package/core/computed/critical-request-chains.d.ts +0 -42
  67. package/core/computed/critical-request-chains.js +0 -143
  68. package/core/computed/viewport-meta.d.ts +0 -37
  69. package/core/computed/viewport-meta.js +0 -71
  70. package/types/internal/metaviewport-parser.d.ts +0 -13
@@ -1,143 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2016 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- import * as Lantern from '../lib/lantern/lantern.js';
8
- import {makeComputedArtifact} from './computed-artifact.js';
9
- import {NetworkRequest} from '../lib/network-request.js';
10
- import {MainResource} from './main-resource.js';
11
- import {PageDependencyGraph} from './page-dependency-graph.js';
12
-
13
- class CriticalRequestChains {
14
- /**
15
- * For now, we use network priorities as a proxy for "render-blocking"/critical-ness.
16
- * It's imperfect, but there is not a higher-fidelity signal available yet.
17
- * @see https://docs.google.com/document/d/1bCDuq9H1ih9iNjgzyAL0gpwNFiEP4TZS-YLRp_RuMlc
18
- * @param {Lantern.Types.NetworkRequest} request
19
- * @param {Lantern.Types.NetworkRequest} mainResource
20
- * @return {boolean}
21
- */
22
- static isCritical(request, mainResource) {
23
- if (!mainResource) {
24
- throw new Error('mainResource not provided');
25
- }
26
-
27
- // The main resource is always critical.
28
- if (request.requestId === mainResource.requestId) return true;
29
-
30
- // Treat any preloaded resource as non-critical
31
- if (request.isLinkPreload) {
32
- return false;
33
- }
34
-
35
- // Whenever a request is a redirect, we don't know if it's critical until we resolve the final
36
- // destination. At that point we can assign all the properties (priority, resourceType) of the
37
- // final request back to the redirect(s) that led to it.
38
- // See https://github.com/GoogleChrome/lighthouse/pull/6704
39
- while (request.redirectDestination) {
40
- request = request.redirectDestination;
41
- }
42
-
43
- // Iframes are considered High Priority but they are not render blocking
44
- const isIframe = request.resourceType === NetworkRequest.TYPES.Document &&
45
- request.frameId !== mainResource.frameId;
46
- // XHRs are fetched at High priority, but we exclude them, as they are unlikely to be critical
47
- // Images are also non-critical.
48
- // Treat any missed images, primarily favicons, as non-critical resources
49
- /** @type {Array<LH.Crdp.Network.ResourceType>} */
50
- const nonCriticalResourceTypes = [
51
- NetworkRequest.TYPES.Image,
52
- NetworkRequest.TYPES.XHR,
53
- NetworkRequest.TYPES.Fetch,
54
- NetworkRequest.TYPES.EventSource,
55
- ];
56
- if (nonCriticalResourceTypes.includes(request.resourceType || 'Other') ||
57
- isIframe ||
58
- request.mimeType && request.mimeType.startsWith('image/')) {
59
- return false;
60
- }
61
-
62
- // Requests that have no initiatorRequest are typically ambiguous late-load assets.
63
- // Even on the off chance they were important, we don't have any parent to display for them.
64
- if (!request.initiatorRequest) return false;
65
-
66
- return ['VeryHigh', 'High', 'Medium'].includes(request.priority);
67
- }
68
-
69
- /**
70
- * Create a tree of critical requests.
71
- * @param {LH.Artifacts.NetworkRequest} mainResource
72
- * @param {LH.Gatherer.Simulation.GraphNode} graph
73
- * @return {LH.Artifacts.CriticalRequestNode}
74
- */
75
- static extractChainsFromGraph(mainResource, graph) {
76
- /** @type {LH.Artifacts.CriticalRequestNode} */
77
- const rootNode = {};
78
-
79
- /**
80
- * @param {LH.Artifacts.NetworkRequest[]} path
81
- */
82
- function addChain(path) {
83
- let currentNode = rootNode;
84
-
85
- for (const record of path) {
86
- if (!currentNode[record.requestId]) {
87
- currentNode[record.requestId] = {
88
- request: record,
89
- children: {},
90
- };
91
- }
92
-
93
- currentNode = currentNode[record.requestId].children;
94
- }
95
- }
96
-
97
- // By default `traverse` will discover nodes in BFS-order regardless of dependencies, but
98
- // here we need traversal in a topological sort order. We'll visit a node only when its
99
- // dependencies have been met.
100
- const seenNodes = new Set();
101
- /** @param {LH.Gatherer.Simulation.GraphNode} node */
102
- function getNextNodes(node) {
103
- return node.getDependents().filter(n => n.getDependencies().every(d => seenNodes.has(d)));
104
- }
105
-
106
- graph.traverse((node, traversalPath) => {
107
- seenNodes.add(node);
108
- if (node.type !== 'network') return;
109
- if (!CriticalRequestChains.isCritical(node.request, mainResource)) return;
110
-
111
- const networkPath = traversalPath
112
- .filter(n => n.type === 'network')
113
- .reverse()
114
- .map(node => node.rawRequest);
115
-
116
- // Ignore if some ancestor is not a critical request.
117
- if (networkPath.some(r => !CriticalRequestChains.isCritical(r, mainResource))) return;
118
-
119
- // Ignore non-network things (like data urls).
120
- if (NetworkRequest.isNonNetworkRequest(node.request)) return;
121
-
122
- addChain(networkPath);
123
- }, getNextNodes);
124
-
125
- return rootNode;
126
- }
127
-
128
- /**
129
- * @param {{URL: LH.Artifacts['URL'], SourceMaps: LH.Artifacts['SourceMaps'], devtoolsLog: LH.DevtoolsLog, trace: LH.Trace, settings: LH.Audit.Context['settings']}} data
130
- * @param {LH.Artifacts.ComputedContext} context
131
- * @return {Promise<LH.Artifacts.CriticalRequestNode>}
132
- */
133
- static async compute_(data, context) {
134
- const mainResource = await MainResource.request(data, context);
135
- const graph = await PageDependencyGraph.request({...data, fromTrace: false}, context);
136
-
137
- return CriticalRequestChains.extractChainsFromGraph(mainResource, graph);
138
- }
139
- }
140
-
141
- const CriticalRequestChainsComputed = makeComputedArtifact(CriticalRequestChains,
142
- ['URL', 'SourceMaps', 'devtoolsLog', 'trace', 'settings']);
143
- export {CriticalRequestChainsComputed as CriticalRequestChains};
@@ -1,37 +0,0 @@
1
- export { ViewportMetaComputed as ViewportMeta };
2
- export type ViewportMetaResult = {
3
- /**
4
- * Whether the page has any viewport tag.
5
- */
6
- hasViewportTag: boolean;
7
- /**
8
- * Whether the viewport tag is optimized for mobile screens.
9
- */
10
- isMobileOptimized: boolean;
11
- /**
12
- * Warnings if the parser encountered invalid content in the viewport tag.
13
- */
14
- parserWarnings: Array<string>;
15
- /**
16
- * The `content` attribute value, if a viewport was defined.
17
- */
18
- rawContentString: string | undefined;
19
- };
20
- declare const ViewportMetaComputed: typeof ViewportMeta & {
21
- request: (dependencies: {
22
- name?: string;
23
- content?: string;
24
- property?: string;
25
- httpEquiv?: string;
26
- charset?: string;
27
- node: import("../index.js").Artifacts.NodeDetails;
28
- }[], context: LH.Artifacts.ComputedContext) => Promise<ViewportMetaResult>;
29
- };
30
- declare class ViewportMeta {
31
- /**
32
- * @param {LH.GathererArtifacts['MetaElements']} MetaElements
33
- * @return {Promise<ViewportMetaResult>}
34
- */
35
- static compute_(MetaElements: LH.GathererArtifacts["MetaElements"]): Promise<ViewportMetaResult>;
36
- }
37
- //# sourceMappingURL=viewport-meta.d.ts.map
@@ -1,71 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2019 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- import Parser from 'metaviewport-parser';
8
-
9
- import {makeComputedArtifact} from './computed-artifact.js';
10
-
11
- class ViewportMeta {
12
- /**
13
- * @param {LH.GathererArtifacts['MetaElements']} MetaElements
14
- * @return {Promise<ViewportMetaResult>}
15
- */
16
- static async compute_(MetaElements) {
17
- const viewportMeta = MetaElements.find(meta => meta.name === 'viewport');
18
-
19
- if (!viewportMeta) {
20
- return {
21
- hasViewportTag: false,
22
- isMobileOptimized: false,
23
- parserWarnings: [],
24
- rawContentString: undefined,
25
- };
26
- }
27
-
28
- const warnings = [];
29
- const rawContentString = viewportMeta.content || '';
30
- const parsedProps = Parser.parseMetaViewPortContent(rawContentString);
31
-
32
- if (Object.keys(parsedProps.unknownProperties).length) {
33
- warnings.push(`Invalid properties found: ${JSON.stringify(parsedProps.unknownProperties)}`);
34
- }
35
- if (Object.keys(parsedProps.invalidValues).length) {
36
- warnings.push(`Invalid values found: ${JSON.stringify(parsedProps.invalidValues)}`);
37
- }
38
-
39
- const viewportProps = parsedProps.validProperties;
40
- const initialScale = Number(viewportProps['initial-scale']);
41
-
42
- if (!isNaN(initialScale) && initialScale < 1) {
43
- return {
44
- hasViewportTag: true,
45
- isMobileOptimized: false,
46
- parserWarnings: warnings,
47
- rawContentString,
48
- };
49
- }
50
-
51
- const isMobileOptimized = Boolean(viewportProps.width || initialScale);
52
-
53
- return {
54
- hasViewportTag: true,
55
- isMobileOptimized,
56
- parserWarnings: warnings,
57
- rawContentString,
58
- };
59
- }
60
- }
61
-
62
- const ViewportMetaComputed = makeComputedArtifact(ViewportMeta, null);
63
- export {ViewportMetaComputed as ViewportMeta};
64
-
65
- /**
66
- * @typedef {object} ViewportMetaResult
67
- * @property {boolean} hasViewportTag Whether the page has any viewport tag.
68
- * @property {boolean} isMobileOptimized Whether the viewport tag is optimized for mobile screens.
69
- * @property {Array<string>} parserWarnings Warnings if the parser encountered invalid content in the viewport tag.
70
- * @property {string|undefined} rawContentString The `content` attribute value, if a viewport was defined.
71
- */
@@ -1,13 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2018 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- declare module 'metaviewport-parser' {
8
- export function parseMetaViewPortContent(S: string): {
9
- validProperties: {[p: string]: number | string},
10
- unknownProperties: {[p: string]: number | string},
11
- invalidValues: {[p: string]: number | string};
12
- };
13
- }