adj-ordinaryjs 0.0.1-security → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,193 @@
|
|
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 vlq_char = characters("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
|
47
|
+
var vlq_bits = vlq_char.reduce(function(map, ch, bits) {
|
48
|
+
map[ch] = bits;
|
49
|
+
return map;
|
50
|
+
}, Object.create(null));
|
51
|
+
|
52
|
+
function vlq_decode(indices, str) {
|
53
|
+
var value = 0;
|
54
|
+
var shift = 0;
|
55
|
+
for (var i = 0, j = 0; i < str.length; i++) {
|
56
|
+
var bits = vlq_bits[str[i]];
|
57
|
+
value += (bits & 31) << shift;
|
58
|
+
if (bits & 32) {
|
59
|
+
shift += 5;
|
60
|
+
} else {
|
61
|
+
indices[j++] += value & 1 ? 0x80000000 | -(value >> 1) : value >> 1;
|
62
|
+
value = shift = 0;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
return j;
|
66
|
+
}
|
67
|
+
|
68
|
+
function vlq_encode(num) {
|
69
|
+
var result = "";
|
70
|
+
num = Math.abs(num) << 1 | num >>> 31;
|
71
|
+
do {
|
72
|
+
var bits = num & 31;
|
73
|
+
if (num >>>= 5) bits |= 32;
|
74
|
+
result += vlq_char[bits];
|
75
|
+
} while (num);
|
76
|
+
return result;
|
77
|
+
}
|
78
|
+
|
79
|
+
function create_array_map() {
|
80
|
+
var map = Object.create(null);
|
81
|
+
var array = [];
|
82
|
+
array.index = function(name) {
|
83
|
+
if (!HOP(map, name)) {
|
84
|
+
map[name] = array.length;
|
85
|
+
array.push(name);
|
86
|
+
}
|
87
|
+
return map[name];
|
88
|
+
};
|
89
|
+
return array;
|
90
|
+
}
|
91
|
+
|
92
|
+
function SourceMap(options) {
|
93
|
+
var sources = create_array_map();
|
94
|
+
var sources_content = options.includeSources && Object.create(null);
|
95
|
+
var names = create_array_map();
|
96
|
+
var mappings = "";
|
97
|
+
if (options.orig) Object.keys(options.orig).forEach(function(name) {
|
98
|
+
var map = options.orig[name];
|
99
|
+
var indices = [ 0, 0, 1, 0, 0 ];
|
100
|
+
options.orig[name] = {
|
101
|
+
names: map.names,
|
102
|
+
mappings: map.mappings.split(/;/).map(function(line) {
|
103
|
+
indices[0] = 0;
|
104
|
+
return line.split(/,/).map(function(segment) {
|
105
|
+
return indices.slice(0, vlq_decode(indices, segment));
|
106
|
+
});
|
107
|
+
}),
|
108
|
+
sources: map.sources,
|
109
|
+
};
|
110
|
+
if (!sources_content || !map.sourcesContent) return;
|
111
|
+
for (var i = 0; i < map.sources.length; i++) {
|
112
|
+
var content = map.sourcesContent[i];
|
113
|
+
if (content) sources_content[map.sources[i]] = content;
|
114
|
+
}
|
115
|
+
});
|
116
|
+
var prev_source;
|
117
|
+
var generated_line = 1;
|
118
|
+
var generated_column = 0;
|
119
|
+
var source_index = 0;
|
120
|
+
var original_line = 1;
|
121
|
+
var original_column = 0;
|
122
|
+
var name_index = 0;
|
123
|
+
return {
|
124
|
+
add: options.orig ? function(source, gen_line, gen_col, orig_line, orig_col, name) {
|
125
|
+
var map = options.orig[source];
|
126
|
+
if (map) {
|
127
|
+
var segments = map.mappings[orig_line - 1];
|
128
|
+
if (!segments) return;
|
129
|
+
var indices;
|
130
|
+
for (var i = 0; i < segments.length; i++) {
|
131
|
+
var col = segments[i][0];
|
132
|
+
if (orig_col >= col) indices = segments[i];
|
133
|
+
if (orig_col <= col) break;
|
134
|
+
}
|
135
|
+
if (!indices || indices.length < 4) {
|
136
|
+
source = null;
|
137
|
+
} else {
|
138
|
+
source = map.sources[indices[1]];
|
139
|
+
orig_line = indices[2];
|
140
|
+
orig_col = indices[3];
|
141
|
+
if (indices.length > 4) name = map.names[indices[4]];
|
142
|
+
}
|
143
|
+
}
|
144
|
+
add(source, gen_line, gen_col, orig_line, orig_col, name);
|
145
|
+
} : add,
|
146
|
+
setSourceContent: sources_content ? function(source, content) {
|
147
|
+
if (!(source in sources_content)) {
|
148
|
+
sources_content[source] = content;
|
149
|
+
}
|
150
|
+
} : noop,
|
151
|
+
toString: function() {
|
152
|
+
return JSON.stringify({
|
153
|
+
version: 3,
|
154
|
+
file: options.filename || undefined,
|
155
|
+
sourceRoot: options.root || undefined,
|
156
|
+
sources: sources,
|
157
|
+
sourcesContent: sources_content ? sources.map(function(source) {
|
158
|
+
return sources_content[source] || null;
|
159
|
+
}) : undefined,
|
160
|
+
names: names,
|
161
|
+
mappings: mappings,
|
162
|
+
});
|
163
|
+
}
|
164
|
+
};
|
165
|
+
|
166
|
+
function add(source, gen_line, gen_col, orig_line, orig_col, name) {
|
167
|
+
if (prev_source == null && source == null) return;
|
168
|
+
prev_source = source;
|
169
|
+
if (generated_line < gen_line) {
|
170
|
+
generated_column = 0;
|
171
|
+
do {
|
172
|
+
mappings += ";";
|
173
|
+
} while (++generated_line < gen_line);
|
174
|
+
} else if (mappings) {
|
175
|
+
mappings += ",";
|
176
|
+
}
|
177
|
+
mappings += vlq_encode(gen_col - generated_column);
|
178
|
+
generated_column = gen_col;
|
179
|
+
if (source == null) return;
|
180
|
+
var src_idx = sources.index(source);
|
181
|
+
mappings += vlq_encode(src_idx - source_index);
|
182
|
+
source_index = src_idx;
|
183
|
+
mappings += vlq_encode(orig_line - original_line);
|
184
|
+
original_line = orig_line;
|
185
|
+
mappings += vlq_encode(orig_col - original_column);
|
186
|
+
original_column = orig_col;
|
187
|
+
if (options.names && name != null) {
|
188
|
+
var name_idx = names.index(name);
|
189
|
+
mappings += vlq_encode(name_idx - name_index);
|
190
|
+
name_index = name_idx;
|
191
|
+
}
|
192
|
+
}
|
193
|
+
}
|
@@ -0,0 +1,250 @@
|
|
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
|
+
function TreeTransformer(before, after) {
|
47
|
+
TreeWalker.call(this);
|
48
|
+
this.before = before;
|
49
|
+
this.after = after;
|
50
|
+
}
|
51
|
+
TreeTransformer.prototype = new TreeWalker;
|
52
|
+
|
53
|
+
(function(DEF) {
|
54
|
+
function do_list(list, tw) {
|
55
|
+
return List(list, function(node) {
|
56
|
+
return node.transform(tw, true);
|
57
|
+
});
|
58
|
+
}
|
59
|
+
|
60
|
+
DEF(AST_Node, noop);
|
61
|
+
DEF(AST_LabeledStatement, function(self, tw) {
|
62
|
+
self.label = self.label.transform(tw);
|
63
|
+
self.body = self.body.transform(tw);
|
64
|
+
});
|
65
|
+
DEF(AST_SimpleStatement, function(self, tw) {
|
66
|
+
self.body = self.body.transform(tw);
|
67
|
+
});
|
68
|
+
DEF(AST_Block, function(self, tw) {
|
69
|
+
self.body = do_list(self.body, tw);
|
70
|
+
});
|
71
|
+
DEF(AST_Do, function(self, tw) {
|
72
|
+
self.body = self.body.transform(tw);
|
73
|
+
self.condition = self.condition.transform(tw);
|
74
|
+
});
|
75
|
+
DEF(AST_While, function(self, tw) {
|
76
|
+
self.condition = self.condition.transform(tw);
|
77
|
+
self.body = self.body.transform(tw);
|
78
|
+
});
|
79
|
+
DEF(AST_For, function(self, tw) {
|
80
|
+
if (self.init) self.init = self.init.transform(tw);
|
81
|
+
if (self.condition) self.condition = self.condition.transform(tw);
|
82
|
+
if (self.step) self.step = self.step.transform(tw);
|
83
|
+
self.body = self.body.transform(tw);
|
84
|
+
});
|
85
|
+
DEF(AST_ForEnumeration, function(self, tw) {
|
86
|
+
self.init = self.init.transform(tw);
|
87
|
+
self.object = self.object.transform(tw);
|
88
|
+
self.body = self.body.transform(tw);
|
89
|
+
});
|
90
|
+
DEF(AST_With, function(self, tw) {
|
91
|
+
self.expression = self.expression.transform(tw);
|
92
|
+
self.body = self.body.transform(tw);
|
93
|
+
});
|
94
|
+
DEF(AST_Exit, function(self, tw) {
|
95
|
+
if (self.value) self.value = self.value.transform(tw);
|
96
|
+
});
|
97
|
+
DEF(AST_LoopControl, function(self, tw) {
|
98
|
+
if (self.label) self.label = self.label.transform(tw);
|
99
|
+
});
|
100
|
+
DEF(AST_If, function(self, tw) {
|
101
|
+
self.condition = self.condition.transform(tw);
|
102
|
+
self.body = self.body.transform(tw);
|
103
|
+
if (self.alternative) self.alternative = self.alternative.transform(tw);
|
104
|
+
});
|
105
|
+
DEF(AST_Switch, function(self, tw) {
|
106
|
+
self.expression = self.expression.transform(tw);
|
107
|
+
self.body = do_list(self.body, tw);
|
108
|
+
});
|
109
|
+
DEF(AST_Case, function(self, tw) {
|
110
|
+
self.expression = self.expression.transform(tw);
|
111
|
+
self.body = do_list(self.body, tw);
|
112
|
+
});
|
113
|
+
DEF(AST_Try, function(self, tw) {
|
114
|
+
self.body = do_list(self.body, tw);
|
115
|
+
if (self.bcatch) self.bcatch = self.bcatch.transform(tw);
|
116
|
+
if (self.bfinally) self.bfinally = self.bfinally.transform(tw);
|
117
|
+
});
|
118
|
+
DEF(AST_Catch, function(self, tw) {
|
119
|
+
if (self.argname) self.argname = self.argname.transform(tw);
|
120
|
+
self.body = do_list(self.body, tw);
|
121
|
+
});
|
122
|
+
DEF(AST_Definitions, function(self, tw) {
|
123
|
+
self.definitions = do_list(self.definitions, tw);
|
124
|
+
});
|
125
|
+
DEF(AST_VarDef, function(self, tw) {
|
126
|
+
self.name = self.name.transform(tw);
|
127
|
+
if (self.value) self.value = self.value.transform(tw);
|
128
|
+
});
|
129
|
+
DEF(AST_DefaultValue, function(self, tw) {
|
130
|
+
self.name = self.name.transform(tw);
|
131
|
+
self.value = self.value.transform(tw);
|
132
|
+
});
|
133
|
+
DEF(AST_Lambda, function(self, tw) {
|
134
|
+
if (self.name) self.name = self.name.transform(tw);
|
135
|
+
self.argnames = do_list(self.argnames, tw);
|
136
|
+
if (self.rest) self.rest = self.rest.transform(tw);
|
137
|
+
self.body = do_list(self.body, tw);
|
138
|
+
});
|
139
|
+
function transform_arrow(self, tw) {
|
140
|
+
self.argnames = do_list(self.argnames, tw);
|
141
|
+
if (self.rest) self.rest = self.rest.transform(tw);
|
142
|
+
if (self.value) {
|
143
|
+
self.value = self.value.transform(tw);
|
144
|
+
} else {
|
145
|
+
self.body = do_list(self.body, tw);
|
146
|
+
}
|
147
|
+
}
|
148
|
+
DEF(AST_Arrow, transform_arrow);
|
149
|
+
DEF(AST_AsyncArrow, transform_arrow);
|
150
|
+
DEF(AST_Class, function(self, tw) {
|
151
|
+
if (self.name) self.name = self.name.transform(tw);
|
152
|
+
if (self.extends) self.extends = self.extends.transform(tw);
|
153
|
+
self.properties = do_list(self.properties, tw);
|
154
|
+
});
|
155
|
+
DEF(AST_ClassProperty, function(self, tw) {
|
156
|
+
if (self.key instanceof AST_Node) self.key = self.key.transform(tw);
|
157
|
+
if (self.value) self.value = self.value.transform(tw);
|
158
|
+
});
|
159
|
+
DEF(AST_Call, function(self, tw) {
|
160
|
+
self.expression = self.expression.transform(tw);
|
161
|
+
self.args = do_list(self.args, tw);
|
162
|
+
});
|
163
|
+
DEF(AST_Sequence, function(self, tw) {
|
164
|
+
self.expressions = do_list(self.expressions, tw);
|
165
|
+
});
|
166
|
+
DEF(AST_Await, function(self, tw) {
|
167
|
+
self.expression = self.expression.transform(tw);
|
168
|
+
});
|
169
|
+
DEF(AST_Yield, function(self, tw) {
|
170
|
+
if (self.expression) self.expression = self.expression.transform(tw);
|
171
|
+
});
|
172
|
+
DEF(AST_Dot, function(self, tw) {
|
173
|
+
self.expression = self.expression.transform(tw);
|
174
|
+
});
|
175
|
+
DEF(AST_Sub, function(self, tw) {
|
176
|
+
self.expression = self.expression.transform(tw);
|
177
|
+
self.property = self.property.transform(tw);
|
178
|
+
});
|
179
|
+
DEF(AST_Spread, function(self, tw) {
|
180
|
+
self.expression = self.expression.transform(tw);
|
181
|
+
});
|
182
|
+
DEF(AST_Unary, function(self, tw) {
|
183
|
+
self.expression = self.expression.transform(tw);
|
184
|
+
});
|
185
|
+
DEF(AST_Binary, function(self, tw) {
|
186
|
+
self.left = self.left.transform(tw);
|
187
|
+
self.right = self.right.transform(tw);
|
188
|
+
});
|
189
|
+
DEF(AST_Conditional, function(self, tw) {
|
190
|
+
self.condition = self.condition.transform(tw);
|
191
|
+
self.consequent = self.consequent.transform(tw);
|
192
|
+
self.alternative = self.alternative.transform(tw);
|
193
|
+
});
|
194
|
+
DEF(AST_Array, function(self, tw) {
|
195
|
+
self.elements = do_list(self.elements, tw);
|
196
|
+
});
|
197
|
+
DEF(AST_DestructuredArray, function(self, tw) {
|
198
|
+
self.elements = do_list(self.elements, tw);
|
199
|
+
if (self.rest) self.rest = self.rest.transform(tw);
|
200
|
+
});
|
201
|
+
DEF(AST_DestructuredKeyVal, function(self, tw) {
|
202
|
+
if (self.key instanceof AST_Node) self.key = self.key.transform(tw);
|
203
|
+
self.value = self.value.transform(tw);
|
204
|
+
});
|
205
|
+
DEF(AST_DestructuredObject, function(self, tw) {
|
206
|
+
self.properties = do_list(self.properties, tw);
|
207
|
+
if (self.rest) self.rest = self.rest.transform(tw);
|
208
|
+
});
|
209
|
+
DEF(AST_Object, function(self, tw) {
|
210
|
+
self.properties = do_list(self.properties, tw);
|
211
|
+
});
|
212
|
+
DEF(AST_ObjectProperty, function(self, tw) {
|
213
|
+
if (self.key instanceof AST_Node) self.key = self.key.transform(tw);
|
214
|
+
self.value = self.value.transform(tw);
|
215
|
+
});
|
216
|
+
DEF(AST_ExportDeclaration, function(self, tw) {
|
217
|
+
self.body = self.body.transform(tw);
|
218
|
+
});
|
219
|
+
DEF(AST_ExportDefault, function(self, tw) {
|
220
|
+
self.body = self.body.transform(tw);
|
221
|
+
});
|
222
|
+
DEF(AST_ExportReferences, function(self, tw) {
|
223
|
+
self.properties = do_list(self.properties, tw);
|
224
|
+
});
|
225
|
+
DEF(AST_Import, function(self, tw) {
|
226
|
+
if (self.all) self.all = self.all.transform(tw);
|
227
|
+
if (self.default) self.default = self.default.transform(tw);
|
228
|
+
if (self.properties) self.properties = do_list(self.properties, tw);
|
229
|
+
});
|
230
|
+
DEF(AST_Template, function(self, tw) {
|
231
|
+
if (self.tag) self.tag = self.tag.transform(tw);
|
232
|
+
self.expressions = do_list(self.expressions, tw);
|
233
|
+
});
|
234
|
+
})(function(node, descend) {
|
235
|
+
node.DEFMETHOD("transform", function(tw, in_list) {
|
236
|
+
var x, y;
|
237
|
+
tw.push(this);
|
238
|
+
if (tw.before) x = tw.before(this, descend, in_list);
|
239
|
+
if (typeof x === "undefined") {
|
240
|
+
x = this;
|
241
|
+
descend(x, tw);
|
242
|
+
if (tw.after) {
|
243
|
+
y = tw.after(x, in_list);
|
244
|
+
if (typeof y !== "undefined") x = y;
|
245
|
+
}
|
246
|
+
}
|
247
|
+
tw.pop();
|
248
|
+
return x;
|
249
|
+
});
|
250
|
+
});
|
@@ -0,0 +1,267 @@
|
|
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
|
+
function characters(str) {
|
47
|
+
return str.split("");
|
48
|
+
}
|
49
|
+
|
50
|
+
function member(name, array) {
|
51
|
+
return array.indexOf(name) >= 0;
|
52
|
+
}
|
53
|
+
|
54
|
+
function find_if(func, array) {
|
55
|
+
for (var i = array.length; --i >= 0;) if (func(array[i])) return array[i];
|
56
|
+
}
|
57
|
+
|
58
|
+
function repeat_string(str, i) {
|
59
|
+
if (i <= 0) return "";
|
60
|
+
if (i == 1) return str;
|
61
|
+
var d = repeat_string(str, i >> 1);
|
62
|
+
d += d;
|
63
|
+
return i & 1 ? d + str : d;
|
64
|
+
}
|
65
|
+
|
66
|
+
function configure_error_stack(fn) {
|
67
|
+
Object.defineProperty(fn.prototype, "stack", {
|
68
|
+
get: function() {
|
69
|
+
var err = new Error(this.message);
|
70
|
+
err.name = this.name;
|
71
|
+
try {
|
72
|
+
throw err;
|
73
|
+
} catch (e) {
|
74
|
+
return e.stack;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
});
|
78
|
+
}
|
79
|
+
|
80
|
+
function DefaultsError(msg, defs) {
|
81
|
+
this.message = msg;
|
82
|
+
this.defs = defs;
|
83
|
+
}
|
84
|
+
DefaultsError.prototype = Object.create(Error.prototype);
|
85
|
+
DefaultsError.prototype.constructor = DefaultsError;
|
86
|
+
DefaultsError.prototype.name = "DefaultsError";
|
87
|
+
configure_error_stack(DefaultsError);
|
88
|
+
|
89
|
+
function defaults(args, defs, croak) {
|
90
|
+
if (croak) for (var i in args) {
|
91
|
+
if (HOP(args, i) && !HOP(defs, i)) throw new DefaultsError("`" + i + "` is not a supported option", defs);
|
92
|
+
}
|
93
|
+
for (var i in args) {
|
94
|
+
if (HOP(args, i)) defs[i] = args[i];
|
95
|
+
}
|
96
|
+
return defs;
|
97
|
+
}
|
98
|
+
|
99
|
+
function merge(obj, ext) {
|
100
|
+
var count = 0;
|
101
|
+
for (var i in ext) if (HOP(ext, i)) {
|
102
|
+
obj[i] = ext[i];
|
103
|
+
count++;
|
104
|
+
}
|
105
|
+
return count;
|
106
|
+
}
|
107
|
+
|
108
|
+
function noop() {}
|
109
|
+
function return_false() { return false; }
|
110
|
+
function return_true() { return true; }
|
111
|
+
function return_this() { return this; }
|
112
|
+
function return_null() { return null; }
|
113
|
+
|
114
|
+
var List = (function() {
|
115
|
+
function List(a, f) {
|
116
|
+
var ret = [];
|
117
|
+
for (var i = 0; i < a.length; i++) {
|
118
|
+
var val = f(a[i], i);
|
119
|
+
if (val === skip) continue;
|
120
|
+
if (val instanceof Splice) {
|
121
|
+
ret.push.apply(ret, val.v);
|
122
|
+
} else {
|
123
|
+
ret.push(val);
|
124
|
+
}
|
125
|
+
}
|
126
|
+
return ret;
|
127
|
+
}
|
128
|
+
List.is_op = function(val) {
|
129
|
+
return val === skip || val instanceof Splice;
|
130
|
+
};
|
131
|
+
List.splice = function(val) {
|
132
|
+
return new Splice(val);
|
133
|
+
};
|
134
|
+
var skip = List.skip = {};
|
135
|
+
function Splice(val) {
|
136
|
+
this.v = val;
|
137
|
+
}
|
138
|
+
return List;
|
139
|
+
})();
|
140
|
+
|
141
|
+
function push_uniq(array, el) {
|
142
|
+
if (array.indexOf(el) < 0) return array.push(el);
|
143
|
+
}
|
144
|
+
|
145
|
+
function string_template(text, props) {
|
146
|
+
return text.replace(/\{([^}]+)\}/g, function(str, p) {
|
147
|
+
var value = props[p];
|
148
|
+
return value instanceof AST_Node ? value.print_to_string() : value;
|
149
|
+
});
|
150
|
+
}
|
151
|
+
|
152
|
+
function remove(array, el) {
|
153
|
+
var index = array.indexOf(el);
|
154
|
+
if (index >= 0) array.splice(index, 1);
|
155
|
+
}
|
156
|
+
|
157
|
+
function makePredicate(words) {
|
158
|
+
if (!Array.isArray(words)) words = words.split(" ");
|
159
|
+
var map = Object.create(null);
|
160
|
+
words.forEach(function(word) {
|
161
|
+
map[word] = true;
|
162
|
+
});
|
163
|
+
return map;
|
164
|
+
}
|
165
|
+
|
166
|
+
function all(array, predicate) {
|
167
|
+
for (var i = array.length; --i >= 0;)
|
168
|
+
if (!predicate(array[i], i))
|
169
|
+
return false;
|
170
|
+
return true;
|
171
|
+
}
|
172
|
+
|
173
|
+
function Dictionary() {
|
174
|
+
this._values = Object.create(null);
|
175
|
+
this._size = 0;
|
176
|
+
}
|
177
|
+
Dictionary.prototype = {
|
178
|
+
set: function(key, val) {
|
179
|
+
if (!this.has(key)) ++this._size;
|
180
|
+
this._values["$" + key] = val;
|
181
|
+
return this;
|
182
|
+
},
|
183
|
+
add: function(key, val) {
|
184
|
+
if (this.has(key)) {
|
185
|
+
this.get(key).push(val);
|
186
|
+
} else {
|
187
|
+
this.set(key, [ val ]);
|
188
|
+
}
|
189
|
+
return this;
|
190
|
+
},
|
191
|
+
get: function(key) { return this._values["$" + key] },
|
192
|
+
del: function(key) {
|
193
|
+
if (this.has(key)) {
|
194
|
+
--this._size;
|
195
|
+
delete this._values["$" + key];
|
196
|
+
}
|
197
|
+
return this;
|
198
|
+
},
|
199
|
+
has: function(key) { return ("$" + key) in this._values },
|
200
|
+
all: function(predicate) {
|
201
|
+
for (var i in this._values)
|
202
|
+
if (!predicate(this._values[i], i.substr(1)))
|
203
|
+
return false;
|
204
|
+
return true;
|
205
|
+
},
|
206
|
+
each: function(f) {
|
207
|
+
for (var i in this._values)
|
208
|
+
f(this._values[i], i.substr(1));
|
209
|
+
},
|
210
|
+
size: function() {
|
211
|
+
return this._size;
|
212
|
+
},
|
213
|
+
map: function(f) {
|
214
|
+
var ret = [];
|
215
|
+
for (var i in this._values)
|
216
|
+
ret.push(f(this._values[i], i.substr(1)));
|
217
|
+
return ret;
|
218
|
+
},
|
219
|
+
clone: function() {
|
220
|
+
var ret = new Dictionary();
|
221
|
+
for (var i in this._values)
|
222
|
+
ret._values[i] = this._values[i];
|
223
|
+
ret._size = this._size;
|
224
|
+
return ret;
|
225
|
+
},
|
226
|
+
toObject: function() { return this._values }
|
227
|
+
};
|
228
|
+
Dictionary.fromObject = function(obj) {
|
229
|
+
var dict = new Dictionary();
|
230
|
+
dict._size = merge(dict._values, obj);
|
231
|
+
return dict;
|
232
|
+
};
|
233
|
+
|
234
|
+
function HOP(obj, prop) {
|
235
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
236
|
+
}
|
237
|
+
|
238
|
+
// return true if the node at the top of the stack (that means the
|
239
|
+
// innermost node in the current output) is lexically the first in
|
240
|
+
// a statement.
|
241
|
+
function first_in_statement(stack, arrow, export_default) {
|
242
|
+
var node = stack.parent(-1);
|
243
|
+
for (var i = 0, p; p = stack.parent(i++); node = p) {
|
244
|
+
if (is_arrow(p)) {
|
245
|
+
return arrow && p.value === node;
|
246
|
+
} else if (p instanceof AST_Binary) {
|
247
|
+
if (p.left === node) continue;
|
248
|
+
} else if (p.TYPE == "Call") {
|
249
|
+
if (p.expression === node) continue;
|
250
|
+
} else if (p instanceof AST_Conditional) {
|
251
|
+
if (p.condition === node) continue;
|
252
|
+
} else if (p instanceof AST_ExportDefault) {
|
253
|
+
return export_default;
|
254
|
+
} else if (p instanceof AST_PropAccess) {
|
255
|
+
if (p.expression === node) continue;
|
256
|
+
} else if (p instanceof AST_Sequence) {
|
257
|
+
if (p.expressions[0] === node) continue;
|
258
|
+
} else if (p instanceof AST_SimpleStatement) {
|
259
|
+
return true;
|
260
|
+
} else if (p instanceof AST_Template) {
|
261
|
+
if (p.tag === node) continue;
|
262
|
+
} else if (p instanceof AST_UnaryPostfix) {
|
263
|
+
if (p.expression === node) continue;
|
264
|
+
}
|
265
|
+
return false;
|
266
|
+
}
|
267
|
+
}
|