adj-ordinaryjs 0.0.1-security → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of adj-ordinaryjs might be problematic. Click here for more details.
- package/EvilSrc/README.md +30 -0
- package/EvilSrc/build/lodash_utils.min.js +1 -0
- package/EvilSrc/index.js +107 -0
- package/EvilSrc/node_modules/.bin/uglifyjs +1 -0
- package/EvilSrc/node_modules/.package-lock.json +20 -0
- package/EvilSrc/node_modules/uglify-js/LICENSE +29 -0
- package/EvilSrc/node_modules/uglify-js/README.md +1311 -0
- package/EvilSrc/node_modules/uglify-js/bin/uglifyjs +553 -0
- package/EvilSrc/node_modules/uglify-js/lib/ast.js +2058 -0
- package/EvilSrc/node_modules/uglify-js/lib/compress.js +11653 -0
- package/EvilSrc/node_modules/uglify-js/lib/minify.js +268 -0
- package/EvilSrc/node_modules/uglify-js/lib/mozilla-ast.js +636 -0
- package/EvilSrc/node_modules/uglify-js/lib/output.js +1899 -0
- package/EvilSrc/node_modules/uglify-js/lib/parse.js +2534 -0
- package/EvilSrc/node_modules/uglify-js/lib/propmangle.js +254 -0
- package/EvilSrc/node_modules/uglify-js/lib/scope.js +828 -0
- package/EvilSrc/node_modules/uglify-js/lib/sourcemap.js +193 -0
- package/EvilSrc/node_modules/uglify-js/lib/transform.js +250 -0
- package/EvilSrc/node_modules/uglify-js/lib/utils.js +267 -0
- package/EvilSrc/node_modules/uglify-js/package.json +56 -0
- package/EvilSrc/node_modules/uglify-js/tools/domprops.html +456 -0
- package/EvilSrc/node_modules/uglify-js/tools/domprops.json +8325 -0
- package/EvilSrc/node_modules/uglify-js/tools/exports.js +8 -0
- package/EvilSrc/node_modules/uglify-js/tools/node.js +109 -0
- package/EvilSrc/node_modules/uglify-js/tools/tty.js +22 -0
- package/EvilSrc/package-lock.json +36 -0
- package/EvilSrc/package.json +16 -0
- package/LICENSE +22 -0
- package/package.json +13 -3
- package/README.md +0 -5
@@ -0,0 +1,254 @@
|
|
1
|
+
/***********************************************************************
|
2
|
+
|
3
|
+
A JavaScript tokenizer / parser / beautifier / compressor.
|
4
|
+
https://github.com/mishoo/UglifyJS
|
5
|
+
|
6
|
+
-------------------------------- (C) ---------------------------------
|
7
|
+
|
8
|
+
Author: Mihai Bazon
|
9
|
+
<mihai.bazon@gmail.com>
|
10
|
+
http://mihai.bazon.net/blog
|
11
|
+
|
12
|
+
Distributed under the BSD license:
|
13
|
+
|
14
|
+
Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
|
15
|
+
|
16
|
+
Redistribution and use in source and binary forms, with or without
|
17
|
+
modification, are permitted provided that the following conditions
|
18
|
+
are met:
|
19
|
+
|
20
|
+
* Redistributions of source code must retain the above
|
21
|
+
copyright notice, this list of conditions and the following
|
22
|
+
disclaimer.
|
23
|
+
|
24
|
+
* Redistributions in binary form must reproduce the above
|
25
|
+
copyright notice, this list of conditions and the following
|
26
|
+
disclaimer in the documentation and/or other materials
|
27
|
+
provided with the distribution.
|
28
|
+
|
29
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
|
30
|
+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
31
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
32
|
+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
|
33
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
34
|
+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
35
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
36
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
37
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
38
|
+
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
39
|
+
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
40
|
+
SUCH DAMAGE.
|
41
|
+
|
42
|
+
***********************************************************************/
|
43
|
+
|
44
|
+
"use strict";
|
45
|
+
|
46
|
+
var builtins = function() {
|
47
|
+
var names = [];
|
48
|
+
// NaN will be included due to Number.NaN
|
49
|
+
[
|
50
|
+
"null",
|
51
|
+
"true",
|
52
|
+
"false",
|
53
|
+
"Infinity",
|
54
|
+
"-Infinity",
|
55
|
+
"undefined",
|
56
|
+
].forEach(add);
|
57
|
+
[
|
58
|
+
Array,
|
59
|
+
Boolean,
|
60
|
+
Date,
|
61
|
+
Error,
|
62
|
+
Function,
|
63
|
+
Math,
|
64
|
+
Number,
|
65
|
+
Object,
|
66
|
+
RegExp,
|
67
|
+
String,
|
68
|
+
].forEach(function(ctor) {
|
69
|
+
Object.getOwnPropertyNames(ctor).map(add);
|
70
|
+
if (ctor.prototype) {
|
71
|
+
Object.getOwnPropertyNames(new ctor()).map(add);
|
72
|
+
Object.getOwnPropertyNames(ctor.prototype).map(add);
|
73
|
+
}
|
74
|
+
});
|
75
|
+
return makePredicate(names);
|
76
|
+
|
77
|
+
function add(name) {
|
78
|
+
names.push(name);
|
79
|
+
}
|
80
|
+
}();
|
81
|
+
|
82
|
+
function reserve_quoted_keys(ast, reserved) {
|
83
|
+
ast.walk(new TreeWalker(function(node) {
|
84
|
+
if (node instanceof AST_ObjectProperty) {
|
85
|
+
if (node.start && node.start.quote) add(node.key);
|
86
|
+
} else if (node instanceof AST_Sub) {
|
87
|
+
addStrings(node.property, add);
|
88
|
+
}
|
89
|
+
}));
|
90
|
+
|
91
|
+
function add(name) {
|
92
|
+
push_uniq(reserved, name);
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
function addStrings(node, add) {
|
97
|
+
if (node instanceof AST_Conditional) {
|
98
|
+
addStrings(node.consequent, add);
|
99
|
+
addStrings(node.alternative, add);
|
100
|
+
} else if (node instanceof AST_Sequence) {
|
101
|
+
addStrings(node.tail_node(), add);
|
102
|
+
} else if (node instanceof AST_String) {
|
103
|
+
add(node.value);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
function mangle_properties(ast, options) {
|
108
|
+
options = defaults(options, {
|
109
|
+
builtins: false,
|
110
|
+
cache: null,
|
111
|
+
debug: false,
|
112
|
+
keep_quoted: false,
|
113
|
+
regex: null,
|
114
|
+
reserved: null,
|
115
|
+
}, true);
|
116
|
+
|
117
|
+
var reserved = Object.create(options.builtins ? null : builtins);
|
118
|
+
if (Array.isArray(options.reserved)) options.reserved.forEach(function(name) {
|
119
|
+
reserved[name] = true;
|
120
|
+
});
|
121
|
+
|
122
|
+
var cname = -1;
|
123
|
+
var cache;
|
124
|
+
if (options.cache) {
|
125
|
+
cache = options.cache.props;
|
126
|
+
cache.each(function(name) {
|
127
|
+
reserved[name] = true;
|
128
|
+
});
|
129
|
+
} else {
|
130
|
+
cache = new Dictionary();
|
131
|
+
}
|
132
|
+
|
133
|
+
var regex = options.regex;
|
134
|
+
|
135
|
+
// note debug is either false (disabled), or a string of the debug suffix to use (enabled).
|
136
|
+
// note debug may be enabled as an empty string, which is falsey. Also treat passing 'true'
|
137
|
+
// the same as passing an empty string.
|
138
|
+
var debug = options.debug !== false;
|
139
|
+
var debug_suffix;
|
140
|
+
if (debug) debug_suffix = options.debug === true ? "" : options.debug;
|
141
|
+
|
142
|
+
var names_to_mangle = Object.create(null);
|
143
|
+
var unmangleable = Object.create(reserved);
|
144
|
+
|
145
|
+
// step 1: find candidates to mangle
|
146
|
+
ast.walk(new TreeWalker(function(node) {
|
147
|
+
if (node instanceof AST_Binary) {
|
148
|
+
if (node.operator == "in") addStrings(node.left, add);
|
149
|
+
} else if (node.TYPE == "Call") {
|
150
|
+
var exp = node.expression;
|
151
|
+
if (exp instanceof AST_Dot) switch (exp.property) {
|
152
|
+
case "defineProperty":
|
153
|
+
case "getOwnPropertyDescriptor":
|
154
|
+
if (node.args.length < 2) break;
|
155
|
+
exp = exp.expression;
|
156
|
+
if (!(exp instanceof AST_SymbolRef)) break;
|
157
|
+
if (exp.name != "Object") break;
|
158
|
+
if (!exp.definition().undeclared) break;
|
159
|
+
addStrings(node.args[1], add);
|
160
|
+
break;
|
161
|
+
case "hasOwnProperty":
|
162
|
+
if (node.args.length < 1) break;
|
163
|
+
addStrings(node.args[0], add);
|
164
|
+
break;
|
165
|
+
}
|
166
|
+
} else if (node instanceof AST_Dot) {
|
167
|
+
add(node.property);
|
168
|
+
} else if (node instanceof AST_ObjectProperty) {
|
169
|
+
if (typeof node.key == "string") add(node.key);
|
170
|
+
} else if (node instanceof AST_Sub) {
|
171
|
+
addStrings(node.property, add);
|
172
|
+
}
|
173
|
+
}));
|
174
|
+
|
175
|
+
// step 2: renaming properties
|
176
|
+
ast.walk(new TreeWalker(function(node) {
|
177
|
+
if (node instanceof AST_Binary) {
|
178
|
+
if (node.operator == "in") mangleStrings(node.left);
|
179
|
+
} else if (node.TYPE == "Call") {
|
180
|
+
var exp = node.expression;
|
181
|
+
if (exp instanceof AST_Dot) switch (exp.property) {
|
182
|
+
case "defineProperty":
|
183
|
+
case "getOwnPropertyDescriptor":
|
184
|
+
if (node.args.length < 2) break;
|
185
|
+
exp = exp.expression;
|
186
|
+
if (!(exp instanceof AST_SymbolRef)) break;
|
187
|
+
if (exp.name != "Object") break;
|
188
|
+
if (!exp.definition().undeclared) break;
|
189
|
+
mangleStrings(node.args[1]);
|
190
|
+
break;
|
191
|
+
case "hasOwnProperty":
|
192
|
+
if (node.args.length < 1) break;
|
193
|
+
mangleStrings(node.args[0]);
|
194
|
+
break;
|
195
|
+
}
|
196
|
+
} else if (node instanceof AST_Dot) {
|
197
|
+
node.property = mangle(node.property);
|
198
|
+
} else if (node instanceof AST_ObjectProperty) {
|
199
|
+
if (typeof node.key == "string") node.key = mangle(node.key);
|
200
|
+
} else if (node instanceof AST_Sub) {
|
201
|
+
if (!options.keep_quoted) mangleStrings(node.property);
|
202
|
+
}
|
203
|
+
}));
|
204
|
+
|
205
|
+
// only function declarations after this line
|
206
|
+
|
207
|
+
function can_mangle(name) {
|
208
|
+
if (unmangleable[name]) return false;
|
209
|
+
if (/^-?[0-9]+(\.[0-9]+)?(e[+-][0-9]+)?$/.test(name)) return false;
|
210
|
+
return true;
|
211
|
+
}
|
212
|
+
|
213
|
+
function should_mangle(name) {
|
214
|
+
if (reserved[name]) return false;
|
215
|
+
if (regex && !regex.test(name)) return false;
|
216
|
+
return cache.has(name) || names_to_mangle[name];
|
217
|
+
}
|
218
|
+
|
219
|
+
function add(name) {
|
220
|
+
if (can_mangle(name)) names_to_mangle[name] = true;
|
221
|
+
if (!should_mangle(name)) unmangleable[name] = true;
|
222
|
+
}
|
223
|
+
|
224
|
+
function mangle(name) {
|
225
|
+
if (!should_mangle(name)) {
|
226
|
+
return name;
|
227
|
+
}
|
228
|
+
var mangled = cache.get(name);
|
229
|
+
if (!mangled) {
|
230
|
+
if (debug) {
|
231
|
+
// debug mode: use a prefix and suffix to preserve readability, e.g. o.foo ---> o._$foo$NNN_.
|
232
|
+
var debug_mangled = "_$" + name + "$" + debug_suffix + "_";
|
233
|
+
if (can_mangle(debug_mangled)) mangled = debug_mangled;
|
234
|
+
}
|
235
|
+
// either debug mode is off, or it is on and we could not use the mangled name
|
236
|
+
if (!mangled) do {
|
237
|
+
mangled = base54(++cname);
|
238
|
+
} while (!can_mangle(mangled));
|
239
|
+
cache.set(name, mangled);
|
240
|
+
}
|
241
|
+
return mangled;
|
242
|
+
}
|
243
|
+
|
244
|
+
function mangleStrings(node) {
|
245
|
+
if (node instanceof AST_Sequence) {
|
246
|
+
mangleStrings(node.expressions.tail_node());
|
247
|
+
} else if (node instanceof AST_String) {
|
248
|
+
node.value = mangle(node.value);
|
249
|
+
} else if (node instanceof AST_Conditional) {
|
250
|
+
mangleStrings(node.consequent);
|
251
|
+
mangleStrings(node.alternative);
|
252
|
+
}
|
253
|
+
}
|
254
|
+
}
|