@@ -43,10 +43,11 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var builtins = function() {
|
function get_builtins() {
|
||||||
var names = new Dictionary();
|
var names = new Dictionary();
|
||||||
// NaN will be included due to Number.NaN
|
// constants
|
||||||
[
|
[
|
||||||
|
"NaN",
|
||||||
"null",
|
"null",
|
||||||
"true",
|
"true",
|
||||||
"false",
|
"false",
|
||||||
@@ -54,30 +55,72 @@ var builtins = function() {
|
|||||||
"-Infinity",
|
"-Infinity",
|
||||||
"undefined",
|
"undefined",
|
||||||
].forEach(add);
|
].forEach(add);
|
||||||
|
// global functions
|
||||||
[
|
[
|
||||||
Array,
|
"encodeURI",
|
||||||
Boolean,
|
"encodeURIComponent",
|
||||||
Date,
|
"escape",
|
||||||
Error,
|
"eval",
|
||||||
Function,
|
"decodeURI",
|
||||||
Math,
|
"decodeURIComponent",
|
||||||
Number,
|
"isFinite",
|
||||||
Object,
|
"isNaN",
|
||||||
RegExp,
|
"parseFloat",
|
||||||
String,
|
"parseInt",
|
||||||
].forEach(function(ctor) {
|
"unescape",
|
||||||
|
].forEach(add);
|
||||||
|
// global constructors & objects
|
||||||
|
var global = Function("return this")();
|
||||||
|
[
|
||||||
|
"Array",
|
||||||
|
"ArrayBuffer",
|
||||||
|
"Atomics",
|
||||||
|
"BigInt",
|
||||||
|
"Boolean",
|
||||||
|
"console",
|
||||||
|
"DataView",
|
||||||
|
"Date",
|
||||||
|
"Error",
|
||||||
|
"Function",
|
||||||
|
"Int8Array",
|
||||||
|
"Intl",
|
||||||
|
"JSON",
|
||||||
|
"Map",
|
||||||
|
"Math",
|
||||||
|
"Number",
|
||||||
|
"Object",
|
||||||
|
"Promise",
|
||||||
|
"Proxy",
|
||||||
|
"Reflect",
|
||||||
|
"RegExp",
|
||||||
|
"Set",
|
||||||
|
"String",
|
||||||
|
"Symbol",
|
||||||
|
"WebAssembly",
|
||||||
|
].forEach(function(name) {
|
||||||
|
add(name);
|
||||||
|
var ctor = global[name];
|
||||||
|
if (!ctor) return;
|
||||||
Object.getOwnPropertyNames(ctor).map(add);
|
Object.getOwnPropertyNames(ctor).map(add);
|
||||||
if (ctor.prototype) {
|
if (typeof ctor != "function") return;
|
||||||
|
if (ctor.__proto__) Object.getOwnPropertyNames(ctor.__proto__).map(add);
|
||||||
|
if (ctor.prototype) Object.getOwnPropertyNames(ctor.prototype).map(add);
|
||||||
|
try {
|
||||||
Object.getOwnPropertyNames(new ctor()).map(add);
|
Object.getOwnPropertyNames(new ctor()).map(add);
|
||||||
Object.getOwnPropertyNames(ctor.prototype).map(add);
|
} catch (e) {
|
||||||
|
try {
|
||||||
|
Object.getOwnPropertyNames(ctor()).map(add);
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return names;
|
return (get_builtins = function() {
|
||||||
|
return names.clone();
|
||||||
|
})();
|
||||||
|
|
||||||
function add(name) {
|
function add(name) {
|
||||||
names.set(name, true);
|
names.set(name, true);
|
||||||
}
|
}
|
||||||
}();
|
}
|
||||||
|
|
||||||
function reserve_quoted_keys(ast, reserved) {
|
function reserve_quoted_keys(ast, reserved) {
|
||||||
ast.walk(new TreeWalker(function(node) {
|
ast.walk(new TreeWalker(function(node) {
|
||||||
@@ -116,7 +159,7 @@ function mangle_properties(ast, options) {
|
|||||||
reserved: null,
|
reserved: null,
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
var reserved = options.builtins ? new Dictionary() : builtins.clone();
|
var reserved = options.builtins ? new Dictionary() : get_builtins();
|
||||||
if (Array.isArray(options.reserved)) options.reserved.forEach(function(name) {
|
if (Array.isArray(options.reserved)) options.reserved.forEach(function(name) {
|
||||||
reserved.set(name, true);
|
reserved.set(name, true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -110,7 +110,9 @@ numeric_literal: {
|
|||||||
|
|
||||||
identifier: {
|
identifier: {
|
||||||
mangle = {
|
mangle = {
|
||||||
properties: true,
|
properties: {
|
||||||
|
builtins: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var obj = {
|
var obj = {
|
||||||
@@ -209,37 +211,37 @@ identifier: {
|
|||||||
B: 28,
|
B: 28,
|
||||||
C: 29,
|
C: 29,
|
||||||
D: 30,
|
D: 30,
|
||||||
F: 31,
|
E: 31,
|
||||||
G: 32,
|
F: 32,
|
||||||
false: 33,
|
G: 33,
|
||||||
null: 34,
|
H: 34,
|
||||||
true: 35,
|
I: 35,
|
||||||
H: 36,
|
J: 36,
|
||||||
I: 37,
|
K: 37,
|
||||||
J: 38,
|
L: 38,
|
||||||
K: 39,
|
M: 39,
|
||||||
L: 40,
|
N: 40,
|
||||||
M: 41,
|
O: 41,
|
||||||
N: 42,
|
P: 42,
|
||||||
O: 43,
|
Q: 43,
|
||||||
P: 44,
|
R: 44,
|
||||||
Q: 45,
|
S: 45,
|
||||||
R: 46,
|
T: 46,
|
||||||
S: 47,
|
U: 47,
|
||||||
T: 48,
|
V: 48,
|
||||||
U: 49,
|
W: 49,
|
||||||
V: 50,
|
X: 50,
|
||||||
W: 51,
|
Y: 51,
|
||||||
X: 52,
|
Z: 52,
|
||||||
Y: 53,
|
$: 53,
|
||||||
Z: 54,
|
_: 54,
|
||||||
$: 55,
|
ee: 55,
|
||||||
_: 56,
|
te: 56,
|
||||||
ee: 57,
|
ne: 57,
|
||||||
te: 58,
|
ae: 58,
|
||||||
ne: 59,
|
ie: 59,
|
||||||
ae: 60,
|
oe: 60,
|
||||||
ie: 61,
|
re: 61,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,6 +206,7 @@ mangle_unquoted_properties: {
|
|||||||
}
|
}
|
||||||
mangle = {
|
mangle = {
|
||||||
properties: {
|
properties: {
|
||||||
|
builtins: true,
|
||||||
keep_quoted: true,
|
keep_quoted: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -305,6 +306,7 @@ mangle_debug_suffix_keep_quoted: {
|
|||||||
}
|
}
|
||||||
mangle = {
|
mangle = {
|
||||||
properties: {
|
properties: {
|
||||||
|
builtins: true,
|
||||||
debug: "XYZ",
|
debug: "XYZ",
|
||||||
keep_quoted: true,
|
keep_quoted: true,
|
||||||
reserved: [],
|
reserved: [],
|
||||||
|
|||||||
Reference in New Issue
Block a user