From 13465701518856c3916e0fefde3c84a0e2b3e5d9 Mon Sep 17 00:00:00 2001 From: sanex3339 Date: Fri, 25 Nov 2016 17:44:25 +0300 Subject: [PATCH] generateCode() now not static --- dist/index.js | 37 +++++++++++++++-------------- src/JavaScriptObfuscatorInternal.ts | 10 ++++---- src/Obfuscator.ts | 1 + 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/dist/index.js b/dist/index.js index fe654318..ede7c103 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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"; diff --git a/src/JavaScriptObfuscatorInternal.ts b/src/JavaScriptObfuscatorInternal.ts index 50545c72..735f48de 100644 --- a/src/JavaScriptObfuscatorInternal.ts +++ b/src/JavaScriptObfuscatorInternal.ts @@ -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); } diff --git a/src/Obfuscator.ts b/src/Obfuscator.ts index 9e722d62..e7d30afc 100644 --- a/src/Obfuscator.ts +++ b/src/Obfuscator.ts @@ -26,6 +26,7 @@ export class Obfuscator implements IObfuscator { * @type {IStorage} */ private readonly customNodesStorage: IStorage; + /** * @type {IObfuscationEventEmitter} */