amos-tool 1.4.4 → 1.4.8
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.
- package/.prettierignore +2 -2
- package/.prettierrc +50 -50
- package/README.md +667 -653
- package/apis/objectPath.md +129 -129
- package/index.d.ts +50 -5
- package/index.js +3 -3
- package/lib/_browser.js +10 -8
- package/lib/_clone.js +67 -62
- package/lib/_cookie.js +35 -32
- package/lib/_deepCopy.js +17 -29
- package/lib/_deepEqual.js +6 -13
- package/lib/_fastDeepEqual.js +28 -44
- package/lib/_flashSupport.js +13 -10
- package/lib/_forOwn.js +8 -7
- package/lib/_funcThrottle.js +16 -15
- package/lib/_isnode.js +2 -1
- package/lib/_list.js +55 -67
- package/lib/_object.assign.js +14 -24
- package/lib/_object.entries.js +6 -5
- package/lib/_object.values.js +5 -4
- package/lib/_omit.js +12 -12
- package/lib/_parseJson.js +7 -6
- package/lib/_pick.js +14 -0
- package/lib/_queue.js +24 -21
- package/lib/_shallowCopy.js +24 -23
- package/lib/_stringify.js +14 -17
- package/lib/_supportWs.js +5 -5
- package/lib/_trim.js +5 -4
- package/lib/_typeOfList.js +22 -21
- package/lib/_uuids.js +30 -35
- package/lib/amostool.js +15 -63
- package/lib/array2tree.js +9 -10
- package/lib/arrayFilter.js +17 -20
- package/lib/arrayUtils.js +13 -11
- package/lib/browser/Cookie.js +34 -35
- package/lib/browser/indexDB.js +71 -82
- package/lib/browserSupport.js +76 -71
- package/lib/completeUnit.js +7 -4
- package/lib/consts.js +2 -1
- package/lib/dom/canvas2img.js +61 -73
- package/lib/dom/canvasTools.js +9 -14
- package/lib/dom/downloadFile.js +15 -12
- package/lib/dom/eventHelper.js +8 -6
- package/lib/dom/fileBlob.js +14 -14
- package/lib/dom/fileSaveAs.js +54 -61
- package/lib/dom/getFontSize.js +7 -10
- package/lib/dom/minfyImg.js +30 -25
- package/lib/encrypt/_base64.js +32 -25
- package/lib/encrypt/_md5.js +68 -31
- package/lib/encrypt/des.js +426 -363
- package/lib/extra/_common.js +119 -166
- package/lib/extra/filterNull.js +3 -2
- package/lib/extra/find.js +10 -11
- package/lib/extra/index.js +4 -3
- package/lib/extra/memo.js +18 -0
- package/lib/extra/pathToTree.js +48 -42
- package/lib/extra/pwdStrength.js +4 -2
- package/lib/extra/sortBy.js +28 -30
- package/lib/flat.js +15 -0
- package/lib/locationParams.js +94 -99
- package/lib/log.js +20 -26
- package/lib/math/_keyColor.js +154 -0
- package/lib/math/addition.js +9 -7
- package/lib/math/amountCase.js +8 -12
- package/lib/math/coinFormat.js +7 -5
- package/lib/math/colorUtil.js +96 -92
- package/lib/math/dateTime.js +76 -94
- package/lib/math/operations.js +33 -37
- package/lib/math/pwdStrength.js +4 -2
- package/lib/math/randomColor.js +17 -5
- package/lib/math/subtraction.js +10 -9
- package/lib/merged.js +9 -9
- package/lib/objectPath.js +88 -95
- package/lib/parseText.js +8 -7
- package/lib/png/Identicon.js +36 -38
- package/lib/png/pnglib.js +58 -32
- package/lib/png/randomPic.js +9 -12
- package/lib/positionFactory.js +25 -80
- package/lib/pwdPolicy.js +27 -31
- package/lib/qs/_assign.js +7 -5
- package/lib/qs/_merge.js +19 -28
- package/lib/qs/_tools.js +3 -2
- package/lib/qs/formats.js +6 -5
- package/lib/qs/index.js +4 -4
- package/lib/qs/parse.js +55 -50
- package/lib/qs/stringify.js +55 -77
- package/lib/qs/utils.js +69 -88
- package/lib/random.js +5 -4
- package/lib/shallowEqual.js +24 -34
- package/lib/store.js +93 -98
- package/lib/strUtils.js +51 -42
- package/lib/tableFilter.js +178 -169
- package/lib/throttleDebounce.js +18 -22
- package/lib/url/encodeUrl.js +5 -4
- package/lib/url/restfulUrl.js +8 -7
- package/lib/utils.js +169 -223
- package/lib/xss/htmlEncode.js +3 -2
- package/lib/xss/implementEncode.js +36 -37
- package/lib/xss/index.js +4 -3
- package/package.json +9 -8
package/lib/merged.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
module.exports = merged;
|
|
2
|
+
|
|
3
|
+
var utils = require("./utils"), merged = function r(s) {
|
|
4
|
+
for (var e = {}, i = 0; i < s.length; i++) for (var t in s[i]) {
|
|
5
|
+
var u = s[i][t];
|
|
6
|
+
utils.isJson(u) ? utils.isJson(e[t]) ? e[t] = r(e[t]) : e[t] = r(u) : e[t] = u;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
module.exports = merged;
|
package/lib/objectPath.js
CHANGED
|
@@ -1,121 +1,114 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
return (_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
|
|
5
|
-
return typeof t
|
|
6
|
-
} : function(t) {
|
|
7
|
-
return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t
|
|
8
|
-
})(t)
|
|
9
|
-
}
|
|
10
|
-
var toStr = Object.prototype.toString;
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")), toStr = Object.prototype.toString;
|
|
11
4
|
|
|
12
|
-
function hasOwnProperty(
|
|
13
|
-
return null !=
|
|
5
|
+
function hasOwnProperty(e, r) {
|
|
6
|
+
return null != e && Object.prototype.hasOwnProperty.call(e, r);
|
|
14
7
|
}
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
|
|
9
|
+
var isArray = Array.isArray || function(e) {
|
|
10
|
+
return "[object Array]" === toStr.call(e);
|
|
17
11
|
};
|
|
18
12
|
|
|
19
|
-
function isEmpty(
|
|
20
|
-
if (!
|
|
21
|
-
if (isArray(
|
|
22
|
-
if ("string"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
function isEmpty(e) {
|
|
14
|
+
if (!e) return !0;
|
|
15
|
+
if (isArray(e) && 0 === e.length) return !0;
|
|
16
|
+
if ("string" != typeof e) {
|
|
17
|
+
for (var r in e) if (hasOwnProperty(e, r)) return !1;
|
|
18
|
+
return !0;
|
|
19
|
+
}
|
|
20
|
+
return !1;
|
|
26
21
|
}
|
|
27
22
|
|
|
28
|
-
function toString(
|
|
29
|
-
return toStr.call(
|
|
23
|
+
function toString(e) {
|
|
24
|
+
return toStr.call(e);
|
|
30
25
|
}
|
|
31
26
|
|
|
32
|
-
function isObject(
|
|
33
|
-
return "object" ===
|
|
27
|
+
function isObject(e) {
|
|
28
|
+
return "object" === (0, _typeof2.default)(e) && "[object Object]" === toString(e);
|
|
34
29
|
}
|
|
35
30
|
|
|
36
|
-
function isBoolean(
|
|
37
|
-
return "boolean" == typeof
|
|
31
|
+
function isBoolean(e) {
|
|
32
|
+
return "boolean" == typeof e || "[object Boolean]" === toString(e);
|
|
38
33
|
}
|
|
39
34
|
|
|
40
|
-
function getKey(
|
|
41
|
-
var r = parseInt(
|
|
42
|
-
return r.toString() ===
|
|
35
|
+
function getKey(e) {
|
|
36
|
+
var r = parseInt(e);
|
|
37
|
+
return r.toString() === e ? r : e;
|
|
43
38
|
}
|
|
44
39
|
|
|
45
|
-
function factory(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}, {})
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return o.includeInheritedProps || "number" == typeof r && Array.isArray(t) || hasOwnProperty(t, r)
|
|
40
|
+
function factory(e) {
|
|
41
|
+
e = e || {};
|
|
42
|
+
var r = function e(r) {
|
|
43
|
+
return Object.keys(e).reduce((function(t, n) {
|
|
44
|
+
return "create" === n || "function" == typeof e[n] && (t[n] = e[n].bind(e, r)),
|
|
45
|
+
t;
|
|
46
|
+
}), {});
|
|
47
|
+
};
|
|
48
|
+
function t(r, t) {
|
|
49
|
+
return e.includeInheritedProps || "number" == typeof t && Array.isArray(r) || hasOwnProperty(r, t);
|
|
56
50
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (i(t, r)) return t[r]
|
|
51
|
+
function n(e, r) {
|
|
52
|
+
if (t(e, r)) return e[r];
|
|
60
53
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if ("
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return 1 === r.length ? (void 0 !== i && n || (t[o] = e), i) : (void 0 === i && ("number" == typeof r[1] ? t[o] = [] : t[o] = {}), y(t[o], r.slice(1), e, n))
|
|
54
|
+
function i(e, r, t, o) {
|
|
55
|
+
if ("number" == typeof r && (r = [ r ]), !r || 0 === r.length) return e;
|
|
56
|
+
if ("string" == typeof r) return i(e, r.split(".").map(getKey), t, o);
|
|
57
|
+
var u = r[0], f = n(e, u);
|
|
58
|
+
return 1 === r.length ? (void 0 !== f && o || (e[u] = t), f) : (void 0 === f && ("number" == typeof r[1] ? e[u] = [] : e[u] = {}),
|
|
59
|
+
i(e[u], r.slice(1), t, o));
|
|
68
60
|
}
|
|
69
|
-
return
|
|
70
|
-
if ("number" == typeof
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
61
|
+
return r.has = function(r, t) {
|
|
62
|
+
if ("number" == typeof t ? t = [ t ] : "string" == typeof t && (t = t.split(".")),
|
|
63
|
+
!t || 0 === t.length) return !!r;
|
|
64
|
+
for (var n = 0; n < t.length; n++) {
|
|
65
|
+
var i = getKey(t[n]);
|
|
66
|
+
if (!("number" == typeof i && isArray(r) && i < r.length || (e.includeInheritedProps ? i in Object(r) : hasOwnProperty(r, i)))) return !1;
|
|
67
|
+
r = r[i];
|
|
75
68
|
}
|
|
76
|
-
return !0
|
|
77
|
-
},
|
|
78
|
-
return
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
69
|
+
return !0;
|
|
70
|
+
}, r.ensureExists = function(e, r, t) {
|
|
71
|
+
return i(e, r, t, !0);
|
|
72
|
+
}, r.set = function(e, r, t, n) {
|
|
73
|
+
return i(e, r, t, n);
|
|
74
|
+
}, r.insert = function(e, t, n, i) {
|
|
75
|
+
var o = r.get(e, t);
|
|
76
|
+
i = ~~i, isArray(o) || r.set(e, t, o = []), o.splice(i, 0, n);
|
|
77
|
+
}, r.empty = function(e, n) {
|
|
78
|
+
var i, o;
|
|
79
|
+
if (!isEmpty(n) && (null != e && (i = r.get(e, n)))) {
|
|
80
|
+
if ("string" == typeof i) return r.set(e, n, "");
|
|
81
|
+
if (isBoolean(i)) return r.set(e, n, !1);
|
|
82
|
+
if ("number" == typeof i) return r.set(e, n, 0);
|
|
83
|
+
if (isArray(i)) i.length = 0; else {
|
|
84
|
+
if (!isObject(i)) return r.set(e, n, null);
|
|
85
|
+
for (o in i) t(i, o) && delete i[o];
|
|
94
86
|
}
|
|
95
87
|
}
|
|
96
|
-
},
|
|
97
|
-
var
|
|
98
|
-
isArray(
|
|
99
|
-
},
|
|
100
|
-
for (var
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if ("
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}, u
|
|
88
|
+
}, r.push = function(e, t) {
|
|
89
|
+
var n = r.get(e, t);
|
|
90
|
+
isArray(n) || r.set(e, t, n = []), n.push.apply(n, Array.prototype.slice.call(arguments, 2));
|
|
91
|
+
}, r.coalesce = function(e, t, n) {
|
|
92
|
+
for (var i, o = 0, u = t.length; o < u; o++) if (void 0 !== (i = r.get(e, t[o]))) return i;
|
|
93
|
+
return n;
|
|
94
|
+
}, r.get = function(e, t, i) {
|
|
95
|
+
if ("number" == typeof t && (t = [ t ]), !t || 0 === t.length) return e;
|
|
96
|
+
if (null == e) return i;
|
|
97
|
+
if ("string" == typeof t) return r.get(e, t.split("."), i);
|
|
98
|
+
var o = getKey(t[0]), u = n(e, o);
|
|
99
|
+
return void 0 === u ? i : 1 === t.length ? u : r.get(e[o], t.slice(1), i);
|
|
100
|
+
}, r.del = function(e, n) {
|
|
101
|
+
if ("number" == typeof n && (n = [ n ]), null == e) return e;
|
|
102
|
+
if (isEmpty(n)) return e;
|
|
103
|
+
if ("string" == typeof n) return r.del(e, n.split("."));
|
|
104
|
+
var i = getKey(n[0]);
|
|
105
|
+
return t(e, i) ? 1 !== n.length ? r.del(e[i], n.slice(1)) : (isArray(e) ? e.splice(i, 1) : delete e[i],
|
|
106
|
+
e) : e;
|
|
107
|
+
}, r;
|
|
117
108
|
}
|
|
109
|
+
|
|
118
110
|
var mod = factory();
|
|
111
|
+
|
|
119
112
|
mod.create = factory, mod.withInheritedProps = factory({
|
|
120
113
|
includeInheritedProps: !0
|
|
121
|
-
}), module.exports = mod;
|
|
114
|
+
}), module.exports = mod;
|
package/lib/parseText.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
2
|
+
|
|
3
|
+
var utils = require("./utils"), defaultRE = /\{((?:.|\n)+?)\}/g;
|
|
4
|
+
|
|
5
|
+
module.exports = function(e, t, u) {
|
|
6
|
+
return u || (u = defaultRE), e && e.replace ? e.replace(u, (function(e, u) {
|
|
7
|
+
return utils.isUndefined(t[u]) ? e : t[u];
|
|
8
|
+
})) : e;
|
|
9
|
+
};
|
package/lib/png/Identicon.js
CHANGED
|
@@ -1,49 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t
|
|
8
|
-
})(t)
|
|
9
|
-
}
|
|
10
|
-
var PNGlib = require("./pnglib"),
|
|
11
|
-
Svg = function(t, i, s) {
|
|
12
|
-
this.size = t, this.foreground = this.color.apply(this, i), this.background = this.color.apply(this, s), this.rectangles = []
|
|
13
|
-
};
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")), PNGlib = require("./pnglib"), Svg = function(t, i, e) {
|
|
4
|
+
this.size = t, this.foreground = this.color.apply(this, i), this.background = this.color.apply(this, e),
|
|
5
|
+
this.rectangles = [];
|
|
6
|
+
};
|
|
14
7
|
|
|
15
8
|
function Identicon(t, i) {
|
|
16
9
|
if ("string" != typeof t || t.length < 15) throw "A hash of at least 15 characters is required.";
|
|
17
10
|
this.defaults = {
|
|
18
|
-
background: [240, 240, 240, 255],
|
|
11
|
+
background: [ 240, 240, 240, 255 ],
|
|
19
12
|
margin: .08,
|
|
20
13
|
size: 64,
|
|
21
14
|
saturation: .7,
|
|
22
15
|
brightness: .5,
|
|
23
16
|
format: "png"
|
|
24
|
-
}, this.options = "object" ===
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.
|
|
17
|
+
}, this.options = "object" === (0, _typeof2.default)(i) ? i : this.defaults, "number" == typeof arguments[1] && (this.options.size = arguments[1]),
|
|
18
|
+
arguments[2] && (this.options.margin = arguments[2]), this.hash = t, this.background = this.options.background || this.defaults.background,
|
|
19
|
+
this.size = this.options.size || this.defaults.size, this.format = this.options.format || this.defaults.format,
|
|
20
|
+
this.margin = void 0 !== this.options.margin ? this.options.margin : this.defaults.margin;
|
|
21
|
+
var e = parseInt(this.hash.substr(-7), 16) / 268435455, s = this.options.saturation || this.defaults.saturation, r = this.options.brightness || this.defaults.brightness;
|
|
22
|
+
this.foreground = this.options.foreground || this.hsl2rgb(e, s, r);
|
|
29
23
|
}
|
|
24
|
+
|
|
30
25
|
Svg.prototype = {
|
|
31
26
|
size: null,
|
|
32
27
|
foreground: null,
|
|
33
28
|
background: null,
|
|
34
29
|
rectangles: null,
|
|
35
|
-
color: function(t, i,
|
|
36
|
-
var r = [t, i,
|
|
37
|
-
return r.push(
|
|
30
|
+
color: function(t, i, e, s) {
|
|
31
|
+
var r = [ t, i, e ].map(Math.round);
|
|
32
|
+
return r.push(s >= 0 && s <= 255 ? s / 255 : 1), "rgba(" + r.join(",") + ")";
|
|
38
33
|
},
|
|
39
34
|
getDump: function() {
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
var t, i, e, s = this.foreground, r = this.background, n = .005 * this.size;
|
|
36
|
+
for (i = "<svg xmlns='http://www.w3.org/2000/svg' width='" + this.size + "' height='" + this.size + "' style='background-color:" + r + ";'><g style='fill:" + s + "; stroke:" + s + "; stroke-width:" + n + ";'>",
|
|
37
|
+
t = 0; t < this.rectangles.length; t++) (e = this.rectangles[t]).color != r && (i += "<rect x='" + e.x + "' y='" + e.y + "' width='" + e.w + "' height='" + e.h + "'/>");
|
|
38
|
+
return i += "</g></svg>";
|
|
42
39
|
},
|
|
43
40
|
getBase64: function() {
|
|
44
41
|
if ("function" == typeof btoa) return btoa(this.getDump());
|
|
45
42
|
if (Buffer) return new Buffer(this.getDump(), "binary").toString("base64");
|
|
46
|
-
throw "Cannot generate base64 output"
|
|
43
|
+
throw "Cannot generate base64 output";
|
|
47
44
|
}
|
|
48
45
|
}, Identicon.prototype = {
|
|
49
46
|
background: null,
|
|
@@ -53,31 +50,32 @@ Svg.prototype = {
|
|
|
53
50
|
size: null,
|
|
54
51
|
format: null,
|
|
55
52
|
image: function() {
|
|
56
|
-
return this.isSvg() ? new Svg(this.size, this.foreground, this.background) : new PNGlib(this.size, this.size, 256)
|
|
53
|
+
return this.isSvg() ? new Svg(this.size, this.foreground, this.background) : new PNGlib(this.size, this.size, 256);
|
|
57
54
|
},
|
|
58
55
|
render: function() {
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
var t, i, e = this.image(), s = this.size, r = Math.floor(s * this.margin), n = Math.floor((s - 2 * r) / 5), o = Math.floor((s - 5 * n) / 2), h = e.color.apply(e, this.background), a = e.color.apply(e, this.foreground);
|
|
57
|
+
for (t = 0; t < 15; t++) i = parseInt(this.hash.charAt(t), 16) % 2 ? h : a, t < 5 ? this.rectangle(2 * n + o, t * n + o, n, n, i, e) : t < 10 ? (this.rectangle(1 * n + o, (t - 5) * n + o, n, n, i, e),
|
|
58
|
+
this.rectangle(3 * n + o, (t - 5) * n + o, n, n, i, e)) : t < 15 && (this.rectangle(0 * n + o, (t - 10) * n + o, n, n, i, e),
|
|
59
|
+
this.rectangle(4 * n + o, (t - 10) * n + o, n, n, i, e));
|
|
60
|
+
return e;
|
|
61
61
|
},
|
|
62
|
-
rectangle: function(t, i,
|
|
62
|
+
rectangle: function(t, i, e, s, r, n) {
|
|
63
|
+
var o, h;
|
|
63
64
|
if (this.isSvg()) n.rectangles.push({
|
|
64
65
|
x: t,
|
|
65
66
|
y: i,
|
|
66
|
-
w:
|
|
67
|
-
h:
|
|
67
|
+
w: e,
|
|
68
|
+
h: s,
|
|
68
69
|
color: r
|
|
69
|
-
});
|
|
70
|
-
else
|
|
71
|
-
for (var e, h = t; h < t + s; h++)
|
|
72
|
-
for (e = i; e < i + o; e++) n.buffer[n.index(h, e)] = r
|
|
70
|
+
}); else for (o = t; o < t + e; o++) for (h = i; h < i + s; h++) n.buffer[n.index(o, h)] = r;
|
|
73
71
|
},
|
|
74
|
-
hsl2rgb: function(t, i,
|
|
75
|
-
return [255 * (i = [
|
|
72
|
+
hsl2rgb: function(t, i, e) {
|
|
73
|
+
return [ 255 * (i = [ e += i *= e < .5 ? e : 1 - e, e - (t *= 6) % 1 * i * 2, e -= i *= 2, e, e + t % 1 * i, e + i ])[~~t % 6], 255 * i[(16 | t) % 6], 255 * i[(8 | t) % 6] ];
|
|
76
74
|
},
|
|
77
75
|
toString: function(t) {
|
|
78
|
-
return t ? this.render().getDump() : this.render().getBase64()
|
|
76
|
+
return t ? this.render().getDump() : this.render().getBase64();
|
|
79
77
|
},
|
|
80
78
|
isSvg: function() {
|
|
81
|
-
return this.format.match(/svg/i)
|
|
79
|
+
return this.format.match(/svg/i);
|
|
82
80
|
}
|
|
83
|
-
}, module.exports = Identicon;
|
|
81
|
+
}, module.exports = Identicon;
|
package/lib/png/pnglib.js
CHANGED
|
@@ -1,57 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* A handy class to calculate color values.
|
|
5
|
+
*
|
|
6
|
+
* @version 1.0
|
|
7
|
+
* @author Robert Eisele <robert@xarg.org>
|
|
8
|
+
* @copyright Copyright (c) 2010, Robert Eisele
|
|
9
|
+
* @link http://www.xarg.org/2010/03/generate-client-side-png-files-using-javascript/
|
|
10
|
+
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
|
11
|
+
*
|
|
12
|
+
*/ function write(t, i) {
|
|
13
|
+
for (var s = 2; s < arguments.length; s++) for (var e = 0; e < arguments[s].length; e++) t[i++] = arguments[s].charAt(e);
|
|
6
14
|
}
|
|
7
15
|
|
|
8
16
|
function byte2(t) {
|
|
9
|
-
return String.fromCharCode(t >> 8 & 255, 255 & t)
|
|
17
|
+
return String.fromCharCode(t >> 8 & 255, 255 & t);
|
|
10
18
|
}
|
|
11
19
|
|
|
12
20
|
function byte4(t) {
|
|
13
|
-
return String.fromCharCode(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, 255 & t)
|
|
21
|
+
return String.fromCharCode(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, 255 & t);
|
|
14
22
|
}
|
|
15
23
|
|
|
16
24
|
function byte2lsb(t) {
|
|
17
|
-
return String.fromCharCode(255 & t, t >> 8 & 255)
|
|
25
|
+
return String.fromCharCode(255 & t, t >> 8 & 255);
|
|
18
26
|
}
|
|
27
|
+
|
|
19
28
|
module.exports = function(t, i, s) {
|
|
20
|
-
this.width = t, this.height = i, this.depth = s, this.pix_size = i * (t + 1), this.data_size = 2 + this.pix_size + 5 * Math.floor((65534 + this.pix_size) / 65535) + 4,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
this.width = t, this.height = i, this.depth = s, this.pix_size = i * (t + 1), this.data_size = 2 + this.pix_size + 5 * Math.floor((65534 + this.pix_size) / 65535) + 4,
|
|
30
|
+
this.ihdr_offs = 0, this.ihdr_size = 25, this.plte_offs = this.ihdr_offs + this.ihdr_size,
|
|
31
|
+
this.plte_size = 8 + 3 * s + 4, this.trns_offs = this.plte_offs + this.plte_size,
|
|
32
|
+
this.trns_size = 8 + s + 4, this.idat_offs = this.trns_offs + this.trns_size, this.idat_size = 8 + this.data_size + 4,
|
|
33
|
+
this.iend_offs = this.idat_offs + this.idat_size, this.iend_size = 12, this.buffer_size = this.iend_offs + this.iend_size,
|
|
34
|
+
this.buffer = new Array, this.palette = new Object, this.pindex = 0;
|
|
35
|
+
for (var e = new Array, h = 0; h < this.buffer_size; h++) this.buffer[h] = "\0";
|
|
36
|
+
write(this.buffer, this.ihdr_offs, byte4(this.ihdr_size - 12), "IHDR", byte4(t), byte4(i), "\b"),
|
|
37
|
+
write(this.buffer, this.plte_offs, byte4(this.plte_size - 12), "PLTE"), write(this.buffer, this.trns_offs, byte4(this.trns_size - 12), "tRNS"),
|
|
38
|
+
write(this.buffer, this.idat_offs, byte4(this.idat_size - 12), "IDAT"), write(this.buffer, this.iend_offs, byte4(this.iend_size - 12), "IEND");
|
|
39
|
+
var r = 30912;
|
|
40
|
+
r += 31 - r % 31, write(this.buffer, this.idat_offs + 8, byte2(r));
|
|
41
|
+
for (h = 0; (h << 16) - 1 < this.pix_size; h++) {
|
|
42
|
+
var f, o;
|
|
43
|
+
h + 65535 < this.pix_size ? (f = 65535, o = "\0") : (f = this.pix_size - (h << 16) - h,
|
|
44
|
+
o = ""), write(this.buffer, this.idat_offs + 8 + 2 + (h << 16) + (h << 2), o, byte2lsb(f), byte2lsb(~f));
|
|
28
45
|
}
|
|
29
|
-
for (
|
|
30
|
-
for (var
|
|
31
|
-
|
|
46
|
+
for (h = 0; h < 256; h++) {
|
|
47
|
+
for (var n = h, d = 0; d < 8; d++) n = 1 & n ? -306674912 ^ n >> 1 & 2147483647 : n >> 1 & 2147483647;
|
|
48
|
+
e[h] = n;
|
|
32
49
|
}
|
|
33
50
|
this.index = function(t, i) {
|
|
34
51
|
var s = i * (this.width + 1) + t + 1;
|
|
35
|
-
return this.idat_offs + 8 + 2 + 5 * Math.floor(s / 65535 + 1) + s
|
|
52
|
+
return this.idat_offs + 8 + 2 + 5 * Math.floor(s / 65535 + 1) + s;
|
|
36
53
|
}, this.color = function(t, i, s, e) {
|
|
37
|
-
var h = (((e =
|
|
54
|
+
var h = (((e = e >= 0 ? e : 255) << 8 | t) << 8 | i) << 8 | s;
|
|
38
55
|
if (void 0 === this.palette[h]) {
|
|
39
56
|
if (this.pindex == this.depth) return "\0";
|
|
40
57
|
var r = this.plte_offs + 8 + 3 * this.pindex;
|
|
41
|
-
this.buffer[r + 0] = String.fromCharCode(t), this.buffer[r + 1] = String.fromCharCode(i),
|
|
58
|
+
this.buffer[r + 0] = String.fromCharCode(t), this.buffer[r + 1] = String.fromCharCode(i),
|
|
59
|
+
this.buffer[r + 2] = String.fromCharCode(s), this.buffer[this.trns_offs + 8 + this.pindex] = String.fromCharCode(e),
|
|
60
|
+
this.palette[h] = String.fromCharCode(this.pindex++);
|
|
42
61
|
}
|
|
43
|
-
return this.palette[h]
|
|
62
|
+
return this.palette[h];
|
|
44
63
|
}, this.getBase64 = function() {
|
|
45
|
-
|
|
46
|
-
|
|
64
|
+
var t, i, s, e, h, r, f, o = this.getDump(), n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", d = o.length, a = 0, _ = "";
|
|
65
|
+
do {
|
|
66
|
+
e = (t = o.charCodeAt(a)) >> 2, h = (3 & t) << 4 | (i = o.charCodeAt(a + 1)) >> 4,
|
|
67
|
+
s = o.charCodeAt(a + 2), r = d < a + 2 ? 64 : (15 & i) << 2 | s >> 6, f = d < a + 3 ? 64 : 63 & s,
|
|
68
|
+
_ += n.charAt(e) + n.charAt(h) + n.charAt(r) + n.charAt(f);
|
|
69
|
+
} while ((a += 3) < d);
|
|
70
|
+
return _;
|
|
47
71
|
}, this.getDump = function() {
|
|
48
|
-
for (var t = 65521, i = 1, s = 0,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
write(t, i + s - 4, byte4(-1 ^ e))
|
|
72
|
+
for (var t = 65521, i = 1, s = 0, h = 5552, r = 0; r < this.height; r++) for (var f = -1; f < this.width; f++) s += i += this.buffer[this.index(f, r)].charCodeAt(0),
|
|
73
|
+
0 == (h -= 1) && (i %= t, s %= t, h = 5552);
|
|
74
|
+
function o(t, i, s) {
|
|
75
|
+
for (var h = -1, r = 4; r < s - 4; r += 1) h = e[255 & (h ^ t[i + r].charCodeAt(0))] ^ h >> 8 & 16777215;
|
|
76
|
+
write(t, i + s - 4, byte4(-1 ^ h));
|
|
54
77
|
}
|
|
55
|
-
return i %= t, s %= t, write(this.buffer, this.idat_offs + this.idat_size - 8, byte4(s << 16 | i)),
|
|
56
|
-
|
|
57
|
-
|
|
78
|
+
return i %= t, s %= t, write(this.buffer, this.idat_offs + this.idat_size - 8, byte4(s << 16 | i)),
|
|
79
|
+
o(this.buffer, this.ihdr_offs, this.ihdr_size), o(this.buffer, this.plte_offs, this.plte_size),
|
|
80
|
+
o(this.buffer, this.trns_offs, this.trns_size), o(this.buffer, this.idat_offs, this.idat_size),
|
|
81
|
+
o(this.buffer, this.iend_offs, this.iend_size), "PNG\r\n\n" + this.buffer.join("");
|
|
82
|
+
};
|
|
83
|
+
};
|
package/lib/png/randomPic.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
var md5 = require("./../encrypt/_md5"), Identicon = require("./Identicon");
|
|
4
4
|
|
|
5
5
|
function randomWord(n, o, r) {
|
|
6
|
-
var t = "",
|
|
7
|
-
e = o,
|
|
8
|
-
d = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
|
|
6
|
+
var t = "", e = o, d = [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" ];
|
|
9
7
|
n && (e = Math.round(Math.random() * (r - o)) + o);
|
|
10
8
|
for (var a = 0; a < e; a++) pos = Math.round(Math.random() * (d.length - 1)), t += d[pos];
|
|
11
|
-
return t
|
|
9
|
+
return t;
|
|
12
10
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
11
|
+
|
|
12
|
+
module.exports = function() {
|
|
13
|
+
var n = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "amos-tool", o = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 16, r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 16, t = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : 420, e = randomWord(n, o, r), d = md5(e), a = new Identicon(d, t).toString(), i = "data:image/png;base64," + a;
|
|
14
|
+
return i;
|
|
15
|
+
};
|