@vope/utils 1.6.0-bate.7 → 1.6.0-bate.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/dist/index.js +1243 -81
- package/package.json +1 -2
- package/sub_storage/offline.js +18 -16
- package/dist/clamp.js +0 -31
- package/dist/classnames.js +0 -37
- package/dist/compare/version.js +0 -35
- package/dist/compare/weak-equal.js +0 -53
- package/dist/convert/json.js +0 -27
- package/dist/convert/object.js +0 -27
- package/dist/convert/strings.js +0 -27
- package/dist/desens.js +0 -71
- package/dist/encoding.js +0 -76
- package/dist/input-regex.js +0 -28
- package/dist/is/class.js +0 -42
- package/dist/is/empty.js +0 -25
- package/dist/is/key.js +0 -24
- package/dist/is/null.js +0 -24
- package/dist/load/image.js +0 -31
- package/dist/memory/basic.js +0 -187
- package/dist/memory/list.js +0 -32
- package/dist/memory/power.js +0 -33
- package/dist/memory/simple.js +0 -114
- package/dist/neo4j-anchors.js +0 -189
- package/dist/neo4j.js +0 -181
- package/dist/once.js +0 -28
- package/dist/parse/num.js +0 -51
- package/dist/power/decon.js +0 -42
- package/dist/rotate/angle.js +0 -25
- package/dist/rotate/rad.js +0 -31
- package/dist/serialize/url-params.js +0 -73
- package/dist/style/css.js +0 -45
- package/dist/subscriber.js +0 -84
- package/dist/table/flex.js +0 -116
- package/dist/union.js +0 -67
- package/dist/url/join.js +0 -29
- package/dist/url/params.js +0 -28
- package/dist/wait.js +0 -24
package/package.json
CHANGED
package/sub_storage/offline.js
CHANGED
|
@@ -26,25 +26,27 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/storage/offline.ts
|
|
29
31
|
var offline_exports = {};
|
|
30
32
|
__export(offline_exports, {
|
|
31
33
|
OfflineStorage: () => OfflineStorage
|
|
32
34
|
});
|
|
33
35
|
module.exports = __toCommonJS(offline_exports);
|
|
34
|
-
var import_localforage = __toESM(require("localforage")
|
|
36
|
+
var import_localforage = __toESM(require("localforage"));
|
|
35
37
|
var import_lodash_es = require("lodash-es");
|
|
36
38
|
var import_sm_crypto = require("sm-crypto");
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
var NAME = "@vope/utils";
|
|
40
|
+
var PREFIX = NAME + "_";
|
|
41
|
+
var key = [25, 144, 1, 32, 25, 135, 6, 40, 32, 23, 18, 19, 32, 36, 9, 5];
|
|
42
|
+
var iv = [182, 59, 9, 29, 86, 64, 118, 111, 112, 101, 47, 117, 116, 105, 108, 115];
|
|
43
|
+
var config = {
|
|
42
44
|
output: "string",
|
|
43
45
|
mode: "cbc",
|
|
44
46
|
iv
|
|
45
47
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
var HEADER = "." + import_sm_crypto.sm4.encrypt(NAME, key, config);
|
|
49
|
+
var encrypt = (data) => {
|
|
48
50
|
let text = "";
|
|
49
51
|
for (const key2 in data) {
|
|
50
52
|
const value = data[key2];
|
|
@@ -54,7 +56,7 @@ const encrypt = (data) => {
|
|
|
54
56
|
}
|
|
55
57
|
return import_sm_crypto.sm4.encrypt(text, key, config);
|
|
56
58
|
};
|
|
57
|
-
|
|
59
|
+
var decrypt = (text) => {
|
|
58
60
|
const data = {};
|
|
59
61
|
let value;
|
|
60
62
|
try {
|
|
@@ -72,21 +74,21 @@ const decrypt = (text) => {
|
|
|
72
74
|
});
|
|
73
75
|
return data;
|
|
74
76
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
var structKey = (index) => index.toString(16).padStart(8, "0");
|
|
78
|
+
var reductKey = (key2) => parseInt(key2, 16);
|
|
79
|
+
var MESSAGES = {
|
|
78
80
|
mount: "Please wait for the mounting to complete",
|
|
79
81
|
auth: "Unauthorized operation",
|
|
80
82
|
push: "Cannot add data to expired databases",
|
|
81
83
|
update: "Cannot update data to expired databases",
|
|
82
84
|
get: "Cannot get data from expired databases"
|
|
83
85
|
};
|
|
84
|
-
|
|
86
|
+
var createInstance = (name, version = 2) => import_localforage.default.createInstance({
|
|
85
87
|
driver: import_localforage.default.INDEXEDDB,
|
|
86
88
|
name,
|
|
87
89
|
version
|
|
88
90
|
});
|
|
89
|
-
|
|
91
|
+
var OfflineStorage = class _OfflineStorage {
|
|
90
92
|
#forage;
|
|
91
93
|
#expire;
|
|
92
94
|
#auth = false;
|
|
@@ -214,7 +216,7 @@ class OfflineStorage {
|
|
|
214
216
|
}
|
|
215
217
|
static default(options) {
|
|
216
218
|
(0, import_lodash_es.isString)(options) && (options = { name: options });
|
|
217
|
-
return new
|
|
219
|
+
return new _OfflineStorage({
|
|
218
220
|
...options,
|
|
219
221
|
crypto: {
|
|
220
222
|
encrypt(plain) {
|
|
@@ -250,4 +252,4 @@ class OfflineStorage {
|
|
|
250
252
|
}
|
|
251
253
|
await Promise.all(tasks);
|
|
252
254
|
}
|
|
253
|
-
}
|
|
255
|
+
};
|
package/dist/clamp.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var clamp_exports = {};
|
|
20
|
-
__export(clamp_exports, {
|
|
21
|
-
clamp: () => clamp
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(clamp_exports);
|
|
24
|
-
const clamp = (value, min, max) => {
|
|
25
|
-
if (min > max) {
|
|
26
|
-
const swap = max;
|
|
27
|
-
max = min;
|
|
28
|
-
min = swap;
|
|
29
|
-
}
|
|
30
|
-
return Math.min(max, Math.max(min, value));
|
|
31
|
-
};
|
package/dist/classnames.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var classnames_exports = {};
|
|
20
|
-
__export(classnames_exports, {
|
|
21
|
-
classnames: () => classnames
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(classnames_exports);
|
|
24
|
-
var import_lodash_es = require("lodash-es");
|
|
25
|
-
const add = (a, b) => a ? a + " " + b : b;
|
|
26
|
-
const classnames = (...list) => list.reduce((caches, data) => {
|
|
27
|
-
if ((0, import_lodash_es.isString)(data)) {
|
|
28
|
-
data && (caches = add(caches, data));
|
|
29
|
-
} else if (Array.isArray(data)) {
|
|
30
|
-
data.forEach((value) => value && (0, import_lodash_es.isString)(value) && (caches = add(caches, value)));
|
|
31
|
-
} else if (!(0, import_lodash_es.isBoolean)(data)) {
|
|
32
|
-
for (const key in data) {
|
|
33
|
-
key && data[key] && (caches = add(caches, key));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return caches;
|
|
37
|
-
}, "");
|
package/dist/compare/version.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var version_exports = {};
|
|
20
|
-
__export(version_exports, {
|
|
21
|
-
compareVersion: () => compareVersion
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(version_exports);
|
|
24
|
-
const CHAR = ".";
|
|
25
|
-
const compareVersion = (from, to) => {
|
|
26
|
-
const froms = from.split(CHAR);
|
|
27
|
-
const tos = to.split(CHAR);
|
|
28
|
-
for (let i = 0, max = Math.max(froms.length, tos.length); i < max; i++) {
|
|
29
|
-
const fromV = +froms[i] || 0;
|
|
30
|
-
const toV = +tos[i] || 0;
|
|
31
|
-
if (fromV > toV) return -1;
|
|
32
|
-
if (fromV < toV) return 1;
|
|
33
|
-
}
|
|
34
|
-
return 0;
|
|
35
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var weak_equal_exports = {};
|
|
20
|
-
__export(weak_equal_exports, {
|
|
21
|
-
deepWeakEqual: () => deepWeakEqual
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(weak_equal_exports);
|
|
24
|
-
var import_strings = require("../convert/strings");
|
|
25
|
-
const deepWeakEqual = (from, to, exclude) => {
|
|
26
|
-
if (typeof from !== "object" || from === null || typeof to !== "object" || to === null) return from === to;
|
|
27
|
-
if (Array.isArray(from) && Array.isArray(to)) {
|
|
28
|
-
if (from.length !== to.length) return false;
|
|
29
|
-
return !from.some((t1, index) => {
|
|
30
|
-
if (!deepWeakEqual(t1, to[index])) {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
} else {
|
|
35
|
-
const caches = {};
|
|
36
|
-
const excludeCaches = exclude && (0, import_strings.hash8strings)(exclude);
|
|
37
|
-
for (const key in from) {
|
|
38
|
-
if (excludeCaches && key in excludeCaches) continue;
|
|
39
|
-
if (!deepWeakEqual(from[key], to[key])) {
|
|
40
|
-
return false;
|
|
41
|
-
} else {
|
|
42
|
-
caches[key] = key;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
for (const key in to) {
|
|
46
|
-
if (excludeCaches && key in excludeCaches || key in caches) continue;
|
|
47
|
-
if (!deepWeakEqual(from[key], to[key])) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return true;
|
|
53
|
-
};
|
package/dist/convert/json.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var json_exports = {};
|
|
20
|
-
__export(json_exports, {
|
|
21
|
-
hash8json: () => hash8json
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(json_exports);
|
|
24
|
-
const hash8json = (list, key) => list.reduce((caches, data) => {
|
|
25
|
-
caches[data[key]] = data;
|
|
26
|
-
return caches;
|
|
27
|
-
}, {});
|
package/dist/convert/object.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var object_exports = {};
|
|
20
|
-
__export(object_exports, {
|
|
21
|
-
hash8object: () => hash8object
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(object_exports);
|
|
24
|
-
const hash8object = (list, key) => list.reduce((caches, data) => {
|
|
25
|
-
caches.set(data[key], data);
|
|
26
|
-
return caches;
|
|
27
|
-
}, /* @__PURE__ */ new Map());
|
package/dist/convert/strings.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var strings_exports = {};
|
|
20
|
-
__export(strings_exports, {
|
|
21
|
-
hash8strings: () => hash8strings
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(strings_exports);
|
|
24
|
-
const hash8strings = (list) => list.reduce((caches, data, index) => {
|
|
25
|
-
caches[data] = index;
|
|
26
|
-
return caches;
|
|
27
|
-
}, {});
|
package/dist/desens.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var desens_exports = {};
|
|
20
|
-
__export(desens_exports, {
|
|
21
|
-
desensDecrypt: () => desensDecrypt,
|
|
22
|
-
desensEncrypt: () => desensEncrypt,
|
|
23
|
-
desensReplace: () => desensReplace
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(desens_exports);
|
|
26
|
-
var import_lodash_es = require("lodash-es");
|
|
27
|
-
const desensEncrypt = (plaintext, encrypt) => {
|
|
28
|
-
const rules = [];
|
|
29
|
-
let point = -1;
|
|
30
|
-
let ciphertext = encrypt(plaintext).reduce((cache, { range, ciphertext: ciphertext2 }) => {
|
|
31
|
-
cache += plaintext.slice(point + 1, range[0]) + ciphertext2;
|
|
32
|
-
point = range[1];
|
|
33
|
-
rules.push({
|
|
34
|
-
range,
|
|
35
|
-
modify: ciphertext2.length
|
|
36
|
-
});
|
|
37
|
-
return cache;
|
|
38
|
-
}, "");
|
|
39
|
-
if (point !== -1) {
|
|
40
|
-
ciphertext += plaintext.slice(point + 1);
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
ciphertext,
|
|
44
|
-
rules
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
const desensDecrypt = (ciphertext, rules, decrypt) => {
|
|
48
|
-
Array.isArray(rules) || (rules = [rules]);
|
|
49
|
-
let offset = 0;
|
|
50
|
-
let from = 0;
|
|
51
|
-
return rules.reduce((cache, { range: [start, stop], modify }) => {
|
|
52
|
-
cache += ciphertext.slice(from, start + offset) + decrypt(ciphertext.slice(start + offset, start + offset + modify));
|
|
53
|
-
from = start + offset + modify;
|
|
54
|
-
offset += modify - (stop + 1 - start);
|
|
55
|
-
return cache;
|
|
56
|
-
}, "") + ciphertext.slice(from);
|
|
57
|
-
};
|
|
58
|
-
const desensReplace = (ciphertext, rules, replacer = "*") => {
|
|
59
|
-
Array.isArray(rules) || (rules = [rules]);
|
|
60
|
-
let offset = 0;
|
|
61
|
-
let from = 0;
|
|
62
|
-
return rules.reduce((cache, { range: [start, stop], modify }) => {
|
|
63
|
-
const part = ciphertext.slice(start + offset, start + offset + modify);
|
|
64
|
-
const size = stop + 1 - start;
|
|
65
|
-
const replaceValue = (0, import_lodash_es.isString)(replacer) ? replacer.repeat(size) : replacer[Symbol.replace](part, size);
|
|
66
|
-
cache += ciphertext.slice(from, start + offset) + replaceValue;
|
|
67
|
-
from = start + offset + modify;
|
|
68
|
-
offset += modify - size;
|
|
69
|
-
return cache;
|
|
70
|
-
}, "") + ciphertext.slice(from);
|
|
71
|
-
};
|
package/dist/encoding.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var encoding_exports = {};
|
|
20
|
-
__export(encoding_exports, {
|
|
21
|
-
getEncoding: () => getEncoding
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(encoding_exports);
|
|
24
|
-
const utf8_first_prefix = /^1{2,}/g;
|
|
25
|
-
const utf8_other_prefix = /^10/;
|
|
26
|
-
const Encodes = {
|
|
27
|
-
UTF_8: "utf-8",
|
|
28
|
-
UTF_16LE: "utf-16le",
|
|
29
|
-
UTF_16BE: "utf-16be",
|
|
30
|
-
GBK: "gbk"
|
|
31
|
-
};
|
|
32
|
-
const BOM = {
|
|
33
|
-
UTF_8: [239, 187, 191],
|
|
34
|
-
UTF_16LE: [255, 254],
|
|
35
|
-
UTF_16BE: [254, 255]
|
|
36
|
-
};
|
|
37
|
-
const equal = (uint, list) => {
|
|
38
|
-
return uint.length === list.length ? !uint.some((value, index) => value !== list[index]) : false;
|
|
39
|
-
};
|
|
40
|
-
const getEncoding = (uint, limit = 1024) => {
|
|
41
|
-
let encoding;
|
|
42
|
-
let offset = 0;
|
|
43
|
-
for (const key in BOM) {
|
|
44
|
-
const head = BOM[key];
|
|
45
|
-
if (equal(uint.slice(0, head.length), head)) {
|
|
46
|
-
offset = head.length;
|
|
47
|
-
encoding = Encodes[key];
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (!encoding) {
|
|
52
|
-
let isBreak = false;
|
|
53
|
-
top:
|
|
54
|
-
for (let i = 0, max = Math.min(uint.length, limit); i < max; i++) {
|
|
55
|
-
const data = uint[i];
|
|
56
|
-
if (data < 128) continue;
|
|
57
|
-
const match = data.toString(2).match(utf8_first_prefix);
|
|
58
|
-
if (match) {
|
|
59
|
-
for (let m = 0; m < match[0].length - 1; m++) {
|
|
60
|
-
const target = uint[++i];
|
|
61
|
-
if (target == void 0 || !utf8_other_prefix.test(target.toString(2))) {
|
|
62
|
-
encoding = Encodes.GBK;
|
|
63
|
-
isBreak = true;
|
|
64
|
-
break top;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
} else {
|
|
68
|
-
encoding = Encodes.GBK;
|
|
69
|
-
isBreak = true;
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
isBreak || (encoding = Encodes.UTF_8);
|
|
74
|
-
}
|
|
75
|
-
return { encoding, offset };
|
|
76
|
-
};
|
package/dist/input-regex.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var input_regex_exports = {};
|
|
20
|
-
__export(input_regex_exports, {
|
|
21
|
-
inputRegex: () => inputRegex
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(input_regex_exports);
|
|
24
|
-
const RE_REGEX = /[$()*+.[?\\^{|]/g;
|
|
25
|
-
const RE_STRING = /[$()*+.[?\\^{|-]/g;
|
|
26
|
-
function inputRegex(text, flags) {
|
|
27
|
-
return flags === false ? text.replace(RE_STRING, ($0) => "\\" + $0) : new RegExp(text.replace(RE_REGEX, ($0) => "\\" + $0), flags);
|
|
28
|
-
}
|
package/dist/is/class.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var class_exports = {};
|
|
20
|
-
__export(class_exports, {
|
|
21
|
-
isClass: () => isClass
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(class_exports);
|
|
24
|
-
const re_anonymous = /^function\s+\(|^function\s+anonymous\(/;
|
|
25
|
-
const re_function = /^function\s+[A-Z]/;
|
|
26
|
-
const re_this = /\b\(this\b|\bthis[\.\[]\b/;
|
|
27
|
-
const re_check = /classCallCheck\(this/;
|
|
28
|
-
const re_default = /^function\sdefault_\d+\s*\(/;
|
|
29
|
-
const isClass = (value, strict = true) => {
|
|
30
|
-
if (typeof value !== "function") return false;
|
|
31
|
-
const proto = value.prototype;
|
|
32
|
-
if (!proto || proto.constructor !== value) return false;
|
|
33
|
-
const str = value.toString();
|
|
34
|
-
if (str.slice(0, 5) === "class" || Object.getOwnPropertyNames(proto).length >= 2) return true;
|
|
35
|
-
if (re_anonymous.test(str)) return false;
|
|
36
|
-
if (strict && re_function.test(str)) return true;
|
|
37
|
-
if (re_this.test(str)) {
|
|
38
|
-
if (!strict || re_check.test(str)) return true;
|
|
39
|
-
return re_default.test(str);
|
|
40
|
-
}
|
|
41
|
-
return false;
|
|
42
|
-
};
|
package/dist/is/empty.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var empty_exports = {};
|
|
20
|
-
__export(empty_exports, {
|
|
21
|
-
isEmpty: () => isEmpty
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(empty_exports);
|
|
24
|
-
var import_null = require("./null");
|
|
25
|
-
const isEmpty = (value) => (0, import_null.isNull)(value) || value === "";
|
package/dist/is/key.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var key_exports = {};
|
|
20
|
-
__export(key_exports, {
|
|
21
|
-
isKey: () => isKey
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(key_exports);
|
|
24
|
-
const isKey = (key, data) => key in data;
|
package/dist/is/null.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var null_exports = {};
|
|
20
|
-
__export(null_exports, {
|
|
21
|
-
isNull: () => isNull
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(null_exports);
|
|
24
|
-
const isNull = (value) => value === void 0 || value === null;
|
package/dist/load/image.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var image_exports = {};
|
|
20
|
-
__export(image_exports, {
|
|
21
|
-
loadImage: () => loadImage
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(image_exports);
|
|
24
|
-
const loadImage = (src) => {
|
|
25
|
-
return new Promise((resolve) => {
|
|
26
|
-
const img = new Image();
|
|
27
|
-
img.onload = () => resolve(img);
|
|
28
|
-
img.onerror = () => resolve(null);
|
|
29
|
-
img.src = src;
|
|
30
|
-
});
|
|
31
|
-
};
|