clickgo 3.1.5-dev14 → 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 +28 -2
- package/dist/app/demo/config.json +17 -1
- 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 +24 -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 +84 -33
- package/dist/app/demo/form/main.xml +5 -0
- package/dist/app/demo/form/method/aform/aform.js +28 -2
- package/dist/app/demo/form/method/aform/sd.js +24 -1
- 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 +35 -1
- package/dist/app/demo/form/method/form/form.xml +2 -0
- package/dist/app/demo/form/method/fs/fs.js +138 -4
- 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 +35 -1
- package/dist/app/demo/form/method/zip/zip.js +29 -3
- package/dist/app/task/app.js +28 -2
- 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 -45
- package/dist/lib/core.ts +17 -41
- package/dist/lib/dom.js +322 -108
- package/dist/lib/dom.ts +394 -127
- package/dist/lib/form.js +441 -58
- package/dist/lib/form.ts +525 -74
- 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 +143 -136
- package/dist/lib/task.ts +124 -127
- package/dist/lib/theme.js +27 -4
- package/dist/lib/tool.js +19 -2
- package/dist/lib/tool.ts +23 -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 +4 -6
- package/types/index.d.ts +42 -34
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,19 @@ 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
|
+
},
|
|
635
690
|
create: function<T extends form.AbstractForm>(
|
|
636
691
|
cls: string | (new () => T),
|
|
637
692
|
data?: Record<string, any>,
|
|
@@ -672,119 +727,62 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
672
727
|
}
|
|
673
728
|
},
|
|
674
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
|
+
},
|
|
675
736
|
getContent: function(
|
|
676
737
|
path: string,
|
|
677
738
|
options: any = {}
|
|
678
739
|
): Promise<Blob | string | null> {
|
|
679
|
-
|
|
680
|
-
options.files = list[taskId].app.files;
|
|
681
|
-
}
|
|
682
|
-
if (!options.current) {
|
|
683
|
-
options.current = list[taskId].current;
|
|
684
|
-
}
|
|
685
|
-
return fs.getContent(path, options);
|
|
740
|
+
return fs.getContent(path, options, taskId);
|
|
686
741
|
},
|
|
687
742
|
putContent: function(path: string, data: string | Blob, options: any = {}) {
|
|
688
|
-
|
|
689
|
-
options.current = list[taskId].current;
|
|
690
|
-
}
|
|
691
|
-
return fs.putContent(path, data, options);
|
|
743
|
+
return fs.putContent(path, data, options, taskId);
|
|
692
744
|
},
|
|
693
745
|
readLink: function(path: string, options: any = {}): Promise<string | null> {
|
|
694
|
-
|
|
695
|
-
options.current = list[taskId].current;
|
|
696
|
-
}
|
|
697
|
-
return fs.readLink(path, options);
|
|
746
|
+
return fs.readLink(path, options, taskId);
|
|
698
747
|
},
|
|
699
748
|
symlink: function(fPath: string, linkPath: string, options: any = {}): Promise<boolean> {
|
|
700
|
-
|
|
701
|
-
options.current = list[taskId].current;
|
|
702
|
-
}
|
|
703
|
-
return fs.symlink(fPath, linkPath, options);
|
|
749
|
+
return fs.symlink(fPath, linkPath, options, taskId);
|
|
704
750
|
},
|
|
705
|
-
unlink: function(path: string
|
|
706
|
-
|
|
707
|
-
options.current = list[taskId].current;
|
|
708
|
-
}
|
|
709
|
-
return fs.unlink(path, options);
|
|
751
|
+
unlink: function(path: string): Promise<boolean> {
|
|
752
|
+
return fs.unlink(path, taskId);
|
|
710
753
|
},
|
|
711
|
-
stats: function(path: string
|
|
712
|
-
|
|
713
|
-
options.files = list[taskId].app.files;
|
|
714
|
-
}
|
|
715
|
-
if (!options.current) {
|
|
716
|
-
options.current = list[taskId].current;
|
|
717
|
-
}
|
|
718
|
-
return fs.stats(path, options);
|
|
754
|
+
stats: function(path: string): Promise<types.IStats | null> {
|
|
755
|
+
return fs.stats(path, taskId);
|
|
719
756
|
},
|
|
720
|
-
isDir: function(path: string
|
|
721
|
-
|
|
722
|
-
options.files = list[taskId].app.files;
|
|
723
|
-
}
|
|
724
|
-
if (!options.current) {
|
|
725
|
-
options.current = list[taskId].current;
|
|
726
|
-
}
|
|
727
|
-
return fs.isDir(path, options);
|
|
757
|
+
isDir: function(path: string): Promise<types.IStats | false> {
|
|
758
|
+
return fs.isDir(path, taskId);
|
|
728
759
|
},
|
|
729
|
-
isFile: function(path: string
|
|
730
|
-
|
|
731
|
-
options.files = list[taskId].app.files;
|
|
732
|
-
}
|
|
733
|
-
if (!options.current) {
|
|
734
|
-
options.current = list[taskId].current;
|
|
735
|
-
}
|
|
736
|
-
return fs.isFile(path, options);
|
|
760
|
+
isFile: function(path: string): Promise<types.IStats | false> {
|
|
761
|
+
return fs.isFile(path, taskId);
|
|
737
762
|
},
|
|
738
|
-
mkdir: function(path: string, mode?: number
|
|
739
|
-
|
|
740
|
-
options.current = list[taskId].current;
|
|
741
|
-
}
|
|
742
|
-
return fs.mkdir(path, mode, options);
|
|
763
|
+
mkdir: function(path: string, mode?: number): Promise<boolean> {
|
|
764
|
+
return fs.mkdir(path, mode, taskId);
|
|
743
765
|
},
|
|
744
|
-
rmdir: function(path: string
|
|
745
|
-
|
|
746
|
-
options.current = list[taskId].current;
|
|
747
|
-
}
|
|
748
|
-
return fs.rmdir(path, options);
|
|
766
|
+
rmdir: function(path: string): Promise<boolean> {
|
|
767
|
+
return fs.rmdir(path, taskId);
|
|
749
768
|
},
|
|
750
|
-
rmdirDeep: function(path: string
|
|
751
|
-
|
|
752
|
-
options.current = list[taskId].current;
|
|
753
|
-
}
|
|
754
|
-
return fs.rmdirDeep(path, options);
|
|
769
|
+
rmdirDeep: function(path: string): Promise<boolean> {
|
|
770
|
+
return fs.rmdirDeep(path, taskId);
|
|
755
771
|
},
|
|
756
|
-
chmod: function(path: string, mod: string | number
|
|
757
|
-
|
|
758
|
-
options.current = list[taskId].current;
|
|
759
|
-
}
|
|
760
|
-
return fs.chmod(path, mod, options);
|
|
772
|
+
chmod: function(path: string, mod: string | number): Promise<boolean> {
|
|
773
|
+
return fs.chmod(path, mod, taskId);
|
|
761
774
|
},
|
|
762
|
-
rename(oldPath: string, newPath: string
|
|
763
|
-
|
|
764
|
-
options.current = list[taskId].current;
|
|
765
|
-
}
|
|
766
|
-
return fs.rename(oldPath, newPath, options);
|
|
775
|
+
rename(oldPath: string, newPath: string): Promise<boolean> {
|
|
776
|
+
return fs.rename(oldPath, newPath, taskId);
|
|
767
777
|
},
|
|
768
|
-
readDir(path: string,
|
|
769
|
-
|
|
770
|
-
options.files = list[taskId].app.files;
|
|
771
|
-
}
|
|
772
|
-
if (!options.current) {
|
|
773
|
-
options.current = list[taskId].current;
|
|
774
|
-
}
|
|
775
|
-
return fs.readDir(path, options);
|
|
778
|
+
readDir(path: string, encoding?: BufferEncoding): Promise<types.IDirent[]> {
|
|
779
|
+
return fs.readDir(path, encoding, taskId);
|
|
776
780
|
},
|
|
777
781
|
copyFolder(from: string, to: string, options: any = {}): Promise<number> {
|
|
778
|
-
|
|
779
|
-
options.current = list[taskId].current;
|
|
780
|
-
}
|
|
781
|
-
return fs.copyFolder(from, to, options);
|
|
782
|
+
return fs.copyFolder(from, to, options, taskId);
|
|
782
783
|
},
|
|
783
|
-
copyFile(src: string, dest: string
|
|
784
|
-
|
|
785
|
-
options.current = list[taskId].current;
|
|
786
|
-
}
|
|
787
|
-
return fs.copyFile(src, dest, options);
|
|
784
|
+
copyFile(src: string, dest: string): Promise<boolean> {
|
|
785
|
+
return fs.copyFile(src, dest, taskId);
|
|
788
786
|
}
|
|
789
787
|
},
|
|
790
788
|
'native': {
|
|
@@ -874,11 +872,13 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
874
872
|
get: function(tid: number): types.ITaskInfo | null {
|
|
875
873
|
return get(tid);
|
|
876
874
|
},
|
|
875
|
+
getPermissions: function(tid: number): string[] {
|
|
876
|
+
return getPermissions(tid);
|
|
877
|
+
},
|
|
877
878
|
getList: function(): Record<string, types.ITaskInfo> {
|
|
878
879
|
return getList();
|
|
879
880
|
},
|
|
880
881
|
run: function(url: string, opt: types.ITaskRunOptions = {}): Promise<number> {
|
|
881
|
-
opt.taskId = taskId;
|
|
882
882
|
if (opt.unblock) {
|
|
883
883
|
const inUnblock: string[] = [];
|
|
884
884
|
// --- 只能解除屏蔽当前函数里面被解除的变量 ---
|
|
@@ -891,11 +891,11 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
891
891
|
opt.unblock = inUnblock;
|
|
892
892
|
}
|
|
893
893
|
if (opt.permissions) {
|
|
894
|
-
if (
|
|
894
|
+
if (!list[taskId]?.runtime.permissions.includes('root')) {
|
|
895
895
|
opt.permissions = undefined;
|
|
896
896
|
}
|
|
897
897
|
}
|
|
898
|
-
return run(url, opt);
|
|
898
|
+
return run(url, opt, taskId);
|
|
899
899
|
},
|
|
900
900
|
checkPermission: function(
|
|
901
901
|
vals: string | string[],
|
|
@@ -1060,7 +1060,7 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
1060
1060
|
return '';
|
|
1061
1061
|
}
|
|
1062
1062
|
// --- 给 form 的 class 增加 filename 的 get ---
|
|
1063
|
-
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) => {
|
|
1064
1064
|
return t + 'get filename() {return __filename;}';
|
|
1065
1065
|
});
|
|
1066
1066
|
return code;
|
|
@@ -1100,10 +1100,8 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
1100
1100
|
path += '.json';
|
|
1101
1101
|
}
|
|
1102
1102
|
const lcontent = await fs.getContent(path, {
|
|
1103
|
-
'encoding': 'utf8'
|
|
1104
|
-
|
|
1105
|
-
'current': current
|
|
1106
|
-
});
|
|
1103
|
+
'encoding': 'utf8'
|
|
1104
|
+
}, taskId);
|
|
1107
1105
|
if (!lcontent) {
|
|
1108
1106
|
continue;
|
|
1109
1107
|
}
|
|
@@ -1154,10 +1152,7 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
1154
1152
|
for (let path of app.config.themes) {
|
|
1155
1153
|
path += '.cgt';
|
|
1156
1154
|
path = tool.urlResolve('/', path);
|
|
1157
|
-
const file = await fs.getContent(path,
|
|
1158
|
-
'files': app.files,
|
|
1159
|
-
'current': current
|
|
1160
|
-
});
|
|
1155
|
+
const file = await fs.getContent(path, undefined, taskId);
|
|
1161
1156
|
if (file && typeof file !== 'string') {
|
|
1162
1157
|
const th = await theme.read(file);
|
|
1163
1158
|
if (th) {
|
|
@@ -1175,10 +1170,8 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
1175
1170
|
// --- 加载任务级全局样式 ---
|
|
1176
1171
|
if (app.config.style) {
|
|
1177
1172
|
const style = await fs.getContent(app.config.style + '.css', {
|
|
1178
|
-
'encoding': 'utf8'
|
|
1179
|
-
|
|
1180
|
-
'current': current
|
|
1181
|
-
});
|
|
1173
|
+
'encoding': 'utf8'
|
|
1174
|
+
}, taskId);
|
|
1182
1175
|
if (style) {
|
|
1183
1176
|
const r = tool.stylePrepend(style, 'cg-task' + taskId.toString() + '_');
|
|
1184
1177
|
dom.pushStyle(taskId, await tool.styleUrl2DataUrl(app.config.style, r.style, app.files));
|
|
@@ -1200,6 +1193,7 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
|
|
|
1200
1193
|
/** --- 本页用到的语言包 --- */
|
|
1201
1194
|
const locale: Record<string, {
|
|
1202
1195
|
'unknown': string;
|
|
1196
|
+
'root': string;
|
|
1203
1197
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1204
1198
|
'apply-permission': string;
|
|
1205
1199
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -1212,6 +1206,7 @@ const locale: Record<string, {
|
|
|
1212
1206
|
}> = {
|
|
1213
1207
|
'sc': {
|
|
1214
1208
|
'unknown': '未知权限',
|
|
1209
|
+
'root': '<b>危险!</b>最高权限!请一定确认是否允许!',
|
|
1215
1210
|
'apply-permission': '正在申请权限,请您仔细确认',
|
|
1216
1211
|
'native.form': '实体窗体控制',
|
|
1217
1212
|
'hash': '可修改地址栏 hash',
|
|
@@ -1221,6 +1216,7 @@ const locale: Record<string, {
|
|
|
1221
1216
|
},
|
|
1222
1217
|
'tc': {
|
|
1223
1218
|
'unknown': '未知許可權',
|
|
1219
|
+
'root': '<b>危險!</b>最高許可權!請一定確認是否允許!',
|
|
1224
1220
|
'apply-permission': '正在申請許可權,請您仔細確認',
|
|
1225
1221
|
'native.form': '實體視窗控制',
|
|
1226
1222
|
'hash': '可修改位址列 hash',
|
|
@@ -1230,6 +1226,7 @@ const locale: Record<string, {
|
|
|
1230
1226
|
},
|
|
1231
1227
|
'en': {
|
|
1232
1228
|
'unknown': 'Unknown',
|
|
1229
|
+
'root': '<b>Danger!</b> Highest authorization! Please confirm whether to authorize?',
|
|
1233
1230
|
'apply-permission': 'is applying for permissions, please check carefully',
|
|
1234
1231
|
'native.form': 'Native window control',
|
|
1235
1232
|
'hash': 'Can modify the location hash',
|
|
@@ -1239,6 +1236,7 @@ const locale: Record<string, {
|
|
|
1239
1236
|
},
|
|
1240
1237
|
'ja': {
|
|
1241
1238
|
'unknown': '不明な許可',
|
|
1239
|
+
'root': '<b>危険!</b>最高の許可!承認するかどうかを確認してください!',
|
|
1242
1240
|
'apply-permission': '許可申請中、よくご確認ください',
|
|
1243
1241
|
'native.form': 'ローカルウィンドウを操作する',
|
|
1244
1242
|
'hash': '網址の hash 変更可能',
|
|
@@ -1411,6 +1409,7 @@ export function end(taskId: number): boolean {
|
|
|
1411
1409
|
form.elements.popList.querySelector('[data-form-id="' + f.id.toString() + '"]')?.remove();
|
|
1412
1410
|
dom.clearWatchStyle(fid);
|
|
1413
1411
|
dom.clearWatchProperty(fid);
|
|
1412
|
+
delete form.activePanels[fid];
|
|
1414
1413
|
}
|
|
1415
1414
|
// --- 移除可能残留的 form wrap ---
|
|
1416
1415
|
const flist = form.elements.list.querySelectorAll('.cg-form-wrap[data-task-id="' + taskId.toString() + '"]');
|
|
@@ -1486,10 +1485,8 @@ export async function loadLocale(lang: string, path: string, taskId?: number): P
|
|
|
1486
1485
|
path = tool.urlResolve(task.current + '/', path) + '.json';
|
|
1487
1486
|
/** --- 获取的语言文件 --- */
|
|
1488
1487
|
const fcontent = await fs.getContent(path, {
|
|
1489
|
-
'encoding': 'utf8'
|
|
1490
|
-
|
|
1491
|
-
'current': task.current
|
|
1492
|
-
});
|
|
1488
|
+
'encoding': 'utf8'
|
|
1489
|
+
}, taskId);
|
|
1493
1490
|
if (!fcontent) {
|
|
1494
1491
|
return false;
|
|
1495
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.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;
|
|
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;
|
package/dist/lib/tool.ts
CHANGED
|
@@ -156,12 +156,34 @@ export async function sleepFrame(count: number): Promise<void> {
|
|
|
156
156
|
*/
|
|
157
157
|
export function purify(text: string): string {
|
|
158
158
|
text = '>' + text + '<';
|
|
159
|
-
|
|
159
|
+
const scripts: string[] = [];
|
|
160
|
+
let num: number = -1;
|
|
161
|
+
text = text.replace(/<!--([\s\S]*?)-->/g, '').replace(/<script[\s\S]+?<\/script>/g, function(t: string): string {
|
|
162
|
+
scripts.push(t);
|
|
163
|
+
return '[SCRIPT]';
|
|
164
|
+
}).replace(/>([\s\S]*?)</g, function(t: string, t1: string): string {
|
|
160
165
|
return '>' + t1.replace(/\t|\r\n| {2}/g, '').replace(/\n|\r/g, '') + '<';
|
|
166
|
+
}).replace(/\[SCRIPT\]/g, function(): string {
|
|
167
|
+
++num;
|
|
168
|
+
return scripts[num];
|
|
161
169
|
});
|
|
162
170
|
return text.slice(1, -1);
|
|
163
171
|
}
|
|
164
172
|
|
|
173
|
+
/**
|
|
174
|
+
* --- 传入正则进行匹配 str 是否有一项满足 ---
|
|
175
|
+
* @param str 要检测的字符串
|
|
176
|
+
* @param regs 正则列表
|
|
177
|
+
*/
|
|
178
|
+
export function match(str: string, regs: RegExp[]): boolean {
|
|
179
|
+
for (const reg of regs) {
|
|
180
|
+
if (reg.test(str)) {
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
|
|
165
187
|
/**
|
|
166
188
|
* --- 将 style 中的 url 转换成 base64 data url ---
|
|
167
189
|
* @param path 路径基准或以文件的路径为基准,以 / 结尾
|
package/dist/lib/zip.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) {
|
|
@@ -8,10 +31,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
32
|
});
|
|
10
33
|
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
11
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
38
|
exports.get = exports.Zip = void 0;
|
|
13
|
-
const
|
|
14
|
-
const tool = require("./tool");
|
|
39
|
+
const jszip_1 = __importDefault(require("jszip"));
|
|
40
|
+
const tool = __importStar(require("./tool"));
|
|
15
41
|
class Zip {
|
|
16
42
|
constructor(zip) {
|
|
17
43
|
this._path = '/';
|
|
@@ -337,7 +363,7 @@ class Zip {
|
|
|
337
363
|
exports.Zip = Zip;
|
|
338
364
|
function get(data) {
|
|
339
365
|
return __awaiter(this, void 0, void 0, function* () {
|
|
340
|
-
const z =
|
|
366
|
+
const z = (0, jszip_1.default)();
|
|
341
367
|
try {
|
|
342
368
|
if (data) {
|
|
343
369
|
yield z.loadAsync(data);
|