浏览代码

* @gradecam/tsenum replaced with an internal implementation
* Optimized performance of `ExpressionStatementsMergeTransformer` when `simplify` option is enabled

sanex 4 年之前
父节点
当前提交
381fd18177

+ 6 - 0
CHANGELOG.md

@@ -1,5 +1,11 @@
 Change Log
 
+v2.6.0
+---
+* Migration to `webpack@5`
+* Optimized performance of `ExpressionStatementsMergeTransformer` when `simplify` option is enabled
+
+
 v2.5.0
 ---
 * Improved hierarchy of generated directories when `--output` is a directory path

文件差异内容过多而无法显示
+ 0 - 23
dist/index.browser.js


+ 67 - 0
dist/index.browser.js.LICENSE.txt

@@ -0,0 +1,67 @@
+/*!
+ * Determine if an object is a Buffer
+ *
+ * @author   Feross Aboukhadijeh <https://feross.org>
+ * @license  MIT
+ */
+
+/*!
+ * The buffer module from node.js, for the browser.
+ *
+ * @author   Feross Aboukhadijeh <[email protected]> <http://feross.org>
+ * @license  MIT
+ */
+
+/*!
+Copyright (C) 2016-2020 Timofey Kachalov <[email protected]>
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+  * Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+  * Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*! *****************************************************************************
+Copyright (C) Microsoft. All rights reserved.
+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
+
+THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
+WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
+MERCHANTABLITY OR NON-INFRINGEMENT.
+
+See the Apache Version 2.0 License for specific language governing permissions
+and limitations under the License.
+***************************************************************************** */
+
+/*! *****************************************************************************
+Copyright (c) Microsoft Corporation.
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+***************************************************************************** */

文件差异内容过多而无法显示
+ 0 - 0
dist/index.cli.js


+ 23 - 0
dist/index.cli.js.LICENSE.txt

@@ -0,0 +1,23 @@
+/*!
+Copyright (C) 2016-2020 Timofey Kachalov <[email protected]>
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+  * Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+  * Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/

文件差异内容过多而无法显示
+ 0 - 0
dist/index.js


+ 23 - 0
dist/index.js.LICENSE.txt

@@ -0,0 +1,23 @@
+/*!
+Copyright (C) 2016-2020 Timofey Kachalov <[email protected]>
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+  * Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+  * Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/

+ 2 - 2
package.json

@@ -1,6 +1,6 @@
 {
   "name": "javascript-obfuscator",
-  "version": "2.5.0",
+  "version": "2.6.0",
   "description": "JavaScript obfuscator",
   "keywords": [
     "obfuscator",
@@ -21,9 +21,9 @@
   },
   "types": "index.d.ts",
   "dependencies": {
-    "@gradecam/tsenum": "1.2.0",
     "@nuxtjs/opencollective": "0.2.2",
     "acorn": "8.0.3",
+    "assert": "^2.0.0",
     "chalk": "4.1.0",
     "chance": "1.1.7",
     "class-validator": "0.12.2",

+ 1 - 1
src/enums/ObfuscationTarget.ts

@@ -1,4 +1,4 @@
-import { MakeEnum } from '@gradecam/tsenum';
+import { MakeEnum } from '../utils/TsEnum';
 
 export const ObfuscationTarget: Readonly<{
     Browser: 'browser';

+ 1 - 1
src/enums/generators/identifier-names-generators/IdentifierNamesGenerator.ts

@@ -1,4 +1,4 @@
-import { MakeEnum } from '@gradecam/tsenum';
+import { MakeEnum } from '../../../utils/TsEnum';
 
 export const IdentifierNamesGenerator: Readonly<{
     DictionaryIdentifierNamesGenerator: 'dictionary';

+ 1 - 1
src/enums/node-transformers/string-array-transformers/StringArrayEncoding.ts

@@ -1,4 +1,4 @@
-import { MakeEnum } from '@gradecam/tsenum';
+import { MakeEnum } from '../../../utils/TsEnum';
 
 export const StringArrayEncoding: Readonly<{
     None: 'none';

+ 1 - 1
src/enums/node-transformers/string-array-transformers/StringArrayWrappersType.ts

@@ -1,4 +1,4 @@
-import { MakeEnum } from '@gradecam/tsenum';
+import { MakeEnum } from '../../../utils/TsEnum';
 
 export const StringArrayWrappersType: Readonly<{
     Variable: 'variable';

+ 1 - 1
src/enums/options/presets/OptionsPreset.ts

@@ -1,4 +1,4 @@
-import { MakeEnum } from '@gradecam/tsenum';
+import { MakeEnum } from '../../../utils/TsEnum';
 
 export const OptionsPreset: Readonly<{
     Default: 'default';

+ 1 - 1
src/enums/source-map/SourceMapMode.ts

@@ -1,4 +1,4 @@
-import { MakeEnum } from '@gradecam/tsenum';
+import { MakeEnum } from '../../utils/TsEnum';
 
 export const SourceMapMode: Readonly<{
     Inline: 'inline';

+ 4 - 5
src/interfaces/options/IOptions.ts

@@ -1,8 +1,7 @@
-import { TypeFromEnum } from '@gradecam/tsenum';
-
 import { TOptionsPreset } from '../../types/options/TOptionsPreset';
 import { TStringArrayEncoding } from '../../types/options/TStringArrayEncoding';
 import { TStringArrayWrappersType } from '../../types/options/TStringArrayWrappersType';
+import { TTypeFromEnum } from '../../types/utils/TTypeFromEnym';
 
 import { IdentifierNamesGenerator } from '../../enums/generators/identifier-names-generators/IdentifierNamesGenerator';
 import { ObfuscationTarget } from '../../enums/ObfuscationTarget';
@@ -19,7 +18,7 @@ export interface IOptions {
     readonly disableConsoleOutput: boolean;
     readonly domainLock: string[];
     readonly forceTransformStrings: string[];
-    readonly identifierNamesGenerator: TypeFromEnum<typeof IdentifierNamesGenerator>;
+    readonly identifierNamesGenerator: TTypeFromEnum<typeof IdentifierNamesGenerator>;
     readonly identifiersDictionary: string[];
     readonly identifiersPrefix: string;
     readonly inputFileName: string;
@@ -38,7 +37,7 @@ export interface IOptions {
     readonly sourceMap: boolean;
     readonly sourceMapBaseUrl: string;
     readonly sourceMapFileName: string;
-    readonly sourceMapMode: TypeFromEnum<typeof SourceMapMode>;
+    readonly sourceMapMode: TTypeFromEnum<typeof SourceMapMode>;
     readonly splitStrings: boolean;
     readonly splitStringsChunkLength: number;
     readonly stringArray: boolean;
@@ -47,7 +46,7 @@ export interface IOptions {
     readonly stringArrayWrappersCount: number;
     readonly stringArrayWrappersType: TStringArrayWrappersType;
     readonly stringArrayThreshold: number;
-    readonly target: TypeFromEnum<typeof ObfuscationTarget>;
+    readonly target: TTypeFromEnum<typeof ObfuscationTarget>;
     readonly transformObjectKeys: boolean;
     readonly unicodeEscapeSequence: boolean;
 }

+ 4 - 2
src/node-transformers/simplifying-transformers/ExpressionStatementsMergeTransformer.ts

@@ -83,14 +83,16 @@ export class ExpressionStatementsMergeTransformer extends AbstractNodeTransforme
 
         if (NodeGuards.isSequenceExpressionNode(prevStatement.expression)) {
             prevStatement.expression.expressions.push(expressionStatementNode.expression);
+            NodeUtils.parentizeNode(expressionStatementNode.expression, prevStatement.expression);
         } else {
             prevStatement.expression = NodeFactory.sequenceExpressionNode([
                 prevStatement.expression,
                 expressionStatementNode.expression
             ]);
-        }
 
-        NodeUtils.parentizeAst(prevStatement);
+            NodeUtils.parentizeAst(prevStatement.expression);
+            NodeUtils.parentizeNode(prevStatement.expression, prevStatement);
+        }
 
         return estraverse.VisitorOption.Remove;
     }

+ 4 - 5
src/options/Options.ts

@@ -1,5 +1,3 @@
-import { TypeFromEnum } from '@gradecam/tsenum';
-
 import { inject, injectable } from 'inversify';
 import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
 
@@ -24,6 +22,7 @@ import { TInputOptions } from '../types/options/TInputOptions';
 import { TOptionsPreset } from '../types/options/TOptionsPreset';
 import { TStringArrayEncoding } from '../types/options/TStringArrayEncoding';
 import { TStringArrayWrappersType } from '../types/options/TStringArrayWrappersType';
+import { TTypeFromEnum } from '../types/utils/TTypeFromEnym';
 
 import { IOptions } from '../interfaces/options/IOptions';
 import { IOptionsNormalizer } from '../interfaces/options/IOptionsNormalizer';
@@ -147,7 +146,7 @@ export class Options implements IOptions {
         IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
         IdentifierNamesGenerator.MangledShuffledIdentifierNamesGenerator
     ])
-    public readonly identifierNamesGenerator!: TypeFromEnum<typeof IdentifierNamesGenerator>;
+    public readonly identifierNamesGenerator!: TTypeFromEnum<typeof IdentifierNamesGenerator>;
 
     /**
      * @type {string}
@@ -279,7 +278,7 @@ export class Options implements IOptions {
      * @type {SourceMapMode}
      */
     @IsIn([SourceMapMode.Inline, SourceMapMode.Separate])
-    public readonly sourceMapMode!: TypeFromEnum<typeof SourceMapMode>;
+    public readonly sourceMapMode!: TTypeFromEnum<typeof SourceMapMode>;
 
     /**
      * @type {boolean}
@@ -340,7 +339,7 @@ export class Options implements IOptions {
      * @type {ObfuscationTarget}
      */
     @IsIn([ObfuscationTarget.Browser, ObfuscationTarget.BrowserNoEval, ObfuscationTarget.Node])
-    public readonly target!: TypeFromEnum<typeof ObfuscationTarget>;
+    public readonly target!: TTypeFromEnum<typeof ObfuscationTarget>;
 
     /**
      * @type {boolean}

+ 3 - 2
src/options/validators/IsAllowedForObfuscationTargets.ts

@@ -1,7 +1,8 @@
 import { registerDecorator, ValidationArguments, ValidationOptions } from 'class-validator';
-import { TypeFromEnum } from '@gradecam/tsenum';
 import equal from 'fast-deep-equal';
 
+import { TTypeFromEnum } from '../../types/utils/TTypeFromEnym';
+
 import { IOptions } from '../../interfaces/options/IOptions';
 
 import { ObfuscationTarget } from '../../enums/ObfuscationTarget';
@@ -15,7 +16,7 @@ import { DEFAULT_PRESET } from '../presets/Default';
  * @returns {(options: IOptions, propertyName: keyof IOptions) => void}
  */
 export function IsAllowedForObfuscationTargets (
-    obfuscationTargets: TypeFromEnum<typeof ObfuscationTarget>[],
+    obfuscationTargets: TTypeFromEnum<typeof ObfuscationTarget>[],
     validationOptions?: ValidationOptions
 ): (options: IOptions, propertyName: keyof IOptions) => void {
     return (optionsObject: IOptions, propertyName: keyof IOptions): void => {

+ 2 - 2
src/types/options/TOptionsPreset.ts

@@ -1,5 +1,5 @@
-import { TypeFromEnum } from '@gradecam/tsenum';
+import { TTypeFromEnum } from '../utils/TTypeFromEnym';
 
 import { OptionsPreset } from '../../enums/options/presets/OptionsPreset';
 
-export type TOptionsPreset = TypeFromEnum<typeof OptionsPreset>;
+export type TOptionsPreset = TTypeFromEnum<typeof OptionsPreset>;

+ 2 - 2
src/types/options/TStringArrayEncoding.ts

@@ -1,5 +1,5 @@
-import { TypeFromEnum } from '@gradecam/tsenum';
+import { TTypeFromEnum } from '../utils/TTypeFromEnym';
 
 import { StringArrayEncoding } from '../../enums/node-transformers/string-array-transformers/StringArrayEncoding';
 
-export type TStringArrayEncoding = TypeFromEnum<typeof StringArrayEncoding>;
+export type TStringArrayEncoding = TTypeFromEnum<typeof StringArrayEncoding>;

+ 2 - 2
src/types/options/TStringArrayWrappersType.ts

@@ -1,5 +1,5 @@
-import { TypeFromEnum } from '@gradecam/tsenum';
+import { TTypeFromEnum } from '../utils/TTypeFromEnym';
 
 import { StringArrayWrappersType } from '../../enums/node-transformers/string-array-transformers/StringArrayWrappersType';
 
-export type TStringArrayWrappersType = TypeFromEnum<typeof StringArrayWrappersType>;
+export type TStringArrayWrappersType = TTypeFromEnum<typeof StringArrayWrappersType>;

+ 1 - 0
src/types/utils/TTypeFromEnym.ts

@@ -0,0 +1 @@
+export type TTypeFromEnum<T extends object> = (T)[keyof T];

+ 61 - 0
src/utils/TsEnum.ts

@@ -0,0 +1,61 @@
+/* eslint-disable no-redeclare */
+/**
+ * https://github.com/gradecam/tsenum
+ */
+export function MakeEnum<T1 extends {[index: string]: U}, U extends string> (x1: T1): Readonly<T1>;
+export function MakeEnum<T1 extends {[index: string]: U}
+    , T2 extends {[index: string]: U}
+    , U extends string> (x1: T1, x2: T2): Readonly<T1 & T2>;
+export function MakeEnum<T1 extends {[index: string]: U}
+    , T2 extends {[index: string]: U}
+    , T3 extends {[index: string]: U}
+    , U extends string> (x1: T1, x2: T2, x3: T3): Readonly<T1 & T2 & T3>;
+export function MakeEnum<T1 extends {[index: string]: U}
+    , T2 extends {[index: string]: U}
+    , T3 extends {[index: string]: U}
+    , T4 extends {[index: string]: U}
+    , U extends string> (x1: T1, x2: T2, x3: T3, x4: T4): Readonly<T1 & T2 & T3 & T4>;
+export function MakeEnum<T1 extends {[index: string]: U}
+    , T2 extends {[index: string]: U}
+    , T3 extends {[index: string]: U}
+    , T4 extends {[index: string]: U}
+    , T5 extends {[index: string]: U}
+    , U extends string> (x1: T1, x2: T2, x3: T3, x4: T4, x5: T5): Readonly<T1 & T2 & T3 & T4 & T5>;
+export function MakeEnum<T1 extends {[index: string]: U}
+    , T2 extends {[index: string]: U}
+    , T3 extends {[index: string]: U}
+    , T4 extends {[index: string]: U}
+    , T5 extends {[index: string]: U}
+    , T6 extends {[index: string]: U}
+    , U extends string> (x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6): Readonly<T1 & T2 & T3 & T4 & T5 & T6>;
+export function MakeEnum<T1 extends {[index: string]: U}
+    , T2 extends {[index: string]: U}
+    , T3 extends {[index: string]: U}
+    , T4 extends {[index: string]: U}
+    , T5 extends {[index: string]: U}
+    , T6 extends {[index: string]: U}
+    , T7 extends {[index: string]: U}
+    , U extends string> (x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7): Readonly<T1 & T2 & T3 & T4 & T5 & T6 & T7>;
+export function MakeEnum<T1 extends {[index: string]: U}
+    , T2 extends {[index: string]: U}
+    , T3 extends {[index: string]: U}
+    , T4 extends {[index: string]: U}
+    , T5 extends {[index: string]: U}
+    , T6 extends {[index: string]: U}
+    , T7 extends {[index: string]: U}
+    , T8 extends {[index: string]: U}
+    , U extends string> (x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8): Readonly<T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8>;
+export function MakeEnum<T1 extends {[index: string]: U}
+    , T2 extends {[index: string]: U}
+    , T3 extends {[index: string]: U}
+    , T4 extends {[index: string]: U}
+    , T5 extends {[index: string]: U}
+    , T6 extends {[index: string]: U}
+    , T7 extends {[index: string]: U}
+    , T8 extends {[index: string]: U}
+    , T9 extends {[index: string]: U}
+    , U extends string> (x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8, x9: T9): Readonly<T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9>;
+
+export function MakeEnum<T extends {[index: string]: U}, U extends string> (...x: T[]): Readonly<T> {
+    return Object.freeze(Object.assign({}, ...x));
+}

+ 4 - 4
test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts

@@ -1,9 +1,9 @@
 import { assert } from 'chai';
-import { TypeFromEnum } from '@gradecam/tsenum';
 
 import { TDictionary } from '../../../src/types/TDictionary';
 import { TInputOptions } from '../../../src/types/options/TInputOptions';
 import { TOptionsPreset } from '../../../src/types/options/TOptionsPreset';
+import { TTypeFromEnum } from '../../../src/types/utils/TTypeFromEnym';
 
 import { IObfuscatedCode } from '../../../src/interfaces/source-code/IObfuscatedCode';
 
@@ -921,12 +921,12 @@ describe('JavaScriptObfuscator', () => {
             const samplesCount: number = 30;
 
             let areCollisionsExists: boolean = false;
-            let obfuscateFunc: (identifierNamesGenerator: TypeFromEnum<typeof IdentifierNamesGenerator>) => string;
+            let obfuscateFunc: (identifierNamesGenerator: TTypeFromEnum<typeof IdentifierNamesGenerator>) => string;
 
             before(() => {
                 const code: string = readFileAsString(__dirname + '/fixtures/custom-nodes-identifier-names-collision.js');
 
-                obfuscateFunc = (identifierNamesGenerator: TypeFromEnum<typeof IdentifierNamesGenerator>) => {
+                obfuscateFunc = (identifierNamesGenerator: TTypeFromEnum<typeof IdentifierNamesGenerator>) => {
                     const obfuscatedCode = JavaScriptObfuscator.obfuscate(
                         code,
                         {
@@ -945,7 +945,7 @@ describe('JavaScriptObfuscator', () => {
                 [
                     IdentifierNamesGenerator.DictionaryIdentifierNamesGenerator,
                     IdentifierNamesGenerator.MangledIdentifierNamesGenerator
-                ].forEach((identifierNamesGenerator: TypeFromEnum<typeof IdentifierNamesGenerator>) => {
+                ].forEach((identifierNamesGenerator: TTypeFromEnum<typeof IdentifierNamesGenerator>) => {
                     for (let i = 0; i < samplesCount; i++) {
                         try {
                             eval(obfuscateFunc(identifierNamesGenerator));

+ 1 - 1
test/runtime-tests/JavaScriptObfuscatorRuntime.spec.ts

@@ -209,7 +209,7 @@ describe('JavaScriptObfuscator runtime eval', function () {
                     `
                         ${getEnvironmentCode()}
                         ${obfuscatedCode}
-                        module.exports.obfuscate('var foo = 1;').getObfuscatedCode();
+                        module.exports.JavaScriptObfuscator.obfuscate('var foo = 1;').getObfuscatedCode();
                     `,
                     evaluationTimeout
                 )

+ 3 - 2
test/unit-tests/source-code/ObfuscatedCode.spec.ts

@@ -1,10 +1,11 @@
 import 'reflect-metadata';
-import { TypeFromEnum } from '@gradecam/tsenum';
 
 import { ServiceIdentifiers } from '../../../src/container/ServiceIdentifiers';
 
 import { assert } from 'chai';
 
+import { TTypeFromEnum } from '../../../src/types/utils/TTypeFromEnym';
+
 import { IInversifyContainerFacade } from '../../../src/interfaces/container/IInversifyContainerFacade';
 import { IObfuscatedCode } from '../../../src/interfaces/source-code/IObfuscatedCode';
 
@@ -24,7 +25,7 @@ function getObfuscatedCode (
     sourceMap: string,
     sourceMapBaseUrl: string,
     sourceMapFileName: string,
-    sourceMapMode: TypeFromEnum<typeof SourceMapMode>
+    sourceMapMode: TTypeFromEnum<typeof SourceMapMode>
 ): IObfuscatedCode {
     const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
 

+ 3 - 0
webpack/webpack.browser.config.js

@@ -21,6 +21,9 @@ module.exports = {
         ]
     },
     resolve: {
+        alias: {
+            assert: 'assert'
+        },
         extensions: ['.ts', '.js']
     },
     plugins: [

+ 87 - 6
yarn.lock

@@ -902,11 +902,6 @@
     minimatch "^3.0.4"
     strip-json-comments "^3.1.1"
 
-"@gradecam/[email protected]":
-  version "1.2.0"
-  resolved "https://registry.yarnpkg.com/@gradecam/tsenum/-/tsenum-1.2.0.tgz#0c7c7c86e00e2d9ab8f242c695bec66b26b79319"
-  integrity sha512-61kSGjcgHBncY1WJ1Fc6VwMgHyMWMQ9A8oconZ3iYizWDKKV64JVYDFTRH/vGmaKlTQb0PXAhRzY7qnIBvYikw==
-
 "@istanbuljs/load-nyc-config@^1.0.0":
   version "1.1.0"
   resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced"
@@ -1637,6 +1632,11 @@ array-differ@^3.0.0:
   resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b"
   integrity sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg==
 
+array-filter@^1.0.0:
+  version "1.0.0"
+  resolved "https://registry.yarnpkg.com/array-filter/-/array-filter-1.0.0.tgz#baf79e62e6ef4c2a4c0b831232daffec251f9d83"
+  integrity sha1-uveeYubvTCpMC4MSMtr/7CUfnYM=
+
 array-includes@^3.1.1:
   version "3.1.1"
   resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.1.tgz#cdd67e6852bdf9c1215460786732255ed2459348"
@@ -1708,6 +1708,16 @@ [email protected], assert-plus@^1.0.0:
   resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525"
   integrity sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=
 
+assert@^2.0.0:
+  version "2.0.0"
+  resolved "https://registry.yarnpkg.com/assert/-/assert-2.0.0.tgz#95fc1c616d48713510680f2eaf2d10dd22e02d32"
+  integrity sha512-se5Cd+js9dXJnu6Ag2JFc00t+HmHOen+8Q+L7O9zI0PqQXr20uk2J0XQqMxZEeo5U50o8Nvmmx7dZrl+Ufr35A==
+  dependencies:
+    es6-object-assign "^1.1.0"
+    is-nan "^1.2.1"
+    object-is "^1.0.1"
+    util "^0.12.0"
+
 assertion-error@^1.1.0:
   version "1.1.0"
   resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b"
@@ -1755,6 +1765,13 @@ atob@^2.1.2:
   resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
   integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
 
+available-typed-arrays@^1.0.0, available-typed-arrays@^1.0.2:
+  version "1.0.2"
+  resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.2.tgz#6b098ca9d8039079ee3f77f7b783c4480ba513f5"
+  integrity sha512-XWX3OX8Onv97LMk/ftVyBibpGwY5a8SmuxZPzeOxqmuEqUCOM9ZE+uIaD1VNJ5QnvU2UQusvmKbuM1FR8QWGfQ==
+  dependencies:
+    array-filter "^1.0.0"
+
 aws-sign2@~0.7.0:
   version "0.7.0"
   resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8"
@@ -2728,7 +2745,7 @@ es-abstract@^1.17.0, es-abstract@^1.17.0-next.1, es-abstract@^1.17.4, es-abstrac
     string.prototype.trimend "^1.0.1"
     string.prototype.trimstart "^1.0.1"
 
-es-abstract@^1.18.0-next.0:
+es-abstract@^1.18.0-next.0, es-abstract@^1.18.0-next.1:
   version "1.18.0-next.1"
   resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.0-next.1.tgz#6e3a0a4bda717e5023ab3b8e90bec36108d22c68"
   integrity sha512-I4UGspA0wpZXWENrdA0uHbnhte683t3qT/1VFH9aX2dA5PPSf6QW5HHXf5HImaqPmjXaVeVk4RGWnaylmV7uAA==
@@ -2778,6 +2795,11 @@ es6-error@^4.0.1:
   resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d"
   integrity sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==
 
+es6-object-assign@^1.1.0:
+  version "1.1.0"
+  resolved "https://registry.yarnpkg.com/es6-object-assign/-/es6-object-assign-1.1.0.tgz#c2c3582656247c39ea107cb1e6652b6f9f24523c"
+  integrity sha1-wsNYJlYkfDnqEHyx5mUrb58kUjw=
+
 escalade@^3.1.0:
   version "3.1.0"
   resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.0.tgz#e8e2d7c7a8b76f6ee64c2181d6b8151441602d4e"
@@ -3306,6 +3328,11 @@ for-in@^1.0.2:
   resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
   integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=
 
+foreach@^2.0.5:
+  version "2.0.5"
+  resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
+  integrity sha1-C+4AUBiusmDQo6865ljdATbsG5k=
+
 foreground-child@^2.0.0:
   version "2.0.0"
   resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-2.0.0.tgz#71b32800c9f15aa8f2f83f4a6bd9bff35d861a53"
@@ -4001,6 +4028,11 @@ is-fullwidth-code-point@^3.0.0:
   resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d"
   integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==
 
+is-generator-function@^1.0.7:
+  version "1.0.7"
+  resolved "https://registry.yarnpkg.com/is-generator-function/-/is-generator-function-1.0.7.tgz#d2132e529bb0000a7f80794d4bdf5cd5e5813522"
+  integrity sha512-YZc5EwyO4f2kWCax7oegfuSr9mFz1ZvieNYBEjmukLxgXfBUbxAWGVF7GZf0zidYtoBl3WvC07YK0wT76a+Rtw==
+
 is-glob@^3.1.0:
   version "3.1.0"
   resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a"
@@ -4020,6 +4052,13 @@ is-map@^2.0.1:
   resolved "https://registry.yarnpkg.com/is-map/-/is-map-2.0.1.tgz#520dafc4307bb8ebc33b813de5ce7c9400d644a1"
   integrity sha512-T/S49scO8plUiAOA2DBTBG3JHpn1yiw0kRp6dgiZ0v2/6twi5eiB0rHtHFH9ZIrvlWc6+4O+m4zg5+Z833aXgw==
 
+is-nan@^1.2.1:
+  version "1.3.0"
+  resolved "https://registry.yarnpkg.com/is-nan/-/is-nan-1.3.0.tgz#85d1f5482f7051c2019f5673ccebdb06f3b0db03"
+  integrity sha512-z7bbREymOqt2CCaZVly8aC4ML3Xhfi0ekuOnjO2L8vKdl+CttdVoGZQhd4adMFAsxQ5VeRVwORs4tU8RH+HFtQ==
+  dependencies:
+    define-properties "^1.1.3"
+
 is-negative-zero@^2.0.0:
   version "2.0.0"
   resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.0.tgz#9553b121b0fac28869da9ed459e20c7543788461"
@@ -4107,6 +4146,16 @@ is-symbol@^1.0.2:
   dependencies:
     has-symbols "^1.0.1"
 
+is-typed-array@^1.1.3:
+  version "1.1.3"
+  resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.3.tgz#a4ff5a5e672e1a55f99c7f54e59597af5c1df04d"
+  integrity sha512-BSYUBOK/HJibQ30wWkWold5txYwMUXQct9YHAQJr8fSwvZoiglcqB0pd7vEN23+Tsi9IUEjztdOSzl4qLVYGTQ==
+  dependencies:
+    available-typed-arrays "^1.0.0"
+    es-abstract "^1.17.4"
+    foreach "^2.0.5"
+    has-symbols "^1.0.1"
+
 is-typedarray@^1.0.0, is-typedarray@~1.0.0:
   version "1.0.0"
   resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
@@ -5086,6 +5135,14 @@ object-inspect@^1.8.0:
   resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.8.0.tgz#df807e5ecf53a609cc6bfe93eac3cc7be5b3a9d0"
   integrity sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==
 
+object-is@^1.0.1:
+  version "1.1.3"
+  resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.3.tgz#2e3b9e65560137455ee3bd62aec4d90a2ea1cc81"
+  integrity sha512-teyqLvFWzLkq5B9ki8FVWA902UER2qkxmdA4nLf+wjOLAWgxzCWZNCxpDq9MvE8MmhWNr+I8w3BN49Vx36Y6Xg==
+  dependencies:
+    define-properties "^1.1.3"
+    es-abstract "^1.18.0-next.1"
+
 object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1:
   version "1.1.1"
   resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e"
@@ -6875,6 +6932,18 @@ util-deprecate@^1.0.1, util-deprecate@~1.0.1:
   resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
   integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=
 
+util@^0.12.0:
+  version "0.12.3"
+  resolved "https://registry.yarnpkg.com/util/-/util-0.12.3.tgz#971bb0292d2cc0c892dab7c6a5d37c2bec707888"
+  integrity sha512-I8XkoQwE+fPQEhy9v012V+TSdH2kp9ts29i20TaaDUXsg7x/onePbhFJUExBfv/2ay1ZOp/Vsm3nDlmnFGSAog==
+  dependencies:
+    inherits "^2.0.3"
+    is-arguments "^1.0.4"
+    is-generator-function "^1.0.7"
+    is-typed-array "^1.1.3"
+    safe-buffer "^5.1.2"
+    which-typed-array "^1.1.2"
+
 uuid@^3.3.2, uuid@^3.3.3:
   version "3.4.0"
   resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
@@ -7021,6 +7090,18 @@ which-module@^2.0.0:
   resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
   integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=
 
+which-typed-array@^1.1.2:
+  version "1.1.2"
+  resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.2.tgz#e5f98e56bda93e3dac196b01d47c1156679c00b2"
+  integrity sha512-KT6okrd1tE6JdZAy3o2VhMoYPh3+J6EMZLyrxBQsZflI1QCZIxMrIYLkosd8Twf+YfknVIHmYQPgJt238p8dnQ==
+  dependencies:
+    available-typed-arrays "^1.0.2"
+    es-abstract "^1.17.5"
+    foreach "^2.0.5"
+    function-bind "^1.1.1"
+    has-symbols "^1.0.1"
+    is-typed-array "^1.1.3"
+
 [email protected]:
   version "1.2.14"
   resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5"

部分文件因为文件数量过多而无法显示