lighthouse 12.3.0 → 12.4.0
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/cli/test/smokehouse/core-tests.js +4 -0
- package/core/audits/audit.d.ts +5 -0
- package/core/audits/audit.js +12 -0
- package/core/audits/bootup-time.js +0 -2
- package/core/audits/byte-efficiency/duplicated-javascript.d.ts +4 -5
- package/core/audits/byte-efficiency/duplicated-javascript.js +9 -5
- package/core/audits/byte-efficiency/legacy-javascript.d.ts +2 -2
- package/core/audits/byte-efficiency/legacy-javascript.js +17 -5
- package/core/audits/byte-efficiency/polyfill-graph-data.json +48 -49
- package/core/audits/byte-efficiency/total-byte-weight.js +0 -2
- package/core/audits/clickjacking-mitigation.d.ts +42 -0
- package/core/audits/clickjacking-mitigation.js +139 -0
- package/core/audits/dobetterweb/dom-size.js +0 -2
- package/core/audits/insights/README.md +3 -0
- package/core/audits/insights/cls-culprits-insight.d.ts +25 -0
- package/core/audits/insights/cls-culprits-insight.js +137 -0
- package/core/audits/insights/document-latency-insight.d.ts +11 -0
- package/core/audits/insights/document-latency-insight.js +48 -0
- package/core/audits/insights/dom-size-insight.d.ts +11 -0
- package/core/audits/insights/dom-size-insight.js +85 -0
- package/core/audits/insights/font-display-insight.d.ts +11 -0
- package/core/audits/insights/font-display-insight.js +53 -0
- package/core/audits/insights/forced-reflow-insight.d.ts +11 -0
- package/core/audits/insights/forced-reflow-insight.js +52 -0
- package/core/audits/insights/image-delivery-insight.d.ts +11 -0
- package/core/audits/insights/image-delivery-insight.js +83 -0
- package/core/audits/insights/insight-audit.d.ts +23 -0
- package/core/audits/insights/insight-audit.js +133 -0
- package/core/audits/insights/interaction-to-next-paint-insight.d.ts +11 -0
- package/core/audits/insights/interaction-to-next-paint-insight.js +71 -0
- package/core/audits/insights/lcp-discovery-insight.d.ts +11 -0
- package/core/audits/insights/lcp-discovery-insight.js +48 -0
- package/core/audits/insights/lcp-phases-insight.d.ts +16 -0
- package/core/audits/insights/lcp-phases-insight.js +87 -0
- package/core/audits/insights/long-critical-network-tree-insight.d.ts +11 -0
- package/core/audits/insights/long-critical-network-tree-insight.js +53 -0
- package/core/audits/insights/render-blocking-insight.d.ts +11 -0
- package/core/audits/insights/render-blocking-insight.js +57 -0
- package/core/audits/insights/slow-css-selector-insight.d.ts +11 -0
- package/core/audits/insights/slow-css-selector-insight.js +52 -0
- package/core/audits/insights/third-parties-insight.d.ts +28 -0
- package/core/audits/insights/third-parties-insight.js +90 -0
- package/core/audits/insights/viewport-insight.d.ts +11 -0
- package/core/audits/insights/viewport-insight.js +54 -0
- package/core/audits/layout-shifts.d.ts +0 -1
- package/core/audits/layout-shifts.js +18 -21
- package/core/audits/mainthread-work-breakdown.js +0 -2
- package/core/audits/seo/is-crawlable.d.ts +1 -0
- package/core/audits/server-response-time.js +0 -1
- package/core/computed/metrics/lantern-metric.js +5 -1
- package/core/computed/trace-engine-result.js +71 -17
- package/core/config/default-config.js +37 -1
- package/core/gather/gatherers/inspector-issues.js +3 -0
- package/core/gather/gatherers/trace-elements.d.ts +10 -2
- package/core/gather/gatherers/trace-elements.js +89 -12
- package/core/lib/bf-cache-strings.d.ts +7 -4
- package/core/lib/bf-cache-strings.js +174 -140
- package/core/lib/cdt/generated/ParsedURL.d.ts +1 -0
- package/core/lib/cdt/generated/ParsedURL.js +16 -4
- package/core/lib/cdt/generated/SourceMap.d.ts +32 -5
- package/core/lib/cdt/generated/SourceMap.js +192 -100
- package/core/lib/deprecations-strings.d.ts +78 -98
- package/core/lib/deprecations-strings.js +23 -41
- package/core/lib/i18n/i18n.d.ts +1 -0
- package/core/lib/i18n/i18n.js +2 -0
- package/core/lib/trace-engine.d.ts +1 -0
- package/core/lib/trace-engine.js +2 -0
- package/core/runner.js +2 -0
- package/dist/report/bundle.esm.js +196 -9
- package/dist/report/flow.js +197 -10
- package/dist/report/standalone.js +197 -10
- package/flow-report/src/i18n/i18n.d.ts +2 -0
- package/package.json +15 -13
- package/readme.md +3 -0
- package/report/assets/styles.css +179 -5
- package/report/assets/templates.html +14 -0
- package/report/renderer/components.js +9 -3
- package/report/renderer/details-renderer.d.ts +5 -0
- package/report/renderer/details-renderer.js +24 -0
- package/report/renderer/dom.d.ts +12 -1
- package/report/renderer/dom.js +26 -1
- package/report/renderer/i18n-formatter.d.ts +1 -1
- package/report/renderer/performance-category-renderer.d.ts +10 -0
- package/report/renderer/performance-category-renderer.js +81 -20
- package/report/renderer/report-utils.d.ts +1 -0
- package/report/renderer/report-utils.js +2 -0
- package/report/renderer/topbar-features.js +7 -0
- package/shared/localization/locales/ar-XB.json +74 -26
- package/shared/localization/locales/ar.json +76 -28
- package/shared/localization/locales/bg.json +74 -26
- package/shared/localization/locales/ca.json +74 -26
- package/shared/localization/locales/cs.json +74 -26
- package/shared/localization/locales/da.json +74 -26
- package/shared/localization/locales/de.json +75 -27
- package/shared/localization/locales/el.json +74 -26
- package/shared/localization/locales/en-GB.json +74 -26
- package/shared/localization/locales/en-US.json +288 -30
- package/shared/localization/locales/en-XA.json +48 -24
- package/shared/localization/locales/en-XL.json +288 -30
- package/shared/localization/locales/es-419.json +74 -26
- package/shared/localization/locales/es.json +74 -26
- package/shared/localization/locales/fi.json +74 -26
- package/shared/localization/locales/fil.json +75 -27
- package/shared/localization/locales/fr.json +74 -26
- package/shared/localization/locales/he.json +82 -34
- package/shared/localization/locales/hi.json +74 -26
- package/shared/localization/locales/hr.json +75 -27
- package/shared/localization/locales/hu.json +74 -26
- package/shared/localization/locales/id.json +74 -26
- package/shared/localization/locales/it.json +85 -37
- package/shared/localization/locales/ja.json +75 -27
- package/shared/localization/locales/ko.json +75 -27
- package/shared/localization/locales/lt.json +75 -27
- package/shared/localization/locales/lv.json +74 -26
- package/shared/localization/locales/nl.json +74 -26
- package/shared/localization/locales/no.json +75 -27
- package/shared/localization/locales/pl.json +74 -26
- package/shared/localization/locales/pt-PT.json +74 -26
- package/shared/localization/locales/pt.json +74 -26
- package/shared/localization/locales/ro.json +74 -26
- package/shared/localization/locales/ru.json +74 -26
- package/shared/localization/locales/sk.json +74 -26
- package/shared/localization/locales/sl.json +74 -26
- package/shared/localization/locales/sr-Latn.json +74 -26
- package/shared/localization/locales/sr.json +74 -26
- package/shared/localization/locales/sv.json +74 -26
- package/shared/localization/locales/ta.json +74 -26
- package/shared/localization/locales/te.json +74 -26
- package/shared/localization/locales/th.json +76 -28
- package/shared/localization/locales/tr.json +74 -26
- package/shared/localization/locales/uk.json +74 -26
- package/shared/localization/locales/vi.json +74 -26
- package/shared/localization/locales/zh-HK.json +75 -27
- package/shared/localization/locales/zh-TW.json +74 -26
- package/shared/localization/locales/zh.json +74 -26
- package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +3 -0
- package/types/artifacts.d.ts +5 -3
- package/types/audit.d.ts +2 -0
- package/types/lhr/audit-details.d.ts +13 -1
- package/types/lhr/audit-result.d.ts +2 -0
- package/core/gather/gatherers/root-causes.d.ts +0 -19
- package/core/gather/gatherers/root-causes.js +0 -144
|
@@ -4,11 +4,18 @@
|
|
|
4
4
|
"use strict";
|
|
5
5
|
const Common = require('../Common.js');
|
|
6
6
|
const Platform = require('../Platform.js');
|
|
7
|
+
|
|
8
|
+
const BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
9
|
+
const BASE64_CODES = new Uint8Array(123);
|
|
10
|
+
for (let index = 0; index < BASE64_CHARS.length; ++index) {
|
|
11
|
+
BASE64_CODES[BASE64_CHARS.charCodeAt(index)] = index;
|
|
12
|
+
}
|
|
13
|
+
|
|
7
14
|
// Copyright 2021 The Chromium Authors. All rights reserved.
|
|
8
15
|
// Use of this source code is governed by a BSD-style license that can be
|
|
9
16
|
// found in the LICENSE file.
|
|
10
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.SourceMap = exports.SourceMapEntry = void 0;
|
|
18
|
+
exports.TokenIterator = exports.SourceMap = exports.SourceMapEntry = void 0;
|
|
12
19
|
exports.parseSourceMap = parseSourceMap;
|
|
13
20
|
/*
|
|
14
21
|
* Copyright (C) 2012 Google Inc. All rights reserved.
|
|
@@ -42,6 +49,9 @@ exports.parseSourceMap = parseSourceMap;
|
|
|
42
49
|
;
|
|
43
50
|
;
|
|
44
51
|
;
|
|
52
|
+
;
|
|
53
|
+
;
|
|
54
|
+
;
|
|
45
55
|
/**
|
|
46
56
|
* Parses the {@link content} as JSON, ignoring BOM markers in the beginning, and
|
|
47
57
|
* also handling the CORB bypass prefix correctly.
|
|
@@ -62,13 +72,15 @@ function parseSourceMap(content) {
|
|
|
62
72
|
class SourceMapEntry {
|
|
63
73
|
lineNumber;
|
|
64
74
|
columnNumber;
|
|
75
|
+
sourceIndex;
|
|
65
76
|
sourceURL;
|
|
66
77
|
sourceLineNumber;
|
|
67
78
|
sourceColumnNumber;
|
|
68
79
|
name;
|
|
69
|
-
constructor(lineNumber, columnNumber, sourceURL, sourceLineNumber, sourceColumnNumber, name) {
|
|
80
|
+
constructor(lineNumber, columnNumber, sourceIndex, sourceURL, sourceLineNumber, sourceColumnNumber, name) {
|
|
70
81
|
this.lineNumber = lineNumber;
|
|
71
82
|
this.columnNumber = columnNumber;
|
|
83
|
+
this.sourceIndex = sourceIndex;
|
|
72
84
|
this.sourceURL = sourceURL;
|
|
73
85
|
this.sourceLineNumber = sourceLineNumber;
|
|
74
86
|
this.sourceColumnNumber = sourceColumnNumber;
|
|
@@ -82,19 +94,15 @@ class SourceMapEntry {
|
|
|
82
94
|
}
|
|
83
95
|
}
|
|
84
96
|
exports.SourceMapEntry = SourceMapEntry;
|
|
85
|
-
const base64Digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
86
|
-
const base64Map = new Map();
|
|
87
|
-
for (let i = 0; i < base64Digits.length; ++i) {
|
|
88
|
-
base64Map.set(base64Digits.charAt(i), i);
|
|
89
|
-
}
|
|
90
|
-
const sourceMapToSourceList = new WeakMap();
|
|
91
97
|
class SourceMap {
|
|
92
98
|
#json;
|
|
93
99
|
#compiledURLInternal;
|
|
94
100
|
#sourceMappingURL;
|
|
95
101
|
#baseURL;
|
|
96
102
|
#mappingsInternal;
|
|
97
|
-
#sourceInfos;
|
|
103
|
+
#sourceInfos = [];
|
|
104
|
+
#sourceInfoByURL = new Map();
|
|
105
|
+
#scopesInfo = null;
|
|
98
106
|
/**
|
|
99
107
|
* Implements Source Map V3 model. See https://github.com/google/closure-compiler/wiki/Source-Maps
|
|
100
108
|
* for format description.
|
|
@@ -103,9 +111,8 @@ class SourceMap {
|
|
|
103
111
|
this.#json = payload;
|
|
104
112
|
this.#compiledURLInternal = compiledURL;
|
|
105
113
|
this.#sourceMappingURL = sourceMappingURL;
|
|
106
|
-
this.#baseURL = (
|
|
114
|
+
this.#baseURL = (Common.ParsedURL.schemeIs(sourceMappingURL, 'data:')) ? compiledURL : sourceMappingURL;
|
|
107
115
|
this.#mappingsInternal = null;
|
|
108
|
-
this.#sourceInfos = new Map();
|
|
109
116
|
if ('sections' in this.#json) {
|
|
110
117
|
if (this.#json.sections.find(section => 'url' in section)) {
|
|
111
118
|
console.warn(`SourceMap "${sourceMappingURL}" contains unsupported "URL" field in one of its sections.`);
|
|
@@ -113,6 +120,9 @@ class SourceMap {
|
|
|
113
120
|
}
|
|
114
121
|
this.eachSection(this.parseSources.bind(this));
|
|
115
122
|
}
|
|
123
|
+
#sourceIndex(sourceURL) {
|
|
124
|
+
return this.#sourceInfos.findIndex(info => info.sourceURL === sourceURL);
|
|
125
|
+
}
|
|
116
126
|
compiledURL() {
|
|
117
127
|
return this.#compiledURLInternal;
|
|
118
128
|
}
|
|
@@ -120,16 +130,40 @@ class SourceMap {
|
|
|
120
130
|
return this.#sourceMappingURL;
|
|
121
131
|
}
|
|
122
132
|
sourceURLs() {
|
|
123
|
-
return [...this.#
|
|
133
|
+
return [...this.#sourceInfoByURL.keys()];
|
|
124
134
|
}
|
|
125
135
|
embeddedContentByURL(sourceURL) {
|
|
126
|
-
const entry = this.#
|
|
136
|
+
const entry = this.#sourceInfoByURL.get(sourceURL);
|
|
127
137
|
if (!entry) {
|
|
128
138
|
return null;
|
|
129
139
|
}
|
|
130
140
|
return entry.content;
|
|
131
141
|
}
|
|
132
|
-
|
|
142
|
+
hasScopeInfo() {
|
|
143
|
+
this.#ensureMappingsProcessed();
|
|
144
|
+
return this.#scopesInfo !== null;
|
|
145
|
+
}
|
|
146
|
+
findEntry(lineNumber, columnNumber, inlineFrameIndex) {
|
|
147
|
+
this.#ensureMappingsProcessed();
|
|
148
|
+
if (inlineFrameIndex && this.#scopesInfo !== null) {
|
|
149
|
+
// For inlineFrameIndex != 0 we use the callsite info for the corresponding inlining site.
|
|
150
|
+
// Note that the callsite for "inlineFrameIndex" is actually in the previous frame.
|
|
151
|
+
const { inlinedFunctions } = this.#scopesInfo.findInlinedFunctions(lineNumber, columnNumber);
|
|
152
|
+
const { callsite } = inlinedFunctions[inlineFrameIndex - 1];
|
|
153
|
+
if (!callsite) {
|
|
154
|
+
console.error('Malformed source map. Expected to have a callsite info for index', inlineFrameIndex);
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
lineNumber,
|
|
159
|
+
columnNumber,
|
|
160
|
+
sourceIndex: callsite.sourceIndex,
|
|
161
|
+
sourceURL: this.sourceURLs()[callsite.sourceIndex],
|
|
162
|
+
sourceLineNumber: callsite.line,
|
|
163
|
+
sourceColumnNumber: callsite.column,
|
|
164
|
+
name: undefined,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
133
167
|
const mappings = this.mappings();
|
|
134
168
|
const index = Platform.ArrayUtilities.upperBound(mappings, undefined, (unused, entry) => lineNumber - entry.lineNumber || columnNumber - entry.columnNumber);
|
|
135
169
|
return index ? mappings[index - 1] : null;
|
|
@@ -239,12 +273,18 @@ class SourceMap {
|
|
|
239
273
|
}
|
|
240
274
|
reversedMappings(sourceURL) {
|
|
241
275
|
this.#ensureMappingsProcessed();
|
|
242
|
-
return this.#
|
|
276
|
+
return this.#sourceInfoByURL.get(sourceURL)?.reverseMappings ?? [];
|
|
243
277
|
}
|
|
244
278
|
#ensureMappingsProcessed() {
|
|
245
279
|
if (this.#mappingsInternal === null) {
|
|
246
280
|
this.#mappingsInternal = [];
|
|
247
|
-
|
|
281
|
+
try {
|
|
282
|
+
this.eachSection(this.parseMap.bind(this));
|
|
283
|
+
}
|
|
284
|
+
catch (e) {
|
|
285
|
+
console.error('Failed to parse source map', e);
|
|
286
|
+
this.#mappingsInternal = [];
|
|
287
|
+
}
|
|
248
288
|
// As per spec, mappings are not necessarily sorted.
|
|
249
289
|
this.mappings().sort(SourceMapEntry.compare);
|
|
250
290
|
this.#computeReverseMappings(this.#mappingsInternal);
|
|
@@ -266,7 +306,7 @@ class SourceMap {
|
|
|
266
306
|
reverseMap.push(i);
|
|
267
307
|
}
|
|
268
308
|
for (const [url, reverseMap] of reverseMappingsPerUrl.entries()) {
|
|
269
|
-
const info = this.#
|
|
309
|
+
const info = this.#sourceInfoByURL.get(url);
|
|
270
310
|
if (!info) {
|
|
271
311
|
continue;
|
|
272
312
|
}
|
|
@@ -285,20 +325,21 @@ class SourceMap {
|
|
|
285
325
|
return;
|
|
286
326
|
}
|
|
287
327
|
if ('sections' in this.#json) {
|
|
328
|
+
let sourcesIndex = 0;
|
|
288
329
|
for (const section of this.#json.sections) {
|
|
289
330
|
if ('map' in section) {
|
|
290
|
-
callback(section.map, section.offset.line, section.offset.column);
|
|
331
|
+
callback(section.map, sourcesIndex, section.offset.line, section.offset.column);
|
|
332
|
+
sourcesIndex += section.map.sources.length;
|
|
291
333
|
}
|
|
292
334
|
}
|
|
293
335
|
}
|
|
294
336
|
else {
|
|
295
|
-
callback(this.#json, 0, 0);
|
|
337
|
+
callback(this.#json, 0, 0, 0);
|
|
296
338
|
}
|
|
297
339
|
}
|
|
298
340
|
parseSources(sourceMap) {
|
|
299
|
-
const sourcesList = [];
|
|
300
341
|
const sourceRoot = sourceMap.sourceRoot ?? '';
|
|
301
|
-
const ignoreList = new Set(sourceMap.x_google_ignoreList);
|
|
342
|
+
const ignoreList = new Set(sourceMap.ignoreList ?? sourceMap.x_google_ignoreList);
|
|
302
343
|
for (let i = 0; i < sourceMap.sources.length; ++i) {
|
|
303
344
|
let href = sourceMap.sources[i];
|
|
304
345
|
// The source map v3 proposal says to prepend the sourceRoot to the source URL
|
|
@@ -316,84 +357,83 @@ class SourceMap {
|
|
|
316
357
|
}
|
|
317
358
|
const url = '' || href;
|
|
318
359
|
const source = sourceMap.sourcesContent && sourceMap.sourcesContent[i];
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
360
|
+
const sourceInfo = {
|
|
361
|
+
sourceURL: url,
|
|
362
|
+
content: source ?? null,
|
|
363
|
+
ignoreListHint: ignoreList.has(i),
|
|
364
|
+
reverseMappings: null,
|
|
365
|
+
};
|
|
366
|
+
this.#sourceInfos.push(sourceInfo);
|
|
367
|
+
if (!this.#sourceInfoByURL.has(url)) {
|
|
368
|
+
this.#sourceInfoByURL.set(url, sourceInfo);
|
|
324
369
|
}
|
|
325
370
|
}
|
|
326
|
-
sourceMapToSourceList.set(sourceMap, sourcesList);
|
|
327
371
|
}
|
|
328
|
-
parseMap(map,
|
|
329
|
-
let sourceIndex =
|
|
372
|
+
parseMap(map, baseSourceIndex, baseLineNumber, baseColumnNumber) {
|
|
373
|
+
let sourceIndex = baseSourceIndex;
|
|
374
|
+
let lineNumber = baseLineNumber;
|
|
375
|
+
let columnNumber = baseColumnNumber;
|
|
330
376
|
let sourceLineNumber = 0;
|
|
331
377
|
let sourceColumnNumber = 0;
|
|
332
378
|
let nameIndex = 0;
|
|
333
|
-
// TODO(crbug.com/1011811): refactor away map.
|
|
334
|
-
// `sources` can be undefined if it wasn't previously
|
|
335
|
-
// processed and added to the list. However, that
|
|
336
|
-
// is not WAI and we should make sure that we can
|
|
337
|
-
// only reach this point when we are certain
|
|
338
|
-
// we have the list available.
|
|
339
|
-
const sources = sourceMapToSourceList.get(map);
|
|
340
379
|
const names = map.names ?? [];
|
|
341
|
-
const
|
|
342
|
-
let sourceURL =
|
|
380
|
+
const tokenIter = new TokenIterator(map.mappings);
|
|
381
|
+
let sourceURL = this.#sourceInfos[sourceIndex].sourceURL;
|
|
343
382
|
while (true) {
|
|
344
|
-
if (
|
|
345
|
-
|
|
383
|
+
if (tokenIter.peek() === ',') {
|
|
384
|
+
tokenIter.next();
|
|
346
385
|
}
|
|
347
386
|
else {
|
|
348
|
-
while (
|
|
387
|
+
while (tokenIter.peek() === ';') {
|
|
349
388
|
lineNumber += 1;
|
|
350
389
|
columnNumber = 0;
|
|
351
|
-
|
|
390
|
+
tokenIter.next();
|
|
352
391
|
}
|
|
353
|
-
if (!
|
|
392
|
+
if (!tokenIter.hasNext()) {
|
|
354
393
|
break;
|
|
355
394
|
}
|
|
356
395
|
}
|
|
357
|
-
columnNumber +=
|
|
358
|
-
if (!
|
|
396
|
+
columnNumber += tokenIter.nextVLQ();
|
|
397
|
+
if (!tokenIter.hasNext() || this.isSeparator(tokenIter.peek())) {
|
|
359
398
|
this.mappings().push(new SourceMapEntry(lineNumber, columnNumber));
|
|
360
399
|
continue;
|
|
361
400
|
}
|
|
362
|
-
const sourceIndexDelta =
|
|
401
|
+
const sourceIndexDelta = tokenIter.nextVLQ();
|
|
363
402
|
if (sourceIndexDelta) {
|
|
364
403
|
sourceIndex += sourceIndexDelta;
|
|
365
|
-
|
|
366
|
-
sourceURL = sources[sourceIndex];
|
|
367
|
-
}
|
|
404
|
+
sourceURL = this.#sourceInfos[sourceIndex].sourceURL;
|
|
368
405
|
}
|
|
369
|
-
sourceLineNumber +=
|
|
370
|
-
sourceColumnNumber +=
|
|
371
|
-
if (!
|
|
372
|
-
this.mappings().push(new SourceMapEntry(lineNumber, columnNumber, sourceURL, sourceLineNumber, sourceColumnNumber));
|
|
406
|
+
sourceLineNumber += tokenIter.nextVLQ();
|
|
407
|
+
sourceColumnNumber += tokenIter.nextVLQ();
|
|
408
|
+
if (!tokenIter.hasNext() || this.isSeparator(tokenIter.peek())) {
|
|
409
|
+
this.mappings().push(new SourceMapEntry(lineNumber, columnNumber, sourceIndex, sourceURL, sourceLineNumber, sourceColumnNumber));
|
|
373
410
|
continue;
|
|
374
411
|
}
|
|
375
|
-
nameIndex +=
|
|
376
|
-
this.mappings().push(new SourceMapEntry(lineNumber, columnNumber, sourceURL, sourceLineNumber, sourceColumnNumber, names[nameIndex]));
|
|
412
|
+
nameIndex += tokenIter.nextVLQ();
|
|
413
|
+
this.mappings().push(new SourceMapEntry(lineNumber, columnNumber, sourceIndex, sourceURL, sourceLineNumber, sourceColumnNumber, names[nameIndex]));
|
|
414
|
+
}
|
|
415
|
+
if (false) {
|
|
416
|
+
if (!this.#scopesInfo) {
|
|
417
|
+
this.#scopesInfo = new SourceMapScopesInfo_js_1.SourceMapScopesInfo(this, [], []);
|
|
418
|
+
}
|
|
419
|
+
if (map.originalScopes && map.generatedRanges) {
|
|
420
|
+
const { originalScopes, generatedRanges } = (0, SourceMapScopes_js_1.decodeScopes)(map, { line: baseLineNumber, column: baseColumnNumber });
|
|
421
|
+
this.#scopesInfo.addOriginalScopes(originalScopes);
|
|
422
|
+
this.#scopesInfo.addGeneratedRanges(generatedRanges);
|
|
423
|
+
}
|
|
424
|
+
else if (map.x_com_bloomberg_sourcesFunctionMappings) {
|
|
425
|
+
const originalScopes = this.parseBloombergScopes(map);
|
|
426
|
+
this.#scopesInfo.addOriginalScopes(originalScopes);
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
// Keep the OriginalScope[] tree array consistent with sources.
|
|
430
|
+
this.#scopesInfo.addOriginalScopes(new Array(map.sources.length));
|
|
431
|
+
}
|
|
377
432
|
}
|
|
378
433
|
}
|
|
379
434
|
isSeparator(char) {
|
|
380
435
|
return char === ',' || char === ';';
|
|
381
436
|
}
|
|
382
|
-
decodeVLQ(stringCharIterator) {
|
|
383
|
-
// Read unsigned value.
|
|
384
|
-
let result = 0;
|
|
385
|
-
let shift = 0;
|
|
386
|
-
let digit = SourceMap._VLQ_CONTINUATION_MASK;
|
|
387
|
-
while (digit & SourceMap._VLQ_CONTINUATION_MASK) {
|
|
388
|
-
digit = base64Map.get(stringCharIterator.next()) || 0;
|
|
389
|
-
result += (digit & SourceMap._VLQ_BASE_MASK) << shift;
|
|
390
|
-
shift += SourceMap._VLQ_BASE_SHIFT;
|
|
391
|
-
}
|
|
392
|
-
// Fix the sign.
|
|
393
|
-
const negative = result & 1;
|
|
394
|
-
result >>= 1;
|
|
395
|
-
return negative ? -result : result;
|
|
396
|
-
}
|
|
397
437
|
mapsOrigin() {
|
|
398
438
|
const mappings = this.mappings();
|
|
399
439
|
if (mappings.length > 0) {
|
|
@@ -403,7 +443,7 @@ class SourceMap {
|
|
|
403
443
|
return false;
|
|
404
444
|
}
|
|
405
445
|
hasIgnoreListHint(sourceURL) {
|
|
406
|
-
return this.#
|
|
446
|
+
return this.#sourceInfoByURL.get(sourceURL)?.ignoreListHint ?? false;
|
|
407
447
|
}
|
|
408
448
|
/**
|
|
409
449
|
* Returns a list of ranges in the generated script for original sources that
|
|
@@ -440,37 +480,89 @@ class SourceMap {
|
|
|
440
480
|
}
|
|
441
481
|
return ranges;
|
|
442
482
|
}
|
|
483
|
+
expandCallFrame(frame) {
|
|
484
|
+
this.#ensureMappingsProcessed();
|
|
485
|
+
if (this.#scopesInfo === null) {
|
|
486
|
+
return [frame];
|
|
487
|
+
}
|
|
488
|
+
return this.#scopesInfo.expandCallFrame(frame);
|
|
489
|
+
}
|
|
490
|
+
resolveScopeChain(frame) {
|
|
491
|
+
this.#ensureMappingsProcessed();
|
|
492
|
+
if (this.#scopesInfo === null) {
|
|
493
|
+
return null;
|
|
494
|
+
}
|
|
495
|
+
return this.#scopesInfo.resolveMappedScopeChain(frame);
|
|
496
|
+
}
|
|
497
|
+
findOriginalFunctionName(position) {
|
|
498
|
+
this.#ensureMappingsProcessed();
|
|
499
|
+
return this.#scopesInfo?.findOriginalFunctionName(position) ?? null;
|
|
500
|
+
}
|
|
443
501
|
}
|
|
444
502
|
exports.SourceMap = SourceMap;
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
string;
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
503
|
+
const VLQ_BASE_SHIFT = 5;
|
|
504
|
+
const VLQ_BASE_MASK = (1 << 5) - 1;
|
|
505
|
+
const VLQ_CONTINUATION_MASK = 1 << 5;
|
|
506
|
+
class TokenIterator {
|
|
507
|
+
#string;
|
|
508
|
+
#position;
|
|
509
|
+
constructor(string) {
|
|
510
|
+
this.#string = string;
|
|
511
|
+
this.#position = 0;
|
|
512
|
+
}
|
|
513
|
+
next() {
|
|
514
|
+
return this.#string.charAt(this.#position++);
|
|
515
|
+
}
|
|
516
|
+
/** Returns the unicode value of the next character and advances the iterator */
|
|
517
|
+
nextCharCode() {
|
|
518
|
+
return this.#string.charCodeAt(this.#position++);
|
|
519
|
+
}
|
|
520
|
+
peek() {
|
|
521
|
+
return this.#string.charAt(this.#position);
|
|
522
|
+
}
|
|
523
|
+
hasNext() {
|
|
524
|
+
return this.#position < this.#string.length;
|
|
525
|
+
}
|
|
526
|
+
nextVLQ() {
|
|
527
|
+
// Read unsigned value.
|
|
528
|
+
let result = 0;
|
|
529
|
+
let shift = 0;
|
|
530
|
+
let digit = VLQ_CONTINUATION_MASK;
|
|
531
|
+
while (digit & VLQ_CONTINUATION_MASK) {
|
|
532
|
+
if (!this.hasNext()) {
|
|
533
|
+
throw new Error('Unexpected end of input while decodling VLQ number!');
|
|
534
|
+
}
|
|
535
|
+
const charCode = this.nextCharCode();
|
|
536
|
+
digit = BASE64_CODES[charCode];
|
|
537
|
+
if (charCode !== 65 /* 'A' */ && digit === 0) {
|
|
538
|
+
throw new Error(`Unexpected char '${String.fromCharCode(charCode)}' encountered while decoding`);
|
|
539
|
+
}
|
|
540
|
+
result += (digit & VLQ_BASE_MASK) << shift;
|
|
541
|
+
shift += VLQ_BASE_SHIFT;
|
|
542
|
+
}
|
|
543
|
+
// Fix the sign.
|
|
544
|
+
const negative = result & 1;
|
|
545
|
+
result >>= 1;
|
|
546
|
+
return negative ? -result : result;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* @returns the next VLQ number without iterating further. Or returns null if
|
|
550
|
+
* the iterator is at the end or it's not a valid number.
|
|
551
|
+
*/
|
|
552
|
+
peekVLQ() {
|
|
553
|
+
const pos = this.#position;
|
|
554
|
+
try {
|
|
555
|
+
return this.nextVLQ();
|
|
556
|
+
}
|
|
557
|
+
catch {
|
|
558
|
+
return null;
|
|
559
|
+
}
|
|
560
|
+
finally {
|
|
561
|
+
this.#position = pos; // Reset the iterator.
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
exports.TokenIterator = TokenIterator;
|
|
474
566
|
|
|
475
567
|
|
|
476
568
|
module.exports = SourceMap;
|