MCPcopy Create free account
hub / github.com/ChromeDevTools/devtools-frontend / parseSources

Method parseSources

front_end/core/sdk/SourceMap.ts:502–533  ·  view source on GitHub ↗
(sourceMap: SourceMapV3Object)

Source from the content-addressed store, hash-verified

500 }
501
502 private parseSources(sourceMap: SourceMapV3Object): void {
503 const sourceRoot = sourceMap.sourceRoot ?? '';
504 const ignoreList = new Set(sourceMap.ignoreList ?? sourceMap.x_google_ignoreList);
505 for (let i = 0; i < sourceMap.sources.length; ++i) {
506 let href = sourceMap.sources[i];
507 // The source map v3 proposal says to prepend the sourceRoot to the source URL
508 // and if the resulting URL is not absolute, then resolve the source URL against
509 // the source map URL. Prepending the sourceRoot (if one exists) is not likely to
510 // be meaningful or useful if the source URL is already absolute though. In this
511 // case, use the source URL as is without prepending the sourceRoot.
512 if (Common.ParsedURL.ParsedURL.isRelativeURL(href)) {
513 if (sourceRoot && !sourceRoot.endsWith('/') && href && !href.startsWith('/')) {
514 href = sourceRoot.concat('/', href);
515 } else {
516 href = sourceRoot.concat(href);
517 }
518 }
519 const url =
520 Common.ParsedURL.ParsedURL.completeURL(this.#baseURL, href) || (href as Platform.DevToolsPath.UrlString);
521 const source = sourceMap.sourcesContent?.[i];
522 const sourceInfo: SourceInfo = {
523 sourceURL: url,
524 content: source ?? null,
525 ignoreListHint: ignoreList.has(i),
526 reverseMappings: null,
527 };
528 this.#sourceInfos.push(sourceInfo);
529 if (!this.#sourceInfoByURL.has(url)) {
530 this.#sourceInfoByURL.set(url, sourceInfo);
531 }
532 }
533 }
534
535 private parseMap(map: SourceMapV3Object, baseSourceIndex: number, baseLineNumber: number, baseColumnNumber: number):
536 void {

Callers

nothing calls this directly

Calls 5

isRelativeURLMethod · 0.80
setMethod · 0.65
completeURLMethod · 0.45
hasMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected