DebugProtectionFunctionIntervalNode.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import 'format-unicorn';
  2. import { TNodeWithBlockStatement } from '../../types/TNodeWithBlockStatement';
  3. import { TStatement } from '../../types/TStatement';
  4. import { IOptions } from '../../interfaces/IOptions';
  5. import { AppendState } from '../../enums/AppendState';
  6. import { DebugProtectionFunctionIntervalTemplate } from '../../templates/custom-nodes/debug-protection-nodes/debug-protection-function-interval-node/DebugProtectionFunctionIntervalTemplate';
  7. import { AbstractCustomNode } from '../AbstractCustomNode';
  8. import { NodeUtils } from '../../NodeUtils';
  9. export class DebugProtectionFunctionIntervalNode extends AbstractCustomNode {
  10. /**
  11. * @type {AppendState}
  12. */
  13. protected appendState: AppendState = AppendState.BeforeObfuscation;
  14. /**
  15. * @type {string}
  16. */
  17. private debugProtectionFunctionName: string;
  18. /**
  19. * @param debugProtectionFunctionName
  20. * @param options
  21. */
  22. constructor (debugProtectionFunctionName: string, options: IOptions) {
  23. super(options);
  24. this.debugProtectionFunctionName = debugProtectionFunctionName;
  25. }
  26. /**
  27. * @param blockScopeNode
  28. */
  29. public appendNode (blockScopeNode: TNodeWithBlockStatement): void {
  30. NodeUtils.appendNode(blockScopeNode, this.getNode());
  31. }
  32. /**
  33. * @returns {TStatement[]}
  34. */
  35. protected getNodeStructure (): TStatement[] {
  36. return NodeUtils.convertCodeToStructure(
  37. DebugProtectionFunctionIntervalTemplate().formatUnicorn({
  38. debugProtectionFunctionName: this.debugProtectionFunctionName
  39. })
  40. );
  41. }
  42. }