| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 if (!SDK.TextSourceMap._base64Map) { | 196 if (!SDK.TextSourceMap._base64Map) { |
| 197 const base64Digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
0123456789+/'; | 197 const base64Digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
0123456789+/'; |
| 198 SDK.TextSourceMap._base64Map = {}; | 198 SDK.TextSourceMap._base64Map = {}; |
| 199 for (var i = 0; i < base64Digits.length; ++i) | 199 for (var i = 0; i < base64Digits.length; ++i) |
| 200 SDK.TextSourceMap._base64Map[base64Digits.charAt(i)] = i; | 200 SDK.TextSourceMap._base64Map[base64Digits.charAt(i)] = i; |
| 201 } | 201 } |
| 202 | 202 |
| 203 this._json = payload; | 203 this._json = payload; |
| 204 this._compiledURL = compiledURL; | 204 this._compiledURL = compiledURL; |
| 205 this._sourceMappingURL = sourceMappingURL; | 205 this._sourceMappingURL = sourceMappingURL; |
| 206 this._baseURL = sourceMappingURL.startsWith('data:') ? compiledURL : sourceM
appingURL; |
| 207 |
| 206 /** @type {?Array<!SDK.SourceMapEntry>} */ | 208 /** @type {?Array<!SDK.SourceMapEntry>} */ |
| 207 this._mappings = null; | 209 this._mappings = null; |
| 208 /** @type {!Map<string, !SDK.TextSourceMap.SourceInfo>} */ | 210 /** @type {!Map<string, !SDK.TextSourceMap.SourceInfo>} */ |
| 209 this._sourceInfos = new Map(); | 211 this._sourceInfos = new Map(); |
| 210 this._eachSection(this._parseSources.bind(this)); | 212 this._eachSection(this._parseSources.bind(this)); |
| 211 } | 213 } |
| 212 | 214 |
| 213 /** | 215 /** |
| 214 * @param {string} sourceMapURL | 216 * @param {string} sourceMapURL |
| 215 * @param {string} compiledURL | 217 * @param {string} compiledURL |
| (...skipping 14 matching lines...) Expand all Loading... |
| 230 function contentLoaded(statusCode, headers, content) { | 232 function contentLoaded(statusCode, headers, content) { |
| 231 if (!content || statusCode >= 400) { | 233 if (!content || statusCode >= 400) { |
| 232 callback(null); | 234 callback(null); |
| 233 return; | 235 return; |
| 234 } | 236 } |
| 235 | 237 |
| 236 if (content.slice(0, 3) === ')]}') | 238 if (content.slice(0, 3) === ')]}') |
| 237 content = content.substring(content.indexOf('\n')); | 239 content = content.substring(content.indexOf('\n')); |
| 238 try { | 240 try { |
| 239 var payload = /** @type {!SDK.SourceMapV3} */ (JSON.parse(content)); | 241 var payload = /** @type {!SDK.SourceMapV3} */ (JSON.parse(content)); |
| 240 var baseURL = sourceMapURL.startsWith('data:') ? compiledURL : sourceMap
URL; | 242 callback(new SDK.TextSourceMap(compiledURL, sourceMapURL, payload)); |
| 241 callback(new SDK.TextSourceMap(compiledURL, baseURL, payload)); | |
| 242 } catch (e) { | 243 } catch (e) { |
| 243 console.error(e); | 244 console.error(e); |
| 244 Common.console.warn('DevTools failed to parse SourceMap: ' + sourceMapUR
L); | 245 Common.console.warn('DevTools failed to parse SourceMap: ' + sourceMapUR
L); |
| 245 callback(null); | 246 callback(null); |
| 246 } | 247 } |
| 247 } | 248 } |
| 248 } | 249 } |
| 249 | 250 |
| 250 /** | 251 /** |
| 251 * @override | 252 * @override |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 /** | 426 /** |
| 426 * @param {!SDK.SourceMapV3} sourceMap | 427 * @param {!SDK.SourceMapV3} sourceMap |
| 427 */ | 428 */ |
| 428 _parseSources(sourceMap) { | 429 _parseSources(sourceMap) { |
| 429 var sourcesList = []; | 430 var sourcesList = []; |
| 430 var sourceRoot = sourceMap.sourceRoot || ''; | 431 var sourceRoot = sourceMap.sourceRoot || ''; |
| 431 if (sourceRoot && !sourceRoot.endsWith('/')) | 432 if (sourceRoot && !sourceRoot.endsWith('/')) |
| 432 sourceRoot += '/'; | 433 sourceRoot += '/'; |
| 433 for (var i = 0; i < sourceMap.sources.length; ++i) { | 434 for (var i = 0; i < sourceMap.sources.length; ++i) { |
| 434 var href = sourceRoot + sourceMap.sources[i]; | 435 var href = sourceRoot + sourceMap.sources[i]; |
| 435 var url = Common.ParsedURL.completeURL(this._sourceMappingURL, href) || hr
ef; | 436 var url = Common.ParsedURL.completeURL(this._baseURL, href) || href; |
| 436 var source = sourceMap.sourcesContent && sourceMap.sourcesContent[i]; | 437 var source = sourceMap.sourcesContent && sourceMap.sourcesContent[i]; |
| 437 if (url === this._compiledURL && source) | 438 if (url === this._compiledURL && source) |
| 438 url += Common.UIString('? [sm]'); | 439 url += Common.UIString('? [sm]'); |
| 439 this._sourceInfos.set(url, new SDK.TextSourceMap.SourceInfo(source, null))
; | 440 this._sourceInfos.set(url, new SDK.TextSourceMap.SourceInfo(source, null))
; |
| 440 sourcesList.push(url); | 441 sourcesList.push(url); |
| 441 } | 442 } |
| 442 sourceMap[SDK.TextSourceMap._sourcesListSymbol] = sourcesList; | 443 sourceMap[SDK.TextSourceMap._sourcesListSymbol] = sourcesList; |
| 443 } | 444 } |
| 444 | 445 |
| 445 /** | 446 /** |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 * @param {?string} content | 605 * @param {?string} content |
| 605 * @param {?Array<!SDK.SourceMapEntry>} reverseMappings | 606 * @param {?Array<!SDK.SourceMapEntry>} reverseMappings |
| 606 */ | 607 */ |
| 607 constructor(content, reverseMappings) { | 608 constructor(content, reverseMappings) { |
| 608 this.content = content; | 609 this.content = content; |
| 609 this.reverseMappings = reverseMappings; | 610 this.reverseMappings = reverseMappings; |
| 610 } | 611 } |
| 611 }; | 612 }; |
| 612 | 613 |
| 613 SDK.TextSourceMap._sourcesListSymbol = Symbol('sourcesList'); | 614 SDK.TextSourceMap._sourcesListSymbol = Symbol('sourcesList'); |
| OLD | NEW |