123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- import 'format-unicorn';
- import { INode } from '../../interfaces/nodes/INode';
- import { IOptions } from "../../interfaces/IOptions";
- import { TNodeWithBlockStatement } from "../../types/TNodeWithBlockStatement";
- import { AppendState } from '../../enums/AppendState';
- import { UnicodeArray } from '../../UnicodeArray';
- import { UnicodeArrayTemplate } from "../../templates/custom-nodes/unicode-array-nodes/unicode-array-node/UnicodeArrayTemplate";
- import { Node } from '../Node';
- import { NodeUtils } from "../../NodeUtils";
- export class UnicodeArrayNode extends Node {
- /**
- * @type {number}
- */
- public static UNICODE_ARRAY_RANDOM_LENGTH: number = 4;
- /**
- * @type {AppendState}
- */
- protected appendState: AppendState = AppendState.AfterObfuscation;
- /**
- * @type {UnicodeArray}
- */
- private unicodeArray: UnicodeArray;
- /**
- * @type {string}
- */
- private unicodeArrayName: string;
- /**
- * @type {number}
- */
- private unicodeArrayRotateValue: number;
- /**
- * @param unicodeArray
- * @param unicodeArrayName
- * @param unicodeArrayRotateValue
- * @param options
- */
- constructor (
- unicodeArray: UnicodeArray,
- unicodeArrayName: string,
- unicodeArrayRotateValue: number = 0,
- options: IOptions
- ) {
- super(options);
- this.unicodeArray = unicodeArray;
- this.unicodeArrayName = unicodeArrayName;
- this.unicodeArrayRotateValue = unicodeArrayRotateValue;
- }
- /**
- * @param blockScopeNode
- */
- public appendNode (blockScopeNode: TNodeWithBlockStatement): void {
- if (!this.unicodeArray.getLength()) {
- return;
- }
- NodeUtils.prependNode(blockScopeNode.body, this.getNode());
- }
- /**
- * @returns {string}
- */
- public getNodeIdentifier (): string {
- return this.unicodeArrayName;
- }
- /**
- * @returns {UnicodeArray}
- */
- public getNodeData (): UnicodeArray {
- return this.unicodeArray;
- }
- /**
- * @returns {INode}
- */
- public getNode (): INode {
- this.unicodeArray.rotateArray(this.unicodeArrayRotateValue);
- return super.getNode();
- }
- /**
- * @param data
- */
- public updateNodeData (data: string): void {
- this.unicodeArray.addToArray(data);
- }
- /**
- * @returns {INode}
- */
- protected getNodeStructure (): INode {
- return NodeUtils.convertCodeToStructure(
- UnicodeArrayTemplate().formatUnicorn({
- unicodeArrayName: this.unicodeArrayName,
- unicodeArray: this.unicodeArray.toString()
- })
- );
- }
- }
|