clickgo 3.0.6-dev7 → 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.
Files changed (41) hide show
  1. package/README.md +1 -1
  2. package/dist/app/demo/app.js +93 -0
  3. package/dist/app/demo/form/control/form/form.js +21 -20
  4. package/dist/app/demo/form/control/form/form.xml +3 -3
  5. package/dist/app/demo/form/main.js +20 -10
  6. package/dist/app/demo/form/main.xml +1 -1
  7. package/dist/app/task/app.js +46 -0
  8. package/dist/app/task/form/bar/bar.js +85 -86
  9. package/dist/app/task/form/bar/bar.xml +5 -6
  10. package/dist/clickgo.js +1 -10
  11. package/dist/clickgo.ts +0 -8
  12. package/dist/control/common.cgc +0 -0
  13. package/dist/control/form.cgc +0 -0
  14. package/dist/control/monaco.cgc +0 -0
  15. package/dist/control/property.cgc +0 -0
  16. package/dist/control/task.cgc +0 -0
  17. package/dist/global.css +1 -1
  18. package/dist/index.js +105 -56
  19. package/dist/index.ts +164 -59
  20. package/dist/lib/control.js +363 -240
  21. package/dist/lib/control.ts +497 -284
  22. package/dist/lib/core.js +331 -217
  23. package/dist/lib/core.ts +418 -244
  24. package/dist/lib/dom.js +6 -3
  25. package/dist/lib/dom.ts +7 -6
  26. package/dist/lib/form.js +635 -980
  27. package/dist/lib/form.ts +817 -1072
  28. package/dist/lib/fs.js +42 -39
  29. package/dist/lib/fs.ts +45 -41
  30. package/dist/lib/native.js +8 -148
  31. package/dist/lib/native.ts +9 -211
  32. package/dist/lib/task.js +707 -191
  33. package/dist/lib/task.ts +778 -210
  34. package/dist/lib/theme.ts +2 -2
  35. package/dist/lib/tool.js +58 -48
  36. package/dist/lib/tool.ts +79 -64
  37. package/dist/theme/familiar.cgt +0 -0
  38. package/package.json +5 -7
  39. package/types/index.d.ts +286 -324
  40. package/dist/app/demo/config.json +0 -106
  41. package/dist/app/task/config.json +0 -32
package/dist/lib/core.js CHANGED
@@ -9,13 +9,16 @@ 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.removeSystemEventListener = exports.setSystemEventListener = exports.globalEvents = exports.getModule = exports.initModules = exports.regModule = exports.cdn = exports.config = void 0;
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;
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");
18
20
  const zip = require("./zip");
21
+ const dom = require("./dom");
19
22
  const configOrigin = {
20
23
  'locale': 'en',
21
24
  'task.position': 'bottom',
@@ -23,7 +26,8 @@ const configOrigin = {
23
26
  'desktop.icon.storage': true,
24
27
  'desktop.icon.recycler': true,
25
28
  'desktop.wallpaper': null,
26
- 'desktop.path': null
29
+ 'desktop.path': null,
30
+ 'launcher.list': []
27
31
  };
28
32
  exports.config = clickgo.vue.reactive({
29
33
  'locale': 'en',
@@ -32,9 +36,226 @@ exports.config = clickgo.vue.reactive({
32
36
  'desktop.icon.storage': true,
33
37
  'desktop.icon.recycler': true,
34
38
  'desktop.wallpaper': null,
35
- 'desktop.path': null
39
+ 'desktop.path': null,
40
+ 'launcher.list': []
36
41
  });
37
- exports.cdn = '';
42
+ class AbstractApp {
43
+ get filename() {
44
+ return '';
45
+ }
46
+ get taskId() {
47
+ return 0;
48
+ }
49
+ set taskId(v) {
50
+ form.notify({
51
+ 'title': 'Error',
52
+ 'content': `The software tries to modify the system variable "taskId" to "${v}".\nPath: ${this.filename}`,
53
+ 'type': 'danger'
54
+ });
55
+ }
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
+ run(form) {
198
+ if (typeof form === 'number') {
199
+ const msg = 'Application run error, Form creation failed (' + form.toString() + ').';
200
+ trigger('error', this.taskId, 0, new Error(msg), msg);
201
+ return;
202
+ }
203
+ form.show();
204
+ }
205
+ onError() {
206
+ return;
207
+ }
208
+ onScreenResize() {
209
+ return;
210
+ }
211
+ onConfigChanged() {
212
+ return;
213
+ }
214
+ onFormCreated() {
215
+ return;
216
+ }
217
+ onFormRemoved() {
218
+ return;
219
+ }
220
+ onFormTitleChanged() {
221
+ return;
222
+ }
223
+ onFormIconChanged() {
224
+ return;
225
+ }
226
+ onFormStateMinChanged() {
227
+ return;
228
+ }
229
+ onFormStateMaxChanged() {
230
+ return;
231
+ }
232
+ onFormShowChanged() {
233
+ return;
234
+ }
235
+ onFormFocused() {
236
+ return;
237
+ }
238
+ onFormBlurred() {
239
+ return;
240
+ }
241
+ onFormFlash() {
242
+ return;
243
+ }
244
+ onTaskStarted() {
245
+ return;
246
+ }
247
+ onTaskEnded() {
248
+ return;
249
+ }
250
+ onLauncherFolderNameChanged() {
251
+ return;
252
+ }
253
+ }
254
+ exports.AbstractApp = AbstractApp;
255
+ function getCdn() {
256
+ return loader.cdn;
257
+ }
258
+ exports.getCdn = getCdn;
38
259
  clickgo.vue.watch(exports.config, function () {
39
260
  for (const key in configOrigin) {
40
261
  if (exports.config[key] !== undefined) {
@@ -88,7 +309,7 @@ const modules = {
88
309
  func: function () {
89
310
  return __awaiter(this, void 0, void 0, function* () {
90
311
  return new Promise(function (resolve, reject) {
91
- fetch(loader.cdn + '/npm/monaco-editor@0.33.0/min/vs/loader.js').then(function (r) {
312
+ fetch(loader.cdn + '/npm/monaco-editor@0.34.1/min/vs/loader.js').then(function (r) {
92
313
  return r.blob();
93
314
  }).then(function (b) {
94
315
  return tool.blob2DataUrl(b);
@@ -193,32 +414,29 @@ function getModule(name) {
193
414
  return modules[name].obj;
194
415
  }
195
416
  exports.getModule = getModule;
196
- exports.globalEvents = {
197
- errorHandler: null,
198
- screenResizeHandler: function () {
417
+ const globalEvents = {
418
+ screenResize: function () {
199
419
  form.refreshMaxPosition();
200
420
  },
201
- configChangedHandler: null,
202
- formCreatedHandler: null,
203
- formRemovedHandler: function (taskId, formId) {
421
+ formRemoved: function (taskId, formId) {
204
422
  if (!form.simpleSystemTaskRoot.forms[formId]) {
205
423
  return;
206
424
  }
207
425
  delete form.simpleSystemTaskRoot.forms[formId];
208
426
  },
209
- formTitleChangedHandler: function (taskId, formId, title) {
427
+ formTitleChanged: function (taskId, formId, title) {
210
428
  if (!form.simpleSystemTaskRoot.forms[formId]) {
211
429
  return;
212
430
  }
213
431
  form.simpleSystemTaskRoot.forms[formId].title = title;
214
432
  },
215
- formIconChangedHandler: function (taskId, formId, icon) {
433
+ formIconChanged: function (taskId, formId, icon) {
216
434
  if (!form.simpleSystemTaskRoot.forms[formId]) {
217
435
  return;
218
436
  }
219
437
  form.simpleSystemTaskRoot.forms[formId].icon = icon;
220
438
  },
221
- formStateMinChangedHandler: function (taskId, formId, state) {
439
+ formStateMinChanged: function (taskId, formId, state) {
222
440
  if (task.systemTaskInfo.taskId > 0) {
223
441
  return;
224
442
  }
@@ -238,93 +456,34 @@ exports.globalEvents = {
238
456
  }
239
457
  delete form.simpleSystemTaskRoot.forms[formId];
240
458
  }
241
- },
242
- formStateMaxChangedHandler: null,
243
- formShowChangedHandler: null,
244
- formFocusedHandler: null,
245
- formBlurredHandler: null,
246
- formFlashHandler: null,
247
- taskStartedHandler: null,
248
- taskEndedHandler: null
249
- };
250
- function setSystemEventListener(name, func, formId, taskId) {
251
- if (!taskId) {
252
- return;
253
- }
254
- const t = task.list[taskId];
255
- if (!t) {
256
- return;
257
- }
258
- if (!formId) {
259
- return;
260
- }
261
- const f = t.forms[formId];
262
- if (!f) {
263
- return;
264
- }
265
- f.events[name] = func;
266
- }
267
- exports.setSystemEventListener = setSystemEventListener;
268
- function removeSystemEventListener(name, formId, taskId) {
269
- if (!taskId) {
270
- return;
271
459
  }
272
- const t = task.list[taskId];
273
- if (!t) {
274
- return;
275
- }
276
- if (!formId) {
277
- return;
278
- }
279
- const f = t.forms[formId];
280
- if (!f) {
281
- return;
282
- }
283
- delete f.events[name];
284
- }
285
- exports.removeSystemEventListener = removeSystemEventListener;
460
+ };
286
461
  function trigger(name, taskId = 0, formId = 0, param1 = '', param2 = '') {
287
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
462
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12;
463
+ const eventName = 'on' + name[0].toUpperCase() + name.slice(1);
288
464
  switch (name) {
289
465
  case 'error': {
290
466
  if (typeof taskId !== 'number' || typeof formId !== 'number') {
291
467
  break;
292
468
  }
293
- const r = (_a = exports.globalEvents.errorHandler) === null || _a === void 0 ? void 0 : _a.call(exports.globalEvents, taskId, formId, param1, param2);
294
- if (r && (r instanceof Promise)) {
295
- r.catch(function (e) {
296
- console.log(e);
297
- });
298
- }
469
+ exports.boot[eventName](taskId, formId, param1, param2);
299
470
  for (const tid in task.list) {
300
471
  const t = task.list[tid];
472
+ (_a = t.class) === null || _a === void 0 ? void 0 : _a[eventName](taskId, formId, param1, param2);
301
473
  for (const fid in t.forms) {
302
- const r = (_c = (_b = t.forms[fid].events)[name]) === null || _c === void 0 ? void 0 : _c.call(_b, taskId, formId, param1, param2);
303
- if (r instanceof Promise) {
304
- r.catch(function (e) {
305
- console.log(e);
306
- });
307
- }
474
+ (_c = (_b = t.forms[fid].vroot)[eventName]) === null || _c === void 0 ? void 0 : _c.call(_b, taskId, formId, param1, param2);
308
475
  }
309
476
  }
310
477
  break;
311
478
  }
312
479
  case 'screenResize': {
313
- const r = (_d = exports.globalEvents.screenResizeHandler) === null || _d === void 0 ? void 0 : _d.call(exports.globalEvents);
314
- if (r && (r instanceof Promise)) {
315
- r.catch(function (e) {
316
- console.log(e);
317
- });
318
- }
480
+ globalEvents.screenResize();
481
+ exports.boot[eventName]();
319
482
  for (const tid in task.list) {
320
483
  const t = task.list[tid];
484
+ (_d = t.class) === null || _d === void 0 ? void 0 : _d[eventName]();
321
485
  for (const fid in t.forms) {
322
- const r = (_f = (_e = t.forms[fid].events)[name]) === null || _f === void 0 ? void 0 : _f.call(_e);
323
- if (r instanceof Promise) {
324
- r.catch(function (e) {
325
- console.log(e);
326
- });
327
- }
486
+ (_f = (_e = t.forms[fid].vroot)[eventName]) === null || _f === void 0 ? void 0 : _f.call(_e);
328
487
  }
329
488
  }
330
489
  break;
@@ -333,53 +492,38 @@ function trigger(name, taskId = 0, formId = 0, param1 = '', param2 = '') {
333
492
  if ((typeof taskId !== 'string') || (typeof formId === 'number')) {
334
493
  break;
335
494
  }
336
- const r = (_g = exports.globalEvents.configChangedHandler) === null || _g === void 0 ? void 0 : _g.call(exports.globalEvents, taskId, formId);
337
- if (r && (r instanceof Promise)) {
338
- r.catch(function (e) {
339
- console.log(e);
340
- });
341
- }
495
+ exports.boot[eventName]();
342
496
  for (const tid in task.list) {
343
497
  const t = task.list[tid];
498
+ (_g = t.class) === null || _g === void 0 ? void 0 : _g[eventName](taskId, formId);
344
499
  for (const fid in t.forms) {
345
- const r = (_j = (_h = t.forms[fid].events)[name]) === null || _j === void 0 ? void 0 : _j.call(_h, taskId, formId);
346
- if (r instanceof Promise) {
347
- r.catch(function (e) {
348
- console.log(e);
349
- });
350
- }
500
+ (_j = (_h = t.forms[fid].vroot)[eventName]) === null || _j === void 0 ? void 0 : _j.call(_h, taskId, formId);
351
501
  }
352
502
  }
353
503
  break;
354
504
  }
355
505
  case 'formCreated':
356
506
  case 'formRemoved': {
357
- (_l = (_k = exports.globalEvents)[name + 'Handler']) === null || _l === void 0 ? void 0 : _l.call(_k, taskId, formId, param1, param2);
507
+ (_l = (_k = globalEvents)[name]) === null || _l === void 0 ? void 0 : _l.call(_k, taskId, formId, param1, param2);
508
+ exports.boot[eventName](taskId, formId, param1, param2);
358
509
  for (const tid in task.list) {
359
510
  const t = task.list[tid];
511
+ (_m = t.class) === null || _m === void 0 ? void 0 : _m[eventName](taskId, formId, param1, param2);
360
512
  for (const fid in t.forms) {
361
- const r = (_o = (_m = t.forms[fid].events)[name]) === null || _o === void 0 ? void 0 : _o.call(_m, taskId, formId, param1, param2);
362
- if (r instanceof Promise) {
363
- r.catch(function (e) {
364
- console.log(e);
365
- });
366
- }
513
+ (_p = (_o = t.forms[fid].vroot)[eventName]) === null || _p === void 0 ? void 0 : _p.call(_o, taskId, formId, param1, param2);
367
514
  }
368
515
  }
369
516
  break;
370
517
  }
371
518
  case 'formTitleChanged':
372
519
  case 'formIconChanged': {
373
- (_q = (_p = exports.globalEvents)[name + 'Handler']) === null || _q === void 0 ? void 0 : _q.call(_p, taskId, formId, param1);
520
+ (_r = (_q = globalEvents)[name]) === null || _r === void 0 ? void 0 : _r.call(_q, taskId, formId, param1);
521
+ exports.boot[eventName](taskId, formId, param1);
374
522
  for (const tid in task.list) {
375
523
  const t = task.list[tid];
524
+ (_s = t.class) === null || _s === void 0 ? void 0 : _s[eventName](taskId, formId, param1);
376
525
  for (const fid in t.forms) {
377
- const r = (_s = (_r = t.forms[fid].events)[name]) === null || _s === void 0 ? void 0 : _s.call(_r, taskId, formId, param1);
378
- if (r instanceof Promise) {
379
- r.catch(function (e) {
380
- console.log(e);
381
- });
382
- }
526
+ (_u = (_t = t.forms[fid].vroot)[eventName]) === null || _u === void 0 ? void 0 : _u.call(_t, taskId, formId, param1);
383
527
  }
384
528
  }
385
529
  break;
@@ -387,16 +531,13 @@ function trigger(name, taskId = 0, formId = 0, param1 = '', param2 = '') {
387
531
  case 'formStateMinChanged':
388
532
  case 'formStateMaxChanged':
389
533
  case 'formShowChanged': {
390
- (_u = (_t = exports.globalEvents)[name + 'Handler']) === null || _u === void 0 ? void 0 : _u.call(_t, taskId, formId, param1);
534
+ (_w = (_v = globalEvents)[name]) === null || _w === void 0 ? void 0 : _w.call(_v, taskId, formId, param1);
535
+ exports.boot[eventName](taskId, formId, param1);
391
536
  for (const tid in task.list) {
392
537
  const t = task.list[tid];
538
+ (_x = t.class) === null || _x === void 0 ? void 0 : _x[eventName](taskId, formId, param1);
393
539
  for (const fid in t.forms) {
394
- const r = (_w = (_v = t.forms[fid].events)[name]) === null || _w === void 0 ? void 0 : _w.call(_v, taskId, formId, param1);
395
- if (r instanceof Promise) {
396
- r.catch(function (e) {
397
- console.log(e);
398
- });
399
- }
540
+ (_z = (_y = t.forms[fid].vroot)[eventName]) === null || _z === void 0 ? void 0 : _z.call(_y, taskId, formId, param1);
400
541
  }
401
542
  }
402
543
  break;
@@ -404,32 +545,43 @@ function trigger(name, taskId = 0, formId = 0, param1 = '', param2 = '') {
404
545
  case 'formFocused':
405
546
  case 'formBlurred':
406
547
  case 'formFlash': {
407
- (_y = (_x = exports.globalEvents)[name + 'Handler']) === null || _y === void 0 ? void 0 : _y.call(_x, taskId, formId);
548
+ (_1 = (_0 = globalEvents)[name]) === null || _1 === void 0 ? void 0 : _1.call(_0, taskId, formId);
549
+ exports.boot[eventName](taskId, formId);
408
550
  for (const tid in task.list) {
409
551
  const t = task.list[tid];
552
+ (_2 = t.class) === null || _2 === void 0 ? void 0 : _2[eventName](taskId, formId);
410
553
  for (const fid in t.forms) {
411
- const r = (_0 = (_z = t.forms[fid].events)[name]) === null || _0 === void 0 ? void 0 : _0.call(_z, taskId, formId);
412
- if (r instanceof Promise) {
413
- r.catch(function (e) {
414
- console.log(e);
415
- });
416
- }
554
+ (_4 = (_3 = t.forms[fid].vroot)[eventName]) === null || _4 === void 0 ? void 0 : _4.call(_3, taskId, formId);
417
555
  }
418
556
  }
419
557
  break;
420
558
  }
421
559
  case 'taskStarted':
422
560
  case 'taskEnded': {
423
- (_2 = (_1 = exports.globalEvents)[name + 'Handler']) === null || _2 === void 0 ? void 0 : _2.call(_1, taskId, formId);
561
+ (_6 = (_5 = globalEvents)[name]) === null || _6 === void 0 ? void 0 : _6.call(_5, taskId, formId);
562
+ exports.boot[eventName](taskId, formId);
424
563
  for (const tid in task.list) {
425
564
  const t = task.list[tid];
565
+ (_7 = t.class) === null || _7 === void 0 ? void 0 : _7[eventName](taskId);
426
566
  for (const fid in t.forms) {
427
- const r = (_4 = (_3 = t.forms[fid].events)[name]) === null || _4 === void 0 ? void 0 : _4.call(_3, taskId);
428
- if (r instanceof Promise) {
429
- r.catch(function (e) {
430
- console.log(e);
431
- });
432
- }
567
+ (_9 = (_8 = t.forms[fid].vroot)[eventName]) === null || _9 === void 0 ? void 0 : _9.call(_8, taskId);
568
+ }
569
+ }
570
+ break;
571
+ }
572
+ case 'launcherFolderNameChanged': {
573
+ if (typeof formId !== 'string') {
574
+ break;
575
+ }
576
+ if (typeof taskId === 'number') {
577
+ taskId = taskId.toString();
578
+ }
579
+ exports.boot[eventName](taskId, formId);
580
+ for (const tid in task.list) {
581
+ const t = task.list[tid];
582
+ (_10 = t.class) === null || _10 === void 0 ? void 0 : _10[eventName](taskId, formId);
583
+ for (const fid in t.forms) {
584
+ (_12 = (_11 = t.forms[fid].vroot)[eventName]) === null || _12 === void 0 ? void 0 : _12.call(_11, taskId, formId);
433
585
  }
434
586
  }
435
587
  break;
@@ -446,37 +598,30 @@ function readApp(blob) {
446
598
  return false;
447
599
  }
448
600
  const files = {};
449
- const configContent = yield z.getContent('/config.json');
450
- if (!configContent) {
451
- return false;
452
- }
453
- const config = JSON.parse(configContent);
454
- for (const file of config.files) {
455
- const mime = tool.getMimeByPath(file);
601
+ const list = z.readDir('/', {
602
+ 'hasChildren': true
603
+ });
604
+ for (const file of list) {
605
+ const mime = tool.getMimeByPath(file.name);
456
606
  if (['txt', 'json', 'js', 'css', 'xml', 'html'].includes(mime.ext)) {
457
- const fab = yield z.getContent(file, 'string');
607
+ const fab = yield z.getContent(file.path + file.name, 'string');
458
608
  if (!fab) {
459
609
  continue;
460
610
  }
461
- files[file] = fab.replace(/^\ufeff/, '');
611
+ files[file.path + file.name] = fab.replace(/^\ufeff/, '');
462
612
  }
463
613
  else {
464
- const fab = yield z.getContent(file, 'arraybuffer');
614
+ const fab = yield z.getContent(file.path + file.name, 'arraybuffer');
465
615
  if (!fab) {
466
616
  continue;
467
617
  }
468
- files[file] = new Blob([fab], {
618
+ files[file.path + file.name] = new Blob([fab], {
469
619
  'type': mime.mime
470
620
  });
471
621
  }
472
622
  }
473
- if (!config) {
474
- return false;
475
- }
476
623
  return {
477
- 'type': 'app',
478
624
  'icon': icon,
479
- 'config': config,
480
625
  'files': files
481
626
  };
482
627
  });
@@ -494,18 +639,14 @@ function fetchApp(url, opt = {}) {
494
639
  }
495
640
  let current = '';
496
641
  if (opt.current) {
497
- if (!opt.current.endsWith('/')) {
498
- return null;
499
- }
500
- if (!url.startsWith('/')) {
501
- url = '/current/' + url;
502
- }
642
+ current = opt.current.endsWith('/') ? opt.current.slice(0, -1) : opt.current;
643
+ url = tool.urlResolve('/current/', url);
503
644
  }
504
645
  else {
505
646
  if (!url.startsWith('/clickgo/') && !url.startsWith('/storage/') && !url.startsWith('/mounted/')) {
506
647
  current = tool.urlResolve(window.location.href, url);
507
648
  if (cga) {
508
- current = current.slice(0, -cga.length);
649
+ current = current.slice(0, -cga.length - 1);
509
650
  url = '/current/' + cga;
510
651
  }
511
652
  else {
@@ -538,76 +679,49 @@ function fetchApp(url, opt = {}) {
538
679
  return null;
539
680
  }
540
681
  }
541
- let config;
542
- const files = {};
543
- try {
544
- const blob = yield fs.getContent(url + 'config.json', {
545
- 'current': current
546
- });
547
- if (blob === null || typeof blob === 'string') {
548
- return null;
549
- }
550
- config = JSON.parse(yield tool.blob2Text(blob));
551
- yield new Promise(function (resolve) {
552
- const total = config.files.length;
553
- let loaded = 0;
554
- for (const file of config.files) {
555
- fs.getContent(url + file.slice(1), {
556
- 'current': current
557
- }).then(function (blob) {
558
- var _a;
559
- return __awaiter(this, void 0, void 0, function* () {
560
- if (blob === null || typeof blob === 'string') {
561
- clickgo.form.notify({
562
- 'title': 'File not found',
563
- 'content': url + file.slice(1),
564
- 'type': 'danger'
565
- });
566
- return;
567
- }
568
- const mime = tool.getMimeByPath(file);
569
- if (['txt', 'json', 'js', 'css', 'xml', 'html'].includes(mime.ext)) {
570
- files[file] = (yield tool.blob2Text(blob)).replace(/^\ufeff/, '');
571
- }
572
- else {
573
- files[file] = blob;
574
- }
575
- ++loaded;
576
- (_a = opt.progress) === null || _a === void 0 ? void 0 : _a.call(opt, loaded, total);
577
- if (opt.notifyId) {
578
- form.notifyProgress(opt.notifyId, loaded / total);
579
- }
580
- if (loaded < total) {
581
- return;
582
- }
583
- resolve();
584
- });
585
- }).catch(function () {
586
- var _a;
587
- ++loaded;
588
- (_a = opt.progress) === null || _a === void 0 ? void 0 : _a.call(opt, loaded, total);
589
- if (opt.notifyId) {
590
- form.notifyProgress(opt.notifyId, loaded / total);
591
- }
592
- if (loaded < total) {
593
- return;
594
- }
595
- resolve();
596
- });
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;
597
697
  }
598
- });
698
+ if (opt.notifyId) {
699
+ form.notifyProgress(opt.notifyId, (loaded / total) / 2);
700
+ }
701
+ if (opt.progress) {
702
+ opt.progress(loaded, total);
703
+ }
704
+ }
705
+ });
706
+ if (opt.notifyId) {
707
+ form.notifyProgress(opt.notifyId, 0.5);
599
708
  }
600
- catch (_b) {
709
+ if (Object.keys(files).length === 0) {
601
710
  return null;
602
711
  }
603
- let icon = '/clickgo/icon.png';
604
- if (config.icon && (files[config.icon] instanceof Blob)) {
605
- icon = yield tool.blob2DataUrl(files[config.icon]);
712
+ const ul = url.length - 1;
713
+ for (const fn in files) {
714
+ files[fn.slice(ul)] = files[fn];
715
+ delete files[fn];
606
716
  }
607
717
  return {
608
- 'type': 'app',
609
- 'icon': icon,
610
- 'config': config,
718
+ 'net': {
719
+ 'current': current,
720
+ 'notify': opt.notifyId,
721
+ 'url': url,
722
+ 'progress': opt.progress
723
+ },
724
+ 'icon': '',
611
725
  'files': files
612
726
  };
613
727
  });