clickgo 3.0.0-dev
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/LICENSE +201 -0
- package/README.md +75 -0
- package/dist/app/demo/config.json +106 -0
- package/dist/app/demo/form/control/block/block.css +1 -0
- package/dist/app/demo/form/control/block/block.scss +17 -0
- package/dist/app/demo/form/control/block/block.xml +7 -0
- package/dist/app/demo/form/control/button/button.css +1 -0
- package/dist/app/demo/form/control/button/button.js +27 -0
- package/dist/app/demo/form/control/button/button.scss +18 -0
- package/dist/app/demo/form/control/button/button.xml +126 -0
- package/dist/app/demo/form/control/check/check.js +12 -0
- package/dist/app/demo/form/control/check/check.xml +13 -0
- package/dist/app/demo/form/control/dialog/dialog.js +8 -0
- package/dist/app/demo/form/control/dialog/dialog.xml +26 -0
- package/dist/app/demo/form/control/file/file.js +23 -0
- package/dist/app/demo/form/control/file/file.xml +25 -0
- package/dist/app/demo/form/control/form/form.css +1 -0
- package/dist/app/demo/form/control/form/form.js +38 -0
- package/dist/app/demo/form/control/form/form.scss +9 -0
- package/dist/app/demo/form/control/form/form.xml +28 -0
- package/dist/app/demo/form/control/greatview/greatview.css +1 -0
- package/dist/app/demo/form/control/greatview/greatview.js +92 -0
- package/dist/app/demo/form/control/greatview/greatview.scss +22 -0
- package/dist/app/demo/form/control/greatview/greatview.xml +89 -0
- package/dist/app/demo/form/control/img/img.xml +16 -0
- package/dist/app/demo/form/control/label/label.xml +11 -0
- package/dist/app/demo/form/control/list/list.css +1 -0
- package/dist/app/demo/form/control/list/list.js +194 -0
- package/dist/app/demo/form/control/list/list.scss +7 -0
- package/dist/app/demo/form/control/list/list.xml +91 -0
- package/dist/app/demo/form/control/loading/loading.xml +8 -0
- package/dist/app/demo/form/control/marquee/marquee.js +30 -0
- package/dist/app/demo/form/control/marquee/marquee.xml +36 -0
- package/dist/app/demo/form/control/menu/menu.js +8 -0
- package/dist/app/demo/form/control/menu/menu.xml +122 -0
- package/dist/app/demo/form/control/monaco/monaco.js +113 -0
- package/dist/app/demo/form/control/monaco/monaco.xml +27 -0
- package/dist/app/demo/form/control/overflow/overflow.css +1 -0
- package/dist/app/demo/form/control/overflow/overflow.js +70 -0
- package/dist/app/demo/form/control/overflow/overflow.scss +18 -0
- package/dist/app/demo/form/control/overflow/overflow.xml +98 -0
- package/dist/app/demo/form/control/property/property.js +129 -0
- package/dist/app/demo/form/control/property/property.xml +6 -0
- package/dist/app/demo/form/control/radio/radio.js +7 -0
- package/dist/app/demo/form/control/radio/radio.xml +12 -0
- package/dist/app/demo/form/control/scroll/scroll.js +14 -0
- package/dist/app/demo/form/control/scroll/scroll.xml +35 -0
- package/dist/app/demo/form/control/select/select.js +91 -0
- package/dist/app/demo/form/control/select/select.xml +74 -0
- package/dist/app/demo/form/control/tab/tab.js +75 -0
- package/dist/app/demo/form/control/tab/tab.xml +22 -0
- package/dist/app/demo/form/control/text/text.js +53 -0
- package/dist/app/demo/form/control/text/text.xml +37 -0
- package/dist/app/demo/form/control/view/view.css +1 -0
- package/dist/app/demo/form/control/view/view.js +73 -0
- package/dist/app/demo/form/control/view/view.scss +18 -0
- package/dist/app/demo/form/control/view/view.xml +94 -0
- package/dist/app/demo/form/event/form/form.css +1 -0
- package/dist/app/demo/form/event/form/form.js +129 -0
- package/dist/app/demo/form/event/form/form.scss +24 -0
- package/dist/app/demo/form/event/form/form.xml +16 -0
- package/dist/app/demo/form/event/screen/screen.js +51 -0
- package/dist/app/demo/form/event/screen/screen.xml +9 -0
- package/dist/app/demo/form/event/task/task.js +78 -0
- package/dist/app/demo/form/event/task/task.xml +20 -0
- package/dist/app/demo/form/main.css +1 -0
- package/dist/app/demo/form/main.js +25 -0
- package/dist/app/demo/form/main.scss +9 -0
- package/dist/app/demo/form/main.xml +49 -0
- package/dist/app/demo/form/method/core/core.js +25 -0
- package/dist/app/demo/form/method/core/core.xml +7 -0
- package/dist/app/demo/form/method/dom/dom.css +1 -0
- package/dist/app/demo/form/method/dom/dom.js +163 -0
- package/dist/app/demo/form/method/dom/dom.scss +10 -0
- package/dist/app/demo/form/method/dom/dom.xml +55 -0
- package/dist/app/demo/form/method/form/form.css +1 -0
- package/dist/app/demo/form/method/form/form.js +217 -0
- package/dist/app/demo/form/method/form/form.scss +3 -0
- package/dist/app/demo/form/method/form/form.xml +56 -0
- package/dist/app/demo/form/method/form/test.xml +5 -0
- package/dist/app/demo/form/method/fs/fs.js +88 -0
- package/dist/app/demo/form/method/fs/fs.xml +8 -0
- package/dist/app/demo/form/method/fs/text.js +15 -0
- package/dist/app/demo/form/method/fs/text.xml +3 -0
- package/dist/app/demo/form/method/task/locale1.json +3 -0
- package/dist/app/demo/form/method/task/locale2.json +3 -0
- package/dist/app/demo/form/method/task/task.js +153 -0
- package/dist/app/demo/form/method/task/task.xml +57 -0
- package/dist/app/demo/form/method/theme/theme.js +74 -0
- package/dist/app/demo/form/method/theme/theme.xml +9 -0
- package/dist/app/demo/form/method/tool/tool.js +64 -0
- package/dist/app/demo/form/method/tool/tool.xml +26 -0
- package/dist/app/demo/form/method/zip/zip.js +99 -0
- package/dist/app/demo/form/method/zip/zip.xml +12 -0
- package/dist/app/demo/global.css +3 -0
- package/dist/app/demo/res/icon.svg +1 -0
- package/dist/app/demo/res/img.jpg +0 -0
- package/dist/app/demo/res/r-1.svg +1 -0
- package/dist/app/demo/res/r-2.svg +1 -0
- package/dist/app/demo/res/sql.svg +1 -0
- package/dist/app/demo/res/txt.svg +1 -0
- package/dist/app/demo/res/zip.svg +1 -0
- package/dist/app/task/config.json +29 -0
- package/dist/app/task/form/bar/bar.js +299 -0
- package/dist/app/task/form/bar/bar.xml +47 -0
- package/dist/app/task/form/desktop/desktop.xml +1 -0
- package/dist/app/task/locale/en.json +11 -0
- package/dist/app/task/locale/ja.json +11 -0
- package/dist/app/task/locale/sc.json +11 -0
- package/dist/app/task/locale/tc.json +11 -0
- package/dist/clickgo.js +41 -0
- package/dist/clickgo.ts +51 -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 -0
- package/dist/icon.png +0 -0
- package/dist/index.js +88 -0
- package/dist/index.ts +92 -0
- package/dist/lib/control.js +365 -0
- package/dist/lib/control.ts +428 -0
- package/dist/lib/core.js +668 -0
- package/dist/lib/core.ts +732 -0
- package/dist/lib/dom.js +1471 -0
- package/dist/lib/dom.ts +1785 -0
- package/dist/lib/form.js +2101 -0
- package/dist/lib/form.ts +2496 -0
- package/dist/lib/fs.js +849 -0
- package/dist/lib/fs.ts +995 -0
- package/dist/lib/native.js +138 -0
- package/dist/lib/native.ts +219 -0
- package/dist/lib/task.js +686 -0
- package/dist/lib/task.ts +842 -0
- package/dist/lib/theme.js +159 -0
- package/dist/lib/theme.ts +196 -0
- package/dist/lib/tool.js +501 -0
- package/dist/lib/tool.ts +620 -0
- package/dist/lib/zip.js +352 -0
- package/dist/lib/zip.ts +434 -0
- package/dist/theme/familiar.cgt +0 -0
- package/package.json +27 -0
- package/types/dev.d.ts +30 -0
- package/types/index.d.ts +673 -0
package/dist/lib/core.js
ADDED
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
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.config = void 0;
|
|
13
|
+
const clickgo = require("../clickgo");
|
|
14
|
+
const fs = require("./fs");
|
|
15
|
+
const form = require("./form");
|
|
16
|
+
const task = require("./task");
|
|
17
|
+
const tool = require("./tool");
|
|
18
|
+
const zip = require("./zip");
|
|
19
|
+
const configOrigin = {
|
|
20
|
+
'locale': 'en',
|
|
21
|
+
'task.position': 'bottom',
|
|
22
|
+
'task.pin': {},
|
|
23
|
+
'desktop.icon.storage': true,
|
|
24
|
+
'desktop.icon.recycler': true,
|
|
25
|
+
'desktop.wallpaper': null,
|
|
26
|
+
'desktop.path': null
|
|
27
|
+
};
|
|
28
|
+
exports.config = Vue.reactive({
|
|
29
|
+
'locale': 'en',
|
|
30
|
+
'task.position': 'bottom',
|
|
31
|
+
'task.pin': {},
|
|
32
|
+
'desktop.icon.storage': true,
|
|
33
|
+
'desktop.icon.recycler': true,
|
|
34
|
+
'desktop.wallpaper': null,
|
|
35
|
+
'desktop.path': null
|
|
36
|
+
});
|
|
37
|
+
Vue.watch(exports.config, function () {
|
|
38
|
+
for (const key in configOrigin) {
|
|
39
|
+
if (exports.config[key] !== undefined) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
form.notify({
|
|
43
|
+
'title': 'Warning',
|
|
44
|
+
'content': 'There is a software that maliciously removed the system config item.\nKey: ' + key,
|
|
45
|
+
'type': 'warning'
|
|
46
|
+
});
|
|
47
|
+
exports.config[key] = configOrigin[key];
|
|
48
|
+
}
|
|
49
|
+
for (const key in exports.config) {
|
|
50
|
+
if (!Object.keys(configOrigin).includes(key)) {
|
|
51
|
+
form.notify({
|
|
52
|
+
'title': 'Warning',
|
|
53
|
+
'content': 'There is a software that maliciously modifies the system config.\nKey: ' + key,
|
|
54
|
+
'type': 'warning'
|
|
55
|
+
});
|
|
56
|
+
delete exports.config[key];
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (key === 'task.pin') {
|
|
60
|
+
const paths = Object.keys(exports.config['task.pin']).sort().toString();
|
|
61
|
+
const originPaths = Object.keys(configOrigin['task.pin']).sort().toString();
|
|
62
|
+
if (paths === originPaths) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
configOrigin['task.pin'] = {};
|
|
66
|
+
for (const path in exports.config['task.pin']) {
|
|
67
|
+
configOrigin['task.pin'][path] = exports.config['task.pin'][path];
|
|
68
|
+
}
|
|
69
|
+
trigger('configChanged', 'task.pin', exports.config['task.pin']);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
if (exports.config[key] === configOrigin[key]) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
configOrigin[key] = exports.config[key];
|
|
76
|
+
if (key === 'task.position') {
|
|
77
|
+
task.refreshSystemPosition();
|
|
78
|
+
}
|
|
79
|
+
trigger('configChanged', key, exports.config[key]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
'deep': true
|
|
84
|
+
});
|
|
85
|
+
const modules = {
|
|
86
|
+
'monaco': {
|
|
87
|
+
func: function () {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
return new Promise(function (resolve, reject) {
|
|
90
|
+
fetch(clickgo.getCdn() + '/npm/monaco-editor@0.33.0/min/vs/loader.js').then(function (r) {
|
|
91
|
+
return r.blob();
|
|
92
|
+
}).then(function (b) {
|
|
93
|
+
return tool.blob2DataUrl(b);
|
|
94
|
+
}).then(function (d) {
|
|
95
|
+
resolve(d);
|
|
96
|
+
}).catch(function (e) {
|
|
97
|
+
reject(e);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
'obj': null,
|
|
103
|
+
'loading': false
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
function regModule(name, func) {
|
|
107
|
+
if (modules[name]) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
modules[name] = {
|
|
111
|
+
func: func,
|
|
112
|
+
'obj': null,
|
|
113
|
+
'loading': false
|
|
114
|
+
};
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
exports.regModule = regModule;
|
|
118
|
+
function initModules(names) {
|
|
119
|
+
return new Promise(function (resolve) {
|
|
120
|
+
if (typeof names === 'string') {
|
|
121
|
+
names = [names];
|
|
122
|
+
}
|
|
123
|
+
if (names.length === 0) {
|
|
124
|
+
resolve(0);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
let loaded = 0;
|
|
128
|
+
let successful = 0;
|
|
129
|
+
for (const name of names) {
|
|
130
|
+
if (!modules[name]) {
|
|
131
|
+
++loaded;
|
|
132
|
+
if (loaded === names.length) {
|
|
133
|
+
resolve(successful);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (modules[name].obj) {
|
|
139
|
+
++loaded;
|
|
140
|
+
++successful;
|
|
141
|
+
if (loaded === names.length) {
|
|
142
|
+
resolve(successful);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (modules[name].loading) {
|
|
148
|
+
++loaded;
|
|
149
|
+
if (loaded === names.length) {
|
|
150
|
+
resolve(successful);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
modules[name].loading = true;
|
|
156
|
+
const rtn = modules[name].func();
|
|
157
|
+
if (rtn instanceof Promise) {
|
|
158
|
+
rtn.then(function (obj) {
|
|
159
|
+
modules[name].obj = obj;
|
|
160
|
+
modules[name].loading = false;
|
|
161
|
+
++loaded;
|
|
162
|
+
++successful;
|
|
163
|
+
if (loaded === names.length) {
|
|
164
|
+
resolve(successful);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
}).catch(function () {
|
|
168
|
+
modules[name].loading = false;
|
|
169
|
+
++loaded;
|
|
170
|
+
if (loaded === names.length) {
|
|
171
|
+
resolve(successful);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
modules[name].obj = rtn;
|
|
177
|
+
modules[name].loading = false;
|
|
178
|
+
++loaded;
|
|
179
|
+
++successful;
|
|
180
|
+
if (loaded === names.length) {
|
|
181
|
+
resolve(successful);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
exports.initModules = initModules;
|
|
188
|
+
function getModule(name) {
|
|
189
|
+
if (!modules[name]) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
return modules[name].obj;
|
|
193
|
+
}
|
|
194
|
+
exports.getModule = getModule;
|
|
195
|
+
exports.globalEvents = {
|
|
196
|
+
errorHandler: null,
|
|
197
|
+
screenResizeHandler: function () {
|
|
198
|
+
form.refreshMaxPosition();
|
|
199
|
+
},
|
|
200
|
+
configChangedHandler: null,
|
|
201
|
+
formCreatedHandler: null,
|
|
202
|
+
formRemovedHandler: function (taskId, formId) {
|
|
203
|
+
if (!form.simpleSystemTaskRoot.forms[formId]) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
delete form.simpleSystemTaskRoot.forms[formId];
|
|
207
|
+
},
|
|
208
|
+
formTitleChangedHandler: function (taskId, formId, title) {
|
|
209
|
+
if (!form.simpleSystemTaskRoot.forms[formId]) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
form.simpleSystemTaskRoot.forms[formId].title = title;
|
|
213
|
+
},
|
|
214
|
+
formIconChangedHandler: function (taskId, formId, icon) {
|
|
215
|
+
if (!form.simpleSystemTaskRoot.forms[formId]) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
form.simpleSystemTaskRoot.forms[formId].icon = icon;
|
|
219
|
+
},
|
|
220
|
+
formStateMinChangedHandler: function (taskId, formId, state) {
|
|
221
|
+
if (task.systemTaskInfo.taskId > 0) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (state) {
|
|
225
|
+
const item = form.get(formId);
|
|
226
|
+
if (!item) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
form.simpleSystemTaskRoot.forms[formId] = {
|
|
230
|
+
'title': item.title,
|
|
231
|
+
'icon': item.icon
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
if (!form.simpleSystemTaskRoot.forms[formId]) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
delete form.simpleSystemTaskRoot.forms[formId];
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
formStateMaxChangedHandler: null,
|
|
242
|
+
formShowChangedHandler: null,
|
|
243
|
+
formFocusedHandler: null,
|
|
244
|
+
formBlurredHandler: null,
|
|
245
|
+
formFlashHandler: null,
|
|
246
|
+
taskStartedHandler: null,
|
|
247
|
+
taskEndedHandler: null
|
|
248
|
+
};
|
|
249
|
+
function setSystemEventListener(name, func, formId, taskId) {
|
|
250
|
+
if (!taskId) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const t = task.list[taskId];
|
|
254
|
+
if (!t) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (!formId) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const f = t.forms[formId];
|
|
261
|
+
if (!f) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
f.events[name] = func;
|
|
265
|
+
}
|
|
266
|
+
exports.setSystemEventListener = setSystemEventListener;
|
|
267
|
+
function removeSystemEventListener(name, formId, taskId) {
|
|
268
|
+
if (!taskId) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const t = task.list[taskId];
|
|
272
|
+
if (!t) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (!formId) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const f = t.forms[formId];
|
|
279
|
+
if (!f) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
delete f.events[name];
|
|
283
|
+
}
|
|
284
|
+
exports.removeSystemEventListener = removeSystemEventListener;
|
|
285
|
+
function trigger(name, taskId = 0, formId = 0, param1 = '', param2 = '') {
|
|
286
|
+
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;
|
|
287
|
+
switch (name) {
|
|
288
|
+
case 'error': {
|
|
289
|
+
if (typeof taskId !== 'number' || typeof formId !== 'number') {
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
const r = (_a = exports.globalEvents.errorHandler) === null || _a === void 0 ? void 0 : _a.call(exports.globalEvents, taskId, formId, param1, param2);
|
|
293
|
+
if (r && (r instanceof Promise)) {
|
|
294
|
+
r.catch(function (e) {
|
|
295
|
+
console.log(e);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
for (const tid in task.list) {
|
|
299
|
+
const t = task.list[tid];
|
|
300
|
+
for (const fid in t.forms) {
|
|
301
|
+
const r = (_c = (_b = t.forms[fid].events)[name]) === null || _c === void 0 ? void 0 : _c.call(_b, taskId, formId, param1, param2);
|
|
302
|
+
if (r instanceof Promise) {
|
|
303
|
+
r.catch(function (e) {
|
|
304
|
+
console.log(e);
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
case 'screenResize': {
|
|
312
|
+
const r = (_d = exports.globalEvents.screenResizeHandler) === null || _d === void 0 ? void 0 : _d.call(exports.globalEvents);
|
|
313
|
+
if (r && (r instanceof Promise)) {
|
|
314
|
+
r.catch(function (e) {
|
|
315
|
+
console.log(e);
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
for (const tid in task.list) {
|
|
319
|
+
const t = task.list[tid];
|
|
320
|
+
for (const fid in t.forms) {
|
|
321
|
+
const r = (_f = (_e = t.forms[fid].events)[name]) === null || _f === void 0 ? void 0 : _f.call(_e);
|
|
322
|
+
if (r instanceof Promise) {
|
|
323
|
+
r.catch(function (e) {
|
|
324
|
+
console.log(e);
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
case 'configChanged': {
|
|
332
|
+
if ((typeof taskId !== 'string') || (typeof formId === 'number')) {
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
const r = (_g = exports.globalEvents.configChangedHandler) === null || _g === void 0 ? void 0 : _g.call(exports.globalEvents, taskId, formId);
|
|
336
|
+
if (r && (r instanceof Promise)) {
|
|
337
|
+
r.catch(function (e) {
|
|
338
|
+
console.log(e);
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
for (const tid in task.list) {
|
|
342
|
+
const t = task.list[tid];
|
|
343
|
+
for (const fid in t.forms) {
|
|
344
|
+
const r = (_j = (_h = t.forms[fid].events)[name]) === null || _j === void 0 ? void 0 : _j.call(_h, taskId, formId);
|
|
345
|
+
if (r instanceof Promise) {
|
|
346
|
+
r.catch(function (e) {
|
|
347
|
+
console.log(e);
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
case 'formCreated':
|
|
355
|
+
case 'formRemoved': {
|
|
356
|
+
(_l = (_k = exports.globalEvents)[name + 'Handler']) === null || _l === void 0 ? void 0 : _l.call(_k, taskId, formId, param1, param2);
|
|
357
|
+
for (const tid in task.list) {
|
|
358
|
+
const t = task.list[tid];
|
|
359
|
+
for (const fid in t.forms) {
|
|
360
|
+
const r = (_o = (_m = t.forms[fid].events)[name]) === null || _o === void 0 ? void 0 : _o.call(_m, taskId, formId, param1, param2);
|
|
361
|
+
if (r instanceof Promise) {
|
|
362
|
+
r.catch(function (e) {
|
|
363
|
+
console.log(e);
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
case 'formTitleChanged':
|
|
371
|
+
case 'formIconChanged': {
|
|
372
|
+
(_q = (_p = exports.globalEvents)[name + 'Handler']) === null || _q === void 0 ? void 0 : _q.call(_p, taskId, formId, param1);
|
|
373
|
+
for (const tid in task.list) {
|
|
374
|
+
const t = task.list[tid];
|
|
375
|
+
for (const fid in t.forms) {
|
|
376
|
+
const r = (_s = (_r = t.forms[fid].events)[name]) === null || _s === void 0 ? void 0 : _s.call(_r, taskId, formId, param1);
|
|
377
|
+
if (r instanceof Promise) {
|
|
378
|
+
r.catch(function (e) {
|
|
379
|
+
console.log(e);
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
case 'formStateMinChanged':
|
|
387
|
+
case 'formStateMaxChanged':
|
|
388
|
+
case 'formShowChanged': {
|
|
389
|
+
(_u = (_t = exports.globalEvents)[name + 'Handler']) === null || _u === void 0 ? void 0 : _u.call(_t, taskId, formId, param1);
|
|
390
|
+
for (const tid in task.list) {
|
|
391
|
+
const t = task.list[tid];
|
|
392
|
+
for (const fid in t.forms) {
|
|
393
|
+
const r = (_w = (_v = t.forms[fid].events)[name]) === null || _w === void 0 ? void 0 : _w.call(_v, taskId, formId, param1);
|
|
394
|
+
if (r instanceof Promise) {
|
|
395
|
+
r.catch(function (e) {
|
|
396
|
+
console.log(e);
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
403
|
+
case 'formFocused':
|
|
404
|
+
case 'formBlurred':
|
|
405
|
+
case 'formFlash': {
|
|
406
|
+
(_y = (_x = exports.globalEvents)[name + 'Handler']) === null || _y === void 0 ? void 0 : _y.call(_x, taskId, formId);
|
|
407
|
+
for (const tid in task.list) {
|
|
408
|
+
const t = task.list[tid];
|
|
409
|
+
for (const fid in t.forms) {
|
|
410
|
+
const r = (_0 = (_z = t.forms[fid].events)[name]) === null || _0 === void 0 ? void 0 : _0.call(_z, taskId, formId);
|
|
411
|
+
if (r instanceof Promise) {
|
|
412
|
+
r.catch(function (e) {
|
|
413
|
+
console.log(e);
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
case 'taskStarted':
|
|
421
|
+
case 'taskEnded': {
|
|
422
|
+
(_2 = (_1 = exports.globalEvents)[name + 'Handler']) === null || _2 === void 0 ? void 0 : _2.call(_1, taskId, formId);
|
|
423
|
+
for (const tid in task.list) {
|
|
424
|
+
const t = task.list[tid];
|
|
425
|
+
for (const fid in t.forms) {
|
|
426
|
+
const r = (_4 = (_3 = t.forms[fid].events)[name]) === null || _4 === void 0 ? void 0 : _4.call(_3, taskId);
|
|
427
|
+
if (r instanceof Promise) {
|
|
428
|
+
r.catch(function (e) {
|
|
429
|
+
console.log(e);
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
exports.trigger = trigger;
|
|
439
|
+
function readApp(blob) {
|
|
440
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
441
|
+
const iconLength = parseInt(yield blob.slice(0, 7).text());
|
|
442
|
+
const icon = yield tool.blob2DataUrl(blob.slice(7, 7 + iconLength));
|
|
443
|
+
const z = yield zip.get(blob.slice(7 + iconLength));
|
|
444
|
+
if (!z) {
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
const files = {};
|
|
448
|
+
const configContent = yield z.getContent('/config.json');
|
|
449
|
+
if (!configContent) {
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
const config = JSON.parse(configContent);
|
|
453
|
+
for (const file of config.files) {
|
|
454
|
+
const mime = tool.getMimeByPath(file);
|
|
455
|
+
if (['txt', 'json', 'js', 'css', 'xml', 'html'].includes(mime.ext)) {
|
|
456
|
+
const fab = yield z.getContent(file, 'string');
|
|
457
|
+
if (!fab) {
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
files[file] = fab.replace(/^\ufeff/, '');
|
|
461
|
+
}
|
|
462
|
+
else {
|
|
463
|
+
const fab = yield z.getContent(file, 'arraybuffer');
|
|
464
|
+
if (!fab) {
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
files[file] = new Blob([fab], {
|
|
468
|
+
'type': mime.mime
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
if (!config) {
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
return {
|
|
476
|
+
'type': 'app',
|
|
477
|
+
'icon': icon,
|
|
478
|
+
'config': config,
|
|
479
|
+
'files': files
|
|
480
|
+
};
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
exports.readApp = readApp;
|
|
484
|
+
function fetchApp(url, opt = {}) {
|
|
485
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
486
|
+
let cga = '';
|
|
487
|
+
if (!url.endsWith('/')) {
|
|
488
|
+
const lio = url.lastIndexOf('/');
|
|
489
|
+
cga = lio === -1 ? url : url.slice(lio + 1);
|
|
490
|
+
if (!cga.endsWith('.cga')) {
|
|
491
|
+
return null;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
let current = '';
|
|
495
|
+
if (opt.current) {
|
|
496
|
+
if (!opt.current.endsWith('/')) {
|
|
497
|
+
return null;
|
|
498
|
+
}
|
|
499
|
+
current = opt.current.slice(0, -1);
|
|
500
|
+
if (!url.startsWith('/')) {
|
|
501
|
+
url = '/current/' + url;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
if (!url.startsWith('/clickgo/') && !url.startsWith('/storage/') && !url.startsWith('/mounted/')) {
|
|
506
|
+
current = tool.urlResolve(window.location.href, url);
|
|
507
|
+
if (cga) {
|
|
508
|
+
current = current.slice(0, -cga.length - 1);
|
|
509
|
+
url = '/current/' + cga;
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
current = current.slice(0, -1);
|
|
513
|
+
url = '/current/';
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (cga) {
|
|
518
|
+
if (opt.notifyId) {
|
|
519
|
+
const blob = yield fs.getContent(url, {
|
|
520
|
+
'current': current,
|
|
521
|
+
progress: (loaded, total) => {
|
|
522
|
+
form.notifyProgress(opt.notifyId, loaded / total);
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
if ((blob === null) || (typeof blob === 'string')) {
|
|
526
|
+
return null;
|
|
527
|
+
}
|
|
528
|
+
form.notifyProgress(opt.notifyId, 1);
|
|
529
|
+
return (yield readApp(blob)) || null;
|
|
530
|
+
}
|
|
531
|
+
else {
|
|
532
|
+
try {
|
|
533
|
+
const blob = yield fs.getContent(url, {
|
|
534
|
+
'current': current
|
|
535
|
+
});
|
|
536
|
+
if ((blob === null) || typeof blob === 'string') {
|
|
537
|
+
return null;
|
|
538
|
+
}
|
|
539
|
+
return (yield readApp(blob)) || null;
|
|
540
|
+
}
|
|
541
|
+
catch (_a) {
|
|
542
|
+
return null;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
let config;
|
|
547
|
+
const files = {};
|
|
548
|
+
try {
|
|
549
|
+
const blob = yield fs.getContent(url + 'config.json', {
|
|
550
|
+
'current': current
|
|
551
|
+
});
|
|
552
|
+
if (blob === null || typeof blob === 'string') {
|
|
553
|
+
return null;
|
|
554
|
+
}
|
|
555
|
+
config = JSON.parse(yield tool.blob2Text(blob));
|
|
556
|
+
yield new Promise(function (resolve) {
|
|
557
|
+
const total = config.files.length;
|
|
558
|
+
let loaded = 0;
|
|
559
|
+
for (const file of config.files) {
|
|
560
|
+
fs.getContent(url + file.slice(1), {
|
|
561
|
+
'current': current
|
|
562
|
+
}).then(function (blob) {
|
|
563
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
564
|
+
if (blob === null || typeof blob === 'string') {
|
|
565
|
+
clickgo.form.notify({
|
|
566
|
+
'title': 'File not found',
|
|
567
|
+
'content': url + file.slice(1),
|
|
568
|
+
'type': 'danger'
|
|
569
|
+
});
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
const mime = tool.getMimeByPath(file);
|
|
573
|
+
if (['txt', 'json', 'js', 'css', 'xml', 'html'].includes(mime.ext)) {
|
|
574
|
+
files[file] = (yield tool.blob2Text(blob)).replace(/^\ufeff/, '');
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
files[file] = blob;
|
|
578
|
+
}
|
|
579
|
+
++loaded;
|
|
580
|
+
if (opt.notifyId) {
|
|
581
|
+
form.notifyProgress(opt.notifyId, loaded / total);
|
|
582
|
+
}
|
|
583
|
+
if (loaded < total) {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
resolve();
|
|
587
|
+
});
|
|
588
|
+
}).catch(function () {
|
|
589
|
+
++loaded;
|
|
590
|
+
if (opt.notifyId) {
|
|
591
|
+
form.notifyProgress(opt.notifyId, loaded / total);
|
|
592
|
+
}
|
|
593
|
+
if (loaded < total) {
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
resolve();
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
catch (_b) {
|
|
602
|
+
return null;
|
|
603
|
+
}
|
|
604
|
+
let icon = '/clickgo/icon.png';
|
|
605
|
+
if (config.icon && (files[config.icon] instanceof Blob)) {
|
|
606
|
+
icon = yield tool.blob2DataUrl(files[config.icon]);
|
|
607
|
+
}
|
|
608
|
+
return {
|
|
609
|
+
'type': 'app',
|
|
610
|
+
'icon': icon,
|
|
611
|
+
'config': config,
|
|
612
|
+
'files': files
|
|
613
|
+
};
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
exports.fetchApp = fetchApp;
|
|
617
|
+
function getAvailArea() {
|
|
618
|
+
if (Object.keys(form.simpleSystemTaskRoot.forms).length > 0) {
|
|
619
|
+
return {
|
|
620
|
+
'left': 0,
|
|
621
|
+
'top': 0,
|
|
622
|
+
'width': document.body.clientWidth,
|
|
623
|
+
'height': document.body.clientHeight - 46
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
let left = 0;
|
|
628
|
+
let top = 0;
|
|
629
|
+
let width = 0;
|
|
630
|
+
let height = 0;
|
|
631
|
+
switch (exports.config['task.position']) {
|
|
632
|
+
case 'left': {
|
|
633
|
+
left = task.systemTaskInfo.length;
|
|
634
|
+
top = 0;
|
|
635
|
+
width = document.body.clientWidth - task.systemTaskInfo.length;
|
|
636
|
+
height = document.body.clientHeight;
|
|
637
|
+
break;
|
|
638
|
+
}
|
|
639
|
+
case 'right': {
|
|
640
|
+
left = 0;
|
|
641
|
+
top = 0;
|
|
642
|
+
width = document.body.clientWidth - task.systemTaskInfo.length;
|
|
643
|
+
height = document.body.clientHeight;
|
|
644
|
+
break;
|
|
645
|
+
}
|
|
646
|
+
case 'top': {
|
|
647
|
+
left = 0;
|
|
648
|
+
top = task.systemTaskInfo.length;
|
|
649
|
+
width = document.body.clientWidth;
|
|
650
|
+
height = document.body.clientHeight - task.systemTaskInfo.length;
|
|
651
|
+
break;
|
|
652
|
+
}
|
|
653
|
+
case 'bottom': {
|
|
654
|
+
left = 0;
|
|
655
|
+
top = 0;
|
|
656
|
+
width = document.body.clientWidth;
|
|
657
|
+
height = document.body.clientHeight - task.systemTaskInfo.length;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
return {
|
|
661
|
+
'left': left,
|
|
662
|
+
'top': top,
|
|
663
|
+
'width': width,
|
|
664
|
+
'height': height
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
exports.getAvailArea = getAvailArea;
|