clickgo 3.1.3-dev12 → 3.1.5-dev14
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/README.md +1 -1
- package/dist/app/demo/app.js +1 -1
- package/dist/app/demo/config.json +9 -2
- package/dist/app/demo/form/control/text/text.js +1 -0
- package/dist/app/demo/form/control/text/text.xml +1 -1
- package/dist/app/demo/form/event/other/other.js +29 -0
- package/dist/app/demo/form/event/other/other.xml +5 -0
- package/dist/app/demo/form/main.js +51 -51
- package/dist/app/demo/form/main.xml +1 -0
- package/dist/app/demo/form/method/aform/aform.js +2 -13
- package/dist/app/demo/form/method/aform/aform.xml +0 -1
- package/dist/app/demo/form/method/aform/sd.js +25 -0
- package/dist/app/demo/form/method/aform/{test.xml → sd.xml} +3 -2
- package/dist/app/demo/form/method/core/core.js +12 -0
- package/dist/app/demo/form/method/core/core.xml +4 -0
- package/dist/app/demo/form/method/form/form.js +5 -6
- package/dist/app/demo/form/method/form/form.xml +1 -0
- package/dist/app/demo/form/method/form/test.xml +5 -0
- package/dist/app/demo/form/method/fs/fs.js +1 -4
- package/dist/app/demo/form/method/task/task.js +9 -1
- package/dist/app/demo/form/method/task/task.xml +1 -0
- package/dist/app/demo/form/method/tool/tool.js +3 -0
- package/dist/app/demo/form/method/tool/tool.xml +1 -0
- package/dist/app/demo/form/method/zip/zip.js +1 -4
- package/dist/app/task/app.js +1 -1
- package/dist/control/common.cgc +0 -0
- package/dist/control/form.cgc +0 -0
- package/dist/control/monaco.cgc +0 -0
- package/dist/control/property.cgc +0 -0
- package/dist/control/task.cgc +0 -0
- package/dist/global.css +1 -1
- package/dist/index.js +3 -0
- package/dist/index.ts +6 -0
- package/dist/lib/core.js +59 -10
- package/dist/lib/core.ts +67 -10
- package/dist/lib/dom.js +3 -3
- package/dist/lib/dom.ts +4 -4
- package/dist/lib/form.js +240 -215
- package/dist/lib/form.ts +290 -249
- package/dist/lib/fs.js +107 -12
- package/dist/lib/fs.ts +111 -20
- package/dist/lib/native.js +8 -1
- package/dist/lib/native.ts +6 -0
- package/dist/lib/task.js +253 -14
- package/dist/lib/task.ts +298 -12
- package/dist/lib/tool.js +39 -1
- package/dist/lib/tool.ts +45 -0
- package/dist/theme/familiar.cgt +0 -0
- package/package.json +3 -3
- package/types/index.d.ts +70 -52
package/dist/lib/task.ts
CHANGED
|
@@ -266,7 +266,7 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
266
266
|
const unblock = opt.unblock ? tool.clone(opt.unblock) : [];
|
|
267
267
|
const unblockSys = [
|
|
268
268
|
'require',
|
|
269
|
-
'__awaiter', 'eval', 'Math', 'Array', 'Blob', 'Error', 'Infinity', 'parseInt', 'parseFloat', 'Promise', 'Date', 'JSON', 'fetch'
|
|
269
|
+
'__awaiter', 'eval', 'Math', 'Array', 'Blob', 'Error', 'Infinity', 'parseInt', 'parseFloat', 'Promise', 'Date', 'JSON', 'fetch', 'Number'
|
|
270
270
|
];
|
|
271
271
|
for (const name of unblockSys) {
|
|
272
272
|
if (unblock.includes(name)) {
|
|
@@ -306,8 +306,65 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
306
306
|
}
|
|
307
307
|
// --- console ---
|
|
308
308
|
invoke.console = {
|
|
309
|
-
|
|
310
|
-
console.
|
|
309
|
+
assert: function(condition?: boolean, ...data: any[]): void {
|
|
310
|
+
console.assert(condition, ...data);
|
|
311
|
+
},
|
|
312
|
+
clear: function(): void {
|
|
313
|
+
console.clear();
|
|
314
|
+
},
|
|
315
|
+
count: function(label?: string): void {
|
|
316
|
+
console.count(label);
|
|
317
|
+
},
|
|
318
|
+
countReset: function(label?: string): void {
|
|
319
|
+
console.countReset(label);
|
|
320
|
+
},
|
|
321
|
+
debug: function(...data: any[]): void {
|
|
322
|
+
console.debug(...data);
|
|
323
|
+
},
|
|
324
|
+
dir: function(item?: any, options?: any): void {
|
|
325
|
+
console.dir(item, options);
|
|
326
|
+
},
|
|
327
|
+
dirxml: function(...data: any[]): void {
|
|
328
|
+
console.dirxml(...data);
|
|
329
|
+
},
|
|
330
|
+
error: function(...data: any[]): void {
|
|
331
|
+
console.error(...data);
|
|
332
|
+
},
|
|
333
|
+
group: function(...data: any[]): void {
|
|
334
|
+
console.group(...data);
|
|
335
|
+
},
|
|
336
|
+
groupCollapsed: function(...data: any[]): void {
|
|
337
|
+
console.groupCollapsed(...data);
|
|
338
|
+
},
|
|
339
|
+
groupEnd: function(): void {
|
|
340
|
+
console.groupEnd();
|
|
341
|
+
},
|
|
342
|
+
info: function(...data: any[]): void {
|
|
343
|
+
console.info(...data);
|
|
344
|
+
},
|
|
345
|
+
log: function(...data: any[]): void {
|
|
346
|
+
console.log(...data);
|
|
347
|
+
},
|
|
348
|
+
table: function(tabularData?: any, properties?: string[]): void {
|
|
349
|
+
console.table(tabularData, properties);
|
|
350
|
+
},
|
|
351
|
+
time: function(label?: string): void {
|
|
352
|
+
console.time(label);
|
|
353
|
+
},
|
|
354
|
+
timeEnd: function(label?: string): void {
|
|
355
|
+
console.timeEnd(label);
|
|
356
|
+
},
|
|
357
|
+
timeLog: function(label?: string, ...data: any[]): void {
|
|
358
|
+
console.timeLog(label, ...data);
|
|
359
|
+
},
|
|
360
|
+
timeStamp: function(label?: string): void {
|
|
361
|
+
console.timeStamp(label);
|
|
362
|
+
},
|
|
363
|
+
trace: function(...data: any[]): void {
|
|
364
|
+
console.trace(...data);
|
|
365
|
+
},
|
|
366
|
+
warn: function(...data: any[]): void {
|
|
367
|
+
console.warn(...data);
|
|
311
368
|
}
|
|
312
369
|
};
|
|
313
370
|
// --- loader ---
|
|
@@ -394,6 +451,9 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
394
451
|
},
|
|
395
452
|
getAvailArea: function(): types.IAvailArea {
|
|
396
453
|
return core.getAvailArea();
|
|
454
|
+
},
|
|
455
|
+
hash: function(hash: string): boolean {
|
|
456
|
+
return core.hash(hash, taskId);
|
|
397
457
|
}
|
|
398
458
|
},
|
|
399
459
|
'dom': {
|
|
@@ -572,6 +632,17 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
572
632
|
hidePop: function(pop?: HTMLElement): void {
|
|
573
633
|
form.hidePop(pop);
|
|
574
634
|
},
|
|
635
|
+
create: function<T extends form.AbstractForm>(
|
|
636
|
+
cls: string | (new () => T),
|
|
637
|
+
data?: Record<string, any>,
|
|
638
|
+
opt?: {
|
|
639
|
+
'layout'?: string;
|
|
640
|
+
'style'?: string;
|
|
641
|
+
'path'?: string;
|
|
642
|
+
}
|
|
643
|
+
): Promise<T> {
|
|
644
|
+
return form.create(cls, data, opt, taskId);
|
|
645
|
+
},
|
|
575
646
|
dialog: function(opt: string | types.IFormDialogOptions): Promise<string> {
|
|
576
647
|
if (typeof opt === 'string') {
|
|
577
648
|
opt = {
|
|
@@ -613,7 +684,7 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
613
684
|
}
|
|
614
685
|
return fs.getContent(path, options);
|
|
615
686
|
},
|
|
616
|
-
putContent: function(path: string, data: string |
|
|
687
|
+
putContent: function(path: string, data: string | Blob, options: any = {}) {
|
|
617
688
|
if (!options.current) {
|
|
618
689
|
options.current = list[taskId].current;
|
|
619
690
|
}
|
|
@@ -745,17 +816,40 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
745
816
|
return native.invoke(name, ...param);
|
|
746
817
|
},
|
|
747
818
|
max: async function(): Promise<void> {
|
|
819
|
+
const rtn = await checkPermission('native.form', false, undefined, taskId);
|
|
820
|
+
if (!rtn[0]) {
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
748
823
|
await native.max();
|
|
749
824
|
},
|
|
750
825
|
min: async function(): Promise<void> {
|
|
826
|
+
const rtn = await checkPermission('native.form', false, undefined, taskId);
|
|
827
|
+
if (!rtn[0]) {
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
751
830
|
await native.min();
|
|
752
831
|
},
|
|
753
832
|
restore: async function(): Promise<void> {
|
|
833
|
+
const rtn = await checkPermission('native.form', false, undefined, taskId);
|
|
834
|
+
if (!rtn[0]) {
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
754
837
|
await native.restore();
|
|
755
838
|
},
|
|
756
839
|
size: async function(width: number, height: number): Promise<void> {
|
|
840
|
+
const rtn = await checkPermission('native.form', false, undefined, taskId);
|
|
841
|
+
if (!rtn[0]) {
|
|
842
|
+
return;
|
|
843
|
+
}
|
|
757
844
|
await native.size(width, height);
|
|
758
845
|
},
|
|
846
|
+
maximizable: async function(val: boolean): Promise<void> {
|
|
847
|
+
const rtn = await checkPermission('native.form', false, undefined, taskId);
|
|
848
|
+
if (!rtn[0]) {
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
await native.maximizable(val);
|
|
852
|
+
},
|
|
759
853
|
ping: function(val: string): Promise<string> {
|
|
760
854
|
return native.ping(val);
|
|
761
855
|
},
|
|
@@ -796,8 +890,20 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
796
890
|
}
|
|
797
891
|
opt.unblock = inUnblock;
|
|
798
892
|
}
|
|
893
|
+
if (opt.permissions) {
|
|
894
|
+
if (ntask && !ntask.runtime.permissions.includes('root')) {
|
|
895
|
+
opt.permissions = undefined;
|
|
896
|
+
}
|
|
897
|
+
}
|
|
799
898
|
return run(url, opt);
|
|
800
899
|
},
|
|
900
|
+
checkPermission: function(
|
|
901
|
+
vals: string | string[],
|
|
902
|
+
apply: boolean = false,
|
|
903
|
+
applyHandler?: (list: string[]) => void | Promise<void>
|
|
904
|
+
): Promise<boolean[]> {
|
|
905
|
+
return checkPermission(vals, apply, applyHandler, taskId);
|
|
906
|
+
},
|
|
801
907
|
end: function(tid: number): boolean {
|
|
802
908
|
return end(tid ?? taskId);
|
|
803
909
|
},
|
|
@@ -910,6 +1016,9 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
910
1016
|
escapeHTML: function(html: string): string {
|
|
911
1017
|
return tool.escapeHTML(html);
|
|
912
1018
|
},
|
|
1019
|
+
rgb2hsl: function(rgb: string): number[] {
|
|
1020
|
+
return tool.rgb2hsl(rgb);
|
|
1021
|
+
},
|
|
913
1022
|
request: function(url: string, opt: types.IRequestOptions): Promise<null | any> {
|
|
914
1023
|
return tool.request(url, opt);
|
|
915
1024
|
},
|
|
@@ -919,6 +1028,9 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
919
1028
|
urlResolve: function(from: string, to: string): string {
|
|
920
1029
|
return tool.urlResolve(from, to);
|
|
921
1030
|
},
|
|
1031
|
+
urlAtom: function(url: string): string {
|
|
1032
|
+
return tool.urlAtom(url);
|
|
1033
|
+
},
|
|
922
1034
|
blob2Text: function(blob: Blob): Promise<string> {
|
|
923
1035
|
return tool.blob2Text(blob);
|
|
924
1036
|
},
|
|
@@ -972,8 +1084,8 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
972
1084
|
'current': current,
|
|
973
1085
|
|
|
974
1086
|
'runtime': clickgo.vue.reactive({
|
|
975
|
-
'
|
|
976
|
-
'
|
|
1087
|
+
'dialogFormIds': [],
|
|
1088
|
+
'permissions': opt.permissions ?? []
|
|
977
1089
|
}),
|
|
978
1090
|
'forms': {},
|
|
979
1091
|
'controls': {},
|
|
@@ -1006,13 +1118,17 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
1006
1118
|
}
|
|
1007
1119
|
let expo: any = [];
|
|
1008
1120
|
try {
|
|
1121
|
+
const map = {
|
|
1122
|
+
'clickgo': '/invoke/clickgo'
|
|
1123
|
+
};
|
|
1124
|
+
if (app.config.map) {
|
|
1125
|
+
Object.assign(map, app.config.map);
|
|
1126
|
+
}
|
|
1009
1127
|
expo = loader.require('/app.js', app.files, {
|
|
1010
1128
|
'dir': '/',
|
|
1011
1129
|
'invoke': invoke,
|
|
1012
1130
|
'preprocess': preprocess,
|
|
1013
|
-
'map':
|
|
1014
|
-
'clickgo': '/invoke/clickgo'
|
|
1015
|
-
}
|
|
1131
|
+
'map': map
|
|
1016
1132
|
})[0];
|
|
1017
1133
|
}
|
|
1018
1134
|
catch (e: any) {
|
|
@@ -1070,9 +1186,9 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
1070
1186
|
}
|
|
1071
1187
|
// --- 触发 taskStarted 事件 ---
|
|
1072
1188
|
core.trigger('taskStarted', taskId);
|
|
1073
|
-
// ---
|
|
1074
|
-
if (
|
|
1075
|
-
await
|
|
1189
|
+
// --- 请求权限 ---
|
|
1190
|
+
if (app.config.permissions) {
|
|
1191
|
+
await checkPermission(app.config.permissions, true, undefined, taskId);
|
|
1076
1192
|
}
|
|
1077
1193
|
// --- 执行 app ---
|
|
1078
1194
|
const appCls: core.AbstractApp = new expo.default();
|
|
@@ -1081,6 +1197,176 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
1081
1197
|
return taskId;
|
|
1082
1198
|
}
|
|
1083
1199
|
|
|
1200
|
+
/** --- 本页用到的语言包 --- */
|
|
1201
|
+
const locale: Record<string, {
|
|
1202
|
+
'unknown': string;
|
|
1203
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1204
|
+
'apply-permission': string;
|
|
1205
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1206
|
+
'native.form': string;
|
|
1207
|
+
'hash': string;
|
|
1208
|
+
'fs': string;
|
|
1209
|
+
'readonly': string;
|
|
1210
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1211
|
+
'read-write': string;
|
|
1212
|
+
}> = {
|
|
1213
|
+
'sc': {
|
|
1214
|
+
'unknown': '未知权限',
|
|
1215
|
+
'apply-permission': '正在申请权限,请您仔细确认',
|
|
1216
|
+
'native.form': '实体窗体控制',
|
|
1217
|
+
'hash': '可修改地址栏 hash',
|
|
1218
|
+
'fs': '文件系统',
|
|
1219
|
+
'readonly': '只读',
|
|
1220
|
+
'read-write': '读写'
|
|
1221
|
+
},
|
|
1222
|
+
'tc': {
|
|
1223
|
+
'unknown': '未知許可權',
|
|
1224
|
+
'apply-permission': '正在申請許可權,請您仔細確認',
|
|
1225
|
+
'native.form': '實體視窗控制',
|
|
1226
|
+
'hash': '可修改位址列 hash',
|
|
1227
|
+
'fs': '檔案系統',
|
|
1228
|
+
'readonly': '唯讀',
|
|
1229
|
+
'read-write': '讀寫'
|
|
1230
|
+
},
|
|
1231
|
+
'en': {
|
|
1232
|
+
'unknown': 'Unknown',
|
|
1233
|
+
'apply-permission': 'is applying for permissions, please check carefully',
|
|
1234
|
+
'native.form': 'Native window control',
|
|
1235
|
+
'hash': 'Can modify the location hash',
|
|
1236
|
+
'fs': 'File system',
|
|
1237
|
+
'readonly': 'Read only',
|
|
1238
|
+
'read-write': 'Read and write'
|
|
1239
|
+
},
|
|
1240
|
+
'ja': {
|
|
1241
|
+
'unknown': '不明な許可',
|
|
1242
|
+
'apply-permission': '許可申請中、よくご確認ください',
|
|
1243
|
+
'native.form': 'ローカルウィンドウを操作する',
|
|
1244
|
+
'hash': '網址の hash 変更可能',
|
|
1245
|
+
'fs': '資料システム',
|
|
1246
|
+
'readonly': '読み取り専用',
|
|
1247
|
+
'read-write': '読み書き'
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1250
|
+
|
|
1251
|
+
// fs.{path}{r/w},path 以 / 结尾则是路径权限,不以 / 结尾是文件权限
|
|
1252
|
+
|
|
1253
|
+
/**
|
|
1254
|
+
* --- 检测应用是否有相应的权限 ---
|
|
1255
|
+
* @param vals 要检测的权限
|
|
1256
|
+
* @param apply 如果没有权限是否自动弹出申请,默认为否
|
|
1257
|
+
* @param applyHandler 向用户申请成功的权限列表回调
|
|
1258
|
+
* @param taskId 要检查的任务 ID,App 模式下无效
|
|
1259
|
+
*/
|
|
1260
|
+
export async function checkPermission(
|
|
1261
|
+
vals: string | string[],
|
|
1262
|
+
apply: boolean = false,
|
|
1263
|
+
applyHandler?: (list: string[]) => void | Promise<void>,
|
|
1264
|
+
taskId?: number
|
|
1265
|
+
): Promise<boolean[]> {
|
|
1266
|
+
if (!taskId) {
|
|
1267
|
+
return [false];
|
|
1268
|
+
}
|
|
1269
|
+
const task = list[taskId];
|
|
1270
|
+
if (!task) {
|
|
1271
|
+
return [false];
|
|
1272
|
+
}
|
|
1273
|
+
if (typeof vals === 'string') {
|
|
1274
|
+
vals = [vals];
|
|
1275
|
+
}
|
|
1276
|
+
const rtn: boolean[] = [];
|
|
1277
|
+
/** --- 需要申请的权限 --- */
|
|
1278
|
+
const applyList: string[] = [];
|
|
1279
|
+
for (const val of vals) {
|
|
1280
|
+
if (task.runtime.permissions.includes('root')) {
|
|
1281
|
+
// --- 有 root 权限,一定成功 ---
|
|
1282
|
+
rtn.push(true);
|
|
1283
|
+
continue;
|
|
1284
|
+
}
|
|
1285
|
+
if (val.startsWith('fs.')) {
|
|
1286
|
+
// --- fs 判断比较特殊 ---
|
|
1287
|
+
let yes = false;
|
|
1288
|
+
const path = val.slice(3, -1);
|
|
1289
|
+
for (const v of task.runtime.permissions) {
|
|
1290
|
+
if (!v.startsWith('fs.')) {
|
|
1291
|
+
continue;
|
|
1292
|
+
}
|
|
1293
|
+
const pa = v.slice(3, -1);
|
|
1294
|
+
if (pa.endsWith('/')) {
|
|
1295
|
+
if (!path.startsWith(pa)) {
|
|
1296
|
+
continue;
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
else if (pa !== path) {
|
|
1300
|
+
continue;
|
|
1301
|
+
}
|
|
1302
|
+
// --- 找到了 ---
|
|
1303
|
+
if (val.endsWith('w')) {
|
|
1304
|
+
// --- 用户要求读写 ---
|
|
1305
|
+
if (v.endsWith('r')) {
|
|
1306
|
+
// --- 但目前只有读的权限 ---
|
|
1307
|
+
continue;
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
// --- 正常,有权限 ---
|
|
1311
|
+
yes = true;
|
|
1312
|
+
break;
|
|
1313
|
+
}
|
|
1314
|
+
rtn.push(yes);
|
|
1315
|
+
if (!yes && apply) {
|
|
1316
|
+
// --- 要申请权限 ---
|
|
1317
|
+
applyList.push(val);
|
|
1318
|
+
}
|
|
1319
|
+
continue;
|
|
1320
|
+
}
|
|
1321
|
+
// --- 其他权限判断 ---
|
|
1322
|
+
const result = task.runtime.permissions.includes(val);
|
|
1323
|
+
if (!result && apply) {
|
|
1324
|
+
// --- 要申请权限 ---
|
|
1325
|
+
applyList.push(val);
|
|
1326
|
+
}
|
|
1327
|
+
rtn.push(result);
|
|
1328
|
+
}
|
|
1329
|
+
// --- 申请权限 ---
|
|
1330
|
+
if (applyList.length) {
|
|
1331
|
+
let html = '<div>"' + tool.escapeHTML(task.app.config.name) + '" ' + ((locale[core.config.locale]?.['apply-permission'] ?? locale['en']['apply-permission']) + ':') + '</div>';
|
|
1332
|
+
for (const item of applyList) {
|
|
1333
|
+
if (item.startsWith('fs.')) {
|
|
1334
|
+
// --- fs 判断比较特殊 ---
|
|
1335
|
+
const path = item.slice(3, -1);
|
|
1336
|
+
html += '<div style="margin-top: 10px;">' +
|
|
1337
|
+
(locale[core.config.locale]?.fs ?? locale['en'].fs) + ' ' + tool.escapeHTML(path) + ' ' + (item.endsWith('r') ? (locale[core.config.locale]?.readonly ?? locale['en'].readonly) : (locale[core.config.locale]?.['read-write'] ?? locale['en']['read-write'])) +
|
|
1338
|
+
'<div style="color: var(--system-border-color);">' + tool.escapeHTML(item) + '</div>' +
|
|
1339
|
+
'</div>';
|
|
1340
|
+
continue;
|
|
1341
|
+
}
|
|
1342
|
+
const lang = (locale as any)[core.config.locale]?.[item] ?? (locale as any)['en'][item];
|
|
1343
|
+
html += '<div style="margin-top: 10px;">' +
|
|
1344
|
+
(lang ?? locale[core.config.locale]?.unknown ?? locale['en'].unknown) +
|
|
1345
|
+
'<div style="color: var(--system-border-color);">' + tool.escapeHTML(item) + '</div>' +
|
|
1346
|
+
'</div>';
|
|
1347
|
+
}
|
|
1348
|
+
if (await form.superConfirm(html)) {
|
|
1349
|
+
// --- 所有 false 变成 true ---
|
|
1350
|
+
for (let i = 0; i < rtn.length; ++i) {
|
|
1351
|
+
if (rtn[i]) {
|
|
1352
|
+
continue;
|
|
1353
|
+
}
|
|
1354
|
+
rtn[i] = true;
|
|
1355
|
+
}
|
|
1356
|
+
for (const item of applyList) {
|
|
1357
|
+
task.runtime.permissions.push(item);
|
|
1358
|
+
}
|
|
1359
|
+
try {
|
|
1360
|
+
applyHandler?.(applyList) as any;
|
|
1361
|
+
}
|
|
1362
|
+
catch (e) {
|
|
1363
|
+
console.log('task.checkPermission', e);
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
return rtn;
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1084
1370
|
/**
|
|
1085
1371
|
* --- 完全结束任务 ---
|
|
1086
1372
|
* @param taskId 任务 id
|
package/dist/lib/tool.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.execCommand = exports.blob2DataUrl = exports.blob2Text = exports.urlResolve = exports.parseUrl = exports.request = exports.escapeHTML = exports.getArray = exports.getNumber = exports.getBoolean = exports.random = exports.RANDOM_LUNS = exports.RANDOM_V = exports.RANDOM_LUN = exports.RANDOM_LU = exports.RANDOM_LN = exports.RANDOM_UN = exports.RANDOM_L = exports.RANDOM_U = exports.RANDOM_N = exports.rand = exports.getMimeByPath = exports.stylePrepend = exports.teleportGlue = exports.eventsAttrWrap = exports.layoutClassPrepend = exports.layoutInsertAttr = exports.layoutAddTagClassAndReTagName = exports.styleUrl2DataUrl = exports.purify = exports.sleepFrame = exports.nextFrame = exports.sleep = exports.clone = exports.blob2ArrayBuffer = exports.getClassPrototype = void 0;
|
|
12
|
+
exports.execCommand = exports.blob2DataUrl = exports.blob2Text = exports.urlAtom = exports.urlResolve = exports.parseUrl = exports.request = exports.rgb2hsl = exports.escapeHTML = exports.getArray = exports.getNumber = exports.getBoolean = exports.random = exports.RANDOM_LUNS = exports.RANDOM_V = exports.RANDOM_LUN = exports.RANDOM_LU = exports.RANDOM_LN = exports.RANDOM_UN = exports.RANDOM_L = exports.RANDOM_U = exports.RANDOM_N = exports.rand = exports.getMimeByPath = exports.stylePrepend = exports.teleportGlue = exports.eventsAttrWrap = exports.layoutClassPrepend = exports.layoutInsertAttr = exports.layoutAddTagClassAndReTagName = exports.styleUrl2DataUrl = exports.purify = exports.sleepFrame = exports.nextFrame = exports.sleep = exports.clone = exports.blob2ArrayBuffer = exports.getClassPrototype = void 0;
|
|
13
13
|
function getClassPrototype(obj, over = [], level = 0) {
|
|
14
14
|
if (level === 0) {
|
|
15
15
|
return getClassPrototype(Object.getPrototypeOf(obj), over, level + 1);
|
|
@@ -430,6 +430,40 @@ function escapeHTML(html) {
|
|
|
430
430
|
return html.replace(/</g, '<').replace(/>/g, '>');
|
|
431
431
|
}
|
|
432
432
|
exports.escapeHTML = escapeHTML;
|
|
433
|
+
function rgb2hsl(rgb) {
|
|
434
|
+
if (rgb.includes('(')) {
|
|
435
|
+
const match = /[0-9., ]+/.exec(rgb);
|
|
436
|
+
if (!match) {
|
|
437
|
+
return [0, 0, 0];
|
|
438
|
+
}
|
|
439
|
+
rgb = match[0];
|
|
440
|
+
}
|
|
441
|
+
const arr = rgb.split(',');
|
|
442
|
+
const [r, g, b] = arr.map(v => parseInt(v) / 255);
|
|
443
|
+
const max = Math.max(r, g, b);
|
|
444
|
+
const min = Math.min(r, g, b);
|
|
445
|
+
const diff = max - min;
|
|
446
|
+
let h = 0;
|
|
447
|
+
const l = (max + min) / 2;
|
|
448
|
+
const s2 = 1 - Math.abs(max + min - 1);
|
|
449
|
+
const s = s2 ? (diff / s2) : 0;
|
|
450
|
+
switch (min) {
|
|
451
|
+
case max:
|
|
452
|
+
h = 0;
|
|
453
|
+
break;
|
|
454
|
+
case r:
|
|
455
|
+
h = (60 * ((b - g) / diff)) + 180;
|
|
456
|
+
break;
|
|
457
|
+
case g:
|
|
458
|
+
h = (60 * ((r - b) / diff)) + 300;
|
|
459
|
+
break;
|
|
460
|
+
case b:
|
|
461
|
+
h = (60 * ((g - r) / diff)) + 60;
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
return [h, s, l];
|
|
465
|
+
}
|
|
466
|
+
exports.rgb2hsl = rgb2hsl;
|
|
433
467
|
function request(url, opt) {
|
|
434
468
|
return new Promise(function (resove) {
|
|
435
469
|
var _a;
|
|
@@ -541,6 +575,10 @@ function urlResolve(from, to) {
|
|
|
541
575
|
return loader.urlResolve(from, to);
|
|
542
576
|
}
|
|
543
577
|
exports.urlResolve = urlResolve;
|
|
578
|
+
function urlAtom(url) {
|
|
579
|
+
return loader.urlAtom(url);
|
|
580
|
+
}
|
|
581
|
+
exports.urlAtom = urlAtom;
|
|
544
582
|
function blob2Text(blob) {
|
|
545
583
|
return loader.blob2Text(blob);
|
|
546
584
|
}
|
package/dist/lib/tool.ts
CHANGED
|
@@ -573,6 +573,47 @@ export function escapeHTML(html: string): string {
|
|
|
573
573
|
return html.replace(/</g, '<').replace(/>/g, '>');
|
|
574
574
|
}
|
|
575
575
|
|
|
576
|
+
/**
|
|
577
|
+
* --- rgb 字符串转 hsl 数组 ---
|
|
578
|
+
* @param rgb rgb(x, x, x) 或直接 x,x,x
|
|
579
|
+
*/
|
|
580
|
+
export function rgb2hsl(rgb: string): number[] {
|
|
581
|
+
if (rgb.includes('(')) {
|
|
582
|
+
const match = /[0-9., ]+/.exec(rgb);
|
|
583
|
+
if (!match) {
|
|
584
|
+
return [0, 0, 0];
|
|
585
|
+
}
|
|
586
|
+
rgb = match[0];
|
|
587
|
+
}
|
|
588
|
+
const arr = rgb.split(',');
|
|
589
|
+
const [r, g, b] = arr.map(v => parseInt(v) / 255);
|
|
590
|
+
|
|
591
|
+
const max = Math.max(r, g, b);
|
|
592
|
+
const min = Math.min(r, g, b);
|
|
593
|
+
const diff = max - min;
|
|
594
|
+
|
|
595
|
+
let h = 0 ;
|
|
596
|
+
const l = (max + min) / 2;
|
|
597
|
+
const s2 = 1 - Math.abs(max + min - 1);
|
|
598
|
+
const s = s2 ? (diff / s2) : 0;
|
|
599
|
+
|
|
600
|
+
switch (min) {
|
|
601
|
+
case max:
|
|
602
|
+
h = 0 ;
|
|
603
|
+
break;
|
|
604
|
+
case r:
|
|
605
|
+
h = (60 * ((b - g) / diff)) + 180;
|
|
606
|
+
break;
|
|
607
|
+
case g:
|
|
608
|
+
h = (60 * ((r - b) / diff)) + 300;
|
|
609
|
+
break;
|
|
610
|
+
case b:
|
|
611
|
+
h = (60 * ((g - r) / diff)) + 60;
|
|
612
|
+
break;
|
|
613
|
+
}
|
|
614
|
+
return [h, s, l] ;
|
|
615
|
+
}
|
|
616
|
+
|
|
576
617
|
/**
|
|
577
618
|
* --- 发起一个网络请求 ---
|
|
578
619
|
* @param url 网址
|
|
@@ -680,6 +721,10 @@ export function urlResolve(from: string, to: string): string {
|
|
|
680
721
|
return loader.urlResolve(from, to);
|
|
681
722
|
}
|
|
682
723
|
|
|
724
|
+
export function urlAtom(url: string): string {
|
|
725
|
+
return loader.urlAtom(url);
|
|
726
|
+
}
|
|
727
|
+
|
|
683
728
|
export function blob2Text(blob: Blob): Promise<string> {
|
|
684
729
|
return loader.blob2Text(blob);
|
|
685
730
|
}
|
package/dist/theme/familiar.cgt
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clickgo",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5-dev14",
|
|
4
4
|
"description": "Background interface, software interface, mobile phone APP interface operation library.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deskrt",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@litert/eslint-plugin-rules": "^0.1.0",
|
|
22
|
-
"@litert/loader": "^3.4.
|
|
23
|
-
"@types/node": "^
|
|
22
|
+
"@litert/loader": "^3.4.4",
|
|
23
|
+
"@types/node": "^18.11.14",
|
|
24
24
|
"electron": "^19.1.3",
|
|
25
25
|
"typescript": "^4.8.4"
|
|
26
26
|
},
|