* Copyright (c) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { KeepInfo } from './ProjectCollections';
export namespace PropCollections {
export let globalMangledTable: Map<string, string> = new Map();
export let historyMangledTable: Map<string, string> = undefined;
export let reservedProperties: Set<string> = new Set();
export let universalReservedProperties: RegExp[] = [];
export let globalMangledNamesInCache: Set<string> = new Set();
export function clearPropsCollections(): void {
globalMangledTable.clear();
historyMangledTable?.clear();
reservedProperties.clear();
universalReservedProperties = [];
globalMangledNamesInCache.clear();
}
}
export namespace UnobfuscationCollections {
export let reservedSdkApiForProp: Set<string> = new Set();
export let reservedSdkApiForGlobal: Set<string> = new Set();
export let reservedSdkApiForLocal: Set<string> = new Set();
export let reservedStruct: Set<string> = new Set();
export let reservedLangForProperty: Set<string> = new Set();
export let reservedLangForTopLevel: Set<string> = new Set(['__global', 'default']);
export let reservedExportName: Set<string> = new Set();
export let reservedExportNameAndProp: Set<string> = new Set();
export let reservedStrProp: Set<string> = new Set();
export let reservedEnum: Set<string> = new Set();
export let reservedObjProp: Set<string> = new Set();
export let unobfuscatedPropMap: Map<string, Set<string>> = new Map();
export let unobfuscatedNamesMap: Map<string, Set<string>> = new Map();
export let reservedWildcardMap: Map<RegExp, string> = new Map();
export function clear(): void {
reservedSdkApiForProp.clear();
reservedSdkApiForGlobal.clear();
reservedSdkApiForLocal.clear();
reservedStruct.clear();
reservedLangForProperty.clear();
reservedExportName.clear();
reservedExportNameAndProp.clear();
reservedStrProp.clear();
reservedEnum.clear();
reservedObjProp.clear();
unobfuscatedPropMap.clear();
unobfuscatedNamesMap.clear();
reservedWildcardMap.clear();
}
}
export namespace LocalVariableCollections {
export let reservedConfig: Set<string> = new Set();
export let reservedLangForLocal: Set<string> = new Set(['this', '__global']);
export function clear(): void {
reservedConfig.clear();
}
}
export namespace AtKeepCollections {
export let keepSymbol: KeepInfo = {
propertyNames: new Set<string>(),
globalNames: new Set<string>()
};
export let keepAsConsumer: KeepInfo = {
propertyNames: new Set<string>(),
globalNames: new Set<string>()
};
export function clear(): void {
keepSymbol.globalNames.clear();
keepSymbol.propertyNames.clear();
keepAsConsumer.globalNames.clear();
keepAsConsumer.propertyNames.clear();
};
}
export namespace AtIntentCollections{
export let propertyNames: Set<string> = new Set();
export let globalNames: Set<string> = new Set();
export function clear(): void{
propertyNames.clear();
globalNames.clear();
}
}
export namespace BytecodeObfuscationCollections {
export let decoratorProp: Set<string> = new Set();
export function clear(): void {
decoratorProp.clear();
}
}