mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
refactoring
This commit is contained in:
+10
-10
@@ -36,7 +36,7 @@ class Obfuscator {
|
||||
this.options = options;
|
||||
}
|
||||
obfuscateNode(node) {
|
||||
this.setNewNodes(node);
|
||||
this.setNewNodes();
|
||||
this.beforeObfuscation(node);
|
||||
estraverse.replace(node, {
|
||||
enter: (node, parent) => this.nodeControllerFirstPass(node, parent)
|
||||
@@ -55,33 +55,33 @@ class Obfuscator {
|
||||
this.nodes.set(key, node);
|
||||
});
|
||||
}
|
||||
afterObfuscation(node) {
|
||||
afterObfuscation(astTree) {
|
||||
this.nodes.forEach((node) => {
|
||||
if (node.getAppendState() === AppendState_1.AppendState.AfterObfuscation) {
|
||||
node.appendNode();
|
||||
node.appendNode(astTree);
|
||||
}
|
||||
});
|
||||
}
|
||||
beforeObfuscation(node) {
|
||||
beforeObfuscation(astTree) {
|
||||
this.nodes.forEach((node) => {
|
||||
if (node.getAppendState() === AppendState_1.AppendState.BeforeObfuscation) {
|
||||
node.appendNode();
|
||||
node.appendNode(astTree);
|
||||
}
|
||||
});
|
||||
}
|
||||
;
|
||||
setNewNodes(astTree) {
|
||||
setNewNodes() {
|
||||
if (this.options['disableConsoleOutput']) {
|
||||
this.setNode('consoleOutputDisableExpressionNode', new ConsoleOutputDisableExpressionNode_1.ConsoleOutputDisableExpressionNode(astTree));
|
||||
this.setNode('consoleOutputDisableExpressionNode', new ConsoleOutputDisableExpressionNode_1.ConsoleOutputDisableExpressionNode());
|
||||
}
|
||||
if (this.options['debugProtection']) {
|
||||
this.setNodesGroup(new DebugProtectionNodesGroup_1.DebugProtectionNodesGroup(astTree, this.options));
|
||||
this.setNodesGroup(new DebugProtectionNodesGroup_1.DebugProtectionNodesGroup(this.options));
|
||||
}
|
||||
if (this.options['rotateUnicodeArray']) {
|
||||
this.setNodesGroup(new UnicodeArrayNodesGroup_1.UnicodeArrayNodesGroup(astTree));
|
||||
this.setNodesGroup(new UnicodeArrayNodesGroup_1.UnicodeArrayNodesGroup());
|
||||
}
|
||||
else {
|
||||
this.setNode('unicodeArrayNode', new UnicodeArrayNode_1.UnicodeArrayNode(astTree, Utils_1.Utils.getRandomVariableName(UnicodeArrayNode_1.UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH)));
|
||||
this.setNode('unicodeArrayNode', new UnicodeArrayNode_1.UnicodeArrayNode(Utils_1.Utils.getRandomVariableName(UnicodeArrayNode_1.UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH)));
|
||||
}
|
||||
}
|
||||
nodeControllerFirstPass(node, parent) {
|
||||
|
||||
+12
-12
@@ -63,7 +63,7 @@ export class Obfuscator {
|
||||
* @param node
|
||||
*/
|
||||
public obfuscateNode (node: INode): void {
|
||||
this.setNewNodes(node);
|
||||
this.setNewNodes();
|
||||
this.beforeObfuscation(node);
|
||||
|
||||
estraverse.replace(node, {
|
||||
@@ -97,48 +97,48 @@ export class Obfuscator {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param node
|
||||
* @param astTree
|
||||
*/
|
||||
private afterObfuscation (node: INode): void {
|
||||
private afterObfuscation (astTree: INode): void {
|
||||
this.nodes.forEach((node: ICustomNode) => {
|
||||
if (node.getAppendState() === AppendState.AfterObfuscation) {
|
||||
node.appendNode();
|
||||
node.appendNode(astTree);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param node
|
||||
* @param astTree
|
||||
*/
|
||||
private beforeObfuscation (node: INode): void {
|
||||
private beforeObfuscation (astTree: INode): void {
|
||||
this.nodes.forEach((node: ICustomNode) => {
|
||||
if (node.getAppendState() === AppendState.BeforeObfuscation) {
|
||||
node.appendNode();
|
||||
node.appendNode(astTree);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
private setNewNodes (astTree: INode): void {
|
||||
private setNewNodes (): void {
|
||||
if (this.options['disableConsoleOutput']) {
|
||||
this.setNode(
|
||||
'consoleOutputDisableExpressionNode',
|
||||
new ConsoleOutputDisableExpressionNode(astTree)
|
||||
new ConsoleOutputDisableExpressionNode()
|
||||
);
|
||||
}
|
||||
|
||||
if (this.options['debugProtection']) {
|
||||
this.setNodesGroup(new DebugProtectionNodesGroup(astTree, this.options));
|
||||
this.setNodesGroup(new DebugProtectionNodesGroup(this.options));
|
||||
}
|
||||
|
||||
/**
|
||||
* Important to set this nodes latest to prevent runtime errors cause by `rotateUnicodeArray` option
|
||||
*/
|
||||
if (this.options['rotateUnicodeArray']) {
|
||||
this.setNodesGroup(new UnicodeArrayNodesGroup(astTree));
|
||||
this.setNodesGroup(new UnicodeArrayNodesGroup());
|
||||
} else {
|
||||
this.setNode(
|
||||
'unicodeArrayNode',
|
||||
new UnicodeArrayNode(astTree, Utils.getRandomVariableName(UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH))
|
||||
new UnicodeArrayNode(Utils.getRandomVariableName(UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,6 @@ export abstract class Node implements ICustomNode {
|
||||
*/
|
||||
protected appendState: AppendState = AppendState.BeforeObfuscation;
|
||||
|
||||
/**
|
||||
* @type {INode}
|
||||
*/
|
||||
protected astTree: INode;
|
||||
|
||||
/**
|
||||
* @type {INode}
|
||||
*/
|
||||
@@ -21,7 +16,7 @@ export abstract class Node implements ICustomNode {
|
||||
|
||||
constructor () {}
|
||||
|
||||
public abstract appendNode (): void;
|
||||
public abstract appendNode (astTree: INode): void;
|
||||
|
||||
/**
|
||||
* @returns {AppendState}
|
||||
|
||||
@@ -4,13 +4,12 @@ const estraverse = require('estraverse');
|
||||
const Node_1 = require('../Node');
|
||||
const NodeUtils_1 = require("../../NodeUtils");
|
||||
class ConsoleOutputDisableExpressionNode extends Node_1.Node {
|
||||
constructor(astTree) {
|
||||
constructor() {
|
||||
super();
|
||||
this.astTree = astTree;
|
||||
this.node = this.getNodeStructure();
|
||||
}
|
||||
appendNode() {
|
||||
estraverse.replace(this.astTree, {
|
||||
appendNode(astTree) {
|
||||
estraverse.replace(astTree, {
|
||||
leave: (node, parent) => {
|
||||
if (NodeUtils_1.NodeUtils.isProgramNode(node)) {
|
||||
NodeUtils_1.NodeUtils.prependNode(node.body, this.getNode());
|
||||
|
||||
@@ -7,19 +7,17 @@ import { Node } from '../Node';
|
||||
import { NodeUtils } from "../../NodeUtils";
|
||||
|
||||
export class ConsoleOutputDisableExpressionNode extends Node {
|
||||
/**
|
||||
* @param astTree
|
||||
*/
|
||||
constructor (astTree: INode) {
|
||||
constructor () {
|
||||
super();
|
||||
|
||||
this.astTree = astTree;
|
||||
|
||||
this.node = this.getNodeStructure();
|
||||
}
|
||||
|
||||
public appendNode (): void {
|
||||
estraverse.replace(this.astTree, {
|
||||
/**
|
||||
* @param astTree
|
||||
*/
|
||||
public appendNode (astTree: INode): void {
|
||||
estraverse.replace(astTree, {
|
||||
leave: (node: INode, parent: INode): any => {
|
||||
if (NodeUtils.isProgramNode(node)) {
|
||||
NodeUtils.prependNode(node.body, this.getNode());
|
||||
|
||||
@@ -4,14 +4,13 @@ const NodeType_1 = require("../../enums/NodeType");
|
||||
const Node_1 = require('../Node');
|
||||
const NodeUtils_1 = require("../../NodeUtils");
|
||||
class DebugProtectionFunctionCallNode extends Node_1.Node {
|
||||
constructor(astTree, debugProtectionFunctionName) {
|
||||
constructor(debugProtectionFunctionName) {
|
||||
super();
|
||||
this.astTree = astTree;
|
||||
this.debugProtectionFunctionName = debugProtectionFunctionName;
|
||||
this.node = this.getNodeStructure();
|
||||
}
|
||||
appendNode() {
|
||||
estraverse.replace(this.astTree, {
|
||||
appendNode(astTree) {
|
||||
estraverse.replace(astTree, {
|
||||
leave: (node, parent) => {
|
||||
if (NodeUtils_1.NodeUtils.isProgramNode(node)) {
|
||||
NodeUtils_1.NodeUtils.appendNode(node.body, this.getNode());
|
||||
|
||||
@@ -14,23 +14,21 @@ export class DebugProtectionFunctionCallNode extends Node {
|
||||
private debugProtectionFunctionName: string;
|
||||
|
||||
/**
|
||||
* @param astTree
|
||||
* @param debugProtectionFunctionName
|
||||
*/
|
||||
constructor (
|
||||
astTree: INode,
|
||||
debugProtectionFunctionName: string
|
||||
) {
|
||||
constructor (debugProtectionFunctionName: string) {
|
||||
super();
|
||||
|
||||
this.astTree = astTree;
|
||||
this.debugProtectionFunctionName = debugProtectionFunctionName;
|
||||
|
||||
this.node = this.getNodeStructure();
|
||||
}
|
||||
|
||||
public appendNode (): void {
|
||||
estraverse.replace(this.astTree, {
|
||||
/**
|
||||
* @param astTree
|
||||
*/
|
||||
public appendNode (astTree: INode): void {
|
||||
estraverse.replace(astTree, {
|
||||
leave: (node: INode, parent: INode): any => {
|
||||
if (NodeUtils.isProgramNode(node)) {
|
||||
NodeUtils.appendNode(node.body, this.getNode());
|
||||
|
||||
@@ -4,14 +4,13 @@ const NodeType_1 = require('../../enums/NodeType');
|
||||
const Node_1 = require('../Node');
|
||||
const NodeUtils_1 = require('../../NodeUtils');
|
||||
class DebugProtectionFunctionIntervalNode extends Node_1.Node {
|
||||
constructor(astTree, debugProtectionFunctionName) {
|
||||
constructor(debugProtectionFunctionName) {
|
||||
super();
|
||||
this.astTree = astTree;
|
||||
this.debugProtectionFunctionName = debugProtectionFunctionName;
|
||||
this.node = this.getNodeStructure();
|
||||
}
|
||||
appendNode() {
|
||||
estraverse.replace(this.astTree, {
|
||||
appendNode(astTree) {
|
||||
estraverse.replace(astTree, {
|
||||
leave: (node, parent) => {
|
||||
if (NodeUtils_1.NodeUtils.isProgramNode(node)) {
|
||||
NodeUtils_1.NodeUtils.appendNode(node.body, this.getNode());
|
||||
|
||||
@@ -14,23 +14,21 @@ export class DebugProtectionFunctionIntervalNode extends Node {
|
||||
private debugProtectionFunctionName: string;
|
||||
|
||||
/**
|
||||
* @param astTree
|
||||
* @param debugProtectionFunctionName
|
||||
*/
|
||||
constructor (
|
||||
astTree: INode,
|
||||
debugProtectionFunctionName: string
|
||||
) {
|
||||
constructor (debugProtectionFunctionName: string) {
|
||||
super();
|
||||
|
||||
this.astTree = astTree;
|
||||
this.debugProtectionFunctionName = debugProtectionFunctionName;
|
||||
|
||||
this.node = this.getNodeStructure();
|
||||
}
|
||||
|
||||
public appendNode (): void {
|
||||
estraverse.replace(this.astTree, {
|
||||
/**
|
||||
* @param astTree
|
||||
*/
|
||||
public appendNode (astTree: INode): void {
|
||||
estraverse.replace(astTree, {
|
||||
leave: (node: INode, parent: INode): any => {
|
||||
if (NodeUtils.isProgramNode(node)) {
|
||||
NodeUtils.appendNode(node.body, this.getNode());
|
||||
|
||||
@@ -3,19 +3,19 @@ const esprima = require('esprima');
|
||||
const estraverse = require('estraverse');
|
||||
const Node_1 = require('../Node');
|
||||
const NodeUtils_1 = require('../../NodeUtils');
|
||||
const Utils_1 = require("../../Utils");
|
||||
class DebugProtectionFunctionNode extends Node_1.Node {
|
||||
constructor(astTree, debugProtectionFunctionName, debugProtectionFunctionIndex) {
|
||||
constructor(debugProtectionFunctionName) {
|
||||
super();
|
||||
this.astTree = astTree;
|
||||
this.debugProtectionFunctionName = debugProtectionFunctionName;
|
||||
this.debugProtectionFunctionIndex = debugProtectionFunctionIndex;
|
||||
this.node = this.getNodeStructure();
|
||||
}
|
||||
appendNode() {
|
||||
estraverse.replace(this.astTree, {
|
||||
appendNode(astTree) {
|
||||
estraverse.replace(astTree, {
|
||||
leave: (node, parent) => {
|
||||
if (NodeUtils_1.NodeUtils.isProgramNode(node)) {
|
||||
NodeUtils_1.NodeUtils.insertNodeAtIndex(node.body, this.getNode(), this.debugProtectionFunctionIndex);
|
||||
let programBodyLength = node.body.length, randomIndex = Utils_1.Utils.getRandomInteger(0, programBodyLength);
|
||||
NodeUtils_1.NodeUtils.insertNodeAtIndex(node.body, this.getNode(), randomIndex);
|
||||
return estraverse.VisitorOption.Break;
|
||||
}
|
||||
return estraverse.VisitorOption.Skip;
|
||||
|
||||
@@ -5,6 +5,7 @@ import { INode } from '../../interfaces/nodes/INode';
|
||||
|
||||
import { Node } from '../Node';
|
||||
import { NodeUtils } from '../../NodeUtils';
|
||||
import { Utils } from "../../Utils";
|
||||
|
||||
export class DebugProtectionFunctionNode extends Node {
|
||||
/**
|
||||
@@ -13,34 +14,29 @@ export class DebugProtectionFunctionNode extends Node {
|
||||
private debugProtectionFunctionName: string;
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
private debugProtectionFunctionIndex: number;
|
||||
|
||||
/**
|
||||
* @param astTree
|
||||
* @param debugProtectionFunctionName
|
||||
* @param debugProtectionFunctionIndex
|
||||
*/
|
||||
constructor (
|
||||
astTree: INode,
|
||||
debugProtectionFunctionName: string,
|
||||
debugProtectionFunctionIndex: number
|
||||
debugProtectionFunctionName: string
|
||||
) {
|
||||
super();
|
||||
|
||||
this.astTree = astTree;
|
||||
this.debugProtectionFunctionName = debugProtectionFunctionName;
|
||||
this.debugProtectionFunctionIndex = debugProtectionFunctionIndex;
|
||||
|
||||
this.node = this.getNodeStructure();
|
||||
}
|
||||
|
||||
public appendNode (): void {
|
||||
estraverse.replace(this.astTree, {
|
||||
/**
|
||||
* @param astTree
|
||||
*/
|
||||
public appendNode (astTree: INode): void {
|
||||
estraverse.replace(astTree, {
|
||||
leave: (node: INode, parent: INode): any => {
|
||||
if (NodeUtils.isProgramNode(node)) {
|
||||
NodeUtils.insertNodeAtIndex(node.body, this.getNode(), this.debugProtectionFunctionIndex);
|
||||
let programBodyLength: number = node.body.length,
|
||||
randomIndex = Utils.getRandomInteger(0, programBodyLength);
|
||||
|
||||
NodeUtils.insertNodeAtIndex(node.body, this.getNode(), randomIndex);
|
||||
|
||||
return estraverse.VisitorOption.Break;
|
||||
}
|
||||
|
||||
@@ -7,17 +7,16 @@ const Node_1 = require('../Node');
|
||||
const NodeUtils_1 = require("../../NodeUtils");
|
||||
const Utils_1 = require('../../Utils');
|
||||
class UnicodeArrayNode extends Node_1.Node {
|
||||
constructor(astTree, unicodeArrayName, unicodeArrayRotateValue = 0) {
|
||||
constructor(unicodeArrayName, unicodeArrayRotateValue = 0) {
|
||||
super();
|
||||
this.appendState = AppendState_1.AppendState.AfterObfuscation;
|
||||
this.unicodeArray = [];
|
||||
this.astTree = astTree;
|
||||
this.unicodeArrayName = unicodeArrayName;
|
||||
this.unicodeArrayRotateValue = unicodeArrayRotateValue;
|
||||
this.node = this.getNodeStructure();
|
||||
}
|
||||
appendNode() {
|
||||
estraverse.replace(this.astTree, {
|
||||
appendNode(astTree) {
|
||||
estraverse.replace(astTree, {
|
||||
leave: (node, parent) => {
|
||||
if (NodeUtils_1.NodeUtils.isProgramNode(node)) {
|
||||
NodeUtils_1.NodeUtils.prependNode(node.body, this.getNode());
|
||||
|
||||
@@ -37,22 +37,23 @@ export class UnicodeArrayNode extends Node {
|
||||
private unicodeArrayRotateValue: number;
|
||||
|
||||
/**
|
||||
* @param astTree
|
||||
* @param unicodeArrayName
|
||||
* @param unicodeArrayRotateValue
|
||||
*/
|
||||
constructor (astTree: INode, unicodeArrayName: string, unicodeArrayRotateValue: number = 0) {
|
||||
constructor (unicodeArrayName: string, unicodeArrayRotateValue: number = 0) {
|
||||
super();
|
||||
|
||||
this.astTree = astTree;
|
||||
this.unicodeArrayName = unicodeArrayName;
|
||||
this.unicodeArrayRotateValue = unicodeArrayRotateValue;
|
||||
|
||||
this.node = this.getNodeStructure();
|
||||
}
|
||||
|
||||
public appendNode (): void {
|
||||
estraverse.replace(this.astTree, {
|
||||
/**
|
||||
* @param astTree
|
||||
*/
|
||||
public appendNode (astTree: INode): void {
|
||||
estraverse.replace(astTree, {
|
||||
leave: (node: INode, parent: INode): any => {
|
||||
if (NodeUtils.isProgramNode(node)) {
|
||||
NodeUtils.prependNode(node.body, this.getNode());
|
||||
|
||||
@@ -4,16 +4,15 @@ const NodeType_1 = require("../../enums/NodeType");
|
||||
const Node_1 = require('../Node');
|
||||
const NodeUtils_1 = require("../../NodeUtils");
|
||||
class UnicodeArrayRotateFunctionCallNode extends Node_1.Node {
|
||||
constructor(astTree, unicodeArrayRotateFunctionName, unicodeArrayName, unicodeArrayRotateValue) {
|
||||
constructor(unicodeArrayRotateFunctionName, unicodeArrayName, unicodeArrayRotateValue) {
|
||||
super();
|
||||
this.astTree = astTree;
|
||||
this.unicodeArrayRotateFunctionName = unicodeArrayRotateFunctionName;
|
||||
this.unicodeArrayName = unicodeArrayName;
|
||||
this.unicodeArrayRotateValue = unicodeArrayRotateValue;
|
||||
this.node = this.getNodeStructure();
|
||||
}
|
||||
appendNode() {
|
||||
estraverse.replace(this.astTree, {
|
||||
appendNode(astTree) {
|
||||
estraverse.replace(astTree, {
|
||||
leave: (node, parent) => {
|
||||
if (NodeUtils_1.NodeUtils.isProgramNode(node)) {
|
||||
NodeUtils_1.NodeUtils.prependNode(node.body, this.getNode());
|
||||
|
||||
@@ -24,21 +24,17 @@ export class UnicodeArrayRotateFunctionCallNode extends Node {
|
||||
private unicodeArrayRotateFunctionName: string;
|
||||
|
||||
/**
|
||||
* @param astTree
|
||||
* @param unicodeArrayRotateFunctionName
|
||||
* @param unicodeArrayName
|
||||
* @param unicodeArrayRotateValue
|
||||
*/
|
||||
constructor (
|
||||
astTree: INode,
|
||||
unicodeArrayRotateFunctionName: string,
|
||||
unicodeArrayName: string,
|
||||
unicodeArrayRotateValue: number
|
||||
) {
|
||||
super();
|
||||
|
||||
this.astTree = astTree;
|
||||
|
||||
this.unicodeArrayRotateFunctionName = unicodeArrayRotateFunctionName;
|
||||
this.unicodeArrayName = unicodeArrayName;
|
||||
this.unicodeArrayRotateValue = unicodeArrayRotateValue;
|
||||
@@ -46,8 +42,8 @@ export class UnicodeArrayRotateFunctionCallNode extends Node {
|
||||
this.node = this.getNodeStructure();
|
||||
}
|
||||
|
||||
public appendNode (): void {
|
||||
estraverse.replace(this.astTree, {
|
||||
public appendNode (astTree: INode): void {
|
||||
estraverse.replace(astTree, {
|
||||
leave: (node: INode, parent: INode): any => {
|
||||
if (NodeUtils.isProgramNode(node)) {
|
||||
NodeUtils.prependNode(node.body, this.getNode());
|
||||
|
||||
@@ -5,15 +5,14 @@ const Node_1 = require('../Node');
|
||||
const NodeUtils_1 = require("../../NodeUtils");
|
||||
const Utils_1 = require('../../Utils');
|
||||
class UnicodeArrayRotateFunctionNode extends Node_1.Node {
|
||||
constructor(astTree, unicodeArrayRotateFunctionName, unicodeArrayName) {
|
||||
constructor(unicodeArrayRotateFunctionName, unicodeArrayName) {
|
||||
super();
|
||||
this.astTree = astTree;
|
||||
this.unicodeArrayRotateFunctionName = unicodeArrayRotateFunctionName;
|
||||
this.unicodeArrayName = unicodeArrayName;
|
||||
this.node = this.getNodeStructure();
|
||||
}
|
||||
appendNode() {
|
||||
estraverse.replace(this.astTree, {
|
||||
appendNode(astTree) {
|
||||
estraverse.replace(astTree, {
|
||||
leave: (node, parent) => {
|
||||
if (NodeUtils_1.NodeUtils.isProgramNode(node)) {
|
||||
NodeUtils_1.NodeUtils.appendNode(node.body, this.getNode());
|
||||
|
||||
@@ -20,26 +20,26 @@ export class UnicodeArrayRotateFunctionNode extends Node {
|
||||
private unicodeArrayRotateFunctionName: string;
|
||||
|
||||
/**
|
||||
* @param astTree
|
||||
* @param unicodeArrayRotateFunctionName
|
||||
* @param unicodeArrayName
|
||||
*/
|
||||
constructor (
|
||||
astTree: INode,
|
||||
unicodeArrayRotateFunctionName: string,
|
||||
unicodeArrayName: string
|
||||
) {
|
||||
super();
|
||||
|
||||
this.astTree = astTree;
|
||||
this.unicodeArrayRotateFunctionName = unicodeArrayRotateFunctionName;
|
||||
this.unicodeArrayName = unicodeArrayName;
|
||||
|
||||
this.node = this.getNodeStructure();
|
||||
}
|
||||
|
||||
public appendNode (): void {
|
||||
estraverse.replace(this.astTree, {
|
||||
/**
|
||||
* @param astTree
|
||||
*/
|
||||
public appendNode (astTree: INode): void {
|
||||
estraverse.replace(astTree, {
|
||||
leave: (node: INode, parent: INode): any => {
|
||||
if (NodeUtils.isProgramNode(node)) {
|
||||
NodeUtils.appendNode(node.body, this.getNode());
|
||||
|
||||
Vendored
+4
-1
@@ -3,7 +3,10 @@ import { INode } from '../interfaces/nodes/INode';
|
||||
import { AppendState } from '../enums/AppendState';
|
||||
|
||||
export interface ICustomNode {
|
||||
appendNode (): void;
|
||||
/**
|
||||
* @param astTree
|
||||
*/
|
||||
appendNode (astTree: INode): void;
|
||||
|
||||
/**
|
||||
* @returns {AppendState}
|
||||
|
||||
@@ -7,24 +7,23 @@ const NodesGroup_1 = require('./NodesGroup');
|
||||
const NodeUtils_1 = require("../NodeUtils");
|
||||
const Utils_1 = require('../Utils');
|
||||
class DebugProtectionNodesGroup extends NodesGroup_1.NodesGroup {
|
||||
constructor(astTree, options) {
|
||||
constructor(options) {
|
||||
super();
|
||||
this.debugProtectionFunctionIdentifier = Utils_1.Utils.getRandomVariableName();
|
||||
this.astTree = astTree;
|
||||
this.options = options;
|
||||
this.debugProtectionFunctionIndex = this.getDebugProtectionFunctionIndex();
|
||||
this.nodes = new Map([
|
||||
[
|
||||
'debugProtectionFunctionNode',
|
||||
new DebugProtectionFunctionNode_1.DebugProtectionFunctionNode(this.astTree, this.debugProtectionFunctionIdentifier, this.debugProtectionFunctionIndex)
|
||||
new DebugProtectionFunctionNode_1.DebugProtectionFunctionNode(this.debugProtectionFunctionIdentifier)
|
||||
],
|
||||
[
|
||||
'debugProtectionFunctionCallNode',
|
||||
new DebugProtectionFunctionCallNode_1.DebugProtectionFunctionCallNode(this.astTree, this.debugProtectionFunctionIdentifier)
|
||||
new DebugProtectionFunctionCallNode_1.DebugProtectionFunctionCallNode(this.debugProtectionFunctionIdentifier)
|
||||
]
|
||||
]);
|
||||
if (this.options['debugProtectionInterval']) {
|
||||
this.nodes.set('debugProtectionFunctionIntervalNode', new DebugProtectionFunctionIntervalNode_1.DebugProtectionFunctionIntervalNode(this.astTree, this.debugProtectionFunctionIdentifier));
|
||||
this.nodes.set('debugProtectionFunctionIntervalNode', new DebugProtectionFunctionIntervalNode_1.DebugProtectionFunctionIntervalNode(this.debugProtectionFunctionIdentifier));
|
||||
}
|
||||
}
|
||||
getDebugProtectionFunctionIndex() {
|
||||
|
||||
@@ -34,13 +34,11 @@ export class DebugProtectionNodesGroup extends NodesGroup {
|
||||
private options: any;
|
||||
|
||||
/**
|
||||
* @param astTree
|
||||
* @param options
|
||||
*/
|
||||
constructor (astTree: INode, options: any) {
|
||||
constructor (options: any) {
|
||||
super();
|
||||
|
||||
this.astTree = astTree;
|
||||
this.options = options;
|
||||
|
||||
this.debugProtectionFunctionIndex = this.getDebugProtectionFunctionIndex();
|
||||
@@ -48,28 +46,18 @@ export class DebugProtectionNodesGroup extends NodesGroup {
|
||||
this.nodes = new Map <string, ICustomNode> ([
|
||||
[
|
||||
'debugProtectionFunctionNode',
|
||||
new DebugProtectionFunctionNode(
|
||||
this.astTree,
|
||||
this.debugProtectionFunctionIdentifier,
|
||||
this.debugProtectionFunctionIndex
|
||||
)
|
||||
new DebugProtectionFunctionNode(this.debugProtectionFunctionIdentifier)
|
||||
],
|
||||
[
|
||||
'debugProtectionFunctionCallNode',
|
||||
new DebugProtectionFunctionCallNode(
|
||||
this.astTree,
|
||||
this.debugProtectionFunctionIdentifier
|
||||
)
|
||||
new DebugProtectionFunctionCallNode(this.debugProtectionFunctionIdentifier)
|
||||
]
|
||||
]);
|
||||
|
||||
if (this.options['debugProtectionInterval']) {
|
||||
this.nodes.set(
|
||||
'debugProtectionFunctionIntervalNode',
|
||||
new DebugProtectionFunctionIntervalNode(
|
||||
this.astTree,
|
||||
this.debugProtectionFunctionIdentifier
|
||||
)
|
||||
new DebugProtectionFunctionIntervalNode(this.debugProtectionFunctionIdentifier)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,22 +5,22 @@ const UnicodeArrayRotateFunctionCallNode_1 = require('../custom-nodes/unicode-ar
|
||||
const UnicodeArrayRotateFunctionNode_1 = require('../custom-nodes/unicode-array-nodes/UnicodeArrayRotateFunctionNode');
|
||||
const Utils_1 = require('../Utils');
|
||||
class UnicodeArrayNodesGroup extends NodesGroup_1.NodesGroup {
|
||||
constructor(astTree) {
|
||||
constructor() {
|
||||
super();
|
||||
this.unicodeArrayRotateFunctionIdentifier = Utils_1.Utils.getRandomVariableName();
|
||||
let unicodeArrayName = Utils_1.Utils.getRandomVariableName(UnicodeArrayNode_1.UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH), unicodeArrayRotateValue = Utils_1.Utils.getRandomInteger(100, 500);
|
||||
this.nodes = new Map([
|
||||
[
|
||||
'unicodeArrayNode',
|
||||
new UnicodeArrayNode_1.UnicodeArrayNode(astTree, unicodeArrayName, unicodeArrayRotateValue)
|
||||
new UnicodeArrayNode_1.UnicodeArrayNode(unicodeArrayName, unicodeArrayRotateValue)
|
||||
],
|
||||
[
|
||||
'unicodeArrayRotateFunctionNode',
|
||||
new UnicodeArrayRotateFunctionNode_1.UnicodeArrayRotateFunctionNode(astTree, this.unicodeArrayRotateFunctionIdentifier, unicodeArrayName)
|
||||
new UnicodeArrayRotateFunctionNode_1.UnicodeArrayRotateFunctionNode(this.unicodeArrayRotateFunctionIdentifier, unicodeArrayName)
|
||||
],
|
||||
[
|
||||
'unicodeArrayRotateFunctionCallNode',
|
||||
new UnicodeArrayRotateFunctionCallNode_1.UnicodeArrayRotateFunctionCallNode(astTree, this.unicodeArrayRotateFunctionIdentifier, unicodeArrayName, unicodeArrayRotateValue)
|
||||
new UnicodeArrayRotateFunctionCallNode_1.UnicodeArrayRotateFunctionCallNode(this.unicodeArrayRotateFunctionIdentifier, unicodeArrayName, unicodeArrayRotateValue)
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -14,10 +14,7 @@ export class UnicodeArrayNodesGroup extends NodesGroup {
|
||||
*/
|
||||
private unicodeArrayRotateFunctionIdentifier: string = Utils.getRandomVariableName();
|
||||
|
||||
/**
|
||||
* @param astTree
|
||||
*/
|
||||
constructor (astTree: INode) {
|
||||
constructor () {
|
||||
super();
|
||||
|
||||
let unicodeArrayName: string = Utils.getRandomVariableName(UnicodeArrayNode.UNICODE_ARRAY_RANDOM_LENGTH),
|
||||
@@ -27,7 +24,6 @@ export class UnicodeArrayNodesGroup extends NodesGroup {
|
||||
[
|
||||
'unicodeArrayNode',
|
||||
new UnicodeArrayNode(
|
||||
astTree,
|
||||
unicodeArrayName,
|
||||
unicodeArrayRotateValue
|
||||
)
|
||||
@@ -35,7 +31,6 @@ export class UnicodeArrayNodesGroup extends NodesGroup {
|
||||
[
|
||||
'unicodeArrayRotateFunctionNode',
|
||||
new UnicodeArrayRotateFunctionNode(
|
||||
astTree,
|
||||
this.unicodeArrayRotateFunctionIdentifier,
|
||||
unicodeArrayName
|
||||
)
|
||||
@@ -43,7 +38,6 @@ export class UnicodeArrayNodesGroup extends NodesGroup {
|
||||
[
|
||||
'unicodeArrayRotateFunctionCallNode',
|
||||
new UnicodeArrayRotateFunctionCallNode(
|
||||
astTree,
|
||||
this.unicodeArrayRotateFunctionIdentifier,
|
||||
unicodeArrayName,
|
||||
unicodeArrayRotateValue
|
||||
|
||||
Reference in New Issue
Block a user