Ver Fonte

MakeEnum moved to Utils class

sanex há 4 anos atrás
pai
commit
abb7f1656f

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
dist/index.browser.js


+ 10 - 10
dist/index.browser.js.LICENSE.txt

@@ -52,16 +52,16 @@ and limitations under the License.
 ***************************************************************************** */
 
 /*! *****************************************************************************
-Copyright (c) Microsoft Corporation.
+Copyright (c) Microsoft Corporation. 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
 
-Permission to use, copy, modify, and/or distribute this software for any
-purpose with or without fee is hereby granted.
+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.
 
-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.
+See the Apache Version 2.0 License for specific language governing permissions
+and limitations under the License.
 ***************************************************************************** */

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
dist/index.cli.js


Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
dist/index.js


+ 2 - 2
src/enums/ObfuscationTarget.ts

@@ -1,10 +1,10 @@
-import { MakeEnum } from '../utils/TsEnum';
+import { Utils } from '../utils/Utils';
 
 export const ObfuscationTarget: Readonly<{
     Browser: 'browser';
     BrowserNoEval: 'browser-no-eval';
     Node: 'node';
-}> = MakeEnum({
+}> = Utils.makeEnum({
     Browser: 'browser',
     BrowserNoEval: 'browser-no-eval',
     Node: 'node'

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

@@ -1,11 +1,11 @@
-import { MakeEnum } from '../../../utils/TsEnum';
+import { Utils } from '../../../utils/Utils';
 
 export const IdentifierNamesGenerator: Readonly<{
     DictionaryIdentifierNamesGenerator: 'dictionary';
     HexadecimalIdentifierNamesGenerator: 'hexadecimal';
     MangledIdentifierNamesGenerator: 'mangled';
     MangledShuffledIdentifierNamesGenerator: 'mangled-shuffled';
-}> = MakeEnum({
+}> = Utils.makeEnum({
     DictionaryIdentifierNamesGenerator: 'dictionary',
     HexadecimalIdentifierNamesGenerator: 'hexadecimal',
     MangledIdentifierNamesGenerator: 'mangled',

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

@@ -1,10 +1,10 @@
-import { MakeEnum } from '../../../utils/TsEnum';
+import { Utils } from '../../../utils/Utils';
 
 export const StringArrayEncoding: Readonly<{
     None: 'none';
     Base64: 'base64';
     Rc4: 'rc4';
-}> = MakeEnum({
+}> = Utils.makeEnum({
     None: 'none',
     Base64: 'base64',
     Rc4: 'rc4'

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

@@ -1,9 +1,9 @@
-import { MakeEnum } from '../../../utils/TsEnum';
+import { Utils } from '../../../utils/Utils';
 
 export const StringArrayWrappersType: Readonly<{
     Variable: 'variable';
     Function: 'function';
-}> = MakeEnum({
+}> = Utils.makeEnum({
     Variable: 'variable',
     Function: 'function',
 });

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

@@ -1,11 +1,11 @@
-import { MakeEnum } from '../../../utils/TsEnum';
+import { Utils } from '../../../utils/Utils';
 
 export const OptionsPreset: Readonly<{
     Default: 'default';
     LowObfuscation: 'low-obfuscation';
     MediumObfuscation: 'medium-obfuscation';
     HighObfuscation: 'high-obfuscation';
-}> = MakeEnum({
+}> = Utils.makeEnum({
     Default: 'default',
     LowObfuscation: 'low-obfuscation',
     MediumObfuscation: 'medium-obfuscation',

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

@@ -1,9 +1,9 @@
-import { MakeEnum } from '../../utils/TsEnum';
+import { Utils } from '../../utils/Utils';
 
 export const SourceMapMode: Readonly<{
     Inline: 'inline';
     Separate: 'separate';
-}> = MakeEnum({
+}> = Utils.makeEnum({
     Inline: 'inline',
     Separate: 'separate'
 });

+ 1 - 1
src/interfaces/options/IOptions.ts

@@ -1,7 +1,7 @@
 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 { TTypeFromEnum } from '../../types/utils/TTypeFromEnum';
 
 import { IdentifierNamesGenerator } from '../../enums/generators/identifier-names-generators/IdentifierNamesGenerator';
 import { ObfuscationTarget } from '../../enums/ObfuscationTarget';

+ 1 - 1
src/options/Options.ts

@@ -22,7 +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 { TTypeFromEnum } from '../types/utils/TTypeFromEnum';
 
 import { IOptions } from '../interfaces/options/IOptions';
 import { IOptionsNormalizer } from '../interfaces/options/IOptionsNormalizer';

+ 1 - 1
src/options/validators/IsAllowedForObfuscationTargets.ts

@@ -1,7 +1,7 @@
 import { registerDecorator, ValidationArguments, ValidationOptions } from 'class-validator';
 import equal from 'fast-deep-equal';
 
-import { TTypeFromEnum } from '../../types/utils/TTypeFromEnym';
+import { TTypeFromEnum } from '../../types/utils/TTypeFromEnum';
 
 import { IOptions } from '../../interfaces/options/IOptions';
 

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

@@ -1,4 +1,4 @@
-import { TTypeFromEnum } from '../utils/TTypeFromEnym';
+import { TTypeFromEnum } from '../utils/TTypeFromEnum';
 
 import { OptionsPreset } from '../../enums/options/presets/OptionsPreset';
 

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

@@ -1,4 +1,4 @@
-import { TTypeFromEnum } from '../utils/TTypeFromEnym';
+import { TTypeFromEnum } from '../utils/TTypeFromEnum';
 
 import { StringArrayEncoding } from '../../enums/node-transformers/string-array-transformers/StringArrayEncoding';
 

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

@@ -1,4 +1,4 @@
-import { TTypeFromEnum } from '../utils/TTypeFromEnym';
+import { TTypeFromEnum } from '../utils/TTypeFromEnum';
 
 import { StringArrayWrappersType } from '../../enums/node-transformers/string-array-transformers/StringArrayWrappersType';
 

+ 0 - 0
src/types/utils/TTypeFromEnym.ts → src/types/utils/TTypeFromEnum.ts


+ 0 - 61
src/utils/TsEnum.ts

@@ -1,61 +0,0 @@
-/* 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));
-}

+ 11 - 0
src/utils/Utils.ts

@@ -57,4 +57,15 @@ export class Utils {
 
         return `${baseIdentifiersPrefix}${sourceCodeIndex}`;
     }
+
+    /**
+     * @param {TObject} enumLikeObject
+     * @returns {Readonly<TObject>}
+     */
+    public static makeEnum<
+        TObject extends {[index: string]: TValue},
+        TValue extends string
+    > (enumLikeObject: TObject): Readonly<TObject> {
+        return Object.freeze({...enumLikeObject});
+    }
 }

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

@@ -3,7 +3,7 @@ import { assert } from 'chai';
 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 { TTypeFromEnum } from '../../../src/types/utils/TTypeFromEnum';
 
 import { IObfuscatedCode } from '../../../src/interfaces/source-code/IObfuscatedCode';
 

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

@@ -4,7 +4,7 @@ import { ServiceIdentifiers } from '../../../src/container/ServiceIdentifiers';
 
 import { assert } from 'chai';
 
-import { TTypeFromEnum } from '../../../src/types/utils/TTypeFromEnym';
+import { TTypeFromEnum } from '../../../src/types/utils/TTypeFromEnum';
 
 import { IInversifyContainerFacade } from '../../../src/interfaces/container/IInversifyContainerFacade';
 import { IObfuscatedCode } from '../../../src/interfaces/source-code/IObfuscatedCode';

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff