clickgo 3.1.1-dev10 → 3.1.3-dev12

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 (106) hide show
  1. package/dist/app/demo/app.js +0 -72
  2. package/dist/app/demo/config.json +109 -0
  3. package/dist/app/demo/form/control/button/button.js +12 -11
  4. package/dist/app/demo/form/control/button/button.xml +6 -6
  5. package/dist/app/demo/form/control/check/check.js +14 -10
  6. package/dist/app/demo/form/control/file/file.js +15 -13
  7. package/dist/app/demo/form/control/{overflow/overflow.css → flow/flow.css} +0 -0
  8. package/dist/app/demo/form/control/flow/flow.js +64 -0
  9. package/dist/app/demo/form/control/{overflow/overflow.scss → flow/flow.scss} +0 -0
  10. package/dist/app/demo/form/control/flow/flow.xml +101 -0
  11. package/dist/app/demo/form/control/form/form.js +1 -1
  12. package/dist/app/demo/form/control/form/form.xml +3 -3
  13. package/dist/app/demo/form/control/img/img.xml +2 -2
  14. package/dist/app/demo/form/control/list/list.js +95 -75
  15. package/dist/app/demo/form/control/list/list.xml +15 -11
  16. package/dist/app/demo/form/control/marquee/marquee.js +12 -10
  17. package/dist/app/demo/form/control/menu/menu.js +10 -6
  18. package/dist/app/demo/form/control/monaco/monaco.js +50 -60
  19. package/dist/app/demo/form/control/monaco/monaco.xml +6 -5
  20. package/dist/app/demo/form/control/property/property.js +131 -127
  21. package/dist/app/demo/form/control/radio/radio.js +9 -5
  22. package/dist/app/demo/form/control/scroll/scroll.js +16 -12
  23. package/dist/app/demo/form/control/scroll/scroll.xml +10 -10
  24. package/dist/app/demo/form/control/select/select.js +132 -71
  25. package/dist/app/demo/form/control/select/select.xml +69 -67
  26. package/dist/app/demo/form/control/tab/tab.js +21 -20
  27. package/dist/app/demo/form/control/tab/tab.xml +2 -2
  28. package/dist/app/demo/form/control/text/text.js +53 -45
  29. package/dist/app/demo/form/control/text/text.xml +3 -3
  30. package/dist/app/demo/form/control/{greatview/greatview.css → vflow/vflow.css} +0 -0
  31. package/dist/app/demo/form/control/vflow/vflow.js +79 -0
  32. package/dist/app/demo/form/control/{greatview/greatview.scss → vflow/vflow.scss} +0 -0
  33. package/dist/app/demo/form/control/{greatview/greatview.xml → vflow/vflow.xml} +25 -25
  34. package/dist/app/demo/form/event/form/form.js +58 -56
  35. package/dist/app/demo/form/event/form/form.xml +3 -3
  36. package/dist/app/demo/form/event/screen/screen.js +30 -28
  37. package/dist/app/demo/form/event/screen/screen.xml +2 -2
  38. package/dist/app/demo/form/event/task/task.js +31 -31
  39. package/dist/app/demo/form/event/task/task.xml +3 -3
  40. package/dist/app/demo/form/main.js +166 -5
  41. package/dist/app/demo/form/main.xml +37 -35
  42. package/dist/app/demo/form/method/aform/aform.js +57 -0
  43. package/dist/app/demo/form/method/aform/aform.xml +35 -0
  44. package/dist/app/demo/form/method/aform/test.xml +6 -0
  45. package/dist/app/demo/form/method/core/core.js +11 -8
  46. package/dist/app/demo/form/method/core/core.xml +2 -1
  47. package/dist/app/demo/form/method/dom/dom.js +91 -99
  48. package/dist/app/demo/form/method/dom/dom.xml +6 -7
  49. package/dist/app/demo/form/method/form/form.js +10 -28
  50. package/dist/app/demo/form/method/form/form.xml +8 -15
  51. package/dist/app/demo/form/method/fs/fs.js +34 -33
  52. package/dist/app/demo/form/method/fs/fs.xml +1 -1
  53. package/dist/app/demo/form/method/fs/text.js +12 -12
  54. package/dist/app/demo/form/method/native/native.js +50 -0
  55. package/dist/app/demo/form/method/native/native.xml +12 -0
  56. package/dist/app/demo/form/method/system/system.js +50 -0
  57. package/dist/app/demo/form/method/system/system.xml +11 -0
  58. package/dist/app/demo/form/method/task/task.js +59 -61
  59. package/dist/app/demo/form/method/task/task.xml +4 -6
  60. package/dist/app/demo/form/method/theme/theme.js +14 -14
  61. package/dist/app/demo/form/method/tool/tool.js +29 -28
  62. package/dist/app/demo/form/method/tool/tool.xml +3 -3
  63. package/dist/app/demo/form/method/zip/zip.js +46 -41
  64. package/dist/app/demo/form/method/zip/zip.xml +1 -1
  65. package/dist/app/task/app.js +0 -25
  66. package/dist/app/task/config.json +29 -0
  67. package/dist/app/task/form/bar/bar.js +2 -2
  68. package/dist/app/task/form/bar/bar.xml +1 -1
  69. package/dist/clickgo.js +17 -5
  70. package/dist/clickgo.ts +22 -3
  71. package/dist/control/common.cgc +0 -0
  72. package/dist/control/form.cgc +0 -0
  73. package/dist/control/monaco.cgc +0 -0
  74. package/dist/control/property.cgc +0 -0
  75. package/dist/control/task.cgc +0 -0
  76. package/dist/global.css +1 -1
  77. package/dist/index.js +28 -8
  78. package/dist/index.ts +33 -7
  79. package/dist/lib/control.js +75 -105
  80. package/dist/lib/control.ts +102 -124
  81. package/dist/lib/core.js +108 -252
  82. package/dist/lib/core.ts +122 -268
  83. package/dist/lib/dom.js +564 -483
  84. package/dist/lib/dom.ts +703 -546
  85. package/dist/lib/form.js +170 -153
  86. package/dist/lib/form.ts +132 -99
  87. package/dist/lib/fs.js +1 -1
  88. package/dist/lib/fs.ts +1 -1
  89. package/dist/lib/native.js +135 -8
  90. package/dist/lib/native.ts +176 -12
  91. package/dist/lib/task.js +301 -175
  92. package/dist/lib/task.ts +330 -207
  93. package/dist/lib/tool.js +48 -1
  94. package/dist/lib/tool.ts +61 -0
  95. package/dist/lib/zip.ts +2 -0
  96. package/dist/theme/familiar.cgt +0 -0
  97. package/package.json +1 -1
  98. package/types/index.d.ts +26 -29
  99. package/dist/app/demo/form/control/greatview/greatview.js +0 -92
  100. package/dist/app/demo/form/control/overflow/overflow.js +0 -70
  101. package/dist/app/demo/form/control/overflow/overflow.xml +0 -98
  102. package/dist/app/demo/form/control/view/view.css +0 -1
  103. package/dist/app/demo/form/control/view/view.js +0 -73
  104. package/dist/app/demo/form/control/view/view.scss +0 -18
  105. package/dist/app/demo/form/control/view/view.xml +0 -94
  106. package/dist/app/demo/form/method/form/test.xml +0 -5
package/dist/lib/core.js CHANGED
@@ -9,16 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getAvailArea = exports.fetchApp = exports.readApp = exports.trigger = exports.getModule = exports.initModules = exports.regModule = exports.boot = exports.getCdn = exports.AbstractApp = exports.config = void 0;
12
+ exports.getAvailArea = exports.fetchApp = exports.readApp = exports.trigger = exports.getModule = exports.regModule = exports.boot = exports.getCdn = exports.AbstractApp = exports.config = void 0;
13
13
  const clickgo = require("../clickgo");
14
14
  const fs = require("./fs");
15
15
  const form = require("./form");
16
16
  const task = require("./task");
17
17
  const tool = require("./tool");
18
- const control = require("./control");
19
- const theme = require("./theme");
20
18
  const zip = require("./zip");
21
- const dom = require("./dom");
22
19
  const configOrigin = {
23
20
  'locale': 'en',
24
21
  'task.position': 'bottom',
@@ -53,147 +50,6 @@ class AbstractApp {
53
50
  'type': 'danger'
54
51
  });
55
52
  }
56
- config(config) {
57
- var _a;
58
- return __awaiter(this, void 0, void 0, function* () {
59
- const t = task.list[this.taskId];
60
- if (!t) {
61
- return false;
62
- }
63
- t.config = config;
64
- if (t.app.net) {
65
- if (!t.config.files) {
66
- return false;
67
- }
68
- const files = t.config.files;
69
- const net = t.app.net;
70
- yield new Promise(function (resolve) {
71
- var _a;
72
- let loaded = 0;
73
- const total = files.length;
74
- const beforeTotal = Object.keys(t.app.files).length;
75
- (_a = net.progress) === null || _a === void 0 ? void 0 : _a.call(net, loaded + beforeTotal, total + beforeTotal);
76
- for (const file of files) {
77
- fs.getContent(net.url + file.slice(1), {
78
- 'current': net.current
79
- }).then(function (blob) {
80
- var _a;
81
- return __awaiter(this, void 0, void 0, function* () {
82
- if (blob === null || typeof blob === 'string') {
83
- clickgo.form.notify({
84
- 'title': 'File not found',
85
- 'content': net.url + file.slice(1),
86
- 'type': 'danger'
87
- });
88
- return;
89
- }
90
- const mime = tool.getMimeByPath(file);
91
- if (['txt', 'json', 'js', 'css', 'xml', 'html'].includes(mime.ext)) {
92
- t.app.files[file] = (yield tool.blob2Text(blob)).replace(/^\ufeff/, '');
93
- }
94
- else {
95
- t.app.files[file] = blob;
96
- }
97
- ++loaded;
98
- (_a = net.progress) === null || _a === void 0 ? void 0 : _a.call(net, loaded + beforeTotal, total + beforeTotal);
99
- if (net.notify) {
100
- form.notifyProgress(net.notify, (loaded / total) / 2 + 0.5);
101
- }
102
- if (loaded < total) {
103
- return;
104
- }
105
- resolve();
106
- });
107
- }).catch(function () {
108
- var _a;
109
- ++loaded;
110
- (_a = net.progress) === null || _a === void 0 ? void 0 : _a.call(net, loaded + beforeTotal, total + beforeTotal);
111
- if (net.notify) {
112
- form.notifyProgress(net.notify, (loaded / total) / 2 + 0.5);
113
- }
114
- if (loaded < total) {
115
- return;
116
- }
117
- resolve();
118
- });
119
- }
120
- });
121
- if (net.notify) {
122
- setTimeout(function () {
123
- form.hideNotify(net.notify);
124
- }, 2000);
125
- }
126
- }
127
- if (!(yield control.init(this.taskId))) {
128
- return false;
129
- }
130
- if ((_a = config.themes) === null || _a === void 0 ? void 0 : _a.length) {
131
- for (let path of config.themes) {
132
- path += '.cgt';
133
- path = tool.urlResolve('/', path);
134
- const file = yield fs.getContent(path, {
135
- 'files': t.app.files,
136
- 'current': t.current
137
- });
138
- if (file && typeof file !== 'string') {
139
- const th = yield theme.read(file);
140
- if (th) {
141
- yield theme.load(th, t.id);
142
- }
143
- }
144
- }
145
- }
146
- else {
147
- if (theme.global) {
148
- yield theme.load(undefined, this.taskId);
149
- }
150
- }
151
- if (config.locales) {
152
- for (let path in config.locales) {
153
- const locale = config.locales[path];
154
- if (!path.endsWith('.json')) {
155
- path += '.json';
156
- }
157
- const lcontent = yield fs.getContent(path, {
158
- 'encoding': 'utf8',
159
- 'files': t.app.files,
160
- 'current': t.current
161
- });
162
- if (!lcontent) {
163
- continue;
164
- }
165
- try {
166
- const data = JSON.parse(lcontent);
167
- task.loadLocaleData(locale, data, '', t.id);
168
- }
169
- catch (_b) {
170
- }
171
- }
172
- }
173
- if (config.style) {
174
- const style = yield fs.getContent(config.style + '.css', {
175
- 'encoding': 'utf8',
176
- 'files': t.app.files,
177
- 'current': t.current
178
- });
179
- if (style) {
180
- const r = tool.stylePrepend(style, 'cg-task' + this.taskId.toString() + '_');
181
- dom.pushStyle(this.taskId, yield tool.styleUrl2DataUrl(config.style, r.style, t.app.files));
182
- }
183
- }
184
- if (config.icon) {
185
- const icon = yield fs.getContent(config.icon, {
186
- 'files': t.app.files,
187
- 'current': t.current
188
- });
189
- if (icon && typeof icon !== 'string') {
190
- t.app.icon = yield tool.blob2DataUrl(icon);
191
- }
192
- }
193
- t.class = this;
194
- return true;
195
- });
196
- }
197
53
  run(form) {
198
54
  if (typeof form === 'number') {
199
55
  const msg = 'Application run error, Form creation failed (' + form.toString() + ').';
@@ -322,7 +178,8 @@ const modules = {
322
178
  });
323
179
  },
324
180
  'obj': null,
325
- 'loading': false
181
+ 'loading': false,
182
+ 'resolve': []
326
183
  }
327
184
  };
328
185
  function regModule(name, func) {
@@ -332,87 +189,53 @@ function regModule(name, func) {
332
189
  modules[name] = {
333
190
  func: func,
334
191
  'obj': null,
335
- 'loading': false
192
+ 'loading': false,
193
+ 'resolve': []
336
194
  };
337
195
  return true;
338
196
  }
339
197
  exports.regModule = regModule;
340
- function initModules(names) {
341
- return new Promise(function (resolve) {
342
- if (typeof names === 'string') {
343
- names = [names];
344
- }
345
- if (names.length === 0) {
346
- resolve(0);
347
- return;
198
+ function getModule(name) {
199
+ return new Promise((resolve) => {
200
+ if (!modules[name]) {
201
+ return null;
348
202
  }
349
- let loaded = 0;
350
- let successful = 0;
351
- for (const name of names) {
352
- if (!modules[name]) {
353
- ++loaded;
354
- if (loaded === names.length) {
355
- resolve(successful);
356
- return;
357
- }
358
- continue;
359
- }
360
- if (modules[name].obj) {
361
- ++loaded;
362
- ++successful;
363
- if (loaded === names.length) {
364
- resolve(successful);
365
- return;
366
- }
367
- continue;
368
- }
203
+ if (!modules[name].obj) {
369
204
  if (modules[name].loading) {
370
- ++loaded;
371
- if (loaded === names.length) {
372
- resolve(successful);
373
- return;
374
- }
375
- continue;
376
- }
377
- modules[name].loading = true;
378
- const rtn = modules[name].func();
379
- if (rtn instanceof Promise) {
380
- rtn.then(function (obj) {
381
- modules[name].obj = obj;
382
- modules[name].loading = false;
383
- ++loaded;
384
- ++successful;
385
- if (loaded === names.length) {
386
- resolve(successful);
387
- return;
388
- }
389
- }).catch(function () {
390
- modules[name].loading = false;
391
- ++loaded;
392
- if (loaded === names.length) {
393
- resolve(successful);
394
- }
205
+ modules[name].resolve.push(() => {
206
+ resolve(modules[name].obj);
395
207
  });
396
208
  }
397
209
  else {
398
- modules[name].obj = rtn;
399
- modules[name].loading = false;
400
- ++loaded;
401
- ++successful;
402
- if (loaded === names.length) {
403
- resolve(successful);
210
+ const rtn = modules[name].func();
211
+ if (rtn instanceof Promise) {
212
+ modules[name].loading = true;
213
+ rtn.then(function (obj) {
214
+ modules[name].obj = obj;
215
+ modules[name].loading = false;
216
+ resolve(obj);
217
+ for (const r of modules[name].resolve) {
218
+ r();
219
+ }
220
+ }).catch(function () {
221
+ modules[name].loading = false;
222
+ resolve(null);
223
+ for (const r of modules[name].resolve) {
224
+ r();
225
+ }
226
+ });
227
+ }
228
+ else {
229
+ modules[name].obj = rtn;
230
+ resolve(rtn);
404
231
  }
405
232
  }
233
+ return;
406
234
  }
235
+ resolve(modules[name].obj);
236
+ return;
407
237
  });
408
238
  }
409
- exports.initModules = initModules;
410
- function getModule(name) {
411
- if (!modules[name]) {
412
- return null;
413
- }
414
- return modules[name].obj;
415
- }
416
239
  exports.getModule = getModule;
417
240
  const globalEvents = {
418
241
  screenResize: function () {
@@ -598,6 +421,11 @@ function readApp(blob) {
598
421
  return false;
599
422
  }
600
423
  const files = {};
424
+ const configContent = yield z.getContent('/config.json');
425
+ if (!configContent) {
426
+ return false;
427
+ }
428
+ const config = JSON.parse(configContent);
601
429
  const list = z.readDir('/', {
602
430
  'hasChildren': true
603
431
  });
@@ -621,8 +449,10 @@ function readApp(blob) {
621
449
  }
622
450
  }
623
451
  return {
624
- 'icon': icon,
625
- 'files': files
452
+ 'type': 'app',
453
+ 'config': config,
454
+ 'files': files,
455
+ 'icon': icon
626
456
  };
627
457
  });
628
458
  }
@@ -679,50 +509,76 @@ function fetchApp(url, opt = {}) {
679
509
  return null;
680
510
  }
681
511
  }
682
- let loaded = 0;
683
- let total = 30;
684
- const files = yield loader.sniffFiles(url + 'app.js', {
685
- 'dir': '/',
686
- adapter: (url) => __awaiter(this, void 0, void 0, function* () {
687
- const r = yield fs.getContent(url, {
688
- 'encoding': 'utf8',
689
- 'current': current
690
- });
691
- return r;
692
- }),
693
- 'loaded': () => {
694
- ++loaded;
695
- if (loaded === total) {
696
- ++total;
697
- }
698
- if (opt.notifyId) {
699
- form.notifyProgress(opt.notifyId, (loaded / total) / 2);
512
+ let config;
513
+ const files = {};
514
+ try {
515
+ const blob = yield fs.getContent(url + 'config.json', {
516
+ 'current': current
517
+ });
518
+ if (blob === null || typeof blob === 'string') {
519
+ return null;
520
+ }
521
+ config = JSON.parse(yield tool.blob2Text(blob));
522
+ yield new Promise(function (resolve) {
523
+ if (!config.files) {
524
+ return;
700
525
  }
701
- if (opt.progress) {
702
- opt.progress(loaded, total);
526
+ const total = config.files.length;
527
+ let loaded = 0;
528
+ for (const file of config.files) {
529
+ fs.getContent(url + file.slice(1), {
530
+ 'current': current
531
+ }).then(function (blob) {
532
+ return __awaiter(this, void 0, void 0, function* () {
533
+ if (blob === null || typeof blob === 'string') {
534
+ clickgo.form.notify({
535
+ 'title': 'File not found',
536
+ 'content': url + file.slice(1),
537
+ 'type': 'danger'
538
+ });
539
+ return;
540
+ }
541
+ const mime = tool.getMimeByPath(file);
542
+ if (['txt', 'json', 'js', 'css', 'xml', 'html'].includes(mime.ext)) {
543
+ files[file] = (yield tool.blob2Text(blob)).replace(/^\ufeff/, '');
544
+ }
545
+ else {
546
+ files[file] = blob;
547
+ }
548
+ ++loaded;
549
+ if (opt.notifyId) {
550
+ form.notifyProgress(opt.notifyId, loaded / total);
551
+ }
552
+ if (loaded < total) {
553
+ return;
554
+ }
555
+ resolve();
556
+ });
557
+ }).catch(function () {
558
+ ++loaded;
559
+ if (opt.notifyId) {
560
+ form.notifyProgress(opt.notifyId, loaded / total);
561
+ }
562
+ if (loaded < total) {
563
+ return;
564
+ }
565
+ resolve();
566
+ });
703
567
  }
704
- }
705
- });
706
- if (opt.notifyId) {
707
- form.notifyProgress(opt.notifyId, 0.5);
568
+ });
708
569
  }
709
- if (Object.keys(files).length === 0) {
570
+ catch (_b) {
710
571
  return null;
711
572
  }
712
- const ul = url.length - 1;
713
- for (const fn in files) {
714
- files[fn.slice(ul)] = files[fn];
715
- delete files[fn];
573
+ let icon = '/clickgo/icon.png';
574
+ if (config.icon && (files[config.icon] instanceof Blob)) {
575
+ icon = yield tool.blob2DataUrl(files[config.icon]);
716
576
  }
717
577
  return {
718
- 'net': {
719
- 'current': current,
720
- 'notify': opt.notifyId,
721
- 'url': url,
722
- 'progress': opt.progress
723
- },
724
- 'icon': '',
725
- 'files': files
578
+ 'type': 'app',
579
+ 'config': config,
580
+ 'files': files,
581
+ 'icon': icon
726
582
  };
727
583
  });
728
584
  }