generateCode() now not static

This commit is contained in:
sanex3339
2016-11-25 17:44:25 +03:00
parent 12bf25cf3b
commit 1346570151
3 changed files with 24 additions and 24 deletions
+19 -18
View File
@@ -88,7 +88,7 @@ module.exports =
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 107);
/******/ return __webpack_require__(__webpack_require__.s = 108);
/******/ })
/************************************************************************/
/******/ ([
@@ -1591,6 +1591,21 @@ var JavaScriptObfuscatorInternal = function () {
}
_createClass(JavaScriptObfuscatorInternal, [{
key: 'generateCode',
value: function generateCode(sourceCode, astTree) {
var escodegenParams = Object.assign({}, JavaScriptObfuscatorInternal.escodegenParams);
if (this.options.sourceMap) {
escodegenParams.sourceMap = 'sourceMap';
escodegenParams.sourceContent = sourceCode;
}
escodegenParams.format = {
compact: this.options.compact
};
var generatorOutput = escodegen.generate(astTree, escodegenParams);
generatorOutput.map = generatorOutput.map ? generatorOutput.map.toString() : '';
return generatorOutput;
}
}, {
key: 'getObfuscationResult',
value: function getObfuscationResult(generatorOutput) {
return new SourceMapCorrector_1.SourceMapCorrector(new ObfuscationResult_1.ObfuscationResult(generatorOutput.code, generatorOutput.map), this.options.sourceMapBaseUrl + this.options.sourceMapFileName, this.options.sourceMapMode).correct();
@@ -1603,24 +1618,9 @@ var JavaScriptObfuscatorInternal = function () {
}
var astTree = esprima.parse(sourceCode, JavaScriptObfuscatorInternal.esprimaParams);
var obfuscatedAstTree = new Obfuscator_1.Obfuscator(new ObfuscationEventEmitter_1.ObfuscationEventEmitter(), new StackTraceAnalyzer_1.StackTraceAnalyzer(), new CustomNodesStorage_1.CustomNodesStorage(this.options), this.options).obfuscateAstTree(astTree);
var generatorOutput = JavaScriptObfuscatorInternal.generateCode(sourceCode, obfuscatedAstTree, this.options);
var generatorOutput = this.generateCode(sourceCode, obfuscatedAstTree);
return this.getObfuscationResult(generatorOutput);
}
}], [{
key: 'generateCode',
value: function generateCode(sourceCode, astTree, options) {
var escodegenParams = Object.assign({}, JavaScriptObfuscatorInternal.escodegenParams);
if (options.sourceMap) {
escodegenParams.sourceMap = 'sourceMap';
escodegenParams.sourceContent = sourceCode;
}
escodegenParams.format = {
compact: options.compact
};
var generatorOutput = escodegen.generate(astTree, escodegenParams);
generatorOutput.map = generatorOutput.map ? generatorOutput.map.toString() : '';
return generatorOutput;
}
}]);
return JavaScriptObfuscatorInternal;
@@ -5178,7 +5178,8 @@ module.exports = require("is-equal");
module.exports = require("mkdirp");
/***/ },
/* 107 */
/* 107 */,
/* 108 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
+4 -6
View File
@@ -47,21 +47,20 @@ export class JavaScriptObfuscatorInternal {
/**
* @param sourceCode
* @param astTree
* @param options
*/
private static generateCode (sourceCode: string, astTree: ESTree.Program, options: IOptions): IGeneratorOutput {
private generateCode (sourceCode: string, astTree: ESTree.Program): IGeneratorOutput {
const escodegenParams: escodegen.GenerateOptions = Object.assign(
{},
JavaScriptObfuscatorInternal.escodegenParams
);
if (options.sourceMap) {
if (this.options.sourceMap) {
escodegenParams.sourceMap = 'sourceMap';
escodegenParams.sourceContent = sourceCode;
}
escodegenParams.format = {
compact: options.compact
compact: this.options.compact
};
const generatorOutput: IGeneratorOutput = escodegen.generate(astTree, escodegenParams);
@@ -107,8 +106,7 @@ export class JavaScriptObfuscatorInternal {
).obfuscateAstTree(astTree);
// generate code
const generatorOutput: IGeneratorOutput = JavaScriptObfuscatorInternal
.generateCode(sourceCode, obfuscatedAstTree, this.options);
const generatorOutput: IGeneratorOutput = this.generateCode(sourceCode, obfuscatedAstTree);
return this.getObfuscationResult(generatorOutput);
}
+1
View File
@@ -26,6 +26,7 @@ export class Obfuscator implements IObfuscator {
* @type {IStorage<ICustomNode>}
*/
private readonly customNodesStorage: IStorage<ICustomNode>;
/**
* @type {IObfuscationEventEmitter}
*/