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,501 @@
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.execCommand = exports.blob2DataUrl = exports.blob2Text = exports.urlResolve = exports.parseUrl = exports.request = exports.escapeHTML = exports.getBoolean = exports.random = exports.RANDOM_LUNS = exports.RANDOM_V = exports.RANDOM_LUN = exports.RANDOM_LU = exports.RANDOM_LN = exports.RANDOM_UN = exports.RANDOM_L = exports.RANDOM_U = exports.RANDOM_N = exports.rand = exports.getObjectURLs = exports.revokeObjectURL = exports.createObjectURL = exports.getMimeByPath = exports.stylePrepend = exports.eventsAttrWrap = exports.layoutClassPrepend = exports.layoutInsertAttr = exports.layoutAddTagClassAndReTagName = exports.styleUrl2DataUrl = exports.purify = exports.sleep = exports.clone = exports.blob2ArrayBuffer = void 0;
13
+ const task = require("./task");
14
+ function blob2ArrayBuffer(blob) {
15
+ return new Promise(function (resove) {
16
+ const fr = new FileReader();
17
+ fr.addEventListener('load', function () {
18
+ resove(fr.result);
19
+ });
20
+ fr.readAsArrayBuffer(blob);
21
+ });
22
+ }
23
+ exports.blob2ArrayBuffer = blob2ArrayBuffer;
24
+ function clone(obj) {
25
+ let newObj = {};
26
+ if (obj instanceof Array) {
27
+ newObj = [];
28
+ for (let i = 0; i < obj.length; ++i) {
29
+ newObj[i] = typeof obj[i] === 'object' ? clone(obj[i]) : obj[i];
30
+ }
31
+ }
32
+ else {
33
+ for (const key in obj) {
34
+ newObj[key] = typeof obj[key] === 'object' ? clone(obj[key]) : obj[key];
35
+ }
36
+ }
37
+ return newObj;
38
+ }
39
+ exports.clone = clone;
40
+ function sleep(ms = 0) {
41
+ return new Promise(function (resolve) {
42
+ if (ms > 1000 * 3) {
43
+ resolve(false);
44
+ return;
45
+ }
46
+ window.setTimeout(function () {
47
+ resolve(true);
48
+ }, ms);
49
+ });
50
+ }
51
+ exports.sleep = sleep;
52
+ function purify(text) {
53
+ text = '>' + text + '<';
54
+ text = text.replace(/<!--([\s\S]*?)-->/g, '').replace(/>([\s\S]*?)</g, function (t, t1) {
55
+ return '>' + t1.replace(/\t|\r\n| {2}/g, '').replace(/\n|\r/g, '') + '<';
56
+ });
57
+ return text.slice(1, -1);
58
+ }
59
+ exports.purify = purify;
60
+ function styleUrl2DataUrl(path, style, files) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ const reg = /url\(["']{0,1}(.+?)["']{0,1}\)/ig;
63
+ let match = null;
64
+ while ((match = reg.exec(style))) {
65
+ let realPath = urlResolve(path, match[1]);
66
+ if (realPath.startsWith('/package/')) {
67
+ realPath = realPath.slice(8);
68
+ }
69
+ if (!files[realPath]) {
70
+ continue;
71
+ }
72
+ if (typeof files[realPath] !== 'string') {
73
+ style = style.replace(match[0], `url('${yield blob2DataUrl(files[realPath])}')`);
74
+ }
75
+ }
76
+ return style;
77
+ });
78
+ }
79
+ exports.styleUrl2DataUrl = styleUrl2DataUrl;
80
+ function layoutAddTagClassAndReTagName(layout, retagname) {
81
+ const list = [];
82
+ layout = layout.replace(/(\S+)=(".+?"|'.+?')/g, function (t, t1) {
83
+ if (t1 === 'class') {
84
+ return t;
85
+ }
86
+ list.push(t);
87
+ return '"CG-PLACEHOLDER"';
88
+ });
89
+ layout = layout.replace(/<(\/{0,1})([\w-]+)([\s\S]*?>)/g, function (t, t1, t2, t3) {
90
+ if (['template', 'slot', 'teleport'].includes(t2)) {
91
+ return t;
92
+ }
93
+ else {
94
+ if (t1 === '/') {
95
+ if (t2 === 'block') {
96
+ return '</div' + t3;
97
+ }
98
+ else {
99
+ return retagname ? ('</cg-' + t2 + t3) : t;
100
+ }
101
+ }
102
+ if (t3.toLowerCase().includes(' class')) {
103
+ t3 = t3.replace(/ class=(["']{0,1})/i, ' class=$1tag-' + t2 + ' ');
104
+ }
105
+ else {
106
+ t3 = ` class="tag-${t2}"` + t3;
107
+ }
108
+ if (t2 === 'block') {
109
+ return '<div' + t3;
110
+ }
111
+ else {
112
+ return retagname ? ('<cg-' + t2 + t3) : ('<' + t2 + t3);
113
+ }
114
+ }
115
+ });
116
+ let i = -1;
117
+ return layout.replace(/"CG-PLACEHOLDER"/g, function () {
118
+ return list[++i];
119
+ });
120
+ }
121
+ exports.layoutAddTagClassAndReTagName = layoutAddTagClassAndReTagName;
122
+ function layoutInsertAttr(layout, insert, opt = {}) {
123
+ return layout.replace(/<([\w-]+)[\s\S]*?>/g, function (t, t1) {
124
+ if (opt.ignore) {
125
+ for (const item of opt.ignore) {
126
+ if (item.test(t1)) {
127
+ return t;
128
+ }
129
+ }
130
+ }
131
+ if (opt.include) {
132
+ let found = false;
133
+ for (const item of opt.include) {
134
+ if (item.test(t1)) {
135
+ found = true;
136
+ break;
137
+ }
138
+ }
139
+ if (!found) {
140
+ return t;
141
+ }
142
+ }
143
+ return t.replace(/<[\w-]+/, function (t) {
144
+ return t + ' ' + insert;
145
+ });
146
+ });
147
+ }
148
+ exports.layoutInsertAttr = layoutInsertAttr;
149
+ function layoutClassPrependObject(object) {
150
+ object = object.slice(1, -1).trim();
151
+ return '{' + object.replace(/(.+?):(.+?)(,|$)/g, function (t, t1, t2, t3) {
152
+ t1 = t1.trim();
153
+ if (t1.startsWith('[')) {
154
+ t1 = '[cgClassPrepend(' + t1.slice(1, -1) + ')]';
155
+ }
156
+ else {
157
+ let sp = '';
158
+ if (t1.startsWith('\'') || t1.startsWith('"')) {
159
+ sp = t1[0];
160
+ t1 = t1.slice(1, -1);
161
+ }
162
+ t1 = `[cgClassPrepend(${sp}${t1}${sp})]`;
163
+ }
164
+ return t1 + ':' + t2 + t3;
165
+ }) + '}';
166
+ }
167
+ function layoutClassPrepend(layout, preps) {
168
+ return layout.replace(/ class=["'](.+?)["']/gi, function (t, t1) {
169
+ t1 = t1.trim();
170
+ const classList = t1.split(' ');
171
+ const resultList = [];
172
+ for (const item of classList) {
173
+ for (const prep of preps) {
174
+ resultList.push(prep + item);
175
+ }
176
+ }
177
+ return ` class='${resultList.join(' ')}'`;
178
+ }).replace(/ :class=(["']).+?>/gi, function (t, sp) {
179
+ return t.replace(new RegExp(` :class=${sp}(.+?)${sp}`, 'gi'), function (t, t1) {
180
+ t1 = t1.trim();
181
+ if (t1.startsWith('[')) {
182
+ t1 = t1.slice(1, -1);
183
+ const t1a = t1.split(',');
184
+ for (let i = 0; i < t1a.length; ++i) {
185
+ t1a[i] = t1a[i].trim();
186
+ if (t1a[i].startsWith('{')) {
187
+ t1a[i] = layoutClassPrependObject(t1a[i]);
188
+ }
189
+ else {
190
+ t1a[i] = 'cgClassPrepend(' + t1a[i] + ')';
191
+ }
192
+ }
193
+ t1 = '[' + t1a.join(',') + ']';
194
+ }
195
+ else {
196
+ t1 = layoutClassPrependObject(t1);
197
+ }
198
+ return ` :class="${t1}"`;
199
+ });
200
+ });
201
+ }
202
+ exports.layoutClassPrepend = layoutClassPrepend;
203
+ function eventsAttrWrap(layout) {
204
+ const events = ['click', 'dblclick', 'mousedown', 'mouseenter', 'mouseleave', 'mouseup', 'touchstart', 'touchmove', 'touchend', 'keydown', 'keypress', 'keyup', 'contextmenu'];
205
+ const reg = new RegExp(`@(${events.join('|')})="(.+?)"`, 'g');
206
+ return layout.replace(reg, function (t, t1, t2) {
207
+ if (/^[\w]+$/.test(t2)) {
208
+ return `@${t1}="cgAllowEvent($event) && ${t2}($event)"`;
209
+ }
210
+ return `@${t1}=";if(cgAllowEvent($event)){${t2}}"`;
211
+ });
212
+ }
213
+ exports.eventsAttrWrap = eventsAttrWrap;
214
+ function stylePrepend(style, prep = '') {
215
+ if (prep === '') {
216
+ prep = 'cg-scope' + Math.round(Math.random() * 1000000000000000).toString() + '_';
217
+ }
218
+ style = style.replace(/([\s\S]+?){([\s\S]+?)}/g, function (t, t1, t2) {
219
+ t1 = t1.replace(/(^|[ >,\r\n])([a-zA-Z-_][a-zA-Z0-9-_]*)/g, function (t, t1, t2) {
220
+ if (t2 === 'global') {
221
+ return '[CGTMP-GLOBAL]';
222
+ }
223
+ return t1 + '.tag-' + t2;
224
+ });
225
+ t1 = t1.replace(/keyframes \.tag-([a-zA-Z0-9-_]+)/g, function (t, t1) {
226
+ return 'keyframes ' + t1;
227
+ });
228
+ t1 = t1.replace(/([.#])([a-zA-Z0-9-_]+)/g, function (t, t1, t2) {
229
+ return t1 + prep + t2;
230
+ }) + '{' + t2 + '}';
231
+ return t1;
232
+ });
233
+ const fontList = [];
234
+ style = style.replace(/(@font-face[\s\S]+?font-family\s*:\s*["']{0,1})(.+?)(["']{0,1}\s*[;\r\n }])/gi, function (t, t1, t2, t3) {
235
+ fontList.push(t2);
236
+ return t1 + prep + t2 + t3;
237
+ });
238
+ for (const font of fontList) {
239
+ const reg = new RegExp(`(font.+?[: "'])(${font})`, 'gi');
240
+ style = style.replace(reg, function (t, t1, t2) {
241
+ return t1 + prep + t2;
242
+ });
243
+ }
244
+ const keyframeList = [];
245
+ style = style.replace(/([-@]keyframes *["']{0,1})([\w-]+)(["']{0,1}\s*?\{)/gi, function (t, t1, t2, t3) {
246
+ if (!keyframeList.includes(t2)) {
247
+ keyframeList.push(t2);
248
+ }
249
+ return t1 + prep + t2 + t3;
250
+ });
251
+ for (const keyframe of keyframeList) {
252
+ const reg = new RegExp(`(animation[ :\\r\\n]+)(${keyframe})([ ;}\\r\\n])`, 'gi');
253
+ style = style.replace(reg, function (t, t1, t2, t3) {
254
+ return t1 + prep + t2 + t3;
255
+ });
256
+ }
257
+ return {
258
+ 'prep': prep,
259
+ 'style': style
260
+ };
261
+ }
262
+ exports.stylePrepend = stylePrepend;
263
+ function getMimeByPath(path) {
264
+ var _a;
265
+ const lio = path.lastIndexOf('.');
266
+ const ext = (lio === -1 ? path : path.slice(lio + 1)).toLowerCase();
267
+ const exts = {
268
+ 'eot': 'application/vnd.ms-fontobject',
269
+ 'woff': 'font/woff',
270
+ 'ttf': 'font/ttf',
271
+ 'svg': 'image/svg+xml',
272
+ 'jpg': 'image/jpeg',
273
+ 'jpeg': 'image/jpeg',
274
+ 'gif': 'image/gif',
275
+ 'png': 'image/png'
276
+ };
277
+ const mime = (_a = exts[ext]) !== null && _a !== void 0 ? _a : 'application/octet-stream';
278
+ return {
279
+ 'mime': mime,
280
+ 'ext': ext
281
+ };
282
+ }
283
+ exports.getMimeByPath = getMimeByPath;
284
+ const objectURLs = [];
285
+ function createObjectURL(object, taskId = 0) {
286
+ let t = null;
287
+ if (taskId > 0) {
288
+ t = task.list[taskId];
289
+ if (!t) {
290
+ return '';
291
+ }
292
+ }
293
+ const url = URL.createObjectURL(object);
294
+ objectURLs.push(url);
295
+ if (t) {
296
+ t.objectURLs.push(url);
297
+ }
298
+ return url;
299
+ }
300
+ exports.createObjectURL = createObjectURL;
301
+ function revokeObjectURL(url, taskId = 0) {
302
+ const oio = objectURLs.indexOf(url);
303
+ if (oio === -1) {
304
+ return;
305
+ }
306
+ if (taskId > 0) {
307
+ const t = task.list[taskId];
308
+ if (!t) {
309
+ return;
310
+ }
311
+ const io = t.objectURLs.indexOf(url);
312
+ if (io === -1) {
313
+ return;
314
+ }
315
+ t.objectURLs.splice(io, 1);
316
+ }
317
+ objectURLs.splice(oio, 1);
318
+ URL.revokeObjectURL(url);
319
+ }
320
+ exports.revokeObjectURL = revokeObjectURL;
321
+ function getObjectURLs() {
322
+ return objectURLs;
323
+ }
324
+ exports.getObjectURLs = getObjectURLs;
325
+ function rand(min, max) {
326
+ if (min > max) {
327
+ [min, max] = [max, min];
328
+ }
329
+ return min + Math.round(Math.random() * (max - min));
330
+ }
331
+ exports.rand = rand;
332
+ exports.RANDOM_N = '0123456789';
333
+ exports.RANDOM_U = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
334
+ exports.RANDOM_L = 'abcdefghijklmnopqrstuvwxyz';
335
+ exports.RANDOM_UN = exports.RANDOM_U + exports.RANDOM_N;
336
+ exports.RANDOM_LN = exports.RANDOM_L + exports.RANDOM_N;
337
+ exports.RANDOM_LU = exports.RANDOM_L + exports.RANDOM_U;
338
+ exports.RANDOM_LUN = exports.RANDOM_L + exports.RANDOM_U + exports.RANDOM_N;
339
+ exports.RANDOM_V = 'ACEFGHJKLMNPRSTWXY34567';
340
+ exports.RANDOM_LUNS = exports.RANDOM_LUN + '()`~!@#$%^&*-+=_|{}[]:;\'<>,.?/]';
341
+ function random(length = 8, source = exports.RANDOM_LN, block = '') {
342
+ let len = block.length;
343
+ if (len > 0) {
344
+ for (let i = 0; i < len; ++i) {
345
+ source = source.replace(block[i], '');
346
+ }
347
+ }
348
+ len = source.length;
349
+ if (len === 0) {
350
+ return '';
351
+ }
352
+ let temp = '';
353
+ for (let i = 0; i < length; ++i) {
354
+ temp += source[rand(0, len - 1)];
355
+ }
356
+ return temp;
357
+ }
358
+ exports.random = random;
359
+ function getBoolean(param) {
360
+ const t = typeof param;
361
+ if (t === 'boolean') {
362
+ return param;
363
+ }
364
+ else if (t === 'string') {
365
+ return param === 'false' ? false : true;
366
+ }
367
+ else {
368
+ return param ? true : false;
369
+ }
370
+ }
371
+ exports.getBoolean = getBoolean;
372
+ function escapeHTML(html) {
373
+ return html.replace(/</g, '&lt;').replace(/>/g, '&gt;');
374
+ }
375
+ exports.escapeHTML = escapeHTML;
376
+ function request(url, opt) {
377
+ return new Promise(function (resove) {
378
+ var _a;
379
+ const xhr = new XMLHttpRequest();
380
+ xhr.upload.onloadstart = function (e) {
381
+ var _a;
382
+ const r = (_a = opt.uploadStart) === null || _a === void 0 ? void 0 : _a.call(opt, e.total);
383
+ if (r && (r instanceof Promise)) {
384
+ r.catch(function (e) {
385
+ console.log(e);
386
+ });
387
+ }
388
+ };
389
+ xhr.upload.onprogress = function (e) {
390
+ var _a;
391
+ const r = (_a = opt.uploadProgress) === null || _a === void 0 ? void 0 : _a.call(opt, e.loaded, e.total);
392
+ if (r && (r instanceof Promise)) {
393
+ r.catch(function (e) {
394
+ console.log(e);
395
+ });
396
+ }
397
+ };
398
+ xhr.upload.onloadend = function () {
399
+ var _a;
400
+ const r = (_a = opt.uploadEnd) === null || _a === void 0 ? void 0 : _a.call(opt);
401
+ if (r && (r instanceof Promise)) {
402
+ r.catch(function (e) {
403
+ console.log(e);
404
+ });
405
+ }
406
+ };
407
+ xhr.onloadstart = function (e) {
408
+ var _a;
409
+ const r = (_a = opt.start) === null || _a === void 0 ? void 0 : _a.call(opt, e.total);
410
+ if (r && (r instanceof Promise)) {
411
+ r.catch(function (e) {
412
+ console.log(e);
413
+ });
414
+ }
415
+ };
416
+ xhr.onprogress = function (e) {
417
+ var _a;
418
+ const r = (_a = opt.progress) === null || _a === void 0 ? void 0 : _a.call(opt, e.loaded, e.total);
419
+ if (r && (r instanceof Promise)) {
420
+ r.catch(function (e) {
421
+ console.log(e);
422
+ });
423
+ }
424
+ };
425
+ xhr.onloadend = function () {
426
+ var _a;
427
+ const r = (_a = opt.end) === null || _a === void 0 ? void 0 : _a.call(opt);
428
+ if (r && (r instanceof Promise)) {
429
+ r.catch(function (e) {
430
+ console.log(e);
431
+ });
432
+ }
433
+ };
434
+ xhr.onload = function () {
435
+ var _a, _b;
436
+ let res = this.response;
437
+ if ((_a = this.getResponseHeader('content-type')) === null || _a === void 0 ? void 0 : _a.includes('json')) {
438
+ try {
439
+ res = JSON.parse(res);
440
+ }
441
+ catch (_c) {
442
+ res = this.response;
443
+ }
444
+ }
445
+ const r = (_b = opt.load) === null || _b === void 0 ? void 0 : _b.call(opt, res);
446
+ if (r && (r instanceof Promise)) {
447
+ r.catch(function (e) {
448
+ console.log(e);
449
+ });
450
+ }
451
+ resove(res);
452
+ };
453
+ xhr.onerror = function () {
454
+ var _a;
455
+ const r = (_a = opt.error) === null || _a === void 0 ? void 0 : _a.call(opt);
456
+ if (r && (r instanceof Promise)) {
457
+ r.catch(function (e) {
458
+ console.log(e);
459
+ });
460
+ }
461
+ resove(null);
462
+ };
463
+ if (opt.responseType) {
464
+ xhr.responseType = opt.responseType;
465
+ }
466
+ if (opt.timeout) {
467
+ xhr.timeout = opt.timeout;
468
+ }
469
+ if (opt.headers) {
470
+ for (const k in opt.headers) {
471
+ xhr.setRequestHeader(k, opt.headers[k]);
472
+ }
473
+ }
474
+ xhr.open((_a = opt.method) !== null && _a !== void 0 ? _a : 'GET', url, true);
475
+ xhr.send(opt.body);
476
+ });
477
+ }
478
+ exports.request = request;
479
+ function parseUrl(url) {
480
+ return loader.parseUrl(url);
481
+ }
482
+ exports.parseUrl = parseUrl;
483
+ function urlResolve(from, to) {
484
+ return loader.urlResolve(from, to);
485
+ }
486
+ exports.urlResolve = urlResolve;
487
+ function blob2Text(blob) {
488
+ return loader.blob2Text(blob);
489
+ }
490
+ exports.blob2Text = blob2Text;
491
+ function blob2DataUrl(blob) {
492
+ return loader.blob2DataUrl(blob);
493
+ }
494
+ exports.blob2DataUrl = blob2DataUrl;
495
+ function execCommand(ac) {
496
+ if (!['copy', 'cut'].includes(ac)) {
497
+ return;
498
+ }
499
+ document.execCommand(ac);
500
+ }
501
+ exports.execCommand = execCommand;