1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import type {NameGeneratorType} from '../generator/NameFactory';
17
18export interface INameObfuscationOption {
19
20  readonly mEnable: boolean;
21
22  readonly mNameGeneratorType?: NameGeneratorType;
23
24  readonly mRenameProperties: boolean;
25
26  mReservedNames?: string[];
27
28  mReservedProperties: string[];
29
30  mUniversalReservedProperties?: RegExp[];
31
32  readonly mDictionaryList?: string[];
33
34  readonly mKeepStringProperty?: boolean;
35
36  readonly mTopLevel?: boolean;
37
38  mReservedToplevelNames?: string[];
39
40  mUniversalReservedToplevelNames?: RegExp[];
41}
42
43export interface IFileNameObfuscationOption {
44
45  readonly mEnable: boolean;
46
47  readonly mNameGeneratorType: NameGeneratorType;
48
49  mReservedFileNames: string[];
50
51  mUniversalReservedFileNames?: RegExp[];
52
53  readonly mOhmUrlStatus?: OhmUrlStatus;
54}
55
56export interface IDeclarationCommentOption {
57
58  readonly mEnable: boolean,
59
60  mReservedComments: string[],
61
62  mUniversalReservedComments?: RegExp[]
63}
64
65export enum OhmUrlStatus {
66  NONE,
67  AT_BUNDLE,
68  NORMALIZED
69}
70
71export interface IPrinterOption {
72  
73  //Print obfuscation time&memory usage of all files and obfuscation processes
74  readonly mFilesPrinter?: boolean;
75
76  //Print time&memory usage of a single file obfuscation in transform processes
77  readonly mSingleFilePrinter?: boolean;
78
79  //Print sum up time of transform processes during obfuscation
80  readonly mSumPrinter?: boolean;
81
82  //Output path of printer
83  readonly mOutputPath?: string;
84}
85
86/**
87 * It records which files cannot be obfuscated (except for file name obfuscation) and their dependent files.
88 * The names and properties exported in the dependent files are put into the whitelist.
89 */
90export interface IKeepSourcePathsAndDependency {
91  mKeepSourceOfPaths: Set<string>;
92  mkeepFilesAndDependencies: Set<string>;
93}
94
95export interface IUnobfuscationOption {
96  mPrintKeptNames: boolean;
97  mPrintPath: string;
98}