lighthouse 8.6.0-dev.20211102 → 8.6.0-dev.20211103
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/dist/report/flow.js +8 -8
- package/dist/report/standalone.js +40 -34
- package/flow-report/assets/standalone-flow-template.html +3 -2
- package/flow-report/src/icons.tsx +9 -0
- package/flow-report/src/sidebar/sidebar.tsx +18 -5
- package/flow-report/src/wrappers/report-renderer.tsx +1 -0
- package/flow-report/src/wrappers/report.tsx +2 -3
- package/flow-report/standalone-flow.tsx +4 -3
- package/flow-report/test/sidebar/sidebar-test.tsx +43 -1
- package/package.json +1 -1
- package/report/assets/standalone-template.html +2 -3
- package/report/assets/styles.css +1 -1
- package/report/clients/bundle.js +1 -0
- package/report/clients/standalone.js +6 -13
- package/report/renderer/api.js +32 -0
- package/report/renderer/category-renderer.js +1 -1
- package/report/renderer/components.js +26 -26
- package/report/renderer/dom.js +16 -1
- package/report/renderer/drop-down-menu.js +2 -2
- package/report/renderer/element-screenshot-renderer.js +6 -6
- package/report/renderer/features-util.js +1 -1
- package/report/renderer/report-renderer.js +32 -9
- package/report/renderer/report-ui-features.js +34 -30
- package/report/renderer/swap-locale-feature.js +3 -3
- package/report/renderer/topbar-features.js +19 -21
- package/report/test/clients/bundle-test.js +3 -0
- package/report/test/renderer/report-renderer-axe-test.js +5 -2
- package/report/test/renderer/report-renderer-test.js +13 -10
- package/report/test/renderer/report-ui-features-test.js +4 -1
- package/report/test-assets/faux-psi-template.html +2 -7
- package/report/test-assets/faux-psi.js +15 -34
- package/report/types/html-renderer.d.ts +2 -0
- package/report/types/report-renderer.d.ts +23 -0
|
@@ -26,43 +26,25 @@ const lighthouseRenderer = window['report'];
|
|
|
26
26
|
for (const [tabId, lhr] of Object.entries(lhrs)) {
|
|
27
27
|
await distinguishLHR(lhr, tabId);
|
|
28
28
|
|
|
29
|
-
const container = document.querySelector(
|
|
29
|
+
const container = document.querySelector(`section#${tabId}`);
|
|
30
30
|
if (!container) throw new Error('Unexpected DOM. Bailing.');
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const dom = new lighthouseRenderer.DOM(doc);
|
|
46
|
-
return new lighthouseRenderer.ReportRenderer(dom);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const renderer = getRenderer(reportContainer.ownerDocument);
|
|
50
|
-
reportContainer.classList.add('lh-root', 'lh-vars');
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
renderer.renderReport(lhrData, reportContainer);
|
|
54
|
-
// TODO: handle topbar removal better
|
|
55
|
-
// TODO: display warnings if appropriate.
|
|
56
|
-
for (const el of reportContainer.querySelectorAll('.lh-topbar, .lh-warnings')) {
|
|
57
|
-
el.setAttribute('hidden', 'true');
|
|
32
|
+
try {
|
|
33
|
+
const reportRootEl = lighthouseRenderer.renderReport(lhr, {
|
|
34
|
+
omitTopbar: true,
|
|
35
|
+
disableAutoDarkModeAndFireworks: true,
|
|
36
|
+
});
|
|
37
|
+
// TODO: display warnings if appropriate.
|
|
38
|
+
for (const el of reportRootEl.querySelectorAll('.lh-warnings')) {
|
|
39
|
+
el.setAttribute('hidden', 'true');
|
|
40
|
+
}
|
|
41
|
+
container.append(reportRootEl);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.error(e);
|
|
44
|
+
container.textContent = 'Error: LHR failed to render.';
|
|
58
45
|
}
|
|
59
|
-
const features = new lighthouseRenderer.ReportUIFeatures(renderer._dom);
|
|
60
|
-
features.initFeatures(lhrData);
|
|
61
|
-
} catch (e) {
|
|
62
|
-
console.error(e);
|
|
63
|
-
reportContainer.textContent = 'Error: LHR failed to render.';
|
|
64
46
|
}
|
|
65
|
-
}
|
|
47
|
+
})();
|
|
66
48
|
|
|
67
49
|
|
|
68
50
|
/**
|
|
@@ -72,7 +54,6 @@ function renderLHReport(lhrData, reportContainer) {
|
|
|
72
54
|
* @param {string} tabId
|
|
73
55
|
*/
|
|
74
56
|
async function distinguishLHR(lhr, tabId) {
|
|
75
|
-
lhr.categories.performance.title += ` ${tabId}`; // for easier identification
|
|
76
57
|
if (tabId === 'desktop') {
|
|
77
58
|
lhr.categories.performance.score = 0.81;
|
|
78
59
|
}
|
|
@@ -8,6 +8,7 @@ import AuditDetails from '../../types/lhr/audit-details';
|
|
|
8
8
|
import {FormattedIcu as FormattedIcu_, IcuMessage as IcuMessage_} from '../../types/lhr/i18n';
|
|
9
9
|
import LHResult from '../../types/lhr/lhr';
|
|
10
10
|
import ReportResult_ from './report-result';
|
|
11
|
+
import Renderer_ from './report-renderer';
|
|
11
12
|
import * as Settings from '../../types/lhr/settings';
|
|
12
13
|
import Treemap_ from '../../types/lhr/treemap';
|
|
13
14
|
|
|
@@ -16,6 +17,7 @@ declare global {
|
|
|
16
17
|
module LH {
|
|
17
18
|
export import Result = LHResult;
|
|
18
19
|
export import ReportResult = ReportResult_;
|
|
20
|
+
export import Renderer = Renderer_;
|
|
19
21
|
export import Locale = Settings.Locale;
|
|
20
22
|
export type IcuMessage = IcuMessage_;
|
|
21
23
|
export type FormattedIcu<T> = FormattedIcu_<T>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
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
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Result as AuditResult } from "../../types/lhr/audit-result";
|
|
8
|
+
|
|
9
|
+
declare module Renderer {
|
|
10
|
+
function renderReport(lhr: AuditResult, options?: Options): HTMLElement;
|
|
11
|
+
|
|
12
|
+
interface Options {
|
|
13
|
+
/**
|
|
14
|
+
* Don't automatically apply dark-mode to dark based on (prefers-color-scheme: dark). (DevTools and PSI don't want this.)
|
|
15
|
+
* Also, the fireworks easter-egg will want to flip to dark, so this setting will also disable chance of fireworks. */
|
|
16
|
+
disableAutoDarkModeAndFireworks?: boolean;
|
|
17
|
+
|
|
18
|
+
/** Disable the topbar UI component */
|
|
19
|
+
omitTopbar?: boolean;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default Renderer;
|