|  | @@ -2,21 +2,17 @@ import { inject, injectable } from 'inversify';
 | 
	
		
			
				|  |  |  import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import { TIdentifierNamesGeneratorFactory } from '../types/container/generators/TIdentifierNamesGeneratorFactory';
 | 
	
		
			
				|  |  | -import { TInputOptions } from '../types/options/TInputOptions';
 | 
	
		
			
				|  |  |  import { TStatement } from '../types/node/TStatement';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import { ICustomNode } from '../interfaces/custom-nodes/ICustomNode';
 | 
	
		
			
				|  |  | +import { ICustomNodeFormatter } from '../interfaces/custom-nodes/ICustomNodeFormatter';
 | 
	
		
			
				|  |  | +import { ICustomNodeObfuscator } from '../interfaces/custom-nodes/ICustomNodeObfuscator';
 | 
	
		
			
				|  |  |  import { IIdentifierNamesGenerator } from '../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
 | 
	
		
			
				|  |  |  import { IOptions } from '../interfaces/options/IOptions';
 | 
	
		
			
				|  |  |  import { IRandomGenerator } from '../interfaces/utils/IRandomGenerator';
 | 
	
		
			
				|  |  | -import { ICustomNodeFormatter } from '../interfaces/custom-nodes/ICustomNodeFormatter';
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -import { GlobalVariableTemplate1 } from '../templates/GlobalVariableTemplate1';
 | 
	
		
			
				|  |  | -import { GlobalVariableTemplate2 } from '../templates/GlobalVariableTemplate2';
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -import { NO_ADDITIONAL_NODES_PRESET } from '../options/presets/NoCustomNodes';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import { JavaScriptObfuscator } from '../JavaScriptObfuscatorFacade';
 | 
	
		
			
				|  |  | +import { GlobalVariableTemplate1 } from './common/templates/GlobalVariableTemplate1';
 | 
	
		
			
				|  |  | +import { GlobalVariableTemplate2 } from './common/templates/GlobalVariableTemplate2';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @injectable()
 | 
	
		
			
				|  |  |  export abstract class AbstractCustomNode <
 | 
	
	
		
			
				|  | @@ -35,6 +31,16 @@ export abstract class AbstractCustomNode <
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      protected cachedNode: TStatement[] | null = null;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * @type {ICustomNodeFormatter}
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    protected readonly customNodeFormatter: ICustomNodeFormatter;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * @type {ICustomNodeObfuscator}
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    protected readonly customNodeObfuscator: ICustomNodeObfuscator;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * @type {IIdentifierNamesGenerator}
 | 
	
		
			
				|  |  |       */
 | 
	
	
		
			
				|  | @@ -50,14 +56,10 @@ export abstract class AbstractCustomNode <
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      protected readonly randomGenerator: IRandomGenerator;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    /**
 | 
	
		
			
				|  |  | -     * @type {ICustomNodeFormatter}
 | 
	
		
			
				|  |  | -     */
 | 
	
		
			
				|  |  | -    protected readonly customNodeFormatter: ICustomNodeFormatter;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
 | 
	
		
			
				|  |  |       * @param {ICustomNodeFormatter} customNodeFormatter
 | 
	
		
			
				|  |  | +     * @param {ICustomNodeObfuscator} customNodeObfuscator
 | 
	
		
			
				|  |  |       * @param {IRandomGenerator} randomGenerator
 | 
	
		
			
				|  |  |       * @param {IOptions} options
 | 
	
		
			
				|  |  |       */
 | 
	
	
		
			
				|  | @@ -65,11 +67,13 @@ export abstract class AbstractCustomNode <
 | 
	
		
			
				|  |  |          @inject(ServiceIdentifiers.Factory__IIdentifierNamesGenerator)
 | 
	
		
			
				|  |  |              identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory,
 | 
	
		
			
				|  |  |          @inject(ServiceIdentifiers.ICustomNodeFormatter) customNodeFormatter: ICustomNodeFormatter,
 | 
	
		
			
				|  |  | +        @inject(ServiceIdentifiers.ICustomNodeObfuscator) customNodeObfuscator: ICustomNodeObfuscator,
 | 
	
		
			
				|  |  |          @inject(ServiceIdentifiers.IRandomGenerator) randomGenerator: IRandomGenerator,
 | 
	
		
			
				|  |  |          @inject(ServiceIdentifiers.IOptions) options: IOptions
 | 
	
		
			
				|  |  |      ) {
 | 
	
		
			
				|  |  |          this.identifierNamesGenerator = identifierNamesGeneratorFactory(options);
 | 
	
		
			
				|  |  |          this.customNodeFormatter = customNodeFormatter;
 | 
	
		
			
				|  |  | +        this.customNodeObfuscator = customNodeObfuscator;
 | 
	
		
			
				|  |  |          this.randomGenerator = randomGenerator;
 | 
	
		
			
				|  |  |          this.options = options;
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -105,41 +109,6 @@ export abstract class AbstractCustomNode <
 | 
	
		
			
				|  |  |          return '';
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    /**
 | 
	
		
			
				|  |  | -     * @param {string} template
 | 
	
		
			
				|  |  | -     * @param {TInputOptions} options
 | 
	
		
			
				|  |  | -     * @returns {string}
 | 
	
		
			
				|  |  | -     */
 | 
	
		
			
				|  |  | -    protected obfuscateTemplate (template: string, options: TInputOptions = {}): string {
 | 
	
		
			
				|  |  | -        const reservedNames: string[] = this.getPreservedNames(options.reservedNames);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        return JavaScriptObfuscator.obfuscate(
 | 
	
		
			
				|  |  | -            template,
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                ...NO_ADDITIONAL_NODES_PRESET,
 | 
	
		
			
				|  |  | -                identifierNamesGenerator: this.options.identifierNamesGenerator,
 | 
	
		
			
				|  |  | -                identifiersDictionary: this.options.identifiersDictionary,
 | 
	
		
			
				|  |  | -                seed: this.randomGenerator.getRawSeed(),
 | 
	
		
			
				|  |  | -                ...options,
 | 
	
		
			
				|  |  | -                reservedNames
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        ).getObfuscatedCode();
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    /**
 | 
	
		
			
				|  |  | -     * @param {string[]} additionalNames
 | 
	
		
			
				|  |  | -     * @returns {string[]}
 | 
	
		
			
				|  |  | -     */
 | 
	
		
			
				|  |  | -    private getPreservedNames (additionalNames: string[] = []): string[] {
 | 
	
		
			
				|  |  | -        return Array
 | 
	
		
			
				|  |  | -            .from(new Set([
 | 
	
		
			
				|  |  | -                ...Array.from(this.identifierNamesGenerator.getPreservedNames().values()),
 | 
	
		
			
				|  |  | -                ...additionalNames
 | 
	
		
			
				|  |  | -            ])
 | 
	
		
			
				|  |  | -            .values())
 | 
	
		
			
				|  |  | -            .map((preservedName: string) => `^${preservedName}$`);
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * @param {TInitialData} args
 | 
	
		
			
				|  |  |       */
 |