* Adds a new source to the collection.
(
event: Cdp.Debugger.ScriptParsedEvent,
contentGetter: ContentGetter,
sourceMapUrl?: string,
inlineSourceRange?: InlineScriptOffset,
runtimeScriptOffset?: InlineScriptOffset,
contentHash?: string,
)
| 617 | * Adds a new source to the collection. |
| 618 | */ |
| 619 | public async addSource( |
| 620 | event: Cdp.Debugger.ScriptParsedEvent, |
| 621 | contentGetter: ContentGetter, |
| 622 | sourceMapUrl?: string, |
| 623 | inlineSourceRange?: InlineScriptOffset, |
| 624 | runtimeScriptOffset?: InlineScriptOffset, |
| 625 | contentHash?: string, |
| 626 | ): Promise<Source> { |
| 627 | const absolutePath = await this.sourcePathResolver.urlToAbsolutePath({ url: event.url }); |
| 628 | |
| 629 | this.logger.verbose(LogTag.RuntimeSourceCreate, 'Creating source from url', { |
| 630 | inputUrl: event.url, |
| 631 | absolutePath, |
| 632 | }); |
| 633 | |
| 634 | let source: Source; |
| 635 | if (event.scriptLanguage === 'WebAssembly') { |
| 636 | source = new WasmSource(this, event, absolutePath); |
| 637 | } else { |
| 638 | source = new Source( |
| 639 | this, |
| 640 | event.url, |
| 641 | absolutePath, |
| 642 | contentGetter, |
| 643 | sourceMapUrl |
| 644 | && this.sourcePathResolver.shouldResolveSourceMap({ |
| 645 | sourceMapUrl, |
| 646 | compiledPath: absolutePath || event.url, |
| 647 | }) |
| 648 | ? { |
| 649 | sourceMapUrl, |
| 650 | compiledPath: absolutePath || event.url, |
| 651 | cacheKey: event.hash, |
| 652 | } |
| 653 | : undefined, |
| 654 | inlineSourceRange, |
| 655 | runtimeScriptOffset, |
| 656 | contentHash, |
| 657 | ); |
| 658 | } |
| 659 | |
| 660 | this._addSource(source); |
| 661 | return source; |
| 662 | } |
| 663 | |
| 664 | private async _addSource(source: Source) { |
| 665 | // todo: we should allow the same source at multiple uri's if their scripts |
no test coverage detected