lighthouse 13.6.0-dev.20261109 → 13.6.0-dev.20261110

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.
@@ -45,6 +45,10 @@ export class NetworkMonitor extends NetworkMonitor_base {
45
45
  requestedUrl?: string;
46
46
  mainDocumentUrl?: string;
47
47
  }>;
48
+ /**
49
+ * @return {Array<NetworkRequest>}
50
+ */
51
+ getRawRecords(): Array<NetworkRequest>;
48
52
  /**
49
53
  * @return {Array<NetworkRequest>}
50
54
  */
@@ -120,9 +120,16 @@ class NetworkMonitor extends NetworkMonitorEventEmitter {
120
120
  /**
121
121
  * @return {Array<NetworkRequest>}
122
122
  */
123
- getInflightRequests() {
123
+ getRawRecords() {
124
124
  if (!this._networkRecorder) return [];
125
- return this._networkRecorder.getRawRecords().filter(request => !request.finished);
125
+ return this._networkRecorder.getRawRecords();
126
+ }
127
+
128
+ /**
129
+ * @return {Array<NetworkRequest>}
130
+ */
131
+ getInflightRequests() {
132
+ return this.getRawRecords().filter(request => !request.finished);
126
133
  }
127
134
 
128
135
  /**
@@ -16,6 +16,7 @@ import LinkHeader from 'http-link-header';
16
16
 
17
17
  import BaseGatherer from '../../base-gatherer.js';
18
18
  import RobotsTxt from '../seo/robots-txt.js';
19
+ import * as Lantern from '../../../lib/lantern/lantern.js';
19
20
 
20
21
  /**
21
22
  * Link relations for ARD entry sources. `ai-catalog` is the predecessor relation, which
@@ -161,15 +162,26 @@ class AgentResourceDiscovery extends BaseGatherer {
161
162
  static async getHttpHeaderLinks(context, finalDisplayedUrl) {
162
163
  if (context.gatherMode !== 'navigation') return NO_LINKS;
163
164
 
164
- try {
165
- const mainResourceResponse = await context.driver.fetcher.fetchResource(finalDisplayedUrl);
166
- const linkHeader = mainResourceResponse.headers?.link;
167
- if (!linkHeader) return NO_LINKS;
165
+ const {mainDocumentUrl} = context.baseArtifacts.URL;
166
+ if (!mainDocumentUrl) return NO_LINKS;
168
167
 
169
- const parsed = LinkHeader.parse(linkHeader.replace(/\n/g, ','));
168
+ try {
169
+ // Read the headers from the network monitor rather than a DevtoolsLog dependency, since
170
+ // this gatherer also supports snapshot mode and so cannot depend on DevtoolsLog.
171
+ const records = context.driver.networkMonitor.getRawRecords();
172
+ const mainResource = Lantern.Core.NetworkAnalyzer.findLastDocumentForUrl(
173
+ records,
174
+ mainDocumentUrl
175
+ );
176
+ if (!mainResource) return NO_LINKS;
177
+
178
+ // NetworkRequest already splits multi-value headers into separate entries.
179
+ const refs = mainResource.responseHeaders
180
+ .filter(header => header.name.toLowerCase() === 'link')
181
+ .flatMap(header => LinkHeader.parse(header.value).refs);
170
182
  /** @param {string} rel */
171
183
  const getUri = rel =>
172
- resolveUrl(parsed.refs.find(ref => ref.rel?.toLowerCase() === rel)?.uri, finalDisplayedUrl);
184
+ resolveUrl(refs.find(ref => ref.rel?.toLowerCase() === rel)?.uri, finalDisplayedUrl);
173
185
  return {ard: getUri(REL_ARD), legacy: getUri(REL_LEGACY)};
174
186
  } catch (err) {
175
187
  log.verbose('AgentResourceDiscovery', `Could not read Link header: ${err.message}`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lighthouse",
3
3
  "type": "module",
4
- "version": "13.6.0-dev.20261109",
4
+ "version": "13.6.0-dev.20261110",
5
5
  "description": "Automated auditing, performance metrics, and best practices for the web.",
6
6
  "main": "./core/index.js",
7
7
  "bin": {