dzkcc-mflow 0.0.1 → 0.0.2

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.
Files changed (48) hide show
  1. package/dist/App.d.ts +22 -22
  2. package/dist/App.js +27 -27
  3. package/dist/_virtual/_tslib.js +30 -30
  4. package/dist/core/Api.d.ts +53 -53
  5. package/dist/core/Core.d.ts +18 -18
  6. package/dist/core/Core.js +78 -78
  7. package/dist/core/Decorators.d.ts +7 -7
  8. package/dist/core/Decorators.js +99 -99
  9. package/dist/core/ICocosResManager.d.ts +11 -11
  10. package/dist/core/ServiceLocator.d.ts +7 -7
  11. package/dist/core/ServiceLocator.js +31 -31
  12. package/dist/core/index.d.ts +5 -5
  13. package/dist/libs/BaseView.d.ts +21 -21
  14. package/dist/libs/BaseView.js +78 -78
  15. package/dist/libs/Broadcaster.d.ts +101 -101
  16. package/dist/libs/Broadcaster.js +240 -240
  17. package/dist/libs/CocosCore.d.ts +5 -5
  18. package/dist/libs/CocosCore.js +16 -16
  19. package/dist/libs/ResLoader.d.ts +10 -10
  20. package/dist/libs/ResLoader.js +76 -74
  21. package/dist/libs/UIManager.d.ts +34 -34
  22. package/dist/libs/UIManager.js +251 -251
  23. package/dist/libs/UIRoot.d.ts +4 -4
  24. package/dist/libs/UIRoot.js +4 -4
  25. package/dist/libs/index.d.ts +6 -6
  26. package/dist/mflow-tools.zip +0 -0
  27. package/dist/utils/ArrayExt.d.ts +67 -67
  28. package/dist/utils/ArrayExt.js +298 -298
  29. package/dist/utils/ArrayUtil.d.ts +41 -41
  30. package/dist/utils/ArrayUtil.js +93 -93
  31. package/dist/utils/CameraUtil.d.ts +10 -10
  32. package/dist/utils/CameraUtil.js +23 -23
  33. package/dist/utils/ImageUtil.d.ts +33 -33
  34. package/dist/utils/ImageUtil.js +92 -92
  35. package/dist/utils/MathUtil.d.ts +213 -213
  36. package/dist/utils/MathUtil.js +435 -435
  37. package/dist/utils/ObjectUtil.d.ts +24 -24
  38. package/dist/utils/ObjectUtil.js +58 -58
  39. package/dist/utils/PlatformUtil.d.ts +9 -9
  40. package/dist/utils/PlatformUtil.js +27 -27
  41. package/dist/utils/RotateUtil.d.ts +30 -30
  42. package/dist/utils/RotateUtil.js +63 -63
  43. package/dist/utils/StringUtil.d.ts +107 -107
  44. package/dist/utils/StringUtil.js +249 -249
  45. package/dist/utils/TimeUtil.d.ts +31 -31
  46. package/dist/utils/TimeUtil.js +85 -85
  47. package/dist/utils/index.d.ts +9 -9
  48. package/package.json +1 -1
@@ -1,254 +1,254 @@
1
1
  import { ObjectUtil } from './ObjectUtil.js';
2
2
 
3
- /** 字符串工具 */
4
- class StringUtil {
5
- /** 获取一个唯一标识的字符串 */
6
- static guid() {
7
- let guid = "";
8
- for (let i = 1; i <= 32; i++) {
9
- let n = Math.floor(Math.random() * 16.0).toString(16);
10
- guid += n;
11
- if ((i == 8) || (i == 12) || (i == 16) || (i == 20))
12
- guid += "-";
13
- }
14
- return guid;
15
- }
16
- /**
17
- * 转美式计数字符串
18
- * @param value 数字
19
- * @example
20
- * 123456789 = 123,456,789
21
- */
22
- static numberTotPermil(value) {
23
- return value.toLocaleString();
24
- }
25
- /**
26
- * 转英文单位计数
27
- * @param value 数字
28
- * @param fixed 保留小数位数
29
- * @example
30
- * 12345 = 12.35K
31
- */
32
- static numberToThousand(value, fixed = 2) {
33
- var k = 1000;
34
- var sizes = ['', 'K', 'M', 'G'];
35
- if (value < k) {
36
- return value.toString();
37
- }
38
- else {
39
- var i = Math.floor(Math.log(value) / Math.log(k));
40
- var r = ((value / Math.pow(k, i)));
41
- return r.toFixed(fixed) + sizes[i];
42
- }
43
- }
44
- /**
45
- * 转中文单位计数
46
- * @param value 数字
47
- * @param fixed 保留小数位数
48
- * @example
49
- * 12345 = 1.23万
50
- */
51
- static numberToTenThousand(value, fixed = 2) {
52
- var k = 10000;
53
- var sizes = ['', '万', '亿', '万亿'];
54
- if (value < k) {
55
- return value.toString();
56
- }
57
- else {
58
- var i = Math.floor(Math.log(value) / Math.log(k));
59
- return ((value / Math.pow(k, i))).toFixed(fixed) + sizes[i];
60
- }
61
- }
62
- /**
63
- * "," 分割字符串成数组
64
- * @param str 字符串
65
- */
66
- static stringToArray1(str) {
67
- if (str == "") {
68
- return [];
69
- }
70
- return str.split(",");
71
- }
72
- /**
73
- * "|" 分割字符串成数组
74
- * @param str 字符串
75
- */
76
- static stringToArray2(str) {
77
- if (str == "") {
78
- return [];
79
- }
80
- return str.split("|");
81
- }
82
- /**
83
- * ":" 分割字符串成数组
84
- * @param str 字符串
85
- */
86
- static stringToArray3(str) {
87
- if (str == "") {
88
- return [];
89
- }
90
- return str.split(":");
91
- }
92
- /**
93
- * ";" 分割字符串成数组
94
- * @param str 字符串
95
- */
96
- static stringToArray4(str) {
97
- if (str == "") {
98
- return [];
99
- }
100
- return str.split(";");
101
- }
102
- /**
103
- * 字符串截取
104
- * @param str 字符串
105
- * @param n 截取长度
106
- * @param showdot 是否把截取的部分用省略号代替
107
- */
108
- static sub(str, n, showdot = false) {
109
- var r = /[^\x00-\xff]/g;
110
- if (str.replace(r, "mm").length <= n) {
111
- return str;
112
- }
113
- var m = Math.floor(n / 2);
114
- for (var i = m; i < str.length; i++) {
115
- if (str.substr(0, i).replace(r, "mm").length >= n) {
116
- if (showdot) {
117
- return str.substr(0, i) + "...";
118
- }
119
- else {
120
- return str.substr(0, i);
121
- }
122
- }
123
- }
124
- return str;
125
- }
126
- /**
127
- * 计算字符串长度,中文算两个字节
128
- * @param str 字符串
129
- */
130
- static stringLen(str) {
131
- var realLength = 0, len = str.length, charCode = -1;
132
- for (var i = 0; i < len; i++) {
133
- charCode = str.charCodeAt(i);
134
- if (charCode >= 0 && charCode <= 128)
135
- realLength += 1;
136
- else
137
- realLength += 2;
138
- }
139
- return realLength;
140
- }
141
- /**
142
- * 截取字符串,显示省略号
143
- * @param str
144
- * @param len
145
- */
146
- static ellipsisString(str, maxChars) {
147
- if (this.isEmptyOrWhiteSpace(str))
148
- return "";
149
- if (str.length > maxChars) {
150
- let truncatedText = str.substring(0, maxChars);
151
- return `${truncatedText}...`;
152
- }
153
- else {
154
- return str;
155
- }
156
- }
157
- /**
158
- * 是否为空或者空格
159
- * @param str
160
- */
161
- static isEmptyOrWhiteSpace(str) {
162
- return !str || str.trim() == '';
163
- }
164
- /**
165
- * 参数替换
166
- * @param str
167
- * @param rest
168
- *
169
- * @example
170
- *
171
- * var str:string = "here is some info '{0}' and {1}";
172
- * StringUtil.substitute(str, 15.4, true);
173
- * "here is some info '15.4' and true"
174
- *
175
- * const result = substitute("Hello, {name}! Today is {day}.", "John Doe", "Monday");
176
- * console.log(result); // 输出: Hello, John Doe! Today is Monday.
177
- *
178
- * const result2 = substitute("The value of {abc} is {num} and the variable {xyz} has the value {value}.", {abc: 123, num: "456", xyz: "789", value: "hello"});
179
- * console.log(result2); // 输出: The value of 123 is 456 and the variable 789 has the value hello.
180
- */
181
- static substitute(str, ...rest) {
182
- if (str == null)
183
- return '';
184
- var args;
185
- let parseByDic = rest.length == 1 && ObjectUtil.isObjectLiteral(rest[0]);
186
- if (parseByDic || (rest.length == 1 && rest[0] instanceof Array)) {
187
- args = rest[0];
188
- }
189
- else {
190
- args = rest;
191
- }
192
- // 创建一个正则表达式来匹配所有的大括号占位符
193
- const placeholderRegex = /\{([\w-]+)\}/g;
194
- if (parseByDic) {
195
- return str.replace(placeholderRegex, (match, key) => {
196
- return args[key];
197
- });
198
- }
199
- else {
200
- // 构建一个映射,将大括号中的内容映射到实际值
201
- const placeholders = new Map();
202
- let match = str.matchAll(placeholderRegex);
203
- let i = 0;
204
- for (const element of match) {
205
- placeholders.set(element[0], args[i]);
206
- i++;
207
- }
208
- // 使用映射替换占位符
209
- return str.replace(placeholderRegex, (match, key) => {
210
- const replacement = placeholders.get(match);
211
- return replacement !== undefined ? replacement : match;
212
- });
213
- }
214
- }
215
- /**
216
- * 获取字符串中指定字符的全部索引
217
- * @param mainStr
218
- * @param subStr
219
- * @returns
220
- */
221
- static findAllSubstringsIndexes(mainStr, subStr) {
222
- const indexes = [];
223
- let currentIndex = mainStr.indexOf(subStr);
224
- while (currentIndex !== -1) {
225
- indexes.push(currentIndex);
226
- currentIndex = mainStr.indexOf(subStr, currentIndex + subStr.length);
227
- }
228
- return indexes;
229
- }
230
- /**
231
- * 用于将英文文本包围在 Unicode RLE 和 PDF 字符中,以确保其在 RTL 文本中正确显示
232
- * @param text
233
- * @returns
234
- */
235
- static surroundLTRWithUnicode(text) {
236
- // 使用正则表达式匹配连续的英文单词,并在其前后添加 \u202B 和 \u202C
237
- return text.replace(/([a-zA-Z\s]+)/g, (match) => {
238
- // 检查匹配到的字符串是否包含英文字符
239
- if (/[a-zA-Z]/.test(match)) {
240
- return `\u202B${match}\u202C`;
241
- }
242
- return match;
243
- });
244
- }
245
- /**
246
- * 判断字符是否为双字节字符(如中文字符)
247
- * @param string 原字符串
248
- */
249
- static isDoubleWord(string) {
250
- return /[^\x00-\xff]/.test(string);
251
- }
3
+ /** 字符串工具 */
4
+ class StringUtil {
5
+ /** 获取一个唯一标识的字符串 */
6
+ static guid() {
7
+ let guid = "";
8
+ for (let i = 1; i <= 32; i++) {
9
+ let n = Math.floor(Math.random() * 16.0).toString(16);
10
+ guid += n;
11
+ if ((i == 8) || (i == 12) || (i == 16) || (i == 20))
12
+ guid += "-";
13
+ }
14
+ return guid;
15
+ }
16
+ /**
17
+ * 转美式计数字符串
18
+ * @param value 数字
19
+ * @example
20
+ * 123456789 = 123,456,789
21
+ */
22
+ static numberTotPermil(value) {
23
+ return value.toLocaleString();
24
+ }
25
+ /**
26
+ * 转英文单位计数
27
+ * @param value 数字
28
+ * @param fixed 保留小数位数
29
+ * @example
30
+ * 12345 = 12.35K
31
+ */
32
+ static numberToThousand(value, fixed = 2) {
33
+ var k = 1000;
34
+ var sizes = ['', 'K', 'M', 'G'];
35
+ if (value < k) {
36
+ return value.toString();
37
+ }
38
+ else {
39
+ var i = Math.floor(Math.log(value) / Math.log(k));
40
+ var r = ((value / Math.pow(k, i)));
41
+ return r.toFixed(fixed) + sizes[i];
42
+ }
43
+ }
44
+ /**
45
+ * 转中文单位计数
46
+ * @param value 数字
47
+ * @param fixed 保留小数位数
48
+ * @example
49
+ * 12345 = 1.23万
50
+ */
51
+ static numberToTenThousand(value, fixed = 2) {
52
+ var k = 10000;
53
+ var sizes = ['', '万', '亿', '万亿'];
54
+ if (value < k) {
55
+ return value.toString();
56
+ }
57
+ else {
58
+ var i = Math.floor(Math.log(value) / Math.log(k));
59
+ return ((value / Math.pow(k, i))).toFixed(fixed) + sizes[i];
60
+ }
61
+ }
62
+ /**
63
+ * "," 分割字符串成数组
64
+ * @param str 字符串
65
+ */
66
+ static stringToArray1(str) {
67
+ if (str == "") {
68
+ return [];
69
+ }
70
+ return str.split(",");
71
+ }
72
+ /**
73
+ * "|" 分割字符串成数组
74
+ * @param str 字符串
75
+ */
76
+ static stringToArray2(str) {
77
+ if (str == "") {
78
+ return [];
79
+ }
80
+ return str.split("|");
81
+ }
82
+ /**
83
+ * ":" 分割字符串成数组
84
+ * @param str 字符串
85
+ */
86
+ static stringToArray3(str) {
87
+ if (str == "") {
88
+ return [];
89
+ }
90
+ return str.split(":");
91
+ }
92
+ /**
93
+ * ";" 分割字符串成数组
94
+ * @param str 字符串
95
+ */
96
+ static stringToArray4(str) {
97
+ if (str == "") {
98
+ return [];
99
+ }
100
+ return str.split(";");
101
+ }
102
+ /**
103
+ * 字符串截取
104
+ * @param str 字符串
105
+ * @param n 截取长度
106
+ * @param showdot 是否把截取的部分用省略号代替
107
+ */
108
+ static sub(str, n, showdot = false) {
109
+ var r = /[^\x00-\xff]/g;
110
+ if (str.replace(r, "mm").length <= n) {
111
+ return str;
112
+ }
113
+ var m = Math.floor(n / 2);
114
+ for (var i = m; i < str.length; i++) {
115
+ if (str.substr(0, i).replace(r, "mm").length >= n) {
116
+ if (showdot) {
117
+ return str.substr(0, i) + "...";
118
+ }
119
+ else {
120
+ return str.substr(0, i);
121
+ }
122
+ }
123
+ }
124
+ return str;
125
+ }
126
+ /**
127
+ * 计算字符串长度,中文算两个字节
128
+ * @param str 字符串
129
+ */
130
+ static stringLen(str) {
131
+ var realLength = 0, len = str.length, charCode = -1;
132
+ for (var i = 0; i < len; i++) {
133
+ charCode = str.charCodeAt(i);
134
+ if (charCode >= 0 && charCode <= 128)
135
+ realLength += 1;
136
+ else
137
+ realLength += 2;
138
+ }
139
+ return realLength;
140
+ }
141
+ /**
142
+ * 截取字符串,显示省略号
143
+ * @param str
144
+ * @param len
145
+ */
146
+ static ellipsisString(str, maxChars) {
147
+ if (this.isEmptyOrWhiteSpace(str))
148
+ return "";
149
+ if (str.length > maxChars) {
150
+ let truncatedText = str.substring(0, maxChars);
151
+ return `${truncatedText}...`;
152
+ }
153
+ else {
154
+ return str;
155
+ }
156
+ }
157
+ /**
158
+ * 是否为空或者空格
159
+ * @param str
160
+ */
161
+ static isEmptyOrWhiteSpace(str) {
162
+ return !str || str.trim() == '';
163
+ }
164
+ /**
165
+ * 参数替换
166
+ * @param str
167
+ * @param rest
168
+ *
169
+ * @example
170
+ *
171
+ * var str:string = "here is some info '{0}' and {1}";
172
+ * StringUtil.substitute(str, 15.4, true);
173
+ * "here is some info '15.4' and true"
174
+ *
175
+ * const result = substitute("Hello, {name}! Today is {day}.", "John Doe", "Monday");
176
+ * console.log(result); // 输出: Hello, John Doe! Today is Monday.
177
+ *
178
+ * const result2 = substitute("The value of {abc} is {num} and the variable {xyz} has the value {value}.", {abc: 123, num: "456", xyz: "789", value: "hello"});
179
+ * console.log(result2); // 输出: The value of 123 is 456 and the variable 789 has the value hello.
180
+ */
181
+ static substitute(str, ...rest) {
182
+ if (str == null)
183
+ return '';
184
+ var args;
185
+ let parseByDic = rest.length == 1 && ObjectUtil.isObjectLiteral(rest[0]);
186
+ if (parseByDic || (rest.length == 1 && rest[0] instanceof Array)) {
187
+ args = rest[0];
188
+ }
189
+ else {
190
+ args = rest;
191
+ }
192
+ // 创建一个正则表达式来匹配所有的大括号占位符
193
+ const placeholderRegex = /\{([\w-]+)\}/g;
194
+ if (parseByDic) {
195
+ return str.replace(placeholderRegex, (match, key) => {
196
+ return args[key];
197
+ });
198
+ }
199
+ else {
200
+ // 构建一个映射,将大括号中的内容映射到实际值
201
+ const placeholders = new Map();
202
+ let match = str.matchAll(placeholderRegex);
203
+ let i = 0;
204
+ for (const element of match) {
205
+ placeholders.set(element[0], args[i]);
206
+ i++;
207
+ }
208
+ // 使用映射替换占位符
209
+ return str.replace(placeholderRegex, (match, key) => {
210
+ const replacement = placeholders.get(match);
211
+ return replacement !== undefined ? replacement : match;
212
+ });
213
+ }
214
+ }
215
+ /**
216
+ * 获取字符串中指定字符的全部索引
217
+ * @param mainStr
218
+ * @param subStr
219
+ * @returns
220
+ */
221
+ static findAllSubstringsIndexes(mainStr, subStr) {
222
+ const indexes = [];
223
+ let currentIndex = mainStr.indexOf(subStr);
224
+ while (currentIndex !== -1) {
225
+ indexes.push(currentIndex);
226
+ currentIndex = mainStr.indexOf(subStr, currentIndex + subStr.length);
227
+ }
228
+ return indexes;
229
+ }
230
+ /**
231
+ * 用于将英文文本包围在 Unicode RLE 和 PDF 字符中,以确保其在 RTL 文本中正确显示
232
+ * @param text
233
+ * @returns
234
+ */
235
+ static surroundLTRWithUnicode(text) {
236
+ // 使用正则表达式匹配连续的英文单词,并在其前后添加 \u202B 和 \u202C
237
+ return text.replace(/([a-zA-Z\s]+)/g, (match) => {
238
+ // 检查匹配到的字符串是否包含英文字符
239
+ if (/[a-zA-Z]/.test(match)) {
240
+ return `\u202B${match}\u202C`;
241
+ }
242
+ return match;
243
+ });
244
+ }
245
+ /**
246
+ * 判断字符是否为双字节字符(如中文字符)
247
+ * @param string 原字符串
248
+ */
249
+ static isDoubleWord(string) {
250
+ return /[^\x00-\xff]/.test(string);
251
+ }
252
252
  }
253
253
 
254
254
  export { StringUtil };
@@ -1,31 +1,31 @@
1
- /** 时间工具 */
2
- export declare class TimeUtil {
3
- /** 间隔天数 */
4
- static daysBetween(time1: number | string | Date, time2: number | string | Date): number;
5
- /** 间隔秒数 */
6
- static secsBetween(time1: number, time2: number): number;
7
- /**
8
- * 检查和上一次时间相比是否是新的一天
9
- * @param lastCheck 上一次检查时间
10
- * @returns
11
- */
12
- static isNewDay(lastCheck?: any): boolean;
13
- /**
14
- * 把时间格式化为00:00:00
15
- * @param seconds 时间
16
- * @returns
17
- */
18
- static format1(seconds: number): string;
19
- /**
20
- * 时间格式化
21
- * @param date 时间对象
22
- * @param fmt 格式化字符(yyyy-MM-dd hh:mm:ss S)
23
- */
24
- static format2(date: Date, fmt: string): string;
25
- /**
26
- * 把时间戳转换为xx.xx.xx
27
- * @param timestamp 时间戳
28
- * @returns
29
- */
30
- static format3(timestamp: number): string;
31
- }
1
+ /** 时间工具 */
2
+ export declare class TimeUtil {
3
+ /** 间隔天数 */
4
+ static daysBetween(time1: number | string | Date, time2: number | string | Date): number;
5
+ /** 间隔秒数 */
6
+ static secsBetween(time1: number, time2: number): number;
7
+ /**
8
+ * 检查和上一次时间相比是否是新的一天
9
+ * @param lastCheck 上一次检查时间
10
+ * @returns
11
+ */
12
+ static isNewDay(lastCheck?: any): boolean;
13
+ /**
14
+ * 把时间格式化为00:00:00
15
+ * @param seconds 时间
16
+ * @returns
17
+ */
18
+ static format1(seconds: number): string;
19
+ /**
20
+ * 时间格式化
21
+ * @param date 时间对象
22
+ * @param fmt 格式化字符(yyyy-MM-dd hh:mm:ss S)
23
+ */
24
+ static format2(date: Date, fmt: string): string;
25
+ /**
26
+ * 把时间戳转换为xx.xx.xx
27
+ * @param timestamp 时间戳
28
+ * @returns
29
+ */
30
+ static format3(timestamp: number): string;
31
+ }