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.
Files changed (96) hide show
  1. package/README.md +7 -7
  2. package/dist/app/demo/app.js +29 -3
  3. package/dist/app/demo/config.json +22 -3
  4. package/dist/app/demo/form/control/box/box.js +66 -0
  5. package/dist/app/demo/form/control/box/box.xml +18 -0
  6. package/dist/app/demo/form/control/button/button.js +24 -1
  7. package/dist/app/demo/form/control/check/check.js +24 -1
  8. package/dist/app/demo/form/control/dialog/dialog.js +24 -1
  9. package/dist/app/demo/form/control/file/file.js +24 -1
  10. package/dist/app/demo/form/control/flow/flow.js +24 -1
  11. package/dist/app/demo/form/control/form/form.js +24 -1
  12. package/dist/app/demo/form/control/layout/layout.js +57 -0
  13. package/dist/app/demo/form/control/layout/layout.xml +16 -0
  14. package/dist/app/demo/form/control/list/list.js +24 -1
  15. package/dist/app/demo/form/control/list/list.xml +8 -2
  16. package/dist/app/demo/form/control/marquee/marquee.js +24 -2
  17. package/dist/app/demo/form/control/marquee/marquee.xml +2 -5
  18. package/dist/app/demo/form/control/menu/menu.js +24 -1
  19. package/dist/app/demo/form/control/monaco/monaco.js +24 -1
  20. package/dist/app/demo/form/control/nav/nav.js +52 -0
  21. package/dist/app/demo/form/control/nav/nav.xml +43 -0
  22. package/dist/app/demo/form/control/panel/panel.js +67 -0
  23. package/dist/app/demo/form/control/panel/panel.xml +11 -0
  24. package/dist/app/demo/form/control/panel/test1.js +58 -0
  25. package/dist/app/demo/form/control/panel/test1.xml +16 -0
  26. package/dist/app/demo/form/control/panel/test2.xml +3 -0
  27. package/dist/app/demo/form/control/property/property.js +24 -1
  28. package/dist/app/demo/form/control/radio/radio.js +24 -1
  29. package/dist/app/demo/form/control/scroll/scroll.js +25 -1
  30. package/dist/app/demo/form/control/scroll/scroll.xml +5 -2
  31. package/dist/app/demo/form/control/select/select.js +24 -1
  32. package/dist/app/demo/form/control/tab/tab.js +24 -1
  33. package/dist/app/demo/form/control/table/table.js +164 -0
  34. package/dist/app/demo/form/control/table/table.xml +35 -0
  35. package/dist/app/demo/form/control/text/text.js +25 -1
  36. package/dist/app/demo/form/control/text/text.xml +1 -1
  37. package/dist/app/demo/form/control/vflow/vflow.js +24 -1
  38. package/dist/app/demo/form/event/form/form.js +24 -1
  39. package/dist/app/demo/form/event/other/other.js +24 -1
  40. package/dist/app/demo/form/event/screen/screen.js +24 -1
  41. package/dist/app/demo/form/event/task/task.js +24 -1
  42. package/dist/app/demo/form/main.js +130 -84
  43. package/dist/app/demo/form/main.xml +5 -0
  44. package/dist/app/demo/form/method/aform/aform.js +29 -15
  45. package/dist/app/demo/form/method/aform/aform.xml +0 -1
  46. package/dist/app/demo/form/method/aform/sd.js +25 -5
  47. package/dist/app/demo/form/method/core/core.js +24 -1
  48. package/dist/app/demo/form/method/dom/dom.js +48 -2
  49. package/dist/app/demo/form/method/dom/dom.xml +11 -0
  50. package/dist/app/demo/form/method/form/form.js +40 -7
  51. package/dist/app/demo/form/method/form/form.xml +3 -0
  52. package/dist/app/demo/form/method/{aform → form}/test.xml +0 -0
  53. package/dist/app/demo/form/method/fs/fs.js +139 -8
  54. package/dist/app/demo/form/method/fs/fs.xml +11 -1
  55. package/dist/app/demo/form/method/fs/text.js +24 -1
  56. package/dist/app/demo/form/method/native/native.js +24 -1
  57. package/dist/app/demo/form/method/system/system.js +24 -1
  58. package/dist/app/demo/form/method/task/task.js +31 -4
  59. package/dist/app/demo/form/method/task/task.xml +6 -1
  60. package/dist/app/demo/form/method/theme/theme.js +24 -1
  61. package/dist/app/demo/form/method/tool/tool.js +38 -1
  62. package/dist/app/demo/form/method/tool/tool.xml +1 -0
  63. package/dist/app/demo/form/method/zip/zip.js +30 -7
  64. package/dist/app/task/app.js +29 -3
  65. package/dist/app/task/form/bar/bar.js +24 -1
  66. package/dist/clickgo.js +33 -10
  67. package/dist/control/box.cgc +0 -0
  68. package/dist/control/common.cgc +0 -0
  69. package/dist/control/form.cgc +0 -0
  70. package/dist/control/monaco.cgc +0 -0
  71. package/dist/control/nav.cgc +0 -0
  72. package/dist/control/property.cgc +0 -0
  73. package/dist/control/table.cgc +0 -0
  74. package/dist/control/task.cgc +0 -0
  75. package/dist/global.css +1 -1
  76. package/dist/lib/control.js +53 -12
  77. package/dist/lib/control.ts +25 -5
  78. package/dist/lib/core.js +44 -50
  79. package/dist/lib/core.ts +18 -48
  80. package/dist/lib/dom.js +322 -108
  81. package/dist/lib/dom.ts +394 -127
  82. package/dist/lib/form.js +590 -226
  83. package/dist/lib/form.ts +706 -267
  84. package/dist/lib/fs.js +485 -224
  85. package/dist/lib/fs.ts +493 -287
  86. package/dist/lib/native.js +24 -1
  87. package/dist/lib/task.js +159 -139
  88. package/dist/lib/task.ts +148 -130
  89. package/dist/lib/theme.js +27 -4
  90. package/dist/lib/tool.js +57 -2
  91. package/dist/lib/tool.ts +68 -1
  92. package/dist/lib/zip.js +29 -3
  93. package/dist/lib/zip.ts +1 -1
  94. package/dist/theme/familiar.cgt +0 -0
  95. package/package.json +5 -7
  96. package/types/index.d.ts +51 -70
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
- text = text.replace(/<!--([\s\S]*?)-->/g, '').replace(/>([\s\S]*?)</g, function(t: string, t1: string) {
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 路径基准或以文件的路径为基准,以 / 结尾
@@ -573,6 +595,47 @@ export function escapeHTML(html: string): string {
573
595
  return html.replace(/</g, '&lt;').replace(/>/g, '&gt;');
574
596
  }
575
597
 
598
+ /**
599
+ * --- rgb 字符串转 hsl 数组 ---
600
+ * @param rgb rgb(x, x, x) 或直接 x,x,x
601
+ */
602
+ export function rgb2hsl(rgb: string): number[] {
603
+ if (rgb.includes('(')) {
604
+ const match = /[0-9., ]+/.exec(rgb);
605
+ if (!match) {
606
+ return [0, 0, 0];
607
+ }
608
+ rgb = match[0];
609
+ }
610
+ const arr = rgb.split(',');
611
+ const [r, g, b] = arr.map(v => parseInt(v) / 255);
612
+
613
+ const max = Math.max(r, g, b);
614
+ const min = Math.min(r, g, b);
615
+ const diff = max - min;
616
+
617
+ let h = 0 ;
618
+ const l = (max + min) / 2;
619
+ const s2 = 1 - Math.abs(max + min - 1);
620
+ const s = s2 ? (diff / s2) : 0;
621
+
622
+ switch (min) {
623
+ case max:
624
+ h = 0 ;
625
+ break;
626
+ case r:
627
+ h = (60 * ((b - g) / diff)) + 180;
628
+ break;
629
+ case g:
630
+ h = (60 * ((r - b) / diff)) + 300;
631
+ break;
632
+ case b:
633
+ h = (60 * ((g - r) / diff)) + 60;
634
+ break;
635
+ }
636
+ return [h, s, l] ;
637
+ }
638
+
576
639
  /**
577
640
  * --- 发起一个网络请求 ---
578
641
  * @param url 网址
@@ -680,6 +743,10 @@ export function urlResolve(from: string, to: string): string {
680
743
  return loader.urlResolve(from, to);
681
744
  }
682
745
 
746
+ export function urlAtom(url: string): string {
747
+ return loader.urlAtom(url);
748
+ }
749
+
683
750
  export function blob2Text(blob: Blob): Promise<string> {
684
751
  return loader.blob2Text(blob);
685
752
  }
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 jszip = require("jszip");
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 = jszip();
366
+ const z = (0, jszip_1.default)();
341
367
  try {
342
368
  if (data) {
343
369
  yield z.loadAsync(data);
package/dist/lib/zip.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as jszip from 'jszip';
1
+ import jszip from 'jszip';
2
2
  import * as types from '../../types';
3
3
  import * as tool from './tool';
4
4
 
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clickgo",
3
- "version": "3.1.4-dev13",
3
+ "version": "3.1.6-dev15",
4
4
  "description": "Background interface, software interface, mobile phone APP interface operation library.",
5
5
  "keywords": [
6
6
  "deskrt",
@@ -19,12 +19,10 @@
19
19
  },
20
20
  "devDependencies": {
21
21
  "@litert/eslint-plugin-rules": "^0.1.0",
22
- "@litert/loader": "^3.4.3",
22
+ "@litert/loader": "^3.4.4",
23
23
  "@types/node": "^18.11.14",
24
- "electron": "^19.1.3",
25
- "typescript": "^4.8.4"
26
- },
27
- "dependencies": {
28
- "jszip": "^3.10.0"
24
+ "electron": "^22.0.2",
25
+ "jszip": "^3.10.1",
26
+ "typescript": "^4.9.4"
29
27
  }
30
28
  }
package/types/index.d.ts CHANGED
@@ -88,7 +88,6 @@ export type TGlobalEvent = 'error' | 'screenResize' | 'configChanged' | 'formCre
88
88
  /** --- 现场下载 app 的参数 --- */
89
89
  export interface ICoreFetchAppOptions {
90
90
  'notifyId'?: number;
91
- 'current'?: string;
92
91
  'progress'?: (loaded: number, total: number) => void | Promise<void>;
93
92
  }
94
93
 
@@ -129,6 +128,8 @@ export interface IAppConfig {
129
128
 
130
129
  /** --- 将要加载的非 js 文件列表,打包为 cga 模式下此配置可省略 --- */
131
130
  'files'?: string[];
131
+ /** --- import 的目录映射关系 --- */
132
+ 'map'?: Record<string, string>;
132
133
  }
133
134
 
134
135
  // -------------------------
@@ -213,6 +214,7 @@ export interface IBindMoveOptions {
213
214
  'objectHeight'?: number;
214
215
  'object'?: HTMLElement | IVue;
215
216
  'showRect'?: boolean;
217
+ 'cursor'?: string;
216
218
  'start'?: (x: number, y: number) => any;
217
219
  'move'?: (e: MouseEvent | TouchEvent, opt: IBindMoveMoveOptions) => void;
218
220
  'up'?: (moveTimes: Array<{ 'time': number; 'ox': number; 'oy': number; }>, e: MouseEvent | TouchEvent) => void;
@@ -260,6 +262,33 @@ export interface IWatchItem {
260
262
  'taskId'?: number;
261
263
  }
262
264
 
265
+ /** --- 获取当前正在监视中的 property 和 style 的元素信息 --- */
266
+ export interface IGetWatchInfoResult {
267
+ 'formId': number;
268
+ 'default': Record<string, {
269
+ 'style': {
270
+ 'list': string[];
271
+ 'count': number;
272
+ };
273
+ 'property': {
274
+ 'list': string[];
275
+ 'count': number;
276
+ };
277
+ }>;
278
+ 'panels': Record<string,
279
+ Record<string, {
280
+ 'style': {
281
+ 'list': string[];
282
+ 'count': number;
283
+ };
284
+ 'property': {
285
+ 'list': string[];
286
+ 'count': number;
287
+ };
288
+ }>
289
+ >;
290
+ }
291
+
263
292
  // --------------------------
264
293
  // -------- form lib --------
265
294
  // --------------------------
@@ -284,84 +313,34 @@ export interface IFormInfo {
284
313
  'focus': boolean;
285
314
  }
286
315
 
287
- /** --- 窗体创建选项 --- */
288
- export interface IFormCreateOptions {
289
- 'code'?: IFormCreateCode;
290
- 'layout': string;
291
- 'style'?: string;
292
-
293
- /** --- 当前窗体的基准路径,不以 / 结尾,仅用作传值,App 内无法填写 --- */
294
- 'path'?: string;
295
- /** --- 传递到 onMounted 的数据 --- */
296
- 'data'?: Record<string, any>;
297
- /** --- APP 内无法填写 --- */
298
- 'taskId'?: number;
299
- }
300
-
301
- /** --- 窗体的 code 参数 --- */
302
- export interface IFormCreateCode {
303
- 'data'?: Record<string, any>;
304
- 'access'?: Record<string, any>;
305
- 'methods'?: Record<string, any>;
306
- 'computed'?: Record<string, {
307
- 'get'?: any;
308
- 'set'?: any;
309
- }>;
310
- 'beforeCreate'?: any;
311
- 'created'?: any;
312
- 'beforeMount'?: any;
313
- 'mounted'?: any;
314
- 'beforeUpdate'?: any;
315
- 'updated'?: any;
316
- 'beforeUnmount'?: any;
317
- 'unmounted'?: any;
318
- }
319
-
320
316
  // --------------------------
321
317
  // --------- fs lib ---------
322
318
  // --------------------------
323
319
 
324
320
  export interface IMountHandler {
325
- 'taskId'?: number;
321
+ /** --- 挂载时间,无需设置 --- */
322
+ 'date'?: Date;
326
323
  getContent?: (path: string, options?: BufferEncoding | {
327
324
  'encoding'?: BufferEncoding;
328
325
  'start'?: number;
329
326
  'end'?: number;
330
- 'files'?: Record<string, Blob | string>;
331
- 'current'?: string;
332
327
  'progress'?: (loaded: number, total: number) => void | Promise<void>;
333
- }) => Promise<Blob | string | null>;
328
+ }) => Blob | string | null | Promise<Blob | string | null>;
334
329
  putContent?: (path: string, data: string | Blob, options?: {
335
330
  'encoding'?: BufferEncoding | null;
336
331
  'mode'?: string | number;
337
332
  'flag'?: string | number;
338
- 'current'?: string;
339
- }) => Promise<boolean>;
340
- readLink?: (path: string, options?: BufferEncoding | {
341
- 'encoding'?: BufferEncoding;
342
- /** --- 不以 / 结尾的路径 --- */
343
- 'current'?: string;
344
- }) => Promise<string | null>;
345
- symlink?: (filePath: string, linkPath: string, options?: {
346
- 'type'?: 'dir' | 'file' | 'junction';
347
- 'current'?: string;
348
- }) => Promise<boolean>;
349
- unlink?: (path: string, options?: {
350
- 'current'?: string;
351
- }) => Promise<boolean>;
352
- stats: (path: string, options?: {
353
- 'files'?: Record<string, Blob | string>;
354
- 'current'?: string;
355
- }) => Promise<IStats | null>;
356
- mkdir: (path: string, mode?: number, options?: {
357
- 'current'?: string;
358
- }) => Promise<boolean>;
359
- rmdir: (path: string, options?: {
360
- 'current'?: string;
361
- }) => Promise<boolean>;
362
- chmod: (path: string, mod: string | number, options?: {
363
- 'current'?: string;
364
- }) => Promise<boolean>;
333
+ }) => boolean | Promise<boolean>;
334
+ readLink?: (path: string, encoding?: BufferEncoding) => string | null | Promise<string | null>;
335
+ symlink?: (filePath: string, linkPath: string, type?: 'dir' | 'file' | 'junction') => boolean | Promise<boolean>;
336
+ unlink?: (path: string) => boolean | Promise<boolean>;
337
+ stats?: (path: string) => IStats | null | Promise<IStats | null>;
338
+ mkdir?: (path: string, mode?: number) => boolean | Promise<boolean>;
339
+ rmdir?: (path: string) => boolean | Promise<boolean>;
340
+ chmod?: (path: string, mod: string | number) => boolean | Promise<boolean>;
341
+ rename?: (oldPath: string, newPath: string) => boolean | Promise<boolean>;
342
+ readDir?: (path: string, encoding?: BufferEncoding) => IDirent[] | Promise<IDirent[]>;
343
+ copyFile?: (src: string, dest: string) => boolean | Promise<boolean>;
365
344
  }
366
345
 
367
346
  /** --- 文件/文件夹信息对象 --- */
@@ -444,8 +423,6 @@ export interface ITaskRunOptions {
444
423
  'progress'?: (loaded: number, total: number) => void | Promise<void>;
445
424
  /** --- 显示 notify 窗口 --- */
446
425
  'notify'?: boolean;
447
- /** --- 所属任务,App 模式无法设置 --- */
448
- 'taskId'?: number;
449
426
  /** --- 不禁止某些浏览器对象,App 模式下仅能设置基任务中已经 unblock 的值 --- */
450
427
  'unblock'?: string[];
451
428
  /** --- 直接赋予此任务相应权限,App 模式下有 "root" 权限的应用才能设置 --- */
@@ -572,15 +549,19 @@ export interface IZipMetadata {
572
549
 
573
550
  /** --- Dialog 选项 --- */
574
551
  export interface IFormDialogOptions {
575
- /** --- 当前的 taskId,App 模式下无效 --- */
576
- 'taskId'?: number;
577
-
578
552
  'title'?: string;
579
553
  'content': string;
580
554
  'buttons'?: string[];
581
555
  'direction'?: 'h' | 'v';
582
556
 
557
+ 'style'?: string;
558
+ /** --- 路径基,以 / 结束或文件路径则以文件的基路径为准,可留空 --- */
559
+ 'path'?: string;
560
+
583
561
  'select'?: (e: Event, button: string) => void;
562
+
563
+ /** --- 当前的 taskId,App 模式下无效 --- */
564
+ 'taskId'?: number;
584
565
  }
585
566
 
586
567
  /** --- Confirm 选项 --- */