lighthouse 9.5.0-dev.20221020 → 9.5.0-dev.20221022
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.
- package/core/user-flow.js +29 -15
- package/flow-report/src/app.tsx +1 -1
- package/flow-report/src/header.tsx +1 -1
- package/flow-report/src/util.ts +1 -1
- package/flow-report/src/wrappers/report.tsx +1 -1
- package/flow-report/types/flow-report.d.ts +8 -1
- package/package.json +1 -1
- package/report/generator/report-generator.js +1 -1
- package/shared/types/shared.d.ts +2 -2
- package/types/global-lh.d.ts +1 -1
- package/types/lhr/{flow.d.ts → flow-result.d.ts} +3 -7
- package/types/user-flow.d.ts +7 -2
package/core/user-flow.js
CHANGED
|
@@ -11,6 +11,7 @@ import {navigationGather} from './gather/navigation-runner.js';
|
|
|
11
11
|
import {Runner} from './runner.js';
|
|
12
12
|
import {initializeConfig} from './config/config.js';
|
|
13
13
|
import {getFormatted} from '../shared/localization/format.js';
|
|
14
|
+
import {mergeConfigFragment, deepClone} from './config/config-helpers.js';
|
|
14
15
|
import * as i18n from './lib/i18n/i18n.js';
|
|
15
16
|
|
|
16
17
|
/** @typedef {WeakMap<LH.UserFlow.GatherStep, LH.Gatherer.FRGatherResult['runnerOptions']>} GatherStepRunnerOptions */
|
|
@@ -67,30 +68,39 @@ class UserFlow {
|
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
|
-
* @param {LH.UserFlow.StepFlags}
|
|
71
|
+
* @param {LH.UserFlow.StepFlags|undefined} flags
|
|
72
|
+
* @return {LH.UserFlow.StepFlags|undefined}
|
|
73
|
+
*/
|
|
74
|
+
_getNextFlags(flags) {
|
|
75
|
+
const clonedFlowFlags = this._options?.flags && deepClone(this._options?.flags);
|
|
76
|
+
if (!flags) return clonedFlowFlags;
|
|
77
|
+
return mergeConfigFragment(clonedFlowFlags || {}, flags, true);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @param {LH.UserFlow.StepFlags|undefined} flags
|
|
71
82
|
* @return {LH.UserFlow.StepFlags}
|
|
72
83
|
*/
|
|
73
84
|
_getNextNavigationFlags(flags) {
|
|
74
|
-
const
|
|
85
|
+
const nextFlags = this._getNextFlags(flags) || {};
|
|
75
86
|
|
|
76
|
-
if (
|
|
77
|
-
|
|
87
|
+
if (nextFlags.skipAboutBlank === undefined) {
|
|
88
|
+
nextFlags.skipAboutBlank = true;
|
|
78
89
|
}
|
|
79
90
|
|
|
80
91
|
// On repeat navigations, we want to disable storage reset by default (i.e. it's not a cold load).
|
|
81
92
|
const isSubsequentNavigation = this._gatherSteps
|
|
82
93
|
.some(step => step.artifacts.GatherContext.gatherMode === 'navigation');
|
|
83
94
|
if (isSubsequentNavigation) {
|
|
84
|
-
if (
|
|
85
|
-
|
|
95
|
+
if (nextFlags.disableStorageReset === undefined) {
|
|
96
|
+
nextFlags.disableStorageReset = true;
|
|
86
97
|
}
|
|
87
98
|
}
|
|
88
99
|
|
|
89
|
-
return
|
|
100
|
+
return nextFlags;
|
|
90
101
|
}
|
|
91
102
|
|
|
92
103
|
/**
|
|
93
|
-
*
|
|
94
104
|
* @param {LH.Gatherer.FRGatherResult} gatherResult
|
|
95
105
|
* @param {LH.UserFlow.StepFlags} [flags]
|
|
96
106
|
*/
|
|
@@ -111,13 +121,13 @@ class UserFlow {
|
|
|
111
121
|
if (this.currentTimespan) throw new Error('Timespan already in progress');
|
|
112
122
|
if (this.currentNavigation) throw new Error('Navigation already in progress');
|
|
113
123
|
|
|
114
|
-
const
|
|
124
|
+
const nextFlags = this._getNextNavigationFlags(flags);
|
|
115
125
|
const gatherResult = await navigationGather(this._page, requestor, {
|
|
116
126
|
config: this._options?.config,
|
|
117
|
-
flags:
|
|
127
|
+
flags: nextFlags,
|
|
118
128
|
});
|
|
119
129
|
|
|
120
|
-
this._addGatherStep(gatherResult,
|
|
130
|
+
this._addGatherStep(gatherResult, nextFlags);
|
|
121
131
|
}
|
|
122
132
|
|
|
123
133
|
/**
|
|
@@ -179,11 +189,13 @@ class UserFlow {
|
|
|
179
189
|
if (this.currentTimespan) throw new Error('Timespan already in progress');
|
|
180
190
|
if (this.currentNavigation) throw new Error('Navigation already in progress');
|
|
181
191
|
|
|
192
|
+
const nextFlags = this._getNextFlags(flags);
|
|
193
|
+
|
|
182
194
|
const timespan = await startTimespanGather(this._page, {
|
|
183
195
|
config: this._options?.config,
|
|
184
|
-
flags:
|
|
196
|
+
flags: nextFlags,
|
|
185
197
|
});
|
|
186
|
-
this.currentTimespan = {timespan, flags};
|
|
198
|
+
this.currentTimespan = {timespan, flags: nextFlags};
|
|
187
199
|
}
|
|
188
200
|
|
|
189
201
|
async endTimespan() {
|
|
@@ -204,12 +216,14 @@ class UserFlow {
|
|
|
204
216
|
if (this.currentTimespan) throw new Error('Timespan already in progress');
|
|
205
217
|
if (this.currentNavigation) throw new Error('Navigation already in progress');
|
|
206
218
|
|
|
219
|
+
const nextFlags = this._getNextFlags(flags);
|
|
220
|
+
|
|
207
221
|
const gatherResult = await snapshotGather(this._page, {
|
|
208
222
|
config: this._options?.config,
|
|
209
|
-
flags:
|
|
223
|
+
flags: nextFlags,
|
|
210
224
|
});
|
|
211
225
|
|
|
212
|
-
this._addGatherStep(gatherResult,
|
|
226
|
+
this._addGatherStep(gatherResult, nextFlags);
|
|
213
227
|
}
|
|
214
228
|
|
|
215
229
|
/**
|
package/flow-report/src/app.tsx
CHANGED
|
@@ -16,7 +16,7 @@ import {Header} from './header';
|
|
|
16
16
|
import {I18nProvider} from './i18n/i18n';
|
|
17
17
|
import {Styles} from './wrappers/styles';
|
|
18
18
|
|
|
19
|
-
function getAnchorElement(hashState: LH.
|
|
19
|
+
function getAnchorElement(hashState: LH.HashState|null) {
|
|
20
20
|
if (!hashState || !hashState.anchor) return null;
|
|
21
21
|
return document.getElementById(hashState.anchor);
|
|
22
22
|
}
|
|
@@ -29,7 +29,7 @@ const HeaderThumbnail: FunctionComponent<{
|
|
|
29
29
|
);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
export const Header: FunctionComponent<{hashState: LH.
|
|
32
|
+
export const Header: FunctionComponent<{hashState: LH.HashState}> =
|
|
33
33
|
({hashState}) => {
|
|
34
34
|
const flowResult = useFlowResult();
|
|
35
35
|
const {index} = hashState;
|
package/flow-report/src/util.ts
CHANGED
|
@@ -97,7 +97,7 @@ function useHashParams(...params: string[]) {
|
|
|
97
97
|
return paramValues;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
function useHashState(): LH.
|
|
100
|
+
function useHashState(): LH.HashState|null {
|
|
101
101
|
const flowResult = useFlowResult();
|
|
102
102
|
const [indexString, anchor] = useHashParams('index', 'anchor');
|
|
103
103
|
|
|
@@ -29,7 +29,7 @@ function convertAnchor(link: HTMLAnchorElement, index: number) {
|
|
|
29
29
|
link.replaceWith(newLink);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export const Report: FunctionComponent<{hashState: LH.
|
|
32
|
+
export const Report: FunctionComponent<{hashState: LH.HashState}> =
|
|
33
33
|
({hashState}) => {
|
|
34
34
|
const ref = useExternalRenderer<HTMLDivElement>(() => {
|
|
35
35
|
return renderReport(hashState.currentLhr, {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import FlowResult_ from '../../types/lhr/flow';
|
|
7
|
+
import FlowResult_ from '../../types/lhr/flow-result';
|
|
8
8
|
import * as Settings from '../../types/lhr/settings';
|
|
9
9
|
|
|
10
10
|
// Import to augment querySelector/querySelectorAll with stricter type checking.
|
|
@@ -20,11 +20,18 @@ declare global {
|
|
|
20
20
|
// Expose global types in LH namespace.
|
|
21
21
|
module LH {
|
|
22
22
|
export type ConfigSettings = Settings.ConfigSettings;
|
|
23
|
+
|
|
23
24
|
export interface FlowReportOptions {
|
|
24
25
|
getReportHtml?: (flowResult: FlowResult_) => string;
|
|
25
26
|
saveAsGist?: (flowResult: FlowResult_) => void;
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
export interface HashState {
|
|
30
|
+
currentLhr: Result;
|
|
31
|
+
index: number;
|
|
32
|
+
anchor: string|null;
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
export import FlowResult = FlowResult_;
|
|
29
36
|
}
|
|
30
37
|
}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import {reportAssets} from './report-assets.js';
|
|
9
9
|
|
|
10
10
|
/** @typedef {import('../../types/lhr/lhr').default} LHResult */
|
|
11
|
-
/** @typedef {import('../../types/lhr/flow').default} FlowResult */
|
|
11
|
+
/** @typedef {import('../../types/lhr/flow-result').default} FlowResult */
|
|
12
12
|
|
|
13
13
|
class ReportGenerator {
|
|
14
14
|
/**
|
package/shared/types/shared.d.ts
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
import {IcuMessage as IcuMessage_} from '../../types/lhr/i18n';
|
|
8
8
|
import LHResult from '../../types/lhr/lhr';
|
|
9
|
-
import FlowResult_ from '../../types/lhr/flow';
|
|
9
|
+
import FlowResult_ from '../../types/lhr/flow-result';
|
|
10
10
|
|
|
11
11
|
import {Locale as Locale_} from '../../types/lhr/settings';
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
declare global {
|
|
14
14
|
// Expose global types in LH namespace.
|
|
15
15
|
module LH {
|
package/types/global-lh.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import Gatherer_ from './gatherer';
|
|
|
16
16
|
import * as I18n from './lhr/i18n';
|
|
17
17
|
import {LighthouseError as LighthouseError_} from '../core/lib/lh-error.js';
|
|
18
18
|
import LHResult from './lhr/lhr';
|
|
19
|
-
import FlowResult_ from './lhr/flow';
|
|
19
|
+
import FlowResult_ from './lhr/flow-result';
|
|
20
20
|
import Protocol_ from './protocol';
|
|
21
21
|
import * as Settings from './lhr/settings';
|
|
22
22
|
import Treemap_ from './lhr/treemap';
|
|
@@ -8,15 +8,11 @@ import Result from './lhr';
|
|
|
8
8
|
|
|
9
9
|
declare module FlowResult {
|
|
10
10
|
interface Step {
|
|
11
|
+
/** Lighthouse report for this flow step. */
|
|
11
12
|
lhr: Result;
|
|
13
|
+
/** Display name of this flow step. */
|
|
12
14
|
name: string;
|
|
13
15
|
}
|
|
14
|
-
|
|
15
|
-
interface HashState {
|
|
16
|
-
currentLhr: Result;
|
|
17
|
-
index: number;
|
|
18
|
-
anchor: string|null;
|
|
19
|
-
}
|
|
20
16
|
}
|
|
21
17
|
|
|
22
18
|
/**
|
|
@@ -25,7 +21,7 @@ declare module FlowResult {
|
|
|
25
21
|
interface FlowResult {
|
|
26
22
|
/** Ordered list of flow steps, each corresponding to a navigation, timespan, or snapshot. */
|
|
27
23
|
steps: FlowResult.Step[];
|
|
28
|
-
/**
|
|
24
|
+
/** Display name of this user flow. */
|
|
29
25
|
name: string;
|
|
30
26
|
}
|
|
31
27
|
|
package/types/user-flow.d.ts
CHANGED
|
@@ -7,11 +7,16 @@ declare module UserFlow {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export interface Options {
|
|
10
|
-
|
|
10
|
+
/** Config to use for each flow step. */
|
|
11
|
+
config?: LH.Config.Json;
|
|
12
|
+
/** Base flags to use for each flow step. Step specific flags will override these flags. */
|
|
13
|
+
flags?: LH.Flags;
|
|
14
|
+
/** Display name for this user flow. */
|
|
11
15
|
name?: string;
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
export interface StepFlags extends LH.Flags {
|
|
19
|
+
/** Display name for this flow step. */
|
|
15
20
|
name?: string;
|
|
16
21
|
}
|
|
17
22
|
|
|
@@ -21,6 +26,6 @@ declare module UserFlow {
|
|
|
21
26
|
}
|
|
22
27
|
}
|
|
23
28
|
|
|
24
|
-
type UserFlow = typeof UserFlow_
|
|
29
|
+
type UserFlow = InstanceType<typeof UserFlow_>;
|
|
25
30
|
|
|
26
31
|
export default UserFlow;
|