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.
Files changed (145) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +75 -0
  3. package/dist/app/demo/config.json +106 -0
  4. package/dist/app/demo/form/control/block/block.css +1 -0
  5. package/dist/app/demo/form/control/block/block.scss +17 -0
  6. package/dist/app/demo/form/control/block/block.xml +7 -0
  7. package/dist/app/demo/form/control/button/button.css +1 -0
  8. package/dist/app/demo/form/control/button/button.js +27 -0
  9. package/dist/app/demo/form/control/button/button.scss +18 -0
  10. package/dist/app/demo/form/control/button/button.xml +126 -0
  11. package/dist/app/demo/form/control/check/check.js +12 -0
  12. package/dist/app/demo/form/control/check/check.xml +13 -0
  13. package/dist/app/demo/form/control/dialog/dialog.js +8 -0
  14. package/dist/app/demo/form/control/dialog/dialog.xml +26 -0
  15. package/dist/app/demo/form/control/file/file.js +23 -0
  16. package/dist/app/demo/form/control/file/file.xml +25 -0
  17. package/dist/app/demo/form/control/form/form.css +1 -0
  18. package/dist/app/demo/form/control/form/form.js +38 -0
  19. package/dist/app/demo/form/control/form/form.scss +9 -0
  20. package/dist/app/demo/form/control/form/form.xml +28 -0
  21. package/dist/app/demo/form/control/greatview/greatview.css +1 -0
  22. package/dist/app/demo/form/control/greatview/greatview.js +92 -0
  23. package/dist/app/demo/form/control/greatview/greatview.scss +22 -0
  24. package/dist/app/demo/form/control/greatview/greatview.xml +89 -0
  25. package/dist/app/demo/form/control/img/img.xml +16 -0
  26. package/dist/app/demo/form/control/label/label.xml +11 -0
  27. package/dist/app/demo/form/control/list/list.css +1 -0
  28. package/dist/app/demo/form/control/list/list.js +194 -0
  29. package/dist/app/demo/form/control/list/list.scss +7 -0
  30. package/dist/app/demo/form/control/list/list.xml +91 -0
  31. package/dist/app/demo/form/control/loading/loading.xml +8 -0
  32. package/dist/app/demo/form/control/marquee/marquee.js +30 -0
  33. package/dist/app/demo/form/control/marquee/marquee.xml +36 -0
  34. package/dist/app/demo/form/control/menu/menu.js +8 -0
  35. package/dist/app/demo/form/control/menu/menu.xml +122 -0
  36. package/dist/app/demo/form/control/monaco/monaco.js +113 -0
  37. package/dist/app/demo/form/control/monaco/monaco.xml +27 -0
  38. package/dist/app/demo/form/control/overflow/overflow.css +1 -0
  39. package/dist/app/demo/form/control/overflow/overflow.js +70 -0
  40. package/dist/app/demo/form/control/overflow/overflow.scss +18 -0
  41. package/dist/app/demo/form/control/overflow/overflow.xml +98 -0
  42. package/dist/app/demo/form/control/property/property.js +129 -0
  43. package/dist/app/demo/form/control/property/property.xml +6 -0
  44. package/dist/app/demo/form/control/radio/radio.js +7 -0
  45. package/dist/app/demo/form/control/radio/radio.xml +12 -0
  46. package/dist/app/demo/form/control/scroll/scroll.js +14 -0
  47. package/dist/app/demo/form/control/scroll/scroll.xml +35 -0
  48. package/dist/app/demo/form/control/select/select.js +91 -0
  49. package/dist/app/demo/form/control/select/select.xml +74 -0
  50. package/dist/app/demo/form/control/tab/tab.js +75 -0
  51. package/dist/app/demo/form/control/tab/tab.xml +22 -0
  52. package/dist/app/demo/form/control/text/text.js +53 -0
  53. package/dist/app/demo/form/control/text/text.xml +37 -0
  54. package/dist/app/demo/form/control/view/view.css +1 -0
  55. package/dist/app/demo/form/control/view/view.js +73 -0
  56. package/dist/app/demo/form/control/view/view.scss +18 -0
  57. package/dist/app/demo/form/control/view/view.xml +94 -0
  58. package/dist/app/demo/form/event/form/form.css +1 -0
  59. package/dist/app/demo/form/event/form/form.js +129 -0
  60. package/dist/app/demo/form/event/form/form.scss +24 -0
  61. package/dist/app/demo/form/event/form/form.xml +16 -0
  62. package/dist/app/demo/form/event/screen/screen.js +51 -0
  63. package/dist/app/demo/form/event/screen/screen.xml +9 -0
  64. package/dist/app/demo/form/event/task/task.js +78 -0
  65. package/dist/app/demo/form/event/task/task.xml +20 -0
  66. package/dist/app/demo/form/main.css +1 -0
  67. package/dist/app/demo/form/main.js +25 -0
  68. package/dist/app/demo/form/main.scss +9 -0
  69. package/dist/app/demo/form/main.xml +49 -0
  70. package/dist/app/demo/form/method/core/core.js +25 -0
  71. package/dist/app/demo/form/method/core/core.xml +7 -0
  72. package/dist/app/demo/form/method/dom/dom.css +1 -0
  73. package/dist/app/demo/form/method/dom/dom.js +163 -0
  74. package/dist/app/demo/form/method/dom/dom.scss +10 -0
  75. package/dist/app/demo/form/method/dom/dom.xml +55 -0
  76. package/dist/app/demo/form/method/form/form.css +1 -0
  77. package/dist/app/demo/form/method/form/form.js +217 -0
  78. package/dist/app/demo/form/method/form/form.scss +3 -0
  79. package/dist/app/demo/form/method/form/form.xml +56 -0
  80. package/dist/app/demo/form/method/form/test.xml +5 -0
  81. package/dist/app/demo/form/method/fs/fs.js +88 -0
  82. package/dist/app/demo/form/method/fs/fs.xml +8 -0
  83. package/dist/app/demo/form/method/fs/text.js +15 -0
  84. package/dist/app/demo/form/method/fs/text.xml +3 -0
  85. package/dist/app/demo/form/method/task/locale1.json +3 -0
  86. package/dist/app/demo/form/method/task/locale2.json +3 -0
  87. package/dist/app/demo/form/method/task/task.js +153 -0
  88. package/dist/app/demo/form/method/task/task.xml +57 -0
  89. package/dist/app/demo/form/method/theme/theme.js +74 -0
  90. package/dist/app/demo/form/method/theme/theme.xml +9 -0
  91. package/dist/app/demo/form/method/tool/tool.js +64 -0
  92. package/dist/app/demo/form/method/tool/tool.xml +26 -0
  93. package/dist/app/demo/form/method/zip/zip.js +99 -0
  94. package/dist/app/demo/form/method/zip/zip.xml +12 -0
  95. package/dist/app/demo/global.css +3 -0
  96. package/dist/app/demo/res/icon.svg +1 -0
  97. package/dist/app/demo/res/img.jpg +0 -0
  98. package/dist/app/demo/res/r-1.svg +1 -0
  99. package/dist/app/demo/res/r-2.svg +1 -0
  100. package/dist/app/demo/res/sql.svg +1 -0
  101. package/dist/app/demo/res/txt.svg +1 -0
  102. package/dist/app/demo/res/zip.svg +1 -0
  103. package/dist/app/task/config.json +29 -0
  104. package/dist/app/task/form/bar/bar.js +299 -0
  105. package/dist/app/task/form/bar/bar.xml +47 -0
  106. package/dist/app/task/form/desktop/desktop.xml +1 -0
  107. package/dist/app/task/locale/en.json +11 -0
  108. package/dist/app/task/locale/ja.json +11 -0
  109. package/dist/app/task/locale/sc.json +11 -0
  110. package/dist/app/task/locale/tc.json +11 -0
  111. package/dist/clickgo.js +41 -0
  112. package/dist/clickgo.ts +51 -0
  113. package/dist/control/common.cgc +0 -0
  114. package/dist/control/form.cgc +0 -0
  115. package/dist/control/monaco.cgc +0 -0
  116. package/dist/control/property.cgc +0 -0
  117. package/dist/control/task.cgc +0 -0
  118. package/dist/global.css +1 -0
  119. package/dist/icon.png +0 -0
  120. package/dist/index.js +88 -0
  121. package/dist/index.ts +92 -0
  122. package/dist/lib/control.js +365 -0
  123. package/dist/lib/control.ts +428 -0
  124. package/dist/lib/core.js +668 -0
  125. package/dist/lib/core.ts +732 -0
  126. package/dist/lib/dom.js +1471 -0
  127. package/dist/lib/dom.ts +1785 -0
  128. package/dist/lib/form.js +2101 -0
  129. package/dist/lib/form.ts +2496 -0
  130. package/dist/lib/fs.js +849 -0
  131. package/dist/lib/fs.ts +995 -0
  132. package/dist/lib/native.js +138 -0
  133. package/dist/lib/native.ts +219 -0
  134. package/dist/lib/task.js +686 -0
  135. package/dist/lib/task.ts +842 -0
  136. package/dist/lib/theme.js +159 -0
  137. package/dist/lib/theme.ts +196 -0
  138. package/dist/lib/tool.js +501 -0
  139. package/dist/lib/tool.ts +620 -0
  140. package/dist/lib/zip.js +352 -0
  141. package/dist/lib/zip.ts +434 -0
  142. package/dist/theme/familiar.cgt +0 -0
  143. package/package.json +27 -0
  144. package/types/dev.d.ts +30 -0
  145. package/types/index.d.ts +673 -0
@@ -0,0 +1,352 @@
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.get = exports.Zip = void 0;
13
+ const jszip = require("jszip");
14
+ const tool = require("./tool");
15
+ class Zip {
16
+ constructor(zip) {
17
+ this._path = '/';
18
+ this._list = {};
19
+ this._zip = zip;
20
+ this._refreshList();
21
+ }
22
+ getContent(path, type = 'string') {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ path = tool.urlResolve(this._path, path);
25
+ const f = this._zip.file(path.slice(1));
26
+ if (!f) {
27
+ return null;
28
+ }
29
+ if (type === 'string') {
30
+ return f.async('string');
31
+ }
32
+ else {
33
+ return f.async(type);
34
+ }
35
+ });
36
+ }
37
+ putContent(path, data, options = {}) {
38
+ path = tool.urlResolve(this._path, path);
39
+ this._zip.file(path.slice(1), data, {
40
+ 'base64': options.base64,
41
+ 'binary': options.binary,
42
+ 'date': options.date
43
+ });
44
+ this._refreshList();
45
+ }
46
+ unlink(path) {
47
+ path = tool.urlResolve(this._path, path);
48
+ this._zip.remove(path.slice(1));
49
+ this._refreshList();
50
+ }
51
+ stats(path) {
52
+ path = tool.urlResolve(this._path, path);
53
+ let dirpath = path.endsWith('/') ? path : path + '/';
54
+ if (!this._list[dirpath]) {
55
+ if (path.endsWith('/')) {
56
+ return null;
57
+ }
58
+ const lio = path.lastIndexOf('/') + 1;
59
+ const dpath = path.slice(0, lio);
60
+ const fname = path.slice(lio);
61
+ if (!this._list[dpath]) {
62
+ return null;
63
+ }
64
+ const file = this._list[dpath][fname];
65
+ if (!file) {
66
+ return null;
67
+ }
68
+ return {
69
+ 'date': file.date,
70
+ 'isFile': true,
71
+ 'isDirectory': false
72
+ };
73
+ }
74
+ else {
75
+ if (dirpath === '/') {
76
+ return {
77
+ 'date': new Date(),
78
+ 'isFile': false,
79
+ 'isDirectory': true
80
+ };
81
+ }
82
+ dirpath = dirpath.slice(0, -1);
83
+ const lio = dirpath.lastIndexOf('/') + 1;
84
+ const dpath = dirpath.slice(0, lio);
85
+ const fname = dirpath.slice(lio);
86
+ const pfolder = this._list[dpath];
87
+ const folder = pfolder[fname];
88
+ return {
89
+ 'date': folder.date,
90
+ 'isFile': false,
91
+ 'isDirectory': true
92
+ };
93
+ }
94
+ }
95
+ isDir(path) {
96
+ const pstats = this.stats(path);
97
+ if (!pstats || !pstats.isDirectory) {
98
+ return false;
99
+ }
100
+ return pstats;
101
+ }
102
+ isFile(path) {
103
+ const pstats = this.stats(path);
104
+ if (!pstats || !pstats.isFile) {
105
+ return false;
106
+ }
107
+ return pstats;
108
+ }
109
+ readDir(path, opt = {}) {
110
+ if (opt.hasChildren === undefined) {
111
+ opt.hasChildren = false;
112
+ }
113
+ if (opt.hasDir === undefined) {
114
+ opt.hasDir = true;
115
+ }
116
+ if (opt.pathAsKey === undefined) {
117
+ opt.pathAsKey = false;
118
+ }
119
+ if (!path) {
120
+ path = this._path;
121
+ }
122
+ else {
123
+ path = tool.urlResolve(this._path, path);
124
+ }
125
+ if (!path.endsWith('/')) {
126
+ path += '/';
127
+ }
128
+ const folder = this._zip.folder(path.slice(1));
129
+ if (!folder) {
130
+ return opt.pathAsKey ? {} : [];
131
+ }
132
+ if (!this._list[path]) {
133
+ return opt.pathAsKey ? {} : [];
134
+ }
135
+ if (!opt.hasChildren) {
136
+ if (opt.pathAsKey) {
137
+ return this._list[path];
138
+ }
139
+ const list = [];
140
+ for (const k in this._list[path]) {
141
+ list.push(this._list[path][k]);
142
+ }
143
+ return list;
144
+ }
145
+ if (opt.pathAsKey) {
146
+ const list = {};
147
+ for (const k in this._list[path]) {
148
+ const item = this._list[path][k];
149
+ if (item.isFile || opt.hasDir) {
150
+ list[item.path + item.name] = item;
151
+ }
152
+ if (item.isDirectory) {
153
+ Object.assign(list, this._readDir(item, {
154
+ 'hasDir': opt.hasDir,
155
+ 'pathAsKey': opt.pathAsKey
156
+ }));
157
+ }
158
+ }
159
+ return list;
160
+ }
161
+ else {
162
+ let list = [];
163
+ for (const k in this._list[path]) {
164
+ const item = this._list[path][k];
165
+ if (item.isFile || opt.hasDir) {
166
+ list.push(item);
167
+ }
168
+ if (item.isDirectory) {
169
+ list = list.concat(this._readDir(item, {
170
+ 'hasDir': opt.hasDir,
171
+ 'pathAsKey': opt.pathAsKey
172
+ }));
173
+ }
174
+ }
175
+ return list;
176
+ }
177
+ }
178
+ _readDir(item, opt) {
179
+ if (opt.pathAsKey) {
180
+ const list = {};
181
+ if (!this._list[item.path + item.name + '/']) {
182
+ return {};
183
+ }
184
+ for (const k in this._list[item.path + item.name + '/']) {
185
+ const it = this._list[item.path + item.name + '/'][k];
186
+ if (it.isFile || opt.hasDir) {
187
+ list[it.path + it.name] = it;
188
+ }
189
+ if (it.isDirectory) {
190
+ Object.assign(list, this._readDir(it, {
191
+ 'hasDir': opt.hasDir,
192
+ 'pathAsKey': opt.pathAsKey
193
+ }));
194
+ }
195
+ }
196
+ return list;
197
+ }
198
+ else {
199
+ let list = [];
200
+ if (!this._list[item.path + item.name + '/']) {
201
+ return [];
202
+ }
203
+ for (const k in this._list[item.path + item.name + '/']) {
204
+ const it = this._list[item.path + item.name + '/'][k];
205
+ if (it.isFile || opt.hasDir) {
206
+ list.push(it);
207
+ }
208
+ if (it.isDirectory) {
209
+ list = list.concat(this._readDir(it, {
210
+ 'hasDir': opt.hasDir,
211
+ 'pathAsKey': opt.pathAsKey
212
+ }));
213
+ }
214
+ }
215
+ return list;
216
+ }
217
+ }
218
+ _refreshList() {
219
+ const list = {};
220
+ this._zip.forEach(function (relativePath, item) {
221
+ if (relativePath.startsWith('/')) {
222
+ relativePath = relativePath.slice(1);
223
+ }
224
+ let parentPath = '/';
225
+ let name = '';
226
+ let s;
227
+ if (item.dir) {
228
+ s = relativePath.slice(0, -1).lastIndexOf('/');
229
+ }
230
+ else {
231
+ s = relativePath.lastIndexOf('/');
232
+ }
233
+ if (s !== -1) {
234
+ parentPath = '/' + relativePath.slice(0, s + 1);
235
+ name = relativePath.slice(s + 1);
236
+ }
237
+ else {
238
+ name = relativePath;
239
+ }
240
+ if (item.dir) {
241
+ name = name.slice(0, -1);
242
+ }
243
+ if (!list[parentPath]) {
244
+ list[parentPath] = {};
245
+ }
246
+ list[parentPath][name] = {
247
+ 'name': name,
248
+ 'date': item.date,
249
+ 'isFile': !item.dir,
250
+ 'isDirectory': item.dir,
251
+ 'path': parentPath
252
+ };
253
+ });
254
+ this._list = list;
255
+ }
256
+ pwd() {
257
+ return this._path.slice(0, -1);
258
+ }
259
+ cd(dir) {
260
+ this._path = tool.urlResolve(this._path, dir);
261
+ if (!this._path.endsWith('/')) {
262
+ this._path += '/';
263
+ }
264
+ return this._path;
265
+ }
266
+ generate(options = {}) {
267
+ const opt = {};
268
+ if (options.type === undefined) {
269
+ opt.type = 'blob';
270
+ }
271
+ else {
272
+ opt.type = options.type;
273
+ }
274
+ if (options.level === undefined) {
275
+ options.level = 9;
276
+ }
277
+ else if (options.level > 9) {
278
+ options.level = 9;
279
+ }
280
+ if (options.level > 0) {
281
+ opt.compression = 'DEFLATE';
282
+ }
283
+ return this._zip.generateAsync(opt, function (meta) {
284
+ var _a;
285
+ (_a = options.onUpdate) === null || _a === void 0 ? void 0 : _a.call(options, meta.percent, meta.currentFile);
286
+ });
287
+ }
288
+ getList() {
289
+ return new Promise((resolve) => {
290
+ const files = {};
291
+ const list = this.readDir('/', {
292
+ 'hasChildren': true,
293
+ 'hasDir': false
294
+ });
295
+ let loaded = 0;
296
+ for (const file of list) {
297
+ const mime = tool.getMimeByPath(file.name);
298
+ if (['txt', 'json', 'js', 'css', 'xml', 'html'].includes(mime.ext)) {
299
+ this.getContent(file.path + file.name, 'string').then(function (fb) {
300
+ if (fb) {
301
+ files[file.path + file.name] = fb;
302
+ }
303
+ ++loaded;
304
+ if (loaded === list.length) {
305
+ resolve(files);
306
+ }
307
+ }).catch(function () {
308
+ ++loaded;
309
+ if (loaded === list.length) {
310
+ resolve(files);
311
+ }
312
+ });
313
+ }
314
+ else {
315
+ this.getContent(file.path + file.name, 'arraybuffer').then(function (fb) {
316
+ if (fb) {
317
+ files[file.path + file.name] = new Blob([fb], {
318
+ 'type': mime.mime
319
+ });
320
+ }
321
+ ++loaded;
322
+ if (loaded === list.length) {
323
+ resolve(files);
324
+ }
325
+ }).catch(function () {
326
+ ++loaded;
327
+ if (loaded === list.length) {
328
+ resolve(files);
329
+ }
330
+ });
331
+ }
332
+ }
333
+ return files;
334
+ });
335
+ }
336
+ }
337
+ exports.Zip = Zip;
338
+ function get(data) {
339
+ return __awaiter(this, void 0, void 0, function* () {
340
+ const z = jszip();
341
+ try {
342
+ if (data) {
343
+ yield z.loadAsync(data);
344
+ }
345
+ return new Zip(z);
346
+ }
347
+ catch (_a) {
348
+ return null;
349
+ }
350
+ });
351
+ }
352
+ exports.get = get;