lighthouse 8.6.0-dev.20211027 → 8.6.0-dev.20211028

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.
@@ -8,7 +8,7 @@ import {FunctionComponent} from 'preact';
8
8
  import {useEffect, useState} from 'preact/hooks';
9
9
 
10
10
  import {NavigationIcon, SnapshotIcon, TimespanIcon} from './icons';
11
- import {getFilmstripFrames, getScreenDimensions, getScreenshot} from './util';
11
+ import {getFilmstripFrames, getScreenDimensions, getFullPageScreenshot} from './util';
12
12
 
13
13
  const ANIMATION_FRAME_DURATION_MS = 500;
14
14
 
@@ -72,15 +72,15 @@ const FlowStepAnimatedThumbnail: FunctionComponent<{
72
72
  };
73
73
 
74
74
  export const FlowStepThumbnail: FunctionComponent<{
75
- reportResult: LH.ReportResult,
75
+ lhr: LH.Result,
76
76
  width?: number,
77
77
  height?: number,
78
- }> = ({reportResult, width, height}) => {
79
- const screenshot = getScreenshot(reportResult);
80
- const frames = getFilmstripFrames(reportResult);
78
+ }> = ({lhr, width, height}) => {
79
+ const screenshot = getFullPageScreenshot(lhr);
80
+ const frames = getFilmstripFrames(lhr);
81
81
 
82
82
  // Resize the image to fit the viewport aspect ratio.
83
- const dimensions = getScreenDimensions(reportResult);
83
+ const dimensions = getScreenDimensions(lhr);
84
84
  if (width && height === undefined) {
85
85
  height = dimensions.height * width / dimensions.width;
86
86
  } else if (height && width === undefined) {
@@ -92,7 +92,7 @@ export const FlowStepThumbnail: FunctionComponent<{
92
92
  return <></>;
93
93
  }
94
94
 
95
- if (reportResult.gatherMode === 'timespan' && frames && frames.length) {
95
+ if (lhr.gatherMode === 'timespan' && frames && frames.length) {
96
96
  return <FlowStepAnimatedThumbnail frames={frames} width={width} height={height} />;
97
97
  }
98
98
 
@@ -101,7 +101,7 @@ export const FlowStepThumbnail: FunctionComponent<{
101
101
  screenshot &&
102
102
  <img
103
103
  className="FlowStepThumbnail"
104
- src={screenshot}
104
+ src={screenshot.screenshot.data}
105
105
  style={{width, height}}
106
106
  alt="Screenshot of a page tested by Lighthouse"
107
107
  />
@@ -6,7 +6,6 @@
6
6
 
7
7
  import {FunctionComponent} from 'preact';
8
8
 
9
- import {Util} from '../../report/renderer/util';
10
9
  import {FlowStepIcon, FlowStepThumbnail} from './common';
11
10
  import {useLocalizedStrings} from './i18n/i18n';
12
11
  import {getModeDescription, useFlowResult} from './util';
@@ -15,16 +14,16 @@ const SIDE_THUMBNAIL_HEIGHT = 80;
15
14
  const MAIN_THUMBNAIL_HEIGHT = 120;
16
15
 
17
16
  const HeaderThumbnail: FunctionComponent<{
18
- reportResult: LH.ReportResult,
17
+ lhr: LH.Result,
19
18
  position: 'prev'|'next'|'main'
20
19
  }> =
21
- ({reportResult, position}) => {
20
+ ({lhr, position}) => {
22
21
  const height = position === 'main' ? MAIN_THUMBNAIL_HEIGHT : SIDE_THUMBNAIL_HEIGHT;
23
22
  return (
24
23
  <div className={`HeaderThumbnail HeaderThumbnail--${position}`}>
25
- <FlowStepThumbnail reportResult={reportResult} height={height}/>
24
+ <FlowStepThumbnail lhr={lhr} height={height}/>
26
25
  <div className="HeaderThumbnail__icon">
27
- <FlowStepIcon mode={reportResult.gatherMode}/>
26
+ <FlowStepIcon mode={lhr.gatherMode}/>
28
27
  </div>
29
28
  </div>
30
29
  );
@@ -50,7 +49,7 @@ export const Header: FunctionComponent<{currentLhr: LH.FlowResult.LhrRef}> =
50
49
  flowResult.steps[index - 2] && <div className="Header__segment"/>
51
50
  }
52
51
  <div className="Header__prev-thumbnail">
53
- <HeaderThumbnail reportResult={Util.prepareReportResult(prevStep.lhr)} position="prev"/>
52
+ <HeaderThumbnail lhr={prevStep.lhr} position="prev"/>
54
53
  <div className="Header__segment"/>
55
54
  </div>
56
55
  <a
@@ -60,7 +59,7 @@ export const Header: FunctionComponent<{currentLhr: LH.FlowResult.LhrRef}> =
60
59
  </>
61
60
  }
62
61
  <div className="Header__current-thumbnail">
63
- <HeaderThumbnail reportResult={Util.prepareReportResult(step.lhr)} position="main"/>
62
+ <HeaderThumbnail lhr={step.lhr} position="main"/>
64
63
  </div>
65
64
  <div className="Header__current-title">
66
65
  {step.name}
@@ -72,7 +71,7 @@ export const Header: FunctionComponent<{currentLhr: LH.FlowResult.LhrRef}> =
72
71
  nextStep && <>
73
72
  <div className="Header__next-thumbnail">
74
73
  <div className="Header__segment"/>
75
- <HeaderThumbnail reportResult={Util.prepareReportResult(nextStep.lhr)} position="next"/>
74
+ <HeaderThumbnail lhr={nextStep.lhr} position="next"/>
76
75
  </div>
77
76
  <a
78
77
  className="Header__next-title"
@@ -63,7 +63,7 @@ export const SummaryFlowStep: FunctionComponent<{
63
63
  <Separator/>
64
64
  </div>
65
65
  }
66
- <FlowStepThumbnail reportResult={reportResult} width={THUMBNAIL_WIDTH}/>
66
+ <FlowStepThumbnail lhr={lhr} width={THUMBNAIL_WIDTH}/>
67
67
  <FlowSegment mode={lhr.gatherMode}/>
68
68
  <div className="SummaryFlowStep__label">
69
69
  <div className="SummaryFlowStep__mode">{modeDescription}</div>
@@ -35,24 +35,24 @@ export function classNames(...args: Array<string|undefined|Record<string, boolea
35
35
  return classes.join(' ');
36
36
  }
37
37
 
38
- export function getScreenDimensions(reportResult: LH.ReportResult) {
38
+ export function getScreenDimensions(reportResult: LH.Result) {
39
39
  const {width, height} = reportResult.configSettings.screenEmulation;
40
40
  return {width, height};
41
41
  }
42
42
 
43
- export function getScreenshot(reportResult: LH.ReportResult) {
43
+ export function getFullPageScreenshot(reportResult: LH.Result) {
44
44
  const fullPageScreenshotAudit = reportResult.audits['full-page-screenshot'];
45
45
  const fullPageScreenshot =
46
46
  fullPageScreenshotAudit &&
47
47
  fullPageScreenshotAudit.details &&
48
48
  fullPageScreenshotAudit.details.type === 'full-page-screenshot' &&
49
- fullPageScreenshotAudit.details.screenshot.data;
49
+ fullPageScreenshotAudit.details;
50
50
 
51
51
  return fullPageScreenshot || null;
52
52
  }
53
53
 
54
54
  export function getFilmstripFrames(
55
- reportResult: LH.ReportResult
55
+ reportResult: LH.Result
56
56
  ): Array<{data: string}> | undefined {
57
57
  const filmstripAudit = reportResult.audits['screenshot-thumbnails'];
58
58
  if (!filmstripAudit) return undefined;
@@ -7,6 +7,8 @@
7
7
  import {FunctionComponent} from 'preact';
8
8
  import {useLayoutEffect, useRef} from 'preact/hooks';
9
9
 
10
+ import {ElementScreenshotRenderer} from '../../../report/renderer/element-screenshot-renderer';
11
+ import {getFullPageScreenshot} from '../util';
10
12
  import {useReportRenderer} from './report-renderer';
11
13
 
12
14
  /**
@@ -41,6 +43,16 @@ export const Report: FunctionComponent<{currentLhr: LH.FlowResult.LhrRef}> =
41
43
  dom.clearComponentCache();
42
44
  reportRenderer.renderReport(currentLhr.value, ref.current);
43
45
  convertChildAnchors(ref.current, currentLhr.index);
46
+ const fullPageScreenshot = getFullPageScreenshot(currentLhr.value);
47
+ if (fullPageScreenshot) {
48
+ const container = dom.find('.lh-container', ref.current);
49
+ ElementScreenshotRenderer.installOverlayFeature({
50
+ dom,
51
+ reportEl: container,
52
+ overlayContainerEl: container,
53
+ fullPageScreenshot,
54
+ });
55
+ }
44
56
  const topbar = ref.current.querySelector('.lh-topbar');
45
57
  if (topbar) topbar.remove();
46
58
  }
@@ -9,7 +9,7 @@ import {act, render} from '@testing-library/preact';
9
9
 
10
10
  import {FlowStepThumbnail} from '../src/common';
11
11
 
12
- let lhr: LH.ReportResult;
12
+ let lhr: LH.Result;
13
13
 
14
14
  jest.useFakeTimers();
15
15
 
@@ -33,7 +33,7 @@ describe('FlowStepThumbnail', () => {
33
33
  });
34
34
 
35
35
  it('renders a thumbnail', () => {
36
- const root = render(<FlowStepThumbnail reportResult={lhr} width={200} height={200} />);
36
+ const root = render(<FlowStepThumbnail lhr={lhr} width={200} height={200} />);
37
37
 
38
38
  const thumbnail = root.getByAltText(/Screenshot/);
39
39
  expect(thumbnail.style.width).toEqual('200px');
@@ -41,14 +41,14 @@ describe('FlowStepThumbnail', () => {
41
41
  });
42
42
 
43
43
  it('renders nothing without dimensions', () => {
44
- const root = render(<FlowStepThumbnail reportResult={lhr} />);
44
+ const root = render(<FlowStepThumbnail lhr={lhr} />);
45
45
 
46
46
  expect(() => root.getByAltText(/Screenshot/)).toThrow();
47
47
  expect(global.console.warn).toHaveBeenCalled();
48
48
  });
49
49
 
50
50
  it('interpolates height', () => {
51
- const root = render(<FlowStepThumbnail reportResult={lhr} width={200} />);
51
+ const root = render(<FlowStepThumbnail lhr={lhr} width={200} />);
52
52
 
53
53
  const thumbnail = root.getByAltText(/Screenshot/);
54
54
  expect(thumbnail.style.width).toEqual('200px');
@@ -56,7 +56,7 @@ describe('FlowStepThumbnail', () => {
56
56
  });
57
57
 
58
58
  it('interpolates width', () => {
59
- const root = render(<FlowStepThumbnail reportResult={lhr} height={150} />);
59
+ const root = render(<FlowStepThumbnail lhr={lhr} height={150} />);
60
60
 
61
61
  const thumbnail = root.getByAltText(/Screenshot/);
62
62
  expect(thumbnail.style.width).toEqual('100px');
@@ -74,7 +74,7 @@ describe('FlowStepThumbnail', () => {
74
74
  ],
75
75
  },
76
76
  } as any;
77
- const root = render(<FlowStepThumbnail reportResult={lhr} height={150} />);
77
+ const root = render(<FlowStepThumbnail lhr={lhr} height={150} />);
78
78
 
79
79
  const thumbnail = root.getByAltText(/Animated/) as HTMLImageElement;
80
80
  expect(thumbnail.style.width).toEqual('100px');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lighthouse",
3
- "version": "8.6.0-dev.20211027",
3
+ "version": "8.6.0-dev.20211028",
4
4
  "description": "Automated auditing, performance metrics, and best practices for the web.",
5
5
  "main": "./lighthouse-core/index.js",
6
6
  "bin": {
@@ -37,7 +37,7 @@
37
37
  "start": "yarn build-report --standalone && node ./lighthouse-cli/index.js",
38
38
  "jest": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js",
39
39
  "test": "yarn diff:sample-json && yarn lint --quiet && yarn unit && yarn type-check",
40
- "test-bundle": "yarn smoke --runner bundle -j=1 --retries=2 --invert-match forms",
40
+ "test-bundle": "yarn smoke --runner bundle -j=1 --retries=2 a11y dbw",
41
41
  "test-clients": "yarn jest \"$PWD/clients/\" && yarn jest --testMatch=\"**/clients/test/**/*-test-pptr.js\"",
42
42
  "test-viewer": "yarn unit-viewer && yarn jest --testMatch=\"**/viewer/**/*-test-pptr.js\"",
43
43
  "test-treemap": "yarn unit-treemap && yarn jest --testMatch=\"**/treemap/**/*-test-pptr.js\"",
@@ -129,7 +129,6 @@
129
129
  "@types/yargs-parser": "^15.0.0",
130
130
  "@typescript-eslint/eslint-plugin": "^4.30.0",
131
131
  "@typescript-eslint/parser": "^4.30.0",
132
- "@wardpeet/brfs": "2.1.0",
133
132
  "acorn": "^8.5.0",
134
133
  "angular": "^1.7.4",
135
134
  "archiver": "^3.0.0",
package/report/README.md CHANGED
@@ -9,7 +9,7 @@ Example standalone HTML report, delivered by the CLI: [`dbwtest-3.0.3.html`](htt
9
9
  ### Report Renderer components
10
10
 
11
11
  1. [`report/generator/report-generator.js`](https://github.com/GoogleChrome/lighthouse/blob/master/report/generator/report-generator.js) is the entry point for generating the HTML from Node. It compiles together the HTML string with everything required within it.
12
- - It runs natively in Node.js but can run in the browser after a compile step is applied during our bundling pipeline. That compile step uses `brfs`, which takes any `fs.readFileSync()` calls and replaces them with the stringified file content.
12
+ - It runs natively in Node.js but can run in the browser after a compile step is applied during our bundling pipeline. That compile step uses `inline-fs`, which takes any `fs.readFileSync()` calls and replaces them with the stringified file content.
13
13
  1. [`report/renderer`](https://github.com/GoogleChrome/lighthouse/tree/master/report/renderer) are all client-side JS files. They transform an LHR object into a report DOM tree. They are all executed within the browser.
14
14
  1. [`report/assets/standalone-template.html`](https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/report/html/report-template.html) is where the client-side build of the DOM report is typically kicked off ([with these four lines](https://github.com/GoogleChrome/lighthouse/blob/eda3a3e2e271249f261655f9504fd542d6acf0f8/lighthouse-core/report/html/report-template.html#L29-L33)) However, see _Current Uses.._ below for more possibilities.
15
15
 
@@ -4,6 +4,6 @@
4
4
 
5
5
  Lighthouse's report generator is the entry point for creating reports from an **LHR** (Lighthouse Result object). It returns results as HTML, JSON, and CSV.
6
6
 
7
- It runs natively in Node.js but can run in the browser after a compile step is applied during our bundling pipeline. That compile step uses `brfs`, which takes any `fs.readFileSync()` calls and replaces them with the stringified file content.
7
+ It runs natively in Node.js but can run in the browser after a compile step is applied during our bundling pipeline. That compile step uses `inline-fs`, which takes any `fs.readFileSync()` calls and replaces them with the stringified file content.
8
8
 
9
9
  Because it's shared between core and the report, dependencies (both code and types) should be kept minimal.
@@ -17,18 +17,14 @@ const DEFAULT_LOCALE = 'en-US';
17
17
 
18
18
  /**
19
19
  * The locale tags for the localized messages available to Lighthouse on disk.
20
- * When bundled, these will be inlined by brfs.
20
+ * When bundled, these will be inlined by `inline-fs`.
21
21
  * These locales are considered the "canonical" locales. We support other locales which
22
22
  * are simply aliases to one of these. ex: es-AR (alias) -> es-419 (canonical)
23
23
  */
24
- let CANONICAL_LOCALES = ['__availableLocales__'];
25
- // TODO: need brfs in gh-pages-app. For now, above is replaced, see build-i18n.module.js
26
- if (fs.readdirSync) {
27
- CANONICAL_LOCALES = fs.readdirSync(__dirname + '/locales/')
28
- .filter(basename => basename.endsWith('.json') && !basename.endsWith('.ctc.json'))
29
- .map(locale => locale.replace('.json', ''))
30
- .sort();
31
- }
24
+ const CANONICAL_LOCALES = fs.readdirSync(__dirname + '/locales/')
25
+ .filter(basename => basename.endsWith('.json') && !basename.endsWith('.ctc.json'))
26
+ .map(locale => locale.replace('.json', ''))
27
+ .sort();
32
28
 
33
29
  /** @typedef {import('intl-messageformat-parser').Element} MessageElement */
34
30
  /** @typedef {import('intl-messageformat-parser').ArgumentElement} ArgumentElement */