clickgo 3.1.4-dev13 → 3.1.6-dev15
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 +7 -7
- package/dist/app/demo/app.js +29 -3
- package/dist/app/demo/config.json +22 -3
- package/dist/app/demo/form/control/box/box.js +66 -0
- package/dist/app/demo/form/control/box/box.xml +18 -0
- package/dist/app/demo/form/control/button/button.js +24 -1
- package/dist/app/demo/form/control/check/check.js +24 -1
- package/dist/app/demo/form/control/dialog/dialog.js +24 -1
- package/dist/app/demo/form/control/file/file.js +24 -1
- package/dist/app/demo/form/control/flow/flow.js +24 -1
- package/dist/app/demo/form/control/form/form.js +24 -1
- package/dist/app/demo/form/control/layout/layout.js +57 -0
- package/dist/app/demo/form/control/layout/layout.xml +16 -0
- package/dist/app/demo/form/control/list/list.js +24 -1
- package/dist/app/demo/form/control/list/list.xml +8 -2
- package/dist/app/demo/form/control/marquee/marquee.js +24 -2
- package/dist/app/demo/form/control/marquee/marquee.xml +2 -5
- package/dist/app/demo/form/control/menu/menu.js +24 -1
- package/dist/app/demo/form/control/monaco/monaco.js +24 -1
- package/dist/app/demo/form/control/nav/nav.js +52 -0
- package/dist/app/demo/form/control/nav/nav.xml +43 -0
- package/dist/app/demo/form/control/panel/panel.js +67 -0
- package/dist/app/demo/form/control/panel/panel.xml +11 -0
- package/dist/app/demo/form/control/panel/test1.js +58 -0
- package/dist/app/demo/form/control/panel/test1.xml +16 -0
- package/dist/app/demo/form/control/panel/test2.xml +3 -0
- package/dist/app/demo/form/control/property/property.js +24 -1
- package/dist/app/demo/form/control/radio/radio.js +24 -1
- package/dist/app/demo/form/control/scroll/scroll.js +25 -1
- package/dist/app/demo/form/control/scroll/scroll.xml +5 -2
- package/dist/app/demo/form/control/select/select.js +24 -1
- package/dist/app/demo/form/control/tab/tab.js +24 -1
- package/dist/app/demo/form/control/table/table.js +164 -0
- package/dist/app/demo/form/control/table/table.xml +35 -0
- package/dist/app/demo/form/control/text/text.js +25 -1
- package/dist/app/demo/form/control/text/text.xml +1 -1
- package/dist/app/demo/form/control/vflow/vflow.js +24 -1
- package/dist/app/demo/form/event/form/form.js +24 -1
- package/dist/app/demo/form/event/other/other.js +24 -1
- package/dist/app/demo/form/event/screen/screen.js +24 -1
- package/dist/app/demo/form/event/task/task.js +24 -1
- package/dist/app/demo/form/main.js +130 -84
- package/dist/app/demo/form/main.xml +5 -0
- package/dist/app/demo/form/method/aform/aform.js +29 -15
- package/dist/app/demo/form/method/aform/aform.xml +0 -1
- package/dist/app/demo/form/method/aform/sd.js +25 -5
- package/dist/app/demo/form/method/core/core.js +24 -1
- package/dist/app/demo/form/method/dom/dom.js +48 -2
- package/dist/app/demo/form/method/dom/dom.xml +11 -0
- package/dist/app/demo/form/method/form/form.js +40 -7
- package/dist/app/demo/form/method/form/form.xml +3 -0
- package/dist/app/demo/form/method/{aform → form}/test.xml +0 -0
- package/dist/app/demo/form/method/fs/fs.js +139 -8
- package/dist/app/demo/form/method/fs/fs.xml +11 -1
- package/dist/app/demo/form/method/fs/text.js +24 -1
- package/dist/app/demo/form/method/native/native.js +24 -1
- package/dist/app/demo/form/method/system/system.js +24 -1
- package/dist/app/demo/form/method/task/task.js +31 -4
- package/dist/app/demo/form/method/task/task.xml +6 -1
- package/dist/app/demo/form/method/theme/theme.js +24 -1
- package/dist/app/demo/form/method/tool/tool.js +38 -1
- package/dist/app/demo/form/method/tool/tool.xml +1 -0
- package/dist/app/demo/form/method/zip/zip.js +30 -7
- package/dist/app/task/app.js +29 -3
- package/dist/app/task/form/bar/bar.js +24 -1
- package/dist/clickgo.js +33 -10
- package/dist/control/box.cgc +0 -0
- package/dist/control/common.cgc +0 -0
- package/dist/control/form.cgc +0 -0
- package/dist/control/monaco.cgc +0 -0
- package/dist/control/nav.cgc +0 -0
- package/dist/control/property.cgc +0 -0
- package/dist/control/table.cgc +0 -0
- package/dist/control/task.cgc +0 -0
- package/dist/global.css +1 -1
- package/dist/lib/control.js +53 -12
- package/dist/lib/control.ts +25 -5
- package/dist/lib/core.js +44 -50
- package/dist/lib/core.ts +18 -48
- package/dist/lib/dom.js +322 -108
- package/dist/lib/dom.ts +394 -127
- package/dist/lib/form.js +590 -226
- package/dist/lib/form.ts +706 -267
- package/dist/lib/fs.js +485 -224
- package/dist/lib/fs.ts +493 -287
- package/dist/lib/native.js +24 -1
- package/dist/lib/task.js +159 -139
- package/dist/lib/task.ts +148 -130
- package/dist/lib/theme.js +27 -4
- package/dist/lib/tool.js +57 -2
- package/dist/lib/tool.ts +68 -1
- package/dist/lib/zip.js +29 -3
- package/dist/lib/zip.ts +1 -1
- package/dist/theme/familiar.cgt +0 -0
- package/package.json +5 -7
- package/types/index.d.ts +51 -70
package/dist/lib/task.ts
CHANGED
|
@@ -119,7 +119,7 @@ export function onFrame(fun: () => void | Promise<void>, opt: {
|
|
|
119
119
|
// --- 接着循环 ---
|
|
120
120
|
timer = requestAnimationFrame(function() {
|
|
121
121
|
timerHandler().catch(function(e) {
|
|
122
|
-
console.log(e);
|
|
122
|
+
console.log('task.onFrame: -3', e);
|
|
123
123
|
});
|
|
124
124
|
});
|
|
125
125
|
frameMaps[ft] = timer;
|
|
@@ -134,7 +134,7 @@ export function onFrame(fun: () => void | Promise<void>, opt: {
|
|
|
134
134
|
// --- 无限循环 ---
|
|
135
135
|
timer = requestAnimationFrame(function() {
|
|
136
136
|
timerHandler().catch(function(e) {
|
|
137
|
-
console.log(e);
|
|
137
|
+
console.log('task.onFrame: -2', e);
|
|
138
138
|
});
|
|
139
139
|
});
|
|
140
140
|
frameMaps[ft] = timer;
|
|
@@ -143,7 +143,7 @@ export function onFrame(fun: () => void | Promise<void>, opt: {
|
|
|
143
143
|
/** --- timer 对象 number --- */
|
|
144
144
|
timer = requestAnimationFrame(function() {
|
|
145
145
|
timerHandler().catch(function(e) {
|
|
146
|
-
console.log(e);
|
|
146
|
+
console.log('task.onFrame: -1', e);
|
|
147
147
|
});
|
|
148
148
|
});
|
|
149
149
|
frameMaps[ft] = timer;
|
|
@@ -194,6 +194,17 @@ export function get(tid: number): types.ITaskInfo | null {
|
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
+
/**
|
|
198
|
+
* --- 获取某个任务的已授权权限列表 ---
|
|
199
|
+
* @param tid 任务 id
|
|
200
|
+
*/
|
|
201
|
+
export function getPermissions(tid: number): string[] {
|
|
202
|
+
if (list[tid] === undefined) {
|
|
203
|
+
return [];
|
|
204
|
+
}
|
|
205
|
+
return tool.clone(list[tid].runtime.permissions);
|
|
206
|
+
}
|
|
207
|
+
|
|
197
208
|
/**
|
|
198
209
|
* --- 获取 task list 的简略情况 ---
|
|
199
210
|
*/
|
|
@@ -218,13 +229,9 @@ export function getList(): Record<string, types.ITaskInfo> {
|
|
|
218
229
|
* --- 运行一个应用,cga 直接文件全部正常加载,url 则静态文件需要去 config 里加载 ---
|
|
219
230
|
* @param url app 路径(以 / 为结尾的路径或以 .cga 结尾的文件)
|
|
220
231
|
* @param opt 选项
|
|
232
|
+
* @param ntid App 模式下无效
|
|
221
233
|
*/
|
|
222
|
-
export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise<number> {
|
|
223
|
-
/** --- 是否是在任务当中启动的任务 --- */
|
|
224
|
-
let ntask: types.ITask | null = null;
|
|
225
|
-
if (opt.taskId) {
|
|
226
|
-
ntask = list[opt.taskId];
|
|
227
|
-
}
|
|
234
|
+
export async function run(url: string, opt: types.ITaskRunOptions = {}, ntid?: number): Promise<number> {
|
|
228
235
|
// --- 检测 url 是否合法 ---
|
|
229
236
|
if (!url.endsWith('/') && !url.endsWith('.cga')) {
|
|
230
237
|
return 0;
|
|
@@ -244,12 +251,21 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
244
251
|
'timeout': 0,
|
|
245
252
|
'progress': true
|
|
246
253
|
}) : undefined;
|
|
254
|
+
// --- 非 ntid 模式下 current 以 location 为准 ---
|
|
255
|
+
if (!ntid &&
|
|
256
|
+
!url.startsWith('/clickgo/') &&
|
|
257
|
+
!url.startsWith('/storage/') &&
|
|
258
|
+
!url.startsWith('/mounted/') &&
|
|
259
|
+
!url.startsWith('/package/') &&
|
|
260
|
+
!url.startsWith('/current/')
|
|
261
|
+
) {
|
|
262
|
+
url = tool.urlResolve(location.href, url);
|
|
263
|
+
}
|
|
247
264
|
// --- 获取并加载 app 对象 ---
|
|
248
265
|
const app = await core.fetchApp(url, {
|
|
249
266
|
'notifyId': notifyId,
|
|
250
|
-
'current': ntask ? ntask.current : undefined,
|
|
251
267
|
'progress': opt.progress
|
|
252
|
-
});
|
|
268
|
+
}, ntid);
|
|
253
269
|
// --- 无论是否成功,都可以先隐藏 notify 了 ---
|
|
254
270
|
if (notifyId) {
|
|
255
271
|
setTimeout(function(): void {
|
|
@@ -266,7 +282,7 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
266
282
|
const unblock = opt.unblock ? tool.clone(opt.unblock) : [];
|
|
267
283
|
const unblockSys = [
|
|
268
284
|
'require',
|
|
269
|
-
'__awaiter', 'eval', 'Math', 'Array', 'Blob', 'Error', 'Infinity', 'parseInt', 'parseFloat', 'Promise', 'Date', 'JSON', 'fetch', 'Number'
|
|
285
|
+
'__awaiter', 'eval', 'Math', 'Array', 'Blob', 'Error', 'Infinity', 'parseInt', 'parseFloat', 'Promise', 'Date', 'JSON', 'fetch', 'Number', 'Object'
|
|
270
286
|
];
|
|
271
287
|
for (const name of unblockSys) {
|
|
272
288
|
if (unblock.includes(name)) {
|
|
@@ -457,6 +473,9 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
457
473
|
}
|
|
458
474
|
},
|
|
459
475
|
'dom': {
|
|
476
|
+
inPage: function(el: HTMLElement): boolean {
|
|
477
|
+
return dom.inPage(el);
|
|
478
|
+
},
|
|
460
479
|
setGlobalCursor: function(type?: string): void {
|
|
461
480
|
dom.setGlobalCursor(type);
|
|
462
481
|
},
|
|
@@ -466,6 +485,9 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
466
485
|
getStyleCount: function(taskId: number, type: 'theme' | 'control' | 'form'): number {
|
|
467
486
|
return dom.getStyleCount(taskId, type);
|
|
468
487
|
},
|
|
488
|
+
getWatchSizeCount: function(taskId?: number): number {
|
|
489
|
+
return dom.getWatchSizeCount(taskId);
|
|
490
|
+
},
|
|
469
491
|
watchSize: function(
|
|
470
492
|
el: HTMLElement,
|
|
471
493
|
cb: () => void | Promise<void>,
|
|
@@ -476,9 +498,12 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
476
498
|
unwatchSize: function(el: HTMLElement): void {
|
|
477
499
|
dom.unwatchSize(el, taskId);
|
|
478
500
|
},
|
|
479
|
-
isWatchSize(el: HTMLElement): boolean {
|
|
501
|
+
isWatchSize: function(el: HTMLElement): boolean {
|
|
480
502
|
return dom.isWatchSize(el);
|
|
481
503
|
},
|
|
504
|
+
getWatchCount: function(taskId?: number): number {
|
|
505
|
+
return dom.getWatchCount(taskId);
|
|
506
|
+
},
|
|
482
507
|
watch: function(el: HTMLElement, cb: () => void, mode: 'child' | 'childsub' | 'style' | 'default' = 'default', immediate: boolean = false): void {
|
|
483
508
|
dom.watch(el, cb, mode, immediate, taskId);
|
|
484
509
|
},
|
|
@@ -499,7 +524,7 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
499
524
|
isWatchStyle: function(el: HTMLElement): boolean {
|
|
500
525
|
return dom.isWatchStyle(el);
|
|
501
526
|
},
|
|
502
|
-
watchProperty(
|
|
527
|
+
watchProperty: function(
|
|
503
528
|
el: HTMLElement,
|
|
504
529
|
name: string | string[],
|
|
505
530
|
cb: (name: string, value: string) => void,
|
|
@@ -510,7 +535,10 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
510
535
|
isWatchProperty(el: HTMLElement): boolean {
|
|
511
536
|
return dom.isWatchProperty(el);
|
|
512
537
|
},
|
|
513
|
-
|
|
538
|
+
getWatchInfo: function(): types.IGetWatchInfoResult {
|
|
539
|
+
return dom.getWatchInfo();
|
|
540
|
+
},
|
|
541
|
+
bindClick: function(e: MouseEvent | TouchEvent, handler: () => void): void {
|
|
514
542
|
dom.bindClick(e, handler);
|
|
515
543
|
},
|
|
516
544
|
bindDown: function(oe: MouseEvent | TouchEvent, opt: types.IBindDownOptions) {
|
|
@@ -535,8 +563,8 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
535
563
|
bindResize: function(e: MouseEvent | TouchEvent, opt: types.IBindResizeOptions): void {
|
|
536
564
|
dom.bindResize(e, opt);
|
|
537
565
|
},
|
|
538
|
-
findParentByData: function(el: HTMLElement, name: string): HTMLElement | null {
|
|
539
|
-
return dom.findParentByData(el, name);
|
|
566
|
+
findParentByData: function(el: HTMLElement, name: string, value?: string): HTMLElement | null {
|
|
567
|
+
return dom.findParentByData(el, name, value);
|
|
540
568
|
},
|
|
541
569
|
findParentByClass: function(el: HTMLElement, name: string): HTMLElement | null {
|
|
542
570
|
return dom.findParentByClass(el, name);
|
|
@@ -552,6 +580,11 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
552
580
|
}
|
|
553
581
|
},
|
|
554
582
|
'form': {
|
|
583
|
+
'AbstractPanel': class extends form.AbstractPanel {
|
|
584
|
+
public get taskId(): number {
|
|
585
|
+
return taskId;
|
|
586
|
+
}
|
|
587
|
+
},
|
|
555
588
|
'AbstractForm': class extends form.AbstractForm {
|
|
556
589
|
public get taskId(): number {
|
|
557
590
|
return taskId;
|
|
@@ -584,6 +617,15 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
584
617
|
getFocus: function(): number | null {
|
|
585
618
|
return form.getFocus();
|
|
586
619
|
},
|
|
620
|
+
getActivePanel: function(formId: number): number[] {
|
|
621
|
+
return form.getActivePanel(formId);
|
|
622
|
+
},
|
|
623
|
+
removeActivePanel: function(panelId: number, formId: number): boolean {
|
|
624
|
+
return form.removeActivePanel(panelId, formId, taskId);
|
|
625
|
+
},
|
|
626
|
+
setActivePanel: function(panelId: number, formId: number): boolean {
|
|
627
|
+
return form.setActivePanel(panelId, formId, taskId);
|
|
628
|
+
},
|
|
587
629
|
changeFocus: function(fid: number = 0): void {
|
|
588
630
|
form.changeFocus(fid);
|
|
589
631
|
},
|
|
@@ -632,6 +674,30 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
632
674
|
hidePop: function(pop?: HTMLElement): void {
|
|
633
675
|
form.hidePop(pop);
|
|
634
676
|
},
|
|
677
|
+
removePanel(id: number, vapp: types.IVApp, el: HTMLElement): boolean {
|
|
678
|
+
return form.removePanel(id, vapp, el);
|
|
679
|
+
},
|
|
680
|
+
createPanel<T extends form.AbstractPanel>(
|
|
681
|
+
cls: (new () => T),
|
|
682
|
+
el: HTMLElement,
|
|
683
|
+
formId: number
|
|
684
|
+
): Promise<{
|
|
685
|
+
'vapp': types.IVApp;
|
|
686
|
+
'vroot': T;
|
|
687
|
+
}> {
|
|
688
|
+
return form.createPanel(cls, el, formId, taskId);
|
|
689
|
+
},
|
|
690
|
+
create: function<T extends form.AbstractForm>(
|
|
691
|
+
cls: string | (new () => T),
|
|
692
|
+
data?: Record<string, any>,
|
|
693
|
+
opt?: {
|
|
694
|
+
'layout'?: string;
|
|
695
|
+
'style'?: string;
|
|
696
|
+
'path'?: string;
|
|
697
|
+
}
|
|
698
|
+
): Promise<T> {
|
|
699
|
+
return form.create(cls, data, opt, taskId);
|
|
700
|
+
},
|
|
635
701
|
dialog: function(opt: string | types.IFormDialogOptions): Promise<string> {
|
|
636
702
|
if (typeof opt === 'string') {
|
|
637
703
|
opt = {
|
|
@@ -661,119 +727,62 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
661
727
|
}
|
|
662
728
|
},
|
|
663
729
|
'fs': {
|
|
730
|
+
mount: function(name: string, handler: types.IMountHandler): boolean {
|
|
731
|
+
return clickgo.fs.mount(name, handler, taskId);
|
|
732
|
+
},
|
|
733
|
+
unmount: function(name: string): Promise<boolean> {
|
|
734
|
+
return clickgo.fs.unmount(name);
|
|
735
|
+
},
|
|
664
736
|
getContent: function(
|
|
665
737
|
path: string,
|
|
666
738
|
options: any = {}
|
|
667
739
|
): Promise<Blob | string | null> {
|
|
668
|
-
|
|
669
|
-
options.files = list[taskId].app.files;
|
|
670
|
-
}
|
|
671
|
-
if (!options.current) {
|
|
672
|
-
options.current = list[taskId].current;
|
|
673
|
-
}
|
|
674
|
-
return fs.getContent(path, options);
|
|
740
|
+
return fs.getContent(path, options, taskId);
|
|
675
741
|
},
|
|
676
742
|
putContent: function(path: string, data: string | Blob, options: any = {}) {
|
|
677
|
-
|
|
678
|
-
options.current = list[taskId].current;
|
|
679
|
-
}
|
|
680
|
-
return fs.putContent(path, data, options);
|
|
743
|
+
return fs.putContent(path, data, options, taskId);
|
|
681
744
|
},
|
|
682
745
|
readLink: function(path: string, options: any = {}): Promise<string | null> {
|
|
683
|
-
|
|
684
|
-
options.current = list[taskId].current;
|
|
685
|
-
}
|
|
686
|
-
return fs.readLink(path, options);
|
|
746
|
+
return fs.readLink(path, options, taskId);
|
|
687
747
|
},
|
|
688
748
|
symlink: function(fPath: string, linkPath: string, options: any = {}): Promise<boolean> {
|
|
689
|
-
|
|
690
|
-
options.current = list[taskId].current;
|
|
691
|
-
}
|
|
692
|
-
return fs.symlink(fPath, linkPath, options);
|
|
749
|
+
return fs.symlink(fPath, linkPath, options, taskId);
|
|
693
750
|
},
|
|
694
|
-
unlink: function(path: string
|
|
695
|
-
|
|
696
|
-
options.current = list[taskId].current;
|
|
697
|
-
}
|
|
698
|
-
return fs.unlink(path, options);
|
|
751
|
+
unlink: function(path: string): Promise<boolean> {
|
|
752
|
+
return fs.unlink(path, taskId);
|
|
699
753
|
},
|
|
700
|
-
stats: function(path: string
|
|
701
|
-
|
|
702
|
-
options.files = list[taskId].app.files;
|
|
703
|
-
}
|
|
704
|
-
if (!options.current) {
|
|
705
|
-
options.current = list[taskId].current;
|
|
706
|
-
}
|
|
707
|
-
return fs.stats(path, options);
|
|
754
|
+
stats: function(path: string): Promise<types.IStats | null> {
|
|
755
|
+
return fs.stats(path, taskId);
|
|
708
756
|
},
|
|
709
|
-
isDir: function(path: string
|
|
710
|
-
|
|
711
|
-
options.files = list[taskId].app.files;
|
|
712
|
-
}
|
|
713
|
-
if (!options.current) {
|
|
714
|
-
options.current = list[taskId].current;
|
|
715
|
-
}
|
|
716
|
-
return fs.isDir(path, options);
|
|
757
|
+
isDir: function(path: string): Promise<types.IStats | false> {
|
|
758
|
+
return fs.isDir(path, taskId);
|
|
717
759
|
},
|
|
718
|
-
isFile: function(path: string
|
|
719
|
-
|
|
720
|
-
options.files = list[taskId].app.files;
|
|
721
|
-
}
|
|
722
|
-
if (!options.current) {
|
|
723
|
-
options.current = list[taskId].current;
|
|
724
|
-
}
|
|
725
|
-
return fs.isFile(path, options);
|
|
760
|
+
isFile: function(path: string): Promise<types.IStats | false> {
|
|
761
|
+
return fs.isFile(path, taskId);
|
|
726
762
|
},
|
|
727
|
-
mkdir: function(path: string, mode?: number
|
|
728
|
-
|
|
729
|
-
options.current = list[taskId].current;
|
|
730
|
-
}
|
|
731
|
-
return fs.mkdir(path, mode, options);
|
|
763
|
+
mkdir: function(path: string, mode?: number): Promise<boolean> {
|
|
764
|
+
return fs.mkdir(path, mode, taskId);
|
|
732
765
|
},
|
|
733
|
-
rmdir: function(path: string
|
|
734
|
-
|
|
735
|
-
options.current = list[taskId].current;
|
|
736
|
-
}
|
|
737
|
-
return fs.rmdir(path, options);
|
|
766
|
+
rmdir: function(path: string): Promise<boolean> {
|
|
767
|
+
return fs.rmdir(path, taskId);
|
|
738
768
|
},
|
|
739
|
-
rmdirDeep: function(path: string
|
|
740
|
-
|
|
741
|
-
options.current = list[taskId].current;
|
|
742
|
-
}
|
|
743
|
-
return fs.rmdirDeep(path, options);
|
|
769
|
+
rmdirDeep: function(path: string): Promise<boolean> {
|
|
770
|
+
return fs.rmdirDeep(path, taskId);
|
|
744
771
|
},
|
|
745
|
-
chmod: function(path: string, mod: string | number
|
|
746
|
-
|
|
747
|
-
options.current = list[taskId].current;
|
|
748
|
-
}
|
|
749
|
-
return fs.chmod(path, mod, options);
|
|
772
|
+
chmod: function(path: string, mod: string | number): Promise<boolean> {
|
|
773
|
+
return fs.chmod(path, mod, taskId);
|
|
750
774
|
},
|
|
751
|
-
rename(oldPath: string, newPath: string
|
|
752
|
-
|
|
753
|
-
options.current = list[taskId].current;
|
|
754
|
-
}
|
|
755
|
-
return fs.rename(oldPath, newPath, options);
|
|
775
|
+
rename(oldPath: string, newPath: string): Promise<boolean> {
|
|
776
|
+
return fs.rename(oldPath, newPath, taskId);
|
|
756
777
|
},
|
|
757
|
-
readDir(path: string,
|
|
758
|
-
|
|
759
|
-
options.files = list[taskId].app.files;
|
|
760
|
-
}
|
|
761
|
-
if (!options.current) {
|
|
762
|
-
options.current = list[taskId].current;
|
|
763
|
-
}
|
|
764
|
-
return fs.readDir(path, options);
|
|
778
|
+
readDir(path: string, encoding?: BufferEncoding): Promise<types.IDirent[]> {
|
|
779
|
+
return fs.readDir(path, encoding, taskId);
|
|
765
780
|
},
|
|
766
781
|
copyFolder(from: string, to: string, options: any = {}): Promise<number> {
|
|
767
|
-
|
|
768
|
-
options.current = list[taskId].current;
|
|
769
|
-
}
|
|
770
|
-
return fs.copyFolder(from, to, options);
|
|
782
|
+
return fs.copyFolder(from, to, options, taskId);
|
|
771
783
|
},
|
|
772
|
-
copyFile(src: string, dest: string
|
|
773
|
-
|
|
774
|
-
options.current = list[taskId].current;
|
|
775
|
-
}
|
|
776
|
-
return fs.copyFile(src, dest, options);
|
|
784
|
+
copyFile(src: string, dest: string): Promise<boolean> {
|
|
785
|
+
return fs.copyFile(src, dest, taskId);
|
|
777
786
|
}
|
|
778
787
|
},
|
|
779
788
|
'native': {
|
|
@@ -863,11 +872,13 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
863
872
|
get: function(tid: number): types.ITaskInfo | null {
|
|
864
873
|
return get(tid);
|
|
865
874
|
},
|
|
875
|
+
getPermissions: function(tid: number): string[] {
|
|
876
|
+
return getPermissions(tid);
|
|
877
|
+
},
|
|
866
878
|
getList: function(): Record<string, types.ITaskInfo> {
|
|
867
879
|
return getList();
|
|
868
880
|
},
|
|
869
881
|
run: function(url: string, opt: types.ITaskRunOptions = {}): Promise<number> {
|
|
870
|
-
opt.taskId = taskId;
|
|
871
882
|
if (opt.unblock) {
|
|
872
883
|
const inUnblock: string[] = [];
|
|
873
884
|
// --- 只能解除屏蔽当前函数里面被解除的变量 ---
|
|
@@ -880,11 +891,11 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
880
891
|
opt.unblock = inUnblock;
|
|
881
892
|
}
|
|
882
893
|
if (opt.permissions) {
|
|
883
|
-
if (
|
|
894
|
+
if (!list[taskId]?.runtime.permissions.includes('root')) {
|
|
884
895
|
opt.permissions = undefined;
|
|
885
896
|
}
|
|
886
897
|
}
|
|
887
|
-
return run(url, opt);
|
|
898
|
+
return run(url, opt, taskId);
|
|
888
899
|
},
|
|
889
900
|
checkPermission: function(
|
|
890
901
|
vals: string | string[],
|
|
@@ -1005,6 +1016,9 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
1005
1016
|
escapeHTML: function(html: string): string {
|
|
1006
1017
|
return tool.escapeHTML(html);
|
|
1007
1018
|
},
|
|
1019
|
+
rgb2hsl: function(rgb: string): number[] {
|
|
1020
|
+
return tool.rgb2hsl(rgb);
|
|
1021
|
+
},
|
|
1008
1022
|
request: function(url: string, opt: types.IRequestOptions): Promise<null | any> {
|
|
1009
1023
|
return tool.request(url, opt);
|
|
1010
1024
|
},
|
|
@@ -1014,6 +1028,9 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
1014
1028
|
urlResolve: function(from: string, to: string): string {
|
|
1015
1029
|
return tool.urlResolve(from, to);
|
|
1016
1030
|
},
|
|
1031
|
+
urlAtom: function(url: string): string {
|
|
1032
|
+
return tool.urlAtom(url);
|
|
1033
|
+
},
|
|
1017
1034
|
blob2Text: function(blob: Blob): Promise<string> {
|
|
1018
1035
|
return tool.blob2Text(blob);
|
|
1019
1036
|
},
|
|
@@ -1043,7 +1060,7 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
1043
1060
|
return '';
|
|
1044
1061
|
}
|
|
1045
1062
|
// --- 给 form 的 class 增加 filename 的 get ---
|
|
1046
|
-
code = code.replace(/extends[\s\S]+?\.\s*(AbstractApp|AbstractForm)\s*{/, (t: string) => {
|
|
1063
|
+
code = code.replace(/extends[\s\S]+?\.\s*(AbstractApp|AbstractForm|AbstractPanel)\s*{/, (t: string) => {
|
|
1047
1064
|
return t + 'get filename() {return __filename;}';
|
|
1048
1065
|
});
|
|
1049
1066
|
return code;
|
|
@@ -1083,10 +1100,8 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
1083
1100
|
path += '.json';
|
|
1084
1101
|
}
|
|
1085
1102
|
const lcontent = await fs.getContent(path, {
|
|
1086
|
-
'encoding': 'utf8'
|
|
1087
|
-
|
|
1088
|
-
'current': current
|
|
1089
|
-
});
|
|
1103
|
+
'encoding': 'utf8'
|
|
1104
|
+
}, taskId);
|
|
1090
1105
|
if (!lcontent) {
|
|
1091
1106
|
continue;
|
|
1092
1107
|
}
|
|
@@ -1101,13 +1116,17 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
1101
1116
|
}
|
|
1102
1117
|
let expo: any = [];
|
|
1103
1118
|
try {
|
|
1119
|
+
const map = {
|
|
1120
|
+
'clickgo': '/invoke/clickgo'
|
|
1121
|
+
};
|
|
1122
|
+
if (app.config.map) {
|
|
1123
|
+
Object.assign(map, app.config.map);
|
|
1124
|
+
}
|
|
1104
1125
|
expo = loader.require('/app.js', app.files, {
|
|
1105
1126
|
'dir': '/',
|
|
1106
1127
|
'invoke': invoke,
|
|
1107
1128
|
'preprocess': preprocess,
|
|
1108
|
-
'map':
|
|
1109
|
-
'clickgo': '/invoke/clickgo'
|
|
1110
|
-
}
|
|
1129
|
+
'map': map
|
|
1111
1130
|
})[0];
|
|
1112
1131
|
}
|
|
1113
1132
|
catch (e: any) {
|
|
@@ -1133,10 +1152,7 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
1133
1152
|
for (let path of app.config.themes) {
|
|
1134
1153
|
path += '.cgt';
|
|
1135
1154
|
path = tool.urlResolve('/', path);
|
|
1136
|
-
const file = await fs.getContent(path,
|
|
1137
|
-
'files': app.files,
|
|
1138
|
-
'current': current
|
|
1139
|
-
});
|
|
1155
|
+
const file = await fs.getContent(path, undefined, taskId);
|
|
1140
1156
|
if (file && typeof file !== 'string') {
|
|
1141
1157
|
const th = await theme.read(file);
|
|
1142
1158
|
if (th) {
|
|
@@ -1154,10 +1170,8 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
1154
1170
|
// --- 加载任务级全局样式 ---
|
|
1155
1171
|
if (app.config.style) {
|
|
1156
1172
|
const style = await fs.getContent(app.config.style + '.css', {
|
|
1157
|
-
'encoding': 'utf8'
|
|
1158
|
-
|
|
1159
|
-
'current': current
|
|
1160
|
-
});
|
|
1173
|
+
'encoding': 'utf8'
|
|
1174
|
+
}, taskId);
|
|
1161
1175
|
if (style) {
|
|
1162
1176
|
const r = tool.stylePrepend(style, 'cg-task' + taskId.toString() + '_');
|
|
1163
1177
|
dom.pushStyle(taskId, await tool.styleUrl2DataUrl(app.config.style, r.style, app.files));
|
|
@@ -1179,6 +1193,7 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
1179
1193
|
/** --- 本页用到的语言包 --- */
|
|
1180
1194
|
const locale: Record<string, {
|
|
1181
1195
|
'unknown': string;
|
|
1196
|
+
'root': string;
|
|
1182
1197
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1183
1198
|
'apply-permission': string;
|
|
1184
1199
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -1191,6 +1206,7 @@ const locale: Record<string, {
|
|
|
1191
1206
|
}> = {
|
|
1192
1207
|
'sc': {
|
|
1193
1208
|
'unknown': '未知权限',
|
|
1209
|
+
'root': '<b>危险!</b>最高权限!请一定确认是否允许!',
|
|
1194
1210
|
'apply-permission': '正在申请权限,请您仔细确认',
|
|
1195
1211
|
'native.form': '实体窗体控制',
|
|
1196
1212
|
'hash': '可修改地址栏 hash',
|
|
@@ -1200,6 +1216,7 @@ const locale: Record<string, {
|
|
|
1200
1216
|
},
|
|
1201
1217
|
'tc': {
|
|
1202
1218
|
'unknown': '未知許可權',
|
|
1219
|
+
'root': '<b>危險!</b>最高許可權!請一定確認是否允許!',
|
|
1203
1220
|
'apply-permission': '正在申請許可權,請您仔細確認',
|
|
1204
1221
|
'native.form': '實體視窗控制',
|
|
1205
1222
|
'hash': '可修改位址列 hash',
|
|
@@ -1209,6 +1226,7 @@ const locale: Record<string, {
|
|
|
1209
1226
|
},
|
|
1210
1227
|
'en': {
|
|
1211
1228
|
'unknown': 'Unknown',
|
|
1229
|
+
'root': '<b>Danger!</b> Highest authorization! Please confirm whether to authorize?',
|
|
1212
1230
|
'apply-permission': 'is applying for permissions, please check carefully',
|
|
1213
1231
|
'native.form': 'Native window control',
|
|
1214
1232
|
'hash': 'Can modify the location hash',
|
|
@@ -1218,6 +1236,7 @@ const locale: Record<string, {
|
|
|
1218
1236
|
},
|
|
1219
1237
|
'ja': {
|
|
1220
1238
|
'unknown': '不明な許可',
|
|
1239
|
+
'root': '<b>危険!</b>最高の許可!承認するかどうかを確認してください!',
|
|
1221
1240
|
'apply-permission': '許可申請中、よくご確認ください',
|
|
1222
1241
|
'native.form': 'ローカルウィンドウを操作する',
|
|
1223
1242
|
'hash': '網址の hash 変更可能',
|
|
@@ -1390,6 +1409,7 @@ export function end(taskId: number): boolean {
|
|
|
1390
1409
|
form.elements.popList.querySelector('[data-form-id="' + f.id.toString() + '"]')?.remove();
|
|
1391
1410
|
dom.clearWatchStyle(fid);
|
|
1392
1411
|
dom.clearWatchProperty(fid);
|
|
1412
|
+
delete form.activePanels[fid];
|
|
1393
1413
|
}
|
|
1394
1414
|
// --- 移除可能残留的 form wrap ---
|
|
1395
1415
|
const flist = form.elements.list.querySelectorAll('.cg-form-wrap[data-task-id="' + taskId.toString() + '"]');
|
|
@@ -1465,10 +1485,8 @@ export async function loadLocale(lang: string, path: string, taskId?: number): P
|
|
|
1465
1485
|
path = tool.urlResolve(task.current + '/', path) + '.json';
|
|
1466
1486
|
/** --- 获取的语言文件 --- */
|
|
1467
1487
|
const fcontent = await fs.getContent(path, {
|
|
1468
|
-
'encoding': 'utf8'
|
|
1469
|
-
|
|
1470
|
-
'current': task.current
|
|
1471
|
-
});
|
|
1488
|
+
'encoding': 'utf8'
|
|
1489
|
+
}, taskId);
|
|
1472
1490
|
if (!fcontent) {
|
|
1473
1491
|
return false;
|
|
1474
1492
|
}
|
package/dist/lib/theme.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -10,10 +33,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
33
|
};
|
|
11
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
35
|
exports.clearGlobal = exports.setGlobal = exports.clear = exports.remove = exports.load = exports.read = exports.global = void 0;
|
|
13
|
-
const zip = require("./zip");
|
|
14
|
-
const tool = require("./tool");
|
|
15
|
-
const task = require("./task");
|
|
16
|
-
const dom = require("./dom");
|
|
36
|
+
const zip = __importStar(require("./zip"));
|
|
37
|
+
const tool = __importStar(require("./tool"));
|
|
38
|
+
const task = __importStar(require("./task"));
|
|
39
|
+
const dom = __importStar(require("./dom"));
|
|
17
40
|
exports.global = null;
|
|
18
41
|
function read(blob) {
|
|
19
42
|
return __awaiter(this, void 0, void 0, function* () {
|
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.match = 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);
|
|
@@ -114,12 +114,29 @@ function sleepFrame(count) {
|
|
|
114
114
|
exports.sleepFrame = sleepFrame;
|
|
115
115
|
function purify(text) {
|
|
116
116
|
text = '>' + text + '<';
|
|
117
|
-
|
|
117
|
+
const scripts = [];
|
|
118
|
+
let num = -1;
|
|
119
|
+
text = text.replace(/<!--([\s\S]*?)-->/g, '').replace(/<script[\s\S]+?<\/script>/g, function (t) {
|
|
120
|
+
scripts.push(t);
|
|
121
|
+
return '[SCRIPT]';
|
|
122
|
+
}).replace(/>([\s\S]*?)</g, function (t, t1) {
|
|
118
123
|
return '>' + t1.replace(/\t|\r\n| {2}/g, '').replace(/\n|\r/g, '') + '<';
|
|
124
|
+
}).replace(/\[SCRIPT\]/g, function () {
|
|
125
|
+
++num;
|
|
126
|
+
return scripts[num];
|
|
119
127
|
});
|
|
120
128
|
return text.slice(1, -1);
|
|
121
129
|
}
|
|
122
130
|
exports.purify = purify;
|
|
131
|
+
function match(str, regs) {
|
|
132
|
+
for (const reg of regs) {
|
|
133
|
+
if (reg.test(str)) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
exports.match = match;
|
|
123
140
|
function styleUrl2DataUrl(path, style, files) {
|
|
124
141
|
return __awaiter(this, void 0, void 0, function* () {
|
|
125
142
|
const reg = /url\(["']{0,1}(.+?)["']{0,1}\)/ig;
|
|
@@ -430,6 +447,40 @@ function escapeHTML(html) {
|
|
|
430
447
|
return html.replace(/</g, '<').replace(/>/g, '>');
|
|
431
448
|
}
|
|
432
449
|
exports.escapeHTML = escapeHTML;
|
|
450
|
+
function rgb2hsl(rgb) {
|
|
451
|
+
if (rgb.includes('(')) {
|
|
452
|
+
const match = /[0-9., ]+/.exec(rgb);
|
|
453
|
+
if (!match) {
|
|
454
|
+
return [0, 0, 0];
|
|
455
|
+
}
|
|
456
|
+
rgb = match[0];
|
|
457
|
+
}
|
|
458
|
+
const arr = rgb.split(',');
|
|
459
|
+
const [r, g, b] = arr.map(v => parseInt(v) / 255);
|
|
460
|
+
const max = Math.max(r, g, b);
|
|
461
|
+
const min = Math.min(r, g, b);
|
|
462
|
+
const diff = max - min;
|
|
463
|
+
let h = 0;
|
|
464
|
+
const l = (max + min) / 2;
|
|
465
|
+
const s2 = 1 - Math.abs(max + min - 1);
|
|
466
|
+
const s = s2 ? (diff / s2) : 0;
|
|
467
|
+
switch (min) {
|
|
468
|
+
case max:
|
|
469
|
+
h = 0;
|
|
470
|
+
break;
|
|
471
|
+
case r:
|
|
472
|
+
h = (60 * ((b - g) / diff)) + 180;
|
|
473
|
+
break;
|
|
474
|
+
case g:
|
|
475
|
+
h = (60 * ((r - b) / diff)) + 300;
|
|
476
|
+
break;
|
|
477
|
+
case b:
|
|
478
|
+
h = (60 * ((g - r) / diff)) + 60;
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
return [h, s, l];
|
|
482
|
+
}
|
|
483
|
+
exports.rgb2hsl = rgb2hsl;
|
|
433
484
|
function request(url, opt) {
|
|
434
485
|
return new Promise(function (resove) {
|
|
435
486
|
var _a;
|
|
@@ -541,6 +592,10 @@ function urlResolve(from, to) {
|
|
|
541
592
|
return loader.urlResolve(from, to);
|
|
542
593
|
}
|
|
543
594
|
exports.urlResolve = urlResolve;
|
|
595
|
+
function urlAtom(url) {
|
|
596
|
+
return loader.urlAtom(url);
|
|
597
|
+
}
|
|
598
|
+
exports.urlAtom = urlAtom;
|
|
544
599
|
function blob2Text(blob) {
|
|
545
600
|
return loader.blob2Text(blob);
|
|
546
601
|
}
|