MCPcopy Create free account
hub / github.com/Snapchat/Valdi / _onScriptParsed

Method _onScriptParsed

valdi/vscode_debugger/src/adapter/threads.ts:1146–1225  ·  view source on GitHub ↗
(event: Cdp.Debugger.ScriptParsedEvent)

Source from the content-addressed store, hash-verified

1144 }
1145
1146 private _onScriptParsed(event: Cdp.Debugger.ScriptParsedEvent) {
1147 if (this._sourceContainer.scriptsById.has(event.scriptId)) {
1148 return;
1149 }
1150
1151 if (event.url) event.url = this._delegate.scriptUrlToUrl(event.url);
1152
1153 let urlHashMap = this._scriptSources.get(event.url);
1154 if (!urlHashMap) {
1155 urlHashMap = new Map();
1156 this._scriptSources.set(event.url, urlHashMap);
1157 }
1158
1159 const createSource = async () => {
1160 const prevSource = event.url && event.hash && urlHashMap && urlHashMap.get(event.hash);
1161 if (prevSource) {
1162 prevSource.addScriptId(event.scriptId);
1163 return prevSource;
1164 }
1165
1166 const contentGetter = async () => {
1167 const response = await this._cdp.Debugger.getScriptSource({ scriptId: event.scriptId });
1168 return response ? response.scriptSource : undefined;
1169 };
1170 const inlineSourceOffset =
1171 event.startLine || event.startColumn
1172 ? { lineOffset: event.startLine, columnOffset: event.startColumn }
1173 : undefined;
1174 let resolvedSourceMapUrl: string | undefined;
1175 if (event.sourceMapURL && this.launchConfig.sourceMaps) {
1176 // Note: we should in theory refetch source maps with relative urls, if the base url has changed,
1177 // but in practice that usually means new scripts with new source maps anyway.
1178 resolvedSourceMapUrl = urlUtils.isDataUri(event.sourceMapURL)
1179 ? event.sourceMapURL
1180 : event.url && urlUtils.completeUrl(event.url, event.sourceMapURL);
1181 if (!resolvedSourceMapUrl) {
1182 this._dap.with(dap =>
1183 errors.reportToConsole(dap, `Could not load source map from ${event.sourceMapURL}`),
1184 );
1185 }
1186 }
1187
1188 const hash = this._delegate.shouldCheckContentHash() ? event.hash : undefined;
1189 const source = await this._sourceContainer.addSource(
1190 event.url,
1191 contentGetter,
1192 resolvedSourceMapUrl,
1193 inlineSourceOffset,
1194 hash,
1195 );
1196 this._sourceContainer.scriptSkipper.initializeSkippingValueForSource(source, event.scriptId);
1197 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1198 urlHashMap!.set(event.hash, source);
1199 source.addScriptId(event.scriptId);
1200
1201 let scriptSet = this._sourceScripts.get(source);
1202 if (!scriptSet) {
1203 scriptSet = new Set();

Callers 1

_initializeMethod · 0.95

Calls 5

hasMethod · 0.65
scriptUrlToUrlMethod · 0.65
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected