lighthouse 13.5.0-dev.20261016 → 13.5.0-dev.20261020
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/.agents/skills/update-trace-engine/SKILL.md +154 -0
- package/cli/test/smokehouse/__snapshots__/report-assert-test.js.snap +1 -1
- package/commitlint.config.js +1 -1
- package/core/audits/baseline.js +1 -1
- package/core/audits/insights/insight-audit.js +3 -2
- package/core/audits/script-treemap-data.js +12 -2
- package/core/computed/metrics/time-to-first-byte.js +5 -3
- package/core/computed/navigation-insights.js +3 -2
- package/core/computed/trace-engine-result.js +22 -4
- package/core/config/config-helpers.js +2 -3
- package/core/config/config.js +1 -2
- package/core/gather/base-artifacts.js +6 -0
- package/core/gather/gatherers/full-page-screenshot.js +2 -2
- package/core/gather/gatherers/inspector-issues.js +2 -0
- package/core/gather/gatherers/js-usage.js +2 -0
- package/core/gather/gatherers/scripts.d.ts +16 -3
- package/core/gather/gatherers/scripts.js +157 -14
- package/core/gather/gatherers/stylesheets.js +2 -0
- package/core/gather/gatherers/trace-elements.js +2 -1
- package/core/lib/cdt/Common.d.ts +1 -1
- package/core/lib/cdt/Common.js +2 -2
- package/core/lib/cdt/Platform.d.ts +7 -7
- package/core/lib/cdt/Platform.js +11 -8
- package/core/lib/cdt/SDK.d.ts +5 -1
- package/core/lib/cdt/SDK.js +4 -2
- package/core/lib/cdt/generated/ParsedURL.d.ts +0 -1
- package/core/lib/cdt/generated/ParsedURL.js +3 -9
- package/core/lib/cdt/generated/SourceMap.d.ts +24 -25
- package/core/lib/cdt/generated/SourceMap.js +7 -15
- package/core/lib/i18n/i18n.d.ts +0 -1
- package/core/lib/i18n/i18n.js +17 -11
- package/core/lib/legacy-javascript/legacy-javascript.d.ts +2 -2
- package/core/lib/legacy-javascript/legacy-javascript.js +1 -1
- package/core/lib/sentry.d.ts +1 -0
- package/core/lib/sentry.js +3 -0
- package/core/runner.js +2 -2
- package/dist/report/flow.js +4 -4
- package/package.json +16 -41
- package/report/generator/flow-report-assets.js +1 -3
- package/report/generator/report-assets.js +1 -2
- package/shared/esm-utils.d.ts +0 -8
- package/shared/esm-utils.js +0 -18
- package/shared/localization/format.js +1 -2
- package/shared/localization/locales/ar-XB.json +0 -6
- package/shared/localization/locales/ar.json +0 -6
- package/shared/localization/locales/bg.json +0 -6
- package/shared/localization/locales/ca.json +0 -6
- package/shared/localization/locales/cs.json +0 -6
- package/shared/localization/locales/da.json +0 -6
- package/shared/localization/locales/de.json +0 -6
- package/shared/localization/locales/el.json +0 -6
- package/shared/localization/locales/en-GB.json +0 -6
- package/shared/localization/locales/en-US.json +4 -7
- package/shared/localization/locales/en-XL.json +4 -7
- package/shared/localization/locales/es-419.json +22 -28
- package/shared/localization/locales/es.json +0 -6
- package/shared/localization/locales/fi.json +0 -6
- package/shared/localization/locales/fil.json +0 -6
- package/shared/localization/locales/fr.json +0 -6
- package/shared/localization/locales/he.json +127 -133
- package/shared/localization/locales/hi.json +0 -6
- package/shared/localization/locales/hr.json +0 -6
- package/shared/localization/locales/hu.json +0 -6
- package/shared/localization/locales/id.json +0 -6
- package/shared/localization/locales/it.json +0 -6
- package/shared/localization/locales/ja.json +115 -121
- package/shared/localization/locales/ko.json +2 -8
- package/shared/localization/locales/lt.json +0 -6
- package/shared/localization/locales/lv.json +0 -6
- package/shared/localization/locales/nl.json +0 -6
- package/shared/localization/locales/no.json +0 -6
- package/shared/localization/locales/pl.json +0 -6
- package/shared/localization/locales/pt-PT.json +0 -6
- package/shared/localization/locales/pt.json +0 -6
- package/shared/localization/locales/ro.json +3 -9
- package/shared/localization/locales/ru.json +3 -9
- package/shared/localization/locales/sk.json +0 -6
- package/shared/localization/locales/sl.json +0 -6
- package/shared/localization/locales/sr-Latn.json +0 -6
- package/shared/localization/locales/sr.json +0 -6
- package/shared/localization/locales/sv.json +0 -6
- package/shared/localization/locales/ta.json +0 -6
- package/shared/localization/locales/te.json +0 -6
- package/shared/localization/locales/th.json +0 -6
- package/shared/localization/locales/tr.json +0 -6
- package/shared/localization/locales/uk.json +0 -6
- package/shared/localization/locales/vi.json +0 -6
- package/shared/localization/locales/zh-HK.json +18 -24
- package/shared/localization/locales/zh-TW.json +60 -66
- package/shared/localization/locales/zh.json +2 -8
- package/shared/root.js +1 -3
- package/tsconfig.json +0 -2
- package/types/artifacts.d.ts +8 -1
- package/types/internal/test.d.ts +1 -0
- package/core/lib/cdt/package.json +0 -4
- package/eslint-local-rules.d.cts +0 -9
- package/eslint.config.mjs +0 -242
- package/third-party/esbuild-plugins-polyfills/LICENSE +0 -3
- package/third-party/esbuild-plugins-polyfills/README.md +0 -7
- package/third-party/esbuild-plugins-polyfills/esbuild-polyfills.d.ts +0 -9
- package/third-party/esbuild-plugins-polyfills/esbuild-polyfills.js +0 -129
- package/types/internal/lookup-closest-locale.d.ts +0 -13
|
@@ -5,19 +5,31 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import BaseGatherer from '../base-gatherer.js';
|
|
8
|
+
import Trace from './trace.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {Object} TraceScript
|
|
12
|
+
* @property {string} scriptId
|
|
13
|
+
* @property {string} [sourceText]
|
|
14
|
+
* @property {string[]} [chunks]
|
|
15
|
+
* @property {string} [url]
|
|
16
|
+
* @property {string} [sourceUrl]
|
|
17
|
+
* @property {number} [executionContextId]
|
|
18
|
+
* @property {string} [frame]
|
|
19
|
+
*/
|
|
8
20
|
|
|
9
21
|
/**
|
|
10
22
|
* @template T, U
|
|
11
23
|
* @param {Array<T>} values
|
|
12
|
-
* @param {(value: T) => Promise<U>} promiseMapper
|
|
24
|
+
* @param {(value: T, index: number) => Promise<U>} promiseMapper
|
|
13
25
|
* @param {boolean} runInSeries
|
|
14
26
|
* @return {Promise<Array<U>>}
|
|
15
27
|
*/
|
|
16
28
|
async function runInSeriesOrParallel(values, promiseMapper, runInSeries) {
|
|
17
29
|
if (runInSeries) {
|
|
18
30
|
const results = [];
|
|
19
|
-
for (
|
|
20
|
-
const result = await promiseMapper(
|
|
31
|
+
for (let i = 0; i < values.length; i++) {
|
|
32
|
+
const result = await promiseMapper(values[i], i);
|
|
21
33
|
results.push(result);
|
|
22
34
|
}
|
|
23
35
|
return results;
|
|
@@ -27,6 +39,121 @@ async function runInSeriesOrParallel(values, promiseMapper, runInSeries) {
|
|
|
27
39
|
}
|
|
28
40
|
}
|
|
29
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Extracts script source text and disambiguating metadata from trace rundown events,
|
|
44
|
+
* grouped by `scriptId`.
|
|
45
|
+
* @param {LH.TraceEvent[]} traceEvents
|
|
46
|
+
* @return {Map<string, TraceScript[]>}
|
|
47
|
+
*/
|
|
48
|
+
function collectTraceScripts(traceEvents) {
|
|
49
|
+
/** @type {Map<string, TraceScript>} */
|
|
50
|
+
const byIsolateAndScriptId = new Map();
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {NonNullable<LH.TraceEvent['args']['data']>} data
|
|
54
|
+
* @return {TraceScript}
|
|
55
|
+
*/
|
|
56
|
+
const getOrCreateRecord = (data) => {
|
|
57
|
+
const scriptId = String(data.scriptId);
|
|
58
|
+
const key = `${data.isolate ?? ''}.${scriptId}`;
|
|
59
|
+
let record = byIsolateAndScriptId.get(key);
|
|
60
|
+
if (!record) {
|
|
61
|
+
record = {scriptId};
|
|
62
|
+
byIsolateAndScriptId.set(key, record);
|
|
63
|
+
}
|
|
64
|
+
return record;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
for (const event of traceEvents) {
|
|
68
|
+
const data = event.args?.data;
|
|
69
|
+
if (!data || data.scriptId === undefined) continue;
|
|
70
|
+
|
|
71
|
+
if (event.cat === 'disabled-by-default-devtools.target-rundown') {
|
|
72
|
+
if (typeof data.frame === 'string') {
|
|
73
|
+
getOrCreateRecord(data).frame = data.frame;
|
|
74
|
+
}
|
|
75
|
+
} else if (event.cat === 'disabled-by-default-devtools.v8-source-rundown' &&
|
|
76
|
+
event.name === 'ScriptCatchup') {
|
|
77
|
+
const record = getOrCreateRecord(data);
|
|
78
|
+
if (typeof data.url === 'string') record.url = data.url;
|
|
79
|
+
if (typeof data.sourceUrl === 'string') record.sourceUrl = data.sourceUrl;
|
|
80
|
+
if (typeof data.executionContextId === 'number') {
|
|
81
|
+
record.executionContextId = data.executionContextId;
|
|
82
|
+
}
|
|
83
|
+
} else if (event.cat === 'disabled-by-default-devtools.v8-source-rundown-sources' &&
|
|
84
|
+
typeof data.sourceText === 'string') {
|
|
85
|
+
const record = getOrCreateRecord(data);
|
|
86
|
+
if (event.name === 'ScriptCatchup') {
|
|
87
|
+
record.sourceText = data.sourceText;
|
|
88
|
+
} else if (event.name === 'LargeScriptCatchup') {
|
|
89
|
+
if (!record.chunks || data.splitIndex === 0) record.chunks = [];
|
|
90
|
+
record.chunks.push(data.sourceText);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** @type {Map<string, TraceScript[]>} */
|
|
96
|
+
const byScriptId = new Map();
|
|
97
|
+
for (const record of byIsolateAndScriptId.values()) {
|
|
98
|
+
if (record.chunks) record.sourceText = record.chunks.join('');
|
|
99
|
+
if (record.sourceText === undefined) continue;
|
|
100
|
+
|
|
101
|
+
let list = byScriptId.get(record.scriptId);
|
|
102
|
+
if (!list) {
|
|
103
|
+
list = [];
|
|
104
|
+
byScriptId.set(record.scriptId, list);
|
|
105
|
+
}
|
|
106
|
+
list.push(record);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return byScriptId;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @param {TraceScript} traceScript
|
|
114
|
+
* @param {LH.Crdp.Debugger.ScriptParsedEvent} script
|
|
115
|
+
* @return {boolean}
|
|
116
|
+
*/
|
|
117
|
+
function matchesScriptParsedEvent(traceScript, script) {
|
|
118
|
+
const frameId = script.executionContextAuxData?.frameId;
|
|
119
|
+
if (frameId && traceScript.frame !== undefined && traceScript.frame !== frameId) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
const scriptUrl = script.embedderName || script.url;
|
|
123
|
+
if (traceScript.url !== undefined &&
|
|
124
|
+
traceScript.url !== scriptUrl &&
|
|
125
|
+
traceScript.sourceUrl !== script.url) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
if (script.executionContextId !== undefined &&
|
|
129
|
+
traceScript.executionContextId !== undefined &&
|
|
130
|
+
traceScript.executionContextId !== script.executionContextId) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @param {LH.Crdp.Debugger.ScriptParsedEvent} script
|
|
138
|
+
* @param {Map<string, TraceScript[]>} traceScriptsByScriptId
|
|
139
|
+
* @return {string|undefined}
|
|
140
|
+
*/
|
|
141
|
+
function findTraceScriptSource(script, traceScriptsByScriptId) {
|
|
142
|
+
const candidates = traceScriptsByScriptId.get(script.scriptId);
|
|
143
|
+
if (!candidates) return undefined;
|
|
144
|
+
|
|
145
|
+
const matches = candidates.filter((candidate) => matchesScriptParsedEvent(candidate, script));
|
|
146
|
+
if (matches.length === 1) return matches[0].sourceText;
|
|
147
|
+
|
|
148
|
+
const frameId = script.executionContextAuxData?.frameId;
|
|
149
|
+
if (matches.length > 1 && frameId) {
|
|
150
|
+
const frameMatches = matches.filter((candidate) => candidate.frame === frameId);
|
|
151
|
+
if (frameMatches.length === 1) return frameMatches[0].sourceText;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
|
|
30
157
|
/**
|
|
31
158
|
* Returns true if the script was created via our own calls
|
|
32
159
|
* to Runtime.evaluate.
|
|
@@ -50,18 +177,16 @@ function isLighthouseRuntimeEvaluateScript(script) {
|
|
|
50
177
|
class Scripts extends BaseGatherer {
|
|
51
178
|
static symbol = Symbol('Scripts');
|
|
52
179
|
|
|
53
|
-
/** @type {LH.Gatherer.GathererMeta} */
|
|
180
|
+
/** @type {LH.Gatherer.GathererMeta<'Trace'>} */
|
|
54
181
|
meta = {
|
|
55
182
|
symbol: Scripts.symbol,
|
|
56
183
|
supportedModes: ['timespan', 'navigation'],
|
|
184
|
+
dependencies: {Trace: Trace.symbol},
|
|
57
185
|
};
|
|
58
186
|
|
|
59
187
|
/** @type {LH.Crdp.Debugger.ScriptParsedEvent[]} */
|
|
60
188
|
_scriptParsedEvents = [];
|
|
61
189
|
|
|
62
|
-
/** @type {Array<string | undefined>} */
|
|
63
|
-
_scriptContents = [];
|
|
64
|
-
|
|
65
190
|
constructor() {
|
|
66
191
|
super();
|
|
67
192
|
this.onScriptParsed = this.onScriptParsed.bind(this);
|
|
@@ -89,26 +214,42 @@ class Scripts extends BaseGatherer {
|
|
|
89
214
|
* @param {LH.Gatherer.Context} context
|
|
90
215
|
*/
|
|
91
216
|
async stopInstrumentation(context) {
|
|
217
|
+
const session = context.driver.defaultSession;
|
|
218
|
+
session.off('Debugger.scriptParsed', this.onScriptParsed);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* @param {LH.Gatherer.Context<'Trace'>} context
|
|
223
|
+
* @return {Promise<LH.Artifacts['Scripts']>}
|
|
224
|
+
*/
|
|
225
|
+
async getArtifact(context) {
|
|
92
226
|
const session = context.driver.defaultSession;
|
|
93
227
|
const formFactor = context.baseArtifacts.HostFormFactor;
|
|
228
|
+
const traceScriptsByScriptId = collectTraceScripts(context.dependencies.Trace.traceEvents);
|
|
229
|
+
const traceSources = this._scriptParsedEvents.map(
|
|
230
|
+
(script) => findTraceScriptSource(script, traceScriptsByScriptId)
|
|
231
|
+
);
|
|
94
232
|
|
|
95
|
-
|
|
233
|
+
if (traceSources.some((source) => source === undefined)) {
|
|
234
|
+
// `disableAsyncStacks()` in `prepare.js` runs after `stopInstrumentation` and calls
|
|
235
|
+
// `Debugger.disable`, so re-enable `Debugger` if we need to call `Debugger.getScriptSource`.
|
|
236
|
+
await session.sendCommand('Debugger.enable');
|
|
237
|
+
}
|
|
96
238
|
|
|
97
239
|
// If run on a mobile device, be sensitive to memory limitations and only
|
|
98
240
|
// request one at a time.
|
|
99
|
-
|
|
241
|
+
const scriptContents = await runInSeriesOrParallel(
|
|
100
242
|
this._scriptParsedEvents,
|
|
101
|
-
(
|
|
102
|
-
return
|
|
243
|
+
(script, i) => {
|
|
244
|
+
if (traceSources[i] !== undefined) return Promise.resolve(traceSources[i]);
|
|
245
|
+
return session.sendCommand('Debugger.getScriptSource', {scriptId: script.scriptId})
|
|
103
246
|
.then((resp) => resp.scriptSource)
|
|
104
247
|
.catch(() => undefined);
|
|
105
248
|
},
|
|
106
249
|
formFactor === 'mobile' /* runInSeries */
|
|
107
250
|
);
|
|
108
251
|
await session.sendCommand('Debugger.disable');
|
|
109
|
-
}
|
|
110
252
|
|
|
111
|
-
async getArtifact() {
|
|
112
253
|
/** @type {LH.Artifacts['Scripts']} */
|
|
113
254
|
const scripts = this._scriptParsedEvents.map((event, i) => {
|
|
114
255
|
// 'embedderName' and 'url' are confusingly named, so we rewrite them here.
|
|
@@ -123,10 +264,12 @@ class Scripts extends BaseGatherer {
|
|
|
123
264
|
// embedderName is optional on the protocol because backends like Node may not set it.
|
|
124
265
|
// For our purposes, it is always set. But just in case it isn't... fallback to the url.
|
|
125
266
|
url: event.embedderName || event.url,
|
|
126
|
-
content:
|
|
267
|
+
content: scriptContents[i],
|
|
127
268
|
};
|
|
128
269
|
});
|
|
129
270
|
|
|
271
|
+
this._scriptParsedEvents = [];
|
|
272
|
+
|
|
130
273
|
return scripts;
|
|
131
274
|
}
|
|
132
275
|
}
|
|
@@ -82,6 +82,8 @@ class Stylesheets extends BaseGatherer {
|
|
|
82
82
|
|
|
83
83
|
// Ensure we finish fetching all stylesheet contents before disabling the CSS domain
|
|
84
84
|
const sheets = await Promise.all(this._sheetPromises.values());
|
|
85
|
+
this._sheetPromises.clear();
|
|
86
|
+
this._session = undefined;
|
|
85
87
|
|
|
86
88
|
await session.sendCommand('CSS.disable');
|
|
87
89
|
await session.sendCommand('DOM.disable');
|
|
@@ -21,6 +21,7 @@ import {ProcessedTrace} from '../../computed/processed-trace.js';
|
|
|
21
21
|
import {Responsiveness} from '../../computed/metrics/responsiveness.js';
|
|
22
22
|
import {CumulativeLayoutShift} from '../../computed/metrics/cumulative-layout-shift.js';
|
|
23
23
|
import {TraceEngineResult} from '../../computed/trace-engine-result.js';
|
|
24
|
+
import {Helpers} from '../../lib/trace-engine.js';
|
|
24
25
|
import SourceMaps from './source-maps.js';
|
|
25
26
|
|
|
26
27
|
/** @typedef {{nodeId: number, animations?: {name?: string, failureReasonsMask?: number, unsupportedProperties?: string[]}[], type?: string}} TraceElementData */
|
|
@@ -80,7 +81,7 @@ class TraceElements extends BaseGatherer {
|
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
if (navigationId) {
|
|
83
|
-
if (insightSet.navigation
|
|
84
|
+
if (Helpers.Trace.navigationIDForEvent(insightSet.navigation) !== navigationId) {
|
|
84
85
|
return [];
|
|
85
86
|
}
|
|
86
87
|
} else {
|
package/core/lib/cdt/Common.d.ts
CHANGED
package/core/lib/cdt/Common.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
export namespace ArrayUtilities {
|
|
2
|
+
export { lowerBound };
|
|
3
|
+
export { upperBound };
|
|
4
|
+
}
|
|
5
|
+
export namespace DevToolsPath {
|
|
6
|
+
let EmptyUrlString: string;
|
|
7
|
+
}
|
|
1
8
|
/**
|
|
2
9
|
* @license
|
|
3
10
|
* Copyright 2021 Google LLC
|
|
@@ -15,12 +22,5 @@ declare function lowerBound(array: any[], needle: any, comparator: any, left: an
|
|
|
15
22
|
* @param {any} comparator
|
|
16
23
|
*/
|
|
17
24
|
declare function upperBound(array: any[], needle: any, comparator: any, left: any, right: any): any;
|
|
18
|
-
export namespace ArrayUtilities {
|
|
19
|
-
export { lowerBound };
|
|
20
|
-
export { upperBound };
|
|
21
|
-
}
|
|
22
|
-
export namespace DevToolsPath {
|
|
23
|
-
let EmptyUrlString: string;
|
|
24
|
-
}
|
|
25
25
|
export {};
|
|
26
26
|
//# sourceMappingURL=Platform.d.ts.map
|
package/core/lib/cdt/Platform.js
CHANGED
|
@@ -46,12 +46,15 @@ function upperBound(array, needle, comparator, left, right) {
|
|
|
46
46
|
return r;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
const ArrayUtilities = {
|
|
50
|
+
lowerBound,
|
|
51
|
+
upperBound,
|
|
52
|
+
};
|
|
53
|
+
const DevToolsPath = {
|
|
54
|
+
EmptyUrlString: '',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
ArrayUtilities,
|
|
59
|
+
DevToolsPath,
|
|
57
60
|
};
|
package/core/lib/cdt/SDK.d.ts
CHANGED
package/core/lib/cdt/SDK.js
CHANGED
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import SourceMap from './generated/SourceMap.js';
|
|
8
|
+
|
|
7
9
|
const SDK = {
|
|
8
|
-
SourceMap
|
|
10
|
+
SourceMap,
|
|
9
11
|
};
|
|
10
12
|
|
|
11
13
|
// Add `lastColumnNumber` to mappings. This will eventually be added to CDT.
|
|
@@ -25,4 +27,4 @@ SDK.SourceMap.prototype.computeLastGeneratedColumns = function() {
|
|
|
25
27
|
// Now, all but the last mapping on each line will have 'lastColumnNumber' set to a number.
|
|
26
28
|
};
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
export default SDK;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// generated by yarn build-cdt-lib
|
|
3
3
|
/* eslint-disable */
|
|
4
|
-
"use strict";
|
|
5
4
|
/*
|
|
6
5
|
* Copyright (C) 2012 Google Inc. All rights reserved.
|
|
7
6
|
*
|
|
@@ -31,15 +30,11 @@
|
|
|
31
30
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
32
31
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
33
32
|
*/
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.ParsedURL = void 0;
|
|
36
|
-
exports.normalizePath = normalizePath;
|
|
37
|
-
exports.schemeIs = schemeIs;
|
|
38
33
|
;
|
|
39
34
|
/**
|
|
40
35
|
* http://tools.ietf.org/html/rfc3986#section-5.2.4
|
|
41
36
|
*/
|
|
42
|
-
function normalizePath(path) {
|
|
37
|
+
export function normalizePath(path) {
|
|
43
38
|
if (path.indexOf('..') === -1 && path.indexOf('.') === -1) {
|
|
44
39
|
return path;
|
|
45
40
|
}
|
|
@@ -69,7 +64,7 @@ function normalizePath(path) {
|
|
|
69
64
|
}
|
|
70
65
|
return normalizedPath;
|
|
71
66
|
}
|
|
72
|
-
function schemeIs(url, scheme) {
|
|
67
|
+
export function schemeIs(url, scheme) {
|
|
73
68
|
try {
|
|
74
69
|
return (new URL(url)).protocol === scheme;
|
|
75
70
|
}
|
|
@@ -77,7 +72,7 @@ function schemeIs(url, scheme) {
|
|
|
77
72
|
return false;
|
|
78
73
|
}
|
|
79
74
|
}
|
|
80
|
-
class ParsedURL {
|
|
75
|
+
export class ParsedURL {
|
|
81
76
|
isValid;
|
|
82
77
|
url;
|
|
83
78
|
scheme;
|
|
@@ -186,5 +181,4 @@ class ParsedURL {
|
|
|
186
181
|
}
|
|
187
182
|
static urlRegexInstance = null;
|
|
188
183
|
}
|
|
189
|
-
exports.ParsedURL = ParsedURL;
|
|
190
184
|
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Parses the {@link content} as JSON, ignoring BOM markers in the beginning, and
|
|
3
|
+
* also handling the CORB bypass prefix correctly.
|
|
4
|
+
*
|
|
5
|
+
* @param content the string representation of a sourcemap.
|
|
6
|
+
* @returns the {@link SourceMapV3} representation of the {@link content}.
|
|
7
|
+
*/
|
|
8
|
+
export function parseSourceMap(content: any): any;
|
|
9
|
+
export class SourceMapEntry {
|
|
10
|
+
static compare(entry1: any, entry2: any): number;
|
|
11
|
+
constructor(lineNumber: any, columnNumber: any, sourceIndex: any, sourceURL: any, sourceLineNumber: any, sourceColumnNumber: any, name: any);
|
|
12
|
+
lineNumber: any;
|
|
13
|
+
columnNumber: any;
|
|
14
|
+
sourceIndex: any;
|
|
15
|
+
sourceURL: any;
|
|
16
|
+
sourceLineNumber: any;
|
|
17
|
+
sourceColumnNumber: any;
|
|
18
|
+
name: any;
|
|
19
|
+
}
|
|
20
|
+
export class SourceMap {
|
|
3
21
|
/**
|
|
4
22
|
* @param {string} compiledURL
|
|
5
23
|
* @param {string} sourceMappingURL
|
|
@@ -76,30 +94,10 @@ declare class SourceMap {
|
|
|
76
94
|
findOriginalFunctionName(position: any): any;
|
|
77
95
|
#private;
|
|
78
96
|
}
|
|
79
|
-
|
|
80
|
-
export { parseSourceMap
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Parses the {@link content} as JSON, ignoring BOM markers in the beginning, and
|
|
84
|
-
* also handling the CORB bypass prefix correctly.
|
|
85
|
-
*
|
|
86
|
-
* @param content the string representation of a sourcemap.
|
|
87
|
-
* @returns the {@link SourceMapV3} representation of the {@link content}.
|
|
88
|
-
*/
|
|
89
|
-
declare function parseSourceMap(content: any): any;
|
|
90
|
-
declare const __esModule: boolean;
|
|
91
|
-
declare class SourceMapEntry {
|
|
92
|
-
static compare(entry1: any, entry2: any): number;
|
|
93
|
-
constructor(lineNumber: any, columnNumber: any, sourceIndex: any, sourceURL: any, sourceLineNumber: any, sourceColumnNumber: any, name: any);
|
|
94
|
-
lineNumber: any;
|
|
95
|
-
columnNumber: any;
|
|
96
|
-
sourceIndex: any;
|
|
97
|
-
sourceURL: any;
|
|
98
|
-
sourceLineNumber: any;
|
|
99
|
-
sourceColumnNumber: any;
|
|
100
|
-
name: any;
|
|
97
|
+
export namespace SourceMap {
|
|
98
|
+
export { parseSourceMap };
|
|
101
99
|
}
|
|
102
|
-
|
|
100
|
+
export class TokenIterator {
|
|
103
101
|
constructor(string: any);
|
|
104
102
|
next(): any;
|
|
105
103
|
/** Returns the unicode value of the next character and advances the iterator */
|
|
@@ -114,4 +112,5 @@ declare class TokenIterator {
|
|
|
114
112
|
peekVLQ(): number | null;
|
|
115
113
|
#private;
|
|
116
114
|
}
|
|
115
|
+
export default SourceMap;
|
|
117
116
|
//# sourceMappingURL=SourceMap.d.ts.map
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// generated by yarn build-cdt-lib
|
|
3
3
|
/* eslint-disable */
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const Platform = require('../Platform.js');
|
|
4
|
+
import * as Common from '../Common.js';
|
|
5
|
+
import * as Platform from '../Platform.js';
|
|
7
6
|
|
|
8
7
|
const BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
9
8
|
const BASE64_CODES = new Uint8Array(123);
|
|
@@ -14,9 +13,6 @@ const Platform = require('../Platform.js');
|
|
|
14
13
|
// Copyright 2021 The Chromium Authors. All rights reserved.
|
|
15
14
|
// Use of this source code is governed by a BSD-style license that can be
|
|
16
15
|
// found in the LICENSE file.
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.TokenIterator = exports.SourceMap = exports.SourceMapEntry = void 0;
|
|
19
|
-
exports.parseSourceMap = parseSourceMap;
|
|
20
16
|
/*
|
|
21
17
|
* Copyright (C) 2012 Google Inc. All rights reserved.
|
|
22
18
|
*
|
|
@@ -59,7 +55,7 @@ exports.parseSourceMap = parseSourceMap;
|
|
|
59
55
|
* @param content the string representation of a sourcemap.
|
|
60
56
|
* @returns the {@link SourceMapV3} representation of the {@link content}.
|
|
61
57
|
*/
|
|
62
|
-
function parseSourceMap(content) {
|
|
58
|
+
export function parseSourceMap(content) {
|
|
63
59
|
if (content.startsWith(')]}')) {
|
|
64
60
|
content = content.substring(content.indexOf('\n'));
|
|
65
61
|
}
|
|
@@ -69,7 +65,7 @@ function parseSourceMap(content) {
|
|
|
69
65
|
}
|
|
70
66
|
return JSON.parse(content);
|
|
71
67
|
}
|
|
72
|
-
class SourceMapEntry {
|
|
68
|
+
export class SourceMapEntry {
|
|
73
69
|
lineNumber;
|
|
74
70
|
columnNumber;
|
|
75
71
|
sourceIndex;
|
|
@@ -93,8 +89,7 @@ class SourceMapEntry {
|
|
|
93
89
|
return entry1.columnNumber - entry2.columnNumber;
|
|
94
90
|
}
|
|
95
91
|
}
|
|
96
|
-
|
|
97
|
-
class SourceMap {
|
|
92
|
+
export class SourceMap {
|
|
98
93
|
#json;
|
|
99
94
|
#compiledURLInternal;
|
|
100
95
|
#sourceMappingURL;
|
|
@@ -502,11 +497,10 @@ class SourceMap {
|
|
|
502
497
|
return this.#scopesInfo?.findOriginalFunctionName(position) ?? null;
|
|
503
498
|
}
|
|
504
499
|
}
|
|
505
|
-
exports.SourceMap = SourceMap;
|
|
506
500
|
const VLQ_BASE_SHIFT = 5;
|
|
507
501
|
const VLQ_BASE_MASK = (1 << 5) - 1;
|
|
508
502
|
const VLQ_CONTINUATION_MASK = 1 << 5;
|
|
509
|
-
class TokenIterator {
|
|
503
|
+
export class TokenIterator {
|
|
510
504
|
#string;
|
|
511
505
|
#position;
|
|
512
506
|
constructor(string) {
|
|
@@ -565,8 +559,6 @@ class TokenIterator {
|
|
|
565
559
|
}
|
|
566
560
|
}
|
|
567
561
|
}
|
|
568
|
-
exports.TokenIterator = TokenIterator;
|
|
569
562
|
|
|
570
|
-
|
|
571
|
-
module.exports = SourceMap;
|
|
563
|
+
export default SourceMap;
|
|
572
564
|
SourceMap.parseSourceMap = parseSourceMap;
|
package/core/lib/i18n/i18n.d.ts
CHANGED
package/core/lib/i18n/i18n.js
CHANGED
|
@@ -4,18 +4,14 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
/** @typedef {import('../../../shared/localization/locales').LhlMessages} LhlMessages */
|
|
8
|
-
|
|
9
7
|
import path from 'path';
|
|
10
8
|
import url from 'url';
|
|
11
9
|
|
|
12
|
-
import lookupClosestLocale from 'lookup-closest-locale';
|
|
13
10
|
import log from 'lighthouse-logger';
|
|
14
11
|
|
|
15
12
|
import {getAvailableLocales} from '../../../shared/localization/format.js';
|
|
16
13
|
import {LH_ROOT} from '../../../shared/root.js';
|
|
17
14
|
import {isIcuMessage, formatMessage, DEFAULT_LOCALE} from '../../../shared/localization/format.js';
|
|
18
|
-
import {getModulePath} from '../../../shared/esm-utils.js';
|
|
19
15
|
|
|
20
16
|
const UIStrings = {
|
|
21
17
|
/** Used to show the duration in milliseconds that something lasted. The `{timeInMs}` placeholder will be replaced with the time duration, shown in milliseconds (e.g. 63 ms) */
|
|
@@ -145,12 +141,22 @@ function lookupLocale(locales, possibleLocales) {
|
|
|
145
141
|
// Filter by what's available in this runtime.
|
|
146
142
|
const availableLocales = Intl.NumberFormat.supportedLocalesOf(canonicalLocales);
|
|
147
143
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
144
|
+
const localesWithMessages = new Set(possibleLocales || getAvailableLocales());
|
|
145
|
+
|
|
146
|
+
/** @type {LH.Locale|undefined} */
|
|
147
|
+
let closestLocale;
|
|
148
|
+
for (const locale of availableLocales) {
|
|
149
|
+
const parts = locale.split('-');
|
|
150
|
+
while (parts.length) {
|
|
151
|
+
const candidate = /** @type {LH.Locale} */ (parts.join('-'));
|
|
152
|
+
if (localesWithMessages.has(candidate)) {
|
|
153
|
+
closestLocale = candidate;
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
parts.pop();
|
|
157
|
+
}
|
|
158
|
+
if (closestLocale) break;
|
|
159
|
+
}
|
|
154
160
|
|
|
155
161
|
if (!closestLocale) {
|
|
156
162
|
// Log extra info if we're pretty sure this version of Node was built with `--with-intl=small-icu`.
|
|
@@ -198,7 +204,7 @@ function createIcuMessageFn(filename, fileStrings = {}) {
|
|
|
198
204
|
// one of the common strings found in `i18n.UIStrings`.
|
|
199
205
|
const filenameToLookup = keyname in fileStrings ?
|
|
200
206
|
filename :
|
|
201
|
-
path.relative(LH_ROOT,
|
|
207
|
+
path.relative(LH_ROOT, import.meta.filename);
|
|
202
208
|
const unixStyleFilename = filenameToLookup.replace(/\\/g, '/');
|
|
203
209
|
const i18nId = `${unixStyleFilename} | ${keyname}`;
|
|
204
210
|
|
|
@@ -15,10 +15,10 @@ export type Result = {
|
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
17
|
* @param {string} content
|
|
18
|
-
* @param {import('../cdt/generated/SourceMap.js')|null} map
|
|
18
|
+
* @param {import('../cdt/generated/SourceMap.js').default|null} map
|
|
19
19
|
* @return {Result}
|
|
20
20
|
*/
|
|
21
|
-
export function detectLegacyJavaScript(content: string, map: import("../cdt/generated/SourceMap.js") | null): Result;
|
|
21
|
+
export function detectLegacyJavaScript(content: string, map: import("../cdt/generated/SourceMap.js").default | null): Result;
|
|
22
22
|
/**
|
|
23
23
|
* @return {Pattern[]}
|
|
24
24
|
*/
|
|
@@ -401,7 +401,7 @@ const matcher = new CodePatternMatcher([
|
|
|
401
401
|
|
|
402
402
|
/**
|
|
403
403
|
* @param {string} content
|
|
404
|
-
* @param {import('../cdt/generated/SourceMap.js')|null} map
|
|
404
|
+
* @param {import('../cdt/generated/SourceMap.js').default|null} map
|
|
405
405
|
* @return {Result}
|
|
406
406
|
*/
|
|
407
407
|
function detectLegacyJavaScript(content, map) {
|
package/core/lib/sentry.d.ts
CHANGED
package/core/lib/sentry.js
CHANGED
|
@@ -32,6 +32,8 @@ const sentryDelegate = {
|
|
|
32
32
|
captureBreadcrumb: noop,
|
|
33
33
|
/** @type {() => any} */
|
|
34
34
|
getContext: noop,
|
|
35
|
+
/** @type {(name: string, context: {[key: string]: any} | null) => void} */
|
|
36
|
+
setContext: noop,
|
|
35
37
|
/** @type {(error: Error, options: {level?: string, tags?: {[key: string]: any}, extra?: {[key: string]: any}}) => Promise<void>} */
|
|
36
38
|
captureException: async () => { },
|
|
37
39
|
_shouldSample() {
|
|
@@ -88,6 +90,7 @@ async function init(opts) {
|
|
|
88
90
|
sentryDelegate.captureMessage = (...args) => Sentry.captureMessage(...args);
|
|
89
91
|
sentryDelegate.captureBreadcrumb = (...args) => Sentry.addBreadcrumb(...args);
|
|
90
92
|
sentryDelegate.getContext = () => extras;
|
|
93
|
+
sentryDelegate.setContext = (...args) => Sentry.setContext(...args);
|
|
91
94
|
|
|
92
95
|
// Keep a record of exceptions per audit/gatherer so we can just report once
|
|
93
96
|
const sentryExceptionCache = new Map();
|