amos-tool 1.4.7 → 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 -667
- package/apis/objectPath.md +129 -129
- package/index.d.ts +11 -2
- package/index.js +3 -3
- package/lib/_browser.js +10 -8
- package/lib/_clone.js +68 -57
- package/lib/_cookie.js +50 -47
- package/lib/_deepCopy.js +14 -19
- package/lib/_deepEqual.js +7 -8
- package/lib/_fastDeepEqual.js +26 -34
- 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 +74 -79
- package/lib/_object.assign.js +19 -19
- package/lib/_object.entries.js +8 -7
- package/lib/_object.values.js +8 -7
- package/lib/_omit.js +12 -11
- package/lib/_parseJson.js +7 -6
- package/lib/_pick.js +8 -7
- package/lib/_queue.js +24 -21
- package/lib/_shallowCopy.js +24 -23
- package/lib/_stringify.js +13 -10
- 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 +4 -66
- package/lib/array2tree.js +9 -9
- package/lib/arrayFilter.js +18 -19
- package/lib/arrayUtils.js +10 -8
- package/lib/browser/Cookie.js +35 -36
- package/lib/browser/indexDB.js +72 -71
- package/lib/browserSupport.js +76 -71
- package/lib/completeUnit.js +7 -4
- package/lib/consts.js +2 -1
- package/lib/dom/canvas2img.js +61 -72
- package/lib/dom/canvasTools.js +11 -16
- package/lib/dom/downloadFile.js +17 -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 +27 -24
- package/lib/encrypt/_base64.js +32 -25
- package/lib/encrypt/_md5.js +68 -31
- package/lib/encrypt/des.js +430 -366
- package/lib/extra/_common.js +120 -161
- package/lib/extra/filterNull.js +5 -4
- 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 +49 -36
- package/lib/extra/pwdStrength.js +4 -2
- package/lib/extra/sortBy.js +28 -30
- package/lib/flat.js +9 -13
- package/lib/locationParams.js +93 -95
- package/lib/log.js +20 -26
- package/lib/math/_keyColor.js +3 -1
- package/lib/math/addition.js +9 -7
- package/lib/math/amountCase.js +8 -12
- package/lib/math/coinFormat.js +6 -4
- package/lib/math/colorUtil.js +91 -94
- package/lib/math/dateTime.js +79 -97
- 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 +81 -82
- package/lib/parseText.js +8 -7
- package/lib/png/Identicon.js +32 -28
- package/lib/png/pnglib.js +59 -34
- package/lib/png/randomPic.js +8 -14
- package/lib/positionFactory.js +28 -28
- package/lib/pwdPolicy.js +27 -31
- package/lib/qs/_assign.js +7 -5
- package/lib/qs/_merge.js +20 -23
- 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 +56 -51
- package/lib/qs/stringify.js +54 -69
- package/lib/qs/utils.js +70 -83
- package/lib/random.js +5 -4
- package/lib/shallowEqual.js +25 -29
- package/lib/store.js +93 -95
- package/lib/strUtils.js +52 -43
- 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 +171 -222
- package/lib/xss/htmlEncode.js +3 -2
- package/lib/xss/implementEncode.js +36 -37
- package/lib/xss/index.js +4 -3
- package/package.json +4 -4
- package/docs/Logger.html +0 -189
- package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -978
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -1049
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/global.html +0 -14535
- package/docs/index.html +0 -791
- package/docs/scripts/collapse.js +0 -20
- package/docs/scripts/linenumber.js +0 -25
- package/docs/scripts/nav.js +0 -12
- package/docs/scripts/polyfill.js +0 -4
- package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docs/scripts/prettify/lang-css.js +0 -2
- package/docs/scripts/prettify/prettify.js +0 -28
- package/docs/scripts/search.js +0 -83
- package/docs/styles/jsdoc.css +0 -765
- package/docs/styles/prettify.css +0 -79
package/lib/browser/indexDB.js
CHANGED
|
@@ -1,79 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
2
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: !0
|
|
5
7
|
}), exports.default = void 0;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
|
|
9
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")), _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")), InvalidStorageDB = function() {
|
|
10
|
+
function e() {
|
|
11
|
+
(0, _classCallCheck2.default)(this, e);
|
|
12
|
+
}
|
|
13
|
+
return (0, _createClass2.default)(e, [ {
|
|
14
|
+
key: "init",
|
|
15
|
+
value: function() {}
|
|
16
|
+
}, {
|
|
17
|
+
key: "get",
|
|
18
|
+
value: function() {}
|
|
19
|
+
}, {
|
|
20
|
+
key: "set",
|
|
21
|
+
value: function() {}
|
|
22
|
+
}, {
|
|
23
|
+
key: "clear",
|
|
24
|
+
value: function() {}
|
|
25
|
+
} ]), e;
|
|
26
|
+
}(), StorageDB = function() {
|
|
27
|
+
function e(t) {
|
|
28
|
+
(0, _classCallCheck2.default)(this, e);
|
|
29
|
+
var a = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
|
|
30
|
+
if (void 0 === a) return console.warn("Storage: IndexedDB not available."), new InvalidStorageDB;
|
|
31
|
+
this._name = t.name || "amostool-db", this.version = t.version || 1, this.storeName = t.storeName || "item",
|
|
32
|
+
this.database, this.indexedDB = a, this.performance = window.performance || {
|
|
33
|
+
now: function() {}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return (0, _createClass2.default)(e, [ {
|
|
37
|
+
key: "init",
|
|
38
|
+
value: function(e) {
|
|
39
|
+
var t = this, a = t.storeName, n = t.indexedDB.open(t._name, t.version);
|
|
40
|
+
n.onupgradeneeded = function(e) {
|
|
41
|
+
var t = e.target.result;
|
|
42
|
+
!1 === t.objectStoreNames.contains(a) && t.createObjectStore(a);
|
|
43
|
+
}, n.onsuccess = function(a) {
|
|
44
|
+
t.database = a.target.result, e && e();
|
|
45
|
+
}, n.onerror = function(e) {
|
|
46
|
+
console.error("IndexedDB", e);
|
|
47
|
+
};
|
|
11
48
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
key: "set",
|
|
20
|
-
value: function() {}
|
|
21
|
-
}, {
|
|
22
|
-
key: "clear",
|
|
23
|
-
value: function() {}
|
|
24
|
-
}]), e
|
|
25
|
-
}(),
|
|
26
|
-
StorageDB = function() {
|
|
27
|
-
function a(e) {
|
|
28
|
-
(0, _classCallCheck2.default)(this, a);
|
|
29
|
-
var t = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
|
|
30
|
-
if (void 0 === t) return console.warn("Storage: IndexedDB not available."), new InvalidStorageDB;
|
|
31
|
-
this._name = e.name || "amostool-db", this.version = e.version || 1, this.storeName = e.storeName || "item", this.database, this.indexedDB = t, this.performance = window.performance || {
|
|
32
|
-
now: function() {}
|
|
33
|
-
}
|
|
49
|
+
}, {
|
|
50
|
+
key: "get",
|
|
51
|
+
value: function(e) {
|
|
52
|
+
var t = this.storeName;
|
|
53
|
+
this.database.transaction([ t ], "readwrite").objectStore(t).get(0).onsuccess = function(t) {
|
|
54
|
+
e && e(t.target.result);
|
|
55
|
+
};
|
|
34
56
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var e = this.storeName;
|
|
54
|
-
this.database.transaction([e], "readwrite").objectStore(e).get(0).onsuccess = function(e) {
|
|
55
|
-
t && t(e.target.result)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}, {
|
|
59
|
-
key: "set",
|
|
60
|
-
value: function(e, t) {
|
|
61
|
-
var a = this,
|
|
62
|
-
n = a.performance.now(),
|
|
63
|
-
o = a.storeName;
|
|
64
|
-
a.database.transaction([o], "readwrite").objectStore(o).put(e, 0).onsuccess = function(e) {
|
|
65
|
-
console.log("[".concat(/\d\d\:\d\d\:\d\d/.exec(new Date)[0], "]"), "Saved item to IndexedDB. ".concat((a.performance.now() - n).toFixed(2), "ms")), t && t(e.target.result)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}, {
|
|
69
|
-
key: "clear",
|
|
70
|
-
value: function() {
|
|
71
|
-
var e, t = this;
|
|
72
|
-
void 0 !== t.database && (e = t.storeName, t.database.transaction([e], "readwrite").objectStore(e).clear().onsuccess = function(e) {
|
|
73
|
-
console.log("[".concat(/\d\d\:\d\d\:\d\d/.exec(new Date)[0], "]"), "Cleared IndexedDB.")
|
|
74
|
-
})
|
|
57
|
+
}, {
|
|
58
|
+
key: "set",
|
|
59
|
+
value: function(e, t) {
|
|
60
|
+
var a = this, n = a.performance.now(), r = a.storeName;
|
|
61
|
+
a.database.transaction([ r ], "readwrite").objectStore(r).put(e, 0).onsuccess = function(e) {
|
|
62
|
+
console.log("[".concat(/\d\d\:\d\d\:\d\d/.exec(new Date)[0], "]"), "Saved item to IndexedDB. ".concat((a.performance.now() - n).toFixed(2), "ms")),
|
|
63
|
+
t && t(e.target.result);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
key: "clear",
|
|
68
|
+
value: function() {
|
|
69
|
+
var e = this;
|
|
70
|
+
if (void 0 !== e.database) {
|
|
71
|
+
var t = e.storeName;
|
|
72
|
+
e.database.transaction([ t ], "readwrite").objectStore(t).clear().onsuccess = function(e) {
|
|
73
|
+
console.log("[".concat(/\d\d\:\d\d\:\d\d/.exec(new Date)[0], "]"), "Cleared IndexedDB.");
|
|
74
|
+
};
|
|
75
75
|
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
}
|
|
77
|
+
} ]), e;
|
|
78
|
+
}(), _default = StorageDB;
|
|
79
|
+
|
|
80
|
+
exports.default = _default;
|
package/lib/browserSupport.js
CHANGED
|
@@ -1,73 +1,78 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
2
|
+
|
|
3
|
+
var _utils = require("./utils"), _consts = require("./consts"), _defaultBrowsers = [ "firefox/51.0", "chrome/56" ], _muiltBrowsers = [ "firefox/", "chrome/" ], calcIeSerails = function(s, e, r, i) {
|
|
4
|
+
var t, o = s.indexOf("compatible") > -1 && s.indexOf("msie") > -1, n = s.indexOf("edge") > -1 && !o, a = s.indexOf("trident") > -1 && s.indexOf("rv:11.0") > -1, c = !1;
|
|
5
|
+
if (o) {
|
|
6
|
+
new RegExp("msie (\\d+\\.\\d+);").test(s);
|
|
7
|
+
var l = parseFloat(RegExp.$1);
|
|
8
|
+
t = 7 == l ? 7 : 8 == l ? 8 : 9 == l ? 9 : 10 == l ? 10 : 6;
|
|
9
|
+
} else t = n ? 12 : a ? 11 : -1;
|
|
10
|
+
switch (r) {
|
|
11
|
+
case _consts.GREATER:
|
|
12
|
+
c = t > i;
|
|
13
|
+
break;
|
|
14
|
+
|
|
15
|
+
case _consts.EQUAL:
|
|
16
|
+
c = t == i;
|
|
17
|
+
break;
|
|
18
|
+
|
|
19
|
+
case _consts.LESS:
|
|
20
|
+
c = t < i;
|
|
21
|
+
break;
|
|
22
|
+
|
|
23
|
+
case _consts.GREATER_EQUAL:
|
|
24
|
+
c = t >= i;
|
|
25
|
+
break;
|
|
26
|
+
|
|
27
|
+
case _consts.LESS_EQUAL:
|
|
28
|
+
c = t <= i;
|
|
29
|
+
}
|
|
30
|
+
return c;
|
|
31
|
+
}, calcBrowserVersion = function(s, e, r, i) {
|
|
32
|
+
var t = !1;
|
|
33
|
+
if (s.indexOf(e) > -1) switch (r) {
|
|
34
|
+
case _consts.GREATER:
|
|
35
|
+
t = s.split(e)[1].split(".")[0] > i;
|
|
36
|
+
break;
|
|
37
|
+
|
|
38
|
+
case _consts.EQUAL:
|
|
39
|
+
t = s.split(e)[1].split(".")[0] == i;
|
|
40
|
+
break;
|
|
41
|
+
|
|
42
|
+
case _consts.LESS:
|
|
43
|
+
t = s.split(e)[1].split(".")[0] < i;
|
|
44
|
+
break;
|
|
45
|
+
|
|
46
|
+
case _consts.GREATER_EQUAL:
|
|
47
|
+
t = s.split(e)[1].split(".")[0] >= i;
|
|
48
|
+
break;
|
|
49
|
+
|
|
50
|
+
case _consts.LESS_EQUAL:
|
|
51
|
+
t = s.split(e)[1].split(".")[0] <= i;
|
|
52
|
+
} else t = calcIeSerails(s, e, r, i);
|
|
53
|
+
return console.log("supported:", t), t;
|
|
54
|
+
}, browserSupport = function(s, e) {
|
|
55
|
+
if (navigator) {
|
|
56
|
+
var r = navigator.userAgent;
|
|
57
|
+
if (!_utils.isEmpty(r)) if (r = r.toLowerCase(), _utils.isEmpty(e)) {
|
|
58
|
+
var i = s || _defaultBrowsers;
|
|
59
|
+
if (!_utils.isEmpty(i)) {
|
|
60
|
+
if (_utils.isArray(i)) return _utils.some(i, (function(s) {
|
|
61
|
+
return console.log("non matchs. target browser is:", s), r.indexOf(s) > -1;
|
|
62
|
+
}));
|
|
63
|
+
if (_utils.isString(i)) return r.indexOf(i) > -1;
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
var t = s || _muiltBrowsers;
|
|
67
|
+
if (!_utils.isEmpty(t)) {
|
|
68
|
+
if (_utils.isArray(t)) return _utils.some(t, (function(s) {
|
|
69
|
+
return console.log("matchs. target browser is:", s), calcBrowserVersion(r, s, e[s].limit, e[s].version);
|
|
70
|
+
}));
|
|
71
|
+
if (_utils.isString(t)) return calcBrowserVersion(r, t, e.limit, e.version);
|
|
72
|
+
}
|
|
26
73
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
case _consts.GREATER:
|
|
33
|
-
i = s.split(e)[1].split(".")[0] > t;
|
|
34
|
-
break;
|
|
35
|
-
case _consts.EQUAL:
|
|
36
|
-
i = s.split(e)[1].split(".")[0] == t;
|
|
37
|
-
break;
|
|
38
|
-
case _consts.LESS:
|
|
39
|
-
i = s.split(e)[1].split(".")[0] < t;
|
|
40
|
-
break;
|
|
41
|
-
case _consts.GREATER_EQUAL:
|
|
42
|
-
i = s.split(e)[1].split(".")[0] >= t;
|
|
43
|
-
break;
|
|
44
|
-
case _consts.LESS_EQUAL:
|
|
45
|
-
i = s.split(e)[1].split(".")[0] <= t
|
|
46
|
-
} else i = calcIeSerails(s, e, r, t);
|
|
47
|
-
return console.log("supported:", i), i
|
|
48
|
-
},
|
|
49
|
-
browserSupport = function(s, e) {
|
|
50
|
-
if (navigator) {
|
|
51
|
-
var r = navigator.userAgent;
|
|
52
|
-
if (!_utils.isEmpty(r))
|
|
53
|
-
if (r = r.toLowerCase(), _utils.isEmpty(e)) {
|
|
54
|
-
var t = s || _defaultBrowsers;
|
|
55
|
-
if (!_utils.isEmpty(t)) {
|
|
56
|
-
if (_utils.isArray(t)) return _utils.some(t, function(s) {
|
|
57
|
-
return console.log("non matchs. target browser is:", s), -1 < r.indexOf(s)
|
|
58
|
-
});
|
|
59
|
-
if (_utils.isString(t)) return -1 < r.indexOf(t)
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
s = s || _muiltBrowsers;
|
|
63
|
-
if (!_utils.isEmpty(s)) {
|
|
64
|
-
if (_utils.isArray(s)) return _utils.some(s, function(s) {
|
|
65
|
-
return console.log("matchs. target browser is:", s), calcBrowserVersion(r, s, e[s].limit, e[s].version)
|
|
66
|
-
});
|
|
67
|
-
if (_utils.isString(s)) return calcBrowserVersion(r, s, e.limit, e.version)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return !1
|
|
72
|
-
};
|
|
73
|
-
module.exports = browserSupport;
|
|
74
|
+
}
|
|
75
|
+
return !1;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
module.exports = browserSupport;
|
package/lib/completeUnit.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
2
3
|
var utils = require("./utils");
|
|
3
4
|
|
|
4
5
|
function completeUnit(e) {
|
|
5
|
-
var t =
|
|
6
|
-
return utils.isString(e) || (e += ""), e.endsWith(t) ? e : "".concat(e).concat(t)
|
|
6
|
+
var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "px";
|
|
7
|
+
return utils.isString(e) || (e += ""), e.endsWith(t) ? e : "".concat(e).concat(t);
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
function toPixel(e) {
|
|
10
11
|
var t = e;
|
|
11
|
-
return e && (utils.isNumber(e) ? t = completeUnit(Number(e)) : utils.isString(e) && e.endsWith("%") ? t = completeUnit(Number(e.replace("%", "")), "%") : utils.isString(e) && e.endsWith("px") ? t = completeUnit(Number(e.replace("px", "")), "px") : utils.isString(e) && e.endsWith("vh") ? t = completeUnit(Number(e.replace("vh", "")), "vh") : utils.isString(e) && e.endsWith("vw") ? t = completeUnit(Number(e.replace("vw", "")), "vw") : utils.isString(e) && e.endsWith("rem") ? t = completeUnit(Number(e.replace("rem", "")), "rem") : utils.isString(e) && e.endsWith("em") && (t = completeUnit(Number(e.replace("em", "")), "em"))),
|
|
12
|
+
return e && (utils.isNumber(e) ? t = completeUnit(Number(e)) : utils.isString(e) && e.endsWith("%") ? t = completeUnit(Number(e.replace("%", "")), "%") : utils.isString(e) && e.endsWith("px") ? t = completeUnit(Number(e.replace("px", "")), "px") : utils.isString(e) && e.endsWith("vh") ? t = completeUnit(Number(e.replace("vh", "")), "vh") : utils.isString(e) && e.endsWith("vw") ? t = completeUnit(Number(e.replace("vw", "")), "vw") : utils.isString(e) && e.endsWith("rem") ? t = completeUnit(Number(e.replace("rem", "")), "rem") : utils.isString(e) && e.endsWith("em") && (t = completeUnit(Number(e.replace("em", "")), "em"))),
|
|
13
|
+
t;
|
|
12
14
|
}
|
|
13
|
-
|
|
15
|
+
|
|
16
|
+
module.exports = completeUnit, module.exports.toPixel = toPixel;
|
package/lib/consts.js
CHANGED
package/lib/dom/canvas2img.js
CHANGED
|
@@ -1,131 +1,120 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var e, t;
|
|
6
|
-
|
|
2
|
+
|
|
3
|
+
var utils = require("./../utils"), $support = {}, support = function() {
|
|
4
|
+
if (utils.isEmpty($support)) {
|
|
5
|
+
var e = document.createElement("canvas"), t = e.getContext("2d");
|
|
6
|
+
$support = {
|
|
7
7
|
canvas: !!t,
|
|
8
8
|
imageData: !!t.getImageData,
|
|
9
9
|
dataURL: !!e.toDataURL,
|
|
10
10
|
btoa: !!window.btoa
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
return $support;
|
|
14
|
+
}, downloadMime = "image/octet-stream";
|
|
14
15
|
|
|
15
16
|
function scaleCanvas(e, t, a) {
|
|
16
|
-
var n = e.width,
|
|
17
|
-
r = e.height;
|
|
17
|
+
var n = e.width, r = e.height;
|
|
18
18
|
null == t && (t = n), null == a && (a = r);
|
|
19
|
-
var o = document.createElement("canvas"),
|
|
20
|
-
|
|
21
|
-
return o.width = t, o.height = a, g.drawImage(e, 0, 0, n, r, 0, 0, t, a), o
|
|
19
|
+
var o = document.createElement("canvas"), g = o.getContext("2d");
|
|
20
|
+
return o.width = t, o.height = a, g.drawImage(e, 0, 0, n, r, 0, 0, t, a), o;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
function getDataURL(e, t, a, n) {
|
|
25
|
-
return (e = scaleCanvas(e, a, n)).toDataURL(t)
|
|
24
|
+
return (e = scaleCanvas(e, a, n)).toDataURL(t);
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
function getBlob(e, t, a) {
|
|
29
|
-
var n = a.type || "image/png",
|
|
30
|
-
|
|
31
|
-
o = a.height,
|
|
32
|
-
a = a.encoderOptions || 1;
|
|
33
|
-
return (e = scaleCanvas(e, r, o)).toBlob(t, n, a)
|
|
28
|
+
var n = a.type || "image/png", r = a.width, o = a.height, g = a.encoderOptions || 1;
|
|
29
|
+
return (e = scaleCanvas(e, r, o)).toBlob(t, n, g);
|
|
34
30
|
}
|
|
35
31
|
|
|
36
32
|
function saveFile(e) {
|
|
37
|
-
document.location.href = e
|
|
33
|
+
document.location.href = e;
|
|
38
34
|
}
|
|
39
35
|
|
|
40
36
|
function genImage(e) {
|
|
41
37
|
var t = document.createElement("img");
|
|
42
|
-
return t.src = e, t
|
|
38
|
+
return t.src = e, t;
|
|
43
39
|
}
|
|
44
40
|
|
|
45
41
|
function fixType(e) {
|
|
46
|
-
return "image/" + (e = e.toLowerCase().replace(/jpg/i, "jpeg")).match(/png|jpeg|bmp|gif/)[0]
|
|
42
|
+
return "image/" + (e = e.toLowerCase().replace(/jpg/i, "jpeg")).match(/png|jpeg|bmp|gif/)[0];
|
|
47
43
|
}
|
|
48
44
|
|
|
49
45
|
function encodeData(e) {
|
|
50
46
|
if (!window.btoa) throw new Error("btoa undefined");
|
|
51
47
|
var t = "";
|
|
52
|
-
if ("string" == typeof e) t = e;
|
|
53
|
-
|
|
54
|
-
for (var a = 0; a < e.length; a++) t += String.fromCharCode(e[a]);
|
|
55
|
-
return btoa(t)
|
|
48
|
+
if ("string" == typeof e) t = e; else for (var a = 0; a < e.length; a++) t += String.fromCharCode(e[a]);
|
|
49
|
+
return btoa(t);
|
|
56
50
|
}
|
|
57
51
|
|
|
58
52
|
function getImageData(e) {
|
|
59
|
-
var t = e.width,
|
|
60
|
-
|
|
61
|
-
return e.getContext("2d").getImageData(0, 0, t, a)
|
|
53
|
+
var t = e.width, a = e.height;
|
|
54
|
+
return e.getContext("2d").getImageData(0, 0, t, a);
|
|
62
55
|
}
|
|
63
56
|
|
|
64
57
|
function makeURI(e, t) {
|
|
65
|
-
return "data:" + t + ";base64," + e
|
|
58
|
+
return "data:" + t + ";base64," + e;
|
|
66
59
|
}
|
|
60
|
+
|
|
67
61
|
var genBitmapImage = function(e) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
n = [40, 0, 0, 0, 255 & t, t >> 8 & 255, t >> 16 & 255, t >> 24 & 255, 255 & a, a >> 8 & 255, a >> 16 & 255, a >> 24 & 255, 1, 0, 24, 0, 0, 0, 0, 0, 255 & n, n >> 8 & 255, n >> 16 & 255, n >> 24 & 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
74
|
-
o = (4 - 3 * t % 4) % 4,
|
|
75
|
-
g = e.data,
|
|
76
|
-
i = "",
|
|
77
|
-
s = t << 2,
|
|
78
|
-
u = a,
|
|
79
|
-
c = String.fromCharCode;
|
|
80
|
-
do {
|
|
81
|
-
for (var m = s * (u - 1), v = "", p = 0; p < t; p++) {
|
|
82
|
-
var d = p << 2;
|
|
83
|
-
v += c(g[m + d + 2]) + c(g[m + d + 1]) + c(g[m + d])
|
|
84
|
-
}
|
|
85
|
-
for (var f = 0; f < o; f++) v += String.fromCharCode(0)
|
|
86
|
-
} while (i += v, --u);
|
|
87
|
-
return encodeData(r.concat(n)) + encodeData(i)
|
|
88
|
-
},
|
|
89
|
-
saveAsImage = function(e, t, a, n) {
|
|
90
|
-
var r;
|
|
91
|
-
support().canvas && support().dataURL && ("string" == typeof e && (e = document.getElementById(e)), n = fixType(n = null == n ? "png" : n), /bmp/.test(n) ? (r = getImageData(scaleCanvas(e, t, a)), saveFile(makeURI(genBitmapImage(r), downloadMime))) : saveFile(getDataURL(e, n, t, a).replace(n, downloadMime)))
|
|
92
|
-
},
|
|
93
|
-
convert2Image = function(e, t, a, n) {
|
|
94
|
-
if (support().canvas && support().dataURL) {
|
|
95
|
-
if ("string" == typeof e && (e = document.getElementById(e)), n = fixType(n = null == n ? "png" : n), /bmp/.test(n)) {
|
|
96
|
-
var r = getImageData(scaleCanvas(e, t, a));
|
|
97
|
-
return genImage(makeURI(genBitmapImage(r), "image/bmp"))
|
|
98
|
-
}
|
|
99
|
-
return genImage(getDataURL(e, n, t, a))
|
|
62
|
+
var t = e.width, a = e.height, n = t * a * 3, r = n + 54, o = [ 66, 77, 255 & r, r >> 8 & 255, r >> 16 & 255, r >> 24 & 255, 0, 0, 0, 0, 54, 0, 0, 0 ], g = [ 40, 0, 0, 0, 255 & t, t >> 8 & 255, t >> 16 & 255, t >> 24 & 255, 255 & a, a >> 8 & 255, a >> 16 & 255, a >> 24 & 255, 1, 0, 24, 0, 0, 0, 0, 0, 255 & n, n >> 8 & 255, n >> 16 & 255, n >> 24 & 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], i = (4 - 3 * t % 4) % 4, s = e.data, u = "", c = t << 2, m = a, v = String.fromCharCode;
|
|
63
|
+
do {
|
|
64
|
+
for (var p = c * (m - 1), f = "", d = 0; d < t; d++) {
|
|
65
|
+
var l = d << 2;
|
|
66
|
+
f += v(s[p + l + 2]) + v(s[p + l + 1]) + v(s[p + l]);
|
|
100
67
|
}
|
|
101
|
-
|
|
68
|
+
for (var I = 0; I < i; I++) f += String.fromCharCode(0);
|
|
69
|
+
u += f;
|
|
70
|
+
} while (--m);
|
|
71
|
+
return encodeData(o.concat(g)) + encodeData(u);
|
|
72
|
+
}, saveAsImage = function(e, t, a, n) {
|
|
73
|
+
if (support().canvas && support().dataURL) if ("string" == typeof e && (e = document.getElementById(e)),
|
|
74
|
+
null == n && (n = "png"), n = fixType(n), /bmp/.test(n)) {
|
|
75
|
+
var r = getImageData(scaleCanvas(e, t, a));
|
|
76
|
+
saveFile(makeURI(genBitmapImage(r), downloadMime));
|
|
77
|
+
} else {
|
|
78
|
+
saveFile(getDataURL(e, n, t, a).replace(n, downloadMime));
|
|
79
|
+
}
|
|
80
|
+
}, convert2Image = function(e, t, a, n) {
|
|
81
|
+
if (support().canvas && support().dataURL) {
|
|
82
|
+
if ("string" == typeof e && (e = document.getElementById(e)), null == n && (n = "png"),
|
|
83
|
+
n = fixType(n), /bmp/.test(n)) {
|
|
84
|
+
var r = getImageData(scaleCanvas(e, t, a));
|
|
85
|
+
return genImage(makeURI(genBitmapImage(r), "image/bmp"));
|
|
86
|
+
}
|
|
87
|
+
return genImage(getDataURL(e, n, t, a));
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
102
91
|
module.exports = {
|
|
103
92
|
saveAsImage: saveAsImage,
|
|
104
93
|
saveAsPNG: function(e, t, a) {
|
|
105
|
-
return saveAsImage(e, t, a, "png")
|
|
94
|
+
return saveAsImage(e, t, a, "png");
|
|
106
95
|
},
|
|
107
96
|
saveAsJPEG: function(e, t, a) {
|
|
108
|
-
return saveAsImage(e, t, a, "jpeg")
|
|
97
|
+
return saveAsImage(e, t, a, "jpeg");
|
|
109
98
|
},
|
|
110
99
|
saveAsGIF: function(e, t, a) {
|
|
111
|
-
return saveAsImage(e, t, a, "gif")
|
|
100
|
+
return saveAsImage(e, t, a, "gif");
|
|
112
101
|
},
|
|
113
102
|
saveAsBMP: function(e, t, a) {
|
|
114
|
-
return saveAsImage(e, t, a, "bmp")
|
|
103
|
+
return saveAsImage(e, t, a, "bmp");
|
|
115
104
|
},
|
|
116
105
|
convert2Image: convert2Image,
|
|
117
106
|
convert2data: getDataURL,
|
|
118
107
|
convert2Blob: getBlob,
|
|
119
108
|
convert2PNG: function(e, t, a) {
|
|
120
|
-
return convert2Image(e, t, a, "png")
|
|
109
|
+
return convert2Image(e, t, a, "png");
|
|
121
110
|
},
|
|
122
111
|
convert2JPEG: function(e, t, a) {
|
|
123
|
-
return convert2Image(e, t, a, "jpeg")
|
|
112
|
+
return convert2Image(e, t, a, "jpeg");
|
|
124
113
|
},
|
|
125
114
|
convert2GIF: function(e, t, a) {
|
|
126
|
-
return convert2Image(e, t, a, "gif")
|
|
115
|
+
return convert2Image(e, t, a, "gif");
|
|
127
116
|
},
|
|
128
117
|
convert2BMP: function(e, t, a) {
|
|
129
|
-
return convert2Image(e, t, a, "bmp")
|
|
118
|
+
return convert2Image(e, t, a, "bmp");
|
|
130
119
|
}
|
|
131
|
-
};
|
|
120
|
+
};
|
package/lib/dom/canvasTools.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
2
3
|
var drawPolygon = function(t, o) {
|
|
3
|
-
var a = o && o.x || 0,
|
|
4
|
-
l = o && o.y || 0,
|
|
5
|
-
e = o && o.num || 3,
|
|
6
|
-
r = o && o.r || 100,
|
|
7
|
-
i = o && o.width || 5,
|
|
8
|
-
n = o && o.strokeStyle,
|
|
9
|
-
h = o && o.fillStyle;
|
|
4
|
+
var a = o && o.x || 0, l = o && o.y || 0, e = o && o.num || 3, r = o && o.r || 100, i = o && o.width || 5, n = o && o.strokeStyle, h = o && o.fillStyle;
|
|
10
5
|
t.beginPath();
|
|
11
|
-
var s = a + r * Math.cos(2 * Math.PI * 0 / e),
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
M = l + r * Math.sin(2 * Math.PI * P / e);
|
|
17
|
-
t.lineTo(y, M)
|
|
6
|
+
var s = a + r * Math.cos(2 * Math.PI * 0 / e), P = l + r * Math.sin(2 * Math.PI * 0 / e);
|
|
7
|
+
t.moveTo(s, P);
|
|
8
|
+
for (var y = 1; y <= e; y++) {
|
|
9
|
+
var M = a + r * Math.cos(2 * Math.PI * y / e), d = l + r * Math.sin(2 * Math.PI * y / e);
|
|
10
|
+
t.lineTo(M, d);
|
|
18
11
|
}
|
|
19
|
-
t.closePath(), n && (t.strokeStyle = n, t.lineWidth = i, t.lineJoin = "round", t.stroke()),
|
|
12
|
+
t.closePath(), n && (t.strokeStyle = n, t.lineWidth = i, t.lineJoin = "round", t.stroke()),
|
|
13
|
+
h && (t.fillStyle = h, t.fill());
|
|
20
14
|
};
|
|
15
|
+
|
|
21
16
|
module.exports = {
|
|
22
17
|
drawPolygon: drawPolygon
|
|
23
|
-
};
|
|
18
|
+
};
|
package/lib/dom/downloadFile.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
|
|
3
|
+
var objectAssign = require("./../_object.assign"), createTags = function(t) {
|
|
4
|
+
return document.createElement(t);
|
|
5
|
+
};
|
|
6
|
+
|
|
6
7
|
module.exports = function(t) {
|
|
7
8
|
var e = objectAssign({}, {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
method: "post"
|
|
10
|
+
}, t), a = createTags("iframe");
|
|
11
|
+
a.setAttribute("id", "down-file-iframe");
|
|
12
|
+
var r = createTags("form");
|
|
13
|
+
for (var i in r.setAttribute("target", "down-file-iframe"), r.setAttribute("method", e.method),
|
|
14
|
+
r.setAttribute("action", e.url), e.data) if (Object.prototype.hasOwnProperty.call(e.data, i)) {
|
|
15
|
+
var o = createTags("input");
|
|
16
|
+
o.setAttribute("type", "hidden"), o.setAttribute("name", i), o.value = e.data[i],
|
|
17
|
+
r.appendChild(o);
|
|
18
|
+
}
|
|
19
|
+
a.appendChild(r), document.body.appendChild(a), r.submit(), a.remove();
|
|
20
|
+
};
|
package/lib/dom/eventHelper.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
2
3
|
module.exports = {
|
|
3
4
|
stopPropagation: function(e) {
|
|
4
|
-
(e = e || window.event).stopPropagation(), void 0 !== e.cancelBubble && (e.cancelBubble = !0)
|
|
5
|
+
(e = e || window.event).stopPropagation(), void 0 !== e.cancelBubble && (e.cancelBubble = !0);
|
|
5
6
|
},
|
|
6
7
|
preventDefault: function(e) {
|
|
7
|
-
e.preventDefault(), void 0 !== e.returnValue && (e.returnValue = !1)
|
|
8
|
+
e.preventDefault(), void 0 !== e.returnValue && (e.returnValue = !1);
|
|
8
9
|
},
|
|
9
10
|
stopEvent: function(e) {
|
|
10
|
-
(e = e || window.event).stopPropagation(), void 0 !== e.cancelBubble && (e.cancelBubble = !0),
|
|
11
|
+
(e = e || window.event).stopPropagation(), void 0 !== e.cancelBubble && (e.cancelBubble = !0),
|
|
12
|
+
e.preventDefault(), void 0 !== e.returnValue && (e.returnValue = !1);
|
|
11
13
|
},
|
|
12
14
|
addHandler: function(e, t, n) {
|
|
13
|
-
e.addEventListener ? e.addEventListener(t, n, !1) : e.attachEvent && e.attachEvent("on" + t, n)
|
|
15
|
+
e.addEventListener ? e.addEventListener(t, n, !1) : e.attachEvent && e.attachEvent("on" + t, n);
|
|
14
16
|
},
|
|
15
17
|
removeHandler: function(e, t, n) {
|
|
16
|
-
e.removeEventListener ? e.removeEventListener(t, n, !1) : e.detachEvent && e.detachEvent("on" + t, n)
|
|
18
|
+
e.removeEventListener ? e.removeEventListener(t, n, !1) : e.detachEvent && e.detachEvent("on" + t, n);
|
|
17
19
|
}
|
|
18
|
-
};
|
|
20
|
+
};
|