lighthouse 9.5.0-dev.20230121 → 9.5.0-dev.20230123
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/audits/bf-cache.js +1 -1
- package/core/audits/screenshot-thumbnails.d.ts +2 -1
- package/core/audits/screenshot-thumbnails.js +14 -9
- package/core/computed/processed-navigation.d.ts +12 -6
- package/core/computed/processed-navigation.js +19 -6
- package/core/util.cjs +42 -9
- package/core/util.d.cts +114 -2
- package/dist/report/bundle.esm.js +199 -261
- package/dist/report/flow.js +23 -23
- package/dist/report/standalone.js +17 -17
- package/flow-report/assets/standalone-flow-template.html +1 -1
- package/flow-report/src/i18n/i18n.d.ts +103 -100
- package/flow-report/src/i18n/i18n.tsx +12 -8
- package/flow-report/src/sidebar/sidebar.tsx +1 -1
- package/flow-report/src/summary/category.tsx +1 -1
- package/flow-report/src/topbar.tsx +4 -28
- package/package.json +2 -2
- package/readme.md +1 -1
- package/report/assets/standalone-template.html +1 -1
- package/report/assets/styles.css +3 -3
- package/report/assets/templates.html +4 -28
- package/report/renderer/category-renderer.js +9 -9
- package/report/renderer/components.js +119 -202
- package/report/renderer/crc-details-renderer.js +4 -3
- package/report/renderer/{i18n.d.ts → i18n-formatter.d.ts} +3 -9
- package/report/renderer/{i18n.js → i18n-formatter.js} +2 -11
- package/report/renderer/performance-category-renderer.js +4 -4
- package/report/renderer/report-renderer.js +14 -18
- package/report/renderer/report-ui-features.js +6 -6
- package/report/renderer/snippet-renderer.js +1 -1
- package/report/renderer/util.d.ts +115 -3
- package/report/renderer/util.js +42 -9
- package/report/test/renderer/category-renderer-test.js +2 -2
- package/report/test/renderer/crc-details-renderer-test.js +2 -2
- package/report/test/renderer/details-renderer-test.js +2 -2
- package/report/test/renderer/dom-test.js +2 -2
- package/report/test/renderer/element-screenshot-renderer-test.js +2 -2
- package/report/test/renderer/{i18n-test.js → i18n-formatter-test.js} +15 -21
- package/report/test/renderer/performance-category-renderer-test.js +2 -2
- package/report/test/renderer/pwa-category-renderer-test.js +2 -2
- package/report/test/renderer/snippet-renderer-test.js +2 -2
- package/report/test/renderer/util-test.js +2 -2
- package/report/test-assets/lhr-3.0.0.json +2332 -0
- package/report/test-assets/lhr-4.3.0.json +4754 -0
- package/report/test-assets/lhr-5.0.0.json +5994 -0
- package/report/test-assets/lhr-6.0.0.json +7222 -0
- package/report/test-assets/lhr-8.5.0.json +8679 -0
- package/shared/localization/locales/en-US.json +1 -1
- package/shared/localization/locales/en-XL.json +1 -1
|
@@ -6,19 +6,13 @@
|
|
|
6
6
|
|
|
7
7
|
import assert from 'assert/strict';
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import {I18n} from '../../renderer/i18n.js';
|
|
11
|
-
|
|
12
|
-
// Require i18n to make sure Intl is polyfilled in Node without full-icu for testing.
|
|
13
|
-
// When Util is run in a browser, Intl will be supplied natively (IE11+).
|
|
14
|
-
// eslint-disable-next-line no-unused-vars
|
|
15
|
-
import '../../../core/lib/i18n/i18n.js';
|
|
9
|
+
import {I18nFormatter} from '../../renderer/i18n-formatter.js';
|
|
16
10
|
|
|
17
11
|
const NBSP = '\xa0';
|
|
18
12
|
|
|
19
|
-
describe('
|
|
13
|
+
describe('i18n formatter', () => {
|
|
20
14
|
it('formats a number', () => {
|
|
21
|
-
const i18n = new
|
|
15
|
+
const i18n = new I18nFormatter('en');
|
|
22
16
|
assert.strictEqual(i18n.formatNumber(10), '10');
|
|
23
17
|
assert.strictEqual(i18n.formatNumber(100.01), '100.01');
|
|
24
18
|
assert.strictEqual(i18n.formatNumber(13000.456), '13,000.456');
|
|
@@ -46,7 +40,7 @@ describe('util helpers', () => {
|
|
|
46
40
|
});
|
|
47
41
|
|
|
48
42
|
it('formats a date', () => {
|
|
49
|
-
const i18n = new
|
|
43
|
+
const i18n = new I18nFormatter('en');
|
|
50
44
|
const timestamp = i18n.formatDateTime('2017-04-28T23:07:51.189Z');
|
|
51
45
|
assert.ok(
|
|
52
46
|
timestamp.includes('Apr 27, 2017') ||
|
|
@@ -56,7 +50,7 @@ describe('util helpers', () => {
|
|
|
56
50
|
});
|
|
57
51
|
|
|
58
52
|
it('formats bytes', () => {
|
|
59
|
-
const i18n = new
|
|
53
|
+
const i18n = new I18nFormatter('en');
|
|
60
54
|
assert.equal(i18n.formatBytesToKiB(100), `0.098${NBSP}KiB`);
|
|
61
55
|
assert.equal(i18n.formatBytesToKiB(100, 0.1), `0.1${NBSP}KiB`);
|
|
62
56
|
assert.equal(i18n.formatBytesToKiB(2000, 0.1), `2.0${NBSP}KiB`);
|
|
@@ -64,7 +58,7 @@ describe('util helpers', () => {
|
|
|
64
58
|
});
|
|
65
59
|
|
|
66
60
|
it('formats bytes with different granularities', () => {
|
|
67
|
-
const i18n = new
|
|
61
|
+
const i18n = new I18nFormatter('en');
|
|
68
62
|
|
|
69
63
|
let granularity = 10;
|
|
70
64
|
assert.strictEqual(i18n.formatBytes(15.0, granularity), `20${NBSP}bytes`);
|
|
@@ -88,7 +82,7 @@ describe('util helpers', () => {
|
|
|
88
82
|
});
|
|
89
83
|
|
|
90
84
|
it('formats bytes with invalid granularity', () => {
|
|
91
|
-
const i18n = new
|
|
85
|
+
const i18n = new I18nFormatter('en');
|
|
92
86
|
const granularity = 0.5;
|
|
93
87
|
const originalWarn = console.warn;
|
|
94
88
|
|
|
@@ -103,7 +97,7 @@ describe('util helpers', () => {
|
|
|
103
97
|
});
|
|
104
98
|
|
|
105
99
|
it('formats kibibytes with different granularities', () => {
|
|
106
|
-
const i18n = new
|
|
100
|
+
const i18n = new I18nFormatter('en');
|
|
107
101
|
|
|
108
102
|
let granularity = 10;
|
|
109
103
|
assert.strictEqual(i18n.formatBytesToKiB(5 * 1024, granularity), `10${NBSP}KiB`);
|
|
@@ -121,7 +115,7 @@ describe('util helpers', () => {
|
|
|
121
115
|
});
|
|
122
116
|
|
|
123
117
|
it('formats ms', () => {
|
|
124
|
-
const i18n = new
|
|
118
|
+
const i18n = new I18nFormatter('en');
|
|
125
119
|
assert.equal(i18n.formatMilliseconds(123, 10), `120${NBSP}ms`);
|
|
126
120
|
assert.equal(i18n.formatMilliseconds(2456.5, 0.1), `2,456.5${NBSP}ms`);
|
|
127
121
|
assert.equal(i18n.formatMilliseconds(0.000001), `0${NBSP}ms`);
|
|
@@ -129,21 +123,21 @@ describe('util helpers', () => {
|
|
|
129
123
|
});
|
|
130
124
|
|
|
131
125
|
it('formats a duration', () => {
|
|
132
|
-
const i18n = new
|
|
126
|
+
const i18n = new I18nFormatter('en');
|
|
133
127
|
assert.equal(i18n.formatDuration(60 * 1000), '1m');
|
|
134
128
|
assert.equal(i18n.formatDuration(60 * 60 * 1000 + 5000), '1h 5s');
|
|
135
129
|
assert.equal(i18n.formatDuration(28 * 60 * 60 * 1000 + 5000), '1d 4h 5s');
|
|
136
130
|
});
|
|
137
131
|
|
|
138
132
|
it('formats a duration based on locale', () => {
|
|
139
|
-
let i18n = new
|
|
133
|
+
let i18n = new I18nFormatter('de');
|
|
140
134
|
assert.equal(i18n.formatDuration(60 * 1000), `1${NBSP}Min.`);
|
|
141
135
|
assert.equal(i18n.formatDuration(60 * 60 * 1000 + 5000), `1${NBSP}Std. 5${NBSP}Sek.`);
|
|
142
136
|
assert.equal(
|
|
143
137
|
i18n.formatDuration(28 * 60 * 60 * 1000 + 5000), `1${NBSP}T 4${NBSP}Std. 5${NBSP}Sek.`);
|
|
144
138
|
|
|
145
139
|
// Yes, this is actually backwards (s h d).
|
|
146
|
-
i18n = new
|
|
140
|
+
i18n = new I18nFormatter('ar');
|
|
147
141
|
/* eslint-disable no-irregular-whitespace */
|
|
148
142
|
assert.equal(i18n.formatDuration(60 * 1000), `١${NBSP}د`);
|
|
149
143
|
assert.equal(i18n.formatDuration(60 * 60 * 1000 + 5000), `١${NBSP}س ٥${NBSP}ث`);
|
|
@@ -155,7 +149,7 @@ describe('util helpers', () => {
|
|
|
155
149
|
// Requires full-icu or Intl polyfill.
|
|
156
150
|
const number = 12346.858558;
|
|
157
151
|
|
|
158
|
-
const i18n = new
|
|
152
|
+
const i18n = new I18nFormatter('de');
|
|
159
153
|
assert.strictEqual(i18n.formatNumber(number), '12.346,859');
|
|
160
154
|
assert.strictEqual(i18n.formatBytesToKiB(number, 0.1), `12,1${NBSP}KiB`);
|
|
161
155
|
assert.strictEqual(i18n.formatMilliseconds(number, 10), `12.350${NBSP}ms`);
|
|
@@ -166,7 +160,7 @@ describe('util helpers', () => {
|
|
|
166
160
|
// Requires full-icu or Intl polyfill.
|
|
167
161
|
const number = 12346.858558;
|
|
168
162
|
|
|
169
|
-
const i18n = new
|
|
163
|
+
const i18n = new I18nFormatter('en-XA');
|
|
170
164
|
assert.strictEqual(i18n.formatNumber(number), '12.346,859');
|
|
171
165
|
assert.strictEqual(i18n.formatBytesToKiB(number, 0.1), `12,1${NBSP}KiB`);
|
|
172
166
|
assert.strictEqual(i18n.formatMilliseconds(number, 100), `12.300${NBSP}ms`);
|
|
@@ -174,7 +168,7 @@ describe('util helpers', () => {
|
|
|
174
168
|
});
|
|
175
169
|
|
|
176
170
|
it('should not crash on unknown locales', () => {
|
|
177
|
-
const i18n = new
|
|
171
|
+
const i18n = new I18nFormatter('unknown-mystery-locale');
|
|
178
172
|
const timestamp = i18n.formatDateTime('2017-04-28T23:07:51.189Z');
|
|
179
173
|
assert.ok(
|
|
180
174
|
timestamp.includes('Apr 27, 2017') ||
|
|
@@ -9,7 +9,7 @@ import assert from 'assert/strict';
|
|
|
9
9
|
import jsdom from 'jsdom';
|
|
10
10
|
|
|
11
11
|
import {Util} from '../../renderer/util.js';
|
|
12
|
-
import {
|
|
12
|
+
import {I18nFormatter} from '../../renderer/i18n-formatter.js';
|
|
13
13
|
import {DOM} from '../../renderer/dom.js';
|
|
14
14
|
import {DetailsRenderer} from '../../renderer/details-renderer.js';
|
|
15
15
|
import {PerformanceCategoryRenderer} from '../../renderer/performance-category-renderer.js';
|
|
@@ -23,7 +23,7 @@ describe('PerfCategoryRenderer', () => {
|
|
|
23
23
|
let sampleResults;
|
|
24
24
|
|
|
25
25
|
before(() => {
|
|
26
|
-
Util.i18n = new
|
|
26
|
+
Util.i18n = new I18nFormatter('en');
|
|
27
27
|
|
|
28
28
|
const {document} = new jsdom.JSDOM().window;
|
|
29
29
|
const dom = new DOM(document);
|
|
@@ -9,7 +9,7 @@ import assert from 'assert/strict';
|
|
|
9
9
|
import jsdom from 'jsdom';
|
|
10
10
|
|
|
11
11
|
import {Util} from '../../renderer/util.js';
|
|
12
|
-
import {
|
|
12
|
+
import {I18nFormatter} from '../../renderer/i18n-formatter.js';
|
|
13
13
|
import {DOM} from '../../renderer/dom.js';
|
|
14
14
|
import {DetailsRenderer} from '../../renderer/details-renderer.js';
|
|
15
15
|
import {PwaCategoryRenderer} from '../../renderer/pwa-category-renderer.js';
|
|
@@ -23,7 +23,7 @@ describe('PwaCategoryRenderer', () => {
|
|
|
23
23
|
let sampleResults;
|
|
24
24
|
|
|
25
25
|
before(() => {
|
|
26
|
-
Util.i18n = new
|
|
26
|
+
Util.i18n = new I18nFormatter('en');
|
|
27
27
|
|
|
28
28
|
const {document} = new jsdom.JSDOM().window;
|
|
29
29
|
const dom = new DOM(document);
|
|
@@ -9,7 +9,7 @@ import assert from 'assert/strict';
|
|
|
9
9
|
import jsdom from 'jsdom';
|
|
10
10
|
|
|
11
11
|
import {Util} from '../../renderer/util.js';
|
|
12
|
-
import {
|
|
12
|
+
import {I18nFormatter} from '../../renderer/i18n-formatter.js';
|
|
13
13
|
import {DOM} from '../../renderer/dom.js';
|
|
14
14
|
import {SnippetRenderer} from '../../renderer/snippet-renderer.js';
|
|
15
15
|
|
|
@@ -55,7 +55,7 @@ describe('DetailsRenderer', () => {
|
|
|
55
55
|
let dom;
|
|
56
56
|
|
|
57
57
|
before(() => {
|
|
58
|
-
Util.i18n = new
|
|
58
|
+
Util.i18n = new I18nFormatter('en');
|
|
59
59
|
const {document} = new jsdom.JSDOM().window;
|
|
60
60
|
dom = new DOM(document);
|
|
61
61
|
});
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
import assert from 'assert/strict';
|
|
8
8
|
|
|
9
9
|
import {Util} from '../../renderer/util.js';
|
|
10
|
-
import {
|
|
10
|
+
import {I18nFormatter} from '../../renderer/i18n-formatter.js';
|
|
11
11
|
import {readJson} from '../../../core/test/test-utils.js';
|
|
12
12
|
|
|
13
13
|
const sampleResult = readJson('../../../core/test/results/sample_v2.json', import.meta);
|
|
14
14
|
|
|
15
15
|
describe('util helpers', () => {
|
|
16
16
|
beforeEach(() => {
|
|
17
|
-
Util.i18n = new
|
|
17
|
+
Util.i18n = new I18nFormatter('en');
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
afterEach(() => {
|