javascript-obfuscator 3.1.0 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +90 -6
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.LICENSE.txt +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cli.js +1 -1
- package/dist/index.cli.js.LICENSE.txt +1 -1
- package/dist/index.cli.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.LICENSE.txt +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +13 -12
- package/typings/src/constants/ReservedIdentifierNames.d.ts +1 -0
- package/typings/src/container/ServiceIdentifiers.d.ts +2 -1
- package/typings/src/custom-nodes/control-flow-flattening-nodes/{StringLiteralNode.d.ts → LiteralNode.d.ts} +4 -3
- package/typings/src/custom-nodes/control-flow-flattening-nodes/control-flow-storage-nodes/ControlFlowStorageNode.d.ts +2 -2
- package/typings/src/enums/custom-nodes/ControlFlowCustomNode.d.ts +2 -2
- package/typings/src/enums/node-transformers/NodeTransformer.d.ts +1 -0
- package/typings/src/enums/node-transformers/control-flow-transformers/control-flow-replacers/ControlFlowReplacer.d.ts +1 -0
- package/typings/src/enums/storages/ControlFlowStorage.d.ts +4 -0
- package/typings/src/generators/identifier-names-generators/AbstractIdentifierNamesGenerator.d.ts +3 -2
- package/typings/src/generators/identifier-names-generators/DictionaryIdentifierNamesGenerator.d.ts +1 -0
- package/typings/src/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.d.ts +1 -0
- package/typings/src/generators/identifier-names-generators/MangledIdentifierNamesGenerator.d.ts +9 -2
- package/typings/src/generators/identifier-names-generators/MangledShuffledIdentifierNamesGenerator.d.ts +2 -2
- package/typings/src/interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator.d.ts +1 -0
- package/typings/src/interfaces/node-transformers/control-flow-transformers/IControlFlowReplacer.d.ts +3 -2
- package/typings/src/interfaces/node-transformers/simplifying-transformers/IIteratedStatementsSimplifyData.d.ts +1 -0
- package/typings/src/interfaces/options/IOptions.d.ts +2 -0
- package/typings/src/interfaces/storages/IWeakMapStorage.d.ts +9 -0
- package/typings/src/interfaces/storages/control-flow-transformers/IControlFlowStorage.d.ts +4 -0
- package/typings/src/interfaces/storages/string-array-transformers/IStringArrayScopeCallsWrappersDataStorage.d.ts +2 -2
- package/typings/src/interfaces/utils/ISetUtils.d.ts +3 -0
- package/typings/src/node/NodeGuards.d.ts +1 -1
- package/typings/src/node/NodeLiteralUtils.d.ts +2 -0
- package/typings/src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.d.ts +22 -13
- package/typings/src/node-transformers/control-flow-transformers/StringArrayControlFlowTransformer.d.ts +26 -0
- package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/AbstractControlFlowReplacer.d.ts +8 -5
- package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/BinaryExpressionControlFlowReplacer.d.ts +4 -3
- package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/CallExpressionControlFlowReplacer.d.ts +4 -3
- package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/ExpressionWithOperatorControlFlowReplacer.d.ts +2 -1
- package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/LogicalExpressionControlFlowReplacer.d.ts +4 -3
- package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/StringArrayCallControlFlowReplacer.d.ts +14 -0
- package/typings/src/node-transformers/control-flow-transformers/control-flow-replacers/StringLiteralControlFlowReplacer.d.ts +5 -4
- package/typings/src/node-transformers/dead-code-injection-transformers/DeadCodeInjectionTransformer.d.ts +0 -2
- package/typings/src/options/Options.d.ts +2 -0
- package/typings/src/options/normalizer-rules/StringArrayCallsTransformThresholdRule.d.ts +2 -0
- package/typings/src/storages/WeakMapStorage.d.ts +17 -0
- package/typings/src/storages/control-flow-transformers/FunctionControlFlowStorage.d.ts +11 -0
- package/typings/src/storages/control-flow-transformers/StringControlFlowStorage.d.ts +8 -0
- package/typings/src/storages/string-array-transformers/StringArrayScopeCallsWrappersDataStorage.d.ts +2 -2
- package/typings/src/types/container/node-transformers/TControlFlowStorageFactory.d.ts +2 -2
- package/typings/src/types/container/node-transformers/TControlFlowStorageFactoryCreator.d.ts +3 -0
- package/typings/src/types/node/TNumberLiteralNode.d.ts +4 -0
- package/typings/src/utils/SetUtils.d.ts +7 -0
- package/typings/src/storages/custom-nodes/ControlFlowStorage.d.ts +0 -7
- package/typings/src/types/storages/TControlFlowStorage.d.ts +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "javascript-obfuscator",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.3",
|
|
4
4
|
"description": "JavaScript obfuscator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"obfuscator",
|
|
@@ -53,45 +53,46 @@
|
|
|
53
53
|
"@types/eslint-scope": "3.7.3",
|
|
54
54
|
"@types/eslint-visitor-keys": "1.0.0",
|
|
55
55
|
"@types/estraverse": "5.1.1",
|
|
56
|
-
"@types/estree": "0.0.
|
|
56
|
+
"@types/estree": "0.0.51",
|
|
57
57
|
"@types/js-beautify": "1.13.3",
|
|
58
58
|
"@types/js-string-escape": "1.0.1",
|
|
59
59
|
"@types/md5": "2.3.1",
|
|
60
60
|
"@types/mkdirp": "1.0.2",
|
|
61
61
|
"@types/mocha": "9.1.0",
|
|
62
62
|
"@types/multimatch": "4.0.0",
|
|
63
|
-
"@types/node": "17.0.
|
|
63
|
+
"@types/node": "17.0.15",
|
|
64
64
|
"@types/rimraf": "3.0.2",
|
|
65
|
-
"@types/sinon": "10.0.
|
|
65
|
+
"@types/sinon": "10.0.10",
|
|
66
66
|
"@types/string-template": "1.0.2",
|
|
67
67
|
"@types/webpack-env": "1.16.3",
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "5.10.
|
|
69
|
-
"@typescript-eslint/parser": "5.10.
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "5.10.2",
|
|
69
|
+
"@typescript-eslint/parser": "5.10.2",
|
|
70
70
|
"chai": "4.3.6",
|
|
71
71
|
"chai-exclude": "2.1.0",
|
|
72
72
|
"cross-env": "7.0.3",
|
|
73
73
|
"eslint": "8.8.0",
|
|
74
74
|
"eslint-plugin-import": "2.25.4",
|
|
75
|
-
"eslint-plugin-jsdoc": "37.7.
|
|
75
|
+
"eslint-plugin-jsdoc": "37.7.1",
|
|
76
76
|
"eslint-plugin-no-null": "1.0.2",
|
|
77
77
|
"eslint-plugin-prefer-arrow": "1.2.3",
|
|
78
78
|
"eslint-plugin-unicorn": "40.1.0",
|
|
79
|
+
"eslint-webpack-plugin": "3.1.1",
|
|
79
80
|
"fork-ts-checker-notifier-webpack-plugin": "4.0.0",
|
|
80
|
-
"fork-ts-checker-webpack-plugin": "
|
|
81
|
+
"fork-ts-checker-webpack-plugin": "7.0.0",
|
|
81
82
|
"husky": "7.0.4",
|
|
82
83
|
"js-beautify": "1.14.0",
|
|
83
84
|
"mocha": "9.2.0",
|
|
84
85
|
"nyc": "15.1.0",
|
|
85
86
|
"pjson": "1.0.9",
|
|
86
87
|
"rimraf": "3.0.2",
|
|
87
|
-
"sinon": "13.0.
|
|
88
|
+
"sinon": "13.0.1",
|
|
88
89
|
"source-map-resolve": "0.6.0",
|
|
89
90
|
"terser": "5.10.0",
|
|
90
91
|
"threads": "1.7.0",
|
|
91
92
|
"ts-loader": "9.2.6",
|
|
92
93
|
"ts-node": "10.4.0",
|
|
93
94
|
"typescript": "4.5.5",
|
|
94
|
-
"webpack": "5.
|
|
95
|
+
"webpack": "5.68.0",
|
|
95
96
|
"webpack-cli": "4.9.2",
|
|
96
97
|
"webpack-node-externals": "3.0.0"
|
|
97
98
|
},
|
|
@@ -111,9 +112,9 @@
|
|
|
111
112
|
"test:devRuntimePerformance": "ts-node test/dev/dev-runtime-performance.ts",
|
|
112
113
|
"test:full": "yarn run test:dev && yarn run test:mocha-coverage && yarn run test:mocha-memory-performance",
|
|
113
114
|
"test:mocha": "mocha --require ts-node/register --require source-map-support/register test/index.spec.ts --exit",
|
|
114
|
-
"test:mocha-coverage": "nyc --reporter text-summary --no-clean yarn run test:mocha",
|
|
115
|
+
"test:mocha-coverage": "NODE_OPTIONS=--max-old-space-size=4096 nyc --reporter text-summary --no-clean yarn run test:mocha",
|
|
115
116
|
"test:mocha-coverage:report": "nyc report --reporter=lcov",
|
|
116
|
-
"test:mocha-memory-performance": "cross-env NODE_OPTIONS=--max-old-space-size=
|
|
117
|
+
"test:mocha-memory-performance": "cross-env NODE_OPTIONS=--max-old-space-size=240 mocha --require ts-node/register test/performance-tests/JavaScriptObfuscatorMemory.spec.ts",
|
|
117
118
|
"test": "yarn run test:full",
|
|
118
119
|
"eslint": "eslint src/**/*.ts",
|
|
119
120
|
"git:addFiles": "git add .",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const reservedIdentifierNames: string[];
|
|
@@ -21,6 +21,7 @@ export declare enum ServiceIdentifiers {
|
|
|
21
21
|
ICodeTransformer = "ICodeTransformer",
|
|
22
22
|
ICodeTransformerNamesGroupsBuilder = "ICodeTransformerNamesGroupsBuilder",
|
|
23
23
|
ICodeTransformersRunner = "ICodeTransformersRunner",
|
|
24
|
+
IControlFlowStorage = "IControlFlowStorage",
|
|
24
25
|
ICryptUtils = "ICryptUtils",
|
|
25
26
|
ICryptUtilsStringArray = "ICryptUtilsStringArray",
|
|
26
27
|
ICustomCodeHelper = "ICustomCodeHelper",
|
|
@@ -50,6 +51,7 @@ export declare enum ServiceIdentifiers {
|
|
|
50
51
|
IRandomGenerator = "IRandomGenerator",
|
|
51
52
|
IRenamePropertiesReplacer = "IRenamePropertiesReplacer",
|
|
52
53
|
IScopeIdentifiersTraverser = "IScopeIdentifiersTraverser",
|
|
54
|
+
ISetUtils = "ISetUtils",
|
|
53
55
|
ISourceCode = "ISourceCode",
|
|
54
56
|
IScopeAnalyzer = "IScopeAnalyzer",
|
|
55
57
|
IStringArrayIndexNode = "IStringArrayIndexNode",
|
|
@@ -59,7 +61,6 @@ export declare enum ServiceIdentifiers {
|
|
|
59
61
|
IThroughIdentifierReplacer = "IThroughIdentifierReplacer",
|
|
60
62
|
IVisitedLexicalScopeNodesStackStorage = "IVisitedLexicalScopeNodesStackStorage",
|
|
61
63
|
Newable__ICustomNode = "Newable<ICustomNode>",
|
|
62
|
-
Newable__TControlFlowStorage = "Newable<TControlFlowStorage>",
|
|
63
64
|
TCustomNodeGroupStorage = "TCustomNodeGroupStorage",
|
|
64
65
|
TInputOptions = "TInputOptions"
|
|
65
66
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import type * as ESTree from 'estree';
|
|
1
2
|
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
|
|
2
3
|
import { TStatement } from '../../types/node/TStatement';
|
|
3
4
|
import { ICustomCodeHelperFormatter } from '../../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
|
|
4
5
|
import { IOptions } from '../../interfaces/options/IOptions';
|
|
5
6
|
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
|
|
6
7
|
import { AbstractCustomNode } from '../AbstractCustomNode';
|
|
7
|
-
export declare class
|
|
8
|
-
private
|
|
8
|
+
export declare class LiteralNode extends AbstractCustomNode {
|
|
9
|
+
private literalNode;
|
|
9
10
|
constructor(identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, customCodeHelperFormatter: ICustomCodeHelperFormatter, randomGenerator: IRandomGenerator, options: IOptions);
|
|
10
|
-
initialize(
|
|
11
|
+
initialize(literalNode: ESTree.Literal): void;
|
|
11
12
|
protected getNodeStructure(): TStatement[];
|
|
12
13
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TControlFlowStorage } from '../../../types/storages/TControlFlowStorage';
|
|
2
1
|
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
|
|
3
2
|
import { TStatement } from '../../../types/node/TStatement';
|
|
3
|
+
import { IControlFlowStorage } from '../../../interfaces/storages/control-flow-transformers/IControlFlowStorage';
|
|
4
4
|
import { ICustomCodeHelperFormatter } from '../../../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
|
|
5
5
|
import { IOptions } from '../../../interfaces/options/IOptions';
|
|
6
6
|
import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
|
|
@@ -8,6 +8,6 @@ import { AbstractCustomNode } from '../../AbstractCustomNode';
|
|
|
8
8
|
export declare class ControlFlowStorageNode extends AbstractCustomNode {
|
|
9
9
|
private controlFlowStorage;
|
|
10
10
|
constructor(identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, customCodeHelperFormatter: ICustomCodeHelperFormatter, randomGenerator: IRandomGenerator, options: IOptions);
|
|
11
|
-
initialize(controlFlowStorage:
|
|
11
|
+
initialize(controlFlowStorage: IControlFlowStorage): void;
|
|
12
12
|
protected getNodeStructure(): TStatement[];
|
|
13
13
|
}
|
|
@@ -5,7 +5,7 @@ export declare enum ControlFlowCustomNode {
|
|
|
5
5
|
CallExpressionFunctionNode = "CallExpressionFunctionNode",
|
|
6
6
|
ControlFlowStorageNode = "ControlFlowStorageNode",
|
|
7
7
|
ExpressionWithOperatorControlFlowStorageCallNode = "ExpressionWithOperatorControlFlowStorageCallNode",
|
|
8
|
+
LiteralNode = "LiteralNode",
|
|
8
9
|
LogicalExpressionFunctionNode = "LogicalExpressionFunctionNode",
|
|
9
|
-
StringLiteralControlFlowStorageCallNode = "StringLiteralControlFlowStorageCallNode"
|
|
10
|
-
StringLiteralNode = "StringLiteralNode"
|
|
10
|
+
StringLiteralControlFlowStorageCallNode = "StringLiteralControlFlowStorageCallNode"
|
|
11
11
|
}
|
|
@@ -28,6 +28,7 @@ export declare enum NodeTransformer {
|
|
|
28
28
|
ScopeIdentifiersTransformer = "ScopeIdentifiersTransformer",
|
|
29
29
|
ScopeThroughIdentifiersTransformer = "ScopeThroughIdentifiersTransformer",
|
|
30
30
|
SplitStringTransformer = "SplitStringTransformer",
|
|
31
|
+
StringArrayControlFlowTransformer = "StringArrayControlFlowTransformer",
|
|
31
32
|
StringArrayTransformer = "StringArrayTransformer",
|
|
32
33
|
StringArrayRotateFunctionTransformer = "StringArrayRotateFunctionTransformer",
|
|
33
34
|
StringArrayScopeCallsWrapperTransformer = "StringArrayScopeCallsWrapperTransformer",
|
|
@@ -2,5 +2,6 @@ export declare enum ControlFlowReplacer {
|
|
|
2
2
|
BinaryExpressionControlFlowReplacer = "BinaryExpressionControlFlowReplacer",
|
|
3
3
|
CallExpressionControlFlowReplacer = "CallExpressionControlFlowReplacer",
|
|
4
4
|
LogicalExpressionControlFlowReplacer = "LogicalExpressionControlFlowReplacer",
|
|
5
|
+
StringArrayCallControlFlowReplacer = "StringArrayCallControlFlowReplacer",
|
|
5
6
|
StringLiteralControlFlowReplacer = "StringLiteralControlFlowReplacer"
|
|
6
7
|
}
|
package/typings/src/generators/identifier-names-generators/AbstractIdentifierNamesGenerator.d.ts
CHANGED
|
@@ -6,15 +6,16 @@ export declare abstract class AbstractIdentifierNamesGenerator implements IIdent
|
|
|
6
6
|
protected readonly options: IOptions;
|
|
7
7
|
protected readonly randomGenerator: IRandomGenerator;
|
|
8
8
|
protected readonly preservedNamesSet: Set<string>;
|
|
9
|
-
protected readonly lexicalScopesPreservedNamesMap:
|
|
9
|
+
protected readonly lexicalScopesPreservedNamesMap: WeakMap<TNodeWithLexicalScope, Set<string>>;
|
|
10
10
|
constructor(randomGenerator: IRandomGenerator, options: IOptions);
|
|
11
11
|
generate(lexicalScopeNode: TNodeWithLexicalScope, nameLength?: number): string;
|
|
12
12
|
preserveName(name: string): void;
|
|
13
13
|
preserveNameForLexicalScope(name: string, lexicalScopeNode: TNodeWithLexicalScope): void;
|
|
14
14
|
isValidIdentifierName(name: string): boolean;
|
|
15
15
|
isValidIdentifierNameInLexicalScopes(name: string, lexicalScopeNodes: TNodeWithLexicalScope[]): boolean;
|
|
16
|
-
private
|
|
16
|
+
private isReservedName;
|
|
17
17
|
abstract generateForGlobalScope(nameLength?: number): string;
|
|
18
18
|
abstract generateForLexicalScope(lexicalScopeNode: TNodeWithLexicalScope, nameLength?: number): string;
|
|
19
|
+
abstract generateForLabel(label: string, nameLength?: number): string;
|
|
19
20
|
abstract generateNext(nameLength?: number): string;
|
|
20
21
|
}
|
package/typings/src/generators/identifier-names-generators/DictionaryIdentifierNamesGenerator.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class DictionaryIdentifierNamesGenerator extends AbstractIdentifi
|
|
|
12
12
|
generateNext(): string;
|
|
13
13
|
generateForGlobalScope(): string;
|
|
14
14
|
generateForLexicalScope(lexicalScopeNode: TNodeWithLexicalScope): string;
|
|
15
|
+
generateForLabel(label: string): string;
|
|
15
16
|
private generateNewDictionaryName;
|
|
16
17
|
private getInitialIdentifierNames;
|
|
17
18
|
private getIncrementedIdentifierNames;
|
package/typings/src/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.d.ts
CHANGED
|
@@ -8,4 +8,5 @@ export declare class HexadecimalIdentifierNamesGenerator extends AbstractIdentif
|
|
|
8
8
|
generateNext(nameLength?: number): string;
|
|
9
9
|
generateForGlobalScope(nameLength?: number): string;
|
|
10
10
|
generateForLexicalScope(lexicalScopeNode: TNodeWithLexicalScope, nameLength?: number): string;
|
|
11
|
+
generateForLabel(label: string, nameLength?: number): string;
|
|
11
12
|
}
|
package/typings/src/generators/identifier-names-generators/MangledIdentifierNamesGenerator.d.ts
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope';
|
|
2
2
|
import { IOptions } from '../../interfaces/options/IOptions';
|
|
3
3
|
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
|
|
4
|
+
import { ISetUtils } from '../../interfaces/utils/ISetUtils';
|
|
4
5
|
import { AbstractIdentifierNamesGenerator } from './AbstractIdentifierNamesGenerator';
|
|
5
6
|
export declare class MangledIdentifierNamesGenerator extends AbstractIdentifierNamesGenerator {
|
|
7
|
+
private static readonly maxRegenerationAttempts;
|
|
6
8
|
private static readonly initMangledNameCharacter;
|
|
7
9
|
private static readonly lastMangledNameInScopeMap;
|
|
8
10
|
private static readonly nameSequence;
|
|
9
11
|
private static readonly reservedNamesSet;
|
|
12
|
+
private readonly lastMangledNameForLabelMap;
|
|
10
13
|
private previousMangledName;
|
|
11
|
-
|
|
14
|
+
private readonly setUtils;
|
|
15
|
+
constructor(randomGenerator: IRandomGenerator, options: IOptions, setUtils: ISetUtils);
|
|
12
16
|
generateNext(nameLength?: number): string;
|
|
13
17
|
generateForGlobalScope(nameLength?: number): string;
|
|
14
18
|
generateForLexicalScope(lexicalScopeNode: TNodeWithLexicalScope, nameLength?: number): string;
|
|
19
|
+
generateForLabel(label: string, nameLength?: number): string;
|
|
15
20
|
isIncrementedMangledName(nextName: string, prevName: string): boolean;
|
|
16
21
|
isValidIdentifierName(mangledName: string): boolean;
|
|
17
22
|
protected getNameSequence(): string[];
|
|
18
23
|
protected updatePreviousMangledName(name: string): void;
|
|
19
|
-
protected
|
|
24
|
+
protected updatePreviousMangledNameForLabel(name: string, label: string, lastMangledNameForLabel: string): void;
|
|
25
|
+
protected generateNewMangledName(previousMangledName: string, validationFunction?: (newIdentifierName: string) => boolean): string;
|
|
20
26
|
private getLastMangledNameForScopes;
|
|
27
|
+
private getLastMangledNameForLabel;
|
|
21
28
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { IArrayUtils } from '../../interfaces/utils/IArrayUtils';
|
|
2
2
|
import { IOptions } from '../../interfaces/options/IOptions';
|
|
3
3
|
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
|
|
4
|
+
import { ISetUtils } from '../../interfaces/utils/ISetUtils';
|
|
4
5
|
import { MangledIdentifierNamesGenerator } from './MangledIdentifierNamesGenerator';
|
|
5
6
|
export declare class MangledShuffledIdentifierNamesGenerator extends MangledIdentifierNamesGenerator {
|
|
6
7
|
protected static shuffledNameSequence: string[];
|
|
7
8
|
private readonly arrayUtils;
|
|
8
|
-
constructor(arrayUtils: IArrayUtils, randomGenerator: IRandomGenerator, options: IOptions);
|
|
9
|
+
constructor(arrayUtils: IArrayUtils, randomGenerator: IRandomGenerator, options: IOptions, setUtils: ISetUtils);
|
|
9
10
|
initialize(): void;
|
|
10
11
|
protected initializeNameSequence(nameSequence: string[]): void;
|
|
11
12
|
protected getNameSequence(): string[];
|
|
12
|
-
protected generateNewMangledName(previousMangledName: string): string;
|
|
13
13
|
}
|
package/typings/src/interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export interface IIdentifierNamesGenerator {
|
|
|
3
3
|
generate(lexicalScopeNode: TNodeWithLexicalScope, nameLength?: number): string;
|
|
4
4
|
generateForGlobalScope(nameLength?: number): string;
|
|
5
5
|
generateForLexicalScope(lexicalScopeNode: TNodeWithLexicalScope, nameLength?: number): string;
|
|
6
|
+
generateForLabel(label: string, nameLength?: number): string;
|
|
6
7
|
generateNext(nameLength?: number): string;
|
|
7
8
|
isValidIdentifierName(identifierName: string): boolean;
|
|
8
9
|
isValidIdentifierNameInLexicalScopes(identifierName: string, lexicalScopeNodes: TNodeWithLexicalScope[]): boolean;
|
package/typings/src/interfaces/node-transformers/control-flow-transformers/IControlFlowReplacer.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as ESTree from 'estree';
|
|
2
|
-
import {
|
|
2
|
+
import { IControlFlowStorage } from '../../storages/control-flow-transformers/IControlFlowStorage';
|
|
3
3
|
export interface IControlFlowReplacer {
|
|
4
|
-
replace(node: ESTree.Node, parentNode: ESTree.Node, controlFlowStorage:
|
|
4
|
+
replace(node: ESTree.Node, parentNode: ESTree.Node, controlFlowStorage: IControlFlowStorage): ESTree.Node;
|
|
5
|
+
generateStorageKey(controlFlowStorage: IControlFlowStorage): string;
|
|
5
6
|
}
|
|
@@ -46,6 +46,8 @@ export interface IOptions {
|
|
|
46
46
|
readonly splitStrings: boolean;
|
|
47
47
|
readonly splitStringsChunkLength: number;
|
|
48
48
|
readonly stringArray: boolean;
|
|
49
|
+
readonly stringArrayCallsTransform: boolean;
|
|
50
|
+
readonly stringArrayCallsTransformThreshold: number;
|
|
49
51
|
readonly stringArrayEncoding: TStringArrayEncoding[];
|
|
50
52
|
readonly stringArrayIndexesType: TStringArrayIndexesType[];
|
|
51
53
|
readonly stringArrayIndexShift: boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IInitializable } from '../IInitializable';
|
|
2
|
+
export interface IWeakMapStorage<K extends object, V> extends IInitializable {
|
|
3
|
+
get(key: K): V | undefined;
|
|
4
|
+
getOrThrow(key: K): V;
|
|
5
|
+
getStorage(): WeakMap<K, V>;
|
|
6
|
+
getStorageId(): string;
|
|
7
|
+
has(key: K): boolean;
|
|
8
|
+
set(key: K, value: V): void;
|
|
9
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TNodeWithLexicalScopeStatements } from '../../../types/node/TNodeWithLexicalScopeStatements';
|
|
2
2
|
import { TStringArrayScopeCallsWrappersDataByEncoding } from '../../../types/node-transformers/string-array-transformers/TStringArrayScopeCallsWrappersDataByEncoding';
|
|
3
|
-
import {
|
|
4
|
-
export interface IStringArrayScopeCallsWrappersDataStorage extends
|
|
3
|
+
import { IWeakMapStorage } from '../IWeakMapStorage';
|
|
4
|
+
export interface IStringArrayScopeCallsWrappersDataStorage extends IWeakMapStorage<TNodeWithLexicalScopeStatements, TStringArrayScopeCallsWrappersDataByEncoding> {
|
|
5
5
|
}
|
|
@@ -65,7 +65,7 @@ export declare class NodeGuards {
|
|
|
65
65
|
static isReturnStatementNode(node: ESTree.Node): node is ESTree.ReturnStatement;
|
|
66
66
|
static isSequenceExpressionNode(node: ESTree.Node): node is ESTree.SequenceExpression;
|
|
67
67
|
static isSpreadElementNode(node: ESTree.Node): node is ESTree.SpreadElement;
|
|
68
|
-
static isStaticBlockNode(node: ESTree.Node):
|
|
68
|
+
static isStaticBlockNode(node: ESTree.Node): node is ESTree.StaticBlock;
|
|
69
69
|
static isSuperNode(node: ESTree.Node): node is ESTree.Super;
|
|
70
70
|
static isSwitchCaseNode(node: ESTree.Node): node is ESTree.SwitchCase;
|
|
71
71
|
static isTaggedTemplateExpressionNode(node: ESTree.Node): node is ESTree.TaggedTemplateExpression;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as ESTree from 'estree';
|
|
2
|
+
import { TNumberLiteralNode } from '../types/node/TNumberLiteralNode';
|
|
2
3
|
import { TStringLiteralNode } from '../types/node/TStringLiteralNode';
|
|
3
4
|
export declare class NodeLiteralUtils {
|
|
5
|
+
static isNumberLiteralNode(literalNode: ESTree.Literal): literalNode is TNumberLiteralNode;
|
|
4
6
|
static isStringLiteralNode(literalNode: ESTree.Literal): literalNode is TStringLiteralNode;
|
|
5
7
|
static isProhibitedLiteralNode(literalNode: ESTree.Literal, parentNode: ESTree.Node): boolean;
|
|
6
8
|
}
|
package/typings/src/node-transformers/control-flow-transformers/FunctionControlFlowTransformer.d.ts
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
|
+
/// <reference types="estraverse" />
|
|
2
|
+
import * as estraverse from '@javascript-obfuscator/estraverse';
|
|
1
3
|
import * as ESTree from 'estree';
|
|
2
4
|
import { TControlFlowCustomNodeFactory } from '../../types/container/custom-nodes/TControlFlowCustomNodeFactory';
|
|
3
5
|
import { TControlFlowReplacerFactory } from '../../types/container/node-transformers/TControlFlowReplacerFactory';
|
|
4
6
|
import { TControlFlowStorageFactory } from '../../types/container/node-transformers/TControlFlowStorageFactory';
|
|
7
|
+
import { TControlFlowStorageFactoryCreator } from '../../types/container/node-transformers/TControlFlowStorageFactoryCreator';
|
|
8
|
+
import { TNodeWithStatements } from '../../types/node/TNodeWithStatements';
|
|
9
|
+
import { IControlFlowStorage } from '../../interfaces/storages/control-flow-transformers/IControlFlowStorage';
|
|
5
10
|
import { IOptions } from '../../interfaces/options/IOptions';
|
|
6
11
|
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
|
|
7
12
|
import { IVisitor } from '../../interfaces/node-transformers/IVisitor';
|
|
13
|
+
import { ControlFlowReplacer } from '../../enums/node-transformers/control-flow-transformers/control-flow-replacers/ControlFlowReplacer';
|
|
8
14
|
import { NodeTransformationStage } from '../../enums/node-transformers/NodeTransformationStage';
|
|
9
15
|
import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
|
|
10
16
|
export declare class FunctionControlFlowTransformer extends AbstractNodeTransformer {
|
|
11
|
-
private static readonly controlFlowReplacersMap;
|
|
12
17
|
private static readonly hostNodeSearchMinDepth;
|
|
13
18
|
private static readonly hostNodeSearchMaxDepth;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
protected readonly controlFlowReplacersMap: Map<string, ControlFlowReplacer>;
|
|
20
|
+
protected readonly controlFlowData: WeakMap<TNodeWithStatements, IControlFlowStorage>;
|
|
21
|
+
protected readonly hostNodesWithControlFlowNode: WeakMap<TNodeWithStatements, ESTree.VariableDeclaration>;
|
|
22
|
+
protected readonly controlFlowReplacerFactory: TControlFlowReplacerFactory;
|
|
23
|
+
protected controlFlowStorageFactory: TControlFlowStorageFactory;
|
|
24
|
+
protected readonly controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory;
|
|
25
|
+
protected readonly visitedFunctionNodes: WeakSet<ESTree.Function>;
|
|
26
|
+
constructor(controlFlowStorageFactoryCreator: TControlFlowStorageFactoryCreator, controlFlowReplacerFactory: TControlFlowReplacerFactory, controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
21
27
|
getVisitor(nodeTransformationStage: NodeTransformationStage): IVisitor | null;
|
|
22
28
|
transformNode(functionNode: ESTree.Function, parentNode: ESTree.Node): ESTree.Function;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
protected transformFunctionBody(functionNode: ESTree.Function, controlFlowStorage: IControlFlowStorage): void;
|
|
30
|
+
protected transformFunctionBodyNode(node: ESTree.Node, parentNode: ESTree.Node | null, functionNode: ESTree.Function, controlFlowStorage: IControlFlowStorage): estraverse.VisitorOption | ESTree.Node;
|
|
31
|
+
protected getHostNode(functionNodeBody: ESTree.BlockStatement): TNodeWithStatements;
|
|
32
|
+
protected getControlFlowStorage(hostNode: TNodeWithStatements): IControlFlowStorage;
|
|
33
|
+
protected getControlFlowStorageNode(controlFlowStorage: IControlFlowStorage): ESTree.VariableDeclaration;
|
|
34
|
+
protected appendControlFlowStorageNode(hostNode: TNodeWithStatements, controlFlowStorageNode: ESTree.VariableDeclaration): void;
|
|
35
|
+
protected isVisitedFunctionNode(node: ESTree.Node): boolean;
|
|
36
|
+
protected isAllowedTransformationByThreshold(): boolean;
|
|
28
37
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="estraverse" />
|
|
2
|
+
import * as estraverse from '@javascript-obfuscator/estraverse';
|
|
3
|
+
import * as ESTree from 'estree';
|
|
4
|
+
import { TControlFlowCustomNodeFactory } from '../../types/container/custom-nodes/TControlFlowCustomNodeFactory';
|
|
5
|
+
import { TControlFlowReplacerFactory } from '../../types/container/node-transformers/TControlFlowReplacerFactory';
|
|
6
|
+
import { TControlFlowStorageFactoryCreator } from '../../types/container/node-transformers/TControlFlowStorageFactoryCreator';
|
|
7
|
+
import { TNodeWithStatements } from '../../types/node/TNodeWithStatements';
|
|
8
|
+
import { IControlFlowStorage } from '../../interfaces/storages/control-flow-transformers/IControlFlowStorage';
|
|
9
|
+
import { IOptions } from '../../interfaces/options/IOptions';
|
|
10
|
+
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
|
|
11
|
+
import { IVisitor } from '../../interfaces/node-transformers/IVisitor';
|
|
12
|
+
import { ControlFlowReplacer } from '../../enums/node-transformers/control-flow-transformers/control-flow-replacers/ControlFlowReplacer';
|
|
13
|
+
import { NodeTransformationStage } from '../../enums/node-transformers/NodeTransformationStage';
|
|
14
|
+
import { NodeTransformer } from '../../enums/node-transformers/NodeTransformer';
|
|
15
|
+
import { FunctionControlFlowTransformer } from './FunctionControlFlowTransformer';
|
|
16
|
+
export declare class StringArrayControlFlowTransformer extends FunctionControlFlowTransformer {
|
|
17
|
+
readonly runAfter: NodeTransformer[];
|
|
18
|
+
protected readonly controlFlowReplacersMap: Map<string, ControlFlowReplacer>;
|
|
19
|
+
protected readonly controlFlowStorageNodes: WeakSet<ESTree.VariableDeclaration>;
|
|
20
|
+
constructor(controlFlowStorageFactoryCreator: TControlFlowStorageFactoryCreator, controlFlowReplacerFactory: TControlFlowReplacerFactory, controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
21
|
+
getVisitor(nodeTransformationStage: NodeTransformationStage): IVisitor | null;
|
|
22
|
+
protected transformFunctionBodyNode(node: ESTree.Node, parentNode: ESTree.Node | null, functionNode: ESTree.Function, controlFlowStorage: IControlFlowStorage): estraverse.VisitorOption | ESTree.Node;
|
|
23
|
+
protected getControlFlowStorage(hostNode: TNodeWithStatements): IControlFlowStorage;
|
|
24
|
+
protected appendControlFlowStorageNode(hostNode: TNodeWithStatements, controlFlowStorageNode: ESTree.VariableDeclaration): void;
|
|
25
|
+
protected isAllowedTransformationByThreshold(): boolean;
|
|
26
|
+
}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import * as ESTree from 'estree';
|
|
2
2
|
import { TControlFlowCustomNodeFactory } from '../../../types/container/custom-nodes/TControlFlowCustomNodeFactory';
|
|
3
|
-
import {
|
|
3
|
+
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
|
|
4
4
|
import { IControlFlowReplacer } from '../../../interfaces/node-transformers/control-flow-transformers/IControlFlowReplacer';
|
|
5
|
+
import { IControlFlowStorage } from '../../../interfaces/storages/control-flow-transformers/IControlFlowStorage';
|
|
5
6
|
import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
|
|
7
|
+
import { IIdentifierNamesGenerator } from '../../../interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator';
|
|
6
8
|
import { IOptions } from '../../../interfaces/options/IOptions';
|
|
7
9
|
import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
|
|
8
10
|
export declare abstract class AbstractControlFlowReplacer implements IControlFlowReplacer {
|
|
9
11
|
protected readonly controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory;
|
|
12
|
+
protected readonly identifierNamesGenerator: IIdentifierNamesGenerator;
|
|
10
13
|
protected readonly options: IOptions;
|
|
11
14
|
protected readonly randomGenerator: IRandomGenerator;
|
|
12
15
|
protected readonly replacerDataByControlFlowStorageId: Map<string, Map<string, string[]>>;
|
|
13
|
-
constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
14
|
-
|
|
15
|
-
protected insertCustomNodeToControlFlowStorage(customNode: ICustomNode, controlFlowStorage:
|
|
16
|
-
abstract replace(node: ESTree.Node, parentNode: ESTree.Node, controlFlowStorage:
|
|
16
|
+
constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
17
|
+
generateStorageKey(controlFlowStorage: IControlFlowStorage): string;
|
|
18
|
+
protected insertCustomNodeToControlFlowStorage(customNode: ICustomNode, controlFlowStorage: IControlFlowStorage, replacerId: string, usingExistingIdentifierChance: number): string;
|
|
19
|
+
abstract replace(node: ESTree.Node, parentNode: ESTree.Node, controlFlowStorage: IControlFlowStorage): ESTree.Node;
|
|
17
20
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as ESTree from 'estree';
|
|
2
2
|
import { TControlFlowCustomNodeFactory } from '../../../types/container/custom-nodes/TControlFlowCustomNodeFactory';
|
|
3
|
-
import {
|
|
3
|
+
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
|
|
4
|
+
import { IControlFlowStorage } from '../../../interfaces/storages/control-flow-transformers/IControlFlowStorage';
|
|
4
5
|
import { IOptions } from '../../../interfaces/options/IOptions';
|
|
5
6
|
import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
|
|
6
7
|
import { ExpressionWithOperatorControlFlowReplacer } from './ExpressionWithOperatorControlFlowReplacer';
|
|
7
8
|
export declare class BinaryExpressionControlFlowReplacer extends ExpressionWithOperatorControlFlowReplacer {
|
|
8
9
|
private static readonly usingExistingIdentifierChance;
|
|
9
|
-
constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
10
|
-
replace(binaryExpressionNode: ESTree.BinaryExpression, parentNode: ESTree.Node, controlFlowStorage:
|
|
10
|
+
constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
11
|
+
replace(binaryExpressionNode: ESTree.BinaryExpression, parentNode: ESTree.Node, controlFlowStorage: IControlFlowStorage): ESTree.Node;
|
|
11
12
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as ESTree from 'estree';
|
|
2
2
|
import { TControlFlowCustomNodeFactory } from '../../../types/container/custom-nodes/TControlFlowCustomNodeFactory';
|
|
3
|
-
import {
|
|
3
|
+
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
|
|
4
|
+
import { IControlFlowStorage } from '../../../interfaces/storages/control-flow-transformers/IControlFlowStorage';
|
|
4
5
|
import { IOptions } from '../../../interfaces/options/IOptions';
|
|
5
6
|
import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
|
|
6
7
|
import { AbstractControlFlowReplacer } from './AbstractControlFlowReplacer';
|
|
7
8
|
export declare class CallExpressionControlFlowReplacer extends AbstractControlFlowReplacer {
|
|
8
9
|
private static readonly usingExistingIdentifierChance;
|
|
9
|
-
constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
10
|
-
replace(callExpressionNode: ESTree.CallExpression, parentNode: ESTree.Node, controlFlowStorage:
|
|
10
|
+
constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
11
|
+
replace(callExpressionNode: ESTree.CallExpression, parentNode: ESTree.Node, controlFlowStorage: IControlFlowStorage): ESTree.Node;
|
|
11
12
|
protected getControlFlowStorageCallNode(controlFlowStorageId: string, storageKey: string, callee: ESTree.Expression, expressionArguments: (ESTree.Expression | ESTree.SpreadElement)[]): ESTree.Node;
|
|
12
13
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as ESTree from 'estree';
|
|
2
2
|
import { TControlFlowCustomNodeFactory } from '../../../types/container/custom-nodes/TControlFlowCustomNodeFactory';
|
|
3
|
+
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
|
|
3
4
|
import { IOptions } from '../../../interfaces/options/IOptions';
|
|
4
5
|
import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
|
|
5
6
|
import { AbstractControlFlowReplacer } from './AbstractControlFlowReplacer';
|
|
6
7
|
export declare abstract class ExpressionWithOperatorControlFlowReplacer extends AbstractControlFlowReplacer {
|
|
7
|
-
constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
8
|
+
constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
8
9
|
protected getControlFlowStorageCallNode(controlFlowStorageId: string, storageKey: string, leftExpression: ESTree.Expression, rightExpression: ESTree.Expression): ESTree.Node;
|
|
9
10
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as ESTree from 'estree';
|
|
2
2
|
import { TControlFlowCustomNodeFactory } from '../../../types/container/custom-nodes/TControlFlowCustomNodeFactory';
|
|
3
|
-
import {
|
|
3
|
+
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
|
|
4
|
+
import { IControlFlowStorage } from '../../../interfaces/storages/control-flow-transformers/IControlFlowStorage';
|
|
4
5
|
import { IOptions } from '../../../interfaces/options/IOptions';
|
|
5
6
|
import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
|
|
6
7
|
import { ExpressionWithOperatorControlFlowReplacer } from './ExpressionWithOperatorControlFlowReplacer';
|
|
7
8
|
export declare class LogicalExpressionControlFlowReplacer extends ExpressionWithOperatorControlFlowReplacer {
|
|
8
9
|
private static readonly usingExistingIdentifierChance;
|
|
9
|
-
constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
10
|
-
replace(logicalExpressionNode: ESTree.LogicalExpression, parentNode: ESTree.Node, controlFlowStorage:
|
|
10
|
+
constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
11
|
+
replace(logicalExpressionNode: ESTree.LogicalExpression, parentNode: ESTree.Node, controlFlowStorage: IControlFlowStorage): ESTree.Node;
|
|
11
12
|
private checkForProhibitedExpressions;
|
|
12
13
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as ESTree from 'estree';
|
|
2
|
+
import { TControlFlowCustomNodeFactory } from '../../../types/container/custom-nodes/TControlFlowCustomNodeFactory';
|
|
3
|
+
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
|
|
4
|
+
import { IControlFlowStorage } from '../../../interfaces/storages/control-flow-transformers/IControlFlowStorage';
|
|
5
|
+
import { IOptions } from '../../../interfaces/options/IOptions';
|
|
6
|
+
import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
|
|
7
|
+
import { AbstractControlFlowReplacer } from './AbstractControlFlowReplacer';
|
|
8
|
+
export declare class StringArrayCallControlFlowReplacer extends AbstractControlFlowReplacer {
|
|
9
|
+
private static readonly usingExistingIdentifierChance;
|
|
10
|
+
constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
11
|
+
replace(literalNode: ESTree.Literal, parentNode: ESTree.Node, controlFlowStorage: IControlFlowStorage): ESTree.Node;
|
|
12
|
+
generateStorageKey(controlFlowStorage: IControlFlowStorage): string;
|
|
13
|
+
protected getControlFlowStorageCallNode(controlFlowStorageId: string, storageKey: string): ESTree.Node;
|
|
14
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as ESTree from 'estree';
|
|
2
2
|
import { TControlFlowCustomNodeFactory } from '../../../types/container/custom-nodes/TControlFlowCustomNodeFactory';
|
|
3
|
-
import {
|
|
3
|
+
import { TIdentifierNamesGeneratorFactory } from '../../../types/container/generators/TIdentifierNamesGeneratorFactory';
|
|
4
|
+
import { IControlFlowStorage } from '../../../interfaces/storages/control-flow-transformers/IControlFlowStorage';
|
|
4
5
|
import { IOptions } from '../../../interfaces/options/IOptions';
|
|
5
6
|
import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
|
|
6
7
|
import { AbstractControlFlowReplacer } from './AbstractControlFlowReplacer';
|
|
7
8
|
export declare class StringLiteralControlFlowReplacer extends AbstractControlFlowReplacer {
|
|
8
|
-
|
|
9
|
-
constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
10
|
-
replace(literalNode: ESTree.Literal, parentNode: ESTree.Node, controlFlowStorage:
|
|
9
|
+
protected static readonly usingExistingIdentifierChance: number;
|
|
10
|
+
constructor(controlFlowCustomNodeFactory: TControlFlowCustomNodeFactory, identifierNamesGeneratorFactory: TIdentifierNamesGeneratorFactory, randomGenerator: IRandomGenerator, options: IOptions);
|
|
11
|
+
replace(literalNode: ESTree.Literal, parentNode: ESTree.Node, controlFlowStorage: IControlFlowStorage): ESTree.Node;
|
|
11
12
|
protected getControlFlowStorageCallNode(controlFlowStorageId: string, storageKey: string): ESTree.Node;
|
|
12
13
|
}
|
|
@@ -6,7 +6,6 @@ import { IOptions } from '../../interfaces/options/IOptions';
|
|
|
6
6
|
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
|
|
7
7
|
import { INodeTransformersRunner } from '../../interfaces/node-transformers/INodeTransformersRunner';
|
|
8
8
|
import { IVisitor } from '../../interfaces/node-transformers/IVisitor';
|
|
9
|
-
import { NodeTransformer } from '../../enums/node-transformers/NodeTransformer';
|
|
10
9
|
import { NodeTransformationStage } from '../../enums/node-transformers/NodeTransformationStage';
|
|
11
10
|
import { AbstractNodeTransformer } from '../AbstractNodeTransformer';
|
|
12
11
|
export declare class DeadCodeInjectionTransformer extends AbstractNodeTransformer {
|
|
@@ -14,7 +13,6 @@ export declare class DeadCodeInjectionTransformer extends AbstractNodeTransforme
|
|
|
14
13
|
private static readonly maxNestedBlockStatementsCount;
|
|
15
14
|
private static readonly minCollectedBlockStatementsCount;
|
|
16
15
|
private static readonly transformersToRenameBlockScopeIdentifiers;
|
|
17
|
-
readonly runAfter: NodeTransformer[];
|
|
18
16
|
private readonly deadCodeInjectionRootAstHostNodeSet;
|
|
19
17
|
private readonly collectedBlockStatements;
|
|
20
18
|
private collectedBlockStatementsTotalLength;
|
|
@@ -50,6 +50,8 @@ export declare class Options implements IOptions {
|
|
|
50
50
|
readonly splitStrings: boolean;
|
|
51
51
|
readonly splitStringsChunkLength: number;
|
|
52
52
|
readonly stringArray: boolean;
|
|
53
|
+
readonly stringArrayCallsTransform: boolean;
|
|
54
|
+
readonly stringArrayCallsTransformThreshold: number;
|
|
53
55
|
readonly stringArrayEncoding: TStringArrayEncoding[];
|
|
54
56
|
readonly stringArrayIndexesType: TStringArrayIndexesType[];
|
|
55
57
|
readonly stringArrayIndexShift: boolean;
|