lighthouse 8.5.1 → 8.6.0-dev.20211016
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/changelog.md +5490 -0
- package/dist/report/flow.js +35 -12
- package/dist/report/standalone.js +20 -21
- package/flow-report/.eslintrc.cjs +49 -0
- package/flow-report/assets/styles.css +272 -9
- package/flow-report/jest.config.js +1 -1
- package/flow-report/package.json +4 -0
- package/flow-report/src/app.tsx +31 -9
- package/flow-report/src/common.tsx +86 -7
- package/flow-report/src/header.tsx +88 -0
- package/flow-report/src/help-dialog.tsx +120 -0
- package/flow-report/src/i18n/i18n.tsx +52 -0
- package/flow-report/src/i18n/localized-strings.js +11 -0
- package/flow-report/src/i18n/ui-strings.js +134 -0
- package/flow-report/src/icons.tsx +20 -3
- package/flow-report/src/sidebar/sidebar.tsx +11 -16
- package/flow-report/src/summary/category.tsx +39 -24
- package/flow-report/src/summary/summary.tsx +35 -32
- package/flow-report/src/topbar.tsx +54 -4
- package/flow-report/src/util.ts +26 -1
- package/flow-report/src/wrappers/report-renderer.tsx +1 -1
- package/flow-report/src/wrappers/report.tsx +6 -21
- package/flow-report/test/app-test.tsx +17 -13
- package/flow-report/test/common-test.tsx +89 -0
- package/flow-report/test/header-test.tsx +55 -0
- package/flow-report/test/sample-flow.ts +17 -0
- package/flow-report/test/setup/env-setup.ts +1 -0
- package/flow-report/test/sidebar/flow-test.tsx +6 -12
- package/flow-report/test/sidebar/sidebar-test.tsx +7 -13
- package/flow-report/test/summary/category-test.tsx +83 -34
- package/flow-report/test/summary/summary-test.tsx +12 -18
- package/flow-report/test/topbar-test.tsx +68 -0
- package/flow-report/test/util-test.tsx +1 -12
- package/flow-report/tsconfig.json +2 -0
- package/flow-report/types/flow-report.d.ts +2 -1
- package/jest.config.js +1 -15
- package/lighthouse-cli/bin.js +5 -0
- package/lighthouse-cli/cli-flags.js +10 -3
- package/lighthouse-cli/commands/commands.js +1 -0
- package/lighthouse-cli/commands/list-locales.js +16 -0
- package/lighthouse-cli/run.js +2 -2
- package/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js +0 -0
- package/lighthouse-cli/test/smokehouse/report-assert.js +20 -4
- package/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +2 -1
- package/lighthouse-core/audits/byte-efficiency/unused-javascript.js +1 -1
- package/lighthouse-core/audits/seo/crawlable-anchors.js +10 -12
- package/lighthouse-core/computed/js-bundles.js +1 -2
- package/lighthouse-core/computed/unused-javascript-summary.js +3 -3
- package/lighthouse-core/config/config-helpers.js +1 -0
- package/lighthouse-core/config/config.js +2 -2
- package/lighthouse-core/config/default-config.js +5 -0
- package/lighthouse-core/fraggle-rock/api.js +10 -0
- package/lighthouse-core/fraggle-rock/config/filters.js +22 -3
- package/lighthouse-core/fraggle-rock/gather/driver.js +4 -0
- package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +2 -2
- package/lighthouse-core/fraggle-rock/user-flow.js +35 -6
- package/lighthouse-core/gather/driver/navigation.js +5 -0
- package/lighthouse-core/gather/driver/prepare.js +14 -0
- package/lighthouse-core/gather/driver/storage.js +5 -0
- package/lighthouse-core/gather/gather-runner.js +2 -2
- package/lighthouse-core/gather/gatherers/dobetterweb/response-compression.js +5 -1
- package/lighthouse-core/gather/gatherers/full-page-screenshot.js +30 -24
- package/lighthouse-core/lib/cdt/Platform.js +55 -0
- package/lighthouse-core/lib/cdt/SDK.js +3 -123
- package/lighthouse-core/lib/cdt/generated/SourceMap.js +148 -312
- package/lighthouse-core/lib/csp-evaluator.js +2 -1
- package/lighthouse-core/lib/i18n/README.md +6 -6
- package/lighthouse-core/lib/i18n/i18n.js +26 -348
- package/lighthouse-core/lib/page-functions.js +4 -4
- package/lighthouse-core/lib/stack-packs.js +1 -13
- package/lighthouse-core/runner.js +6 -6
- package/lighthouse-core/scripts/manual-chrome-launcher.js +4 -1
- package/lighthouse-core/scripts/package.json +4 -0
- package/lighthouse-core/util-commonjs.js +20 -4
- package/package.json +19 -16
- package/readme.md +1 -1
- package/report/assets/standalone-template.html +0 -1
- package/report/assets/styles.css +16 -41
- package/report/assets/templates.html +42 -4
- package/report/clients/psi.js +1 -0
- package/report/clients/standalone.js +1 -2
- package/report/generator/file-namer.js +17 -8
- package/report/generator/report-generator.js +0 -1
- package/report/renderer/category-renderer.js +4 -16
- package/report/renderer/components.js +107 -71
- package/report/renderer/dom.js +19 -0
- package/report/renderer/logger.js +35 -2
- package/report/renderer/performance-category-renderer.js +23 -21
- package/report/renderer/pwa-category-renderer.js +1 -2
- package/report/renderer/report-renderer.js +21 -0
- package/report/renderer/report-ui-features.js +7 -19
- package/report/renderer/swap-locale-feature.js +82 -0
- package/report/renderer/util.js +20 -4
- package/report/test/clients/psi-test.js +0 -4
- package/report/test/generator/file-namer-test.js +2 -2
- package/report/test/renderer/category-renderer-test.js +1 -1
- package/report/test/renderer/performance-category-renderer-test.js +12 -0
- package/report/test/renderer/report-renderer-axe-test.js +86 -0
- package/report/test/renderer/report-renderer-test.js +0 -55
- package/report/test/renderer/util-test.js +68 -8
- package/report/test-assets/faux-psi-template.html +0 -1
- package/report/tsconfig.json +2 -1
- package/report/types/html-renderer.d.ts +2 -1
- package/root.js +18 -0
- package/shared/localization/format.js +455 -0
- package/{lighthouse-core/lib/cdt/Common.js → shared/localization/i18n-module.js} +3 -8
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/ar-XB.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/ar.json +141 -6
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/bg.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/ca.json +140 -5
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/cs.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/da.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/de.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/el.json +141 -6
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/en-GB.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/en-US.json +129 -0
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/en-XA.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/en-XL.json +129 -0
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/es-419.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/es.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/fi.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/fil.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/fr.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/he.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/hi.json +142 -7
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/hr.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/hu.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/id.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/it.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/ja.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/ko.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/lt.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/lv.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/nl.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/no.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/pl.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/pt-PT.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/pt.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/ro.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/ru.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/sk.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/sl.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/sr-Latn.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/sr.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/sv.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/ta.json +146 -11
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/te.json +179 -44
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/th.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/tr.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/uk.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/vi.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/zh-HK.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/zh-TW.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales/zh.json +139 -4
- package/{lighthouse-core/lib/i18n → shared/localization}/locales.js +8 -1
- package/shared/localization/swap-flow-locale.js +20 -0
- package/{lighthouse-core/lib/i18n → shared/localization}/swap-locale.js +9 -7
- package/shared/test/localization/format-test.js +421 -0
- package/shared/test/localization/locales-test.js +47 -0
- package/shared/test/localization/swap-locale-test.js +140 -0
- package/shared/tsconfig.json +22 -0
- package/{lighthouse-core/lib → shared}/type-verifiers.js +0 -0
- package/shared/types/shared.d.ts +24 -0
- package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +5 -3
- package/third-party/chromium-synchronization/installability-errors-test.js +2 -1
- package/tsconfig-all.json +1 -0
- package/tsconfig-base.json +1 -1
- package/tsconfig.json +2 -3
- package/types/config.d.ts +1 -0
- package/types/es-main.d.ts +18 -0
- package/types/externs.d.ts +2 -0
- package/types/lhr/flow.d.ts +7 -0
- package/types/lhr/i18n.d.ts +0 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// generated by yarn build-cdt-lib
|
|
3
|
-
const
|
|
3
|
+
const Platform = require('../Platform.js');
|
|
4
4
|
"use strict";
|
|
5
5
|
/*
|
|
6
6
|
* Copyright (C) 2012 Google Inc. All rights reserved.
|
|
@@ -32,100 +32,32 @@ const Common = require('../Common.js')
|
|
|
32
32
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
33
33
|
*/
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @return {string}
|
|
47
|
-
*/
|
|
48
|
-
url() {
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* @return {!Array<string>}
|
|
52
|
-
*/
|
|
53
|
-
sourceURLs() {
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* @param {string} sourceURL
|
|
57
|
-
* @return {?string}
|
|
58
|
-
*/
|
|
59
|
-
embeddedContentByURL(sourceURL) {
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* @param {number} lineNumber in compiled resource
|
|
63
|
-
* @param {number} columnNumber in compiled resource
|
|
64
|
-
* @return {?SourceMapEntry}
|
|
65
|
-
*/
|
|
66
|
-
findEntry(lineNumber, columnNumber) {
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* @param {string} sourceURL
|
|
70
|
-
* @param {number} lineNumber
|
|
71
|
-
* @param {number} columnNumber
|
|
72
|
-
* @return {?SourceMapEntry}
|
|
73
|
-
*/
|
|
74
|
-
sourceLineMapping(sourceURL, lineNumber, columnNumber) {
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* @return {!Array<!SourceMapEntry>}
|
|
78
|
-
*/
|
|
79
|
-
mappings() {
|
|
80
|
-
}
|
|
81
|
-
dispose() {
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* @unrestricted
|
|
87
|
-
*/
|
|
35
|
+
exports.TextSourceMap = exports.SourceMapEntry = exports.Offset = exports.Section = exports.SourceMapV3 = void 0;
|
|
36
|
+
;
|
|
37
|
+
;
|
|
38
|
+
;
|
|
39
|
+
;
|
|
40
|
+
;
|
|
41
|
+
;
|
|
42
|
+
;
|
|
43
|
+
;
|
|
44
|
+
;
|
|
88
45
|
class SourceMapV3 {
|
|
89
46
|
constructor() {
|
|
90
|
-
/** @type {number} */ this.version;
|
|
91
|
-
/** @type {string|undefined} */ this.file;
|
|
92
|
-
/** @type {!Array.<string>} */ this.sources;
|
|
93
|
-
/** @type {!Array.<!SourceMapV3.Section>|undefined} */ this.sections;
|
|
94
|
-
/** @type {string} */ this.mappings;
|
|
95
|
-
/** @type {string|undefined} */ this.sourceRoot;
|
|
96
|
-
/** @type {!Array.<string>|undefined} */ this.names;
|
|
97
47
|
}
|
|
98
48
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
*/
|
|
102
|
-
SourceMapV3.Section = class {
|
|
49
|
+
exports.SourceMapV3 = SourceMapV3;
|
|
50
|
+
class Section {
|
|
103
51
|
constructor() {
|
|
104
|
-
/** @type {!SourceMapV3} */ this.map;
|
|
105
|
-
/** @type {!SourceMapV3.Offset} */ this.offset;
|
|
106
52
|
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
*/
|
|
111
|
-
SourceMapV3.Offset = class {
|
|
53
|
+
}
|
|
54
|
+
exports.Section = Section;
|
|
55
|
+
class Offset {
|
|
112
56
|
constructor() {
|
|
113
|
-
/** @type {number} */ this.line;
|
|
114
|
-
/** @type {number} */ this.column;
|
|
115
57
|
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
* @unrestricted
|
|
119
|
-
*/
|
|
58
|
+
}
|
|
59
|
+
exports.Offset = Offset;
|
|
120
60
|
class SourceMapEntry {
|
|
121
|
-
/**
|
|
122
|
-
* @param {number} lineNumber
|
|
123
|
-
* @param {number} columnNumber
|
|
124
|
-
* @param {string=} sourceURL
|
|
125
|
-
* @param {number=} sourceLineNumber
|
|
126
|
-
* @param {number=} sourceColumnNumber
|
|
127
|
-
* @param {string=} name
|
|
128
|
-
*/
|
|
129
61
|
constructor(lineNumber, columnNumber, sourceURL, sourceLineNumber, sourceColumnNumber, name) {
|
|
130
62
|
this.lineNumber = lineNumber;
|
|
131
63
|
this.columnNumber = columnNumber;
|
|
@@ -134,11 +66,6 @@ class SourceMapEntry {
|
|
|
134
66
|
this.sourceColumnNumber = sourceColumnNumber;
|
|
135
67
|
this.name = name;
|
|
136
68
|
}
|
|
137
|
-
/**
|
|
138
|
-
* @param {!SourceMapEntry} entry1
|
|
139
|
-
* @param {!SourceMapEntry} entry2
|
|
140
|
-
* @return {number}
|
|
141
|
-
*/
|
|
142
69
|
static compare(entry1, entry2) {
|
|
143
70
|
if (entry1.lineNumber !== entry2.lineNumber) {
|
|
144
71
|
return entry1.lineNumber - entry2.lineNumber;
|
|
@@ -146,99 +73,59 @@ class SourceMapEntry {
|
|
|
146
73
|
return entry1.columnNumber - entry2.columnNumber;
|
|
147
74
|
}
|
|
148
75
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
76
|
+
exports.SourceMapEntry = SourceMapEntry;
|
|
77
|
+
const base64Digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
78
|
+
const base64Map = new Map();
|
|
79
|
+
for (let i = 0; i < base64Digits.length; ++i) {
|
|
80
|
+
base64Map.set(base64Digits.charAt(i), i);
|
|
81
|
+
}
|
|
82
|
+
const sourceMapToSourceList = new WeakMap();
|
|
156
83
|
class TextSourceMap {
|
|
157
84
|
/**
|
|
158
85
|
* Implements Source Map V3 model. See https://github.com/google/closure-compiler/wiki/Source-Maps
|
|
159
86
|
* for format description.
|
|
160
|
-
* @param {string} compiledURL
|
|
161
|
-
* @param {string} sourceMappingURL
|
|
162
|
-
* @param {!SourceMapV3} payload
|
|
163
87
|
*/
|
|
164
|
-
constructor(compiledURL, sourceMappingURL, payload) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
this.
|
|
173
|
-
|
|
174
|
-
this._sourceMappingURL = sourceMappingURL;
|
|
175
|
-
this._baseURL = sourceMappingURL.startsWith('data:') ? compiledURL : sourceMappingURL;
|
|
176
|
-
/** @type {?Array<!SourceMapEntry>} */
|
|
177
|
-
this._mappings = null;
|
|
178
|
-
/** @type {!Map<string, !TextSourceMap.SourceInfo>} */
|
|
179
|
-
this._sourceInfos = new Map();
|
|
180
|
-
if (this._json.sections) {
|
|
181
|
-
const sectionWithURL = !!this._json.sections.find(section => !!section.url);
|
|
88
|
+
constructor(compiledURL, sourceMappingURL, payload, initiator) {
|
|
89
|
+
this.initiator = initiator;
|
|
90
|
+
this.json = payload;
|
|
91
|
+
this.compiledURLInternal = compiledURL;
|
|
92
|
+
this.sourceMappingURL = sourceMappingURL;
|
|
93
|
+
this.baseURL = sourceMappingURL.startsWith('data:') ? compiledURL : sourceMappingURL;
|
|
94
|
+
this.mappingsInternal = null;
|
|
95
|
+
this.sourceInfos = new Map();
|
|
96
|
+
if (this.json.sections) {
|
|
97
|
+
const sectionWithURL = Boolean(this.json.sections.find(section => Boolean(section.url)));
|
|
182
98
|
if (sectionWithURL) {
|
|
183
|
-
|
|
99
|
+
console.warn(`SourceMap "${sourceMappingURL}" contains unsupported "URL" field in one of its sections.`);
|
|
184
100
|
}
|
|
185
101
|
}
|
|
186
|
-
this.
|
|
102
|
+
this.eachSection(this.parseSources.bind(this));
|
|
187
103
|
}
|
|
188
|
-
/**
|
|
189
|
-
* @override
|
|
190
|
-
* @return {string}
|
|
191
|
-
*/
|
|
192
104
|
compiledURL() {
|
|
193
|
-
return this.
|
|
105
|
+
return this.compiledURLInternal;
|
|
194
106
|
}
|
|
195
|
-
/**
|
|
196
|
-
* @override
|
|
197
|
-
* @return {string}
|
|
198
|
-
*/
|
|
199
107
|
url() {
|
|
200
|
-
return this.
|
|
108
|
+
return this.sourceMappingURL;
|
|
201
109
|
}
|
|
202
|
-
/**
|
|
203
|
-
* @override
|
|
204
|
-
* @return {!Array.<string>}
|
|
205
|
-
*/
|
|
206
110
|
sourceURLs() {
|
|
207
|
-
return this.
|
|
111
|
+
return [...this.sourceInfos.keys()];
|
|
208
112
|
}
|
|
209
|
-
/**
|
|
210
|
-
* @override
|
|
211
|
-
* @param {string} sourceURL
|
|
212
|
-
* @return {?string}
|
|
213
|
-
*/
|
|
214
113
|
embeddedContentByURL(sourceURL) {
|
|
215
|
-
|
|
114
|
+
const entry = this.sourceInfos.get(sourceURL);
|
|
115
|
+
if (!entry) {
|
|
216
116
|
return null;
|
|
217
117
|
}
|
|
218
|
-
return
|
|
118
|
+
return entry.content;
|
|
219
119
|
}
|
|
220
|
-
/**
|
|
221
|
-
* @override
|
|
222
|
-
* @param {number} lineNumber in compiled resource
|
|
223
|
-
* @param {number} columnNumber in compiled resource
|
|
224
|
-
* @return {?SourceMapEntry}
|
|
225
|
-
*/
|
|
226
120
|
findEntry(lineNumber, columnNumber) {
|
|
227
121
|
const mappings = this.mappings();
|
|
228
|
-
const index =
|
|
122
|
+
const index = Platform.ArrayUtilities.upperBound(mappings, undefined, (unused, entry) => lineNumber - entry.lineNumber || columnNumber - entry.columnNumber);
|
|
229
123
|
return index ? mappings[index - 1] : null;
|
|
230
124
|
}
|
|
231
|
-
/**
|
|
232
|
-
* @override
|
|
233
|
-
* @param {string} sourceURL
|
|
234
|
-
* @param {number} lineNumber
|
|
235
|
-
* @param {number} columnNumber
|
|
236
|
-
* @return {?SourceMapEntry}
|
|
237
|
-
*/
|
|
238
125
|
sourceLineMapping(sourceURL, lineNumber, columnNumber) {
|
|
239
|
-
const mappings = this.
|
|
240
|
-
const first =
|
|
241
|
-
const last =
|
|
126
|
+
const mappings = this.reversedMappings(sourceURL);
|
|
127
|
+
const first = Platform.ArrayUtilities.lowerBound(mappings, lineNumber, lineComparator);
|
|
128
|
+
const last = Platform.ArrayUtilities.upperBound(mappings, lineNumber, lineComparator);
|
|
242
129
|
if (first >= mappings.length || mappings[first].sourceLineNumber !== lineNumber) {
|
|
243
130
|
return null;
|
|
244
131
|
}
|
|
@@ -246,26 +133,15 @@ class TextSourceMap {
|
|
|
246
133
|
if (!columnMappings.length) {
|
|
247
134
|
return null;
|
|
248
135
|
}
|
|
249
|
-
const index =
|
|
136
|
+
const index = Platform.ArrayUtilities.lowerBound(columnMappings, columnNumber, (columnNumber, mapping) => columnNumber - mapping.sourceColumnNumber);
|
|
250
137
|
return index >= columnMappings.length ? columnMappings[columnMappings.length - 1] : columnMappings[index];
|
|
251
|
-
/**
|
|
252
|
-
* @param {number} lineNumber
|
|
253
|
-
* @param {!SourceMapEntry} mapping
|
|
254
|
-
* @return {number}
|
|
255
|
-
*/
|
|
256
138
|
function lineComparator(lineNumber, mapping) {
|
|
257
139
|
return lineNumber - mapping.sourceLineNumber;
|
|
258
140
|
}
|
|
259
141
|
}
|
|
260
|
-
/**
|
|
261
|
-
* @param {string} sourceURL
|
|
262
|
-
* @param {number} lineNumber
|
|
263
|
-
* @param {number} columnNumber
|
|
264
|
-
* @return {!Array<!SourceMapEntry>}
|
|
265
|
-
*/
|
|
266
142
|
findReverseEntries(sourceURL, lineNumber, columnNumber) {
|
|
267
|
-
const mappings = this.
|
|
268
|
-
const endIndex =
|
|
143
|
+
const mappings = this.reversedMappings(sourceURL);
|
|
144
|
+
const endIndex = Platform.ArrayUtilities.upperBound(mappings, undefined, (unused, entry) => lineNumber - entry.sourceLineNumber || columnNumber - entry.sourceColumnNumber);
|
|
269
145
|
let startIndex = endIndex;
|
|
270
146
|
while (startIndex > 0 && mappings[startIndex - 1].sourceLineNumber === mappings[endIndex - 1].sourceLineNumber &&
|
|
271
147
|
mappings[startIndex - 1].sourceColumnNumber === mappings[endIndex - 1].sourceColumnNumber) {
|
|
@@ -273,37 +149,25 @@ class TextSourceMap {
|
|
|
273
149
|
}
|
|
274
150
|
return mappings.slice(startIndex, endIndex);
|
|
275
151
|
}
|
|
276
|
-
/**
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
this._mappings = [];
|
|
283
|
-
this._eachSection(this._parseMap.bind(this));
|
|
284
|
-
this._json = null;
|
|
152
|
+
/** @return {Array<{lineNumber: number, columnNumber: number, sourceURL?: string, sourceLineNumber, sourceColumnNumber: number, name?: string, lastColumnNumber?: number}>} */
|
|
153
|
+
mappings() {
|
|
154
|
+
if (this.mappingsInternal === null) {
|
|
155
|
+
this.mappingsInternal = [];
|
|
156
|
+
this.eachSection(this.parseMap.bind(this));
|
|
157
|
+
this.json = null;
|
|
285
158
|
}
|
|
286
|
-
return /** @type {!Array<!SourceMapEntry>} */
|
|
159
|
+
return /** @type {!Array<!SourceMapEntry>} */ this.mappingsInternal;
|
|
287
160
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
*/
|
|
292
|
-
_reversedMappings(sourceURL) {
|
|
293
|
-
if (!this._sourceInfos.has(sourceURL)) {
|
|
161
|
+
reversedMappings(sourceURL) {
|
|
162
|
+
const info = this.sourceInfos.get(sourceURL);
|
|
163
|
+
if (!info) {
|
|
294
164
|
return [];
|
|
295
165
|
}
|
|
296
166
|
const mappings = this.mappings();
|
|
297
|
-
const info = this._sourceInfos.get(sourceURL);
|
|
298
167
|
if (info.reverseMappings === null) {
|
|
299
168
|
info.reverseMappings = mappings.filter(mapping => mapping.sourceURL === sourceURL).sort(sourceMappingComparator);
|
|
300
169
|
}
|
|
301
170
|
return info.reverseMappings;
|
|
302
|
-
/**
|
|
303
|
-
* @param {!SourceMapEntry} a
|
|
304
|
-
* @param {!SourceMapEntry} b
|
|
305
|
-
* @return {number}
|
|
306
|
-
*/
|
|
307
171
|
function sourceMappingComparator(a, b) {
|
|
308
172
|
if (a.sourceLineNumber !== b.sourceLineNumber) {
|
|
309
173
|
return a.sourceLineNumber - b.sourceLineNumber;
|
|
@@ -317,22 +181,19 @@ class TextSourceMap {
|
|
|
317
181
|
return a.columnNumber - b.columnNumber;
|
|
318
182
|
}
|
|
319
183
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
if (!this.
|
|
325
|
-
callback(this.
|
|
184
|
+
eachSection(callback) {
|
|
185
|
+
if (!this.json) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (!this.json.sections) {
|
|
189
|
+
callback(this.json, 0, 0);
|
|
326
190
|
return;
|
|
327
191
|
}
|
|
328
|
-
for (const section of this.
|
|
192
|
+
for (const section of this.json.sections) {
|
|
329
193
|
callback(section.map, section.offset.line, section.offset.column);
|
|
330
194
|
}
|
|
331
195
|
}
|
|
332
|
-
|
|
333
|
-
* @param {!SourceMapV3} sourceMap
|
|
334
|
-
*/
|
|
335
|
-
_parseSources(sourceMap) {
|
|
196
|
+
parseSources(sourceMap) {
|
|
336
197
|
const sourcesList = [];
|
|
337
198
|
let sourceRoot = sourceMap.sourceRoot || '';
|
|
338
199
|
if (sourceRoot && !sourceRoot.endsWith('/')) {
|
|
@@ -342,27 +203,28 @@ class TextSourceMap {
|
|
|
342
203
|
const href = sourceRoot + sourceMap.sources[i];
|
|
343
204
|
let url = '' || href;
|
|
344
205
|
const source = sourceMap.sourcesContent && sourceMap.sourcesContent[i];
|
|
345
|
-
if (url === this.
|
|
206
|
+
if (url === this.compiledURLInternal && source) {
|
|
346
207
|
}
|
|
347
|
-
this.
|
|
208
|
+
this.sourceInfos.set(url, new TextSourceMap.SourceInfo(source || null, null));
|
|
348
209
|
sourcesList.push(url);
|
|
349
210
|
}
|
|
350
|
-
sourceMap
|
|
211
|
+
sourceMapToSourceList.set(sourceMap, sourcesList);
|
|
351
212
|
}
|
|
352
|
-
|
|
353
|
-
* @param {!SourceMapV3} map
|
|
354
|
-
* @param {number} lineNumber
|
|
355
|
-
* @param {number} columnNumber
|
|
356
|
-
*/
|
|
357
|
-
_parseMap(map, lineNumber, columnNumber) {
|
|
213
|
+
parseMap(map, lineNumber, columnNumber) {
|
|
358
214
|
let sourceIndex = 0;
|
|
359
215
|
let sourceLineNumber = 0;
|
|
360
216
|
let sourceColumnNumber = 0;
|
|
361
217
|
let nameIndex = 0;
|
|
362
|
-
|
|
218
|
+
// TODO(crbug.com/1011811): refactor away map.
|
|
219
|
+
// `sources` can be undefined if it wasn't previously
|
|
220
|
+
// processed and added to the list. However, that
|
|
221
|
+
// is not WAI and we should make sure that we can
|
|
222
|
+
// only reach this point when we are certain
|
|
223
|
+
// we have the list available.
|
|
224
|
+
const sources = sourceMapToSourceList.get(map);
|
|
363
225
|
const names = map.names || [];
|
|
364
226
|
const stringCharIterator = new TextSourceMap.StringCharIterator(map.mappings);
|
|
365
|
-
let sourceURL = sources[sourceIndex];
|
|
227
|
+
let sourceURL = sources && sources[sourceIndex];
|
|
366
228
|
while (true) {
|
|
367
229
|
if (stringCharIterator.peek() === ',') {
|
|
368
230
|
stringCharIterator.next();
|
|
@@ -377,134 +239,108 @@ class TextSourceMap {
|
|
|
377
239
|
break;
|
|
378
240
|
}
|
|
379
241
|
}
|
|
380
|
-
columnNumber += this.
|
|
381
|
-
if (!stringCharIterator.hasNext() || this.
|
|
382
|
-
this.
|
|
242
|
+
columnNumber += this.decodeVLQ(stringCharIterator);
|
|
243
|
+
if (!stringCharIterator.hasNext() || this.isSeparator(stringCharIterator.peek())) {
|
|
244
|
+
this.mappings().push(new SourceMapEntry(lineNumber, columnNumber));
|
|
383
245
|
continue;
|
|
384
246
|
}
|
|
385
|
-
const sourceIndexDelta = this.
|
|
247
|
+
const sourceIndexDelta = this.decodeVLQ(stringCharIterator);
|
|
386
248
|
if (sourceIndexDelta) {
|
|
387
249
|
sourceIndex += sourceIndexDelta;
|
|
388
|
-
|
|
250
|
+
if (sources) {
|
|
251
|
+
sourceURL = sources[sourceIndex];
|
|
252
|
+
}
|
|
389
253
|
}
|
|
390
|
-
sourceLineNumber += this.
|
|
391
|
-
sourceColumnNumber += this.
|
|
392
|
-
if (!stringCharIterator.hasNext() || this.
|
|
393
|
-
this.
|
|
254
|
+
sourceLineNumber += this.decodeVLQ(stringCharIterator);
|
|
255
|
+
sourceColumnNumber += this.decodeVLQ(stringCharIterator);
|
|
256
|
+
if (!stringCharIterator.hasNext() || this.isSeparator(stringCharIterator.peek())) {
|
|
257
|
+
this.mappings().push(new SourceMapEntry(lineNumber, columnNumber, sourceURL, sourceLineNumber, sourceColumnNumber));
|
|
394
258
|
continue;
|
|
395
259
|
}
|
|
396
|
-
nameIndex += this.
|
|
397
|
-
this.
|
|
260
|
+
nameIndex += this.decodeVLQ(stringCharIterator);
|
|
261
|
+
this.mappings().push(new SourceMapEntry(lineNumber, columnNumber, sourceURL, sourceLineNumber, sourceColumnNumber, names[nameIndex]));
|
|
398
262
|
}
|
|
399
263
|
// As per spec, mappings are not necessarily sorted.
|
|
400
|
-
this.
|
|
264
|
+
this.mappings().sort(SourceMapEntry.compare);
|
|
401
265
|
}
|
|
402
|
-
|
|
403
|
-
* @param {string} char
|
|
404
|
-
* @return {boolean}
|
|
405
|
-
*/
|
|
406
|
-
_isSeparator(char) {
|
|
266
|
+
isSeparator(char) {
|
|
407
267
|
return char === ',' || char === ';';
|
|
408
268
|
}
|
|
409
|
-
|
|
410
|
-
* @param {!TextSourceMap.StringCharIterator} stringCharIterator
|
|
411
|
-
* @return {number}
|
|
412
|
-
*/
|
|
413
|
-
_decodeVLQ(stringCharIterator) {
|
|
269
|
+
decodeVLQ(stringCharIterator) {
|
|
414
270
|
// Read unsigned value.
|
|
415
271
|
let result = 0;
|
|
416
272
|
let shift = 0;
|
|
417
|
-
let digit;
|
|
418
|
-
|
|
419
|
-
digit =
|
|
273
|
+
let digit = TextSourceMap._VLQ_CONTINUATION_MASK;
|
|
274
|
+
while (digit & TextSourceMap._VLQ_CONTINUATION_MASK) {
|
|
275
|
+
digit = base64Map.get(stringCharIterator.next()) || 0;
|
|
420
276
|
result += (digit & TextSourceMap._VLQ_BASE_MASK) << shift;
|
|
421
277
|
shift += TextSourceMap._VLQ_BASE_SHIFT;
|
|
422
|
-
}
|
|
278
|
+
}
|
|
423
279
|
// Fix the sign.
|
|
424
280
|
const negative = result & 1;
|
|
425
281
|
result >>= 1;
|
|
426
282
|
return negative ? -result : result;
|
|
427
283
|
}
|
|
428
|
-
/**
|
|
429
|
-
* @param {string} url
|
|
430
|
-
* @param {!TextUtils.TextRange} textRange
|
|
431
|
-
* @return {!TextUtils.TextRange}
|
|
432
|
-
*/
|
|
433
284
|
reverseMapTextRange(url, textRange) {
|
|
434
|
-
/**
|
|
435
|
-
* @param {!{lineNumber: number, columnNumber: number}} position
|
|
436
|
-
* @param {!SourceMapEntry} mapping
|
|
437
|
-
* @return {number}
|
|
438
|
-
*/
|
|
439
285
|
function comparator(position, mapping) {
|
|
440
286
|
if (position.lineNumber !== mapping.sourceLineNumber) {
|
|
441
287
|
return position.lineNumber - mapping.sourceLineNumber;
|
|
442
288
|
}
|
|
443
289
|
return position.columnNumber - mapping.sourceColumnNumber;
|
|
444
290
|
}
|
|
445
|
-
const mappings = this.
|
|
446
|
-
|
|
447
|
-
|
|
291
|
+
const mappings = this.reversedMappings(url);
|
|
292
|
+
if (!mappings.length) {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
const startIndex = Platform.ArrayUtilities.lowerBound(mappings, { lineNumber: textRange.startLine, columnNumber: textRange.startColumn }, comparator);
|
|
296
|
+
const endIndex = Platform.ArrayUtilities.upperBound(mappings, { lineNumber: textRange.endLine, columnNumber: textRange.endColumn }, comparator);
|
|
448
297
|
const startMapping = mappings[startIndex];
|
|
449
298
|
const endMapping = mappings[endIndex];
|
|
450
|
-
return new TextUtils.TextRange(startMapping.lineNumber, startMapping.columnNumber, endMapping.lineNumber, endMapping.columnNumber);
|
|
299
|
+
return new TextUtils.TextRange.TextRange(startMapping.lineNumber, startMapping.columnNumber, endMapping.lineNumber, endMapping.columnNumber);
|
|
451
300
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
301
|
+
mapsOrigin() {
|
|
302
|
+
const mappings = this.mappings();
|
|
303
|
+
if (mappings.length > 0) {
|
|
304
|
+
const firstEntry = mappings[0];
|
|
305
|
+
return (firstEntry === null || firstEntry === void 0 ? void 0 : firstEntry.lineNumber) === 0 || firstEntry.columnNumber === 0;
|
|
306
|
+
}
|
|
307
|
+
return false;
|
|
456
308
|
}
|
|
457
309
|
}
|
|
458
|
-
|
|
459
|
-
TextSourceMap
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
TextSourceMap.
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
return this._string.charAt(this._position);
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* @return {boolean}
|
|
487
|
-
*/
|
|
488
|
-
hasNext() {
|
|
489
|
-
return this._position < this._string.length;
|
|
310
|
+
exports.TextSourceMap = TextSourceMap;
|
|
311
|
+
(function (TextSourceMap) {
|
|
312
|
+
// TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration
|
|
313
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
314
|
+
TextSourceMap._VLQ_BASE_SHIFT = 5;
|
|
315
|
+
// TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration
|
|
316
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
317
|
+
TextSourceMap._VLQ_BASE_MASK = (1 << 5) - 1;
|
|
318
|
+
// TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration
|
|
319
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
320
|
+
TextSourceMap._VLQ_CONTINUATION_MASK = 1 << 5;
|
|
321
|
+
class StringCharIterator {
|
|
322
|
+
constructor(string) {
|
|
323
|
+
this.string = string;
|
|
324
|
+
this.position = 0;
|
|
325
|
+
}
|
|
326
|
+
next() {
|
|
327
|
+
return this.string.charAt(this.position++);
|
|
328
|
+
}
|
|
329
|
+
peek() {
|
|
330
|
+
return this.string.charAt(this.position);
|
|
331
|
+
}
|
|
332
|
+
hasNext() {
|
|
333
|
+
return this.position < this.string.length;
|
|
334
|
+
}
|
|
490
335
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
* @param {?string} content
|
|
498
|
-
* @param {?Array<!SourceMapEntry>} reverseMappings
|
|
499
|
-
*/
|
|
500
|
-
constructor(content, reverseMappings) {
|
|
501
|
-
this.content = content;
|
|
502
|
-
this.reverseMappings = reverseMappings;
|
|
336
|
+
TextSourceMap.StringCharIterator = StringCharIterator;
|
|
337
|
+
class SourceInfo {
|
|
338
|
+
constructor(content, reverseMappings) {
|
|
339
|
+
this.content = content;
|
|
340
|
+
this.reverseMappings = reverseMappings;
|
|
341
|
+
}
|
|
503
342
|
}
|
|
504
|
-
|
|
505
|
-
TextSourceMap.
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
343
|
+
TextSourceMap.SourceInfo = SourceInfo;
|
|
344
|
+
})(TextSourceMap = exports.TextSourceMap || (exports.TextSourceMap = {}));
|
|
509
345
|
|
|
510
|
-
module.exports = TextSourceMap
|
|
346
|
+
module.exports = TextSourceMap;
|
|
@@ -18,6 +18,7 @@ const {Directive} = require('csp_evaluator/dist/csp.js');
|
|
|
18
18
|
|
|
19
19
|
const log = require('lighthouse-logger');
|
|
20
20
|
const i18n = require('../lib/i18n/i18n.js');
|
|
21
|
+
const {isIcuMessage} = require('../../shared/localization/format.js');
|
|
21
22
|
|
|
22
23
|
const UIStrings = {
|
|
23
24
|
/** Message shown when a CSP does not have a base-uri directive. Shown in a table with a list of other CSP vulnerabilities and suggestions. "CSP" stands for "Content Security Policy". "base-uri", "'none'", and "'self'" do not need to be translated. */
|
|
@@ -130,7 +131,7 @@ function getTranslatedDescription(finding) {
|
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
// Return if translated result found.
|
|
133
|
-
if (
|
|
134
|
+
if (isIcuMessage(result)) return result;
|
|
134
135
|
|
|
135
136
|
// If result was not translated, that means `finding.value` is included in the UI string.
|
|
136
137
|
if (typeof result === 'string') return str_(result, {keyword: finding.value || ''});
|