Skip to content

Commit

Permalink
update frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Dec 11, 2019
1 parent 5d17268 commit 6480198
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 19 deletions.
9 changes: 6 additions & 3 deletions build/build-cdt-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const fs = require('fs');
const outDir = `${__dirname}/../lighthouse-core/lib/cdt/generated`;
const files = {
'node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js': 'SourceMap.js',
}
};

// eslint-disable-next-line no-console
console.log('making modifications ...');
Expand All @@ -36,13 +36,15 @@ for (const [input, output] of Object.entries(files)) {
if (line.includes('static load(')) deletionMode = true;
if (line.includes('sourceContentProvider(')) deletionMode = true;
if (line.includes('Common.UIString')) newLine = '';
if (line.includes('export class WasmSourceMap')) deletionMode = true;
if (line.includes('WasmSourceMap')) newLine = '';
if (line.includes('export class EditResult')) deletionMode = true;
newLine = newLine.replace(`Common.ParsedURL.completeURL(this._baseURL, href)`, `''`);
}

if (deletionMode) {
if (line.trim().endsWith('{')) deletionCounter += 1;
if (line.trim().startsWith('}')) deletionCounter -= 1;
console.log(line.trim(), deletionCounter);
if (deletionCounter >= 0) {
newLine = '';
// newLine = newLine.trim() + ` /* hi ${deletionCounter} */\n`;
Expand All @@ -60,7 +62,8 @@ for (const [input, output] of Object.entries(files)) {
}
match = newLine.match(/export class (\w*)/);
if (match) {
newLine = newLine.replace(match[0], `const ${match[1]} = module.exports.${match[1]} = class ${match[1]}`);
newLine = newLine
.replace(match[0], `const ${match[1]} = module.exports.${match[1]} = class ${match[1]}`);
}

if (newLine !== line) {
Expand Down
120 changes: 107 additions & 13 deletions lighthouse-core/lib/cdt/generated/SourceMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,30 @@ const SourceMap = module.exports = class SourceMap {
*/
findEntry(lineNumber, columnNumber) {
}

/**
* @param {string} sourceURL
* @param {number} lineNumber
* @param {number} columnNumber
* @return {?SourceMapEntry}
*/
sourceLineMapping(sourceURL, lineNumber, columnNumber) {
}

/**
* @return {!Array<!SourceMapEntry>}
*/
mappings() {
}

dispose() {
}
}

/**
* @unrestricted
*/
const SourceMapV3 = module.exports.SourceMapV3 = class SourceMapV3 {
class SourceMapV3 {
constructor() {
/** @type {number} */ this.version;
/** @type {string|undefined} */ this.file;
Expand Down Expand Up @@ -147,18 +165,11 @@ const SourceMapEntry = module.exports.SourceMapEntry = class SourceMapEntry {
/**
* @unrestricted
*/
const EditResult = module.exports.EditResult = class EditResult {
/**
* @param {!SourceMap} map
* @param {!Array<!TextUtils.SourceEdit>} compiledEdits
* @param {!Map<string, string>} newSources
*/
constructor(map, compiledEdits, newSources) {
this.map = map;
this.compiledEdits = compiledEdits;
this.newSources = newSources;
}
}

/**
* @implements {SourceMap}
Expand Down Expand Up @@ -205,11 +216,25 @@ const TextSourceMap = module.exports.TextSourceMap = class TextSourceMap {
* @return {!Promise<?TextSourceMap>}
* @this {TextSourceMap}
*/
/**
* @param {number} statusCode
* @param {!Object.<string, string>} headers
* @param {string} content
*/
static async load(sourceMapURL, compiledURL) {
let content = await new Promise((resolve, reject) => {
SDK.multitargetNetworkManager.loadResource(sourceMapURL, (statusCode, _headers, content) => {
if (!content || statusCode >= 400) {
const error = new Error(ls`Could not load content for ${sourceMapURL} : HTTP status code: ${statusCode}`);
reject(error);
} else {
resolve(content);
}
});
});

if (content.slice(0, 3) === ')]}') {
content = content.substring(content.indexOf('\n'));
}

const payload = /** @type {!SourceMapV3} */ (JSON.parse(content));
return new TextSourceMap(compiledURL, sourceMapURL, payload);
}

/**
* @override
Expand Down Expand Up @@ -268,6 +293,7 @@ const TextSourceMap = module.exports.TextSourceMap = class TextSourceMap {
}

/**
* @override
* @param {string} sourceURL
* @param {number} lineNumber
* @param {number} columnNumber
Expand Down Expand Up @@ -318,6 +344,7 @@ const TextSourceMap = module.exports.TextSourceMap = class TextSourceMap {
}

/**
* @override
* @return {!Array<!SourceMapEntry>}
*/
mappings() {
Expand Down Expand Up @@ -517,6 +544,12 @@ const TextSourceMap = module.exports.TextSourceMap = class TextSourceMap {
return new TextUtils.TextRange(
startMapping.lineNumber, startMapping.columnNumber, endMapping.lineNumber, endMapping.columnNumber);
}

/**
* @override
*/
dispose() {
}
}

TextSourceMap._VLQ_BASE_SHIFT = 5;
Expand Down Expand Up @@ -573,3 +606,64 @@ TextSourceMap.SourceInfo = class {

TextSourceMap._sourcesListSymbol = Symbol('sourcesList');

/**
* @implements {SDK.SourceMap}
* @unrestricted
*/
/**
* Implements SourceMap interface for DWARF information in Wasm.
* @param {string} wasmUrl
* @param {*} resolver
*/
/**
* @private
*/
/**
* @private
*/
/**
* @override
* @return {string}
*/
/**
* @override
* @return {string}
*/
/**
* @override
* @return {!Array.<string>}
*/
/**
* @override
* @param {string} sourceURL
* @param {!Common.ResourceType} contentType
* @return {!Common.ContentProvider}
*/
/**
* @override
* @param {string} sourceURL
* @return {?string}
*/
/**
* @override
* @param {number} lineNumber in compiled resource
* @param {number} columnNumber in compiled resource
* @return {?SDK.SourceMapEntry}
*/
/**
* @override
* @param {string} sourceURL
* @param {number} lineNumber
* @param {number} columnNumber
* @return {?SourceMapEntry}
*/
/**
* @override
* @return {!Array<!SourceMapEntry>}
*/
/**
* @override
*/

/* Special URL that should be kept in sync with one in V8 */

6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1791,9 +1791,9 @@ chownr@^1.1.1:
integrity sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw==

chrome-devtools-frontend@^1.0.708769:
version "1.0.708769"
resolved "https://registry.yarnpkg.com/chrome-devtools-frontend/-/chrome-devtools-frontend-1.0.708769.tgz#2210edfd7923c64dc0453ab89dbb560983cea91d"
integrity sha512-P32BUwvIxdbnJjW3Mz3Vr19UB9j2IH9PlZ83u/q2Qb7LEjCY3BRPCFqbG192lWQUfYhq8+gLVDMQFEdE8f9vWg==
version "1.0.723630"
resolved "https://registry.yarnpkg.com/chrome-devtools-frontend/-/chrome-devtools-frontend-1.0.723630.tgz#145c832caea15e2bf0919afdd8fc210f3079dcca"
integrity sha512-eoBh7jGJJCoeObofX/lUYAZA/WuYs2WlDw2AmdsWqi89/OBBRTvw25gcfkRhA7M1okxm0DasVHEshWG/F5s5jw==

chrome-launcher@^0.12.0:
version "0.12.0"
Expand Down

0 comments on commit 6480198

Please sign in to comment.