light-h5-core-lib 2.10.4 → 2.10.6
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 +7 -4
- package/common/base/SetterGetterBase.js +9 -2
- package/common/util/GetDecorateUtils.js +73 -0
- package/common/util/PromiseUtil.js +43 -15
- package/package.json +1 -1
- package/pool/PoolObj.js +2 -2
- package/type/index.d.ts +46 -4
package/LightCore.js
CHANGED
|
@@ -3,7 +3,7 @@ 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;
|
|
6
|
+
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
7
|
var PoolObj_1 = require("./pool/PoolObj");
|
|
8
8
|
Object.defineProperty(exports, "PoolObj", { enumerable: true, get: function () { return PoolObj_1.PoolObj; } });
|
|
9
9
|
var BaseSingleton_1 = require("./common/base/BaseSingleton");
|
|
@@ -24,8 +24,8 @@ var BeizerUtil_1 = require("./common/util/BeizerUtil");
|
|
|
24
24
|
Object.defineProperty(exports, "BeizerUtil", { enumerable: true, get: function () { return BeizerUtil_1.BeizerUtil; } });
|
|
25
25
|
var MD5_1 = require("./common/md5/MD5");
|
|
26
26
|
Object.defineProperty(exports, "MD5", { enumerable: true, get: function () { return MD5_1.MD5; } });
|
|
27
|
-
var PromiseUtil_1 =
|
|
28
|
-
exports
|
|
27
|
+
var PromiseUtil_1 = require("./common/util/PromiseUtil");
|
|
28
|
+
Object.defineProperty(exports, "PromiseUtil", { enumerable: true, get: function () { return PromiseUtil_1.PromiseUtil; } });
|
|
29
29
|
var Crc32Util_1 = __importDefault(require("./common/util/Crc32Util"));
|
|
30
30
|
exports.Crc32Util = Crc32Util_1.default;
|
|
31
31
|
var BooleanUtil_1 = require("./common/util/BooleanUtil");
|
|
@@ -40,6 +40,8 @@ var ClassNameUtil_1 = require("./common/util/ClassNameUtil");
|
|
|
40
40
|
Object.defineProperty(exports, "ClassNameUtil", { enumerable: true, get: function () { return ClassNameUtil_1.ClassNameUtil; } });
|
|
41
41
|
var SetterGetterBase_1 = require("./common/base/SetterGetterBase");
|
|
42
42
|
Object.defineProperty(exports, "SetterGetterBase", { enumerable: true, get: function () { return SetterGetterBase_1.SetterGetterBase; } });
|
|
43
|
+
var GetDecorateUtils_1 = require("./common/util/GetDecorateUtils");
|
|
44
|
+
Object.defineProperty(exports, "GetDecorateUtils", { enumerable: true, get: function () { return GetDecorateUtils_1.GetDecorateUtils; } });
|
|
43
45
|
module.exports = {
|
|
44
46
|
PoolObj: PoolObj_1.PoolObj,
|
|
45
47
|
ClassNameUtil: ClassNameUtil_1.ClassNameUtil,
|
|
@@ -53,10 +55,11 @@ module.exports = {
|
|
|
53
55
|
StringUtil: StringUtil_1.StringUtil,
|
|
54
56
|
UniqueIDUtil: UniqueIDUtil_1.UniqueIDUtil,
|
|
55
57
|
BeizerUtil: BeizerUtil_1.BeizerUtil,
|
|
56
|
-
PromiseUtil: PromiseUtil_1.
|
|
58
|
+
PromiseUtil: PromiseUtil_1.PromiseUtil,
|
|
57
59
|
Crc32Util: Crc32Util_1.default,
|
|
58
60
|
BooleanUtil: BooleanUtil_1.BooleanUtil,
|
|
59
61
|
NumberUtil: NumberUtil_1.NumberUtil,
|
|
62
|
+
GetDecorateUtils: GetDecorateUtils_1.GetDecorateUtils,
|
|
60
63
|
SelfDecrypt: SelfDecrypt_1.SelfDecrypt,
|
|
61
64
|
CollisionDetectionUtil: CollisionDetectionUtil_1.CollisionDetectionUtil,
|
|
62
65
|
};
|
|
@@ -8,6 +8,12 @@ exports.SetterGetterBase = void 0;
|
|
|
8
8
|
var SetterGetterBase = /** @class */ (function () {
|
|
9
9
|
function SetterGetterBase() {
|
|
10
10
|
}
|
|
11
|
+
SetterGetterBase.prototype.isNeedCheckChanged = function (publicName) {
|
|
12
|
+
if (!this.ignoreCheckChangedFields || this.ignoreCheckChangedFields.length == 0) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
return !this.ignoreCheckChangedFields.includes(publicName);
|
|
16
|
+
};
|
|
11
17
|
/**
|
|
12
18
|
* 扫描实例属性并自动创建访问器
|
|
13
19
|
*/
|
|
@@ -64,8 +70,9 @@ var SetterGetterBase = /** @class */ (function () {
|
|
|
64
70
|
if (oldValue === value)
|
|
65
71
|
return;
|
|
66
72
|
this[privateName] = value;
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
if (this.isNeedCheckChanged(publicName)) {
|
|
74
|
+
(_a = this.onPropertyChanged) === null || _a === void 0 ? void 0 : _a.call(this, publicName, value, oldValue);
|
|
75
|
+
}
|
|
69
76
|
},
|
|
70
77
|
enumerable: true,
|
|
71
78
|
configurable: true,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetDecorateUtils = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 获取装饰的相关参数
|
|
6
|
+
* @author Aonaufly
|
|
7
|
+
*/
|
|
8
|
+
var GetDecorateUtils = /** @class */ (function () {
|
|
9
|
+
function GetDecorateUtils() {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 获取类中成员
|
|
13
|
+
* @param obj
|
|
14
|
+
* @param memberName 成员名称
|
|
15
|
+
*/
|
|
16
|
+
GetDecorateUtils.getObjMember = function (obj, memberName) {
|
|
17
|
+
if (!obj)
|
|
18
|
+
return null;
|
|
19
|
+
if (obj[memberName]) {
|
|
20
|
+
return obj[memberName];
|
|
21
|
+
}
|
|
22
|
+
if (obj["__proto__"] && obj["__proto__"]["constructor"] && obj["__proto__"]["constructor"][memberName]) {
|
|
23
|
+
return obj["__proto__"]["constructor"][memberName];
|
|
24
|
+
}
|
|
25
|
+
if (obj["prototype"] && obj["prototype"][memberName]) {
|
|
26
|
+
return obj["prototype"][memberName];
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* 绑定方法
|
|
32
|
+
* @param classObj
|
|
33
|
+
* @param funName
|
|
34
|
+
* @param fun
|
|
35
|
+
*/
|
|
36
|
+
GetDecorateUtils.bindFun = function (classObj, funName, fun) {
|
|
37
|
+
if (classObj[funName] != null) {
|
|
38
|
+
classObj[funName] = fun.bind(classObj);
|
|
39
|
+
}
|
|
40
|
+
else if (classObj["__proto__"] && classObj["__proto__"]["constructor"] && classObj["__proto__"]["constructor"][funName]) {
|
|
41
|
+
classObj["__proto__"]["constructor"][funName] = fun.bind(classObj);
|
|
42
|
+
}
|
|
43
|
+
else if (classObj["prototype"] && classObj["prototype"][funName]) {
|
|
44
|
+
classObj["prototype"][funName] = fun.bind(classObj);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
console.warn("".concat(funName, " \u7ED1\u5B9A\u65B9\u6CD5\u5931\u8D25!"));
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* 设置字段/属性的值
|
|
52
|
+
* @param classObj
|
|
53
|
+
* @param fieldName
|
|
54
|
+
* @param value
|
|
55
|
+
*/
|
|
56
|
+
GetDecorateUtils.setFieldValue = function (classObj, fieldName, value) {
|
|
57
|
+
if (classObj[fieldName] != null) {
|
|
58
|
+
classObj[fieldName] = value;
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
else if (classObj["__proto__"] && classObj["__proto__"]["constructor"] && classObj["__proto__"]["constructor"][fieldName]) {
|
|
62
|
+
classObj["__proto__"]["constructor"][fieldName] = value;
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
else if (classObj["prototype"] && classObj["prototype"][fieldName]) {
|
|
66
|
+
classObj["prototype"][fieldName] = value;
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
};
|
|
71
|
+
return GetDecorateUtils;
|
|
72
|
+
}());
|
|
73
|
+
exports.GetDecorateUtils = GetDecorateUtils;
|
|
@@ -36,6 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.PromiseUtil = void 0;
|
|
39
40
|
/**
|
|
40
41
|
* 异步处理工具
|
|
41
42
|
* @author Aonaufly
|
|
@@ -44,31 +45,58 @@ var PromiseUtil = /** @class */ (function () {
|
|
|
44
45
|
function PromiseUtil() {
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
47
|
-
*
|
|
48
|
+
* 执行所有异步并返回数据<br>
|
|
49
|
+
* <div style="color: #FF0000;">⚠️:参数为异步方法数组,封装了异步方法的执行</div>
|
|
48
50
|
*/
|
|
49
51
|
PromiseUtil.all = function (promiseArr) {
|
|
50
52
|
return __awaiter(this, void 0, void 0, function () {
|
|
51
53
|
return __generator(this, function (_a) {
|
|
52
54
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
if (!promiseArr || promiseArr.length == 0) {
|
|
56
|
+
resolve(new Error('promiseArr is null'));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
var execAsync = function (isFunc) {
|
|
60
|
+
var arr = [];
|
|
61
|
+
if (isFunc) {
|
|
62
|
+
var promiseFuncs = promiseArr.slice(0);
|
|
63
|
+
for (var i = 0; i < promiseFuncs.length; i++) {
|
|
64
|
+
arr.push(promiseFuncs[i]());
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
var promiseObjects = promiseArr.slice(0);
|
|
69
|
+
var item = void 0;
|
|
70
|
+
for (var i = 0; i < promiseObjects.length; i++) {
|
|
71
|
+
item = promiseObjects[i];
|
|
72
|
+
if (item.params && item.params.length > 0) {
|
|
73
|
+
arr.push(item.asyncFunc.apply(item, item.params));
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
arr.push(item.asyncFunc());
|
|
77
|
+
}
|
|
62
78
|
}
|
|
63
|
-
}
|
|
79
|
+
}
|
|
80
|
+
return arr;
|
|
64
81
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
82
|
+
var allPromises = execAsync(promiseArr[0] instanceof Function);
|
|
83
|
+
Promise.all(allPromises).then(function (promiseResult) {
|
|
84
|
+
resolve(promiseResult);
|
|
85
|
+
}).catch(function (e) { return reject(e); });
|
|
68
86
|
})];
|
|
69
87
|
});
|
|
70
88
|
});
|
|
71
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* 拼接带参数的异步列表
|
|
92
|
+
*/
|
|
93
|
+
PromiseUtil.spliceExistParamsAsyncFuncList = function (funcList, params) {
|
|
94
|
+
var arr = [];
|
|
95
|
+
for (var i = 0; i < funcList.length; i++) {
|
|
96
|
+
arr.push({ asyncFunc: funcList[i], params: params[i] });
|
|
97
|
+
}
|
|
98
|
+
return arr;
|
|
99
|
+
};
|
|
72
100
|
return PromiseUtil;
|
|
73
101
|
}());
|
|
74
|
-
exports.
|
|
102
|
+
exports.PromiseUtil = PromiseUtil;
|
package/package.json
CHANGED
package/pool/PoolObj.js
CHANGED
|
@@ -56,8 +56,8 @@ var PoolObj = /** @class */ (function () {
|
|
|
56
56
|
};
|
|
57
57
|
/**
|
|
58
58
|
* 获得一个Item<br>
|
|
59
|
-
* <
|
|
60
|
-
* <b style="color
|
|
59
|
+
* <div style="color: #FF0000;">⚠️友情提示:如果有createCallback需要判断是否是New的item则提前使用 this.size == 0保存句柄</div><br>
|
|
60
|
+
* <b style="color:#FFFF00">⚠️如果size==0,则自动使用createCallback创建 ,如果size==0 && createCallback==null,则返回null</b>
|
|
61
61
|
*/
|
|
62
62
|
PoolObj.prototype.one = function () {
|
|
63
63
|
if (this._pool.length == 0) {
|
package/type/index.d.ts
CHANGED
|
@@ -35,8 +35,8 @@ export declare class PoolObj<T> implements IClear {
|
|
|
35
35
|
put(obj: T): boolean;
|
|
36
36
|
/**
|
|
37
37
|
* 获得一个Item<br>
|
|
38
|
-
* <
|
|
39
|
-
* <b style="color
|
|
38
|
+
* <div style="color: #FF0000;">⚠️友情提示:如果有createCallback需要判断是否是New的item则提前使用 this.size == 0保存句柄</div><br>
|
|
39
|
+
* <b style="color:#FFFF00">⚠️如果size==0,则自动使用createCallback创建 ,如果size==0 && createCallback==null,则返回null</b>
|
|
40
40
|
*/
|
|
41
41
|
one(): T;
|
|
42
42
|
/**
|
|
@@ -338,9 +338,20 @@ export declare class MD5 extends BaseSingleton {
|
|
|
338
338
|
*/
|
|
339
339
|
export declare class PromiseUtil {
|
|
340
340
|
/**
|
|
341
|
-
*
|
|
341
|
+
* 执行所有异步并返回数据<br>
|
|
342
|
+
* <div style="color: #FF0000;">⚠️:参数为异步方法数组,封装了异步方法的执行</div>
|
|
342
343
|
*/
|
|
343
|
-
static all(promiseArr: Promise<any>[]
|
|
344
|
+
static all(promiseArr: (() => Promise<any>)[] | {
|
|
345
|
+
asyncFunc: (...args: any[]) => Promise<any>;
|
|
346
|
+
params: any[];
|
|
347
|
+
}[]): Promise<any>;
|
|
348
|
+
/**
|
|
349
|
+
* 拼接带参数的异步列表
|
|
350
|
+
*/
|
|
351
|
+
static spliceExistParamsAsyncFuncList(funcList: ((...args: any[]) => Promise<any>)[], params: any[][]): {
|
|
352
|
+
asyncFunc: (...args: any[]) => Promise<any>;
|
|
353
|
+
params: any[];
|
|
354
|
+
}[];
|
|
344
355
|
}
|
|
345
356
|
/**
|
|
346
357
|
* Crc32验证工具
|
|
@@ -485,6 +496,11 @@ export declare abstract class SetterGetterBase {
|
|
|
485
496
|
* 不需要添加setter / getter的字段(不需要加_前缀)
|
|
486
497
|
*/
|
|
487
498
|
protected abstract get ignoreFields(): string[];
|
|
499
|
+
/**
|
|
500
|
+
* 不需要监听变化的字段(不需要加_前缀)
|
|
501
|
+
*/
|
|
502
|
+
protected abstract get ignoreCheckChangedFields(): string[];
|
|
503
|
+
private isNeedCheckChanged;
|
|
488
504
|
/**
|
|
489
505
|
* 扫描实例属性并自动创建访问器
|
|
490
506
|
*/
|
|
@@ -502,5 +518,31 @@ export declare abstract class SetterGetterBase {
|
|
|
502
518
|
*/
|
|
503
519
|
protected onPropertyChanged?(propertyName: string, newValue: any, oldValue: any): void;
|
|
504
520
|
}
|
|
521
|
+
/**
|
|
522
|
+
* 获取装饰的相关参数
|
|
523
|
+
* @author Aonaufly
|
|
524
|
+
*/
|
|
525
|
+
export declare class GetDecorateUtils {
|
|
526
|
+
/**
|
|
527
|
+
* 获取类中成员
|
|
528
|
+
* @param obj
|
|
529
|
+
* @param memberName 成员名称
|
|
530
|
+
*/
|
|
531
|
+
static getObjMember<T>(obj: any, memberName: string): T;
|
|
532
|
+
/**
|
|
533
|
+
* 绑定方法
|
|
534
|
+
* @param classObj
|
|
535
|
+
* @param funName
|
|
536
|
+
* @param fun
|
|
537
|
+
*/
|
|
538
|
+
static bindFun(classObj: any, funName: string, fun: Function): void;
|
|
539
|
+
/**
|
|
540
|
+
* 设置字段/属性的值
|
|
541
|
+
* @param classObj
|
|
542
|
+
* @param fieldName
|
|
543
|
+
* @param value
|
|
544
|
+
*/
|
|
545
|
+
static setFieldValue<T>(classObj: any, fieldName: string, value: T): boolean;
|
|
546
|
+
}
|
|
505
547
|
|
|
506
548
|
export {};
|