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