light-h5-core-lib 2.10.5 → 2.10.7
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/LightCore.js +27 -21
- package/common/base/BaseSingleton.js +7 -8
- package/common/base/SetterGetterBase.js +23 -26
- package/common/md5/MD5.js +67 -89
- package/common/util/BeizerUtil.js +47 -51
- package/common/util/BitUtil.js +9 -12
- package/common/util/BooleanUtil.js +4 -8
- package/common/util/ClassNameUtil.js +6 -10
- package/common/util/CollisionDetectionUtil.js +119 -161
- package/common/util/Crc32Util.js +10 -15
- package/common/util/DateUtil.js +26 -40
- package/common/util/FloatDigitUtil.js +14 -20
- package/common/util/GetDecorateUtils.js +70 -0
- package/common/util/MapUtil.js +28 -0
- package/common/util/NumberUtil.js +4 -8
- package/common/util/PromiseUtil.js +49 -64
- package/common/util/RandomNumUtil.js +21 -28
- package/common/util/SelfDecrypt.js +19 -22
- package/common/util/StringUtil.js +52 -65
- package/common/util/UniqueIDUtil.js +7 -10
- package/package.json +18 -18
- package/pool/PoolObj.js +54 -79
- package/type/index.d.ts +58 -5
package/LightCore.js
CHANGED
|
@@ -3,43 +3,47 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CollisionDetectionUtil = exports.SelfDecrypt = exports.NumberUtil = exports.BooleanUtil = exports.Crc32Util = exports.PromiseUtil = exports.BeizerUtil = exports.UniqueIDUtil = exports.StringUtil = exports.RandomNumUtil = exports.FloatDigitUtil = exports.DateUtil = exports.BitUtil = exports.MD5 = exports.BaseSingleton = exports.SetterGetterBase = exports.ClassNameUtil = exports.PoolObj = void 0;
|
|
7
|
-
|
|
6
|
+
exports.MapUtil = exports.CollisionDetectionUtil = exports.SelfDecrypt = exports.GetDecorateUtils = exports.NumberUtil = exports.BooleanUtil = exports.Crc32Util = exports.PromiseUtil = exports.BeizerUtil = exports.UniqueIDUtil = exports.StringUtil = exports.RandomNumUtil = exports.FloatDigitUtil = exports.DateUtil = exports.BitUtil = exports.MD5 = exports.BaseSingleton = exports.SetterGetterBase = exports.ClassNameUtil = exports.PoolObj = void 0;
|
|
7
|
+
const PoolObj_1 = require("./pool/PoolObj");
|
|
8
8
|
Object.defineProperty(exports, "PoolObj", { enumerable: true, get: function () { return PoolObj_1.PoolObj; } });
|
|
9
|
-
|
|
9
|
+
const BaseSingleton_1 = require("./common/base/BaseSingleton");
|
|
10
10
|
Object.defineProperty(exports, "BaseSingleton", { enumerable: true, get: function () { return BaseSingleton_1.BaseSingleton; } });
|
|
11
|
-
|
|
11
|
+
const BitUtil_1 = require("./common/util/BitUtil");
|
|
12
12
|
Object.defineProperty(exports, "BitUtil", { enumerable: true, get: function () { return BitUtil_1.BitUtil; } });
|
|
13
|
-
|
|
13
|
+
const DateUtil_1 = require("./common/util/DateUtil");
|
|
14
14
|
Object.defineProperty(exports, "DateUtil", { enumerable: true, get: function () { return DateUtil_1.DateUtil; } });
|
|
15
|
-
|
|
15
|
+
const FloatDigitUtil_1 = require("./common/util/FloatDigitUtil");
|
|
16
16
|
Object.defineProperty(exports, "FloatDigitUtil", { enumerable: true, get: function () { return FloatDigitUtil_1.FloatDigitUtil; } });
|
|
17
|
-
|
|
17
|
+
const RandomNumUtil_1 = require("./common/util/RandomNumUtil");
|
|
18
18
|
Object.defineProperty(exports, "RandomNumUtil", { enumerable: true, get: function () { return RandomNumUtil_1.RandomNumUtil; } });
|
|
19
|
-
|
|
19
|
+
const StringUtil_1 = require("./common/util/StringUtil");
|
|
20
20
|
Object.defineProperty(exports, "StringUtil", { enumerable: true, get: function () { return StringUtil_1.StringUtil; } });
|
|
21
|
-
|
|
21
|
+
const UniqueIDUtil_1 = require("./common/util/UniqueIDUtil");
|
|
22
22
|
Object.defineProperty(exports, "UniqueIDUtil", { enumerable: true, get: function () { return UniqueIDUtil_1.UniqueIDUtil; } });
|
|
23
|
-
|
|
23
|
+
const BeizerUtil_1 = require("./common/util/BeizerUtil");
|
|
24
24
|
Object.defineProperty(exports, "BeizerUtil", { enumerable: true, get: function () { return BeizerUtil_1.BeizerUtil; } });
|
|
25
|
-
|
|
25
|
+
const MD5_1 = require("./common/md5/MD5");
|
|
26
26
|
Object.defineProperty(exports, "MD5", { enumerable: true, get: function () { return MD5_1.MD5; } });
|
|
27
|
-
|
|
28
|
-
exports
|
|
29
|
-
|
|
27
|
+
const PromiseUtil_1 = require("./common/util/PromiseUtil");
|
|
28
|
+
Object.defineProperty(exports, "PromiseUtil", { enumerable: true, get: function () { return PromiseUtil_1.PromiseUtil; } });
|
|
29
|
+
const Crc32Util_1 = __importDefault(require("./common/util/Crc32Util"));
|
|
30
30
|
exports.Crc32Util = Crc32Util_1.default;
|
|
31
|
-
|
|
31
|
+
const BooleanUtil_1 = require("./common/util/BooleanUtil");
|
|
32
32
|
Object.defineProperty(exports, "BooleanUtil", { enumerable: true, get: function () { return BooleanUtil_1.BooleanUtil; } });
|
|
33
|
-
|
|
33
|
+
const NumberUtil_1 = require("./common/util/NumberUtil");
|
|
34
34
|
Object.defineProperty(exports, "NumberUtil", { enumerable: true, get: function () { return NumberUtil_1.NumberUtil; } });
|
|
35
|
-
|
|
35
|
+
const SelfDecrypt_1 = require("./common/util/SelfDecrypt");
|
|
36
36
|
Object.defineProperty(exports, "SelfDecrypt", { enumerable: true, get: function () { return SelfDecrypt_1.SelfDecrypt; } });
|
|
37
|
-
|
|
37
|
+
const CollisionDetectionUtil_1 = require("./common/util/CollisionDetectionUtil");
|
|
38
38
|
Object.defineProperty(exports, "CollisionDetectionUtil", { enumerable: true, get: function () { return CollisionDetectionUtil_1.CollisionDetectionUtil; } });
|
|
39
|
-
|
|
39
|
+
const ClassNameUtil_1 = require("./common/util/ClassNameUtil");
|
|
40
40
|
Object.defineProperty(exports, "ClassNameUtil", { enumerable: true, get: function () { return ClassNameUtil_1.ClassNameUtil; } });
|
|
41
|
-
|
|
41
|
+
const SetterGetterBase_1 = require("./common/base/SetterGetterBase");
|
|
42
42
|
Object.defineProperty(exports, "SetterGetterBase", { enumerable: true, get: function () { return SetterGetterBase_1.SetterGetterBase; } });
|
|
43
|
+
const GetDecorateUtils_1 = require("./common/util/GetDecorateUtils");
|
|
44
|
+
Object.defineProperty(exports, "GetDecorateUtils", { enumerable: true, get: function () { return GetDecorateUtils_1.GetDecorateUtils; } });
|
|
45
|
+
const MapUtil_1 = require("./common/util/MapUtil");
|
|
46
|
+
Object.defineProperty(exports, "MapUtil", { enumerable: true, get: function () { return MapUtil_1.MapUtil; } });
|
|
43
47
|
module.exports = {
|
|
44
48
|
PoolObj: PoolObj_1.PoolObj,
|
|
45
49
|
ClassNameUtil: ClassNameUtil_1.ClassNameUtil,
|
|
@@ -53,10 +57,12 @@ module.exports = {
|
|
|
53
57
|
StringUtil: StringUtil_1.StringUtil,
|
|
54
58
|
UniqueIDUtil: UniqueIDUtil_1.UniqueIDUtil,
|
|
55
59
|
BeizerUtil: BeizerUtil_1.BeizerUtil,
|
|
56
|
-
PromiseUtil: PromiseUtil_1.
|
|
60
|
+
PromiseUtil: PromiseUtil_1.PromiseUtil,
|
|
57
61
|
Crc32Util: Crc32Util_1.default,
|
|
58
62
|
BooleanUtil: BooleanUtil_1.BooleanUtil,
|
|
59
63
|
NumberUtil: NumberUtil_1.NumberUtil,
|
|
64
|
+
GetDecorateUtils: GetDecorateUtils_1.GetDecorateUtils,
|
|
60
65
|
SelfDecrypt: SelfDecrypt_1.SelfDecrypt,
|
|
61
66
|
CollisionDetectionUtil: CollisionDetectionUtil_1.CollisionDetectionUtil,
|
|
67
|
+
MapUtil: MapUtil_1.MapUtil,
|
|
62
68
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseSingleton = void 0;
|
|
4
|
-
|
|
4
|
+
const ClassNameUtil_1 = require("../util/ClassNameUtil");
|
|
5
5
|
/**
|
|
6
6
|
* 单例基类(简单非泛型)
|
|
7
7
|
* @description
|
|
@@ -11,17 +11,16 @@ var ClassNameUtil_1 = require("../util/ClassNameUtil");
|
|
|
11
11
|
* ③,ctor相当于构造函数,只在new时执行一次
|
|
12
12
|
* @author Aonaufly
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
class BaseSingleton {
|
|
15
|
+
constructor() {
|
|
16
16
|
if (BaseSingleton._instance) {
|
|
17
|
-
|
|
18
|
-
throw new Error(
|
|
17
|
+
const constructorName = ClassNameUtil_1.ClassNameUtil.getClassName(this);
|
|
18
|
+
throw new Error(`${constructorName} is a singleton class, can't create new instance`);
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
21
|
this.ctor();
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
return BaseSingleton;
|
|
26
|
-
}());
|
|
24
|
+
}
|
|
27
25
|
exports.BaseSingleton = BaseSingleton;
|
|
26
|
+
BaseSingleton._instance = null;
|
|
@@ -5,28 +5,27 @@ exports.SetterGetterBase = void 0;
|
|
|
5
5
|
* setter/getter基类
|
|
6
6
|
* @author Aonaufly
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
class SetterGetterBase {
|
|
9
|
+
constructor() {
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
isNeedCheckChanged(publicName) {
|
|
12
12
|
if (!this.ignoreCheckChangedFields || this.ignoreCheckChangedFields.length == 0) {
|
|
13
13
|
return true;
|
|
14
14
|
}
|
|
15
15
|
return !this.ignoreCheckChangedFields.includes(publicName);
|
|
16
|
-
}
|
|
16
|
+
}
|
|
17
17
|
/**
|
|
18
18
|
* 扫描实例属性并自动创建访问器
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
for (
|
|
25
|
-
var propName = instanceProps_1[_i];
|
|
20
|
+
installAccessors() {
|
|
21
|
+
const proto = Object.getPrototypeOf(this);
|
|
22
|
+
const instanceProps = this.getEnumerableProperties(this);
|
|
23
|
+
const ignoreFieldArr = this.ignoreFields;
|
|
24
|
+
for (const propName of instanceProps) {
|
|
26
25
|
// 只处理以下划线开头的私有/受保护字段
|
|
27
26
|
if (!propName.startsWith('_'))
|
|
28
27
|
continue;
|
|
29
|
-
|
|
28
|
+
const publicName = propName.slice(1);
|
|
30
29
|
if (!publicName)
|
|
31
30
|
continue;
|
|
32
31
|
if (ignoreFieldArr != null && ignoreFieldArr.length > 0) {
|
|
@@ -35,7 +34,7 @@ var SetterGetterBase = /** @class */ (function () {
|
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
36
|
// 检查原型上是否已存在对应访问器
|
|
38
|
-
|
|
37
|
+
const descriptor = Object.getOwnPropertyDescriptor(proto, publicName);
|
|
39
38
|
// 如果完全不存在,则创建 getter/setter
|
|
40
39
|
if (!descriptor) {
|
|
41
40
|
this.createAccessor(proto, propName, publicName);
|
|
@@ -46,38 +45,36 @@ var SetterGetterBase = /** @class */ (function () {
|
|
|
46
45
|
this.createAccessor(proto, propName, publicName);
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
|
-
}
|
|
48
|
+
}
|
|
50
49
|
/**
|
|
51
50
|
* 安全获取对象的可枚举属性(排除方法)
|
|
52
51
|
*/
|
|
53
|
-
|
|
54
|
-
return Object.getOwnPropertyNames(obj).filter(
|
|
55
|
-
|
|
52
|
+
getEnumerableProperties(obj) {
|
|
53
|
+
return Object.getOwnPropertyNames(obj).filter(name => {
|
|
54
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, name);
|
|
56
55
|
return descriptor && !descriptor.get && !descriptor.set && typeof descriptor.value !== 'function';
|
|
57
56
|
});
|
|
58
|
-
}
|
|
57
|
+
}
|
|
59
58
|
/**
|
|
60
59
|
* 在原型上动态创建访问器
|
|
61
60
|
*/
|
|
62
|
-
|
|
61
|
+
createAccessor(proto, privateName, publicName) {
|
|
63
62
|
Object.defineProperty(proto, publicName, {
|
|
64
|
-
get
|
|
63
|
+
get() {
|
|
65
64
|
return this[privateName];
|
|
66
65
|
},
|
|
67
|
-
set
|
|
68
|
-
|
|
69
|
-
var oldValue = this[privateName];
|
|
66
|
+
set(value) {
|
|
67
|
+
const oldValue = this[privateName];
|
|
70
68
|
if (oldValue === value)
|
|
71
69
|
return;
|
|
72
70
|
this[privateName] = value;
|
|
73
71
|
if (this.isNeedCheckChanged(publicName)) {
|
|
74
|
-
|
|
72
|
+
this.onPropertyChanged?.(publicName, value, oldValue);
|
|
75
73
|
}
|
|
76
74
|
},
|
|
77
75
|
enumerable: true,
|
|
78
76
|
configurable: true,
|
|
79
77
|
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
}());
|
|
78
|
+
}
|
|
79
|
+
}
|
|
83
80
|
exports.SetterGetterBase = SetterGetterBase;
|
package/common/md5/MD5.js
CHANGED
|
@@ -1,84 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.MD5 = void 0;
|
|
19
|
-
|
|
4
|
+
const BaseSingleton_1 = require("../base/BaseSingleton");
|
|
20
5
|
/**
|
|
21
6
|
* MD5单例
|
|
22
7
|
* @author Aonaufly
|
|
23
8
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
9
|
+
class MD5 extends BaseSingleton_1.BaseSingleton {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
|
|
13
|
+
this.b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
|
|
14
|
+
}
|
|
15
|
+
ctor() {
|
|
16
|
+
}
|
|
17
|
+
static get install() {
|
|
18
|
+
if (!MD5._instance) {
|
|
19
|
+
MD5._instance = new MD5();
|
|
20
|
+
}
|
|
21
|
+
return MD5._instance;
|
|
31
22
|
}
|
|
32
|
-
MD5.prototype.ctor = function () {
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(MD5, "install", {
|
|
35
|
-
get: function () {
|
|
36
|
-
if (!MD5._instance) {
|
|
37
|
-
MD5._instance = new MD5();
|
|
38
|
-
}
|
|
39
|
-
return MD5._instance;
|
|
40
|
-
},
|
|
41
|
-
enumerable: false,
|
|
42
|
-
configurable: true
|
|
43
|
-
});
|
|
44
23
|
/*
|
|
45
24
|
* These are the privates you'll usually want to call
|
|
46
25
|
* They take string arguments and return either hex or base-64 encoded strings
|
|
47
26
|
*/
|
|
48
|
-
|
|
27
|
+
hex_md5(s) {
|
|
49
28
|
return this.rstr2hex(this.rstr_md5(this.str2rstr_utf8(s)));
|
|
50
|
-
}
|
|
51
|
-
|
|
29
|
+
} //这个函数就行了,
|
|
30
|
+
b64_md5(s) {
|
|
52
31
|
return this.rstr2b64(this.rstr_md5(this.str2rstr_utf8(s)));
|
|
53
|
-
}
|
|
54
|
-
|
|
32
|
+
}
|
|
33
|
+
any_md5(s, e) {
|
|
55
34
|
return this.rstr2any(this.rstr_md5(this.str2rstr_utf8(s)), e);
|
|
56
|
-
}
|
|
57
|
-
|
|
35
|
+
}
|
|
36
|
+
hex_hmac_md5(k, d) {
|
|
58
37
|
return this.rstr2hex(this.rstr_hmac_md5(this.str2rstr_utf8(k), this.str2rstr_utf8(d)));
|
|
59
|
-
}
|
|
60
|
-
|
|
38
|
+
}
|
|
39
|
+
b64_hmac_md5(k, d) {
|
|
61
40
|
return this.rstr2b64(this.rstr_hmac_md5(this.str2rstr_utf8(k), this.str2rstr_utf8(d)));
|
|
62
|
-
}
|
|
63
|
-
|
|
41
|
+
}
|
|
42
|
+
any_hmac_md5(k, d, e) {
|
|
64
43
|
return this.rstr2any(this.rstr_hmac_md5(this.str2rstr_utf8(k), this.str2rstr_utf8(d)), e);
|
|
65
|
-
}
|
|
44
|
+
}
|
|
66
45
|
/*
|
|
67
46
|
* Perform a simple self-test to see if the VM is working
|
|
68
47
|
*/
|
|
69
|
-
|
|
48
|
+
md5_vm_test() {
|
|
70
49
|
return this.hex_md5("abc").toLowerCase() == "900150983cd24fb0d6963f7d28e17f72";
|
|
71
|
-
}
|
|
50
|
+
}
|
|
72
51
|
/*
|
|
73
52
|
* Calculate the MD5 of a raw string
|
|
74
53
|
*/
|
|
75
|
-
|
|
54
|
+
rstr_md5(s) {
|
|
76
55
|
return this.binl2rstr(this.binl_md5(this.rstr2binl(s), s.length * 8));
|
|
77
|
-
}
|
|
56
|
+
}
|
|
78
57
|
/*
|
|
79
58
|
* Calculate the HMAC-MD5, of a key and some data (raw strings)
|
|
80
59
|
*/
|
|
81
|
-
|
|
60
|
+
rstr_hmac_md5(key, data) {
|
|
82
61
|
var bkey = this.rstr2binl(key);
|
|
83
62
|
if (bkey.length > 16)
|
|
84
63
|
bkey = this.binl_md5(bkey, key.length * 8);
|
|
@@ -89,11 +68,11 @@ var MD5 = /** @class */ (function (_super) {
|
|
|
89
68
|
}
|
|
90
69
|
var hash = this.binl_md5(ipad.concat(this.rstr2binl(data)), 512 + data.length * 8);
|
|
91
70
|
return this.binl2rstr(this.binl_md5(opad.concat(hash), 512 + 128));
|
|
92
|
-
}
|
|
71
|
+
}
|
|
93
72
|
/*
|
|
94
73
|
* Convert a raw string to a hex string
|
|
95
74
|
*/
|
|
96
|
-
|
|
75
|
+
rstr2hex(input) {
|
|
97
76
|
try {
|
|
98
77
|
this.hexcase;
|
|
99
78
|
}
|
|
@@ -108,11 +87,11 @@ var MD5 = /** @class */ (function (_super) {
|
|
|
108
87
|
output += hex_tab.charAt((x >>> 4) & 0x0f) + hex_tab.charAt(x & 0x0f);
|
|
109
88
|
}
|
|
110
89
|
return output;
|
|
111
|
-
}
|
|
90
|
+
}
|
|
112
91
|
/*
|
|
113
92
|
* Convert a raw string to a base-64 string
|
|
114
93
|
*/
|
|
115
|
-
|
|
94
|
+
rstr2b64(input) {
|
|
116
95
|
try {
|
|
117
96
|
this.b64pad;
|
|
118
97
|
}
|
|
@@ -134,11 +113,11 @@ var MD5 = /** @class */ (function (_super) {
|
|
|
134
113
|
}
|
|
135
114
|
}
|
|
136
115
|
return output;
|
|
137
|
-
}
|
|
116
|
+
}
|
|
138
117
|
/*
|
|
139
118
|
* Convert a raw string to an arbitrary string encoding
|
|
140
119
|
*/
|
|
141
|
-
|
|
120
|
+
rstr2any(input, encoding) {
|
|
142
121
|
var divisor = encoding.length;
|
|
143
122
|
var i, j, q, x, quotient;
|
|
144
123
|
/* Convert to an array of 16-bit big-endian values, forming the dividend */
|
|
@@ -172,12 +151,12 @@ var MD5 = /** @class */ (function (_super) {
|
|
|
172
151
|
for (i = remainders.length - 1; i >= 0; i--)
|
|
173
152
|
output += encoding.charAt(remainders[i]);
|
|
174
153
|
return output;
|
|
175
|
-
}
|
|
154
|
+
}
|
|
176
155
|
/*
|
|
177
156
|
* Encode a string as utf-8.
|
|
178
157
|
* For efficiency, this assumes the input is valid utf-16.
|
|
179
158
|
*/
|
|
180
|
-
|
|
159
|
+
str2rstr_utf8(input) {
|
|
181
160
|
var output = "";
|
|
182
161
|
var i = -1;
|
|
183
162
|
var x, y;
|
|
@@ -200,47 +179,47 @@ var MD5 = /** @class */ (function (_super) {
|
|
|
200
179
|
output += String.fromCharCode(0xf0 | ((x >>> 18) & 0x07), 0x80 | ((x >>> 12) & 0x3f), 0x80 | ((x >>> 6) & 0x3f), 0x80 | (x & 0x3f));
|
|
201
180
|
}
|
|
202
181
|
return output;
|
|
203
|
-
}
|
|
182
|
+
}
|
|
204
183
|
/*
|
|
205
184
|
* Encode a string as utf-16
|
|
206
185
|
*/
|
|
207
|
-
|
|
186
|
+
str2rstr_utf16le(input) {
|
|
208
187
|
var output = "";
|
|
209
188
|
for (var i = 0; i < input.length; i++)
|
|
210
189
|
output += String.fromCharCode(input.charCodeAt(i) & 0xff, (input.charCodeAt(i) >>> 8) & 0xff);
|
|
211
190
|
return output;
|
|
212
|
-
}
|
|
213
|
-
|
|
191
|
+
}
|
|
192
|
+
str2rstr_utf16be(input) {
|
|
214
193
|
var output = "";
|
|
215
194
|
for (var i = 0; i < input.length; i++)
|
|
216
195
|
output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xff, input.charCodeAt(i) & 0xff);
|
|
217
196
|
return output;
|
|
218
|
-
}
|
|
197
|
+
}
|
|
219
198
|
/*
|
|
220
199
|
* Convert a raw string to an array of little-endian words
|
|
221
200
|
* Characters >255 have their high-byte silently ignored.
|
|
222
201
|
*/
|
|
223
|
-
|
|
202
|
+
rstr2binl(input) {
|
|
224
203
|
var output = Array(input.length >> 2);
|
|
225
204
|
for (var i = 0; i < output.length; i++)
|
|
226
205
|
output[i] = 0;
|
|
227
206
|
for (var i = 0; i < input.length * 8; i += 8)
|
|
228
207
|
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << i % 32;
|
|
229
208
|
return output;
|
|
230
|
-
}
|
|
209
|
+
}
|
|
231
210
|
/*
|
|
232
211
|
* Convert an array of little-endian words to a string
|
|
233
212
|
*/
|
|
234
|
-
|
|
213
|
+
binl2rstr(input) {
|
|
235
214
|
var output = "";
|
|
236
215
|
for (var i = 0; i < input.length * 32; i += 8)
|
|
237
216
|
output += String.fromCharCode((input[i >> 5] >>> i % 32) & 0xff);
|
|
238
217
|
return output;
|
|
239
|
-
}
|
|
218
|
+
}
|
|
240
219
|
/*
|
|
241
220
|
* Calculate the MD5 of an array of little-endian words, and a bit length.
|
|
242
221
|
*/
|
|
243
|
-
|
|
222
|
+
binl_md5(x, len) {
|
|
244
223
|
/* append padding */
|
|
245
224
|
x[len >> 5] |= 0x80 << len % 32;
|
|
246
225
|
x[(((len + 64) >>> 9) << 4) + 14] = len;
|
|
@@ -323,44 +302,43 @@ var MD5 = /** @class */ (function (_super) {
|
|
|
323
302
|
d = this.safe_add(d, oldd);
|
|
324
303
|
}
|
|
325
304
|
return [a, b, c, d];
|
|
326
|
-
}
|
|
305
|
+
}
|
|
327
306
|
/*
|
|
328
307
|
* These privates implement the four basic operations the algorithm uses.
|
|
329
308
|
*/
|
|
330
|
-
|
|
309
|
+
md5_cmn(q, a, b, x, s, t) {
|
|
331
310
|
return this.safe_add(this.bit_rol(this.safe_add(this.safe_add(a, q), this.safe_add(x, t)), s), b);
|
|
332
|
-
}
|
|
333
|
-
|
|
311
|
+
}
|
|
312
|
+
md5_ff(a, b, c, d, x, s, t) {
|
|
334
313
|
return this.md5_cmn((b & c) | (~b & d), a, b, x, s, t);
|
|
335
|
-
}
|
|
336
|
-
|
|
314
|
+
}
|
|
315
|
+
md5_gg(a, b, c, d, x, s, t) {
|
|
337
316
|
return this.md5_cmn((b & d) | (c & ~d), a, b, x, s, t);
|
|
338
|
-
}
|
|
339
|
-
|
|
317
|
+
}
|
|
318
|
+
md5_hh(a, b, c, d, x, s, t) {
|
|
340
319
|
return this.md5_cmn(b ^ c ^ d, a, b, x, s, t);
|
|
341
|
-
}
|
|
342
|
-
|
|
320
|
+
}
|
|
321
|
+
md5_ii(a, b, c, d, x, s, t) {
|
|
343
322
|
return this.md5_cmn(c ^ (b | ~d), a, b, x, s, t);
|
|
344
|
-
}
|
|
323
|
+
}
|
|
345
324
|
/*
|
|
346
325
|
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
|
347
326
|
* to work around bugs in some JS interpreters.
|
|
348
327
|
*/
|
|
349
|
-
|
|
328
|
+
safe_add(x, y) {
|
|
350
329
|
var lsw = (x & 0xffff) + (y & 0xffff);
|
|
351
330
|
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
|
352
331
|
return (msw << 16) | (lsw & 0xffff);
|
|
353
|
-
}
|
|
332
|
+
}
|
|
354
333
|
/*
|
|
355
334
|
* Bitwise rotate a 32-bit number to the left.
|
|
356
335
|
*/
|
|
357
|
-
|
|
336
|
+
bit_rol(num, cnt) {
|
|
358
337
|
return (num << cnt) | (num >>> (32 - cnt));
|
|
359
|
-
}
|
|
360
|
-
|
|
338
|
+
}
|
|
339
|
+
destroy() {
|
|
361
340
|
MD5._instance = null;
|
|
362
341
|
delete MD5._instance;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
}(BaseSingleton_1.BaseSingleton));
|
|
342
|
+
}
|
|
343
|
+
}
|
|
366
344
|
exports.MD5 = MD5;
|
|
@@ -5,79 +5,75 @@ exports.BeizerUtil = void 0;
|
|
|
5
5
|
* 贝塞尔曲线运动工具<b style="color:red">支持多点</b>
|
|
6
6
|
* @author Aonaufly
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
function BeizerUtil() {
|
|
10
|
-
}
|
|
8
|
+
class BeizerUtil {
|
|
11
9
|
//#region 获得当前坐标
|
|
12
10
|
/**
|
|
13
11
|
* 获得当前坐标
|
|
14
12
|
* @param timer 时间[0,1]
|
|
15
13
|
* @returns
|
|
16
14
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
for (
|
|
15
|
+
static getPosition(points, timer) {
|
|
16
|
+
let x = 0, y = 0;
|
|
17
|
+
let bezier;
|
|
18
|
+
for (let i = 0, n = points.length; i < n; i++) {
|
|
21
19
|
bezier =
|
|
22
20
|
Math.min(Math.pow(1 - timer, n - i - 1) * Math.pow(timer, i)) *
|
|
23
21
|
BeizerUtil.calculationC(i, n);
|
|
24
22
|
x += points[i].x * bezier;
|
|
25
23
|
y += points[i].y * bezier;
|
|
26
24
|
}
|
|
27
|
-
return { x
|
|
28
|
-
}
|
|
25
|
+
return { x, y };
|
|
26
|
+
}
|
|
29
27
|
//#endregion
|
|
30
28
|
//region 获得路线的长度
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
static distance(p1, p2) {
|
|
30
|
+
const dx = p2.x - p1.x;
|
|
31
|
+
const dy = p2.y - p1.y;
|
|
34
32
|
return Math.sqrt(dx * dx + dy * dy);
|
|
35
|
-
}
|
|
33
|
+
}
|
|
36
34
|
/**
|
|
37
35
|
* 获得整个路线的长度
|
|
38
36
|
* @param precision 精确度(微积分方案)
|
|
39
37
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
for (var t = 0; t < 1; t += 1 / precision) {
|
|
38
|
+
static getLength(points, precision = 100) {
|
|
39
|
+
let length = 0;
|
|
40
|
+
let point1;
|
|
41
|
+
let point2;
|
|
42
|
+
for (let t = 0; t < 1; t += 1 / precision) {
|
|
46
43
|
point1 = BeizerUtil.getBezierPoint(points, t);
|
|
47
44
|
point2 = BeizerUtil.getBezierPoint(points, t + 1 / precision);
|
|
48
45
|
length += BeizerUtil.distance(point1, point2);
|
|
49
46
|
}
|
|
50
47
|
return length;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return (BeizerUtil.factorial(n - 1) /
|
|
54
|
-
(BeizerUtil.factorial(i) * BeizerUtil.factorial(n - 1 - i)));
|
|
55
|
-
};
|
|
56
|
-
BeizerUtil.factorial = function (num) {
|
|
57
|
-
if (num < 0) {
|
|
58
|
-
return 1;
|
|
59
|
-
}
|
|
60
|
-
else if (num === 0 || num === 1) {
|
|
61
|
-
return 1;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
return num * BeizerUtil.factorial(num - 1);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
BeizerUtil.getBezierPoint = function (points, t) {
|
|
68
|
-
if (points.length === 1) {
|
|
69
|
-
return points[0];
|
|
70
|
-
}
|
|
71
|
-
var nextPoints = [];
|
|
72
|
-
var x;
|
|
73
|
-
var y;
|
|
74
|
-
for (var i = 0; i < points.length - 1; i++) {
|
|
75
|
-
x = (1 - t) * points[i].x + t * points[i + 1].x;
|
|
76
|
-
y = (1 - t) * points[i].y + t * points[i + 1].y;
|
|
77
|
-
nextPoints.push({ x: x, y: y });
|
|
78
|
-
}
|
|
79
|
-
return BeizerUtil.getBezierPoint(nextPoints, t);
|
|
80
|
-
};
|
|
81
|
-
return BeizerUtil;
|
|
82
|
-
}());
|
|
48
|
+
}
|
|
49
|
+
}
|
|
83
50
|
exports.BeizerUtil = BeizerUtil;
|
|
51
|
+
BeizerUtil.calculationC = (i, n) => {
|
|
52
|
+
return (BeizerUtil.factorial(n - 1) /
|
|
53
|
+
(BeizerUtil.factorial(i) * BeizerUtil.factorial(n - 1 - i)));
|
|
54
|
+
};
|
|
55
|
+
BeizerUtil.factorial = (num) => {
|
|
56
|
+
if (num < 0) {
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
else if (num === 0 || num === 1) {
|
|
60
|
+
return 1;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return num * BeizerUtil.factorial(num - 1);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
BeizerUtil.getBezierPoint = (points, t) => {
|
|
67
|
+
if (points.length === 1) {
|
|
68
|
+
return points[0];
|
|
69
|
+
}
|
|
70
|
+
const nextPoints = [];
|
|
71
|
+
let x;
|
|
72
|
+
let y;
|
|
73
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
74
|
+
x = (1 - t) * points[i].x + t * points[i + 1].x;
|
|
75
|
+
y = (1 - t) * points[i].y + t * points[i + 1].y;
|
|
76
|
+
nextPoints.push({ x, y });
|
|
77
|
+
}
|
|
78
|
+
return BeizerUtil.getBezierPoint(nextPoints, t);
|
|
79
|
+
};
|