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/task.js
ADDED
|
@@ -0,0 +1,686 @@
|
|
|
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.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;
|
|
13
|
+
const core = require("./core");
|
|
14
|
+
const control = require("./control");
|
|
15
|
+
const dom = require("./dom");
|
|
16
|
+
const tool = require("./tool");
|
|
17
|
+
const form = require("./form");
|
|
18
|
+
const theme = require("./theme");
|
|
19
|
+
const fs = require("./fs");
|
|
20
|
+
const native = require("./native");
|
|
21
|
+
exports.list = {};
|
|
22
|
+
exports.lastId = 0;
|
|
23
|
+
const localeData = {
|
|
24
|
+
'en': {
|
|
25
|
+
'loading': 'Loading...',
|
|
26
|
+
},
|
|
27
|
+
'sc': {
|
|
28
|
+
'loading': '加载中……'
|
|
29
|
+
},
|
|
30
|
+
'tc': {
|
|
31
|
+
'loading': '載入中……'
|
|
32
|
+
},
|
|
33
|
+
'ja': {
|
|
34
|
+
'loading': '読み込み中...'
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
let frameTimer = 0;
|
|
38
|
+
const frameMaps = {};
|
|
39
|
+
function onFrame(fun, opt = {}) {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
const taskId = opt.taskId;
|
|
42
|
+
const formId = opt.formId;
|
|
43
|
+
if (!taskId || !formId) {
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
const ft = ++frameTimer;
|
|
47
|
+
const scope = (_a = opt.scope) !== null && _a !== void 0 ? _a : 'form';
|
|
48
|
+
const count = (_b = opt.count) !== null && _b !== void 0 ? _b : 0;
|
|
49
|
+
let c = 0;
|
|
50
|
+
let timer;
|
|
51
|
+
const timerHandler = () => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
++c;
|
|
53
|
+
if (exports.list[taskId].forms[formId] === undefined) {
|
|
54
|
+
if (scope === 'form') {
|
|
55
|
+
delete exports.list[taskId].timers['1x' + ft.toString()];
|
|
56
|
+
delete frameMaps[ft];
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
yield fun();
|
|
61
|
+
if (exports.list[taskId].timers['1x' + ft.toString()] == undefined) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (count > 1) {
|
|
65
|
+
if (c === count) {
|
|
66
|
+
delete exports.list[taskId].timers['1x' + ft.toString()];
|
|
67
|
+
delete frameMaps[ft];
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
timer = requestAnimationFrame(function () {
|
|
72
|
+
timerHandler().catch(function (e) {
|
|
73
|
+
console.log(e);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
frameMaps[ft] = timer;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else if (count === 1) {
|
|
80
|
+
delete exports.list[taskId].timers['1x' + ft.toString()];
|
|
81
|
+
delete frameMaps[ft];
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
timer = requestAnimationFrame(function () {
|
|
85
|
+
timerHandler().catch(function (e) {
|
|
86
|
+
console.log(e);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
frameMaps[ft] = timer;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
timer = requestAnimationFrame(function () {
|
|
93
|
+
timerHandler().catch(function (e) {
|
|
94
|
+
console.log(e);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
frameMaps[ft] = timer;
|
|
98
|
+
exports.list[taskId].timers['1x' + ft.toString()] = formId;
|
|
99
|
+
return ft;
|
|
100
|
+
}
|
|
101
|
+
exports.onFrame = onFrame;
|
|
102
|
+
function offFrame(ft, opt = {}) {
|
|
103
|
+
const taskId = opt.taskId;
|
|
104
|
+
if (!taskId) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const formId = exports.list[taskId].timers['1x' + ft.toString()];
|
|
108
|
+
if (formId === undefined) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
cancelAnimationFrame(frameMaps[ft]);
|
|
112
|
+
delete exports.list[taskId].timers['1x' + ft.toString()];
|
|
113
|
+
delete frameMaps[ft];
|
|
114
|
+
}
|
|
115
|
+
exports.offFrame = offFrame;
|
|
116
|
+
function get(tid) {
|
|
117
|
+
if (exports.list[tid] === undefined) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
'name': exports.list[tid].app.config.name,
|
|
122
|
+
'locale': exports.list[tid].locale.lang,
|
|
123
|
+
'customTheme': exports.list[tid].customTheme,
|
|
124
|
+
'formCount': Object.keys(exports.list[tid].forms).length,
|
|
125
|
+
'icon': exports.list[tid].icon,
|
|
126
|
+
'path': exports.list[tid].path
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
exports.get = get;
|
|
130
|
+
function getList() {
|
|
131
|
+
const rtn = {};
|
|
132
|
+
for (const tid in exports.list) {
|
|
133
|
+
const item = exports.list[tid];
|
|
134
|
+
rtn[tid] = {
|
|
135
|
+
'name': item.app.config.name,
|
|
136
|
+
'locale': item.locale.lang,
|
|
137
|
+
'customTheme': item.customTheme,
|
|
138
|
+
'formCount': Object.keys(item.forms).length,
|
|
139
|
+
'icon': item.icon,
|
|
140
|
+
'path': item.path
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
return rtn;
|
|
144
|
+
}
|
|
145
|
+
exports.getList = getList;
|
|
146
|
+
function run(url, opt = {}) {
|
|
147
|
+
var _a, _b, _c;
|
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
let ntask = null;
|
|
150
|
+
if (opt.taskId) {
|
|
151
|
+
ntask = exports.list[opt.taskId];
|
|
152
|
+
}
|
|
153
|
+
if (!url.endsWith('/') && !url.endsWith('.cga')) {
|
|
154
|
+
return 0;
|
|
155
|
+
}
|
|
156
|
+
let icon = __dirname + '/../icon.png';
|
|
157
|
+
if (opt.icon) {
|
|
158
|
+
icon = opt.icon;
|
|
159
|
+
}
|
|
160
|
+
if (opt.progress === undefined) {
|
|
161
|
+
opt.progress = true;
|
|
162
|
+
}
|
|
163
|
+
const notifyId = opt.progress ? form.notify({
|
|
164
|
+
'title': (_b = (_a = localeData[core.config.locale]) === null || _a === void 0 ? void 0 : _a.loading) !== null && _b !== void 0 ? _b : localeData['en'].loading,
|
|
165
|
+
'content': url,
|
|
166
|
+
'icon': icon,
|
|
167
|
+
'timeout': 0,
|
|
168
|
+
'progress': true
|
|
169
|
+
}) : undefined;
|
|
170
|
+
const app = yield core.fetchApp(url, {
|
|
171
|
+
'notifyId': notifyId,
|
|
172
|
+
'current': ntask ? ntask.path : undefined
|
|
173
|
+
});
|
|
174
|
+
if (notifyId) {
|
|
175
|
+
setTimeout(function () {
|
|
176
|
+
form.hideNotify(notifyId);
|
|
177
|
+
}, 2000);
|
|
178
|
+
}
|
|
179
|
+
if (!app) {
|
|
180
|
+
return -1;
|
|
181
|
+
}
|
|
182
|
+
const files = {};
|
|
183
|
+
for (const fpath in app.files) {
|
|
184
|
+
files[fpath] = app.files[fpath];
|
|
185
|
+
}
|
|
186
|
+
const taskId = ++exports.lastId;
|
|
187
|
+
exports.list[taskId] = {
|
|
188
|
+
'id': taskId,
|
|
189
|
+
'app': app,
|
|
190
|
+
'customTheme': false,
|
|
191
|
+
'locale': Vue.reactive({
|
|
192
|
+
'lang': '',
|
|
193
|
+
'data': {}
|
|
194
|
+
}),
|
|
195
|
+
'icon': (_c = app.icon) !== null && _c !== void 0 ? _c : icon,
|
|
196
|
+
'path': url,
|
|
197
|
+
'files': files,
|
|
198
|
+
'permissions': {},
|
|
199
|
+
'forms': {},
|
|
200
|
+
'objectURLs': [],
|
|
201
|
+
'controls': {
|
|
202
|
+
'loaded': {},
|
|
203
|
+
'layout': {},
|
|
204
|
+
'prep': {}
|
|
205
|
+
},
|
|
206
|
+
'timers': {}
|
|
207
|
+
};
|
|
208
|
+
const task = exports.list[taskId];
|
|
209
|
+
for (let path of app.config.controls) {
|
|
210
|
+
path += '.cgc';
|
|
211
|
+
path = tool.urlResolve('/', path);
|
|
212
|
+
const file = yield fs.getContent(path, {
|
|
213
|
+
'files': task.files
|
|
214
|
+
});
|
|
215
|
+
if (file && typeof file !== 'string') {
|
|
216
|
+
const c = yield control.read(file);
|
|
217
|
+
if (c) {
|
|
218
|
+
task.controls.loaded[path] = c;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
form.notify({
|
|
222
|
+
'title': 'Control failed to load',
|
|
223
|
+
'content': path
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (app.config.themes) {
|
|
229
|
+
for (let path of app.config.themes) {
|
|
230
|
+
path += '.cgt';
|
|
231
|
+
path = tool.urlResolve('/', path);
|
|
232
|
+
const file = yield fs.getContent(path, {
|
|
233
|
+
'files': task.files
|
|
234
|
+
});
|
|
235
|
+
if (file && typeof file !== 'string') {
|
|
236
|
+
const th = yield theme.read(file);
|
|
237
|
+
if (th) {
|
|
238
|
+
yield theme.load(th, taskId);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (app.config.locales) {
|
|
244
|
+
for (let path in app.config.locales) {
|
|
245
|
+
const locale = app.config.locales[path];
|
|
246
|
+
if (!path.endsWith('.json')) {
|
|
247
|
+
path += '.json';
|
|
248
|
+
}
|
|
249
|
+
const lcontent = yield fs.getContent(path, {
|
|
250
|
+
'encoding': 'utf8',
|
|
251
|
+
'files': task.files,
|
|
252
|
+
'current': task.path
|
|
253
|
+
});
|
|
254
|
+
if (!lcontent) {
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
try {
|
|
258
|
+
const data = JSON.parse(lcontent);
|
|
259
|
+
loadLocaleData(locale, data, '', task.id);
|
|
260
|
+
}
|
|
261
|
+
catch (_d) {
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
core.trigger('taskStarted', task.id);
|
|
266
|
+
dom.createToStyleList(task.id);
|
|
267
|
+
const f = yield form.create({
|
|
268
|
+
'taskId': task.id,
|
|
269
|
+
'file': app.config.main
|
|
270
|
+
});
|
|
271
|
+
if (typeof f === 'number') {
|
|
272
|
+
delete exports.list[task.id];
|
|
273
|
+
dom.removeFromStyleList(task.id);
|
|
274
|
+
core.trigger('taskEnded', task.id);
|
|
275
|
+
return f - 100;
|
|
276
|
+
}
|
|
277
|
+
if (app.config.style && app.files[app.config.style + '.css']) {
|
|
278
|
+
const style = app.files[app.config.style + '.css'];
|
|
279
|
+
const r = tool.stylePrepend(style, 'cg-task' + task.id.toString() + '_');
|
|
280
|
+
dom.pushStyle(task.id, yield tool.styleUrl2DataUrl(app.config.style, r.style, app.files));
|
|
281
|
+
}
|
|
282
|
+
if (app.config.themes && app.config.themes.length > 0) {
|
|
283
|
+
task.customTheme = true;
|
|
284
|
+
for (const path of app.config.themes) {
|
|
285
|
+
const blob = yield fs.getContent(path, {
|
|
286
|
+
'files': task.files,
|
|
287
|
+
'current': task.path
|
|
288
|
+
});
|
|
289
|
+
if (!(blob instanceof Blob)) {
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
const th = yield theme.read(blob);
|
|
293
|
+
if (!th) {
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
yield theme.load(th, task.id);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
if (theme.global) {
|
|
301
|
+
yield theme.load(undefined, task.id);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return task.id;
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
exports.run = run;
|
|
308
|
+
function end(taskId) {
|
|
309
|
+
const task = exports.list[taskId];
|
|
310
|
+
if (!task) {
|
|
311
|
+
return true;
|
|
312
|
+
}
|
|
313
|
+
const fid = form.getMaxZIndexID({
|
|
314
|
+
'taskIds': [task.id]
|
|
315
|
+
});
|
|
316
|
+
if (fid) {
|
|
317
|
+
form.changeFocus(fid);
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
form.changeFocus();
|
|
321
|
+
}
|
|
322
|
+
for (const fid in task.forms) {
|
|
323
|
+
const f = task.forms[fid];
|
|
324
|
+
core.trigger('formRemoved', taskId, f.id, f.vroot.$refs.form.title, f.vroot.$refs.form.iconData);
|
|
325
|
+
f.vapp.unmount();
|
|
326
|
+
f.vapp._container.remove();
|
|
327
|
+
}
|
|
328
|
+
dom.removeFromStyleList(taskId);
|
|
329
|
+
for (const url of task.objectURLs) {
|
|
330
|
+
tool.revokeObjectURL(url, task.id);
|
|
331
|
+
}
|
|
332
|
+
for (const timer in exports.list[taskId].timers) {
|
|
333
|
+
if (timer.startsWith('1x')) {
|
|
334
|
+
const ft = timer.slice(2);
|
|
335
|
+
cancelAnimationFrame(frameMaps[ft]);
|
|
336
|
+
delete frameMaps[ft];
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
clearTimeout(parseFloat(timer));
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
native.clearListener(taskId);
|
|
343
|
+
dom.clearWatchSize(taskId);
|
|
344
|
+
delete exports.list[taskId];
|
|
345
|
+
core.trigger('taskEnded', taskId);
|
|
346
|
+
clearSystem(taskId);
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
exports.end = end;
|
|
350
|
+
function loadLocaleData(lang, data, pre = '', taskId) {
|
|
351
|
+
if (!taskId) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
if (!exports.list[taskId].locale.data[lang]) {
|
|
355
|
+
exports.list[taskId].locale.data[lang] = {};
|
|
356
|
+
}
|
|
357
|
+
for (const k in data) {
|
|
358
|
+
const v = data[k];
|
|
359
|
+
if (typeof v === 'object') {
|
|
360
|
+
loadLocaleData(lang, v, pre + k + '.', taskId);
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
exports.list[taskId].locale.data[lang][pre + k] = v;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
exports.loadLocaleData = loadLocaleData;
|
|
368
|
+
function loadLocale(lang, path, taskId, formId) {
|
|
369
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
370
|
+
if (!taskId) {
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
const task = exports.list[taskId];
|
|
374
|
+
if (!task) {
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
let form = null;
|
|
378
|
+
if (formId) {
|
|
379
|
+
if (!task.forms[formId]) {
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
form = task.forms[formId];
|
|
383
|
+
}
|
|
384
|
+
const base = form ? form.vroot.cgPath : '/';
|
|
385
|
+
path = tool.urlResolve(base, path) + '.json';
|
|
386
|
+
const fcontent = yield fs.getContent(path, {
|
|
387
|
+
'encoding': 'utf8',
|
|
388
|
+
'files': task.files,
|
|
389
|
+
'current': task.path
|
|
390
|
+
});
|
|
391
|
+
if (!fcontent) {
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
try {
|
|
395
|
+
const data = JSON.parse(fcontent);
|
|
396
|
+
loadLocaleData(lang, data, '', task.id);
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
catch (_a) {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
exports.loadLocale = loadLocale;
|
|
405
|
+
function clearLocale(taskId) {
|
|
406
|
+
if (!taskId) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
const task = exports.list[taskId];
|
|
410
|
+
if (!task) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
task.locale.data = {};
|
|
414
|
+
}
|
|
415
|
+
exports.clearLocale = clearLocale;
|
|
416
|
+
function setLocale(lang, path, taskId, formId) {
|
|
417
|
+
clearLocale(taskId);
|
|
418
|
+
return loadLocale(lang, path, taskId, formId);
|
|
419
|
+
}
|
|
420
|
+
exports.setLocale = setLocale;
|
|
421
|
+
function setLocaleLang(lang, taskId) {
|
|
422
|
+
if (!taskId) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
const task = exports.list[taskId];
|
|
426
|
+
if (!task) {
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
task.locale.lang = lang;
|
|
430
|
+
}
|
|
431
|
+
exports.setLocaleLang = setLocaleLang;
|
|
432
|
+
function clearLocaleLang(taskId) {
|
|
433
|
+
if (!taskId) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
const task = exports.list[taskId];
|
|
437
|
+
if (!task) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
task.locale.lang = '';
|
|
441
|
+
}
|
|
442
|
+
exports.clearLocaleLang = clearLocaleLang;
|
|
443
|
+
function createTimer(fun, delay, opt = {}) {
|
|
444
|
+
var _a, _b;
|
|
445
|
+
const taskId = opt.taskId;
|
|
446
|
+
if (!taskId) {
|
|
447
|
+
return 0;
|
|
448
|
+
}
|
|
449
|
+
const formId = opt.formId;
|
|
450
|
+
if (!formId) {
|
|
451
|
+
return 0;
|
|
452
|
+
}
|
|
453
|
+
const scope = (_a = opt.scope) !== null && _a !== void 0 ? _a : 'form';
|
|
454
|
+
const count = (_b = opt.count) !== null && _b !== void 0 ? _b : 0;
|
|
455
|
+
let c = 0;
|
|
456
|
+
if (opt.immediate) {
|
|
457
|
+
const r = fun();
|
|
458
|
+
if (r instanceof Promise) {
|
|
459
|
+
r.catch(function (e) {
|
|
460
|
+
console.log(e);
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
++c;
|
|
464
|
+
if (count > 0 && c === count) {
|
|
465
|
+
return 0;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
let timer;
|
|
469
|
+
const timerHandler = () => {
|
|
470
|
+
++c;
|
|
471
|
+
if (exports.list[taskId].forms[formId] === undefined) {
|
|
472
|
+
if (scope === 'form') {
|
|
473
|
+
clearTimeout(timer);
|
|
474
|
+
delete exports.list[taskId].timers[timer];
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
const r = fun();
|
|
479
|
+
if (r instanceof Promise) {
|
|
480
|
+
r.catch(function (e) {
|
|
481
|
+
console.log(e);
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
if (count > 0 && c === count) {
|
|
485
|
+
clearTimeout(timer);
|
|
486
|
+
delete exports.list[taskId].timers[timer];
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
if (count === 1) {
|
|
491
|
+
timer = window.setTimeout(timerHandler, delay);
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
timer = window.setInterval(timerHandler, delay);
|
|
495
|
+
}
|
|
496
|
+
exports.list[taskId].timers[timer] = formId;
|
|
497
|
+
return timer;
|
|
498
|
+
}
|
|
499
|
+
exports.createTimer = createTimer;
|
|
500
|
+
function removeTimer(timer, taskId) {
|
|
501
|
+
if (!taskId) {
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
if (exports.list[taskId] === undefined) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
const formId = exports.list[taskId].timers[timer];
|
|
508
|
+
if (formId === undefined) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
clearTimeout(timer);
|
|
512
|
+
delete exports.list[taskId].timers[timer];
|
|
513
|
+
}
|
|
514
|
+
exports.removeTimer = removeTimer;
|
|
515
|
+
function sleep(fun, delay, taskId, formId) {
|
|
516
|
+
return createTimer(fun, delay, {
|
|
517
|
+
'taskId': taskId,
|
|
518
|
+
'formId': formId,
|
|
519
|
+
'count': 1
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
exports.sleep = sleep;
|
|
523
|
+
exports.systemTaskInfo = Vue.reactive({
|
|
524
|
+
'taskId': 0,
|
|
525
|
+
'formId': 0,
|
|
526
|
+
'length': 0
|
|
527
|
+
});
|
|
528
|
+
Vue.watch(exports.systemTaskInfo, function (n, o) {
|
|
529
|
+
var _a, _b;
|
|
530
|
+
const originKeys = ['taskId', 'formId', 'length'];
|
|
531
|
+
for (const key of originKeys) {
|
|
532
|
+
if (exports.systemTaskInfo[key] !== undefined) {
|
|
533
|
+
continue;
|
|
534
|
+
}
|
|
535
|
+
form.notify({
|
|
536
|
+
'title': 'Warning',
|
|
537
|
+
'content': 'There is a software that maliciously removed the system task info item.\nKey: ' + key,
|
|
538
|
+
'type': 'warning'
|
|
539
|
+
});
|
|
540
|
+
exports.systemTaskInfo[key] = (_a = o[key]) !== null && _a !== void 0 ? _a : 0;
|
|
541
|
+
}
|
|
542
|
+
for (const key in exports.systemTaskInfo) {
|
|
543
|
+
if (!['taskId', 'formId', 'length'].includes(key)) {
|
|
544
|
+
form.notify({
|
|
545
|
+
'title': 'Warning',
|
|
546
|
+
'content': 'There is a software that maliciously modifies the system task info item.\nKey: ' + key,
|
|
547
|
+
'type': 'warning'
|
|
548
|
+
});
|
|
549
|
+
delete exports.systemTaskInfo[key];
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
if (typeof exports.systemTaskInfo[key] === 'number') {
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
form.notify({
|
|
556
|
+
'title': 'Warning',
|
|
557
|
+
'content': 'There is a software that maliciously modifies the system task info item.\nKey: ' + key,
|
|
558
|
+
'type': 'warning'
|
|
559
|
+
});
|
|
560
|
+
exports.systemTaskInfo[key] = (_b = o[key]) !== null && _b !== void 0 ? _b : 0;
|
|
561
|
+
}
|
|
562
|
+
}, {
|
|
563
|
+
'deep': true
|
|
564
|
+
});
|
|
565
|
+
function setSystem(formId, taskId) {
|
|
566
|
+
if (!formId || !taskId) {
|
|
567
|
+
return false;
|
|
568
|
+
}
|
|
569
|
+
const task = exports.list[taskId];
|
|
570
|
+
if (!task) {
|
|
571
|
+
return false;
|
|
572
|
+
}
|
|
573
|
+
const f = task.forms[formId];
|
|
574
|
+
if (!f) {
|
|
575
|
+
return false;
|
|
576
|
+
}
|
|
577
|
+
if (f.vroot.position === undefined) {
|
|
578
|
+
form.notify({
|
|
579
|
+
'title': 'Warning',
|
|
580
|
+
'content': `Task id is "${taskId}" app is not an available task app, position not found.`,
|
|
581
|
+
'type': 'warning'
|
|
582
|
+
});
|
|
583
|
+
return false;
|
|
584
|
+
}
|
|
585
|
+
if (exports.systemTaskInfo.taskId > 0) {
|
|
586
|
+
form.notify({
|
|
587
|
+
'title': 'Info',
|
|
588
|
+
'content': 'More than 1 system-level task application is currently running.',
|
|
589
|
+
'type': 'info'
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
exports.systemTaskInfo.taskId = taskId;
|
|
593
|
+
exports.systemTaskInfo.formId = formId;
|
|
594
|
+
form.simpleSystemTaskRoot.forms = {};
|
|
595
|
+
refreshSystemPosition();
|
|
596
|
+
return true;
|
|
597
|
+
}
|
|
598
|
+
exports.setSystem = setSystem;
|
|
599
|
+
function clearSystem(taskId) {
|
|
600
|
+
if (!taskId) {
|
|
601
|
+
return false;
|
|
602
|
+
}
|
|
603
|
+
if (typeof taskId !== 'number') {
|
|
604
|
+
form.notify({
|
|
605
|
+
'title': 'Warning',
|
|
606
|
+
'content': 'The "formId" of "clearTask" must be a number type.',
|
|
607
|
+
'type': 'warning'
|
|
608
|
+
});
|
|
609
|
+
return false;
|
|
610
|
+
}
|
|
611
|
+
if (exports.systemTaskInfo.taskId !== taskId) {
|
|
612
|
+
return false;
|
|
613
|
+
}
|
|
614
|
+
exports.systemTaskInfo.taskId = 0;
|
|
615
|
+
exports.systemTaskInfo.formId = 0;
|
|
616
|
+
exports.systemTaskInfo.length = 0;
|
|
617
|
+
core.trigger('screenResize');
|
|
618
|
+
const tasks = getList();
|
|
619
|
+
for (const taskId in tasks) {
|
|
620
|
+
const forms = form.getList(parseInt(taskId));
|
|
621
|
+
for (const formId in forms) {
|
|
622
|
+
const f = forms[formId];
|
|
623
|
+
if (!f.stateMin) {
|
|
624
|
+
continue;
|
|
625
|
+
}
|
|
626
|
+
form.simpleSystemTaskRoot.forms[formId] = {
|
|
627
|
+
'title': f.title,
|
|
628
|
+
'icon': f.icon
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
return true;
|
|
633
|
+
}
|
|
634
|
+
exports.clearSystem = clearSystem;
|
|
635
|
+
function refreshSystemPosition() {
|
|
636
|
+
if (exports.systemTaskInfo.taskId > 0) {
|
|
637
|
+
const form = exports.list[exports.systemTaskInfo.taskId].forms[exports.systemTaskInfo.formId];
|
|
638
|
+
switch (core.config['task.position']) {
|
|
639
|
+
case 'left':
|
|
640
|
+
case 'right': {
|
|
641
|
+
form.vroot.$refs.form.setPropData('width', 'auto');
|
|
642
|
+
form.vroot.$refs.form.setPropData('height', document.body.clientHeight);
|
|
643
|
+
break;
|
|
644
|
+
}
|
|
645
|
+
case 'top':
|
|
646
|
+
case 'bottom': {
|
|
647
|
+
form.vroot.$refs.form.setPropData('width', document.body.clientWidth);
|
|
648
|
+
form.vroot.$refs.form.setPropData('height', 'auto');
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
setTimeout(function () {
|
|
653
|
+
switch (core.config['task.position']) {
|
|
654
|
+
case 'left': {
|
|
655
|
+
exports.systemTaskInfo.length = form.vroot.$el.offsetWidth;
|
|
656
|
+
form.vroot.$refs.form.setPropData('left', 0);
|
|
657
|
+
form.vroot.$refs.form.setPropData('top', 0);
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
case 'right': {
|
|
661
|
+
exports.systemTaskInfo.length = form.vroot.$el.offsetWidth;
|
|
662
|
+
form.vroot.$refs.form.setPropData('left', document.body.clientWidth - exports.systemTaskInfo.length);
|
|
663
|
+
form.vroot.$refs.form.setPropData('top', 0);
|
|
664
|
+
break;
|
|
665
|
+
}
|
|
666
|
+
case 'top': {
|
|
667
|
+
exports.systemTaskInfo.length = form.vroot.$el.offsetHeight;
|
|
668
|
+
form.vroot.$refs.form.setPropData('left', 0);
|
|
669
|
+
form.vroot.$refs.form.setPropData('top', 0);
|
|
670
|
+
break;
|
|
671
|
+
}
|
|
672
|
+
case 'bottom': {
|
|
673
|
+
exports.systemTaskInfo.length = form.vroot.$el.offsetHeight;
|
|
674
|
+
form.vroot.$refs.form.setPropData('left', 0);
|
|
675
|
+
form.vroot.$refs.form.setPropData('top', document.body.clientHeight - exports.systemTaskInfo.length);
|
|
676
|
+
break;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
core.trigger('screenResize');
|
|
680
|
+
}, 50);
|
|
681
|
+
}
|
|
682
|
+
else {
|
|
683
|
+
core.trigger('screenResize');
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
exports.refreshSystemPosition = refreshSystemPosition;
|