mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Sync with master
This commit is contained in:
+12
-12
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-console */
|
||||
import { inject, injectable, } from 'inversify';
|
||||
import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
|
||||
|
||||
@@ -17,6 +18,16 @@ import { NodeFactory } from '../../../node/NodeFactory';
|
||||
|
||||
@injectable()
|
||||
export class RenamePropertiesReplacer implements IRenamePropertiesReplacer {
|
||||
/**
|
||||
* Properties list taken from `UglifyJS` and `terser`
|
||||
* https://github.com/mishoo/UglifyJS/blob/master/tools/domprops.json
|
||||
* https://github.com/terser/terser/blob/master/tools/domprops.js
|
||||
* Copyright 2012-2018 (c) Mihai Bazon <mihai.bazon@gmail.com>
|
||||
*
|
||||
* @type {Set<string>}
|
||||
*/
|
||||
private static readonly reservedDomPropertiesList: Set<string> = new Set(ReservedDomProperties);
|
||||
|
||||
/**
|
||||
* @type {IIdentifierNamesGenerator}
|
||||
*/
|
||||
@@ -33,17 +44,6 @@ export class RenamePropertiesReplacer implements IRenamePropertiesReplacer {
|
||||
*/
|
||||
private readonly options: IOptions;
|
||||
|
||||
/**
|
||||
* Properties list taken from `UglifyJS` and `terser`
|
||||
* https://github.com/mishoo/UglifyJS/blob/master/tools/domprops.json
|
||||
* https://github.com/terser/terser/blob/master/tools/domprops.js
|
||||
* Copyright 2012-2018 (c) Mihai Bazon <mihai.bazon@gmail.com>
|
||||
*
|
||||
* @type {Set<string>}
|
||||
*/
|
||||
private readonly reservedDomPropertiesList: Set<string> = new Set(ReservedDomProperties);
|
||||
|
||||
|
||||
/**
|
||||
* @param {TIdentifierNamesGeneratorFactory} identifierNamesGeneratorFactory
|
||||
* @param {IOptions} options
|
||||
@@ -128,6 +128,6 @@ export class RenamePropertiesReplacer implements IRenamePropertiesReplacer {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
private isReservedDomPropertyName (name: string): boolean {
|
||||
return this.reservedDomPropertiesList.has(name);
|
||||
return RenamePropertiesReplacer.reservedDomPropertiesList.has(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import { StringArrayEncoding } from '../../enums/node-transformers/string-array-
|
||||
import { MapStorage } from '../MapStorage';
|
||||
|
||||
@injectable()
|
||||
export class StringArrayStorage extends MapStorage <string, IStringArrayStorageItemData> implements IStringArrayStorage {
|
||||
export class StringArrayStorage extends MapStorage <`${string}-${TStringArrayEncoding}`, IStringArrayStorageItemData> implements IStringArrayStorage {
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
@@ -227,9 +227,9 @@ export class StringArrayStorage extends MapStorage <string, IStringArrayStorageI
|
||||
this.storage = new Map(
|
||||
this.arrayUtils
|
||||
.shuffle(Array.from(this.storage.entries()))
|
||||
.map<[string, IStringArrayStorageItemData]>(
|
||||
.map<[`${string}-${TStringArrayEncoding}`, IStringArrayStorageItemData]>(
|
||||
(
|
||||
[value, stringArrayStorageItemData]: [string, IStringArrayStorageItemData],
|
||||
[value, stringArrayStorageItemData],
|
||||
index: number
|
||||
) => {
|
||||
stringArrayStorageItemData.index = index;
|
||||
@@ -250,7 +250,9 @@ export class StringArrayStorage extends MapStorage <string, IStringArrayStorageI
|
||||
*/
|
||||
private getOrSetIfDoesNotExist (value: string): IStringArrayStorageItemData {
|
||||
const { encodedValue, encoding, decodeKey }: IEncodedValue = this.getEncodedValue(value);
|
||||
const storedStringArrayStorageItemData: IStringArrayStorageItemData | undefined = this.storage.get(encodedValue);
|
||||
|
||||
const cacheKey = <`${string}-${TStringArrayEncoding}`>`${encodedValue}-${encoding}`;
|
||||
const storedStringArrayStorageItemData: IStringArrayStorageItemData | undefined = this.storage.get(cacheKey);
|
||||
|
||||
if (storedStringArrayStorageItemData) {
|
||||
return storedStringArrayStorageItemData;
|
||||
@@ -264,7 +266,7 @@ export class StringArrayStorage extends MapStorage <string, IStringArrayStorageI
|
||||
index: this.getLength()
|
||||
};
|
||||
|
||||
this.storage.set(encodedValue, stringArrayStorageItemData);
|
||||
this.storage.set(cacheKey, stringArrayStorageItemData);
|
||||
|
||||
return stringArrayStorageItemData;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user