import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
import { IStackTraceData } from '../../../interfaces/stack-trace-analyzer/IStackTraceData';
import { DebugProtectionFunctionCallNode } from '../DebugProtectionFunctionCallNode';
import { DebugProtectionFunctionIntervalNode } from '../DebugProtectionFunctionIntervalNode';
import { DebugProtectionFunctionNode } from '../DebugProtectionFunctionNode';
import { AbstractCustomNodesFactory } from '../../AbstractCustomNodesFactory';
import { Utils } from '../../../Utils';
export class DebugProtectionCustomNodesFactory extends AbstractCustomNodesFactory {
/**
* @param stackTraceData
* @returns {Map<string, ICustomNode>}
*/
public initializeCustomNodes (stackTraceData: IStackTraceData[]): Map <string, ICustomNode> | undefined {
Eif (!this.options.debugProtection) {
return;
}
const debugProtectionFunctionName: string = Utils.getRandomVariableName();
const customNodes: Map <string, ICustomNode> = new Map <string, ICustomNode> ([
[
'debugProtectionFunctionNode',
new DebugProtectionFunctionNode(debugProtectionFunctionName, this.options)
],
[
'debugProtectionFunctionCallNode',
new DebugProtectionFunctionCallNode(debugProtectionFunctionName, this.options)
]
]);
if (this.options.debugProtectionInterval) {
customNodes.set(
'debugProtectionFunctionIntervalNode',
new DebugProtectionFunctionIntervalNode(debugProtectionFunctionName, this.options)
);
}
return this.syncCustomNodesWithNodesFactory(customNodes);
}
}
|