Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report: move renderer code to report/ #12690

Merged
merged 14 commits into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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('../lighthouse-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 = `./lighthouse-report/report-generator.js`;
const htmlReportAssets = require('../lighthouse-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 = `./lighthouse-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: '../../lighthouse-report/renderer/logger.js'},
{path: '../../lighthouse-report/renderer/i18n.js'},
{path: '../../lighthouse-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('../lighthouse-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}/../lighthouse-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.
* lighthouse-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](../lighthouse-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('./lighthouse-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',
'**/lighthouse-report/**/*.js',
'**/lighthouse-viewer/**/*.js',
],
coveragePathIgnorePatterns: [
Expand All @@ -22,6 +23,7 @@ module.exports = {
testMatch: [
'**/lighthouse-core/**/*-test.js',
'**/lighthouse-cli/**/*-test.js',
'**/lighthouse-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('../../lighthouse-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('../../lighthouse-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('lighthouse-report/'));
const strings = /** @type {LH.I18NRendererStrings} */ ({});
for (const icuMessageId of icuMessageIds) {
const [filename, varName] = icuMessageId.split(' | ');
Expand Down
138 changes: 0 additions & 138 deletions lighthouse-core/lib/i18n/locales/ar-XB.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading