clickgo 3.1.2-dev11 → 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 (103) hide show
  1. package/dist/app/demo/app.js +0 -73
  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 +161 -5
  41. package/dist/app/demo/form/main.xml +36 -35
  42. package/dist/app/demo/form/method/aform/aform.xml +3 -2
  43. package/dist/app/demo/form/method/core/core.js +11 -8
  44. package/dist/app/demo/form/method/core/core.xml +2 -1
  45. package/dist/app/demo/form/method/dom/dom.js +91 -99
  46. package/dist/app/demo/form/method/dom/dom.xml +6 -7
  47. package/dist/app/demo/form/method/form/form.js +8 -8
  48. package/dist/app/demo/form/method/form/form.xml +4 -4
  49. package/dist/app/demo/form/method/fs/fs.js +34 -33
  50. package/dist/app/demo/form/method/fs/fs.xml +1 -1
  51. package/dist/app/demo/form/method/fs/text.js +12 -12
  52. package/dist/app/demo/form/method/native/native.js +50 -0
  53. package/dist/app/demo/form/method/native/native.xml +12 -0
  54. package/dist/app/demo/form/method/system/system.js +50 -0
  55. package/dist/app/demo/form/method/system/system.xml +11 -0
  56. package/dist/app/demo/form/method/task/task.js +59 -61
  57. package/dist/app/demo/form/method/task/task.xml +4 -6
  58. package/dist/app/demo/form/method/theme/theme.js +14 -14
  59. package/dist/app/demo/form/method/tool/tool.js +29 -28
  60. package/dist/app/demo/form/method/tool/tool.xml +3 -3
  61. package/dist/app/demo/form/method/zip/zip.js +46 -41
  62. package/dist/app/demo/form/method/zip/zip.xml +1 -1
  63. package/dist/app/task/app.js +0 -25
  64. package/dist/app/task/config.json +29 -0
  65. package/dist/app/task/form/bar/bar.js +1 -1
  66. package/dist/app/task/form/bar/bar.xml +1 -1
  67. package/dist/clickgo.js +1 -1
  68. package/dist/clickgo.ts +1 -1
  69. package/dist/control/common.cgc +0 -0
  70. package/dist/control/form.cgc +0 -0
  71. package/dist/control/monaco.cgc +0 -0
  72. package/dist/control/property.cgc +0 -0
  73. package/dist/control/task.cgc +0 -0
  74. package/dist/global.css +1 -1
  75. package/dist/index.js +3 -3
  76. package/dist/index.ts +3 -3
  77. package/dist/lib/control.js +70 -104
  78. package/dist/lib/control.ts +97 -123
  79. package/dist/lib/core.js +108 -252
  80. package/dist/lib/core.ts +122 -268
  81. package/dist/lib/dom.js +564 -483
  82. package/dist/lib/dom.ts +703 -546
  83. package/dist/lib/form.js +146 -138
  84. package/dist/lib/form.ts +108 -86
  85. package/dist/lib/fs.js +1 -1
  86. package/dist/lib/fs.ts +1 -1
  87. package/dist/lib/native.js +135 -8
  88. package/dist/lib/native.ts +175 -11
  89. package/dist/lib/task.js +294 -158
  90. package/dist/lib/task.ts +326 -172
  91. package/dist/lib/tool.js +48 -1
  92. package/dist/lib/tool.ts +61 -0
  93. package/dist/lib/zip.ts +2 -0
  94. package/dist/theme/familiar.cgt +0 -0
  95. package/package.json +1 -1
  96. package/types/index.d.ts +23 -24
  97. package/dist/app/demo/form/control/greatview/greatview.js +0 -92
  98. package/dist/app/demo/form/control/overflow/overflow.js +0 -70
  99. package/dist/app/demo/form/control/overflow/overflow.xml +0 -98
  100. package/dist/app/demo/form/control/view/view.css +0 -1
  101. package/dist/app/demo/form/control/view/view.js +0 -73
  102. package/dist/app/demo/form/control/view/view.scss +0 -18
  103. package/dist/app/demo/form/control/view/view.xml +0 -94
package/dist/lib/task.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.refreshSystemPosition = exports.clearSystem = exports.setSystem = exports.systemTaskInfo = exports.sleep = exports.removeTimer = exports.createTimer = exports.clearLocaleLang = exports.setLocaleLang = exports.setLocale = exports.clearLocale = exports.loadLocale = exports.loadLocaleData = exports.end = exports.run = exports.getList = exports.get = exports.offFrame = exports.onFrame = exports.lastId = exports.list = void 0;
12
+ exports.refreshSystemPosition = exports.clearSystem = exports.setSystem = exports.systemTaskInfo = exports.sleep = exports.removeTimer = exports.createTimer = exports.clearLocaleLang = exports.setLocaleLang = exports.setLocale = exports.clearLocale = exports.loadLocale = exports.loadLocaleData = exports.end = exports.run = exports.getList = exports.get = exports.offFrame = exports.onFrame = exports.getFocus = exports.setFocus = exports.lastId = exports.list = void 0;
13
13
  const clickgo = require("../clickgo");
14
14
  const core = require("./core");
15
15
  const dom = require("./dom");
@@ -17,9 +17,19 @@ const tool = require("./tool");
17
17
  const form = require("./form");
18
18
  const control = require("./control");
19
19
  const fs = require("./fs");
20
+ const theme = require("./theme");
20
21
  const native = require("./native");
21
22
  exports.list = {};
22
23
  exports.lastId = 0;
24
+ let focusId = null;
25
+ function setFocus(id) {
26
+ focusId = id !== null && id !== void 0 ? id : null;
27
+ }
28
+ exports.setFocus = setFocus;
29
+ function getFocus() {
30
+ return focusId;
31
+ }
32
+ exports.getFocus = getFocus;
23
33
  const localeData = {
24
34
  'en': {
25
35
  'loading': 'Loading...',
@@ -125,7 +135,7 @@ function get(tid) {
125
135
  return null;
126
136
  }
127
137
  return {
128
- 'name': exports.list[tid].config.name,
138
+ 'name': exports.list[tid].app.config.name,
129
139
  'locale': exports.list[tid].locale.lang,
130
140
  'customTheme': exports.list[tid].customTheme,
131
141
  'formCount': Object.keys(exports.list[tid].forms).length,
@@ -140,7 +150,7 @@ function getList() {
140
150
  for (const tid in exports.list) {
141
151
  const item = exports.list[tid];
142
152
  rtn[tid] = {
143
- 'name': item.config.name,
153
+ 'name': item.app.config.name,
144
154
  'locale': item.locale.lang,
145
155
  'customTheme': item.customTheme,
146
156
  'formCount': Object.keys(item.forms).length,
@@ -181,27 +191,41 @@ function run(url, opt = {}) {
181
191
  'current': ntask ? ntask.current : undefined,
182
192
  'progress': opt.progress
183
193
  });
184
- if (!app) {
185
- if (notifyId) {
186
- setTimeout(function () {
187
- form.hideNotify(notifyId);
188
- }, 2000);
189
- }
190
- return -1;
191
- }
192
- if (notifyId && !app.net) {
194
+ if (notifyId) {
193
195
  setTimeout(function () {
194
196
  form.hideNotify(notifyId);
195
197
  }, 2000);
196
198
  }
199
+ if (!app) {
200
+ return -1;
201
+ }
197
202
  const taskId = ++exports.lastId;
198
- const unblock = (_c = opt.unblock) !== null && _c !== void 0 ? _c : [];
203
+ const unblock = opt.unblock ? tool.clone(opt.unblock) : [];
204
+ const unblockSys = [
205
+ 'require',
206
+ '__awaiter', 'eval', 'Math', 'Array', 'Blob', 'Error', 'Infinity', 'parseInt', 'parseFloat', 'Promise', 'Date', 'JSON', 'fetch'
207
+ ];
208
+ for (const name of unblockSys) {
209
+ if (unblock.includes(name)) {
210
+ continue;
211
+ }
212
+ unblock.push(name);
213
+ }
199
214
  const invoke = {};
200
215
  if (!unblock.includes('window')) {
201
- invoke.window = undefined;
216
+ invoke.window = {};
217
+ for (const name of unblock) {
218
+ if (window[name] === undefined) {
219
+ continue;
220
+ }
221
+ invoke.window[name] = window[name];
222
+ }
202
223
  }
203
224
  const ks = Object.getOwnPropertyNames(window);
204
225
  for (const k of ks) {
226
+ if (k.includes('window')) {
227
+ continue;
228
+ }
205
229
  if (k.includes('Event')) {
206
230
  continue;
207
231
  }
@@ -211,12 +235,6 @@ function run(url, opt = {}) {
211
235
  if (/^[0-9]+$/.test(k)) {
212
236
  continue;
213
237
  }
214
- if ([
215
- 'require',
216
- '__awaiter', 'eval', 'Math', 'Array', 'Blob', 'Infinity', 'parseInt', 'parseFloat', 'Promise', 'Date', 'JSON', 'fetch'
217
- ].includes(k)) {
218
- continue;
219
- }
220
238
  if (unblock.includes(k)) {
221
239
  continue;
222
240
  }
@@ -293,89 +311,92 @@ function run(url, opt = {}) {
293
311
  getCdn: function () {
294
312
  return core.getCdn();
295
313
  },
296
- initModules: function (names) {
297
- return clickgo.core.initModules(names);
298
- },
299
314
  getModule: function (name) {
300
- return clickgo.core.getModule(name);
315
+ return core.getModule(name);
301
316
  },
302
317
  readApp: function (blob) {
303
- return clickgo.core.readApp(blob);
318
+ return core.readApp(blob);
304
319
  },
305
320
  getAvailArea: function () {
306
- return clickgo.core.getAvailArea();
321
+ return core.getAvailArea();
307
322
  }
308
323
  },
309
324
  'dom': {
310
325
  setGlobalCursor: function (type) {
311
- clickgo.dom.setGlobalCursor(type);
326
+ dom.setGlobalCursor(type);
312
327
  },
313
328
  hasTouchButMouse: function (e) {
314
- return clickgo.dom.hasTouchButMouse(e);
329
+ return dom.hasTouchButMouse(e);
315
330
  },
316
331
  getStyleCount: function (taskId, type) {
317
- return clickgo.dom.getStyleCount(taskId, type);
318
- },
319
- getSize: function (el) {
320
- return clickgo.dom.getSize(el);
332
+ return dom.getStyleCount(taskId, type);
321
333
  },
322
334
  watchSize: function (el, cb, immediate = false) {
323
- return clickgo.dom.watchSize(el, cb, immediate, taskId);
335
+ return dom.watchSize(el, cb, immediate, taskId);
324
336
  },
325
337
  unwatchSize: function (el) {
326
- clickgo.dom.unwatchSize(el, taskId);
338
+ dom.unwatchSize(el, taskId);
327
339
  },
328
- clearWatchSize() {
329
- clickgo.dom.clearWatchSize(taskId);
340
+ isWatchSize(el) {
341
+ return dom.isWatchSize(el);
330
342
  },
331
343
  watch: function (el, cb, mode = 'default', immediate = false) {
332
- clickgo.dom.watch(el, cb, mode, immediate, taskId);
344
+ dom.watch(el, cb, mode, immediate, taskId);
333
345
  },
334
346
  unwatch: function (el) {
335
- clickgo.dom.unwatch(el, taskId);
347
+ dom.unwatch(el, taskId);
336
348
  },
337
- clearWatch: function () {
338
- clickgo.dom.clearWatch(taskId);
349
+ isWatch(el) {
350
+ return dom.isWatch(el);
339
351
  },
340
352
  watchStyle: function (el, name, cb, immediate = false) {
341
- clickgo.dom.watchStyle(el, name, cb, immediate);
353
+ dom.watchStyle(el, name, cb, immediate);
342
354
  },
343
355
  isWatchStyle: function (el) {
344
- return clickgo.dom.isWatchStyle(el);
356
+ return dom.isWatchStyle(el);
357
+ },
358
+ watchProperty(el, name, cb, immediate = false) {
359
+ dom.watchProperty(el, name, cb, immediate);
360
+ },
361
+ isWatchProperty(el) {
362
+ return dom.isWatchProperty(el);
363
+ },
364
+ bindClick(e, handler) {
365
+ dom.bindClick(e, handler);
345
366
  },
346
367
  bindDown: function (oe, opt) {
347
- clickgo.dom.bindDown(oe, opt);
368
+ dom.bindDown(oe, opt);
348
369
  },
349
- bindGesture: function (e, opt) {
350
- clickgo.dom.bindGesture(e, opt);
370
+ bindGesture: function (oe, before, handler) {
371
+ dom.bindGesture(oe, before, handler);
351
372
  },
352
373
  bindLong: function (e, long) {
353
- clickgo.dom.bindLong(e, long);
374
+ dom.bindLong(e, long);
354
375
  },
355
376
  bindDrag: function (e, opt) {
356
- clickgo.dom.bindDrag(e, opt);
377
+ dom.bindDrag(e, opt);
357
378
  },
358
- 'is': clickgo.dom.is,
379
+ 'is': dom.is,
359
380
  bindMove: function (e, opt) {
360
- return clickgo.dom.bindMove(e, opt);
381
+ return dom.bindMove(e, opt);
361
382
  },
362
383
  bindResize: function (e, opt) {
363
- clickgo.dom.bindResize(e, opt);
384
+ dom.bindResize(e, opt);
364
385
  },
365
386
  findParentByData: function (el, name) {
366
- return clickgo.dom.findParentByData(el, name);
387
+ return dom.findParentByData(el, name);
367
388
  },
368
389
  findParentByClass: function (el, name) {
369
- return clickgo.dom.findParentByClass(el, name);
390
+ return dom.findParentByClass(el, name);
370
391
  },
371
392
  siblings: function (el) {
372
- return clickgo.dom.siblings(el);
393
+ return dom.siblings(el);
373
394
  },
374
395
  siblingsData: function (el, name) {
375
- return clickgo.dom.siblingsData(el, name);
396
+ return dom.siblingsData(el, name);
376
397
  },
377
398
  fullscreen: function () {
378
- return clickgo.dom.fullscreen();
399
+ return dom.fullscreen();
379
400
  }
380
401
  },
381
402
  'form': {
@@ -385,73 +406,76 @@ function run(url, opt = {}) {
385
406
  }
386
407
  },
387
408
  min: function (fid) {
388
- return clickgo.form.min(fid);
409
+ return form.min(fid);
389
410
  },
390
411
  max: function max(fid) {
391
- return clickgo.form.max(fid);
412
+ return form.max(fid);
392
413
  },
393
414
  close: function (fid) {
394
- return clickgo.form.close(fid);
415
+ return form.close(fid);
395
416
  },
396
417
  bindResize: function (e, border) {
397
- clickgo.form.bindResize(e, border);
418
+ form.bindResize(e, border);
398
419
  },
399
420
  bindDrag: function (e) {
400
- clickgo.form.bindDrag(e);
421
+ form.bindDrag(e);
401
422
  },
402
423
  getTaskId: function (fid) {
403
- return clickgo.form.getTaskId(fid);
424
+ return form.getTaskId(fid);
404
425
  },
405
426
  get: function (fid) {
406
- return clickgo.form.get(fid);
427
+ return form.get(fid);
407
428
  },
408
429
  getList: function (tid) {
409
- return clickgo.form.getList(tid);
430
+ return form.getList(tid);
431
+ },
432
+ getFocus: function () {
433
+ return form.getFocus();
410
434
  },
411
435
  changeFocus: function (fid = 0) {
412
- clickgo.form.changeFocus(fid);
436
+ form.changeFocus(fid);
413
437
  },
414
438
  getMaxZIndexID: function (out) {
415
- return clickgo.form.getMaxZIndexID(out);
439
+ return form.getMaxZIndexID(out);
416
440
  },
417
441
  getRectByBorder: function (border) {
418
- return clickgo.form.getRectByBorder(border);
442
+ return form.getRectByBorder(border);
419
443
  },
420
444
  showCircular: function (x, y) {
421
- clickgo.form.showCircular(x, y);
445
+ form.showCircular(x, y);
422
446
  },
423
447
  moveRectangle: function (border) {
424
- clickgo.form.moveRectangle(border);
448
+ form.moveRectangle(border);
425
449
  },
426
450
  showRectangle: function (x, y, border) {
427
- clickgo.form.showRectangle(x, y, border);
451
+ form.showRectangle(x, y, border);
428
452
  },
429
453
  hideRectangle: function () {
430
- clickgo.form.hideRectangle();
454
+ form.hideRectangle();
431
455
  },
432
456
  showDrag: function () {
433
- clickgo.form.showDrag();
457
+ form.showDrag();
434
458
  },
435
459
  moveDrag: function (opt) {
436
- clickgo.form.moveDrag(opt);
460
+ form.moveDrag(opt);
437
461
  },
438
462
  hideDrag: function () {
439
- clickgo.form.hideDrag();
463
+ form.hideDrag();
440
464
  },
441
465
  notify: function (opt) {
442
- return clickgo.form.notify(opt);
466
+ return form.notify(opt);
443
467
  },
444
468
  notifyProgress: function (notifyId, per) {
445
- clickgo.form.notifyProgress(notifyId, per);
469
+ form.notifyProgress(notifyId, per);
446
470
  },
447
471
  hideNotify: function (notifyId) {
448
- clickgo.form.hideNotify(notifyId);
472
+ form.hideNotify(notifyId);
449
473
  },
450
474
  showPop: function (el, pop, direction, opt = {}) {
451
- clickgo.form.showPop(el, pop, direction, opt);
475
+ form.showPop(el, pop, direction, opt);
452
476
  },
453
477
  hidePop: function (pop) {
454
- clickgo.form.hidePop(pop);
478
+ form.hidePop(pop);
455
479
  },
456
480
  dialog: function (opt) {
457
481
  if (typeof opt === 'string') {
@@ -460,7 +484,7 @@ function run(url, opt = {}) {
460
484
  };
461
485
  }
462
486
  opt.taskId = taskId;
463
- return clickgo.form.dialog(opt);
487
+ return form.dialog(opt);
464
488
  },
465
489
  confirm: function (opt) {
466
490
  if (typeof opt === 'string') {
@@ -469,16 +493,16 @@ function run(url, opt = {}) {
469
493
  };
470
494
  }
471
495
  opt.taskId = taskId;
472
- return clickgo.form.confirm(opt);
496
+ return form.confirm(opt);
473
497
  },
474
498
  flash: function (fid) {
475
- clickgo.form.flash(fid, taskId);
499
+ form.flash(fid, taskId);
476
500
  },
477
501
  showLauncher: function () {
478
- clickgo.form.showLauncher();
502
+ form.showLauncher();
479
503
  },
480
504
  hideLauncher: function () {
481
- clickgo.form.hideLauncher();
505
+ form.hideLauncher();
482
506
  }
483
507
  },
484
508
  'fs': {
@@ -489,31 +513,31 @@ function run(url, opt = {}) {
489
513
  if (!options.current) {
490
514
  options.current = exports.list[taskId].current;
491
515
  }
492
- return clickgo.fs.getContent(path, options);
516
+ return fs.getContent(path, options);
493
517
  },
494
518
  putContent: function (path, data, options = {}) {
495
519
  if (!options.current) {
496
520
  options.current = exports.list[taskId].current;
497
521
  }
498
- return clickgo.fs.putContent(path, data, options);
522
+ return fs.putContent(path, data, options);
499
523
  },
500
524
  readLink: function (path, options = {}) {
501
525
  if (!options.current) {
502
526
  options.current = exports.list[taskId].current;
503
527
  }
504
- return clickgo.fs.readLink(path, options);
528
+ return fs.readLink(path, options);
505
529
  },
506
530
  symlink: function (fPath, linkPath, options = {}) {
507
531
  if (!options.current) {
508
532
  options.current = exports.list[taskId].current;
509
533
  }
510
- return clickgo.fs.symlink(fPath, linkPath, options);
534
+ return fs.symlink(fPath, linkPath, options);
511
535
  },
512
536
  unlink: function (path, options = {}) {
513
537
  if (!options.current) {
514
538
  options.current = exports.list[taskId].current;
515
539
  }
516
- return clickgo.fs.unlink(path, options);
540
+ return fs.unlink(path, options);
517
541
  },
518
542
  stats: function (path, options = {}) {
519
543
  if (!options.files) {
@@ -522,7 +546,7 @@ function run(url, opt = {}) {
522
546
  if (!options.current) {
523
547
  options.current = exports.list[taskId].current;
524
548
  }
525
- return clickgo.fs.stats(path, options);
549
+ return fs.stats(path, options);
526
550
  },
527
551
  isDir: function (path, options = {}) {
528
552
  if (!options.files) {
@@ -531,7 +555,7 @@ function run(url, opt = {}) {
531
555
  if (!options.current) {
532
556
  options.current = exports.list[taskId].current;
533
557
  }
534
- return clickgo.fs.isDir(path, options);
558
+ return fs.isDir(path, options);
535
559
  },
536
560
  isFile: function (path, options = {}) {
537
561
  if (!options.files) {
@@ -540,37 +564,37 @@ function run(url, opt = {}) {
540
564
  if (!options.current) {
541
565
  options.current = exports.list[taskId].current;
542
566
  }
543
- return clickgo.fs.isFile(path, options);
567
+ return fs.isFile(path, options);
544
568
  },
545
569
  mkdir: function (path, mode, options = {}) {
546
570
  if (!options.current) {
547
571
  options.current = exports.list[taskId].current;
548
572
  }
549
- return clickgo.fs.mkdir(path, mode, options);
573
+ return fs.mkdir(path, mode, options);
550
574
  },
551
575
  rmdir: function (path, options = {}) {
552
576
  if (!options.current) {
553
577
  options.current = exports.list[taskId].current;
554
578
  }
555
- return clickgo.fs.rmdir(path, options);
579
+ return fs.rmdir(path, options);
556
580
  },
557
581
  rmdirDeep: function (path, options = {}) {
558
582
  if (!options.current) {
559
583
  options.current = exports.list[taskId].current;
560
584
  }
561
- return clickgo.fs.rmdirDeep(path, options);
585
+ return fs.rmdirDeep(path, options);
562
586
  },
563
587
  chmod: function (path, mod, options = {}) {
564
588
  if (!options.current) {
565
589
  options.current = exports.list[taskId].current;
566
590
  }
567
- return clickgo.fs.chmod(path, mod, options);
591
+ return fs.chmod(path, mod, options);
568
592
  },
569
593
  rename(oldPath, newPath, options = {}) {
570
594
  if (!options.current) {
571
595
  options.current = exports.list[taskId].current;
572
596
  }
573
- return clickgo.fs.rename(oldPath, newPath, options);
597
+ return fs.rename(oldPath, newPath, options);
574
598
  },
575
599
  readDir(path, options = {}) {
576
600
  if (!options.files) {
@@ -579,94 +603,136 @@ function run(url, opt = {}) {
579
603
  if (!options.current) {
580
604
  options.current = exports.list[taskId].current;
581
605
  }
582
- return clickgo.fs.readDir(path, options);
606
+ return fs.readDir(path, options);
583
607
  },
584
608
  copyFolder(from, to, options = {}) {
585
609
  if (!options.current) {
586
610
  options.current = exports.list[taskId].current;
587
611
  }
588
- return clickgo.fs.copyFolder(from, to, options);
612
+ return fs.copyFolder(from, to, options);
589
613
  },
590
614
  copyFile(src, dest, options = {}) {
591
615
  if (!options.current) {
592
616
  options.current = exports.list[taskId].current;
593
617
  }
594
- return clickgo.fs.copyFile(src, dest, options);
618
+ return fs.copyFile(src, dest, options);
595
619
  }
596
620
  },
597
621
  'native': {
622
+ on(name, handler, once = false, formId) {
623
+ native.on(name, handler, once, formId, taskId);
624
+ },
625
+ once(name, handler, formId) {
626
+ native.once(name, handler, formId, taskId);
627
+ },
628
+ off(name, formId) {
629
+ native.off(name, formId, taskId);
630
+ },
631
+ clear(formId, taskId) {
632
+ native.clear(formId, taskId);
633
+ },
634
+ getListenerList(taskId) {
635
+ return native.getListenerList(taskId);
636
+ },
598
637
  invoke: function (name, ...param) {
599
- return clickgo.native.invoke(name, ...param);
638
+ return native.invoke(name, ...param);
600
639
  },
601
640
  max: function () {
602
- clickgo.native.max();
641
+ return __awaiter(this, void 0, void 0, function* () {
642
+ yield native.max();
643
+ });
603
644
  },
604
645
  min: function () {
605
- clickgo.native.min();
646
+ return __awaiter(this, void 0, void 0, function* () {
647
+ yield native.min();
648
+ });
606
649
  },
607
650
  restore: function () {
608
- clickgo.native.restore();
651
+ return __awaiter(this, void 0, void 0, function* () {
652
+ yield native.restore();
653
+ });
609
654
  },
610
655
  size: function (width, height) {
611
- clickgo.native.size(width, height);
656
+ return __awaiter(this, void 0, void 0, function* () {
657
+ yield native.size(width, height);
658
+ });
659
+ },
660
+ ping: function (val) {
661
+ return native.ping(val);
662
+ },
663
+ isMax: function () {
664
+ return native.isMax();
612
665
  }
613
666
  },
614
667
  'task': {
668
+ getFocus() {
669
+ return focusId;
670
+ },
615
671
  onFrame: function (fun, opt = {}) {
616
672
  opt.taskId = taskId;
617
- return clickgo.task.onFrame(fun, opt);
673
+ return onFrame(fun, opt);
618
674
  },
619
675
  offFrame: function (ft, opt = {}) {
620
676
  opt.taskId = taskId;
621
- clickgo.task.offFrame(ft, opt);
677
+ offFrame(ft, opt);
622
678
  },
623
679
  get: function (tid) {
624
- return clickgo.task.get(tid);
680
+ return get(tid);
625
681
  },
626
682
  getList: function () {
627
- return clickgo.task.getList();
683
+ return getList();
628
684
  },
629
685
  run: function (url, opt = {}) {
630
686
  opt.taskId = taskId;
631
- return clickgo.task.run(url, opt);
687
+ if (opt.unblock) {
688
+ const inUnblock = [];
689
+ for (const item of opt.unblock) {
690
+ if (!unblock.includes(item)) {
691
+ continue;
692
+ }
693
+ inUnblock.push(item);
694
+ }
695
+ opt.unblock = inUnblock;
696
+ }
697
+ return run(url, opt);
632
698
  },
633
699
  end: function (tid) {
634
- return clickgo.task.end(tid !== null && tid !== void 0 ? tid : taskId);
700
+ return end(tid !== null && tid !== void 0 ? tid : taskId);
635
701
  },
636
702
  loadLocaleData: function (lang, data, pre = '') {
637
- clickgo.task.loadLocaleData(lang, data, pre, taskId);
703
+ loadLocaleData(lang, data, pre, taskId);
638
704
  },
639
705
  loadLocale: function (lang, path) {
640
- return clickgo.task.loadLocale(lang, path, taskId);
706
+ return loadLocale(lang, path, taskId);
641
707
  },
642
708
  clearLocale: function () {
643
- clickgo.task.clearLocale(taskId);
709
+ clearLocale(taskId);
644
710
  },
645
711
  setLocale: function (lang, path) {
646
- return clickgo.task.setLocale(lang, path, taskId);
712
+ return setLocale(lang, path, taskId);
647
713
  },
648
714
  setLocaleLang: function (lang) {
649
- clickgo.task.setLocaleLang(lang, taskId);
715
+ setLocaleLang(lang, taskId);
650
716
  },
651
717
  clearLocaleLang: function () {
652
- clickgo.task.clearLocaleLang(taskId);
718
+ clearLocaleLang(taskId);
653
719
  },
654
720
  createTimer: function (fun, delay, opt = {}) {
655
721
  opt.taskId = taskId;
656
- return clickgo.task.createTimer(fun, delay, opt);
722
+ return createTimer(fun, delay, opt);
657
723
  },
658
724
  removeTimer: function (timer) {
659
- clickgo.task.removeTimer(timer, taskId);
725
+ removeTimer(timer, taskId);
660
726
  },
661
727
  sleep: function (fun, delay) {
662
- return clickgo.task.sleep(fun, delay, taskId);
728
+ return sleep(fun, delay, taskId);
663
729
  },
664
- systemTaskInfo: clickgo.task.systemTaskInfo,
730
+ 'systemTaskInfo': clickgo.task.systemTaskInfo,
665
731
  setSystem: function (fid) {
666
- return clickgo.task.setSystem(fid, taskId);
732
+ return setSystem(fid, taskId);
667
733
  },
668
734
  clearSystem: function () {
669
- return clickgo.task.clearSystem(taskId);
735
+ return clearSystem(taskId);
670
736
  }
671
737
  },
672
738
  'theme': {
@@ -696,58 +762,67 @@ function run(url, opt = {}) {
696
762
  },
697
763
  'tool': {
698
764
  blob2ArrayBuffer: function (blob) {
699
- return clickgo.tool.blob2ArrayBuffer(blob);
765
+ return tool.blob2ArrayBuffer(blob);
700
766
  },
701
767
  clone: function (obj) {
702
- return clickgo.tool.clone(obj);
768
+ return tool.clone(obj);
703
769
  },
704
770
  sleep: function (ms = 0) {
705
- return clickgo.tool.sleep(ms);
771
+ return tool.sleep(ms);
772
+ },
773
+ nextFrame() {
774
+ return tool.nextFrame();
775
+ },
776
+ sleepFrame(count) {
777
+ return tool.sleepFrame(count);
706
778
  },
707
779
  purify: function (text) {
708
- return clickgo.tool.purify(text);
780
+ return tool.purify(text);
709
781
  },
710
782
  rand: function (min, max) {
711
- return clickgo.tool.rand(min, max);
712
- },
713
- 'RANDOM_N': clickgo.tool.RANDOM_N,
714
- 'RANDOM_U': clickgo.tool.RANDOM_U,
715
- 'RANDOM_L': clickgo.tool.RANDOM_L,
716
- 'RANDOM_UN': clickgo.tool.RANDOM_UN,
717
- 'RANDOM_LN': clickgo.tool.RANDOM_LN,
718
- 'RANDOM_LU': clickgo.tool.RANDOM_LU,
719
- 'RANDOM_LUN': clickgo.tool.RANDOM_LUN,
720
- 'RANDOM_V': clickgo.tool.RANDOM_V,
721
- 'RANDOM_LUNS': clickgo.tool.RANDOM_LUNS,
722
- random: function (length = 8, source = clickgo.tool.RANDOM_LN, block = '') {
723
- return clickgo.tool.random(length, source, block);
783
+ return tool.rand(min, max);
784
+ },
785
+ 'RANDOM_N': tool.RANDOM_N,
786
+ 'RANDOM_U': tool.RANDOM_U,
787
+ 'RANDOM_L': tool.RANDOM_L,
788
+ 'RANDOM_UN': tool.RANDOM_UN,
789
+ 'RANDOM_LN': tool.RANDOM_LN,
790
+ 'RANDOM_LU': tool.RANDOM_LU,
791
+ 'RANDOM_LUN': tool.RANDOM_LUN,
792
+ 'RANDOM_V': tool.RANDOM_V,
793
+ 'RANDOM_LUNS': tool.RANDOM_LUNS,
794
+ random: function (length = 8, source = tool.RANDOM_LN, block = '') {
795
+ return tool.random(length, source, block);
724
796
  },
725
797
  getBoolean: function (param) {
726
- return clickgo.tool.getBoolean(param);
798
+ return tool.getBoolean(param);
727
799
  },
728
800
  getNumber: function (param) {
729
- return clickgo.tool.getNumber(param);
801
+ return tool.getNumber(param);
802
+ },
803
+ getArray(param) {
804
+ return tool.getArray(param);
730
805
  },
731
806
  escapeHTML: function (html) {
732
- return clickgo.tool.escapeHTML(html);
807
+ return tool.escapeHTML(html);
733
808
  },
734
809
  request: function (url, opt) {
735
- return clickgo.tool.request(url, opt);
810
+ return tool.request(url, opt);
736
811
  },
737
812
  parseUrl: function (url) {
738
- return clickgo.tool.parseUrl(url);
813
+ return tool.parseUrl(url);
739
814
  },
740
815
  urlResolve: function (from, to) {
741
- return clickgo.tool.urlResolve(from, to);
816
+ return tool.urlResolve(from, to);
742
817
  },
743
818
  blob2Text: function (blob) {
744
- return clickgo.tool.blob2Text(blob);
819
+ return tool.blob2Text(blob);
745
820
  },
746
821
  blob2DataUrl: function (blob) {
747
- return clickgo.tool.blob2DataUrl(blob);
822
+ return tool.blob2DataUrl(blob);
748
823
  },
749
824
  execCommand: function (ac) {
750
- clickgo.tool.execCommand(ac);
825
+ tool.execCommand(ac);
751
826
  }
752
827
  },
753
828
  'zip': {
@@ -794,6 +869,28 @@ function run(url, opt = {}) {
794
869
  'timers': {},
795
870
  'invoke': invoke
796
871
  };
872
+ if (app.config.locales) {
873
+ for (let path in app.config.locales) {
874
+ const locale = app.config.locales[path];
875
+ if (!path.endsWith('.json')) {
876
+ path += '.json';
877
+ }
878
+ const lcontent = yield fs.getContent(path, {
879
+ 'encoding': 'utf8',
880
+ 'files': app.files,
881
+ 'current': current
882
+ });
883
+ if (!lcontent) {
884
+ continue;
885
+ }
886
+ try {
887
+ const data = JSON.parse(lcontent);
888
+ loadLocaleData(locale, data, '', taskId);
889
+ }
890
+ catch (_d) {
891
+ }
892
+ }
893
+ }
797
894
  let expo = [];
798
895
  try {
799
896
  expo = loader.require('/app.js', app.files, {
@@ -815,23 +912,57 @@ function run(url, opt = {}) {
815
912
  return -3;
816
913
  }
817
914
  dom.createToStyleList(taskId);
915
+ const r = yield control.init(taskId, invoke);
916
+ if (r < 0) {
917
+ dom.removeFromStyleList(taskId);
918
+ delete exports.list[taskId];
919
+ return -400 + r;
920
+ }
921
+ if ((_c = app.config.themes) === null || _c === void 0 ? void 0 : _c.length) {
922
+ for (let path of app.config.themes) {
923
+ path += '.cgt';
924
+ path = tool.urlResolve('/', path);
925
+ const file = yield fs.getContent(path, {
926
+ 'files': app.files,
927
+ 'current': current
928
+ });
929
+ if (file && typeof file !== 'string') {
930
+ const th = yield theme.read(file);
931
+ if (th) {
932
+ yield theme.load(th, taskId);
933
+ }
934
+ }
935
+ }
936
+ }
937
+ else {
938
+ if (theme.global) {
939
+ yield theme.load(undefined, taskId);
940
+ }
941
+ }
942
+ if (app.config.style) {
943
+ const style = yield fs.getContent(app.config.style + '.css', {
944
+ 'encoding': 'utf8',
945
+ 'files': app.files,
946
+ 'current': current
947
+ });
948
+ if (style) {
949
+ const r = tool.stylePrepend(style, 'cg-task' + taskId.toString() + '_');
950
+ dom.pushStyle(taskId, yield tool.styleUrl2DataUrl(app.config.style, r.style, app.files));
951
+ }
952
+ }
818
953
  core.trigger('taskStarted', taskId);
819
954
  if (taskId === 1) {
820
- native.invoke('cg-init', native.getToken());
955
+ yield native.invoke('cg-init', native.getToken());
821
956
  }
822
957
  const appCls = new expo.default();
958
+ exports.list[taskId].class = appCls;
823
959
  yield appCls.main();
824
- if (!exports.list[taskId].class) {
825
- delete exports.list[taskId];
826
- dom.removeFromStyleList(taskId);
827
- core.trigger('taskEnded', taskId);
828
- return -4;
829
- }
830
960
  return taskId;
831
961
  });
832
962
  }
833
963
  exports.run = run;
834
964
  function end(taskId) {
965
+ var _a;
835
966
  const task = exports.list[taskId];
836
967
  if (!task) {
837
968
  return true;
@@ -857,15 +988,18 @@ function end(taskId) {
857
988
  catch (err) {
858
989
  const msg = `Message: ${err.message}\nTask id: ${task.id}\nForm id: ${fid}\nFunction: task.end, unmount.`;
859
990
  form.notify({
860
- 'title': 'Runtime Error',
991
+ 'title': 'Form Unmount Error',
861
992
  'content': msg,
862
993
  'type': 'danger'
863
994
  });
864
- console.log('Runtime Error', msg, err);
995
+ console.log('Form Unmount Error', msg, err);
865
996
  }
866
997
  f.vapp._container.remove();
998
+ (_a = form.elements.popList.querySelector('[data-form-id="' + f.id.toString() + '"]')) === null || _a === void 0 ? void 0 : _a.remove();
999
+ dom.clearWatchStyle(fid);
1000
+ dom.clearWatchProperty(fid);
867
1001
  }
868
- const flist = document.querySelectorAll('#cg-form-list > [data-task-id="' + taskId.toString() + '"]');
1002
+ const flist = form.elements.list.querySelectorAll('.cg-form-wrap[data-task-id="' + taskId.toString() + '"]');
869
1003
  for (const f of flist) {
870
1004
  f.remove();
871
1005
  }
@@ -881,6 +1015,8 @@ function end(taskId) {
881
1015
  }
882
1016
  }
883
1017
  dom.clearWatchSize(taskId);
1018
+ dom.clearWatch(taskId);
1019
+ native.clear(undefined, taskId);
884
1020
  delete exports.list[taskId];
885
1021
  core.trigger('taskEnded', taskId);
886
1022
  clearSystem(taskId);