@vandenberghinc/volt 1.1.2

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 (451) hide show
  1. package/.vrepo +28 -0
  2. package/.vscode/tasks.json +87 -0
  3. package/README.md +67 -0
  4. package/backend/dist/cjs/blacklist.d.ts +10 -0
  5. package/backend/dist/cjs/blacklist.js +53 -0
  6. package/backend/dist/cjs/cli.d.ts +2 -0
  7. package/backend/dist/cjs/cli.js +263 -0
  8. package/backend/dist/cjs/database.d.ts +364 -0
  9. package/backend/dist/cjs/database.js +1962 -0
  10. package/backend/dist/cjs/endpoint.d.ts +57 -0
  11. package/backend/dist/cjs/endpoint.js +425 -0
  12. package/backend/dist/cjs/file_watcher.d.ts +44 -0
  13. package/backend/dist/cjs/file_watcher.js +348 -0
  14. package/backend/dist/cjs/frontend.d.ts +13 -0
  15. package/backend/dist/cjs/frontend.js +30 -0
  16. package/backend/dist/cjs/image_endpoint.d.ts +24 -0
  17. package/backend/dist/cjs/image_endpoint.js +210 -0
  18. package/backend/dist/cjs/logger.d.ts +5 -0
  19. package/backend/dist/cjs/logger.js +16 -0
  20. package/backend/dist/cjs/meta.d.ts +50 -0
  21. package/backend/dist/cjs/meta.js +153 -0
  22. package/backend/dist/cjs/mutex.d.ts +24 -0
  23. package/backend/dist/cjs/mutex.js +52 -0
  24. package/backend/dist/cjs/package.json +1 -0
  25. package/backend/dist/cjs/payments/paddle.d.ts +161 -0
  26. package/backend/dist/cjs/payments/paddle.js +2301 -0
  27. package/backend/dist/cjs/plugins/browser.d.ts +36 -0
  28. package/backend/dist/cjs/plugins/browser.js +183 -0
  29. package/backend/dist/cjs/plugins/communication.d.ts +70 -0
  30. package/backend/dist/cjs/plugins/communication.js +177 -0
  31. package/backend/dist/cjs/plugins/css.d.ts +10 -0
  32. package/backend/dist/cjs/plugins/css.js +71 -0
  33. package/backend/dist/cjs/plugins/mail.d.ts +277 -0
  34. package/backend/dist/cjs/plugins/mail.js +1419 -0
  35. package/backend/dist/cjs/plugins/pdf.d.ts +757 -0
  36. package/backend/dist/cjs/plugins/pdf.js +1694 -0
  37. package/backend/dist/cjs/plugins/thread_monitor.d.ts +18 -0
  38. package/backend/dist/cjs/plugins/thread_monitor.js +127 -0
  39. package/backend/dist/cjs/plugins/ts/compiler.d.ts +132 -0
  40. package/backend/dist/cjs/plugins/ts/compiler.js +944 -0
  41. package/backend/dist/cjs/plugins/ts/preprocessing.d.ts +14 -0
  42. package/backend/dist/cjs/plugins/ts/preprocessing.js +762 -0
  43. package/backend/dist/cjs/rate_limit.d.ts +65 -0
  44. package/backend/dist/cjs/rate_limit.js +463 -0
  45. package/backend/dist/cjs/request.deprc.d.ts +48 -0
  46. package/backend/dist/cjs/request.deprc.js +572 -0
  47. package/backend/dist/cjs/response.deprc.d.ts +55 -0
  48. package/backend/dist/cjs/response.deprc.js +275 -0
  49. package/backend/dist/cjs/server.d.ts +311 -0
  50. package/backend/dist/cjs/server.js +3475 -0
  51. package/backend/dist/cjs/splash_screen.d.ts +35 -0
  52. package/backend/dist/cjs/splash_screen.js +152 -0
  53. package/backend/dist/cjs/status.d.ts +60 -0
  54. package/backend/dist/cjs/status.js +199 -0
  55. package/backend/dist/cjs/stream.d.ts +75 -0
  56. package/backend/dist/cjs/stream.js +954 -0
  57. package/backend/dist/cjs/users.d.ts +111 -0
  58. package/backend/dist/cjs/users.js +1945 -0
  59. package/backend/dist/cjs/utils.d.ts +27 -0
  60. package/backend/dist/cjs/utils.js +329 -0
  61. package/backend/dist/cjs/view.d.ts +52 -0
  62. package/backend/dist/cjs/view.js +568 -0
  63. package/backend/dist/cjs/vinc.d.ts +2 -0
  64. package/backend/dist/cjs/vinc.dev.d.ts +2 -0
  65. package/backend/dist/cjs/vinc.dev.js +42 -0
  66. package/backend/dist/cjs/vinc.js +42 -0
  67. package/backend/dist/cjs/volt.d.ts +15 -0
  68. package/backend/dist/cjs/volt.js +64 -0
  69. package/backend/dist/css/adyen.css +92 -0
  70. package/backend/dist/css/volt.css +65 -0
  71. package/backend/dist/esm/blacklist.d.ts +10 -0
  72. package/backend/dist/esm/blacklist.js +49 -0
  73. package/backend/dist/esm/cli.d.ts +2 -0
  74. package/backend/dist/esm/cli.js +228 -0
  75. package/backend/dist/esm/database.d.ts +364 -0
  76. package/backend/dist/esm/database.js +1957 -0
  77. package/backend/dist/esm/endpoint.d.ts +57 -0
  78. package/backend/dist/esm/endpoint.js +421 -0
  79. package/backend/dist/esm/file_watcher.d.ts +44 -0
  80. package/backend/dist/esm/file_watcher.js +313 -0
  81. package/backend/dist/esm/frontend.d.ts +13 -0
  82. package/backend/dist/esm/frontend.js +27 -0
  83. package/backend/dist/esm/image_endpoint.d.ts +24 -0
  84. package/backend/dist/esm/image_endpoint.js +206 -0
  85. package/backend/dist/esm/logger.d.ts +5 -0
  86. package/backend/dist/esm/logger.js +13 -0
  87. package/backend/dist/esm/meta.d.ts +50 -0
  88. package/backend/dist/esm/meta.js +149 -0
  89. package/backend/dist/esm/mutex.d.ts +24 -0
  90. package/backend/dist/esm/mutex.js +48 -0
  91. package/backend/dist/esm/payments/paddle.d.ts +161 -0
  92. package/backend/dist/esm/payments/paddle.js +2261 -0
  93. package/backend/dist/esm/plugins/browser.d.ts +36 -0
  94. package/backend/dist/esm/plugins/browser.js +176 -0
  95. package/backend/dist/esm/plugins/communication.d.ts +70 -0
  96. package/backend/dist/esm/plugins/communication.js +169 -0
  97. package/backend/dist/esm/plugins/css.d.ts +10 -0
  98. package/backend/dist/esm/plugins/css.js +64 -0
  99. package/backend/dist/esm/plugins/mail.d.ts +277 -0
  100. package/backend/dist/esm/plugins/mail.js +1403 -0
  101. package/backend/dist/esm/plugins/pdf.d.ts +757 -0
  102. package/backend/dist/esm/plugins/pdf.js +1694 -0
  103. package/backend/dist/esm/plugins/thread_monitor.d.ts +18 -0
  104. package/backend/dist/esm/plugins/thread_monitor.js +120 -0
  105. package/backend/dist/esm/plugins/ts/compiler.d.ts +132 -0
  106. package/backend/dist/esm/plugins/ts/compiler.js +907 -0
  107. package/backend/dist/esm/plugins/ts/preprocessing.d.ts +14 -0
  108. package/backend/dist/esm/plugins/ts/preprocessing.js +724 -0
  109. package/backend/dist/esm/rate_limit.d.ts +65 -0
  110. package/backend/dist/esm/rate_limit.js +425 -0
  111. package/backend/dist/esm/request.deprc.d.ts +48 -0
  112. package/backend/dist/esm/request.deprc.js +572 -0
  113. package/backend/dist/esm/response.deprc.d.ts +55 -0
  114. package/backend/dist/esm/response.deprc.js +275 -0
  115. package/backend/dist/esm/server.d.ts +311 -0
  116. package/backend/dist/esm/server.js +3435 -0
  117. package/backend/dist/esm/splash_screen.d.ts +35 -0
  118. package/backend/dist/esm/splash_screen.js +148 -0
  119. package/backend/dist/esm/status.d.ts +60 -0
  120. package/backend/dist/esm/status.js +196 -0
  121. package/backend/dist/esm/stream.d.ts +75 -0
  122. package/backend/dist/esm/stream.js +947 -0
  123. package/backend/dist/esm/users.d.ts +111 -0
  124. package/backend/dist/esm/users.js +1908 -0
  125. package/backend/dist/esm/utils.d.ts +27 -0
  126. package/backend/dist/esm/utils.js +324 -0
  127. package/backend/dist/esm/view.d.ts +52 -0
  128. package/backend/dist/esm/view.js +561 -0
  129. package/backend/dist/esm/vinc.d.ts +2 -0
  130. package/backend/dist/esm/vinc.dev.d.ts +2 -0
  131. package/backend/dist/esm/vinc.dev.js +6 -0
  132. package/backend/dist/esm/vinc.js +6 -0
  133. package/backend/dist/esm/volt.d.ts +15 -0
  134. package/backend/dist/esm/volt.js +23 -0
  135. package/backend/dist/esm-dev/blacklist.d.ts +10 -0
  136. package/backend/dist/esm-dev/blacklist.js +49 -0
  137. package/backend/dist/esm-dev/cli.d.ts +2 -0
  138. package/backend/dist/esm-dev/cli.js +228 -0
  139. package/backend/dist/esm-dev/database.d.ts +364 -0
  140. package/backend/dist/esm-dev/database.js +1957 -0
  141. package/backend/dist/esm-dev/endpoint.d.ts +57 -0
  142. package/backend/dist/esm-dev/endpoint.js +421 -0
  143. package/backend/dist/esm-dev/file_watcher.d.ts +44 -0
  144. package/backend/dist/esm-dev/file_watcher.js +313 -0
  145. package/backend/dist/esm-dev/frontend.d.ts +13 -0
  146. package/backend/dist/esm-dev/frontend.js +27 -0
  147. package/backend/dist/esm-dev/image_endpoint.d.ts +24 -0
  148. package/backend/dist/esm-dev/image_endpoint.js +206 -0
  149. package/backend/dist/esm-dev/logger.d.ts +5 -0
  150. package/backend/dist/esm-dev/logger.js +13 -0
  151. package/backend/dist/esm-dev/meta.d.ts +50 -0
  152. package/backend/dist/esm-dev/meta.js +149 -0
  153. package/backend/dist/esm-dev/mutex.d.ts +24 -0
  154. package/backend/dist/esm-dev/mutex.js +48 -0
  155. package/backend/dist/esm-dev/payments/paddle.d.ts +161 -0
  156. package/backend/dist/esm-dev/payments/paddle.js +2261 -0
  157. package/backend/dist/esm-dev/plugins/browser.d.ts +36 -0
  158. package/backend/dist/esm-dev/plugins/browser.js +176 -0
  159. package/backend/dist/esm-dev/plugins/communication.d.ts +70 -0
  160. package/backend/dist/esm-dev/plugins/communication.js +169 -0
  161. package/backend/dist/esm-dev/plugins/css.d.ts +10 -0
  162. package/backend/dist/esm-dev/plugins/css.js +64 -0
  163. package/backend/dist/esm-dev/plugins/mail.d.ts +277 -0
  164. package/backend/dist/esm-dev/plugins/mail.js +1403 -0
  165. package/backend/dist/esm-dev/plugins/pdf.d.ts +757 -0
  166. package/backend/dist/esm-dev/plugins/pdf.js +1694 -0
  167. package/backend/dist/esm-dev/plugins/thread_monitor.d.ts +18 -0
  168. package/backend/dist/esm-dev/plugins/thread_monitor.js +120 -0
  169. package/backend/dist/esm-dev/plugins/ts/compiler.d.ts +132 -0
  170. package/backend/dist/esm-dev/plugins/ts/compiler.js +907 -0
  171. package/backend/dist/esm-dev/plugins/ts/preprocessing.d.ts +14 -0
  172. package/backend/dist/esm-dev/plugins/ts/preprocessing.js +724 -0
  173. package/backend/dist/esm-dev/rate_limit.d.ts +65 -0
  174. package/backend/dist/esm-dev/rate_limit.js +425 -0
  175. package/backend/dist/esm-dev/request.deprc.d.ts +48 -0
  176. package/backend/dist/esm-dev/request.deprc.js +572 -0
  177. package/backend/dist/esm-dev/response.deprc.d.ts +55 -0
  178. package/backend/dist/esm-dev/response.deprc.js +275 -0
  179. package/backend/dist/esm-dev/server.d.ts +311 -0
  180. package/backend/dist/esm-dev/server.js +3435 -0
  181. package/backend/dist/esm-dev/splash_screen.d.ts +35 -0
  182. package/backend/dist/esm-dev/splash_screen.js +148 -0
  183. package/backend/dist/esm-dev/status.d.ts +60 -0
  184. package/backend/dist/esm-dev/status.js +196 -0
  185. package/backend/dist/esm-dev/stream.d.ts +75 -0
  186. package/backend/dist/esm-dev/stream.js +947 -0
  187. package/backend/dist/esm-dev/users.d.ts +111 -0
  188. package/backend/dist/esm-dev/users.js +1908 -0
  189. package/backend/dist/esm-dev/utils.d.ts +27 -0
  190. package/backend/dist/esm-dev/utils.js +324 -0
  191. package/backend/dist/esm-dev/view.d.ts +52 -0
  192. package/backend/dist/esm-dev/view.js +561 -0
  193. package/backend/dist/esm-dev/vinc.d.ts +2 -0
  194. package/backend/dist/esm-dev/vinc.dev.d.ts +2 -0
  195. package/backend/dist/esm-dev/vinc.dev.js +6 -0
  196. package/backend/dist/esm-dev/vinc.js +6 -0
  197. package/backend/dist/esm-dev/volt.d.ts +15 -0
  198. package/backend/dist/esm-dev/volt.js +23 -0
  199. package/backend/src/blacklist.ts +69 -0
  200. package/backend/src/cli.js +245 -0
  201. package/backend/src/database.ts +2241 -0
  202. package/backend/src/endpoint.ts +494 -0
  203. package/backend/src/file_watcher.ts +359 -0
  204. package/backend/src/frontend.ts +35 -0
  205. package/backend/src/globals.d.ts +8 -0
  206. package/backend/src/image_endpoint.ts +258 -0
  207. package/backend/src/logger.ts +18 -0
  208. package/backend/src/meta.ts +202 -0
  209. package/backend/src/mutex.ts +51 -0
  210. package/backend/src/payments/paddle.ts +2659 -0
  211. package/backend/src/plugins/browser.ts +188 -0
  212. package/backend/src/plugins/communication.ts +204 -0
  213. package/backend/src/plugins/css.ts +84 -0
  214. package/backend/src/plugins/fonts/Menlo-Bold.ttf +0 -0
  215. package/backend/src/plugins/fonts/Menlo-Regular.ttf +0 -0
  216. package/backend/src/plugins/mail.ts +1720 -0
  217. package/backend/src/plugins/pdf.js +1932 -0
  218. package/backend/src/plugins/thread_monitor.ts +164 -0
  219. package/backend/src/plugins/ts/compiler.ts +1242 -0
  220. package/backend/src/plugins/ts/preprocessing.ts +812 -0
  221. package/backend/src/rate_limit.ts +503 -0
  222. package/backend/src/request.deprc.js +626 -0
  223. package/backend/src/response.deprc.js +354 -0
  224. package/backend/src/server.ts +4149 -0
  225. package/backend/src/splash_screen.ts +192 -0
  226. package/backend/src/status.ts +199 -0
  227. package/backend/src/stream.ts +1070 -0
  228. package/backend/src/users.ts +2077 -0
  229. package/backend/src/utils.ts +359 -0
  230. package/backend/src/view.ts +655 -0
  231. package/backend/src/vinc.dev.js +6 -0
  232. package/backend/src/vinc.ts +6 -0
  233. package/backend/src/volt.js +25 -0
  234. package/backend/tsconfig.cjs.json +29 -0
  235. package/backend/tsconfig.esm.dev.json +34 -0
  236. package/backend/tsconfig.esm.json +30 -0
  237. package/backend/tsconfig.json +2 -0
  238. package/frontend/compile.js +436 -0
  239. package/frontend/dist/elements/base.d.ts +9891 -0
  240. package/frontend/dist/elements/base.js +8818 -0
  241. package/frontend/dist/elements/module.d.ts +16 -0
  242. package/frontend/dist/elements/module.js +178 -0
  243. package/frontend/dist/modules/array.d.ts +37 -0
  244. package/frontend/dist/modules/array.js +284 -0
  245. package/frontend/dist/modules/auth.d.ts +45 -0
  246. package/frontend/dist/modules/auth.js +138 -0
  247. package/frontend/dist/modules/colors.d.ts +26 -0
  248. package/frontend/dist/modules/colors.js +340 -0
  249. package/frontend/dist/modules/compression.d.ts +6 -0
  250. package/frontend/dist/modules/compression.js +999 -0
  251. package/frontend/dist/modules/cookies.d.ts +17 -0
  252. package/frontend/dist/modules/cookies.js +166 -0
  253. package/frontend/dist/modules/date.d.ts +142 -0
  254. package/frontend/dist/modules/date.js +493 -0
  255. package/frontend/dist/modules/events.d.ts +7 -0
  256. package/frontend/dist/modules/events.js +90 -0
  257. package/frontend/dist/modules/google.d.ts +10 -0
  258. package/frontend/dist/modules/google.js +53 -0
  259. package/frontend/dist/modules/meta.d.ts +9 -0
  260. package/frontend/dist/modules/meta.js +45 -0
  261. package/frontend/dist/modules/mutex.d.ts +8 -0
  262. package/frontend/dist/modules/mutex.js +52 -0
  263. package/frontend/dist/modules/number.d.ts +12 -0
  264. package/frontend/dist/modules/number.js +8 -0
  265. package/frontend/dist/modules/object.d.ts +50 -0
  266. package/frontend/dist/modules/object.js +147 -0
  267. package/frontend/dist/modules/paddle.d.ts +1403 -0
  268. package/frontend/dist/modules/paddle.js +2641 -0
  269. package/frontend/dist/modules/scheme.d.ts +207 -0
  270. package/frontend/dist/modules/scheme.js +649 -0
  271. package/frontend/dist/modules/settings.d.ts +3 -0
  272. package/frontend/dist/modules/settings.js +4 -0
  273. package/frontend/dist/modules/statics.d.ts +4 -0
  274. package/frontend/dist/modules/statics.js +45 -0
  275. package/frontend/dist/modules/string.d.ts +163 -0
  276. package/frontend/dist/modules/string.js +291 -0
  277. package/frontend/dist/modules/support.d.ts +18 -0
  278. package/frontend/dist/modules/support.js +102 -0
  279. package/frontend/dist/modules/themes.d.ts +8 -0
  280. package/frontend/dist/modules/themes.js +17 -0
  281. package/frontend/dist/modules/user.d.ts +58 -0
  282. package/frontend/dist/modules/user.js +279 -0
  283. package/frontend/dist/modules/utils.d.ts +58 -0
  284. package/frontend/dist/modules/utils.js +1159 -0
  285. package/frontend/dist/types/gradient.d.ts +12 -0
  286. package/frontend/dist/types/gradient.js +79 -0
  287. package/frontend/dist/ui/border_button.d.ts +177 -0
  288. package/frontend/dist/ui/border_button.js +235 -0
  289. package/frontend/dist/ui/button.d.ts +42 -0
  290. package/frontend/dist/ui/button.js +114 -0
  291. package/frontend/dist/ui/canvas.d.ts +56 -0
  292. package/frontend/dist/ui/canvas.js +411 -0
  293. package/frontend/dist/ui/checkbox.d.ts +72 -0
  294. package/frontend/dist/ui/checkbox.js +277 -0
  295. package/frontend/dist/ui/code.d.ts +232 -0
  296. package/frontend/dist/ui/code.js +977 -0
  297. package/frontend/dist/ui/color.d.ts +1 -0
  298. package/frontend/dist/ui/color.js +110 -0
  299. package/frontend/dist/ui/context_menu.d.ts +30 -0
  300. package/frontend/dist/ui/context_menu.js +211 -0
  301. package/frontend/dist/ui/css.d.ts +10 -0
  302. package/frontend/dist/ui/css.js +44 -0
  303. package/frontend/dist/ui/divider.d.ts +18 -0
  304. package/frontend/dist/ui/divider.js +82 -0
  305. package/frontend/dist/ui/dropdown.d.ts +115 -0
  306. package/frontend/dist/ui/dropdown.js +446 -0
  307. package/frontend/dist/ui/for_each.d.ts +38 -0
  308. package/frontend/dist/ui/for_each.js +97 -0
  309. package/frontend/dist/ui/form.d.ts +25 -0
  310. package/frontend/dist/ui/form.js +227 -0
  311. package/frontend/dist/ui/frame_modes.d.ts +28 -0
  312. package/frontend/dist/ui/frame_modes.js +116 -0
  313. package/frontend/dist/ui/google_map.d.ts +31 -0
  314. package/frontend/dist/ui/google_map.js +111 -0
  315. package/frontend/dist/ui/gradient.d.ts +24 -0
  316. package/frontend/dist/ui/gradient.js +115 -0
  317. package/frontend/dist/ui/image.d.ts +138 -0
  318. package/frontend/dist/ui/image.js +570 -0
  319. package/frontend/dist/ui/input.d.ts +316 -0
  320. package/frontend/dist/ui/input.js +1187 -0
  321. package/frontend/dist/ui/link.d.ts +39 -0
  322. package/frontend/dist/ui/link.js +146 -0
  323. package/frontend/dist/ui/list.d.ts +33 -0
  324. package/frontend/dist/ui/list.js +161 -0
  325. package/frontend/dist/ui/loader_button.d.ts +108 -0
  326. package/frontend/dist/ui/loader_button.js +207 -0
  327. package/frontend/dist/ui/loaders.d.ts +60 -0
  328. package/frontend/dist/ui/loaders.js +150 -0
  329. package/frontend/dist/ui/popup.d.ts +84 -0
  330. package/frontend/dist/ui/popup.js +331 -0
  331. package/frontend/dist/ui/pseudo.d.ts +16 -0
  332. package/frontend/dist/ui/pseudo.js +81 -0
  333. package/frontend/dist/ui/scroller.d.ts +131 -0
  334. package/frontend/dist/ui/scroller.js +1251 -0
  335. package/frontend/dist/ui/slider.d.ts +35 -0
  336. package/frontend/dist/ui/slider.js +203 -0
  337. package/frontend/dist/ui/spacer.d.ts +20 -0
  338. package/frontend/dist/ui/spacer.js +83 -0
  339. package/frontend/dist/ui/span.d.ts +11 -0
  340. package/frontend/dist/ui/span.js +75 -0
  341. package/frontend/dist/ui/stack.d.ts +123 -0
  342. package/frontend/dist/ui/stack.js +344 -0
  343. package/frontend/dist/ui/steps.d.ts +72 -0
  344. package/frontend/dist/ui/steps.js +306 -0
  345. package/frontend/dist/ui/style.d.ts +12 -0
  346. package/frontend/dist/ui/style.js +78 -0
  347. package/frontend/dist/ui/switch.d.ts +44 -0
  348. package/frontend/dist/ui/switch.js +280 -0
  349. package/frontend/dist/ui/table.d.ts +118 -0
  350. package/frontend/dist/ui/table.js +411 -0
  351. package/frontend/dist/ui/tabs.d.ts +85 -0
  352. package/frontend/dist/ui/tabs.js +392 -0
  353. package/frontend/dist/ui/text.d.ts +19 -0
  354. package/frontend/dist/ui/text.js +88 -0
  355. package/frontend/dist/ui/theme.d.ts +25 -0
  356. package/frontend/dist/ui/theme.js +237 -0
  357. package/frontend/dist/ui/title.d.ts +36 -0
  358. package/frontend/dist/ui/title.js +127 -0
  359. package/frontend/dist/ui/ui.d.ts +38 -0
  360. package/frontend/dist/ui/ui.js +41 -0
  361. package/frontend/dist/ui/view.d.ts +25 -0
  362. package/frontend/dist/ui/view.js +93 -0
  363. package/frontend/dist/volt.d.ts +22 -0
  364. package/frontend/dist/volt.js +27 -0
  365. package/frontend/exports.json +1340 -0
  366. package/frontend/src/css/adyen.css +92 -0
  367. package/frontend/src/css/volt.css +65 -0
  368. package/frontend/src/elements/base.ts +16790 -0
  369. package/frontend/src/elements/module.ts +184 -0
  370. package/frontend/src/elements/types.d.ts +155 -0
  371. package/frontend/src/modules/array.ts +366 -0
  372. package/frontend/src/modules/auth.ts +188 -0
  373. package/frontend/src/modules/colors.ts +449 -0
  374. package/frontend/src/modules/compression.ts +67 -0
  375. package/frontend/src/modules/cookies.ts +182 -0
  376. package/frontend/src/modules/date.js +535 -0
  377. package/frontend/src/modules/date.ts +583 -0
  378. package/frontend/src/modules/events.ts +96 -0
  379. package/frontend/src/modules/google.ts +60 -0
  380. package/frontend/src/modules/meta.ts +59 -0
  381. package/frontend/src/modules/mutex.ts +59 -0
  382. package/frontend/src/modules/number.ts +20 -0
  383. package/frontend/src/modules/object.ts +212 -0
  384. package/frontend/src/modules/paddle.ts +2990 -0
  385. package/frontend/src/modules/scheme.ts +740 -0
  386. package/frontend/src/modules/settings.ts +5 -0
  387. package/frontend/src/modules/statics.ts +47 -0
  388. package/frontend/src/modules/string.ts +500 -0
  389. package/frontend/src/modules/support.ts +118 -0
  390. package/frontend/src/modules/themes.ts +24 -0
  391. package/frontend/src/modules/user.ts +321 -0
  392. package/frontend/src/modules/utils.ts +1260 -0
  393. package/frontend/src/static/admin/admin.png +0 -0
  394. package/frontend/src/static/admin/password.webp +0 -0
  395. package/frontend/src/static/icons/copy.webp +0 -0
  396. package/frontend/src/static/payments/arrow.long.webp +0 -0
  397. package/frontend/src/static/payments/arrow.long2.webp +0 -0
  398. package/frontend/src/static/payments/cancelled.webp +0 -0
  399. package/frontend/src/static/payments/check.sign.webp +0 -0
  400. package/frontend/src/static/payments/check.webp +0 -0
  401. package/frontend/src/static/payments/close.webp +0 -0
  402. package/frontend/src/static/payments/error.webp +0 -0
  403. package/frontend/src/static/payments/exclamation.webp +0 -0
  404. package/frontend/src/static/payments/minus.webp +0 -0
  405. package/frontend/src/static/payments/party.webp +0 -0
  406. package/frontend/src/static/payments/plus.webp +0 -0
  407. package/frontend/src/static/payments/shopping_cart.webp +0 -0
  408. package/frontend/src/static/payments/trash.webp +0 -0
  409. package/frontend/src/types/global.d.ts +4 -0
  410. package/frontend/src/types/gradient.ts +87 -0
  411. package/frontend/src/ui/any_element.d.ts +5 -0
  412. package/frontend/src/ui/border_button.ts +320 -0
  413. package/frontend/src/ui/button.ts +62 -0
  414. package/frontend/src/ui/canvas.ts +431 -0
  415. package/frontend/src/ui/checkbox.ts +284 -0
  416. package/frontend/src/ui/code.ts +1049 -0
  417. package/frontend/src/ui/color.ts +117 -0
  418. package/frontend/src/ui/context_menu.ts +194 -0
  419. package/frontend/src/ui/css.ts +57 -0
  420. package/frontend/src/ui/divider.ts +28 -0
  421. package/frontend/src/ui/dropdown.ts +503 -0
  422. package/frontend/src/ui/for_each.ts +71 -0
  423. package/frontend/src/ui/form.ts +208 -0
  424. package/frontend/src/ui/frame_modes.ts +140 -0
  425. package/frontend/src/ui/google_map.ts +70 -0
  426. package/frontend/src/ui/gradient.ts +73 -0
  427. package/frontend/src/ui/image.ts +587 -0
  428. package/frontend/src/ui/input.ts +1284 -0
  429. package/frontend/src/ui/link.ts +77 -0
  430. package/frontend/src/ui/list.ts +88 -0
  431. package/frontend/src/ui/loader_button.ts +192 -0
  432. package/frontend/src/ui/loaders.ts +126 -0
  433. package/frontend/src/ui/popup.ts +370 -0
  434. package/frontend/src/ui/pseudo.ts +33 -0
  435. package/frontend/src/ui/scroller.ts +1324 -0
  436. package/frontend/src/ui/slider.ts +215 -0
  437. package/frontend/src/ui/spacer.ts +29 -0
  438. package/frontend/src/ui/span.ts +23 -0
  439. package/frontend/src/ui/stack.ts +238 -0
  440. package/frontend/src/ui/steps.ts +334 -0
  441. package/frontend/src/ui/style.ts +26 -0
  442. package/frontend/src/ui/switch.ts +286 -0
  443. package/frontend/src/ui/table.ts +323 -0
  444. package/frontend/src/ui/tabs.ts +441 -0
  445. package/frontend/src/ui/text.ts +38 -0
  446. package/frontend/src/ui/theme.ts +279 -0
  447. package/frontend/src/ui/title.ts +64 -0
  448. package/frontend/src/ui/ui.ts +47 -0
  449. package/frontend/src/ui/view.ts +44 -0
  450. package/frontend/src/volt.ts +31 -0
  451. package/package.json +58 -0
@@ -0,0 +1,1159 @@
1
+ /*
2
+ * Author: Daan van den Bergh
3
+ * Copyright: © 2022 - 2024 Daan van den Bergh.
4
+ */
5
+ // Utils module.
6
+ const Utils = {
7
+ is_apple: navigator.vendor.includes('Apple'),
8
+ is_safari: navigator.vendor.includes('Apple'),
9
+ /* @docs:
10
+ @nav: Frontend
11
+ @chapter: Utils
12
+ @title: Check if value is a string
13
+ @desc: Determine whether the provided value is a string.
14
+ @param:
15
+ @name: value
16
+ @description The value to check.
17
+ @type: any
18
+ @return:
19
+ @description Returns true if the value is a string, otherwise false.
20
+ @type: boolean
21
+ */
22
+ is_string(value) {
23
+ return typeof value === 'string' || value instanceof String;
24
+ },
25
+ /* @docs:
26
+ @nav: Frontend
27
+ @chapter: Utils
28
+ @title: Check if value is numeric
29
+ @desc: Determine whether the provided value is a finite number.
30
+ @param:
31
+ @name: value
32
+ @description The value to check.
33
+ @type: any
34
+ @return:
35
+ @description Returns true if the value is a finite number, otherwise false.
36
+ @type: boolean
37
+ */
38
+ is_numeric(value) {
39
+ return typeof value === 'number' && Number.isFinite(value);
40
+ },
41
+ /* @docs:
42
+ @nav: Frontend
43
+ @chapter: Utils
44
+ @title: Check if value is an integer
45
+ @desc: Determine whether the provided value is an integer.
46
+ @param:
47
+ @name: value
48
+ @description The value to check.
49
+ @type: any
50
+ @return:
51
+ @description Returns true if the value is an integer, otherwise false.
52
+ @type: boolean
53
+ */
54
+ is_int(value) {
55
+ return typeof value === 'number' && Number.isInteger(value);
56
+ },
57
+ /* @docs:
58
+ @nav: Frontend
59
+ @chapter: Utils
60
+ @title: Check if value is a float
61
+ @desc: Determine whether the provided value is a floating-point number.
62
+ @param:
63
+ @name: value
64
+ @description The value to check.
65
+ @type: any
66
+ @return:
67
+ @description Returns true if the value is a float, otherwise false.
68
+ @type: boolean
69
+ */
70
+ is_float(value) {
71
+ return typeof value === 'number' && !Number.isNaN(value) && !Number.isInteger(value);
72
+ },
73
+ /* @docs:
74
+ @nav: Frontend
75
+ @chapter: Utils
76
+ @title: Check if value is a function
77
+ @desc: Determine whether the provided value is a function.
78
+ @param:
79
+ @name: value
80
+ @description The value to check.
81
+ @type: any
82
+ @return:
83
+ @description Returns true if the value is a function, otherwise false.
84
+ @type: boolean
85
+ */
86
+ is_func(value) {
87
+ return typeof value === 'function';
88
+ },
89
+ /* @docs:
90
+ @nav: Frontend
91
+ @chapter: Utils
92
+ @title: Check if value is an array
93
+ @desc: Determine whether the provided value is an array.
94
+ @param:
95
+ @name: value
96
+ @description The value to check.
97
+ @type: any
98
+ @return:
99
+ @description Returns true if the value is an array, otherwise false.
100
+ @type: boolean
101
+ */
102
+ is_array(value) {
103
+ return Array.isArray(value);
104
+ },
105
+ /* @docs:
106
+ @nav: Frontend
107
+ @chapter: Utils
108
+ @title: Check if value is an object
109
+ @desc: Determine whether the provided value is a non-array object.
110
+ @param:
111
+ @name: value
112
+ @description The value to check.
113
+ @type: any
114
+ @return:
115
+ @description Returns true if the value is an object and not an array, otherwise false.
116
+ @type: boolean
117
+ */
118
+ is_obj(value) {
119
+ return value != null && typeof value === 'object' && !Array.isArray(value);
120
+ },
121
+ /* @docs:
122
+ @nav: Frontend
123
+ @chapter: Utils
124
+ @title: Check if number is even
125
+ @desc: Determine whether the provided number is even.
126
+ @param:
127
+ @name: number
128
+ @description The number to check.
129
+ @type: number
130
+ @return:
131
+ @description Returns true if the number is even, otherwise false.
132
+ @type: boolean
133
+ */
134
+ is_even(number) {
135
+ return number % 2 === 0;
136
+ },
137
+ /* @docs:
138
+ @nav: Frontend
139
+ @chapter: Utils
140
+ @title: Is Mobile
141
+ @desc: Check if the user agent is a mobile device.
142
+ */
143
+ is_mobile() {
144
+ return (!!navigator.userAgent.match(/Android/i) ||
145
+ !!navigator.userAgent.match(/webOS/i) ||
146
+ !!navigator.userAgent.match(/iPhone/i) ||
147
+ !!navigator.userAgent.match(/iPad/i) ||
148
+ !!navigator.userAgent.match(/iPod/i) ||
149
+ !!navigator.userAgent.match(/BlackBerry/i) ||
150
+ !!navigator.userAgent.match(/Windows Phone/i));
151
+ },
152
+ /* @docs:
153
+ @nav: Frontend
154
+ @chapter: Utils
155
+ @title: Make Immutable
156
+ @desc:
157
+ Make all objects of an array or object immutable. All nested objects will also be made immutable recursively.
158
+ @param:
159
+ @name: object
160
+ @desc: The array or object to freeze.
161
+ @type: array | object
162
+ */
163
+ make_immutable(object) {
164
+ if (Array.isArray(object)) {
165
+ object.forEach((item, index) => {
166
+ if (item !== null && typeof item === "object") {
167
+ object[index] = Utils.make_immutable(item);
168
+ }
169
+ });
170
+ Object.freeze(object);
171
+ }
172
+ else if (object !== null && typeof object === "object") {
173
+ Object.keys(object).forEach((key) => {
174
+ if (object[key] !== null && typeof object[key] === "object") {
175
+ object[key] = Utils.make_immutable(object[key]);
176
+ }
177
+ });
178
+ Object.freeze(object);
179
+ }
180
+ return object;
181
+ },
182
+ /* @docs:
183
+ @nav: Frontend
184
+ @chapter: Utils
185
+ @title: Is child
186
+ @desc:
187
+ Check if an element is a direct child of an element or the parent element itself.
188
+ @param:
189
+ @name: parent
190
+ @desc: The parent element to test.
191
+ @type: Node | Element
192
+ @param:
193
+ @name: target
194
+ @desc: The target element to test.
195
+ @type: Node | Element
196
+ */
197
+ is_child(parent, target) {
198
+ for (let i = 0; i < parent.children.length; i++) {
199
+ if (target === parent.children[i]) {
200
+ return true;
201
+ }
202
+ }
203
+ return false;
204
+ },
205
+ /* @docs:
206
+ @nav: Frontend
207
+ @chapter: Utils
208
+ @title: Is child recursively
209
+ @desc:
210
+ Check if an element is a recursively nested child of an element or the parent element itself.
211
+ @param:
212
+ @name: parent
213
+ @desc: The parent element to test.
214
+ @type: Node | Element
215
+ @param:
216
+ @name: target
217
+ @desc: The target element to test.
218
+ @type: Node | Element
219
+ @param:
220
+ @name: stop_node
221
+ @desc: A node at which to stop checking if target is a parent of the current element.
222
+ @type: Node | Element | null
223
+ */
224
+ is_nested_child(parent, target, stop_node = null) {
225
+ let e = target instanceof Element ? target : null;
226
+ while (e != null) {
227
+ if (e === parent) {
228
+ return true;
229
+ }
230
+ else if (e === stop_node) {
231
+ return false;
232
+ }
233
+ e = e.parentElement;
234
+ }
235
+ return false;
236
+ },
237
+ // Equals.
238
+ // eq(x, y) { return x == y; }
239
+ // not_eq(x, y) { return x != y; }
240
+ // Greater than.
241
+ // gt(x, y) { return x > y; }
242
+ // gt_eq(x, y) { return x >= y; }
243
+ // Lesser than.
244
+ // lt(x, y) { return x < y; }
245
+ // lt_eq(x, y) { return x <= y; }
246
+ /* @docs:
247
+ @nav: Frontend
248
+ @chapter: Utils
249
+ @title: Round to decimals
250
+ @desc: Round a number to a specified number of decimal places.
251
+ @param:
252
+ @name: value
253
+ @desc: The number to round.
254
+ @type: number
255
+ @name: decimals
256
+ @desc: The number of decimal places.
257
+ @type: number
258
+ @return:
259
+ @desc: The rounded number.
260
+ @type: number
261
+ */
262
+ round(value, decimals) {
263
+ const factor = 10 ** decimals;
264
+ return Math.round(value * factor) / factor;
265
+ },
266
+ /* @docs:
267
+ @nav: Frontend
268
+ @chapter: Utils
269
+ @title: Get device width
270
+ @desc: Get the width of the device's viewport.
271
+ @return:
272
+ @desc: The width of the device's viewport.
273
+ @type: number
274
+ */
275
+ device_width() {
276
+ return (window.innerWidth > 0) ? window.innerWidth : screen.width;
277
+ },
278
+ /* @docs:
279
+ @nav: Frontend
280
+ @chapter: Utils
281
+ @title: Get device height
282
+ @desc: Get the height of the device's viewport.
283
+ @return:
284
+ @desc: The height of the device's viewport.
285
+ @type: number
286
+ */
287
+ device_height() {
288
+ return (window.innerHeight > 0) ? window.innerHeight : screen.height;
289
+ },
290
+ /* @docs:
291
+ @nav: Frontend
292
+ @chapter: Utils
293
+ @title: Get endpoint
294
+ @desc: Get the endpoint sub URL of a full domain URL. When parameter "url" is undefined, it uses the current URL.
295
+ @param:
296
+ @name: url
297
+ @desc: The full domain URL.
298
+ @type: string | null
299
+ @return:
300
+ @desc: The endpoint sub URL.
301
+ @type: string
302
+ */
303
+ endpoint(url = null) {
304
+ if (url == null) {
305
+ return Utils.endpoint(window.location.href);
306
+ }
307
+ else {
308
+ // Strip http:// or https://
309
+ let endpoint = url.replace(/^https?:\/\//, "");
310
+ // Remove domain.
311
+ const firstSlash = endpoint.indexOf('/');
312
+ endpoint = firstSlash !== -1 ? endpoint.substring(firstSlash) : '/';
313
+ // Strip query.
314
+ const queryIndex = endpoint.indexOf("?");
315
+ if (queryIndex !== -1) {
316
+ endpoint = endpoint.substring(0, queryIndex);
317
+ }
318
+ // Clean.
319
+ endpoint = endpoint.replaceAll("//", "/");
320
+ // Remove trailing slashes.
321
+ if (endpoint.length === 0) {
322
+ return '/';
323
+ }
324
+ else {
325
+ while (endpoint.length > 1 && endpoint.endsWith('/')) {
326
+ endpoint = endpoint.slice(0, -1);
327
+ }
328
+ }
329
+ return endpoint;
330
+ }
331
+ },
332
+ // Get style name for vendor prefix.
333
+ // get_vendor_prefix_property(property: string, style: CSSStyleDeclaration): string {
334
+ // if (Utils.vendor_prefix_cache[property]) {
335
+ // return Utils.vendor_prefix_cache[property];
336
+ // }
337
+ // const vendors = ['webkit', 'moz', 'ms', 'o'];
338
+ // for (let i = 0; i < vendors.length; i++) {
339
+ // let vendor_property = "-";
340
+ // vendor_property += vendors[i];
341
+ // vendor_property += "-";
342
+ // vendor_property += property;
343
+ // if (property in style) {
344
+ // Utils.vendor_prefix_cache[property] = vendor_property;
345
+ // return vendor_property;
346
+ // }
347
+ // }
348
+ // Utils.vendor_prefix_cache[property] = property;
349
+ // return property;
350
+ // }
351
+ /* @docs:
352
+ @nav: Frontend
353
+ @chapter: Utils
354
+ @title: Redirect
355
+ @desc: Redirect to a specified URL, optionally forcing the redirect even if the endpoint is the same.
356
+ @param:
357
+ @name: url
358
+ @desc: The URL to redirect to.
359
+ @type: string
360
+ @name: forced
361
+ @desc: Whether to force the redirect even if the current endpoint is the same as the target URL.
362
+ @type: boolean
363
+ */
364
+ redirect(url, forced = false) {
365
+ if (forced || Utils.endpoint() !== url) {
366
+ window.location.href = url;
367
+ }
368
+ },
369
+ /* @docs:
370
+ @nav: Frontend
371
+ @chapter: Utils
372
+ @title: Delay
373
+ @desc: Delay the execution of a function by a specified number of milliseconds.
374
+ @param:
375
+ @name: mseconds
376
+ @desc: The number of milliseconds to delay.
377
+ @type: number
378
+ @name: func
379
+ @desc: The function to execute after the delay.
380
+ @type: () => void
381
+ */
382
+ delay(mseconds, func) {
383
+ setTimeout(() => func(), mseconds);
384
+ },
385
+ /* @docs:
386
+ @nav: Frontend
387
+ @chapter: Utils
388
+ @title: Get URL parameter
389
+ @desc: Get a URL parameter by name, with an optional default value.
390
+ @param:
391
+ @name: name
392
+ @desc: The name of the URL parameter.
393
+ @type: string
394
+ @name: def
395
+ @desc: The default value to return if the parameter is not found.
396
+ @type: any | null
397
+ @return:
398
+ @desc: The value of the URL parameter or the default value.
399
+ @type: any | null
400
+ */
401
+ url_param(name, def = null) {
402
+ const params = new URLSearchParams(window.location.search);
403
+ const param = params.get(name);
404
+ if (param == null || param === "") {
405
+ return def;
406
+ }
407
+ switch (param.toLowerCase()) {
408
+ case "true": return true;
409
+ case "false": return false;
410
+ case "null": return null;
411
+ default: return param;
412
+ }
413
+ },
414
+ /* @docs:
415
+ @nav: Frontend
416
+ @chapter: Utils
417
+ @title: URL Encode
418
+ @desc: Encode an object into a URL-encoded query string.
419
+ @param:
420
+ @name: params
421
+ @desc: The parameters to encode.
422
+ @type: Record<string, any>
423
+ @return:
424
+ @desc: The URL-encoded query string.
425
+ @type: string
426
+ */
427
+ url_encode(params) {
428
+ const encodedParams = [];
429
+ Object.keys(params).forEach((key) => {
430
+ const encodedKey = encodeURIComponent(key);
431
+ const encodedValue = encodeURIComponent(params[key]);
432
+ encodedParams.push(`${encodedKey}=${encodedValue}`);
433
+ });
434
+ return encodedParams.join('&');
435
+ },
436
+ /* @docs:
437
+ @nav: Frontend
438
+ @chapter: Utils
439
+ @title: Copy to Clipboard
440
+ @desc: Copy text to the clipboard.
441
+ @param:
442
+ @name: text
443
+ @desc: The text to copy.
444
+ @type: string
445
+ @return:
446
+ @desc: A Promise that resolves when the text is copied.
447
+ @type: Promise<void>
448
+ */
449
+ async copy_to_clipboard(text) {
450
+ return new Promise((resolve, reject) => {
451
+ navigator.clipboard.writeText(text)
452
+ .then(() => {
453
+ resolve();
454
+ })
455
+ .catch((err) => {
456
+ reject(err);
457
+ });
458
+ });
459
+ },
460
+ // Get the brightness of a hex color (0.0 white 1.0 dark).
461
+ // @deprecated moved to `Colors`
462
+ hex_brightness(color) {
463
+ // Remove the hash symbol if present
464
+ color = color.replace(/^#/, '');
465
+ // Convert hex to RGB
466
+ const bigint = parseInt(color, 16);
467
+ const r = (bigint >> 16) & 255;
468
+ const g = (bigint >> 8) & 255;
469
+ const b = bigint & 255;
470
+ // Calculate perceived brightness using the relative luminance formula
471
+ const brightness = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
472
+ return brightness;
473
+ },
474
+ // Hex to rgbA.
475
+ // @deprecated moved to `Colors`
476
+ hex_to_rgb(hex) {
477
+ let index = hex.indexOf("#");
478
+ if (index !== -1) {
479
+ hex = hex.substr(index + 1);
480
+ }
481
+ let r = parseInt(hex.substring(0, 2), 16);
482
+ let g = parseInt(hex.substring(2, 4), 16);
483
+ let b = parseInt(hex.substring(4, 6), 16);
484
+ let a = 1;
485
+ if (hex.length > 6) {
486
+ a = parseInt(hex.substring(6, 8)) / 100;
487
+ }
488
+ return { r, g, b, a };
489
+ },
490
+ /* @docs:
491
+ @nav: Frontend
492
+ @chapter: Utils
493
+ @title: Deep copy
494
+ @desc: Perform a deep copy on any type, it does not support classes, only primitive objects.
495
+ @param:
496
+ @name: obj
497
+ @desc: The object to deep copy.
498
+ @type: any
499
+ @return:
500
+ @desc: The deep copied object.
501
+ @type: any
502
+ */
503
+ deep_copy(obj) {
504
+ if (Array.isArray(obj)) {
505
+ const copy = [];
506
+ obj.forEach((item) => {
507
+ copy.push(Utils.deep_copy(item));
508
+ });
509
+ return copy;
510
+ }
511
+ else if (obj !== null && obj instanceof String) {
512
+ return new String(obj.toString());
513
+ }
514
+ else if (obj !== null && typeof obj === "object") {
515
+ const copy = {};
516
+ const keys = Object.keys(obj);
517
+ const values = Object.values(obj);
518
+ for (let i = 0; i < keys.length; i++) {
519
+ copy[keys[i]] = Utils.deep_copy(values[i]);
520
+ }
521
+ return copy;
522
+ }
523
+ else {
524
+ return obj;
525
+ }
526
+ },
527
+ /* @docs:
528
+ @nav: Frontend
529
+ @chapter: Utils
530
+ @title: Request
531
+ @desc: Make an HTTP request with the specified options.
532
+ @param:
533
+ @name: options
534
+ @desc: The request options.
535
+ @type: {
536
+ method?: string,
537
+ url?: string | null,
538
+ data?: any,
539
+ json?: boolean,
540
+ credentials?: 'include' | 'same-origin' | 'omit',
541
+ headers?: Record<string, string>,
542
+ }
543
+ @return:
544
+ @desc: A Promise that resolves with the response data.
545
+ @type: Promise<any>
546
+ */
547
+ request(options) {
548
+ const { method = "GET", url = null, data = null, json = true, credentials = "same-origin", headers = {}, } = options;
549
+ // Set headers.
550
+ // Host and User-Agent headers are restricted and set by the browser itself.
551
+ if (json && data !== null && headers['Content-Type'] == null) {
552
+ headers['Content-Type'] = 'application/json';
553
+ }
554
+ // Handle data.
555
+ let finalUrl = url;
556
+ let bodyData = data !== null ? data : undefined;
557
+ if (data !== null && typeof data === "object") {
558
+ if (method.toUpperCase() === "GET") {
559
+ finalUrl = `${url}?${new URLSearchParams(data).toString()}`;
560
+ bodyData = undefined;
561
+ }
562
+ else {
563
+ // Stringify.
564
+ bodyData = JSON.stringify(data);
565
+ }
566
+ }
567
+ // Define options.
568
+ const fetchOptions = {
569
+ method,
570
+ credentials,
571
+ headers,
572
+ body: bodyData,
573
+ };
574
+ return new Promise((resolve, reject) => {
575
+ fetch(finalUrl, fetchOptions)
576
+ .then(response => {
577
+ // Handle error code.
578
+ if (!response.ok) {
579
+ // Parse as json.
580
+ if (json) {
581
+ const clone = response.clone();
582
+ response.json().then(data => {
583
+ if (data.status === undefined) {
584
+ data.status = response.status;
585
+ }
586
+ reject(data);
587
+ }).catch(err => {
588
+ clone.text()
589
+ .then(data => {
590
+ reject({
591
+ error: data,
592
+ status: response.status
593
+ });
594
+ })
595
+ .catch(text_err => {
596
+ reject({
597
+ error: err,
598
+ status: response.status
599
+ });
600
+ });
601
+ });
602
+ }
603
+ // Reject.
604
+ else {
605
+ reject({
606
+ error: response.statusText,
607
+ status: response.status
608
+ });
609
+ }
610
+ return; // stop.
611
+ }
612
+ // Successful response.
613
+ if (json) {
614
+ response.json().then(data => {
615
+ resolve(data);
616
+ }).catch(err => {
617
+ console.log("Response:", response);
618
+ reject({
619
+ error: 'Failed to parse JSON response: ' + err.message,
620
+ status: response.status
621
+ });
622
+ });
623
+ }
624
+ else {
625
+ response.text().then(data => {
626
+ resolve(data);
627
+ }).catch(err => {
628
+ console.log("Response:", response);
629
+ reject({
630
+ error: 'Failed to parse text response: ' + err.message,
631
+ status: response.status
632
+ });
633
+ });
634
+ }
635
+ })
636
+ .catch(error => {
637
+ reject({ error: error.message }); // Reject with error message if fetch fails
638
+ });
639
+ });
640
+ },
641
+ /*
642
+ request(options: {
643
+ method?: string,
644
+ url?: string | null,
645
+ data?: any,
646
+ async?: boolean,
647
+ success?: (status: number, data: any) => void,
648
+ error?: (status: number, error: any) => void,
649
+ before?: () => void,
650
+ }): Promise<any> {
651
+ // Original commented out implementation.
652
+ }
653
+ */
654
+ /* @docs:
655
+ @nav: Frontend
656
+ @chapter: Utils
657
+ @title: On load
658
+ @desc: Execute a function when the content is loaded, optionally handling a splash screen.
659
+ @param:
660
+ @name: func
661
+ @desc: The function to execute when the content is loaded.
662
+ @type: () => HTMLElement | Promise<HTMLElement> | null
663
+ @return:
664
+ @desc: void
665
+ @type: void
666
+ */
667
+ async on_load(func) {
668
+ // document.addEventListener("DOMContentLoaded", async () => {
669
+ const splash = document.getElementById("__volt_splash_screen");
670
+ if (splash != null) {
671
+ splash.remove();
672
+ }
673
+ let e = func();
674
+ if (e instanceof Promise) {
675
+ try {
676
+ e = await e;
677
+ }
678
+ catch (err) {
679
+ console.error(err);
680
+ return;
681
+ }
682
+ }
683
+ if (e != null && e instanceof HTMLElement) {
684
+ document.body.appendChild(e);
685
+ }
686
+ // });
687
+ },
688
+ /* @docs:
689
+ @nav: Frontend
690
+ @chapter: Utils
691
+ @title: Unix to Date
692
+ @desc: Convert a Unix timestamp in seconds or milliseconds to the user's date format.
693
+ @param:
694
+ @name: unix
695
+ @desc: The Unix timestamp.
696
+ @type: number
697
+ @name: mseconds
698
+ @desc: Optional. Whether the Unix timestamp is in milliseconds.
699
+ @type: boolean | null
700
+ @return:
701
+ @desc: The formatted date string.
702
+ @type: string
703
+ */
704
+ unix_to_date(unix, mseconds = null) {
705
+ // Guess msec or sec.
706
+ if (mseconds === null) {
707
+ // As of now, Unix time in milliseconds is 13 digits and in seconds is 10 digits
708
+ const str = unix.toString();
709
+ if (str.length === 13) {
710
+ mseconds = true;
711
+ }
712
+ else if (str.length === 10) {
713
+ mseconds = false;
714
+ }
715
+ else {
716
+ // Future-proofing: When second-based timestamps eventually reach 11 digits
717
+ if (str.length > 10 && str.length < 13) {
718
+ // Check if adding three zeroes (to simulate milliseconds) results in a plausible future date
719
+ // This is a rough estimation and might not be accurate
720
+ const futureCheck = new Date(parseInt(str + "000", 10));
721
+ if (futureCheck.getFullYear() > new Date().getFullYear() && futureCheck.getFullYear() < 3000) {
722
+ mseconds = false;
723
+ }
724
+ }
725
+ }
726
+ }
727
+ // Format.
728
+ const date = new Date(mseconds ? unix : unix * 1000);
729
+ const lang = navigator.language || navigator.userLanguage;
730
+ const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
731
+ let options = {
732
+ year: "numeric",
733
+ month: "2-digit",
734
+ day: "2-digit",
735
+ timeZone: tz,
736
+ };
737
+ const date_format = new Intl.DateTimeFormat(lang, options).format(date);
738
+ options = {
739
+ hour: "2-digit",
740
+ minute: "2-digit",
741
+ second: "2-digit",
742
+ hour12: lang.toLowerCase().includes("en"),
743
+ timeZone: tz,
744
+ };
745
+ const time_format = new Intl.DateTimeFormat(lang, options).format(date);
746
+ return `${date_format} ${time_format}`;
747
+ },
748
+ /* @docs:
749
+ @nav: Frontend
750
+ @chapter: Utils
751
+ @title: Fuzzy Search
752
+ @description:
753
+ Perform a fuzzy similarity match between a query and an array of targets.
754
+ @type: number
755
+ @return:
756
+ Returns an array with the targets sorted from best match to lowest match, unless parameter `get_matches` is enabled.
757
+ @param:
758
+ @name: query
759
+ @description: The search query.
760
+ @type: string
761
+ @name: targets
762
+ @description:
763
+ The targets to search through.
764
+ When the nested items are objects, define the parameter `key` to specify the query string key.
765
+ When the nested items are arrays, the first value of the array will be used as the query string.
766
+ @type: Array<string | object | any[]>
767
+ @name: limit
768
+ @description: Limit the number of results. Define the limit as `null` or `-1` to set no limit.
769
+ @type: number
770
+ @name: case_match
771
+ @description:
772
+ When the `case_match` flag is enabled, the similarity match is case sensitive.
773
+ @type: boolean
774
+ @name: allow_exceeding_chars
775
+ @description:
776
+ Allow matches where the single character count of the search query exceeds that of the target.
777
+ For example, when the query is "aa" and the target is "a", no match will be given since the "a" count of the target (2) is higher than the query (1).
778
+ @type: boolean
779
+ @name: get_matches
780
+ @description:
781
+ When the `get_matches` flag is enabled, the function returns an array with nested arrays containing the similarity match `[similarity <number>, <target>]`.
782
+ @type: boolean
783
+ @name: key
784
+ @description: The key for the query string when the array's target items are objects. The key may also be an array with keys to use the best match of the key's value.
785
+ @type: string | string[] | null
786
+ @name: nested_key
787
+ @description:
788
+ When the target items are objects and the object may have nested children that also should be searched, define the `nested_key` parameter to specify the key used for the nested children.
789
+ The value for the nested key should also be an array of objects and use the same structure for the `key` parameter, otherwise it will cause undefined behavior.
790
+ The nested key will be ignored if the nested key does not exist in a target object.
791
+ @type: string | null
792
+ */
793
+ fuzzy_search({ query, targets = [], limit = 25, case_match = false, allow_exceeding_chars = true, get_matches = false, key = null, nested_key = null, }) {
794
+ // Checks.
795
+ if (query == null) {
796
+ throw new Error("Define parameter \"query\".");
797
+ }
798
+ // Vars.
799
+ const is_obj = targets.length > 0 && typeof targets[0] === "object" && !Array.isArray(targets[0]);
800
+ const is_array = targets.length > 0 && Array.isArray(targets[0]);
801
+ if (is_obj && key == null) {
802
+ key = "query";
803
+ }
804
+ const is_key_array = Array.isArray(key);
805
+ const results = [];
806
+ if (!case_match) {
807
+ query = query.toLowerCase();
808
+ }
809
+ // Calculate the similarities.
810
+ const calc_sims = (current_targets = []) => {
811
+ current_targets.forEach(target => {
812
+ let match;
813
+ if (is_array) {
814
+ match = Utils.fuzzy_match(query, case_match ? target[0] : (typeof target[0] === 'string' ? target[0].toLowerCase() : target[0]), allow_exceeding_chars);
815
+ }
816
+ else if (is_obj) {
817
+ if (is_key_array && Array.isArray(key)) {
818
+ let min_match = null;
819
+ key.forEach(k => {
820
+ if (target[k] == null) {
821
+ return;
822
+ }
823
+ const current_match = Utils.fuzzy_match(query, case_match ? target[k] : (typeof target[k] === 'string' ? target[k].toLowerCase() : target[k]), allow_exceeding_chars);
824
+ if (current_match != null && (min_match === null || current_match < min_match)) {
825
+ min_match = current_match;
826
+ }
827
+ });
828
+ match = min_match;
829
+ }
830
+ else {
831
+ if (target[key] == null) {
832
+ return;
833
+ }
834
+ match = Utils.fuzzy_match(query, case_match ? target[key] : (typeof target[key] === 'string' ? target[key].toLowerCase() : target[key]), allow_exceeding_chars);
835
+ }
836
+ if (nested_key !== null && target[nested_key] != null) {
837
+ calc_sims(target[nested_key]);
838
+ }
839
+ }
840
+ else {
841
+ if (target == null) {
842
+ return;
843
+ }
844
+ match = Utils.fuzzy_match(query, case_match ? target : (typeof target === 'string' ? target.toLowerCase() : target), allow_exceeding_chars);
845
+ }
846
+ if (match !== null) {
847
+ results.push([match, target]);
848
+ }
849
+ });
850
+ };
851
+ // Calculate the similarities.
852
+ calc_sims(targets);
853
+ // Sort the results.
854
+ results.sort((a, b) => a[0] - b[0]); // Lower score is better
855
+ // Limit the results.
856
+ if (limit !== null && limit >= 0 && results.length > limit) {
857
+ results.length = limit;
858
+ }
859
+ // Convert the results to targets only.
860
+ if (!get_matches) {
861
+ return results.map(item => item[1]);
862
+ }
863
+ // Return the results.
864
+ return results;
865
+ },
866
+ /* @docs:
867
+ @nav: Frontend
868
+ @chapter: Utils
869
+ @title: Fuzzy Match
870
+ @desc: Perform a fuzzy similarity match between a query and a target.
871
+ @param:
872
+ @name: search
873
+ @desc: The search query.
874
+ @type: string
875
+ @name: target
876
+ @desc: The target string.
877
+ @type: string
878
+ @name: allow_exceeding_chars
879
+ @desc:
880
+ Allow matches where the single character count of the search query exceeds that of the target.
881
+ So when the query is "aa" and the target is "a" then no match will be given since the "a" count of the target (2) is higher than the query (1).
882
+ The function returns `null` when this flag is enabled and detected.
883
+ @type: boolean
884
+ @return:
885
+ @desc: Returns a floating number indicating the similarity; a lower value represents a better match.
886
+ @type: number | null
887
+ */
888
+ fuzzy_match(search, target, allow_exceeding_chars = true) {
889
+ // Check exceeding chars.
890
+ if (!allow_exceeding_chars) {
891
+ // Exceeding length.
892
+ if (search.length > target.length) {
893
+ return null;
894
+ }
895
+ // Create the target count.
896
+ const text_count = {};
897
+ for (let i = 0; i < target.length; i++) {
898
+ const c = target.charAt(i);
899
+ text_count[c] = (text_count[c] || 0) + 1;
900
+ }
901
+ // Create the query count.
902
+ const query_count = {};
903
+ for (let i = 0; i < search.length; i++) {
904
+ const c = search.charAt(i);
905
+ query_count[c] = (query_count[c] || 0) + 1;
906
+ if (text_count[c] == null || query_count[c] > text_count[c]) {
907
+ return null;
908
+ }
909
+ }
910
+ }
911
+ // Wrappers.
912
+ const get_search_code = (index) => {
913
+ if (index >= 0 && index < search.length) {
914
+ return search.charCodeAt(index);
915
+ }
916
+ return -1;
917
+ };
918
+ const get_target_code = (index) => {
919
+ if (index >= 0 && index < target.length) {
920
+ return target.charCodeAt(index);
921
+ }
922
+ return -1;
923
+ };
924
+ const prepareBeginningIndexes = (targetStr) => {
925
+ const targetLen = targetStr.length;
926
+ const beginningIndexes = [];
927
+ let wasUpper = false;
928
+ let wasAlphanum = false;
929
+ for (let i = 0; i < targetLen; ++i) {
930
+ const targetCode = targetStr.charCodeAt(i);
931
+ const isUpper = targetCode >= 65 && targetCode <= 90;
932
+ const isAlphanum = isUpper || (targetCode >= 97 && targetCode <= 122) || (targetCode >= 48 && targetCode <= 57);
933
+ const isBeginning = (isUpper && !wasUpper) || !wasAlphanum || !isAlphanum;
934
+ wasUpper = isUpper;
935
+ wasAlphanum = isAlphanum;
936
+ if (isBeginning)
937
+ beginningIndexes.push(i);
938
+ }
939
+ return beginningIndexes;
940
+ };
941
+ const prepareNextBeginningIndexes = (targetStr) => {
942
+ const targetLen = targetStr.length;
943
+ const beginningIndexes = prepareBeginningIndexes(targetStr);
944
+ const nextBeginningIndexes = [];
945
+ let lastIsBeginning = beginningIndexes[0];
946
+ let lastIsBeginningI = 0;
947
+ for (let i = 0; i < targetLen; ++i) {
948
+ if (lastIsBeginning > i) {
949
+ nextBeginningIndexes[i] = lastIsBeginning;
950
+ }
951
+ else {
952
+ lastIsBeginning = beginningIndexes[++lastIsBeginningI];
953
+ nextBeginningIndexes[i] = lastIsBeginning === undefined ? targetLen : lastIsBeginning;
954
+ }
955
+ }
956
+ return nextBeginningIndexes;
957
+ };
958
+ // Vars.
959
+ let searchI = 0;
960
+ const searchLen = search.length;
961
+ let searchCode = get_search_code(searchI);
962
+ let searchLower = search.toLowerCase();
963
+ let targetI = 0;
964
+ const targetLen = target.length;
965
+ let targetCode = get_target_code(targetI);
966
+ const targetLower = target.toLowerCase();
967
+ const matchesSimple = [];
968
+ let matchesSimpleLen = 0;
969
+ let successStrict = false;
970
+ const matchesStrict = [];
971
+ let matchesStrictLen = 0;
972
+ // Very basic fuzzy match; to remove non-matching targets ASAP!
973
+ // Walk through target. Find sequential matches.
974
+ // If all chars aren't found then exit
975
+ while (true) {
976
+ const isMatch = searchCode === get_target_code(targetI);
977
+ if (isMatch) {
978
+ matchesSimple[matchesSimpleLen++] = targetI;
979
+ searchI++;
980
+ if (searchI === searchLen)
981
+ break;
982
+ searchCode = get_search_code(searchI);
983
+ }
984
+ targetI++;
985
+ if (targetI >= targetLen) {
986
+ return null; // Failed to find searchI
987
+ }
988
+ }
989
+ searchI = 0;
990
+ targetI = 0;
991
+ const nextBeginningIndexes = prepareNextBeginningIndexes(target);
992
+ targetI = matchesSimple[0] === 0 ? 0 : (nextBeginningIndexes[matchesSimple[0] - 1] || 0);
993
+ // More advanced and strict test to improve the score
994
+ let backtrackCount = 0;
995
+ if (targetI !== targetLen) {
996
+ while (true) {
997
+ if (targetI >= targetLen) {
998
+ // We failed to find a good spot for this search char, go back to the previous search char and force it forward
999
+ if (searchI <= 0)
1000
+ break; // We failed to push chars forward for a better match
1001
+ backtrackCount++;
1002
+ if (backtrackCount > 200)
1003
+ break; // Prevent excessive backtracking
1004
+ searchI--;
1005
+ const lastMatch = matchesStrict[--matchesStrictLen];
1006
+ targetI = nextBeginningIndexes[lastMatch] || 0;
1007
+ }
1008
+ else {
1009
+ const isMatch = get_search_code(searchI) === get_target_code(targetI);
1010
+ if (isMatch) {
1011
+ matchesStrict[matchesStrictLen++] = targetI;
1012
+ searchI++;
1013
+ if (searchI === searchLen) {
1014
+ successStrict = true;
1015
+ break;
1016
+ }
1017
+ targetI++;
1018
+ }
1019
+ else {
1020
+ targetI = nextBeginningIndexes[targetI] || targetLen;
1021
+ }
1022
+ }
1023
+ }
1024
+ }
1025
+ // Check if it's a substring match
1026
+ const substringIndex = targetLower.indexOf(searchLower, matchesSimple[0]); // Performance: this is slow
1027
+ const isSubstring = substringIndex !== -1;
1028
+ let isSubstringBeginning = false;
1029
+ if (isSubstring && !successStrict) { // Rewrite the indexes from basic to the substring
1030
+ for (let i = 0; i < matchesSimpleLen; ++i) {
1031
+ matchesSimple[i] = substringIndex + i;
1032
+ }
1033
+ }
1034
+ if (isSubstring) {
1035
+ isSubstringBeginning = nextBeginningIndexes[substringIndex - 1] === substringIndex;
1036
+ }
1037
+ // Tally up the score & keep track of matches for highlighting later
1038
+ let score = 0;
1039
+ let matchesBest;
1040
+ let matchesBestLen;
1041
+ if (successStrict) {
1042
+ matchesBest = matchesStrict;
1043
+ matchesBestLen = matchesStrictLen;
1044
+ }
1045
+ else {
1046
+ matchesBest = matchesSimple;
1047
+ matchesBestLen = matchesSimpleLen;
1048
+ }
1049
+ let extraMatchGroupCount = 0;
1050
+ for (let i = 1; i < searchLen; ++i) {
1051
+ if (matchesBest[i] - matchesBest[i - 1] !== 1) {
1052
+ score -= matchesBest[i];
1053
+ extraMatchGroupCount++;
1054
+ }
1055
+ }
1056
+ const unmatchedDistance = matchesBest[searchLen - 1] - matchesBest[0] - (searchLen - 1);
1057
+ score -= (12 + unmatchedDistance) * extraMatchGroupCount; // Penalty for more groups
1058
+ if (matchesBest[0] !== 0)
1059
+ score -= Math.pow(matchesBest[0], 2) * 0.2; // Penalty for not starting near the beginning
1060
+ if (!successStrict) {
1061
+ score *= 1000;
1062
+ }
1063
+ else {
1064
+ // successStrict on a target with too many beginning indexes loses points for being a bad target
1065
+ let uniqueBeginningIndexes = 1;
1066
+ for (let i = nextBeginningIndexes[0]; i < targetLen; i = nextBeginningIndexes[i]) {
1067
+ uniqueBeginningIndexes++;
1068
+ }
1069
+ if (uniqueBeginningIndexes > 24)
1070
+ score *= (uniqueBeginningIndexes - 24) * 10; // Arbitrary penalty
1071
+ }
1072
+ if (isSubstring)
1073
+ score /= 1 + Math.pow(searchLen, 2); // Bonus for being a full substring
1074
+ if (isSubstringBeginning)
1075
+ score /= 1 + Math.pow(searchLen, 2); // Bonus for substring starting on a beginningIndex
1076
+ score -= targetLen - searchLen; // Penalty for longer targets
1077
+ return score;
1078
+ },
1079
+ /* @docs:
1080
+ @nav: Frontend
1081
+ @chapter: Utils
1082
+ @title: Debounce
1083
+ @desc: Create a debounced version of a function that delays invoking it until after a specified delay.
1084
+ @param:
1085
+ @name: delay
1086
+ @desc: The number of milliseconds to delay.
1087
+ @type: number
1088
+ @name: func
1089
+ @desc: The function to debounce.
1090
+ @type: (...args: any[]) => void
1091
+ @return:
1092
+ @desc: The debounced function.
1093
+ @type: (...args: any[]) => void
1094
+ */
1095
+ debounce(delay, func) {
1096
+ let timeout;
1097
+ return function (...args) {
1098
+ if (timeout !== undefined) {
1099
+ clearTimeout(timeout);
1100
+ }
1101
+ timeout = window.setTimeout(() => func.apply(this, args), delay);
1102
+ };
1103
+ },
1104
+ // Create the on render observer.
1105
+ on_render_observer: new ResizeObserver((entries, observer) => {
1106
+ entries.forEach(entry => {
1107
+ const target = entry.target;
1108
+ if (!target.rendered) {
1109
+ target._on_render_callbacks.iterate((func) => { func(entry.target); });
1110
+ target.rendered = true;
1111
+ Utils.on_render_observer.unobserve(entry.target);
1112
+ }
1113
+ });
1114
+ }),
1115
+ // Create the on resize observer.
1116
+ on_resize_observer: new ResizeObserver((entries, observer) => {
1117
+ entries.forEach(entry => {
1118
+ entry.target._on_resize_callbacks.iterate((func) => { func(entry.target); });
1119
+ });
1120
+ }),
1121
+ // Aggregate multiple classes into a single class, can be used to extend more than one class.
1122
+ // aggregate(
1123
+ // BaseClass: new (...args: any[]) => any,
1124
+ // ...Mixins: Array<new (...args: any[]) => any>
1125
+ // ) {
1126
+ // class AggregatedClass extends BaseClass {
1127
+ // constructor(...args: any[]) {
1128
+ // super(...args);
1129
+ // // Additional initialization if needed
1130
+ // }
1131
+ // }
1132
+ // // Copy methods and properties from mixin classes to the AggregatedClass prototype
1133
+ // Mixins.forEach(MixinClass => {
1134
+ // // Copy instance methods and properties
1135
+ // Object.getOwnPropertyNames(MixinClass.prototype).forEach(name => {
1136
+ // if (name !== 'constructor') {
1137
+ // Object.defineProperty(
1138
+ // AggregatedClass.prototype,
1139
+ // name,
1140
+ // Object.getOwnPropertyDescriptor(MixinClass.prototype, name)!
1141
+ // );
1142
+ // }
1143
+ // });
1144
+ // // Copy static methods and properties if needed
1145
+ // Object.getOwnPropertyNames(MixinClass).forEach(name => {
1146
+ // if (name !== 'prototype' && name !== 'name' && name !== 'length') {
1147
+ // Object.defineProperty(
1148
+ // AggregatedClass,
1149
+ // name,
1150
+ // Object.getOwnPropertyDescriptor(MixinClass, name)!
1151
+ // );
1152
+ // }
1153
+ // });
1154
+ // });
1155
+ // return AggregatedClass;
1156
+ // },
1157
+ };
1158
+ // Export.
1159
+ export { Utils };