clickgo 3.16.27 → 4.0.0

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 (299) hide show
  1. package/README.md +20 -9
  2. package/dist/app/{demo/res/video.mp4 → demo.cga} +0 -0
  3. package/dist/app/task.cga +0 -0
  4. package/dist/control/arteditor.cgc +0 -0
  5. package/dist/control/box.cgc +0 -0
  6. package/dist/control/captcha.cgc +0 -0
  7. package/dist/control/common.cgc +0 -0
  8. package/dist/control/desc.cgc +0 -0
  9. package/dist/control/drawer.cgc +0 -0
  10. package/dist/control/echarts.cgc +0 -0
  11. package/dist/control/form.cgc +0 -0
  12. package/dist/control/iconview.cgc +0 -0
  13. package/dist/control/jodit.cgc +0 -0
  14. package/dist/control/map.cgc +0 -0
  15. package/dist/control/monaco.cgc +0 -0
  16. package/dist/control/mpegts.cgc +0 -0
  17. package/dist/control/nav.cgc +0 -0
  18. package/dist/control/novnc.cgc +0 -0
  19. package/dist/control/page.cgc +0 -0
  20. package/dist/control/pdf.cgc +0 -0
  21. package/dist/control/property.cgc +0 -0
  22. package/dist/control/qrcode.cgc +0 -0
  23. package/dist/control/table.cgc +0 -0
  24. package/dist/control/task.cgc +0 -0
  25. package/dist/control/tplink.cgc +0 -0
  26. package/dist/control/tuieditor.cgc +0 -0
  27. package/dist/control/tuiviewer.cgc +0 -0
  28. package/dist/control/tums.cgc +0 -0
  29. package/dist/control/xterm.cgc +0 -0
  30. package/dist/ext/tums-player/audio.wasm +0 -0
  31. package/dist/ext/tums-player/decoder.worker.js +129 -0
  32. package/dist/ext/tums-player/libaudio.js +1 -0
  33. package/dist/ext/tums-player/libaudio.wasm +0 -0
  34. package/dist/ext/tums-player/libffmpeg.js +1 -0
  35. package/dist/ext/tums-player/libffmpeg.wasm +0 -0
  36. package/dist/ext/tums-player/libs.worker.js +92 -0
  37. package/dist/ext/tums-player/tums-player.umd.min.js +35 -0
  38. package/dist/ext/tums-player/webgl.js +2 -0
  39. package/dist/ext/tums-player/webgl.worker.js +42 -0
  40. package/dist/global.css +1 -1
  41. package/dist/index.js +1 -187
  42. package/dist/theme/dark.cgt +0 -0
  43. package/dist/theme/light.cgt +0 -0
  44. package/package.json +16 -10
  45. package/dist/app/demo/app.js +0 -60
  46. package/dist/app/demo/config.json +0 -249
  47. package/dist/app/demo/form/control/alayout2/alayout2.js +0 -43
  48. package/dist/app/demo/form/control/alayout2/alayout2.xml +0 -16
  49. package/dist/app/demo/form/control/alert/alert.js +0 -43
  50. package/dist/app/demo/form/control/alert/alert.xml +0 -32
  51. package/dist/app/demo/form/control/arteditor/arteditor.js +0 -75
  52. package/dist/app/demo/form/control/arteditor/arteditor.xml +0 -12
  53. package/dist/app/demo/form/control/arteditor/img.js +0 -61
  54. package/dist/app/demo/form/control/arteditor/img.xml +0 -6
  55. package/dist/app/demo/form/control/block/block.css +0 -1
  56. package/dist/app/demo/form/control/block/block.scss +0 -17
  57. package/dist/app/demo/form/control/block/block.xml +0 -7
  58. package/dist/app/demo/form/control/box/box.js +0 -87
  59. package/dist/app/demo/form/control/box/box.xml +0 -23
  60. package/dist/app/demo/form/control/button/button.css +0 -1
  61. package/dist/app/demo/form/control/button/button.js +0 -62
  62. package/dist/app/demo/form/control/button/button.scss +0 -18
  63. package/dist/app/demo/form/control/button/button.xml +0 -133
  64. package/dist/app/demo/form/control/calendar/calendar.js +0 -62
  65. package/dist/app/demo/form/control/calendar/calendar.xml +0 -34
  66. package/dist/app/demo/form/control/captcha/captcha.js +0 -60
  67. package/dist/app/demo/form/control/captcha/captcha.xml +0 -10
  68. package/dist/app/demo/form/control/check/check.js +0 -65
  69. package/dist/app/demo/form/control/check/check.xml +0 -17
  70. package/dist/app/demo/form/control/circle/circle.xml +0 -36
  71. package/dist/app/demo/form/control/content/content.js +0 -58
  72. package/dist/app/demo/form/control/content/content.xml +0 -16
  73. package/dist/app/demo/form/control/date/date.js +0 -56
  74. package/dist/app/demo/form/control/date/date.xml +0 -28
  75. package/dist/app/demo/form/control/datepanel/datepanel.js +0 -63
  76. package/dist/app/demo/form/control/datepanel/datepanel.xml +0 -32
  77. package/dist/app/demo/form/control/daterange/daterange.js +0 -54
  78. package/dist/app/demo/form/control/daterange/daterange.xml +0 -22
  79. package/dist/app/demo/form/control/delete/delete.js +0 -58
  80. package/dist/app/demo/form/control/delete/delete.xml +0 -20
  81. package/dist/app/demo/form/control/desc/desc.js +0 -82
  82. package/dist/app/demo/form/control/desc/desc.xml +0 -44
  83. package/dist/app/demo/form/control/dialog/dialog.js +0 -47
  84. package/dist/app/demo/form/control/dialog/dialog.xml +0 -32
  85. package/dist/app/demo/form/control/drawer/drawer.js +0 -45
  86. package/dist/app/demo/form/control/drawer/drawer.xml +0 -34
  87. package/dist/app/demo/form/control/echarts/echarts.js +0 -137
  88. package/dist/app/demo/form/control/echarts/echarts.xml +0 -12
  89. package/dist/app/demo/form/control/empty/empty.js +0 -44
  90. package/dist/app/demo/form/control/empty/empty.xml +0 -9
  91. package/dist/app/demo/form/control/file/file.js +0 -60
  92. package/dist/app/demo/form/control/file/file.xml +0 -25
  93. package/dist/app/demo/form/control/flow/flow.css +0 -1
  94. package/dist/app/demo/form/control/flow/flow.js +0 -97
  95. package/dist/app/demo/form/control/flow/flow.scss +0 -18
  96. package/dist/app/demo/form/control/flow/flow.xml +0 -101
  97. package/dist/app/demo/form/control/form/form.css +0 -1
  98. package/dist/app/demo/form/control/form/form.js +0 -77
  99. package/dist/app/demo/form/control/form/form.scss +0 -5
  100. package/dist/app/demo/form/control/form/form.xml +0 -29
  101. package/dist/app/demo/form/control/grid/grid.js +0 -45
  102. package/dist/app/demo/form/control/grid/grid.xml +0 -27
  103. package/dist/app/demo/form/control/group/group.js +0 -50
  104. package/dist/app/demo/form/control/group/group.xml +0 -46
  105. package/dist/app/demo/form/control/hske/hske.js +0 -44
  106. package/dist/app/demo/form/control/hske/hske.xml +0 -19
  107. package/dist/app/demo/form/control/html/html.js +0 -70
  108. package/dist/app/demo/form/control/html/html.xml +0 -18
  109. package/dist/app/demo/form/control/icon/icon.xml +0 -49
  110. package/dist/app/demo/form/control/iconview/iconview.js +0 -191
  111. package/dist/app/demo/form/control/iconview/iconview.xml +0 -45
  112. package/dist/app/demo/form/control/img/img.xml +0 -26
  113. package/dist/app/demo/form/control/imgviewer/imgviewer.js +0 -46
  114. package/dist/app/demo/form/control/imgviewer/imgviewer.xml +0 -9
  115. package/dist/app/demo/form/control/jodit/jodit.js +0 -75
  116. package/dist/app/demo/form/control/jodit/jodit.xml +0 -24
  117. package/dist/app/demo/form/control/label/label.js +0 -51
  118. package/dist/app/demo/form/control/label/label.xml +0 -34
  119. package/dist/app/demo/form/control/layout/layout.js +0 -45
  120. package/dist/app/demo/form/control/layout/layout.xml +0 -18
  121. package/dist/app/demo/form/control/link/link.js +0 -53
  122. package/dist/app/demo/form/control/link/link.xml +0 -30
  123. package/dist/app/demo/form/control/list/list.css +0 -1
  124. package/dist/app/demo/form/control/list/list.js +0 -394
  125. package/dist/app/demo/form/control/list/list.scss +0 -7
  126. package/dist/app/demo/form/control/list/list.xml +0 -150
  127. package/dist/app/demo/form/control/loading/loading.xml +0 -8
  128. package/dist/app/demo/form/control/map/map.js +0 -217
  129. package/dist/app/demo/form/control/map/map.xml +0 -44
  130. package/dist/app/demo/form/control/marquee/marquee.js +0 -64
  131. package/dist/app/demo/form/control/marquee/marquee.xml +0 -33
  132. package/dist/app/demo/form/control/menu/menu.js +0 -67
  133. package/dist/app/demo/form/control/menu/menu.xml +0 -125
  134. package/dist/app/demo/form/control/monaco/monaco.js +0 -136
  135. package/dist/app/demo/form/control/monaco/monaco.xml +0 -28
  136. package/dist/app/demo/form/control/mpegts/mpegts.js +0 -70
  137. package/dist/app/demo/form/control/mpegts/mpegts.xml +0 -11
  138. package/dist/app/demo/form/control/nav/nav.js +0 -71
  139. package/dist/app/demo/form/control/nav/nav.xml +0 -106
  140. package/dist/app/demo/form/control/page/page.js +0 -51
  141. package/dist/app/demo/form/control/page/page.xml +0 -22
  142. package/dist/app/demo/form/control/palette/palette.js +0 -46
  143. package/dist/app/demo/form/control/palette/palette.xml +0 -16
  144. package/dist/app/demo/form/control/panel/panel.js +0 -117
  145. package/dist/app/demo/form/control/panel/panel.xml +0 -16
  146. package/dist/app/demo/form/control/panel/test1.js +0 -105
  147. package/dist/app/demo/form/control/panel/test1.xml +0 -22
  148. package/dist/app/demo/form/control/panel/test2.xml +0 -4
  149. package/dist/app/demo/form/control/pdf/pdf.js +0 -78
  150. package/dist/app/demo/form/control/pdf/pdf.xml +0 -12
  151. package/dist/app/demo/form/control/pdf/test.pdf +0 -0
  152. package/dist/app/demo/form/control/progress/progress.js +0 -63
  153. package/dist/app/demo/form/control/progress/progress.xml +0 -9
  154. package/dist/app/demo/form/control/property/property.js +0 -166
  155. package/dist/app/demo/form/control/property/property.xml +0 -6
  156. package/dist/app/demo/form/control/qrcode/qrcode.js +0 -45
  157. package/dist/app/demo/form/control/qrcode/qrcode.xml +0 -13
  158. package/dist/app/demo/form/control/radio/radio.js +0 -62
  159. package/dist/app/demo/form/control/radio/radio.xml +0 -15
  160. package/dist/app/demo/form/control/scroll/scroll.js +0 -52
  161. package/dist/app/demo/form/control/scroll/scroll.xml +0 -38
  162. package/dist/app/demo/form/control/select/select.js +0 -286
  163. package/dist/app/demo/form/control/select/select.xml +0 -141
  164. package/dist/app/demo/form/control/setting/setting.xml +0 -11
  165. package/dist/app/demo/form/control/sgroup/sgroup.xml +0 -28
  166. package/dist/app/demo/form/control/step/step.js +0 -61
  167. package/dist/app/demo/form/control/step/step.xml +0 -16
  168. package/dist/app/demo/form/control/svg/svg.js +0 -61
  169. package/dist/app/demo/form/control/svg/svg.xml +0 -24
  170. package/dist/app/demo/form/control/switch/switch.js +0 -64
  171. package/dist/app/demo/form/control/switch/switch.xml +0 -29
  172. package/dist/app/demo/form/control/tab/tab.js +0 -113
  173. package/dist/app/demo/form/control/tab/tab.xml +0 -22
  174. package/dist/app/demo/form/control/table/table.js +0 -233
  175. package/dist/app/demo/form/control/table/table.xml +0 -97
  176. package/dist/app/demo/form/control/tag/tag.js +0 -44
  177. package/dist/app/demo/form/control/tag/tag.xml +0 -52
  178. package/dist/app/demo/form/control/text/text.js +0 -127
  179. package/dist/app/demo/form/control/text/text.xml +0 -70
  180. package/dist/app/demo/form/control/timeline/timeline.js +0 -43
  181. package/dist/app/demo/form/control/timeline/timeline.xml +0 -19
  182. package/dist/app/demo/form/control/tip/tip.js +0 -43
  183. package/dist/app/demo/form/control/tip/tip.xml +0 -42
  184. package/dist/app/demo/form/control/tplink/tplink.js +0 -74
  185. package/dist/app/demo/form/control/tplink/tplink.xml +0 -13
  186. package/dist/app/demo/form/control/tuieditor/tuieditor.js +0 -73
  187. package/dist/app/demo/form/control/tuieditor/tuieditor.xml +0 -22
  188. package/dist/app/demo/form/control/tuiviewer/tuiviewer.js +0 -45
  189. package/dist/app/demo/form/control/tuiviewer/tuiviewer.xml +0 -14
  190. package/dist/app/demo/form/control/uploader/uploader.js +0 -91
  191. package/dist/app/demo/form/control/uploader/uploader.xml +0 -15
  192. package/dist/app/demo/form/control/vflow/vflow.css +0 -1
  193. package/dist/app/demo/form/control/vflow/vflow.js +0 -112
  194. package/dist/app/demo/form/control/vflow/vflow.scss +0 -22
  195. package/dist/app/demo/form/control/vflow/vflow.xml +0 -89
  196. package/dist/app/demo/form/control/video/video.js +0 -47
  197. package/dist/app/demo/form/control/video/video.xml +0 -14
  198. package/dist/app/demo/form/control/web/web.js +0 -43
  199. package/dist/app/demo/form/control/web/web.xml +0 -4
  200. package/dist/app/demo/form/control/xterm/xterm.js +0 -100
  201. package/dist/app/demo/form/control/xterm/xterm.xml +0 -6
  202. package/dist/app/demo/form/event/form/form.css +0 -1
  203. package/dist/app/demo/form/event/form/form.js +0 -180
  204. package/dist/app/demo/form/event/form/form.scss +0 -24
  205. package/dist/app/demo/form/event/form/form.xml +0 -16
  206. package/dist/app/demo/form/event/other/other.js +0 -78
  207. package/dist/app/demo/form/event/other/other.xml +0 -5
  208. package/dist/app/demo/form/event/screen/screen.js +0 -86
  209. package/dist/app/demo/form/event/screen/screen.xml +0 -9
  210. package/dist/app/demo/form/event/task/task.js +0 -111
  211. package/dist/app/demo/form/event/task/task.xml +0 -20
  212. package/dist/app/demo/form/main.css +0 -1
  213. package/dist/app/demo/form/main.js +0 -521
  214. package/dist/app/demo/form/main.scss +0 -9
  215. package/dist/app/demo/form/main.xml +0 -160
  216. package/dist/app/demo/form/method/acontrol/acontrol.js +0 -53
  217. package/dist/app/demo/form/method/acontrol/acontrol.xml +0 -5
  218. package/dist/app/demo/form/method/aform/aform.js +0 -123
  219. package/dist/app/demo/form/method/aform/aform.xml +0 -60
  220. package/dist/app/demo/form/method/aform/sd.js +0 -58
  221. package/dist/app/demo/form/method/aform/sd.xml +0 -7
  222. package/dist/app/demo/form/method/core/core.js +0 -111
  223. package/dist/app/demo/form/method/core/core.xml +0 -23
  224. package/dist/app/demo/form/method/dom/dom.css +0 -1
  225. package/dist/app/demo/form/method/dom/dom.js +0 -251
  226. package/dist/app/demo/form/method/dom/dom.scss +0 -10
  227. package/dist/app/demo/form/method/dom/dom.xml +0 -76
  228. package/dist/app/demo/form/method/form/form.js +0 -287
  229. package/dist/app/demo/form/method/form/form.xml +0 -74
  230. package/dist/app/demo/form/method/form/test.xml +0 -5
  231. package/dist/app/demo/form/method/fs/fs.js +0 -230
  232. package/dist/app/demo/form/method/fs/fs.xml +0 -18
  233. package/dist/app/demo/form/method/fs/text.js +0 -48
  234. package/dist/app/demo/form/method/fs/text.xml +0 -3
  235. package/dist/app/demo/form/method/native/native.js +0 -128
  236. package/dist/app/demo/form/method/native/native.xml +0 -22
  237. package/dist/app/demo/form/method/storage/storage.js +0 -95
  238. package/dist/app/demo/form/method/storage/storage.xml +0 -18
  239. package/dist/app/demo/form/method/system/system.js +0 -88
  240. package/dist/app/demo/form/method/system/system.xml +0 -14
  241. package/dist/app/demo/form/method/task/locale1.json +0 -3
  242. package/dist/app/demo/form/method/task/locale2.json +0 -3
  243. package/dist/app/demo/form/method/task/task.js +0 -196
  244. package/dist/app/demo/form/method/task/task.xml +0 -61
  245. package/dist/app/demo/form/method/theme/theme.js +0 -107
  246. package/dist/app/demo/form/method/theme/theme.xml +0 -12
  247. package/dist/app/demo/form/method/tool/tool.js +0 -143
  248. package/dist/app/demo/form/method/tool/tool.xml +0 -40
  249. package/dist/app/demo/form/method/zip/zip.js +0 -137
  250. package/dist/app/demo/form/method/zip/zip.xml +0 -12
  251. package/dist/app/demo/form/solution/backpanel/backpanel.js +0 -89
  252. package/dist/app/demo/form/solution/backpanel/backpanel.xml +0 -31
  253. package/dist/app/demo/global.css +0 -3
  254. package/dist/app/demo/res/custombtn.cgc +0 -0
  255. package/dist/app/demo/res/icon.svg +0 -5
  256. package/dist/app/demo/res/img.jpg +0 -0
  257. package/dist/app/demo/res/marker.svg +0 -5
  258. package/dist/app/demo/res/r-1.svg +0 -32
  259. package/dist/app/demo/res/r-2.svg +0 -38
  260. package/dist/app/demo/res/sql.svg +0 -25
  261. package/dist/app/demo/res/txt.svg +0 -21
  262. package/dist/app/demo/res/zip.svg +0 -21
  263. package/dist/app/task/app.js +0 -57
  264. package/dist/app/task/config.json +0 -29
  265. package/dist/app/task/form/bar/bar.js +0 -419
  266. package/dist/app/task/form/bar/bar.xml +0 -46
  267. package/dist/app/task/form/desktop/desktop.xml +0 -1
  268. package/dist/app/task/locale/en.json +0 -11
  269. package/dist/app/task/locale/ja.json +0 -11
  270. package/dist/app/task/locale/sc.json +0 -11
  271. package/dist/app/task/locale/tc.json +0 -11
  272. package/dist/clickgo.d.ts +0 -22
  273. package/dist/clickgo.js +0 -109
  274. package/dist/index.d.ts +0 -55
  275. package/dist/lib/control.d.ts +0 -53
  276. package/dist/lib/control.js +0 -606
  277. package/dist/lib/core.d.ts +0 -47
  278. package/dist/lib/core.js +0 -1028
  279. package/dist/lib/dom.d.ts +0 -75
  280. package/dist/lib/dom.js +0 -2176
  281. package/dist/lib/form.d.ts +0 -222
  282. package/dist/lib/form.js +0 -3033
  283. package/dist/lib/fs.d.ts +0 -35
  284. package/dist/lib/fs.js +0 -1241
  285. package/dist/lib/native.d.ts +0 -43
  286. package/dist/lib/native.js +0 -228
  287. package/dist/lib/storage.d.ts +0 -6
  288. package/dist/lib/storage.js +0 -227
  289. package/dist/lib/task.d.ts +0 -32
  290. package/dist/lib/task.js +0 -1875
  291. package/dist/lib/theme.d.ts +0 -8
  292. package/dist/lib/theme.js +0 -195
  293. package/dist/lib/tool.d.ts +0 -122
  294. package/dist/lib/tool.js +0 -1054
  295. package/dist/lib/zip.d.ts +0 -40
  296. package/dist/lib/zip.js +0 -397
  297. package/dist/theme/blue.cgt +0 -0
  298. package/dist/theme/byterun.cgt +0 -0
  299. package/types/index.d.ts +0 -1374
package/dist/lib/tool.js DELETED
@@ -1,1054 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- 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 = void 0;
46
- exports.compressor = compressor;
47
- exports.getClassPrototype = getClassPrototype;
48
- exports.blob2ArrayBuffer = blob2ArrayBuffer;
49
- exports.sizeFormat = sizeFormat;
50
- exports.weightFormat = weightFormat;
51
- exports.clone = clone;
52
- exports.sleep = sleep;
53
- exports.nextFrame = nextFrame;
54
- exports.sleepFrame = sleepFrame;
55
- exports.purify = purify;
56
- exports.match = match;
57
- exports.styleUrl2DataUrl = styleUrl2DataUrl;
58
- exports.layoutAddTagClassAndReTagName = layoutAddTagClassAndReTagName;
59
- exports.layoutInsertAttr = layoutInsertAttr;
60
- exports.layoutClassPrepend = layoutClassPrepend;
61
- exports.eventsAttrWrap = eventsAttrWrap;
62
- exports.teleportGlue = teleportGlue;
63
- exports.stylePrepend = stylePrepend;
64
- exports.getMimeByPath = getMimeByPath;
65
- exports.rand = rand;
66
- exports.random = random;
67
- exports.getBoolean = getBoolean;
68
- exports.getNumber = getNumber;
69
- exports.getArray = getArray;
70
- exports.escapeHTML = escapeHTML;
71
- exports.formatColor = formatColor;
72
- exports.rgb2hex = rgb2hex;
73
- exports.hex2rgb = hex2rgb;
74
- exports.rgb2hsl = rgb2hsl;
75
- exports.hsl2rgb = hsl2rgb;
76
- exports.request = request;
77
- exports.fetch = fetch;
78
- exports.get = get;
79
- exports.post = post;
80
- exports.getResponseJson = getResponseJson;
81
- exports.postResponseJson = postResponseJson;
82
- exports.parseUrl = parseUrl;
83
- exports.urlResolve = urlResolve;
84
- exports.urlAtom = urlAtom;
85
- exports.blob2Text = blob2Text;
86
- exports.blob2DataUrl = blob2DataUrl;
87
- exports.execCommand = execCommand;
88
- exports.compar = compar;
89
- exports.formatSecond = formatSecond;
90
- exports.formatTime = formatTime;
91
- exports.isMs = isMs;
92
- exports.queryStringify = queryStringify;
93
- exports.queryParse = queryParse;
94
- exports.isEscaped = isEscaped;
95
- exports.parseArrayString = parseArrayString;
96
- const core = __importStar(require("./core"));
97
- let compressorjs = null;
98
- function compressor(file_1) {
99
- return __awaiter(this, arguments, void 0, function* (file, options = {}) {
100
- if (!compressorjs) {
101
- try {
102
- compressorjs = yield core.getModule('compressorjs');
103
- }
104
- catch (_a) {
105
- return false;
106
- }
107
- }
108
- return new Promise((resolve) => {
109
- new compressorjs(file, {
110
- 'quality': options.quality,
111
- 'maxWidth': options.maxWidth,
112
- 'maxHeight': options.maxHeight,
113
- success: (result) => {
114
- resolve(result);
115
- },
116
- error: () => {
117
- resolve(false);
118
- }
119
- });
120
- });
121
- });
122
- }
123
- function getClassPrototype(obj, over = [], level = 0) {
124
- var _a;
125
- if (level === 0) {
126
- return getClassPrototype(Object.getPrototypeOf(obj), over, level + 1);
127
- }
128
- const rtn = {
129
- 'method': {},
130
- 'access': {}
131
- };
132
- const names = Object.getOwnPropertyNames(obj);
133
- if (names.includes('toString')) {
134
- return rtn;
135
- }
136
- for (const item of names) {
137
- if (item === 'constructor') {
138
- continue;
139
- }
140
- if (over.includes(item)) {
141
- continue;
142
- }
143
- const des = Object.getOwnPropertyDescriptor(obj, item);
144
- if (!des) {
145
- continue;
146
- }
147
- over.push(item);
148
- if (des.value) {
149
- rtn.method[item] = des.value;
150
- }
151
- else if ((_a = des.get) !== null && _a !== void 0 ? _a : des.set) {
152
- if (!rtn.access[item]) {
153
- rtn.access[item] = {};
154
- }
155
- if (des.get) {
156
- rtn.access[item].get = des.get;
157
- }
158
- if (des.set) {
159
- rtn.access[item].set = des.set;
160
- }
161
- }
162
- }
163
- const rtn2 = getClassPrototype(Object.getPrototypeOf(obj), over, level + 1);
164
- Object.assign(rtn.method, rtn2.method);
165
- Object.assign(rtn.access, rtn2.access);
166
- return rtn;
167
- }
168
- function blob2ArrayBuffer(blob) {
169
- return new Promise(function (resove) {
170
- const fr = new FileReader();
171
- fr.addEventListener('load', function () {
172
- resove(fr.result);
173
- });
174
- fr.readAsArrayBuffer(blob);
175
- });
176
- }
177
- function sizeFormat(size, spliter = ' ') {
178
- const units = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
179
- let i = 0;
180
- for (; i < 6 && size >= 1024.0; ++i) {
181
- size /= 1024.0;
182
- }
183
- return (Math.round(size * 100) / 100).toString() + spliter + units[i];
184
- }
185
- function weightFormat(weight, spliter = ' ') {
186
- const units = ['mg', 'g', 'kg'];
187
- let i = 0;
188
- for (; i < 3 && weight >= 1000; ++i) {
189
- weight /= 1000;
190
- }
191
- return (Math.round(weight * 100) / 100).toString() + spliter + units[i];
192
- }
193
- function clone(obj) {
194
- if (Array.isArray(obj)) {
195
- const newObj = [];
196
- for (let i = 0; i < obj.length; ++i) {
197
- if (obj[i] instanceof Date) {
198
- newObj[i] = new Date(obj[i].getTime());
199
- }
200
- else if (obj[i] instanceof FormData) {
201
- const fd = new FormData();
202
- for (const item of obj[i]) {
203
- fd.append(item[0], item[1]);
204
- }
205
- newObj[i] = fd;
206
- }
207
- else if (obj[i] === null) {
208
- newObj[i] = null;
209
- }
210
- else if (typeof obj[i] === 'object') {
211
- newObj[i] = clone(obj[i]);
212
- }
213
- else {
214
- newObj[i] = obj[i];
215
- }
216
- }
217
- return newObj;
218
- }
219
- const newObj = {};
220
- for (const key in obj) {
221
- if (obj[key] instanceof Date) {
222
- newObj[key] = new Date(obj[key].getTime());
223
- }
224
- else if (obj[key] instanceof FormData) {
225
- const fd = new FormData();
226
- for (const item of obj[key]) {
227
- fd.append(item[0], item[1]);
228
- }
229
- newObj[key] = fd;
230
- }
231
- else if (obj[key] === null) {
232
- newObj[key] = null;
233
- }
234
- else if (typeof obj[key] === 'object') {
235
- newObj[key] = clone(obj[key]);
236
- }
237
- else {
238
- newObj[key] = obj[key];
239
- }
240
- }
241
- return newObj;
242
- }
243
- function sleep(ms = 0) {
244
- return new Promise(function (resolve) {
245
- if (ms > 30000) {
246
- resolve(false);
247
- return;
248
- }
249
- window.setTimeout(function () {
250
- resolve(true);
251
- }, ms);
252
- });
253
- }
254
- function nextFrame() {
255
- return new Promise(function (resolve) {
256
- requestAnimationFrame(() => {
257
- resolve();
258
- });
259
- });
260
- }
261
- function sleepFrame(count) {
262
- return __awaiter(this, void 0, void 0, function* () {
263
- if (count > 10) {
264
- count = 10;
265
- }
266
- for (let i = 0; i < count; ++i) {
267
- yield nextFrame();
268
- }
269
- });
270
- }
271
- function purify(text) {
272
- text = '>' + text + '<';
273
- const scripts = [];
274
- let num = -1;
275
- text = text.replace(/<!--([\s\S]*?)-->/g, '').replace(/<script[\s\S]+?<\/script>/g, function (t) {
276
- scripts.push(t);
277
- return '[SCRIPT]';
278
- }).replace(/>([\s\S]*?)</g, function (t, t1) {
279
- return '>' + t1.replace(/\t|\r\n| {2}/g, '').replace(/\n|\r/g, '') + '<';
280
- }).replace(/\[SCRIPT\]/g, function () {
281
- ++num;
282
- return scripts[num];
283
- });
284
- return text.slice(1, -1);
285
- }
286
- function match(str, regs) {
287
- for (const reg of regs) {
288
- if (reg.test(str)) {
289
- return true;
290
- }
291
- }
292
- return false;
293
- }
294
- function styleUrl2DataUrl(path, style, files) {
295
- return __awaiter(this, void 0, void 0, function* () {
296
- const reg = /url\(["']{0,1}(.+?)["']{0,1}\)/ig;
297
- let match = null;
298
- while ((match = reg.exec(style))) {
299
- let realPath = urlResolve(path, match[1]);
300
- if (realPath.startsWith('/package/')) {
301
- realPath = realPath.slice(8);
302
- }
303
- if (!files[realPath]) {
304
- continue;
305
- }
306
- if (typeof files[realPath] !== 'string') {
307
- style = style.replace(match[0], `url('${yield blob2DataUrl(files[realPath])}')`);
308
- }
309
- }
310
- return style;
311
- });
312
- }
313
- function layoutAddTagClassAndReTagName(layout, retagname) {
314
- const list = [];
315
- layout = layout.replace(/(\S+)=(".+?"|'.+?')/g, function (t, t1) {
316
- if (t1 === 'class') {
317
- return t;
318
- }
319
- list.push(t);
320
- return '"CG-PLACEHOLDER"';
321
- });
322
- layout = layout.replace(/<(\/{0,1})([\w-]+)([\s\S]*?>)/g, function (t, t1, t2, t3) {
323
- if (['template', 'slot', 'teleport'].includes(t2)) {
324
- return t;
325
- }
326
- else {
327
- if (t1 === '/') {
328
- if (t2 === 'block') {
329
- return '</div' + t3;
330
- }
331
- else {
332
- return retagname ? ('</cg-' + t2 + t3) : t;
333
- }
334
- }
335
- if (t3.toLowerCase().includes(' class')) {
336
- t3 = t3.replace(/ class=(["']{0,1})/i, ' class=$1tag-' + t2 + ' ');
337
- }
338
- else {
339
- t3 = ` class="tag-${t2}"` + t3;
340
- }
341
- if (t2 === 'block') {
342
- return '<div' + t3;
343
- }
344
- else {
345
- return retagname ? ('<cg-' + t2 + t3) : ('<' + t2 + t3);
346
- }
347
- }
348
- });
349
- let i = -1;
350
- return layout.replace(/"CG-PLACEHOLDER"/g, function () {
351
- return list[++i];
352
- });
353
- }
354
- function layoutInsertAttr(layout, insert, opt = {}) {
355
- return layout.replace(/<([\w-]+)[\s\S]*?>/g, function (t, t1) {
356
- if (opt.ignore) {
357
- for (const item of opt.ignore) {
358
- if (item.test(t1)) {
359
- return t;
360
- }
361
- }
362
- }
363
- if (opt.include) {
364
- let found = false;
365
- for (const item of opt.include) {
366
- if (item.test(t1)) {
367
- found = true;
368
- break;
369
- }
370
- }
371
- if (!found) {
372
- return t;
373
- }
374
- }
375
- return t.replace(/<[\w-]+/, function (t) {
376
- return t + ' ' + insert;
377
- });
378
- });
379
- }
380
- function layoutClassPrependObject(object) {
381
- object = object.slice(1, -1).trim();
382
- return '{' + object.replace(/([ a-zA-Z0-9'"`[\]\-_]+)(\s*:)/g, function (t, t1, t2) {
383
- t1 = t1.trim();
384
- if (t1.startsWith('[')) {
385
- t1 = '[classPrepend(' + t1.slice(1, -1) + ')]';
386
- }
387
- else {
388
- let sp = '';
389
- if (t1.startsWith('\'') || t1.startsWith('"') || t1.startsWith('`')) {
390
- sp = t1[0];
391
- t1 = t1.slice(1, -1);
392
- }
393
- t1 = `[classPrepend(${sp}${t1}${sp})]`;
394
- }
395
- return t1 + t2;
396
- }) + '}';
397
- }
398
- function layoutClassPrepend(layout, preps) {
399
- const rtn = layout.replace(/ class=["'](.+?)["']/gi, function (t, t1) {
400
- t1 = t1.trim();
401
- const classList = t1.split(' ');
402
- const resultList = [];
403
- for (const item of classList) {
404
- for (const prep of preps) {
405
- resultList.push(prep + item);
406
- }
407
- }
408
- return ` class="${resultList.join(' ')}"`;
409
- }).replace(/ :class=(["']).+?["']((\s+[a-zA-Z0-9-_:@]+(=|\s*>))|(\s*)>)/gi, function (t, sp) {
410
- return t.replace(new RegExp(` :class=${sp}(.+?)${sp}((\\s+[a-zA-Z0-9-_:@]+(=|\\s*>))|(\\s*)>)`, 'gi'), function (t, t1, t2) {
411
- t1 = t1.trim();
412
- if (t1.startsWith('[')) {
413
- const t1a = parseArrayString(t1);
414
- for (let i = 0; i < t1a.length; ++i) {
415
- t1a[i] = t1a[i].trim();
416
- if (t1a[i].startsWith('{')) {
417
- t1a[i] = layoutClassPrependObject(t1a[i]);
418
- }
419
- else {
420
- t1a[i] = 'classPrepend(' + t1a[i] + ')';
421
- }
422
- }
423
- t1 = '[' + t1a.join(',') + ']';
424
- }
425
- else {
426
- t1 = layoutClassPrependObject(t1);
427
- }
428
- return ` :class="${t1}"${t2}`;
429
- });
430
- }).replace(/ id=(["'])/gi, ' id=$1' + preps[0]);
431
- return rtn;
432
- }
433
- function eventsAttrWrap(layout) {
434
- const events = ['click', 'dblclick', 'mousedown', 'mouseenter', 'mouseleave', 'mouseup', 'touchstart', 'touchmove', 'touchend', 'keydown', 'keypress', 'keyup', 'contextmenu'];
435
- const reg = new RegExp(`@(${events.join('|')})="(.+?)"`, 'g');
436
- return layout.replace(reg, function (t, t1, t2) {
437
- if (/^[\w]+$/.test(t2)) {
438
- return `@${t1}="allowEvent($event) && ${t2}($event)"`;
439
- }
440
- return `@${t1}=";if(allowEvent($event)){${t2}}"`;
441
- });
442
- }
443
- function teleportGlue(layout, formId) {
444
- if (typeof formId !== 'string') {
445
- formId = formId.toString();
446
- }
447
- const fid = formId;
448
- return layout.replace(/<teleport([\s\S]+?)to="(.+?)"([\s\S]+?<[\w-]+)/g, (v, v1, v2, v3) => {
449
- if (v2 !== 'system') {
450
- return v;
451
- }
452
- return '<teleport' + v1 + 'to="#cg-pop-list > [data-form-id=\'' + fid + '\']"' + v3 + ' data-cg-pop data-cg-pop-none';
453
- });
454
- }
455
- function stylePrepend(style, prep = '') {
456
- if (prep === '') {
457
- prep = 'cg-scope' + Math.round(Math.random() * 1000000000000000).toString() + '_';
458
- }
459
- style = style.replace(/([\s\S]+?){([\s\S]+?)}/g, function (t, t1, t2) {
460
- t1 = t1.replace(/(^|[ >,}\r\n])([a-zA-Z-_][a-zA-Z0-9-_]*)/g, function (t, t1, t2) {
461
- if (t2 === 'global') {
462
- return '[CGTMP-GLOBAL]';
463
- }
464
- return t1 + '.tag-' + t2;
465
- });
466
- t1 = t1.replace(/keyframes \.tag-([a-zA-Z0-9-_]+)/g, function (t, t1) {
467
- return 'keyframes ' + t1;
468
- });
469
- t1 = t1.replace(/([.#])([a-zA-Z0-9-_]+)/g, function (t, t1, t2) {
470
- return t1 + prep + t2;
471
- }) + '{' + t2 + '}';
472
- return t1;
473
- });
474
- const fontList = [];
475
- style = style.replace(/(@font-face[\s\S]+?font-family\s*:\s*["']{0,1})(.+?)(["']{0,1}\s*[;\r\n }])/gi, function (t, t1, t2, t3) {
476
- fontList.push(t2);
477
- return t1 + prep + t2 + t3;
478
- });
479
- for (const font of fontList) {
480
- const reg = new RegExp(`(font.+?[: "'])(${font})`, 'gi');
481
- style = style.replace(reg, function (t, t1, t2) {
482
- return t1 + prep + t2;
483
- });
484
- }
485
- const keyframeList = [];
486
- style = style.replace(/([-@]keyframes *["']{0,1})([\w-]+)(["']{0,1}\s*?\{)/gi, function (t, t1, t2, t3) {
487
- if (!keyframeList.includes(t2)) {
488
- keyframeList.push(t2);
489
- }
490
- return t1 + prep + t2 + t3;
491
- });
492
- for (const keyframe of keyframeList) {
493
- let reg = new RegExp(`(animation[ :\\r\\n]+)(${keyframe})([ ;}\\r\\n])`, 'gi');
494
- style = style.replace(reg, function (t, t1, t2, t3) {
495
- return t1 + prep + t2 + t3;
496
- });
497
- reg = new RegExp(`(animation-name[ :\\r\\n]+)(${keyframe})([ ;}\\r\\n])`, 'gi');
498
- style = style.replace(reg, function (t, t1, t2, t3) {
499
- return t1 + prep + t2 + t3;
500
- });
501
- }
502
- return {
503
- 'prep': prep,
504
- 'style': style
505
- };
506
- }
507
- function getMimeByPath(path) {
508
- var _a;
509
- const lio = path.lastIndexOf('.');
510
- const ext = (lio === -1 ? path : path.slice(lio + 1)).toLowerCase();
511
- const exts = {
512
- 'eot': 'application/vnd.ms-fontobject',
513
- 'woff': 'font/woff',
514
- 'ttf': 'font/ttf',
515
- 'svg': 'image/svg+xml',
516
- 'jpg': 'image/jpeg',
517
- 'jpeg': 'image/jpeg',
518
- 'gif': 'image/gif',
519
- 'png': 'image/png'
520
- };
521
- const mime = (_a = exts[ext]) !== null && _a !== void 0 ? _a : 'application/octet-stream';
522
- return {
523
- 'mime': mime,
524
- 'ext': ext
525
- };
526
- }
527
- function rand(min, max) {
528
- if (min > max) {
529
- [min, max] = [max, min];
530
- }
531
- return min + Math.round(Math.random() * (max - min));
532
- }
533
- exports.RANDOM_N = '0123456789';
534
- exports.RANDOM_U = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
535
- exports.RANDOM_L = 'abcdefghijklmnopqrstuvwxyz';
536
- exports.RANDOM_UN = exports.RANDOM_U + exports.RANDOM_N;
537
- exports.RANDOM_LN = exports.RANDOM_L + exports.RANDOM_N;
538
- exports.RANDOM_LU = exports.RANDOM_L + exports.RANDOM_U;
539
- exports.RANDOM_LUN = exports.RANDOM_L + exports.RANDOM_U + exports.RANDOM_N;
540
- exports.RANDOM_V = 'ACEFGHJKLMNPRSTWXY34567';
541
- exports.RANDOM_LUNS = exports.RANDOM_LUN + '()`~!@#$%^&*-+=_|{}[]:;\'<>,.?/]"';
542
- function random(length = 8, source = exports.RANDOM_LN, block = '') {
543
- let len = block.length;
544
- if (len > 0) {
545
- for (let i = 0; i < len; ++i) {
546
- source = source.replace(block[i], '');
547
- }
548
- }
549
- len = source.length;
550
- if (len === 0) {
551
- return '';
552
- }
553
- let temp = '';
554
- for (let i = 0; i < length; ++i) {
555
- temp += source[rand(0, len - 1)];
556
- }
557
- return temp;
558
- }
559
- function getBoolean(param) {
560
- const t = typeof param;
561
- if (t === 'boolean') {
562
- return param;
563
- }
564
- if (t === 'string') {
565
- return param === 'false' ? false : true;
566
- }
567
- return param ? true : false;
568
- }
569
- function getNumber(param) {
570
- if (typeof param === 'number') {
571
- return param;
572
- }
573
- return parseFloat(param);
574
- }
575
- function getArray(param) {
576
- if (typeof param !== 'string') {
577
- return param;
578
- }
579
- param = param.trim();
580
- let rtn = [];
581
- if (param.startsWith('[')) {
582
- try {
583
- rtn = JSON.parse(param);
584
- }
585
- catch (_a) {
586
- return [];
587
- }
588
- }
589
- else {
590
- param = param.replace(/ /g, '');
591
- rtn = param.split(',');
592
- }
593
- return rtn;
594
- }
595
- function escapeHTML(html) {
596
- return html.replace(/</g, '&lt;').replace(/>/g, '&gt;');
597
- }
598
- function formatColor(color) {
599
- const matc = /[0-9.%, ]+/.exec(color);
600
- if (!matc) {
601
- return [];
602
- }
603
- const arr = matc[0].split(',');
604
- return arr.map((v) => {
605
- return parseFloat(v);
606
- });
607
- }
608
- function rgb2hex(r, g, b, a = 1) {
609
- var _a;
610
- if (g === undefined || b === undefined) {
611
- if (typeof r !== 'string') {
612
- return '';
613
- }
614
- const rgb = formatColor(r);
615
- r = Math.round(rgb[0]);
616
- g = Math.round(rgb[1]);
617
- b = Math.round(rgb[2]);
618
- a = (_a = rgb[3]) !== null && _a !== void 0 ? _a : 1;
619
- }
620
- else {
621
- if (typeof r === 'string') {
622
- r = Math.round(parseFloat(r));
623
- }
624
- if (typeof g === 'string') {
625
- g = Math.round(parseFloat(g));
626
- }
627
- if (typeof b === 'string') {
628
- b = Math.round(parseFloat(b));
629
- }
630
- if (typeof a === 'string') {
631
- a = parseFloat(a);
632
- }
633
- }
634
- return ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0') + (a === 1 ? '' : Math.round(a * 255).toString(16).padStart(2, '0'));
635
- }
636
- function hex2rgb(hex) {
637
- const rgb = {
638
- 'r': 0,
639
- 'g': 0,
640
- 'b': 0,
641
- 'a': 1,
642
- 'rgb': 'rgb'
643
- };
644
- let alpha = false, h = hex.slice(hex.startsWith('#') ? 1 : 0);
645
- if (h.length === 3) {
646
- h = [...h].map(x => x + x).join('');
647
- }
648
- else if (h.length === 8) {
649
- alpha = true;
650
- }
651
- const hn = parseInt(h, 16);
652
- rgb.r = (hn >>> (alpha ? 24 : 16));
653
- rgb.g = (hn & (alpha ? 0x00ff0000 : 0x00ff00)) >>> (alpha ? 16 : 8);
654
- rgb.b = (hn & (alpha ? 0x0000ff00 : 0x0000ff)) >>> (alpha ? 8 : 0);
655
- if (alpha) {
656
- rgb.a = Math.round((hn & 0x000000ff) / 255 * 100) / 1000;
657
- }
658
- rgb.rgb = `${alpha ? 'a' : ''}(${rgb.r},${rgb.g},${rgb.b}${alpha ? ',' + rgb.a : ''})`;
659
- return rgb;
660
- }
661
- function rgb2hsl(r, g, b, a = 1, decimal = false) {
662
- var _a;
663
- const hsl = {
664
- 'h': 0,
665
- 's': 0,
666
- 'l': 0,
667
- 'a': 1,
668
- 'hsl': 'hsl'
669
- };
670
- if (g === undefined || b === undefined) {
671
- if (typeof r !== 'string') {
672
- return hsl;
673
- }
674
- const rgb = formatColor(r);
675
- r = rgb[0];
676
- g = rgb[1];
677
- b = rgb[2];
678
- a = (_a = rgb[3]) !== null && _a !== void 0 ? _a : 1;
679
- }
680
- else {
681
- if (typeof r === 'string') {
682
- r = parseFloat(r);
683
- }
684
- if (typeof g === 'string') {
685
- g = parseFloat(g);
686
- }
687
- if (typeof b === 'string') {
688
- b = parseFloat(b);
689
- }
690
- if (typeof a === 'string') {
691
- a = parseFloat(a);
692
- }
693
- }
694
- r /= 255;
695
- g /= 255;
696
- b /= 255;
697
- const cmin = Math.min(r, g, b), cmax = Math.max(r, g, b), delta = cmax - cmin;
698
- let h = 0, s = 0, l = 0;
699
- if (delta == 0) {
700
- h = 0;
701
- }
702
- else if (cmax == r) {
703
- h = ((g - b) / delta) % 6;
704
- }
705
- else if (cmax == g) {
706
- h = (b - r) / delta + 2;
707
- }
708
- else {
709
- h = (r - g) / delta + 4;
710
- }
711
- h = Math.round(h * 60);
712
- if (h < 0) {
713
- h += 360;
714
- }
715
- l = (cmax + cmin) / 2;
716
- s = delta == 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
717
- s = s * 100;
718
- l = l * 100;
719
- hsl.h = h;
720
- hsl.s = s;
721
- hsl.l = l;
722
- hsl.a = a;
723
- if (!decimal) {
724
- hsl.h = Math.round(hsl.h);
725
- hsl.s = Math.round(hsl.s);
726
- hsl.l = Math.round(hsl.l);
727
- }
728
- hsl.hsl += (hsl.a === 1 ? '' : 'a') + `(${hsl.h},${hsl.s}%,${hsl.l}%${hsl.a === 1 ? '' : ',' + hsl.a})`;
729
- return hsl;
730
- }
731
- function hsl2rgb(h, s, l, a = 1, decimal = false) {
732
- var _a;
733
- const rgb = {
734
- 'r': 0,
735
- 'g': 0,
736
- 'b': 0,
737
- 'a': 1,
738
- 'rgb': 'rgb'
739
- };
740
- if (s === undefined || l === undefined) {
741
- if (typeof h !== 'string') {
742
- return rgb;
743
- }
744
- const hsl = formatColor(h);
745
- h = hsl[0];
746
- s = hsl[1];
747
- l = hsl[2];
748
- a = (_a = hsl[3]) !== null && _a !== void 0 ? _a : 1;
749
- }
750
- else {
751
- if (typeof h === 'string') {
752
- h = parseFloat(h);
753
- }
754
- if (typeof s === 'string') {
755
- s = parseFloat(s);
756
- }
757
- if (typeof l === 'string') {
758
- l = parseFloat(l);
759
- }
760
- if (typeof a === 'string') {
761
- a = parseFloat(a);
762
- }
763
- }
764
- s /= 100;
765
- l /= 100;
766
- const k = (n) => (n + h / 30) % 12;
767
- const aa = s * Math.min(l, 1 - l);
768
- const f = (n) => l - aa * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
769
- rgb.r = 255 * f(0);
770
- rgb.g = 255 * f(8);
771
- rgb.b = 255 * f(4);
772
- rgb.a = a;
773
- if (!decimal) {
774
- rgb.r = Math.round(rgb.r);
775
- rgb.g = Math.round(rgb.g);
776
- rgb.b = Math.round(rgb.b);
777
- }
778
- rgb.rgb += (rgb.a === 1 ? '' : 'a') + `(${rgb.r},${rgb.g},${rgb.b}${rgb.a === 1 ? '' : ',' + rgb.a})`;
779
- return rgb;
780
- }
781
- function request(url, opt) {
782
- return new Promise(function (resove) {
783
- var _a;
784
- const xhr = new XMLHttpRequest();
785
- if (opt.credentials === false) {
786
- xhr.withCredentials = false;
787
- }
788
- xhr.upload.onloadstart = function (e) {
789
- var _a;
790
- const r = (_a = opt.uploadStart) === null || _a === void 0 ? void 0 : _a.call(opt, e.total);
791
- if (r && (r instanceof Promise)) {
792
- r.catch(function (e1) {
793
- console.log(e1);
794
- });
795
- }
796
- };
797
- xhr.upload.onprogress = function (e) {
798
- var _a;
799
- const r = (_a = opt.uploadProgress) === null || _a === void 0 ? void 0 : _a.call(opt, e.loaded, e.total);
800
- if (r && (r instanceof Promise)) {
801
- r.catch(function (e1) {
802
- console.log(e1);
803
- });
804
- }
805
- };
806
- xhr.upload.onloadend = function () {
807
- var _a;
808
- const r = (_a = opt.uploadEnd) === null || _a === void 0 ? void 0 : _a.call(opt);
809
- if (r && (r instanceof Promise)) {
810
- r.catch(function (e) {
811
- console.log(e);
812
- });
813
- }
814
- };
815
- xhr.onloadstart = function (e) {
816
- var _a;
817
- const r = (_a = opt.start) === null || _a === void 0 ? void 0 : _a.call(opt, e.total);
818
- if (r && (r instanceof Promise)) {
819
- r.catch(function (e1) {
820
- console.log(e1);
821
- });
822
- }
823
- };
824
- xhr.onprogress = function (e) {
825
- var _a;
826
- const r = (_a = opt.progress) === null || _a === void 0 ? void 0 : _a.call(opt, e.loaded, e.total);
827
- if (r && (r instanceof Promise)) {
828
- r.catch(function (e1) {
829
- console.log(e1);
830
- });
831
- }
832
- };
833
- xhr.onloadend = function () {
834
- var _a;
835
- const r = (_a = opt.end) === null || _a === void 0 ? void 0 : _a.call(opt);
836
- if (r && (r instanceof Promise)) {
837
- r.catch(function (e) {
838
- console.log(e);
839
- });
840
- }
841
- };
842
- xhr.onload = function () {
843
- var _a, _b;
844
- let res = this.response;
845
- if ((_a = this.getResponseHeader('content-type')) === null || _a === void 0 ? void 0 : _a.includes('json')) {
846
- try {
847
- res = JSON.parse(res);
848
- }
849
- catch (_c) {
850
- res = this.response;
851
- }
852
- }
853
- const r = (_b = opt.load) === null || _b === void 0 ? void 0 : _b.call(opt, res);
854
- if (r && (r instanceof Promise)) {
855
- r.catch(function (e) {
856
- console.log(e);
857
- });
858
- }
859
- resove(res);
860
- };
861
- xhr.onerror = function () {
862
- var _a;
863
- const r = (_a = opt.error) === null || _a === void 0 ? void 0 : _a.call(opt);
864
- if (r && (r instanceof Promise)) {
865
- r.catch(function (e) {
866
- console.log(e);
867
- });
868
- }
869
- resove(null);
870
- };
871
- if (opt.responseType) {
872
- xhr.responseType = opt.responseType;
873
- }
874
- if (opt.timeout) {
875
- xhr.timeout = opt.timeout;
876
- }
877
- if (opt.headers && !Array.isArray(opt.headers)) {
878
- for (const k in opt.headers) {
879
- xhr.setRequestHeader(k, opt.headers[k]);
880
- }
881
- }
882
- xhr.open((_a = opt.method) !== null && _a !== void 0 ? _a : 'GET', url, true);
883
- xhr.send(opt.body);
884
- });
885
- }
886
- function fetch(url, init) {
887
- return loader.fetch(url, init);
888
- }
889
- function get(url, opt) {
890
- return loader.get(url, opt);
891
- }
892
- function post(url, data, opt) {
893
- return loader.post(url, data, opt);
894
- }
895
- function getResponseJson(url, opt) {
896
- return __awaiter(this, void 0, void 0, function* () {
897
- return loader.getResponseJson(url, opt);
898
- });
899
- }
900
- function postResponseJson(url, data, opt) {
901
- return __awaiter(this, void 0, void 0, function* () {
902
- return loader.postResponseJson(url, data, opt);
903
- });
904
- }
905
- function parseUrl(url) {
906
- return loader.parseUrl(url);
907
- }
908
- function urlResolve(from, to) {
909
- return loader.urlResolve(from, to);
910
- }
911
- function urlAtom(url) {
912
- return loader.urlAtom(url);
913
- }
914
- function blob2Text(blob) {
915
- return loader.blob2Text(blob);
916
- }
917
- function blob2DataUrl(blob) {
918
- return loader.blob2DataUrl(blob);
919
- }
920
- function execCommand(ac) {
921
- if (!['copy', 'cut'].includes(ac)) {
922
- return;
923
- }
924
- document.execCommand(ac);
925
- }
926
- function compar(before, after) {
927
- const rtn = {
928
- 'remove': {},
929
- 'add': {},
930
- 'length': {
931
- 'remove': 0,
932
- 'add': 0
933
- }
934
- };
935
- for (let i = 0; i < before.length; ++i) {
936
- const item = before[i];
937
- if (after.includes(item)) {
938
- continue;
939
- }
940
- rtn.remove[item] = i;
941
- ++rtn.length.remove;
942
- }
943
- for (let i = 0; i < after.length; ++i) {
944
- const item = after[i];
945
- if (before.includes(item)) {
946
- continue;
947
- }
948
- rtn.add[item] = i;
949
- ++rtn.length.add;
950
- }
951
- return rtn;
952
- }
953
- function formatSecond(second) {
954
- const h = Math.floor(second / 3600);
955
- second = second - h * 3600;
956
- const m = Math.floor(second / 60);
957
- const s = Math.floor(second - m * 60);
958
- return (h ? h.toString().padStart(2, '0') + ':' : '') + m.toString().padStart(2, '0') + ':' + s.toString().padStart(2, '0');
959
- }
960
- function formatTime(ts, tz) {
961
- const rtn = {
962
- 'date': '',
963
- 'time': '',
964
- 'zone': ''
965
- };
966
- if (typeof ts === 'number') {
967
- ts = new Date(ts);
968
- }
969
- const ntz = tz !== null && tz !== void 0 ? tz : -(ts.getTimezoneOffset() / 60);
970
- ts.setTime(ts.getTime() + ntz * 60 * 60000);
971
- rtn.date = ts.getUTCFullYear().toString() + '-' + (ts.getUTCMonth() + 1).toString().padStart(2, '0') + '-' + ts.getUTCDate().toString().padStart(2, '0');
972
- rtn.time = ts.getUTCHours().toString().padStart(2, '0') + ':' + ts.getUTCMinutes().toString().padStart(2, '0') + ':' + ts.getUTCSeconds().toString().padStart(2, '0');
973
- rtn.zone = 'UTC' + (ntz >= 0 ? '+' : '') + ntz.toString();
974
- return rtn;
975
- }
976
- function isMs(time) {
977
- return time > 1000000000000 ? true : false;
978
- }
979
- function queryStringify(query) {
980
- return Object.entries(query).map(([k, v]) => {
981
- if (Array.isArray(v)) {
982
- return v.map((i) => `${encodeURIComponent(k)}=${encodeURIComponent(`${i}`)}`).join('&');
983
- }
984
- return `${encodeURIComponent(k)}=${encodeURIComponent(`${v}`)}`;
985
- }).join('&');
986
- }
987
- function queryParse(query) {
988
- const ret = {};
989
- const arrayKeys = {};
990
- for (const i of query.split('&')) {
991
- if (!i.length) {
992
- continue;
993
- }
994
- const pos = i.indexOf('=');
995
- const key = decodeURIComponent(pos === -1 ? i : i.slice(0, pos));
996
- const value = pos === -1 ? '' : decodeURIComponent(i.slice(pos + 1));
997
- if (arrayKeys[key]) {
998
- ret[key].push(value);
999
- }
1000
- else if (undefined === ret[key]) {
1001
- ret[key] = value;
1002
- }
1003
- else {
1004
- ret[key] = [ret[key], value];
1005
- arrayKeys[key] = true;
1006
- }
1007
- }
1008
- return ret;
1009
- }
1010
- function isEscaped(str, pos) {
1011
- let count = 0;
1012
- for (let i = pos - 1; i >= 0 && str[i] === '\\'; i--) {
1013
- count++;
1014
- }
1015
- return count % 2 !== 0;
1016
- }
1017
- function parseArrayString(arrayStr) {
1018
- const content = arrayStr.trim().slice(1, -1);
1019
- const result = [];
1020
- let current = '';
1021
- let depth = 0;
1022
- let inString = false;
1023
- let quote = '';
1024
- for (let i = 0; i < content.length; i++) {
1025
- const char = content[i];
1026
- if ((char === '"' || char === "'") && !inString) {
1027
- inString = true;
1028
- quote = char;
1029
- }
1030
- else if (char === quote && inString && !isEscaped(content, i)) {
1031
- inString = false;
1032
- quote = '';
1033
- }
1034
- if (!inString) {
1035
- if (char === '{' || char === '[' || char === '(') {
1036
- depth++;
1037
- }
1038
- else if (char === '}' || char === ']' || char === ')') {
1039
- depth--;
1040
- }
1041
- else if (char === ',' && depth === 0) {
1042
- if (current.trim())
1043
- result.push(current.trim());
1044
- current = '';
1045
- continue;
1046
- }
1047
- }
1048
- current += char;
1049
- }
1050
- if (current.trim()) {
1051
- result.push(current.trim());
1052
- }
1053
- return result;
1054
- }