Last active
November 27, 2015 08:21
-
-
Save develar/6365b609dc94047bd9fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (CompileEvent != null) { | |
// node adds \n\n}) | |
const nodejsSuffix = "(?:[\\r\\n]+\\}\\);?)?" | |
const sourceMapRegExp = new RegExp("[\\r\\n]//(?:@|#)[ \\t]sourceMappingURL=[ \\t]*(?:file://)?([^\\r\\n]*)\\s*(?:\\*/\\s*)?" + nodejsSuffix + "$") | |
CompileEvent.prototype.super$toJSONProtocol = CompileEvent.prototype.toJSONProtocol | |
CompileEvent.prototype.toJSONProtocol = function (): string { | |
try { | |
if (this.eventType() != 5) { | |
return this.super$toJSONProtocol() | |
} | |
var script = this.script() | |
if (script.name() == null /* source void 0; - skip it */ || | |
script.context() == null || | |
script.scriptType() === 0 /* native */ || | |
script.source().indexOf("javascript:void(0);") === 0) { | |
return '{"event": "scriptParsed"}' | |
} | |
var descriptor: any = { | |
id: script.id(), | |
path: script.name(), | |
type: script.scriptType(), | |
endLine: (script.lineOffset() + script.lineCount()) - 1 | |
} | |
var startLine = script.lineOffset() | |
if (startLine !== 0) { | |
descriptor.startLine = startLine | |
} | |
var startColumn = script.columnOffset() | |
if (startColumn !== 0) { | |
descriptor.startColumn = startColumn | |
} | |
var source = script.source() | |
if (source != null) { | |
var result = sourceMapRegExp.exec(source) | |
if (result != null && result.length > 1) { | |
descriptor.sourceMapUrl = result[1] | |
} | |
} | |
return '{"event": "scriptParsed", "body": ' + JSON.stringify(descriptor) + '}' | |
} | |
catch (e) { | |
//noinspection TypeScriptUnresolvedVariable | |
return '{"success": false, "message": ' + JSON.stringify('Error while sending break event:' + "\n\n" + e) + '}' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment