clickgo 3.1.3-dev12 → 3.1.5-dev14

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 (50) hide show
  1. package/README.md +1 -1
  2. package/dist/app/demo/app.js +1 -1
  3. package/dist/app/demo/config.json +9 -2
  4. package/dist/app/demo/form/control/text/text.js +1 -0
  5. package/dist/app/demo/form/control/text/text.xml +1 -1
  6. package/dist/app/demo/form/event/other/other.js +29 -0
  7. package/dist/app/demo/form/event/other/other.xml +5 -0
  8. package/dist/app/demo/form/main.js +51 -51
  9. package/dist/app/demo/form/main.xml +1 -0
  10. package/dist/app/demo/form/method/aform/aform.js +2 -13
  11. package/dist/app/demo/form/method/aform/aform.xml +0 -1
  12. package/dist/app/demo/form/method/aform/sd.js +25 -0
  13. package/dist/app/demo/form/method/aform/{test.xml → sd.xml} +3 -2
  14. package/dist/app/demo/form/method/core/core.js +12 -0
  15. package/dist/app/demo/form/method/core/core.xml +4 -0
  16. package/dist/app/demo/form/method/form/form.js +5 -6
  17. package/dist/app/demo/form/method/form/form.xml +1 -0
  18. package/dist/app/demo/form/method/form/test.xml +5 -0
  19. package/dist/app/demo/form/method/fs/fs.js +1 -4
  20. package/dist/app/demo/form/method/task/task.js +9 -1
  21. package/dist/app/demo/form/method/task/task.xml +1 -0
  22. package/dist/app/demo/form/method/tool/tool.js +3 -0
  23. package/dist/app/demo/form/method/tool/tool.xml +1 -0
  24. package/dist/app/demo/form/method/zip/zip.js +1 -4
  25. package/dist/app/task/app.js +1 -1
  26. package/dist/control/common.cgc +0 -0
  27. package/dist/control/form.cgc +0 -0
  28. package/dist/control/monaco.cgc +0 -0
  29. package/dist/control/property.cgc +0 -0
  30. package/dist/control/task.cgc +0 -0
  31. package/dist/global.css +1 -1
  32. package/dist/index.js +3 -0
  33. package/dist/index.ts +6 -0
  34. package/dist/lib/core.js +59 -10
  35. package/dist/lib/core.ts +67 -10
  36. package/dist/lib/dom.js +3 -3
  37. package/dist/lib/dom.ts +4 -4
  38. package/dist/lib/form.js +240 -215
  39. package/dist/lib/form.ts +290 -249
  40. package/dist/lib/fs.js +107 -12
  41. package/dist/lib/fs.ts +111 -20
  42. package/dist/lib/native.js +8 -1
  43. package/dist/lib/native.ts +6 -0
  44. package/dist/lib/task.js +253 -14
  45. package/dist/lib/task.ts +298 -12
  46. package/dist/lib/tool.js +39 -1
  47. package/dist/lib/tool.ts +45 -0
  48. package/dist/theme/familiar.cgt +0 -0
  49. package/package.json +3 -3
  50. package/types/index.d.ts +70 -52
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.getFocus = exports.setFocus = 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.checkPermission = 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");
@@ -163,7 +163,7 @@ function getList() {
163
163
  }
164
164
  exports.getList = getList;
165
165
  function run(url, opt = {}) {
166
- var _a, _b, _c;
166
+ var _a, _b, _c, _d;
167
167
  return __awaiter(this, void 0, void 0, function* () {
168
168
  let ntask = null;
169
169
  if (opt.taskId) {
@@ -203,7 +203,7 @@ function run(url, opt = {}) {
203
203
  const unblock = opt.unblock ? tool.clone(opt.unblock) : [];
204
204
  const unblockSys = [
205
205
  'require',
206
- '__awaiter', 'eval', 'Math', 'Array', 'Blob', 'Error', 'Infinity', 'parseInt', 'parseFloat', 'Promise', 'Date', 'JSON', 'fetch'
206
+ '__awaiter', 'eval', 'Math', 'Array', 'Blob', 'Error', 'Infinity', 'parseInt', 'parseFloat', 'Promise', 'Date', 'JSON', 'fetch', 'Number'
207
207
  ];
208
208
  for (const name of unblockSys) {
209
209
  if (unblock.includes(name)) {
@@ -241,8 +241,65 @@ function run(url, opt = {}) {
241
241
  invoke[k] = undefined;
242
242
  }
243
243
  invoke.console = {
244
- log: function (message, ...optionalParams) {
245
- console.log(message, ...optionalParams);
244
+ assert: function (condition, ...data) {
245
+ console.assert(condition, ...data);
246
+ },
247
+ clear: function () {
248
+ console.clear();
249
+ },
250
+ count: function (label) {
251
+ console.count(label);
252
+ },
253
+ countReset: function (label) {
254
+ console.countReset(label);
255
+ },
256
+ debug: function (...data) {
257
+ console.debug(...data);
258
+ },
259
+ dir: function (item, options) {
260
+ console.dir(item, options);
261
+ },
262
+ dirxml: function (...data) {
263
+ console.dirxml(...data);
264
+ },
265
+ error: function (...data) {
266
+ console.error(...data);
267
+ },
268
+ group: function (...data) {
269
+ console.group(...data);
270
+ },
271
+ groupCollapsed: function (...data) {
272
+ console.groupCollapsed(...data);
273
+ },
274
+ groupEnd: function () {
275
+ console.groupEnd();
276
+ },
277
+ info: function (...data) {
278
+ console.info(...data);
279
+ },
280
+ log: function (...data) {
281
+ console.log(...data);
282
+ },
283
+ table: function (tabularData, properties) {
284
+ console.table(tabularData, properties);
285
+ },
286
+ time: function (label) {
287
+ console.time(label);
288
+ },
289
+ timeEnd: function (label) {
290
+ console.timeEnd(label);
291
+ },
292
+ timeLog: function (label, ...data) {
293
+ console.timeLog(label, ...data);
294
+ },
295
+ timeStamp: function (label) {
296
+ console.timeStamp(label);
297
+ },
298
+ trace: function (...data) {
299
+ console.trace(...data);
300
+ },
301
+ warn: function (...data) {
302
+ console.warn(...data);
246
303
  }
247
304
  };
248
305
  invoke.loader = {
@@ -319,6 +376,9 @@ function run(url, opt = {}) {
319
376
  },
320
377
  getAvailArea: function () {
321
378
  return core.getAvailArea();
379
+ },
380
+ hash: function (hash) {
381
+ return core.hash(hash, taskId);
322
382
  }
323
383
  },
324
384
  'dom': {
@@ -477,6 +537,9 @@ function run(url, opt = {}) {
477
537
  hidePop: function (pop) {
478
538
  form.hidePop(pop);
479
539
  },
540
+ create: function (cls, data, opt) {
541
+ return form.create(cls, data, opt, taskId);
542
+ },
480
543
  dialog: function (opt) {
481
544
  if (typeof opt === 'string') {
482
545
  opt = {
@@ -639,24 +702,49 @@ function run(url, opt = {}) {
639
702
  },
640
703
  max: function () {
641
704
  return __awaiter(this, void 0, void 0, function* () {
705
+ const rtn = yield checkPermission('native.form', false, undefined, taskId);
706
+ if (!rtn[0]) {
707
+ return;
708
+ }
642
709
  yield native.max();
643
710
  });
644
711
  },
645
712
  min: function () {
646
713
  return __awaiter(this, void 0, void 0, function* () {
714
+ const rtn = yield checkPermission('native.form', false, undefined, taskId);
715
+ if (!rtn[0]) {
716
+ return;
717
+ }
647
718
  yield native.min();
648
719
  });
649
720
  },
650
721
  restore: function () {
651
722
  return __awaiter(this, void 0, void 0, function* () {
723
+ const rtn = yield checkPermission('native.form', false, undefined, taskId);
724
+ if (!rtn[0]) {
725
+ return;
726
+ }
652
727
  yield native.restore();
653
728
  });
654
729
  },
655
730
  size: function (width, height) {
656
731
  return __awaiter(this, void 0, void 0, function* () {
732
+ const rtn = yield checkPermission('native.form', false, undefined, taskId);
733
+ if (!rtn[0]) {
734
+ return;
735
+ }
657
736
  yield native.size(width, height);
658
737
  });
659
738
  },
739
+ maximizable: function (val) {
740
+ return __awaiter(this, void 0, void 0, function* () {
741
+ const rtn = yield checkPermission('native.form', false, undefined, taskId);
742
+ if (!rtn[0]) {
743
+ return;
744
+ }
745
+ yield native.maximizable(val);
746
+ });
747
+ },
660
748
  ping: function (val) {
661
749
  return native.ping(val);
662
750
  },
@@ -694,8 +782,16 @@ function run(url, opt = {}) {
694
782
  }
695
783
  opt.unblock = inUnblock;
696
784
  }
785
+ if (opt.permissions) {
786
+ if (ntask && !ntask.runtime.permissions.includes('root')) {
787
+ opt.permissions = undefined;
788
+ }
789
+ }
697
790
  return run(url, opt);
698
791
  },
792
+ checkPermission: function (vals, apply = false, applyHandler) {
793
+ return checkPermission(vals, apply, applyHandler, taskId);
794
+ },
699
795
  end: function (tid) {
700
796
  return end(tid !== null && tid !== void 0 ? tid : taskId);
701
797
  },
@@ -806,6 +902,9 @@ function run(url, opt = {}) {
806
902
  escapeHTML: function (html) {
807
903
  return tool.escapeHTML(html);
808
904
  },
905
+ rgb2hsl: function (rgb) {
906
+ return tool.rgb2hsl(rgb);
907
+ },
809
908
  request: function (url, opt) {
810
909
  return tool.request(url, opt);
811
910
  },
@@ -815,6 +914,9 @@ function run(url, opt = {}) {
815
914
  urlResolve: function (from, to) {
816
915
  return tool.urlResolve(from, to);
817
916
  },
917
+ urlAtom: function (url) {
918
+ return tool.urlAtom(url);
919
+ },
818
920
  blob2Text: function (blob) {
819
921
  return tool.blob2Text(blob);
820
922
  },
@@ -861,8 +963,8 @@ function run(url, opt = {}) {
861
963
  'path': path,
862
964
  'current': current,
863
965
  'runtime': clickgo.vue.reactive({
864
- 'permissions': {},
865
- 'dialogFormIds': []
966
+ 'dialogFormIds': [],
967
+ 'permissions': (_c = opt.permissions) !== null && _c !== void 0 ? _c : []
866
968
  }),
867
969
  'forms': {},
868
970
  'controls': {},
@@ -887,19 +989,23 @@ function run(url, opt = {}) {
887
989
  const data = JSON.parse(lcontent);
888
990
  loadLocaleData(locale, data, '', taskId);
889
991
  }
890
- catch (_d) {
992
+ catch (_e) {
891
993
  }
892
994
  }
893
995
  }
894
996
  let expo = [];
895
997
  try {
998
+ const map = {
999
+ 'clickgo': '/invoke/clickgo'
1000
+ };
1001
+ if (app.config.map) {
1002
+ Object.assign(map, app.config.map);
1003
+ }
896
1004
  expo = loader.require('/app.js', app.files, {
897
1005
  'dir': '/',
898
1006
  'invoke': invoke,
899
1007
  'preprocess': preprocess,
900
- 'map': {
901
- 'clickgo': '/invoke/clickgo'
902
- }
1008
+ 'map': map
903
1009
  })[0];
904
1010
  }
905
1011
  catch (e) {
@@ -918,7 +1024,7 @@ function run(url, opt = {}) {
918
1024
  delete exports.list[taskId];
919
1025
  return -400 + r;
920
1026
  }
921
- if ((_c = app.config.themes) === null || _c === void 0 ? void 0 : _c.length) {
1027
+ if ((_d = app.config.themes) === null || _d === void 0 ? void 0 : _d.length) {
922
1028
  for (let path of app.config.themes) {
923
1029
  path += '.cgt';
924
1030
  path = tool.urlResolve('/', path);
@@ -951,8 +1057,8 @@ function run(url, opt = {}) {
951
1057
  }
952
1058
  }
953
1059
  core.trigger('taskStarted', taskId);
954
- if (taskId === 1) {
955
- yield native.invoke('cg-init', native.getToken());
1060
+ if (app.config.permissions) {
1061
+ yield checkPermission(app.config.permissions, true, undefined, taskId);
956
1062
  }
957
1063
  const appCls = new expo.default();
958
1064
  exports.list[taskId].class = appCls;
@@ -961,6 +1067,139 @@ function run(url, opt = {}) {
961
1067
  });
962
1068
  }
963
1069
  exports.run = run;
1070
+ const locale = {
1071
+ 'sc': {
1072
+ 'unknown': '未知权限',
1073
+ 'apply-permission': '正在申请权限,请您仔细确认',
1074
+ 'native.form': '实体窗体控制',
1075
+ 'hash': '可修改地址栏 hash',
1076
+ 'fs': '文件系统',
1077
+ 'readonly': '只读',
1078
+ 'read-write': '读写'
1079
+ },
1080
+ 'tc': {
1081
+ 'unknown': '未知許可權',
1082
+ 'apply-permission': '正在申請許可權,請您仔細確認',
1083
+ 'native.form': '實體視窗控制',
1084
+ 'hash': '可修改位址列 hash',
1085
+ 'fs': '檔案系統',
1086
+ 'readonly': '唯讀',
1087
+ 'read-write': '讀寫'
1088
+ },
1089
+ 'en': {
1090
+ 'unknown': 'Unknown',
1091
+ 'apply-permission': 'is applying for permissions, please check carefully',
1092
+ 'native.form': 'Native window control',
1093
+ 'hash': 'Can modify the location hash',
1094
+ 'fs': 'File system',
1095
+ 'readonly': 'Read only',
1096
+ 'read-write': 'Read and write'
1097
+ },
1098
+ 'ja': {
1099
+ 'unknown': '不明な許可',
1100
+ 'apply-permission': '許可申請中、よくご確認ください',
1101
+ 'native.form': 'ローカルウィンドウを操作する',
1102
+ 'hash': '網址の hash 変更可能',
1103
+ 'fs': '資料システム',
1104
+ 'readonly': '読み取り専用',
1105
+ 'read-write': '読み書き'
1106
+ }
1107
+ };
1108
+ function checkPermission(vals, apply = false, applyHandler, taskId) {
1109
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1110
+ return __awaiter(this, void 0, void 0, function* () {
1111
+ if (!taskId) {
1112
+ return [false];
1113
+ }
1114
+ const task = exports.list[taskId];
1115
+ if (!task) {
1116
+ return [false];
1117
+ }
1118
+ if (typeof vals === 'string') {
1119
+ vals = [vals];
1120
+ }
1121
+ const rtn = [];
1122
+ const applyList = [];
1123
+ for (const val of vals) {
1124
+ if (task.runtime.permissions.includes('root')) {
1125
+ rtn.push(true);
1126
+ continue;
1127
+ }
1128
+ if (val.startsWith('fs.')) {
1129
+ let yes = false;
1130
+ const path = val.slice(3, -1);
1131
+ for (const v of task.runtime.permissions) {
1132
+ if (!v.startsWith('fs.')) {
1133
+ continue;
1134
+ }
1135
+ const pa = v.slice(3, -1);
1136
+ if (pa.endsWith('/')) {
1137
+ if (!path.startsWith(pa)) {
1138
+ continue;
1139
+ }
1140
+ }
1141
+ else if (pa !== path) {
1142
+ continue;
1143
+ }
1144
+ if (val.endsWith('w')) {
1145
+ if (v.endsWith('r')) {
1146
+ continue;
1147
+ }
1148
+ }
1149
+ yes = true;
1150
+ break;
1151
+ }
1152
+ rtn.push(yes);
1153
+ if (!yes && apply) {
1154
+ applyList.push(val);
1155
+ }
1156
+ continue;
1157
+ }
1158
+ const result = task.runtime.permissions.includes(val);
1159
+ if (!result && apply) {
1160
+ applyList.push(val);
1161
+ }
1162
+ rtn.push(result);
1163
+ }
1164
+ if (applyList.length) {
1165
+ let html = '<div>"' + tool.escapeHTML(task.app.config.name) + '" ' + (((_b = (_a = locale[core.config.locale]) === null || _a === void 0 ? void 0 : _a['apply-permission']) !== null && _b !== void 0 ? _b : locale['en']['apply-permission']) + ':') + '</div>';
1166
+ for (const item of applyList) {
1167
+ if (item.startsWith('fs.')) {
1168
+ const path = item.slice(3, -1);
1169
+ html += '<div style="margin-top: 10px;">' +
1170
+ ((_d = (_c = locale[core.config.locale]) === null || _c === void 0 ? void 0 : _c.fs) !== null && _d !== void 0 ? _d : locale['en'].fs) + ' ' + tool.escapeHTML(path) + ' ' + (item.endsWith('r') ? ((_f = (_e = locale[core.config.locale]) === null || _e === void 0 ? void 0 : _e.readonly) !== null && _f !== void 0 ? _f : locale['en'].readonly) : ((_h = (_g = locale[core.config.locale]) === null || _g === void 0 ? void 0 : _g['read-write']) !== null && _h !== void 0 ? _h : locale['en']['read-write'])) +
1171
+ '<div style="color: var(--system-border-color);">' + tool.escapeHTML(item) + '</div>' +
1172
+ '</div>';
1173
+ continue;
1174
+ }
1175
+ const lang = (_k = (_j = locale[core.config.locale]) === null || _j === void 0 ? void 0 : _j[item]) !== null && _k !== void 0 ? _k : locale['en'][item];
1176
+ html += '<div style="margin-top: 10px;">' +
1177
+ ((_m = lang !== null && lang !== void 0 ? lang : (_l = locale[core.config.locale]) === null || _l === void 0 ? void 0 : _l.unknown) !== null && _m !== void 0 ? _m : locale['en'].unknown) +
1178
+ '<div style="color: var(--system-border-color);">' + tool.escapeHTML(item) + '</div>' +
1179
+ '</div>';
1180
+ }
1181
+ if (yield form.superConfirm(html)) {
1182
+ for (let i = 0; i < rtn.length; ++i) {
1183
+ if (rtn[i]) {
1184
+ continue;
1185
+ }
1186
+ rtn[i] = true;
1187
+ }
1188
+ for (const item of applyList) {
1189
+ task.runtime.permissions.push(item);
1190
+ }
1191
+ try {
1192
+ applyHandler === null || applyHandler === void 0 ? void 0 : applyHandler(applyList);
1193
+ }
1194
+ catch (e) {
1195
+ console.log('task.checkPermission', e);
1196
+ }
1197
+ }
1198
+ }
1199
+ return rtn;
1200
+ });
1201
+ }
1202
+ exports.checkPermission = checkPermission;
964
1203
  function end(taskId) {
965
1204
  var _a;
966
1205
  const task = exports.list[taskId];