clickgo 3.0.7-dev8 → 3.1.0-dev9
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 +93 -0
- package/dist/app/demo/form/control/form/form.js +21 -20
- package/dist/app/demo/form/control/form/form.xml +3 -3
- package/dist/app/demo/form/main.js +20 -10
- package/dist/app/demo/form/main.xml +1 -1
- package/dist/app/task/app.js +46 -0
- package/dist/app/task/form/bar/bar.js +84 -88
- package/dist/app/task/form/bar/bar.xml +4 -5
- package/dist/clickgo.js +1 -10
- package/dist/clickgo.ts +0 -8
- 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/index.js +105 -56
- package/dist/index.ts +164 -59
- package/dist/lib/control.js +363 -240
- package/dist/lib/control.ts +497 -284
- package/dist/lib/core.js +313 -228
- package/dist/lib/core.ts +400 -255
- package/dist/lib/dom.ts +1 -3
- package/dist/lib/form.js +398 -928
- package/dist/lib/form.ts +630 -1075
- package/dist/lib/fs.js +42 -39
- package/dist/lib/fs.ts +45 -41
- package/dist/lib/native.ts +3 -0
- package/dist/lib/task.js +705 -182
- package/dist/lib/task.ts +775 -200
- package/dist/lib/theme.ts +2 -2
- package/dist/lib/tool.js +58 -48
- package/dist/lib/tool.ts +79 -64
- package/dist/theme/familiar.cgt +0 -0
- package/package.json +5 -7
- package/types/index.d.ts +274 -325
- package/dist/app/demo/config.json +0 -106
- package/dist/app/task/config.json +0 -32
package/dist/lib/theme.ts
CHANGED
|
@@ -19,7 +19,7 @@ import * as tool from './tool';
|
|
|
19
19
|
import * as task from './task';
|
|
20
20
|
import * as dom from './dom';
|
|
21
21
|
|
|
22
|
-
/** ---
|
|
22
|
+
/** --- 当前全局主题,App 模式下无效 --- */
|
|
23
23
|
export let global: types.ITheme | null = null;
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -117,7 +117,7 @@ export async function load(theme?: types.ITheme, taskId?: number): Promise<boole
|
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* --- 移除当前 task 的 theme(只能移除自定的) ---
|
|
120
|
-
* @param 要移除的主题
|
|
120
|
+
* @param name 要移除的主题
|
|
121
121
|
* @param taskId 任务 ID,App 模式下无效
|
|
122
122
|
*/
|
|
123
123
|
export async function remove(name: string, taskId?: number): Promise<void> {
|
package/dist/lib/tool.js
CHANGED
|
@@ -9,8 +9,52 @@ 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.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.
|
|
13
|
-
|
|
12
|
+
exports.execCommand = exports.blob2DataUrl = exports.blob2Text = exports.urlResolve = exports.parseUrl = exports.request = exports.escapeHTML = 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.eventsAttrWrap = exports.layoutClassPrepend = exports.layoutInsertAttr = exports.layoutAddTagClassAndReTagName = exports.styleUrl2DataUrl = exports.purify = exports.sleep = exports.clone = exports.blob2ArrayBuffer = exports.getClassPrototype = void 0;
|
|
13
|
+
function getClassPrototype(obj, over = [], level = 0) {
|
|
14
|
+
if (level === 0) {
|
|
15
|
+
return getClassPrototype(Object.getPrototypeOf(obj), over, level + 1);
|
|
16
|
+
}
|
|
17
|
+
const rtn = {
|
|
18
|
+
'method': {},
|
|
19
|
+
'access': {}
|
|
20
|
+
};
|
|
21
|
+
const names = Object.getOwnPropertyNames(obj);
|
|
22
|
+
if (names.includes('toString')) {
|
|
23
|
+
return rtn;
|
|
24
|
+
}
|
|
25
|
+
for (const item of names) {
|
|
26
|
+
if (item === 'constructor') {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (over.includes(item)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const des = Object.getOwnPropertyDescriptor(obj, item);
|
|
33
|
+
if (!des) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
over.push(item);
|
|
37
|
+
if (des.value) {
|
|
38
|
+
rtn.method[item] = des.value;
|
|
39
|
+
}
|
|
40
|
+
else if (des.get || des.set) {
|
|
41
|
+
if (!rtn.access[item]) {
|
|
42
|
+
rtn.access[item] = {};
|
|
43
|
+
}
|
|
44
|
+
if (des.get) {
|
|
45
|
+
rtn.access[item].get = des.get;
|
|
46
|
+
}
|
|
47
|
+
if (des.set) {
|
|
48
|
+
rtn.access[item].set = des.set;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const rtn2 = getClassPrototype(Object.getPrototypeOf(obj), over, level + 1);
|
|
53
|
+
Object.assign(rtn.method, rtn2.method);
|
|
54
|
+
Object.assign(rtn.access, rtn2.access);
|
|
55
|
+
return rtn;
|
|
56
|
+
}
|
|
57
|
+
exports.getClassPrototype = getClassPrototype;
|
|
14
58
|
function blob2ArrayBuffer(blob) {
|
|
15
59
|
return new Promise(function (resove) {
|
|
16
60
|
const fr = new FileReader();
|
|
@@ -151,7 +195,7 @@ function layoutClassPrependObject(object) {
|
|
|
151
195
|
return '{' + object.replace(/(.+?):(.+?)(,|$)/g, function (t, t1, t2, t3) {
|
|
152
196
|
t1 = t1.trim();
|
|
153
197
|
if (t1.startsWith('[')) {
|
|
154
|
-
t1 = '[
|
|
198
|
+
t1 = '[classPrepend(' + t1.slice(1, -1) + ')]';
|
|
155
199
|
}
|
|
156
200
|
else {
|
|
157
201
|
let sp = '';
|
|
@@ -159,7 +203,7 @@ function layoutClassPrependObject(object) {
|
|
|
159
203
|
sp = t1[0];
|
|
160
204
|
t1 = t1.slice(1, -1);
|
|
161
205
|
}
|
|
162
|
-
t1 = `[
|
|
206
|
+
t1 = `[classPrepend(${sp}${t1}${sp})]`;
|
|
163
207
|
}
|
|
164
208
|
return t1 + ':' + t2 + t3;
|
|
165
209
|
}) + '}';
|
|
@@ -187,7 +231,7 @@ function layoutClassPrepend(layout, preps) {
|
|
|
187
231
|
t1a[i] = layoutClassPrependObject(t1a[i]);
|
|
188
232
|
}
|
|
189
233
|
else {
|
|
190
|
-
t1a[i] = '
|
|
234
|
+
t1a[i] = 'classPrepend(' + t1a[i] + ')';
|
|
191
235
|
}
|
|
192
236
|
}
|
|
193
237
|
t1 = '[' + t1a.join(',') + ']';
|
|
@@ -205,9 +249,9 @@ function eventsAttrWrap(layout) {
|
|
|
205
249
|
const reg = new RegExp(`@(${events.join('|')})="(.+?)"`, 'g');
|
|
206
250
|
return layout.replace(reg, function (t, t1, t2) {
|
|
207
251
|
if (/^[\w]+$/.test(t2)) {
|
|
208
|
-
return `@${t1}="
|
|
252
|
+
return `@${t1}="allowEvent($event) && ${t2}($event)"`;
|
|
209
253
|
}
|
|
210
|
-
return `@${t1}=";if(
|
|
254
|
+
return `@${t1}=";if(allowEvent($event)){${t2}}"`;
|
|
211
255
|
});
|
|
212
256
|
}
|
|
213
257
|
exports.eventsAttrWrap = eventsAttrWrap;
|
|
@@ -281,47 +325,6 @@ function getMimeByPath(path) {
|
|
|
281
325
|
};
|
|
282
326
|
}
|
|
283
327
|
exports.getMimeByPath = getMimeByPath;
|
|
284
|
-
const objectURLs = [];
|
|
285
|
-
function createObjectURL(object, taskId = 0) {
|
|
286
|
-
let t = null;
|
|
287
|
-
if (taskId > 0) {
|
|
288
|
-
t = task.list[taskId];
|
|
289
|
-
if (!t) {
|
|
290
|
-
return '';
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
const url = URL.createObjectURL(object);
|
|
294
|
-
objectURLs.push(url);
|
|
295
|
-
if (t) {
|
|
296
|
-
t.objectURLs.push(url);
|
|
297
|
-
}
|
|
298
|
-
return url;
|
|
299
|
-
}
|
|
300
|
-
exports.createObjectURL = createObjectURL;
|
|
301
|
-
function revokeObjectURL(url, taskId = 0) {
|
|
302
|
-
const oio = objectURLs.indexOf(url);
|
|
303
|
-
if (oio === -1) {
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
if (taskId > 0) {
|
|
307
|
-
const t = task.list[taskId];
|
|
308
|
-
if (!t) {
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
const io = t.objectURLs.indexOf(url);
|
|
312
|
-
if (io === -1) {
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
t.objectURLs.splice(io, 1);
|
|
316
|
-
}
|
|
317
|
-
objectURLs.splice(oio, 1);
|
|
318
|
-
URL.revokeObjectURL(url);
|
|
319
|
-
}
|
|
320
|
-
exports.revokeObjectURL = revokeObjectURL;
|
|
321
|
-
function getObjectURLs() {
|
|
322
|
-
return objectURLs;
|
|
323
|
-
}
|
|
324
|
-
exports.getObjectURLs = getObjectURLs;
|
|
325
328
|
function rand(min, max) {
|
|
326
329
|
if (min > max) {
|
|
327
330
|
[min, max] = [max, min];
|
|
@@ -369,6 +372,13 @@ function getBoolean(param) {
|
|
|
369
372
|
}
|
|
370
373
|
}
|
|
371
374
|
exports.getBoolean = getBoolean;
|
|
375
|
+
function getNumber(param) {
|
|
376
|
+
if (typeof param === 'number') {
|
|
377
|
+
return param;
|
|
378
|
+
}
|
|
379
|
+
return parseFloat(param);
|
|
380
|
+
}
|
|
381
|
+
exports.getNumber = getNumber;
|
|
372
382
|
function escapeHTML(html) {
|
|
373
383
|
return html.replace(/</g, '<').replace(/>/g, '>');
|
|
374
384
|
}
|
package/dist/lib/tool.ts
CHANGED
|
@@ -14,7 +14,67 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import * as types from '../../types';
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
interface IClassPrototype {
|
|
19
|
+
'method': Record<string, any>;
|
|
20
|
+
'access': Record<string, {
|
|
21
|
+
'get'?: any;
|
|
22
|
+
'set'?: any;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* --- 获取 class 的所有 method 和 get/set ---
|
|
28
|
+
* @param obj 实例化 class 对象
|
|
29
|
+
* @param over 不传入此参数
|
|
30
|
+
* @param level 不传入此参数
|
|
31
|
+
*/
|
|
32
|
+
export function getClassPrototype(obj: object, over: string[] = [], level: number = 0): IClassPrototype {
|
|
33
|
+
if (level === 0) {
|
|
34
|
+
return getClassPrototype(Object.getPrototypeOf(obj), over, level + 1);
|
|
35
|
+
}
|
|
36
|
+
const rtn: IClassPrototype = {
|
|
37
|
+
'method': {},
|
|
38
|
+
'access': {}
|
|
39
|
+
};
|
|
40
|
+
const names = Object.getOwnPropertyNames(obj);
|
|
41
|
+
if (names.includes('toString')) {
|
|
42
|
+
return rtn;
|
|
43
|
+
}
|
|
44
|
+
for (const item of names) {
|
|
45
|
+
if (item === 'constructor') {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (over.includes(item)) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const des = Object.getOwnPropertyDescriptor(obj, item);
|
|
52
|
+
if (!des) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
over.push(item);
|
|
56
|
+
if (des.value) {
|
|
57
|
+
// --- method ---
|
|
58
|
+
rtn.method[item] = des.value;
|
|
59
|
+
}
|
|
60
|
+
else if (des.get || des.set) {
|
|
61
|
+
if (!rtn.access[item]) {
|
|
62
|
+
rtn.access[item] = {};
|
|
63
|
+
}
|
|
64
|
+
if (des.get) {
|
|
65
|
+
rtn.access[item].get = (des as any).get;
|
|
66
|
+
}
|
|
67
|
+
if (des.set) {
|
|
68
|
+
rtn.access[item].set = (des as any).set;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// --- 往上级检查 ---
|
|
73
|
+
const rtn2 = getClassPrototype(Object.getPrototypeOf(obj), over, level + 1);
|
|
74
|
+
Object.assign(rtn.method, rtn2.method);
|
|
75
|
+
Object.assign(rtn.access, rtn2.access);
|
|
76
|
+
return rtn;
|
|
77
|
+
}
|
|
18
78
|
|
|
19
79
|
/**
|
|
20
80
|
* --- 将 blob 对象转换为 ArrayBuffer ---
|
|
@@ -80,7 +140,7 @@ export function purify(text: string): string {
|
|
|
80
140
|
|
|
81
141
|
/**
|
|
82
142
|
* --- 将 style 中的 url 转换成 base64 data url ---
|
|
83
|
-
* @param path
|
|
143
|
+
* @param path 路径基准或以文件的路径为基准,以 / 结尾
|
|
84
144
|
* @param style 样式表
|
|
85
145
|
* @param files 在此文件列表中查找
|
|
86
146
|
*/
|
|
@@ -205,7 +265,7 @@ function layoutClassPrependObject(object: string): string {
|
|
|
205
265
|
// --- t1 是 'xxx', t2 是 xxx,t3 是结尾或者 , 分隔符 ---
|
|
206
266
|
t1 = t1.trim();
|
|
207
267
|
if (t1.startsWith('[')) {
|
|
208
|
-
t1 = '[
|
|
268
|
+
t1 = '[classPrepend(' + t1.slice(1, -1) + ')]';
|
|
209
269
|
}
|
|
210
270
|
else {
|
|
211
271
|
let sp = '';
|
|
@@ -213,7 +273,7 @@ function layoutClassPrependObject(object: string): string {
|
|
|
213
273
|
sp = t1[0];
|
|
214
274
|
t1 = t1.slice(1, -1);
|
|
215
275
|
}
|
|
216
|
-
t1 = `[
|
|
276
|
+
t1 = `[classPrepend(${sp}${t1}${sp})]`;
|
|
217
277
|
}
|
|
218
278
|
return t1 + ':' + t2 + t3;
|
|
219
279
|
}) + '}';
|
|
@@ -250,7 +310,7 @@ export function layoutClassPrepend(layout: string, preps: string[]): string {
|
|
|
250
310
|
t1a[i] = layoutClassPrependObject(t1a[i]);
|
|
251
311
|
}
|
|
252
312
|
else {
|
|
253
|
-
t1a[i] = '
|
|
313
|
+
t1a[i] = 'classPrepend(' + t1a[i] + ')';
|
|
254
314
|
}
|
|
255
315
|
}
|
|
256
316
|
t1 = '[' + t1a.join(',') + ']';
|
|
@@ -272,9 +332,9 @@ export function eventsAttrWrap(layout: string): string {
|
|
|
272
332
|
const reg = new RegExp(`@(${events.join('|')})="(.+?)"`, 'g');
|
|
273
333
|
return layout.replace(reg, function(t, t1, t2): string {
|
|
274
334
|
if (/^[\w]+$/.test(t2)) {
|
|
275
|
-
return `@${t1}="
|
|
335
|
+
return `@${t1}="allowEvent($event) && ${t2}($event)"`;
|
|
276
336
|
}
|
|
277
|
-
return `@${t1}=";if(
|
|
337
|
+
return `@${t1}=";if(allowEvent($event)){${t2}}"`;
|
|
278
338
|
});
|
|
279
339
|
}
|
|
280
340
|
|
|
@@ -375,62 +435,6 @@ export function getMimeByPath(path: string): { 'mime': string; 'ext': string; }
|
|
|
375
435
|
};
|
|
376
436
|
}
|
|
377
437
|
|
|
378
|
-
/** --- 已创建的 object url 列表 --- */
|
|
379
|
-
const objectURLs: string[] = [];
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* --- 通过 blob 创建 object url ---
|
|
383
|
-
* @param object blob 对象
|
|
384
|
-
* @param taskId 要记录到 task 里面,待 task 结束后则清除相关 object url
|
|
385
|
-
*/
|
|
386
|
-
export function createObjectURL(object: Blob, taskId: number = 0): string {
|
|
387
|
-
let t: types.ITask | null = null;
|
|
388
|
-
if (taskId > 0) {
|
|
389
|
-
t = task.list[taskId];
|
|
390
|
-
if (!t) {
|
|
391
|
-
return '';
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
const url = URL.createObjectURL(object);
|
|
395
|
-
objectURLs.push(url);
|
|
396
|
-
if (t) {
|
|
397
|
-
t.objectURLs.push(url);
|
|
398
|
-
}
|
|
399
|
-
return url;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* --- 移除已创建的 object url ---
|
|
404
|
-
* @param url 已创建的 url
|
|
405
|
-
* @param 是否是 task 里面的,若不是,则无法被移除
|
|
406
|
-
*/
|
|
407
|
-
export function revokeObjectURL(url: string, taskId: number = 0): void {
|
|
408
|
-
const oio = objectURLs.indexOf(url);
|
|
409
|
-
if (oio === -1) {
|
|
410
|
-
return;
|
|
411
|
-
}
|
|
412
|
-
if (taskId > 0) {
|
|
413
|
-
const t = task.list[taskId];
|
|
414
|
-
if (!t) {
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
const io = t.objectURLs.indexOf(url);
|
|
418
|
-
if (io === -1) {
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
t.objectURLs.splice(io, 1);
|
|
422
|
-
}
|
|
423
|
-
objectURLs.splice(oio, 1);
|
|
424
|
-
URL.revokeObjectURL(url);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* --- 获取已创建的 object url 列表,App 模式下无效 ---
|
|
429
|
-
*/
|
|
430
|
-
export function getObjectURLs(): string[] {
|
|
431
|
-
return objectURLs;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
438
|
/**
|
|
435
439
|
* --- 生成范围内的随机数 ---
|
|
436
440
|
* @param min 最新范围
|
|
@@ -476,7 +480,7 @@ export function random(length: number = 8, source: string = RANDOM_LN, block: st
|
|
|
476
480
|
* --- 根据参数获取最终的布尔值 ---
|
|
477
481
|
* @param param 参数
|
|
478
482
|
*/
|
|
479
|
-
export function getBoolean(param: boolean | string | number): boolean {
|
|
483
|
+
export function getBoolean(param: boolean | string | number | undefined): boolean {
|
|
480
484
|
const t = typeof param;
|
|
481
485
|
if (t === 'boolean') {
|
|
482
486
|
return param as boolean;
|
|
@@ -489,6 +493,17 @@ export function getBoolean(param: boolean | string | number): boolean {
|
|
|
489
493
|
}
|
|
490
494
|
}
|
|
491
495
|
|
|
496
|
+
/**
|
|
497
|
+
* --- 根据参数获取最终的数字型 ---
|
|
498
|
+
* @param param 参数
|
|
499
|
+
*/
|
|
500
|
+
export function getNumber(param: string | number): number {
|
|
501
|
+
if (typeof param === 'number') {
|
|
502
|
+
return param;
|
|
503
|
+
}
|
|
504
|
+
return parseFloat(param);
|
|
505
|
+
}
|
|
506
|
+
|
|
492
507
|
/**
|
|
493
508
|
* --- 转义 HTML ---
|
|
494
509
|
* @param html HTML 字符
|
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.0
|
|
3
|
+
"version": "3.1.0-dev9",
|
|
4
4
|
"description": "Background interface, software interface, mobile phone APP interface operation library.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deskrt",
|
|
@@ -18,13 +18,11 @@
|
|
|
18
18
|
"native4": "electron ./dist/test/native/index4"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@litert/
|
|
21
|
+
"@litert/eslint-plugin-rules": "^0.1.0",
|
|
22
|
+
"@litert/loader": "^3.4.3",
|
|
22
23
|
"@types/node": "^17.0.21",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"electron": "^19.0.8",
|
|
26
|
-
"eslint": "^8.12.0",
|
|
27
|
-
"typescript": "^4.6.4"
|
|
24
|
+
"electron": "^19.1.3",
|
|
25
|
+
"typescript": "^4.8.4"
|
|
28
26
|
},
|
|
29
27
|
"dependencies": {
|
|
30
28
|
"jszip": "^3.10.0"
|