Skip to content

Commit

Permalink
report: move renderer code to report/ (#12690)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored Jun 25, 2021
1 parent 168ef7e commit dddeb0d
Show file tree
Hide file tree
Showing 113 changed files with 7,065 additions and 7,128 deletions.
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ chromium-webtests
.tmp

# generated files
**/pages/scripts/lighthouse-report.js
*.report.html
*.dom.html
*.devtoolslog.json
Expand Down
2 changes: 1 addition & 1 deletion build/build-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async function browserifyFile(entryPath, distPath) {
// Don't include the stringified report in DevTools - see devtools-report-assets.js
// Don't include in Lightrider - HTML generation isn't supported, so report assets aren't needed.
if (isDevtools(entryPath) || isLightrider(entryPath)) {
bundle.ignore(require.resolve('../lighthouse-core/report/html/html-report-assets.js'));
bundle.ignore(require.resolve('../report/report-assets.js'));
}

// Don't include locales in DevTools.
Expand Down
6 changes: 3 additions & 3 deletions build/build-dt-report-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const assert = require('assert').strict;

const distDir = path.join(__dirname, '..', 'dist', 'dt-report-resources');
const bundleOutFile = `${distDir}/report-generator.js`;
const generatorFilename = `./lighthouse-core/report/report-generator.js`;
const htmlReportAssets = require('../lighthouse-core/report/html/html-report-assets.js');
const generatorFilename = `./report/report-generator.js`;
const htmlReportAssets = require('../report/report-assets.js');

/**
* Used to save cached resources (Runtime.cachedResources).
Expand All @@ -30,7 +30,7 @@ fs.mkdirSync(distDir);

writeFile('report.js', htmlReportAssets.REPORT_JAVASCRIPT);
writeFile('report.css', htmlReportAssets.REPORT_CSS);
writeFile('template.html', htmlReportAssets.REPORT_TEMPLATE);
writeFile('standalone-template.html', htmlReportAssets.REPORT_TEMPLATE);
writeFile('templates.html', htmlReportAssets.REPORT_TEMPLATES);
writeFile('report.d.ts', 'export {}');
writeFile('report-generator.d.ts', 'export {}');
Expand Down
2 changes: 1 addition & 1 deletion build/build-lightrider-bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const distDir = path.join(__dirname, '..', 'dist', 'lightrider');
const sourceDir = __dirname + '/../clients/lightrider';

const bundleOutFile = `${distDir}/report-generator-bundle.js`;
const generatorFilename = `./lighthouse-core/report/report-generator.js`;
const generatorFilename = `./report/report-generator.js`;

const entrySourceName = 'lightrider-entry.js';
const entryDistName = 'lighthouse-lr-bundle.js';
Expand Down
6 changes: 3 additions & 3 deletions build/build-treemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ async function run() {
fs.readFileSync(require.resolve('pako/dist/pako_inflate.js'), 'utf-8'),
/* eslint-enable max-len */
buildStrings(),
{path: '../../lighthouse-core/report/html/renderer/logger.js'},
{path: '../../lighthouse-core/report/html/renderer/i18n.js'},
{path: '../../lighthouse-core/report/html/renderer/text-encoding.js'},
{path: '../../report/renderer/logger.js'},
{path: '../../report/renderer/i18n.js'},
{path: '../../report/renderer/text-encoding.js'},
{path: '../../lighthouse-viewer/app/src/drag-and-drop.js'},
{path: '../../lighthouse-viewer/app/src/github-api.js'},
{path: '../../lighthouse-viewer/app/src/firebase-auth.js'},
Expand Down
4 changes: 2 additions & 2 deletions build/build-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ const fs = require('fs');
const browserify = require('browserify');
const GhPagesApp = require('./gh-pages-app.js');
const {minifyFileTransform} = require('./build-utils.js');
const htmlReportAssets = require('../lighthouse-core/report/html/html-report-assets.js');
const htmlReportAssets = require('../report/report-assets.js');

/**
* Build viewer, optionally deploying to gh-pages if `--deploy` flag was set.
*/
async function run() {
// JS bundle from browserified ReportGenerator.
const generatorFilename = `${__dirname}/../lighthouse-core/report/report-generator.js`;
const generatorFilename = `${__dirname}/../report/report-generator.js`;
const generatorBrowserify = browserify(generatorFilename, {standalone: 'ReportGenerator'})
.transform('@wardpeet/brfs', {
readFileSyncTransform: minifyFileTransform,
Expand Down
4 changes: 2 additions & 2 deletions clients/devtools-report-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* @fileoverview Instead of loading report assets form the filesystem, in Devtools we must load
* them via Runtime.cachedResources. We use this module to shim
* lighthouse-core/report/html/html-report-assets.js in Devtools.
* report/report-assets.js in Devtools.
*/

/* global globalThis */
Expand All @@ -28,7 +28,7 @@ module.exports = {
return cachedResources.get('third_party/lighthouse/report-assets/report.js');
},
get REPORT_TEMPLATE() {
return cachedResources.get('third_party/lighthouse/report-assets/template.html');
return cachedResources.get('third_party/lighthouse/report-assets/standalone-template.html');
},
get REPORT_TEMPLATES() {
return cachedResources.get('third_party/lighthouse/report-assets/templates.html');
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _Some incomplete notes_
3. `defaultPass.devtoolslog.json`: A log of all the [DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/) events. Primary signal about network requests and page state.
* **Audit** - The [audits](../lighthouse-core/audits) are tests for a single feature/optimization/metric. Using the Artifacts as input, an audit evaluates a test and resolves to a numeric score. See [Understanding Results](./understanding-results.md) for details of the LHR (Lighthouse Result object).
* **Computed Artifacts** - [Generated](../lighthouse-core/computed) on-demand from artifacts, these add additional meaning, and are often shared amongst multiple audits.
* **Report** - The report UI, created client-side from the LHR. See [HTML Report Generation Overview](../lighthouse-core/report/html/readme.md) for details.
* **Report** - The report UI, created client-side from the LHR. See [HTML Report Generation Overview](../report/readme.md) for details.

### Audit/Report terminology
* **Category** - Roll-up collection of audits and audit groups into a user-facing section of the report (eg. `Best Practices`). Applies weighting and overall scoring to the section. Examples: PWA, Accessibility, Best Practices.
Expand Down
2 changes: 1 addition & 1 deletion docs/hacking-tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ node generate_report.js > temp.report.html; open temp.report.html
// generate_report.js
'use strict';

const ReportGenerator = require('./lighthouse-core/report/report-generator');
const ReportGenerator = require('./report/report-generator.js');
const results = require('./temp.report.json');
const html = ReportGenerator.generateReportHtml(results);

Expand Down
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
collectCoverageFrom: [
'**/lighthouse-core/**/*.js',
'**/lighthouse-cli/**/*.js',
'**/report/**/*.js',
'**/lighthouse-viewer/**/*.js',
],
coveragePathIgnorePatterns: [
Expand All @@ -22,6 +23,7 @@ module.exports = {
testMatch: [
'**/lighthouse-core/**/*-test.js',
'**/lighthouse-cli/**/*-test.js',
'**/report/**/*-test.js',
'**/lighthouse-core/test/fraggle-rock/**/*-test-pptr.js',
'**/lighthouse-treemap/**/*-test.js',
'**/lighthouse-treemap/**/*-test-pptr.js',
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

const {isUnderTest} = require('../lib/lh-env.js');
const statistics = require('../lib/statistics.js');
const Util = require('../report/html/renderer/util.js');
const Util = require('../../report/renderer/util.js');

const DEFAULT_PASS = 'defaultPass';

Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/computed/resource-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const URL = require('../lib/url-shim.js');
const NetworkRequest = require('../lib/network-request.js');
const MainResource = require('./main-resource.js');
const Budget = require('../config/budget.js');
const Util = require('../report/html/renderer/util.js');
const Util = require('../../report/renderer/util.js');

/** @typedef {{count: number, resourceSize: number, transferSize: number}} ResourceEntry */

Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/lib/i18n/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ function getRendererFormattedStrings(locale) {
const localeMessages = LOCALES[locale];
if (!localeMessages) throw new Error(`Unsupported locale '${locale}'`);

const icuMessageIds = Object.keys(localeMessages).filter(f => f.includes('core/report/html/'));
const icuMessageIds = Object.keys(localeMessages).filter(f => f.startsWith('report/'));
const strings = /** @type {LH.I18NRendererStrings} */ ({});
for (const icuMessageId of icuMessageIds) {
const [filename, varName] = icuMessageId.split(' | ');
Expand Down
Loading

0 comments on commit dddeb0d

Please sign in to comment.