chrome-devtools-frontend 1.0.1014346 → 1.0.1014853
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/.eslintignore +1 -0
- package/front_end/core/sdk/SourceMap.ts +88 -27
- package/front_end/models/javascript_metadata/DOMPinnedProperties.ts +3322 -833
- package/front_end/models/source_map_scopes/NamesResolver.ts +88 -19
- package/package.json +1 -1
- package/scripts/webidl-properties/config.js +305 -239
- package/scripts/webidl-properties/get-props.js +23 -12
- package/scripts/webidl-properties/index.js +14 -9
- package/scripts/webidl-properties/tests.js +58 -14
package/.eslintignore
CHANGED
@@ -7,6 +7,7 @@ front_end/.eslintrc.js
|
|
7
7
|
front_end/diff/diff_match_patch.js
|
8
8
|
front_end/generated/protocol.ts
|
9
9
|
front_end/javascript_metadata/NativeFunctions.js
|
10
|
+
front_end/javascript_metadata/DOMPinnedProperties.ts
|
10
11
|
front_end/third_party/
|
11
12
|
node_modules
|
12
13
|
scripts/migration/**/*.js
|
@@ -66,6 +66,11 @@ export interface SourceMap {
|
|
66
66
|
TextUtils.ContentProvider.ContentProvider;
|
67
67
|
embeddedContentByURL(sourceURL: Platform.DevToolsPath.UrlString): string|null;
|
68
68
|
findEntry(lineNumber: number, columnNumber: number): SourceMapEntry|null;
|
69
|
+
findEntryRanges(lineNumber: number, columnNumber: number): {
|
70
|
+
range: TextUtils.TextRange.TextRange,
|
71
|
+
sourceRange: TextUtils.TextRange.TextRange,
|
72
|
+
sourceURL: Platform.DevToolsPath.UrlString,
|
73
|
+
}|null;
|
69
74
|
findReverseRanges(sourceURL: Platform.DevToolsPath.UrlString, lineNumber: number, columnNumber: number):
|
70
75
|
TextUtils.TextRange.TextRange[];
|
71
76
|
sourceLineMapping(sourceURL: Platform.DevToolsPath.UrlString, lineNumber: number, columnNumber: number):
|
@@ -233,6 +238,52 @@ export class TextSourceMap implements SourceMap {
|
|
233
238
|
return index ? mappings[index - 1] : null;
|
234
239
|
}
|
235
240
|
|
241
|
+
findEntryRanges(lineNumber: number, columnNumber: number): {
|
242
|
+
range: TextUtils.TextRange.TextRange,
|
243
|
+
sourceRange: TextUtils.TextRange.TextRange,
|
244
|
+
sourceURL: Platform.DevToolsPath.UrlString,
|
245
|
+
}|null {
|
246
|
+
const mappings = this.mappings();
|
247
|
+
const index = Platform.ArrayUtilities.upperBound(
|
248
|
+
mappings, undefined, (unused, entry) => lineNumber - entry.lineNumber || columnNumber - entry.columnNumber);
|
249
|
+
if (!index) {
|
250
|
+
// If the line and column are preceding all the entries, then there is nothing to map.
|
251
|
+
return null;
|
252
|
+
}
|
253
|
+
const sourceURL = mappings[index].sourceURL;
|
254
|
+
if (!sourceURL) {
|
255
|
+
return null;
|
256
|
+
}
|
257
|
+
|
258
|
+
// Let us compute the range that contains the source position in the compiled code.
|
259
|
+
const endLine = index < mappings.length ? mappings[index].lineNumber : 2 ** 31 - 1;
|
260
|
+
const endColumn = index < mappings.length ? mappings[index].columnNumber : 2 ** 31 - 1;
|
261
|
+
const range = new TextUtils.TextRange.TextRange(
|
262
|
+
mappings[index - 1].lineNumber, mappings[index - 1].columnNumber, endLine, endColumn);
|
263
|
+
|
264
|
+
// Now try to find the corresponding token in the original code.
|
265
|
+
const reverseMappings = this.reversedMappings(sourceURL);
|
266
|
+
const startSourceLine = mappings[index - 1].sourceLineNumber;
|
267
|
+
const startSourceColumn = mappings[index - 1].sourceColumnNumber;
|
268
|
+
const endReverseIndex = Platform.ArrayUtilities.upperBound(
|
269
|
+
reverseMappings, undefined,
|
270
|
+
(unused, i) =>
|
271
|
+
startSourceLine - mappings[i].sourceLineNumber || startSourceColumn - mappings[i].sourceColumnNumber);
|
272
|
+
if (!endReverseIndex) {
|
273
|
+
return null;
|
274
|
+
}
|
275
|
+
const endSourceLine = endReverseIndex < reverseMappings.length ?
|
276
|
+
mappings[reverseMappings[endReverseIndex]].sourceLineNumber :
|
277
|
+
2 ** 31 - 1;
|
278
|
+
const endSourceColumn = endReverseIndex < reverseMappings.length ?
|
279
|
+
mappings[reverseMappings[endReverseIndex]].sourceColumnNumber :
|
280
|
+
2 ** 31 - 1;
|
281
|
+
|
282
|
+
const sourceRange =
|
283
|
+
new TextUtils.TextRange.TextRange(startSourceLine, startSourceColumn, endSourceLine, endSourceColumn);
|
284
|
+
return {range, sourceRange, sourceURL};
|
285
|
+
}
|
286
|
+
|
236
287
|
sourceLineMapping(sourceURL: Platform.DevToolsPath.UrlString, lineNumber: number, columnNumber: number):
|
237
288
|
SourceMapEntry|null {
|
238
289
|
const mappings = this.mappings();
|
@@ -315,42 +366,53 @@ export class TextSourceMap implements SourceMap {
|
|
315
366
|
}
|
316
367
|
|
317
368
|
mappings(): SourceMapEntry[] {
|
369
|
+
this.#ensureMappingsProcessed();
|
370
|
+
return this.#mappingsInternal ?? [];
|
371
|
+
}
|
372
|
+
|
373
|
+
private reversedMappings(sourceURL: Platform.DevToolsPath.UrlString): number[] {
|
374
|
+
this.#ensureMappingsProcessed();
|
375
|
+
return this.#sourceInfos.get(sourceURL)?.reverseMappings ?? [];
|
376
|
+
}
|
377
|
+
|
378
|
+
#ensureMappingsProcessed(): void {
|
318
379
|
if (this.#mappingsInternal === null) {
|
319
380
|
this.#mappingsInternal = [];
|
320
381
|
this.eachSection(this.parseMap.bind(this));
|
382
|
+
this.#computeReverseMappings(this.#mappingsInternal);
|
321
383
|
this.#json = null;
|
322
384
|
}
|
323
|
-
return this.#mappingsInternal;
|
324
385
|
}
|
325
386
|
|
326
|
-
|
327
|
-
const
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
387
|
+
#computeReverseMappings(mappings: SourceMapEntry[]): void {
|
388
|
+
const reverseMappingsPerUrl = new Map<Platform.DevToolsPath.UrlString, number[]>();
|
389
|
+
for (let i = 0; i < mappings.length; i++) {
|
390
|
+
const entryUrl = mappings[i].sourceURL;
|
391
|
+
if (!entryUrl) {
|
392
|
+
continue;
|
393
|
+
}
|
394
|
+
let reverseMap = reverseMappingsPerUrl.get(entryUrl);
|
395
|
+
if (!reverseMap) {
|
396
|
+
reverseMap = [];
|
397
|
+
reverseMappingsPerUrl.set(entryUrl, reverseMap);
|
398
|
+
}
|
399
|
+
reverseMap.push(i);
|
335
400
|
}
|
336
401
|
|
337
|
-
|
402
|
+
for (const [url, reverseMap] of reverseMappingsPerUrl.entries()) {
|
403
|
+
const info = this.#sourceInfos.get(url);
|
404
|
+
if (!info) {
|
405
|
+
continue;
|
406
|
+
}
|
407
|
+
reverseMap.sort(sourceMappingComparator);
|
408
|
+
info.reverseMappings = reverseMap;
|
409
|
+
}
|
338
410
|
|
339
411
|
function sourceMappingComparator(indexA: number, indexB: number): number {
|
340
412
|
const a = mappings[indexA];
|
341
413
|
const b = mappings[indexB];
|
342
|
-
|
343
|
-
|
344
|
-
}
|
345
|
-
if (a.sourceColumnNumber !== b.sourceColumnNumber) {
|
346
|
-
return a.sourceColumnNumber - b.sourceColumnNumber;
|
347
|
-
}
|
348
|
-
|
349
|
-
if (a.lineNumber !== b.lineNumber) {
|
350
|
-
return a.lineNumber - b.lineNumber;
|
351
|
-
}
|
352
|
-
|
353
|
-
return a.columnNumber - b.columnNumber;
|
414
|
+
return a.sourceLineNumber - b.sourceLineNumber || a.sourceColumnNumber - b.sourceColumnNumber ||
|
415
|
+
a.lineNumber - b.lineNumber || a.columnNumber - b.columnNumber;
|
354
416
|
}
|
355
417
|
}
|
356
418
|
|
@@ -392,7 +454,7 @@ export class TextSourceMap implements SourceMap {
|
|
392
454
|
if (this.#sourceInfos.has(url)) {
|
393
455
|
continue;
|
394
456
|
}
|
395
|
-
this.#sourceInfos.set(url, new TextSourceMap.SourceInfo(source
|
457
|
+
this.#sourceInfos.set(url, new TextSourceMap.SourceInfo(source ?? null));
|
396
458
|
sourcesList.push(url);
|
397
459
|
}
|
398
460
|
sourceMapToSourceList.set(sourceMap, sourcesList);
|
@@ -560,11 +622,10 @@ export namespace TextSourceMap {
|
|
560
622
|
|
561
623
|
export class SourceInfo {
|
562
624
|
content: string|null;
|
563
|
-
reverseMappings: number[]|null;
|
625
|
+
reverseMappings: number[]|null = null;
|
564
626
|
|
565
|
-
constructor(content: string|null
|
627
|
+
constructor(content: string|null) {
|
566
628
|
this.content = content;
|
567
|
-
this.reverseMappings = reverseMappings;
|
568
629
|
}
|
569
630
|
}
|
570
631
|
}
|