DebugProtectionFunctionIntervalNode.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 { NodeAppender } from '../../node/NodeAppender';
  9. import { NodeUtils } from '../../node/NodeUtils';
  10. export class DebugProtectionFunctionIntervalNode extends AbstractCustomNode {
  11. /**
  12. * @type {AppendState}
  13. */
  14. protected appendState: AppendState = AppendState.BeforeObfuscation;
  15. /**
  16. * @type {string}
  17. */
  18. private debugProtectionFunctionName: string;
  19. /**
  20. * @param debugProtectionFunctionName
  21. * @param options
  22. */
  23. constructor (debugProtectionFunctionName: string, options: IOptions) {
  24. super(options);
  25. this.debugProtectionFunctionName = debugProtectionFunctionName;
  26. }
  27. /**
  28. * @param blockScopeNode
  29. */
  30. public appendNode (blockScopeNode: TNodeWithBlockStatement): void {
  31. NodeAppender.appendNode(blockScopeNode, this.getNode());
  32. }
  33. /**
  34. * @returns {TStatement[]}
  35. */
  36. protected getNodeStructure (): TStatement[] {
  37. return NodeUtils.convertCodeToStructure(
  38. DebugProtectionFunctionIntervalTemplate().formatUnicorn({
  39. debugProtectionFunctionName: this.debugProtectionFunctionName
  40. })
  41. );
  42. }
  43. }