소스 검색

refactoring: nodesGroups -> customNodesFactory change

sanex3339 8 년 전
부모
커밋
aa656b678d

+ 21 - 21
dist/index.js

@@ -965,8 +965,8 @@ var AbstractCustomNodesFactory = function () {
     }
 
     _createClass(AbstractCustomNodesFactory, [{
-        key: "syncCustomNodesWithNodesGroup",
-        value: function syncCustomNodesWithNodesGroup(customNodes) {
+        key: "syncCustomNodesWithNodesFactory",
+        value: function syncCustomNodesWithNodesFactory(customNodes) {
             var _this = this;
 
             customNodes.forEach(function (node) {
@@ -1656,12 +1656,12 @@ var Obfuscator = function () {
             var _this = this;
 
             var customNodes = [];
-            Obfuscator.customNodesFactories.forEach(function (nodeGroupConstructor) {
-                var nodeGroupNodes = new nodeGroupConstructor(stackTraceData, _this.options).getNodes();
-                if (!nodeGroupNodes) {
+            Obfuscator.customNodesFactories.forEach(function (customNodesFactoryConstructor) {
+                var customNodesFactory = new customNodesFactoryConstructor(stackTraceData, _this.options).initializeCustomNodes();
+                if (!customNodesFactory) {
                     return;
                 }
-                customNodes.push.apply(customNodes, _toConsumableArray(nodeGroupNodes));
+                customNodes.push.apply(customNodes, _toConsumableArray(customNodesFactory));
             });
             this.customNodes = new Map(customNodes);
         }
@@ -2069,14 +2069,14 @@ var ConsoleOutputCustomNodesFactory = function (_AbstractCustomNodesF) {
     }
 
     _createClass(ConsoleOutputCustomNodesFactory, [{
-        key: 'getNodes',
-        value: function getNodes() {
+        key: 'initializeCustomNodes',
+        value: function initializeCustomNodes() {
             if (!this.options.disableConsoleOutput) {
                 return;
             }
             var callsControllerFunctionName = Utils_1.Utils.getRandomVariableName();
             var randomStackTraceIndex = NodeAppender_1.NodeAppender.getRandomStackTraceIndex(this.stackTraceData.length);
-            return this.syncCustomNodesWithNodesGroup(new Map([['consoleOutputDisableExpressionNode', new ConsoleOutputDisableExpressionNode_1.ConsoleOutputDisableExpressionNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)], ['ConsoleOutputNodeCallsControllerFunctionNode', new NodeCallsControllerFunctionNode_1.NodeCallsControllerFunctionNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)]]));
+            return this.syncCustomNodesWithNodesFactory(new Map([['consoleOutputDisableExpressionNode', new ConsoleOutputDisableExpressionNode_1.ConsoleOutputDisableExpressionNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)], ['ConsoleOutputNodeCallsControllerFunctionNode', new NodeCallsControllerFunctionNode_1.NodeCallsControllerFunctionNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)]]));
         }
     }]);
 
@@ -2444,8 +2444,8 @@ var DebugProtectionCustomNodesFactory = function (_AbstractCustomNodesF) {
     }
 
     _createClass(DebugProtectionCustomNodesFactory, [{
-        key: 'getNodes',
-        value: function getNodes() {
+        key: 'initializeCustomNodes',
+        value: function initializeCustomNodes() {
             if (!this.options.debugProtection) {
                 return;
             }
@@ -2454,7 +2454,7 @@ var DebugProtectionCustomNodesFactory = function (_AbstractCustomNodesF) {
             if (this.options.debugProtectionInterval) {
                 customNodes.set('debugProtectionFunctionIntervalNode', new DebugProtectionFunctionIntervalNode_1.DebugProtectionFunctionIntervalNode(debugProtectionFunctionName, this.options));
             }
-            return this.syncCustomNodesWithNodesGroup(customNodes);
+            return this.syncCustomNodesWithNodesFactory(customNodes);
         }
     }]);
 
@@ -2560,14 +2560,14 @@ var DomainLockCustomNodesFactory = function (_AbstractCustomNodesF) {
     }
 
     _createClass(DomainLockCustomNodesFactory, [{
-        key: 'getNodes',
-        value: function getNodes() {
+        key: 'initializeCustomNodes',
+        value: function initializeCustomNodes() {
             if (!this.options.domainLock.length) {
                 return;
             }
             var callsControllerFunctionName = Utils_1.Utils.getRandomVariableName();
             var randomStackTraceIndex = NodeAppender_1.NodeAppender.getRandomStackTraceIndex(this.stackTraceData.length);
-            return this.syncCustomNodesWithNodesGroup(new Map([['DomainLockNode', new DomainLockNode_1.DomainLockNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)], ['DomainLockNodeCallsControllerFunctionNode', new NodeCallsControllerFunctionNode_1.NodeCallsControllerFunctionNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)]]));
+            return this.syncCustomNodesWithNodesFactory(new Map([['DomainLockNode', new DomainLockNode_1.DomainLockNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)], ['DomainLockNodeCallsControllerFunctionNode', new NodeCallsControllerFunctionNode_1.NodeCallsControllerFunctionNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)]]));
         }
     }]);
 
@@ -2672,14 +2672,14 @@ var SelfDefendingCustomNodesFactory = function (_AbstractCustomNodesF) {
     }
 
     _createClass(SelfDefendingCustomNodesFactory, [{
-        key: 'getNodes',
-        value: function getNodes() {
+        key: 'initializeCustomNodes',
+        value: function initializeCustomNodes() {
             if (!this.options.selfDefending) {
                 return;
             }
             var callsControllerFunctionName = Utils_1.Utils.getRandomVariableName();
             var randomStackTraceIndex = NodeAppender_1.NodeAppender.getRandomStackTraceIndex(this.stackTraceData.length);
-            return this.syncCustomNodesWithNodesGroup(new Map([['selfDefendingUnicodeNode', new SelfDefendingUnicodeNode_1.SelfDefendingUnicodeNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)], ['SelfDefendingNodeCallsControllerFunctionNode', new NodeCallsControllerFunctionNode_1.NodeCallsControllerFunctionNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)]]));
+            return this.syncCustomNodesWithNodesFactory(new Map([['selfDefendingUnicodeNode', new SelfDefendingUnicodeNode_1.SelfDefendingUnicodeNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)], ['SelfDefendingNodeCallsControllerFunctionNode', new NodeCallsControllerFunctionNode_1.NodeCallsControllerFunctionNode(this.stackTraceData, callsControllerFunctionName, randomStackTraceIndex, this.options)]]));
         }
     }]);
 
@@ -2994,8 +2994,8 @@ var StringArrayCustomNodesFactory = function (_AbstractCustomNodesF) {
     }
 
     _createClass(StringArrayCustomNodesFactory, [{
-        key: 'getNodes',
-        value: function getNodes() {
+        key: 'initializeCustomNodes',
+        value: function initializeCustomNodes() {
             if (!this.options.stringArray) {
                 return;
             }
@@ -3010,7 +3010,7 @@ var StringArrayCustomNodesFactory = function (_AbstractCustomNodesF) {
             if (this.options.rotateStringArray) {
                 customNodes.set('stringArrayRotateFunctionNode', new StringArrayRotateFunctionNode_1.StringArrayRotateFunctionNode(this.stringArrayName, stringArray, this.stringArrayRotateValue, this.options));
             }
-            return this.syncCustomNodesWithNodesGroup(customNodes);
+            return this.syncCustomNodesWithNodesFactory(customNodes);
         }
     }]);
 

+ 5 - 5
src/Obfuscator.ts

@@ -118,16 +118,16 @@ export class Obfuscator implements IObfuscator {
     private initializeCustomNodes (stackTraceData: IStackTraceData[]): void {
         const customNodes: [string, ICustomNode][] = [];
 
-        Obfuscator.customNodesFactories.forEach((nodeGroupConstructor: TCustomNodesFactory) => {
-            const nodeGroupNodes: Map <string, ICustomNode> | undefined = new nodeGroupConstructor(
+        Obfuscator.customNodesFactories.forEach((customNodesFactoryConstructor: TCustomNodesFactory) => {
+            const customNodesFactory: Map <string, ICustomNode> | undefined = new customNodesFactoryConstructor(
                 stackTraceData, this.options
-            ).getNodes();
+            ).initializeCustomNodes();
 
-            if (!nodeGroupNodes) {
+            if (!customNodesFactory) {
                 return;
             }
 
-            customNodes.push(...nodeGroupNodes);
+            customNodes.push(...customNodesFactory);
         });
 
         this.customNodes = new Map <string, ICustomNode> (customNodes);

+ 2 - 2
src/custom-nodes/AbstractCustomNodesFactory.ts

@@ -33,13 +33,13 @@ export abstract class AbstractCustomNodesFactory implements ICustomNodesFactory
     /**
      * @returns {Map<string, ICustomNode> | undefined}
      */
-    public abstract getNodes (): Map <string, ICustomNode> | undefined;
+    public abstract initializeCustomNodes (): Map <string, ICustomNode> | undefined;
 
     /**
      * @param customNodes
      * @returns {Map<string, ICustomNode>}
      */
-    protected syncCustomNodesWithNodesGroup (customNodes: Map <string, ICustomNode>): Map <string, ICustomNode> {
+    protected syncCustomNodesWithNodesFactory (customNodes: Map <string, ICustomNode>): Map <string, ICustomNode> {
         customNodes.forEach((node: ICustomNode) => {
             node.setAppendState(this.appendState);
         });

+ 2 - 2
src/custom-nodes/console-output-nodes/factory/ConsoleOutputCustomNodesFactory.ts

@@ -11,7 +11,7 @@ export class ConsoleOutputCustomNodesFactory extends AbstractCustomNodesFactory
     /**
      * @returns {Map<string, ICustomNode>}
      */
-    public getNodes (): Map <string, ICustomNode> | undefined {
+    public initializeCustomNodes (): Map <string, ICustomNode> | undefined {
         if (!this.options.disableConsoleOutput) {
             return;
         }
@@ -19,7 +19,7 @@ export class ConsoleOutputCustomNodesFactory extends AbstractCustomNodesFactory
         const callsControllerFunctionName: string = Utils.getRandomVariableName();
         const randomStackTraceIndex: number = NodeAppender.getRandomStackTraceIndex(this.stackTraceData.length);
 
-        return this.syncCustomNodesWithNodesGroup(new Map <string, ICustomNode> ([
+        return this.syncCustomNodesWithNodesFactory(new Map <string, ICustomNode> ([
             [
                 'consoleOutputDisableExpressionNode',
                 new ConsoleOutputDisableExpressionNode(

+ 2 - 2
src/custom-nodes/debug-protection-nodes/factory/DebugProtectionCustomNodesFactory.ts

@@ -11,7 +11,7 @@ export class DebugProtectionCustomNodesFactory extends AbstractCustomNodesFactor
     /**
      * @returns {Map<string, ICustomNode> | undefined}
      */
-    public getNodes (): Map <string, ICustomNode> | undefined {
+    public initializeCustomNodes (): Map <string, ICustomNode> | undefined {
         if (!this.options.debugProtection) {
             return;
         }
@@ -35,6 +35,6 @@ export class DebugProtectionCustomNodesFactory extends AbstractCustomNodesFactor
             );
         }
 
-        return this.syncCustomNodesWithNodesGroup(customNodes);
+        return this.syncCustomNodesWithNodesFactory(customNodes);
     }
 }

+ 2 - 2
src/custom-nodes/domain-lock-nodes/factory/DomainLockCustomNodesFactory.ts

@@ -11,7 +11,7 @@ export class DomainLockCustomNodesFactory extends AbstractCustomNodesFactory {
     /**
      * @returns {Map<string, ICustomNode> | undefined}
      */
-    public getNodes (): Map <string, ICustomNode> | undefined {
+    public initializeCustomNodes (): Map <string, ICustomNode> | undefined {
         if (!this.options.domainLock.length) {
             return;
         }
@@ -19,7 +19,7 @@ export class DomainLockCustomNodesFactory extends AbstractCustomNodesFactory {
         const callsControllerFunctionName: string = Utils.getRandomVariableName();
         const randomStackTraceIndex: number = NodeAppender.getRandomStackTraceIndex(this.stackTraceData.length);
 
-        return this.syncCustomNodesWithNodesGroup(new Map <string, ICustomNode> ([
+        return this.syncCustomNodesWithNodesFactory(new Map <string, ICustomNode> ([
             [
                 'DomainLockNode',
                 new DomainLockNode(

+ 2 - 2
src/custom-nodes/self-defending-nodes/factory/SelfDefendingCustomNodesFactory.ts

@@ -18,7 +18,7 @@ export class SelfDefendingCustomNodesFactory extends AbstractCustomNodesFactory
     /**
      * @returns {Map<string, ICustomNode> | undefined}
      */
-    public getNodes (): Map <string, ICustomNode> | undefined {
+    public initializeCustomNodes (): Map <string, ICustomNode> | undefined {
         if (!this.options.selfDefending) {
             return;
         }
@@ -26,7 +26,7 @@ export class SelfDefendingCustomNodesFactory extends AbstractCustomNodesFactory
         const callsControllerFunctionName: string = Utils.getRandomVariableName();
         const randomStackTraceIndex: number = NodeAppender.getRandomStackTraceIndex(this.stackTraceData.length);
 
-        return this.syncCustomNodesWithNodesGroup(new Map <string, ICustomNode> ([
+        return this.syncCustomNodesWithNodesFactory(new Map <string, ICustomNode> ([
             [
                 'selfDefendingUnicodeNode',
                 new SelfDefendingUnicodeNode(

+ 2 - 2
src/custom-nodes/string-array-nodes/factory/StringArrayCustomNodesFactory.ts

@@ -35,7 +35,7 @@ export class StringArrayCustomNodesFactory extends AbstractCustomNodesFactory {
     /**
      * @returns {Map<string, ICustomNode> | undefined}
      */
-    public getNodes (): Map <string, ICustomNode> | undefined {
+    public initializeCustomNodes (): Map <string, ICustomNode> | undefined {
         if (!this.options.stringArray) {
             return;
         }
@@ -80,6 +80,6 @@ export class StringArrayCustomNodesFactory extends AbstractCustomNodesFactory {
             );
         }
 
-        return this.syncCustomNodesWithNodesGroup(customNodes);
+        return this.syncCustomNodesWithNodesFactory(customNodes);
     }
 }

+ 1 - 1
src/interfaces/ICustomNodesFactory.d.ts

@@ -4,5 +4,5 @@ export interface ICustomNodesFactory {
     /**
      * @returns {Map <string, ICustomNode> | undefined}
      */
-    getNodes (): Map <string, ICustomNode> | undefined;
+    initializeCustomNodes (): Map <string, ICustomNode> | undefined;
 }