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