lighthouse 11.6.0-dev.20240304 → 11.6.0-dev.20240305

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.
@@ -7,9 +7,6 @@
7
7
  import {Protocol as Crdp} from 'devtools-protocol/types/protocol.js';
8
8
  import {ProtocolMapping as CrdpMappings} from 'devtools-protocol/types/protocol-mapping.js';
9
9
 
10
- import {NetworkNode as _NetworkNode} from '../core/lib/lantern/network-node.js';
11
- import {CPUNode as _CPUNode} from '../core/lib/lantern/cpu-node.js';
12
- import {Simulator as _Simulator} from '../core/lib/lantern/simulator/simulator.js';
13
10
  import {ExecutionContext} from '../core/gather/driver/execution-context.js';
14
11
  import {NetworkMonitor} from '../core/gather/driver/network-monitor.js';
15
12
  import {Fetcher} from '../core/gather/fetcher.js';
@@ -20,6 +17,7 @@ import Config from './config.js';
20
17
  import Result from './lhr/lhr.js';
21
18
  import Protocol from './protocol.js';
22
19
  import Puppeteer from './puppeteer.js';
20
+ import {Lantern} from '../types/internal/lantern.js';
23
21
 
24
22
  type CrdpEvents = CrdpMappings.Events;
25
23
  type CrdpCommands = CrdpMappings.Commands;
@@ -133,38 +131,13 @@ declare module Gatherer {
133
131
  type AnyGathererInstance = GathererInstanceExpander<Gatherer.DependencyKey>
134
132
 
135
133
  namespace Simulation {
136
- type GraphNode = import('../core/lib/lantern/base-node.js').Node<Artifacts.NetworkRequest>;
137
- type GraphNetworkNode = _NetworkNode<Artifacts.NetworkRequest>;
138
- type GraphCPUNode = _CPUNode;
139
- type Simulator = _Simulator;
140
-
141
- interface MetricCoefficients {
142
- intercept: number;
143
- optimistic: number;
144
- pessimistic: number;
145
- }
146
-
147
- interface Options {
148
- rtt?: number;
149
- throughput?: number;
150
- observedThroughput: number;
151
- maximumConcurrentRequests?: number;
152
- cpuSlowdownMultiplier?: number;
153
- layoutTaskMultiplier?: number;
154
- additionalRttByOrigin?: Map<string, number>;
155
- serverResponseTimeByOrigin?: Map<string, number>;
156
- }
157
-
158
- interface NodeTiming {
159
- startTime: number;
160
- endTime: number;
161
- duration: number;
162
- }
163
-
164
- interface Result {
165
- timeInMs: number;
166
- nodeTimings: Map<GraphNode, NodeTiming>;
167
- }
134
+ type GraphNode = Lantern.Simulation.GraphNode<Artifacts.NetworkRequest>;
135
+ type GraphNetworkNode = Lantern.Simulation.GraphNetworkNode<Artifacts.NetworkRequest>;
136
+ type GraphCPUNode = Lantern.Simulation.GraphCPUNode;
137
+ type Simulator = Lantern.Simulation.Simulator<Artifacts.NetworkRequest>;
138
+ type NodeTiming = Lantern.Simulation.NodeTiming;
139
+ type MetricCoefficients = Lantern.Simulation.MetricCoefficients;
140
+ type Result = Lantern.Simulation.Result<Artifacts.NetworkRequest>;
168
141
  }
169
142
  }
170
143
 
@@ -4,79 +4,121 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import * as LH from '../lh.js'
7
+ import * as LH from '../lh.js';
8
8
 
9
- export type ParsedURL = {
10
- /**
11
- * Equivalent to a `new URL(url).protocol` BUT w/o the trailing colon (:)
12
- */
13
- scheme: string;
14
- /**
15
- * Equivalent to a `new URL(url).hostname`
16
- */
17
- host: string;
18
- securityOrigin: string;
19
- };
20
- export type LightriderStatistics = {
21
- /**
22
- * The difference in networkEndTime between the observed Lighthouse networkEndTime and Lightrider's derived networkEndTime.
23
- */
24
- endTimeDeltaMs: number;
25
- /**
26
- * The time spent making a TCP connection (connect + SSL). Note: this is poorly named.
27
- */
28
- TCPMs: number;
29
- /**
30
- * The time spent requesting a resource from a remote server, we use this to approx RTT. Note: this is poorly names, it really should be "server response time".
31
- */
32
- requestMs: number;
33
- /**
34
- * Time to receive the entire response payload starting the clock on receiving the first fragment (first non-header byte).
35
- */
36
- responseMs: number;
37
- };
38
- export class NetworkRequest<T=any> {
39
- /**
40
- * The canonical network record.
41
- * Users of Lantern must create NetworkRequests matching this interface,
42
- * but can store the source-of-truth for their network model in this `record`
43
- * property. This is then accessible as a read-only property on NetworkNode.
44
- */
45
- record?: T;
9
+ declare namespace Lantern {
10
+ type ParsedURL = {
11
+ /**
12
+ * Equivalent to a `new URL(url).protocol` BUT w/o the trailing colon (:)
13
+ */
14
+ scheme: string;
15
+ /**
16
+ * Equivalent to a `new URL(url).hostname`
17
+ */
18
+ host: string;
19
+ securityOrigin: string;
20
+ };
21
+ type LightriderStatistics = {
22
+ /**
23
+ * The difference in networkEndTime between the observed Lighthouse networkEndTime and Lightrider's derived networkEndTime.
24
+ */
25
+ endTimeDeltaMs: number;
26
+ /**
27
+ * The time spent making a TCP connection (connect + SSL). Note: this is poorly named.
28
+ */
29
+ TCPMs: number;
30
+ /**
31
+ * The time spent requesting a resource from a remote server, we use this to approx RTT. Note: this is poorly names, it really should be "server response time".
32
+ */
33
+ requestMs: number;
34
+ /**
35
+ * Time to receive the entire response payload starting the clock on receiving the first fragment (first non-header byte).
36
+ */
37
+ responseMs: number;
38
+ };
39
+ class NetworkRequest<T = any> {
40
+ /**
41
+ * The canonical network record.
42
+ * Users of Lantern must create NetworkRequests matching this interface,
43
+ * but can store the source-of-truth for their network model in this `record`
44
+ * property. This is then accessible as a read-only property on NetworkNode.
45
+ */
46
+ record?: T;
46
47
 
47
- requestId: string;
48
- connectionId: string;
49
- connectionReused: boolean;
50
- url: string;
51
- protocol: string;
52
- parsedURL: ParsedURL;
53
- /** When the renderer process initially discovers a network request, in milliseconds. */
54
- rendererStartTime: number;
55
- /**
56
- * When the network service is about to handle a request, ie. just before going to the
57
- * HTTP cache or going to the network for DNS/connection setup, in milliseconds.
58
- */
59
- networkRequestTime: number;
60
- /** When the last byte of the response headers is received, in milliseconds. */
61
- responseHeadersEndTime: number;
62
- /** When the last byte of the response body is received, in milliseconds. */
63
- networkEndTime: number;
64
- transferSize: number;
65
- resourceSize: number;
66
- fromDiskCache: boolean;
67
- fromMemoryCache: boolean;
68
- // TODO(15841): remove from lantern.
69
- /** Extra timing information available only when run in Lightrider. */
70
- lrStatistics: LightriderStatistics | undefined;
71
- finished: boolean;
72
- statusCode: number;
73
- /** The network request that this one redirected to */
74
- redirectDestination: NetworkRequest<T> | undefined;
75
- failed: boolean;
76
- initiator: LH.Crdp.Network.Initiator;
77
- timing: LH.Crdp.Network.ResourceTiming | undefined;
78
- resourceType: LH.Crdp.Network.ResourceType | undefined;
79
- priority: LH.Crdp.Network.ResourcePriority;
80
- }
48
+ requestId: string;
49
+ connectionId: string;
50
+ connectionReused: boolean;
51
+ url: string;
52
+ protocol: string;
53
+ parsedURL: ParsedURL;
54
+ documentURL: string;
55
+ /** When the renderer process initially discovers a network request, in milliseconds. */
56
+ rendererStartTime: number;
57
+ /**
58
+ * When the network service is about to handle a request, ie. just before going to the
59
+ * HTTP cache or going to the network for DNS/connection setup, in milliseconds.
60
+ */
61
+ networkRequestTime: number;
62
+ /** When the last byte of the response headers is received, in milliseconds. */
63
+ responseHeadersEndTime: number;
64
+ /** When the last byte of the response body is received, in milliseconds. */
65
+ networkEndTime: number;
66
+ transferSize: number;
67
+ resourceSize: number;
68
+ fromDiskCache: boolean;
69
+ fromMemoryCache: boolean;
70
+ // TODO(15841): remove from lantern.
71
+ /** Extra timing information available only when run in Lightrider. */
72
+ lrStatistics: LightriderStatistics | undefined;
73
+ finished: boolean;
74
+ statusCode: number;
75
+ /** The network request that this one redirected to */
76
+ redirectDestination: NetworkRequest<T> | undefined;
77
+ failed: boolean;
78
+ initiator: LH.Crdp.Network.Initiator;
79
+ initiatorRequest: NetworkRequest<T> | undefined;
80
+ /** The chain of network requests that redirected to this one */
81
+ redirects: NetworkRequest[] | undefined;
82
+ timing: LH.Crdp.Network.ResourceTiming | undefined;
83
+ resourceType: LH.Crdp.Network.ResourceType | undefined;
84
+ mimeType: string;
85
+ priority: LH.Crdp.Network.ResourcePriority;
86
+ frameId: string | undefined;
87
+ sessionTargetType: LH.Protocol.TargetType | undefined;
88
+ }
89
+
90
+ export namespace Simulation {
91
+ type GraphNode<T> = import('../../core/lib/lantern/base-node.js').Node<T>;
92
+ type GraphNetworkNode<T> = import('../../core/lib/lantern/network-node.js').NetworkNode<T>;
93
+ type GraphCPUNode = import('../../core/lib/lantern/cpu-node.js').CPUNode;
94
+ type Simulator<T> = import('../../core/lib/lantern/simulator/simulator.js').Simulator<T>;
95
+
96
+ interface MetricCoefficients {
97
+ intercept: number;
98
+ optimistic: number;
99
+ pessimistic: number;
100
+ }
81
101
 
82
- export {};
102
+ interface Options {
103
+ rtt?: number;
104
+ throughput?: number;
105
+ observedThroughput: number;
106
+ maximumConcurrentRequests?: number;
107
+ cpuSlowdownMultiplier?: number;
108
+ layoutTaskMultiplier?: number;
109
+ additionalRttByOrigin?: Map<string, number>;
110
+ serverResponseTimeByOrigin?: Map<string, number>;
111
+ }
112
+
113
+ interface NodeTiming {
114
+ startTime: number;
115
+ endTime: number;
116
+ duration: number;
117
+ }
118
+
119
+ interface Result<T = any> {
120
+ timeInMs: number;
121
+ nodeTimings: Map<GraphNode<T>, NodeTiming>;
122
+ }
123
+ }
124
+ }