clickgo 3.1.3-dev12 → 3.1.4-dev13
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.
- package/README.md +1 -1
- package/dist/app/demo/config.json +4 -0
- package/dist/app/demo/form/event/other/other.js +29 -0
- package/dist/app/demo/form/event/other/other.xml +5 -0
- package/dist/app/demo/form/main.js +5 -0
- package/dist/app/demo/form/main.xml +1 -0
- package/dist/app/demo/form/method/aform/aform.js +2 -1
- package/dist/app/demo/form/method/aform/sd.js +28 -0
- package/dist/app/demo/form/method/aform/sd.xml +7 -0
- package/dist/app/demo/form/method/aform/test.xml +4 -5
- package/dist/app/demo/form/method/core/core.js +12 -0
- package/dist/app/demo/form/method/core/core.xml +4 -0
- package/dist/app/demo/form/method/task/task.js +9 -1
- package/dist/app/demo/form/method/task/task.xml +1 -0
- package/dist/control/common.cgc +0 -0
- package/dist/control/form.cgc +0 -0
- package/dist/control/monaco.cgc +0 -0
- package/dist/control/property.cgc +0 -0
- package/dist/control/task.cgc +0 -0
- package/dist/global.css +1 -1
- package/dist/index.js +3 -0
- package/dist/index.ts +6 -0
- package/dist/lib/core.js +59 -5
- package/dist/lib/core.ts +66 -3
- package/dist/lib/dom.js +3 -3
- package/dist/lib/dom.ts +4 -4
- package/dist/lib/form.js +77 -33
- package/dist/lib/form.ts +90 -37
- package/dist/lib/fs.js +107 -12
- package/dist/lib/fs.ts +111 -20
- package/dist/lib/native.js +8 -1
- package/dist/lib/native.ts +6 -0
- package/dist/lib/task.js +237 -11
- package/dist/lib/task.ts +274 -9
- package/dist/theme/familiar.cgt +0 -0
- package/package.json +2 -2
- package/types/index.d.ts +61 -16
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
|
-
|
|
245
|
-
console.
|
|
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': {
|
|
@@ -639,24 +699,49 @@ function run(url, opt = {}) {
|
|
|
639
699
|
},
|
|
640
700
|
max: function () {
|
|
641
701
|
return __awaiter(this, void 0, void 0, function* () {
|
|
702
|
+
const rtn = yield checkPermission('native.form', false, undefined, taskId);
|
|
703
|
+
if (!rtn[0]) {
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
642
706
|
yield native.max();
|
|
643
707
|
});
|
|
644
708
|
},
|
|
645
709
|
min: function () {
|
|
646
710
|
return __awaiter(this, void 0, void 0, function* () {
|
|
711
|
+
const rtn = yield checkPermission('native.form', false, undefined, taskId);
|
|
712
|
+
if (!rtn[0]) {
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
647
715
|
yield native.min();
|
|
648
716
|
});
|
|
649
717
|
},
|
|
650
718
|
restore: function () {
|
|
651
719
|
return __awaiter(this, void 0, void 0, function* () {
|
|
720
|
+
const rtn = yield checkPermission('native.form', false, undefined, taskId);
|
|
721
|
+
if (!rtn[0]) {
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
652
724
|
yield native.restore();
|
|
653
725
|
});
|
|
654
726
|
},
|
|
655
727
|
size: function (width, height) {
|
|
656
728
|
return __awaiter(this, void 0, void 0, function* () {
|
|
729
|
+
const rtn = yield checkPermission('native.form', false, undefined, taskId);
|
|
730
|
+
if (!rtn[0]) {
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
657
733
|
yield native.size(width, height);
|
|
658
734
|
});
|
|
659
735
|
},
|
|
736
|
+
maximizable: function (val) {
|
|
737
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
738
|
+
const rtn = yield checkPermission('native.form', false, undefined, taskId);
|
|
739
|
+
if (!rtn[0]) {
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
yield native.maximizable(val);
|
|
743
|
+
});
|
|
744
|
+
},
|
|
660
745
|
ping: function (val) {
|
|
661
746
|
return native.ping(val);
|
|
662
747
|
},
|
|
@@ -694,8 +779,16 @@ function run(url, opt = {}) {
|
|
|
694
779
|
}
|
|
695
780
|
opt.unblock = inUnblock;
|
|
696
781
|
}
|
|
782
|
+
if (opt.permissions) {
|
|
783
|
+
if (ntask && !ntask.runtime.permissions.includes('root')) {
|
|
784
|
+
opt.permissions = undefined;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
697
787
|
return run(url, opt);
|
|
698
788
|
},
|
|
789
|
+
checkPermission: function (vals, apply = false, applyHandler) {
|
|
790
|
+
return checkPermission(vals, apply, applyHandler, taskId);
|
|
791
|
+
},
|
|
699
792
|
end: function (tid) {
|
|
700
793
|
return end(tid !== null && tid !== void 0 ? tid : taskId);
|
|
701
794
|
},
|
|
@@ -861,8 +954,8 @@ function run(url, opt = {}) {
|
|
|
861
954
|
'path': path,
|
|
862
955
|
'current': current,
|
|
863
956
|
'runtime': clickgo.vue.reactive({
|
|
864
|
-
'
|
|
865
|
-
'
|
|
957
|
+
'dialogFormIds': [],
|
|
958
|
+
'permissions': (_c = opt.permissions) !== null && _c !== void 0 ? _c : []
|
|
866
959
|
}),
|
|
867
960
|
'forms': {},
|
|
868
961
|
'controls': {},
|
|
@@ -887,7 +980,7 @@ function run(url, opt = {}) {
|
|
|
887
980
|
const data = JSON.parse(lcontent);
|
|
888
981
|
loadLocaleData(locale, data, '', taskId);
|
|
889
982
|
}
|
|
890
|
-
catch (
|
|
983
|
+
catch (_e) {
|
|
891
984
|
}
|
|
892
985
|
}
|
|
893
986
|
}
|
|
@@ -918,7 +1011,7 @@ function run(url, opt = {}) {
|
|
|
918
1011
|
delete exports.list[taskId];
|
|
919
1012
|
return -400 + r;
|
|
920
1013
|
}
|
|
921
|
-
if ((
|
|
1014
|
+
if ((_d = app.config.themes) === null || _d === void 0 ? void 0 : _d.length) {
|
|
922
1015
|
for (let path of app.config.themes) {
|
|
923
1016
|
path += '.cgt';
|
|
924
1017
|
path = tool.urlResolve('/', path);
|
|
@@ -951,8 +1044,8 @@ function run(url, opt = {}) {
|
|
|
951
1044
|
}
|
|
952
1045
|
}
|
|
953
1046
|
core.trigger('taskStarted', taskId);
|
|
954
|
-
if (
|
|
955
|
-
yield
|
|
1047
|
+
if (app.config.permissions) {
|
|
1048
|
+
yield checkPermission(app.config.permissions, true, undefined, taskId);
|
|
956
1049
|
}
|
|
957
1050
|
const appCls = new expo.default();
|
|
958
1051
|
exports.list[taskId].class = appCls;
|
|
@@ -961,6 +1054,139 @@ function run(url, opt = {}) {
|
|
|
961
1054
|
});
|
|
962
1055
|
}
|
|
963
1056
|
exports.run = run;
|
|
1057
|
+
const locale = {
|
|
1058
|
+
'sc': {
|
|
1059
|
+
'unknown': '未知权限',
|
|
1060
|
+
'apply-permission': '正在申请权限,请您仔细确认',
|
|
1061
|
+
'native.form': '实体窗体控制',
|
|
1062
|
+
'hash': '可修改地址栏 hash',
|
|
1063
|
+
'fs': '文件系统',
|
|
1064
|
+
'readonly': '只读',
|
|
1065
|
+
'read-write': '读写'
|
|
1066
|
+
},
|
|
1067
|
+
'tc': {
|
|
1068
|
+
'unknown': '未知許可權',
|
|
1069
|
+
'apply-permission': '正在申請許可權,請您仔細確認',
|
|
1070
|
+
'native.form': '實體視窗控制',
|
|
1071
|
+
'hash': '可修改位址列 hash',
|
|
1072
|
+
'fs': '檔案系統',
|
|
1073
|
+
'readonly': '唯讀',
|
|
1074
|
+
'read-write': '讀寫'
|
|
1075
|
+
},
|
|
1076
|
+
'en': {
|
|
1077
|
+
'unknown': 'Unknown',
|
|
1078
|
+
'apply-permission': 'is applying for permissions, please check carefully',
|
|
1079
|
+
'native.form': 'Native window control',
|
|
1080
|
+
'hash': 'Can modify the location hash',
|
|
1081
|
+
'fs': 'File system',
|
|
1082
|
+
'readonly': 'Read only',
|
|
1083
|
+
'read-write': 'Read and write'
|
|
1084
|
+
},
|
|
1085
|
+
'ja': {
|
|
1086
|
+
'unknown': '不明な許可',
|
|
1087
|
+
'apply-permission': '許可申請中、よくご確認ください',
|
|
1088
|
+
'native.form': 'ローカルウィンドウを操作する',
|
|
1089
|
+
'hash': '網址の hash 変更可能',
|
|
1090
|
+
'fs': '資料システム',
|
|
1091
|
+
'readonly': '読み取り専用',
|
|
1092
|
+
'read-write': '読み書き'
|
|
1093
|
+
}
|
|
1094
|
+
};
|
|
1095
|
+
function checkPermission(vals, apply = false, applyHandler, taskId) {
|
|
1096
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1097
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1098
|
+
if (!taskId) {
|
|
1099
|
+
return [false];
|
|
1100
|
+
}
|
|
1101
|
+
const task = exports.list[taskId];
|
|
1102
|
+
if (!task) {
|
|
1103
|
+
return [false];
|
|
1104
|
+
}
|
|
1105
|
+
if (typeof vals === 'string') {
|
|
1106
|
+
vals = [vals];
|
|
1107
|
+
}
|
|
1108
|
+
const rtn = [];
|
|
1109
|
+
const applyList = [];
|
|
1110
|
+
for (const val of vals) {
|
|
1111
|
+
if (task.runtime.permissions.includes('root')) {
|
|
1112
|
+
rtn.push(true);
|
|
1113
|
+
continue;
|
|
1114
|
+
}
|
|
1115
|
+
if (val.startsWith('fs.')) {
|
|
1116
|
+
let yes = false;
|
|
1117
|
+
const path = val.slice(3, -1);
|
|
1118
|
+
for (const v of task.runtime.permissions) {
|
|
1119
|
+
if (!v.startsWith('fs.')) {
|
|
1120
|
+
continue;
|
|
1121
|
+
}
|
|
1122
|
+
const pa = v.slice(3, -1);
|
|
1123
|
+
if (pa.endsWith('/')) {
|
|
1124
|
+
if (!path.startsWith(pa)) {
|
|
1125
|
+
continue;
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
else if (pa !== path) {
|
|
1129
|
+
continue;
|
|
1130
|
+
}
|
|
1131
|
+
if (val.endsWith('w')) {
|
|
1132
|
+
if (v.endsWith('r')) {
|
|
1133
|
+
continue;
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
yes = true;
|
|
1137
|
+
break;
|
|
1138
|
+
}
|
|
1139
|
+
rtn.push(yes);
|
|
1140
|
+
if (!yes && apply) {
|
|
1141
|
+
applyList.push(val);
|
|
1142
|
+
}
|
|
1143
|
+
continue;
|
|
1144
|
+
}
|
|
1145
|
+
const result = task.runtime.permissions.includes(val);
|
|
1146
|
+
if (!result && apply) {
|
|
1147
|
+
applyList.push(val);
|
|
1148
|
+
}
|
|
1149
|
+
rtn.push(result);
|
|
1150
|
+
}
|
|
1151
|
+
if (applyList.length) {
|
|
1152
|
+
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>';
|
|
1153
|
+
for (const item of applyList) {
|
|
1154
|
+
if (item.startsWith('fs.')) {
|
|
1155
|
+
const path = item.slice(3, -1);
|
|
1156
|
+
html += '<div style="margin-top: 10px;">' +
|
|
1157
|
+
((_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'])) +
|
|
1158
|
+
'<div style="color: var(--system-border-color);">' + tool.escapeHTML(item) + '</div>' +
|
|
1159
|
+
'</div>';
|
|
1160
|
+
continue;
|
|
1161
|
+
}
|
|
1162
|
+
const lang = (_k = (_j = locale[core.config.locale]) === null || _j === void 0 ? void 0 : _j[item]) !== null && _k !== void 0 ? _k : locale['en'][item];
|
|
1163
|
+
html += '<div style="margin-top: 10px;">' +
|
|
1164
|
+
((_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) +
|
|
1165
|
+
'<div style="color: var(--system-border-color);">' + tool.escapeHTML(item) + '</div>' +
|
|
1166
|
+
'</div>';
|
|
1167
|
+
}
|
|
1168
|
+
if (yield form.superConfirm(html)) {
|
|
1169
|
+
for (let i = 0; i < rtn.length; ++i) {
|
|
1170
|
+
if (rtn[i]) {
|
|
1171
|
+
continue;
|
|
1172
|
+
}
|
|
1173
|
+
rtn[i] = true;
|
|
1174
|
+
}
|
|
1175
|
+
for (const item of applyList) {
|
|
1176
|
+
task.runtime.permissions.push(item);
|
|
1177
|
+
}
|
|
1178
|
+
try {
|
|
1179
|
+
applyHandler === null || applyHandler === void 0 ? void 0 : applyHandler(applyList);
|
|
1180
|
+
}
|
|
1181
|
+
catch (e) {
|
|
1182
|
+
console.log('task.checkPermission', e);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
return rtn;
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
exports.checkPermission = checkPermission;
|
|
964
1190
|
function end(taskId) {
|
|
965
1191
|
var _a;
|
|
966
1192
|
const task = exports.list[taskId];
|