@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,1049 @@
1
+ /*
2
+ * Author: Daan van den Bergh
3
+ * Copyright: © 2022 - 2024 Daan van den Bergh.
4
+ */
5
+
6
+ // @exports: CodeBlockElement, CodeBlock, CodePreElement, CodePre, CodeLineElement, CodeLine, MultiLanguageCodeBlockElement, MultiLanguageCodeBlock
7
+
8
+ // Imports.
9
+ import { Utils } from "../modules/utils.js"
10
+ import { Elements, VElementTagMap, VHTMLElement, VPreElement, VSpanElement, VDiv, VDivElement } from "../elements/module.js"
11
+ import { Span } from "./span"
12
+ import { VStack, VStackElement, HStack, HStackElement } from "./stack"
13
+ import { ImageMaskElement, ImageMask } from "./image"
14
+ import { ForEach } from "./for_each"
15
+ import { Spacer } from "./spacer"
16
+ import { DividerElement, Divider } from "./divider"
17
+
18
+ // import * as vhighlight from "/Users/administrator/persistance/private/dev/vinc/vhighlight"
19
+ import * as vhighlight from "vhighlight"
20
+
21
+ // All codeblocks using languages.
22
+ const language_codeblocks = [];
23
+
24
+ // CodeBlock.
25
+ @Elements.register
26
+ export class CodeBlockElement extends VElementTagMap.code {
27
+
28
+ static default_style = {
29
+ "display": "flex",
30
+ "flex-direction": "column",
31
+ "margin": "0px 0px 0px 0px",
32
+ "padding": "15px 20px 15px 20px",
33
+ "text-align": "start",
34
+ "white-space": "pre",
35
+ "font-family": "'Menlo', 'Consolas', monospace",
36
+ "font-size": "13px",
37
+ "font-weight": "500",
38
+ "line-height": "18px",
39
+ "border-radius": "15px",
40
+ "color": "#FFFFFF",
41
+ "background": "#262F3D",
42
+ "overflow": "hidden", // only the content should scroll so the header remains fixed.
43
+ "width": "100%",
44
+ "min-width": "100%",
45
+ "--header-color": "inherit",
46
+ "--header-border": "#00000010",
47
+ "--header-background": "inherit",
48
+ "--selected-language-color": "inherit",
49
+ };
50
+
51
+ // Attributes.
52
+ public language?: string;
53
+ public line_numbers?: boolean;
54
+ public line_divider?: boolean;
55
+ // @ts-expect-error
56
+ public animate?: boolean;
57
+ // @ts-expect-error
58
+ public delay?: number;
59
+ // @ts-expect-error
60
+ public duration?: number;
61
+ public already_highlighted?: boolean;
62
+ public opts?: Record<string, any>;
63
+
64
+ public pre: CodePreElement;
65
+ public lines: VDivElement;
66
+ public lines_divider: VDivElement;
67
+ // @ts-expect-error
68
+ public content: HStackElement;
69
+
70
+ // Constructor.
71
+ constructor(code_or_opts: string | {
72
+ code: string,
73
+ language?: string,
74
+ line_numbers: boolean,
75
+ line_divider: boolean,
76
+ animate: boolean,
77
+ delay: number,
78
+ duration?: number,
79
+ already_highlighted: boolean,
80
+ opts: Record<string, any>,
81
+ } = {
82
+ code: "", // the code data.
83
+ language: undefined, // the language.
84
+ line_numbers: false, // enable line numbers.
85
+ line_divider: true, // enable the line divider, only an option when line numbers are enabled.
86
+ animate: false, // animate code writing.
87
+ delay: 25, // animation delay in milliseconds, only used when animatinos are enabled.
88
+ duration: undefined, // animation duration in milliseconds, only used when animatinos are enabled.
89
+ already_highlighted: false, // can be used to indicate the code is already highlighted.
90
+ opts: {}, // special args of the language's tokenizer constructor.
91
+ }) {
92
+
93
+ // Initialize base class.
94
+ super({
95
+ derived: CodeBlockElement,
96
+ });
97
+
98
+ // Attributes.
99
+ let code = code_or_opts;
100
+ this.language = undefined;
101
+ this.line_numbers = false;
102
+ this.line_divider = true;
103
+ this.animate = false
104
+ this.delay = 25
105
+ this.duration = undefined
106
+ this.already_highlighted = false;
107
+ this.opts = {};
108
+ if (typeof code_or_opts === "object") {
109
+ if (code_or_opts.code !== undefined) { code = code_or_opts.code; }
110
+ if (code_or_opts.language !== undefined) { this.language = code_or_opts.language; }
111
+ if (code_or_opts.line_numbers !== undefined) { this.line_numbers = code_or_opts.line_numbers; }
112
+ if (code_or_opts.line_divider !== undefined) { this.line_divider = code_or_opts.line_divider; }
113
+ if (code_or_opts.already_highlighted !== undefined) { this.already_highlighted = code_or_opts.already_highlighted; }
114
+ if (code_or_opts.animate !== undefined) { this.animate = code_or_opts.animate; }
115
+ if (code_or_opts.delay !== undefined) { this.delay = code_or_opts.delay; }
116
+ if (code_or_opts.duration !== undefined) { this.duration = code_or_opts.duration; }
117
+ if (code_or_opts.opts !== undefined) { this.opts = code_or_opts.opts; }
118
+ }
119
+
120
+ // Code per language.
121
+ if (typeof code === "object") {
122
+ console.warn("This behaviour is deprecated., use MultiLanguageCodeBlock instead.");
123
+ code = "";
124
+ } else {
125
+ code = code.trim();
126
+ }
127
+
128
+ // Code pre.
129
+ this.pre = CodePre(code as unknown as string)
130
+ .parent(this)
131
+ .color("inherit")
132
+ .font("inherit")
133
+ .background("none")
134
+ .border_radius(0)
135
+ .padding(0)
136
+ .margin(0)
137
+ .stretch(true)
138
+ .overflow("visible")
139
+ .line_height("inherit")
140
+
141
+ // Line numbers.
142
+ this.lines = VDiv()
143
+ .parent(this)
144
+ .color("var(--vhighlight-token-comment)")
145
+ .font("inherit")
146
+ .white_space("pre")
147
+ .line_height("inherit")
148
+ .flex_shrink(0)
149
+ .hide()
150
+
151
+ // Line numbers divider.
152
+ this.lines_divider = VDiv()
153
+ .parent(this)
154
+ .background("var(--vhighlight-token-comment)")
155
+ .fixed_width(0.5)
156
+ .flex_shrink(0)
157
+ .fixed_height("calc(100% - 6px)")
158
+ .margin(3, 10, 0, 10)
159
+ .hide()
160
+
161
+ // The content.
162
+ this.content = HStack(this.lines, this.lines_divider, this.pre)
163
+ .parent(this)
164
+ .padding(CodeBlockElement.default_style.padding)
165
+ .flex_wrap("nowrap")
166
+ .overflow("auto visible")
167
+
168
+ // Append code pre.
169
+ this.append(
170
+ this.content,
171
+ );
172
+
173
+ // Set padding.
174
+ this.padding(0)
175
+
176
+
177
+ }
178
+
179
+ // Hide/show the scrollbar.
180
+ hide_scrollbar(): this {
181
+ this.content.classList.add("hide_scrollbar");
182
+ return this;
183
+ }
184
+ show_scrollbar(): this {
185
+ this.content.classList.remove("hide_scrollbar");
186
+ return this;
187
+ }
188
+
189
+ // Show.
190
+ show() : this {
191
+ this.style.display = "flex";
192
+ return this;
193
+ }
194
+
195
+ // Highlight code.
196
+ highlight({
197
+ code, // only required if the code was not provided by the constructor.
198
+ language, // code language, precedes element attribute "language".
199
+ line_numbers, // show line numbers.
200
+ line_divider, // show line numbers divider.
201
+ animate, // animate code writing.
202
+ delay, // animation delay in milliseconds, only used when animatinos are enabled.
203
+ duration, // animation duration in milliseconds, only used when animatinos are enabled.
204
+ opts, // special args of the language's tokenizer constructor.
205
+ }: {
206
+ code?: string,
207
+ language?: string,
208
+ line_numbers?: boolean,
209
+ line_divider?: boolean,
210
+ animate?: boolean,
211
+ delay?: number,
212
+ duration?: number,
213
+ opts?: Record<string, any>,
214
+ } = {}) : this {
215
+
216
+ // Update attributes.
217
+ if (language == null) { language = this.language; }
218
+ if (line_numbers == null) { line_numbers = this.line_numbers; }
219
+ if (line_divider == null) { line_divider = this.line_divider; }
220
+ if (animate == null) { animate = this.animate; }
221
+ if (delay == null) { delay = this.delay; }
222
+ if (duration == null) { duration = this.duration; }
223
+ if (opts == null) { opts = this.opts; }
224
+
225
+ // Highlight.
226
+ this.pre.highlight({
227
+ code: code,
228
+ language: language,
229
+ animate: animate,
230
+ delay: delay,
231
+ duration: duration,
232
+ opts: opts,
233
+ _post_tokenized_callback: !line_numbers ? undefined : (tokens) => {
234
+
235
+ // Set line numbers.
236
+ this.lines.show();
237
+ this.lines_divider.show();
238
+ if (line_divider) {
239
+ this.lines_divider.fixed_width(1);
240
+ this.lines_divider.margin(3, 10, 0, 10)
241
+ } else {
242
+ this.lines_divider.fixed_width(0);
243
+ this.lines_divider.margin(3, 12.5, 0, 12.5)
244
+ }
245
+ let html = "";
246
+ for (var i = 0; i < tokens.length; i++) {
247
+ html += `${(i + 1)}\n`;
248
+ }
249
+ this.lines.innerHTML = html;
250
+ this.lines_divider.min_height(this.lines.offsetHeight - 6)
251
+
252
+ },
253
+ })
254
+
255
+ // Response.
256
+ return this;
257
+ }
258
+ }
259
+ export const CodeBlock = Elements.wrapper(CodeBlockElement);
260
+ export const NullCodeBlock = Elements.create_null(CodeBlockElement);
261
+ declare module './any_element.d.ts' { interface AnyElementMap { CodeBlockElement: CodeBlockElement }}
262
+
263
+ // CodePre.
264
+ @Elements.register
265
+ export class CodePreElement extends VElementTagMap.pre {
266
+
267
+ static default_style = {
268
+ "margin": "0px 0px 0px 0px",
269
+ "padding": "15px 20px 15px 20px",
270
+ "text-align": "start",
271
+ "white-space": "pre",
272
+ "font-family": "'Menlo', 'Consolas', monospace",
273
+ "font-size": "13px",
274
+ "font-weight": "500",
275
+ "line-height": "16px",
276
+ "border-radius": "15px",
277
+ "color": "#FFFFFF",
278
+ "background": "#262F3D",
279
+ "tab-size": 4,
280
+ "overflow": "scroll visible",
281
+ }
282
+
283
+ // Attributes.
284
+ public code: string;
285
+ public tokens: any = null;
286
+ public allow_animation: any;
287
+ public animate_promise: any;
288
+ public tokenizer: any;
289
+ public language: string = "";
290
+
291
+ // Constructor.
292
+ constructor(code: string = "") {
293
+
294
+ // Initialize base class.
295
+ super({
296
+ derived: CodePreElement,
297
+ });
298
+
299
+ // Attributes.
300
+ this.code = code;
301
+
302
+ // Set code.
303
+ if (this.code != null) {
304
+ while (this.code.length > 0 && this.code[this.code.length - 1] == "\n") {
305
+ this.code = this.code.slice(-this.code.length, -1);
306
+ }
307
+ this.text(this.code);
308
+ }
309
+
310
+ }
311
+
312
+ // Animate writing.
313
+ // @note cant use attribute for highlighted code since that may be edited inside `highlight()` while the animation is still busy and otherwise highlight would need to be an sync func, but it has to return this, not a promise.
314
+ async animate_writing({
315
+ code,
316
+ delay = 25,
317
+ duration = undefined,
318
+ }: {
319
+ code: string,
320
+ delay?: number,
321
+ duration?: number,
322
+ }): Promise<void> {
323
+
324
+ // Check highlighted code.
325
+ if (code == null) {
326
+ throw Error(`The code must be highlighted first using "highlight()".`)
327
+ }
328
+
329
+ // Cancel animation.
330
+ await this.cancel_animation();
331
+
332
+ // Start animation.
333
+ this.innerHTML = "";
334
+ this.allow_animation = true;
335
+ this.animate_promise = new Promise((resolve): any => {
336
+
337
+ // Set delay based on duration.
338
+ if (duration != null) {
339
+ delay = duration / code.length;
340
+ }
341
+
342
+ // Set the min height otherwise the height expands while scrolling while the writing is animated then this can created unwanted behviour when scrolling up.
343
+ const computed = window.getComputedStyle(this as any);
344
+ this.style.minHeight = `${parseFloat(computed.paddingTop) + parseFloat(computed.paddingBottom) + parseFloat(computed.lineHeight) * this.tokens.length}px`;
345
+
346
+ // Reset content.
347
+ this.innerHTML = "";
348
+
349
+ // Check html entity.
350
+ const check_html_entity = (index) => {
351
+ let entity = "&", entity_last_index;
352
+ for (let i = index + 1; i < index + 1 + 5; i++) {
353
+ entity += code.charAt(i);
354
+ if (code.charAt(i) === ";") {
355
+ entity_last_index = i;
356
+ break;
357
+ }
358
+ }
359
+ return {entity, entity_last_index};
360
+ }
361
+
362
+ // Add char.
363
+ const add_char = (index): any => {
364
+
365
+ // Stop.
366
+ if (this.allow_animation !== true) {
367
+ resolve(undefined)
368
+ return ;
369
+ }
370
+
371
+ // Animation finished.
372
+ else if (index >= code.length) {
373
+ resolve(undefined)
374
+ return ;
375
+ }
376
+
377
+ // Animate.
378
+ else {
379
+
380
+ // Span opening.
381
+ if (code.charAt(index) === '<') {
382
+
383
+ // Fins span open, close and code.
384
+ let span_index;
385
+ let span_open = "";
386
+ let span_close = "";
387
+ let span_code = "";
388
+ let open = true;
389
+ let first = true;
390
+ let recursive = false;
391
+ for (span_index = index; span_index < code.length; span_index++) {
392
+ if (this.allow_animation !== true) {
393
+ return ;
394
+ }
395
+ let char = code.charAt(span_index);
396
+
397
+ // Add html entities in one batch.
398
+ if (char === "&") {
399
+ let {entity, entity_last_index} = check_html_entity(span_index)
400
+ if (entity_last_index !== undefined) {
401
+ char = entity;
402
+ span_index = entity_last_index;
403
+ }
404
+ }
405
+
406
+ // Already open or start of opening.
407
+ if (char == '<' || open) {
408
+ open = true;
409
+ if (first) {
410
+ span_open += char;
411
+ } else {
412
+ span_close += char;
413
+ }
414
+ if (char == '>') {
415
+ open = false;
416
+ if (first) {
417
+ first = false;
418
+ continue;
419
+ }
420
+
421
+ // Animate span code writing.
422
+ let before = this.innerHTML;
423
+ let added_span_code = "";
424
+ const add_span_code = (index) => {
425
+ if (index < span_code.length) {
426
+ added_span_code += span_code[index]
427
+ let add = before;
428
+ add += span_open;
429
+ add += added_span_code;
430
+ add += span_close;
431
+ this.innerHTML = add;
432
+ setTimeout(() => add_span_code(index + 1), delay);
433
+ } else {
434
+ recursive = true;
435
+ setTimeout(() => add_char(span_index + 1), delay);
436
+ }
437
+ }
438
+ add_span_code(0)
439
+
440
+ // Stop.
441
+ break;
442
+ }
443
+ }
444
+
445
+ // Add non span code.
446
+ else {
447
+ span_code += char;
448
+ }
449
+
450
+ }
451
+ if (recursive === false && span_index === code.length) {
452
+ resolve(undefined)
453
+ }
454
+ }
455
+
456
+ // Non span code.
457
+ else {
458
+
459
+ // Set char.
460
+ let char = code.charAt(index);
461
+
462
+ // Add html entities in one batch.
463
+ if (char === "&") {
464
+ let {entity, entity_last_index} = check_html_entity(index)
465
+ if (entity_last_index !== undefined) {
466
+ char = entity;
467
+ index = entity_last_index;
468
+ }
469
+ }
470
+
471
+ // Default.
472
+ this.innerHTML += char;
473
+ setTimeout(() => add_char(index + 1), delay);
474
+ }
475
+ }
476
+ }
477
+
478
+ // Start animation.
479
+ add_char(0);
480
+
481
+ })
482
+
483
+ // Response.
484
+ return this.animate_promise;
485
+ }
486
+
487
+ // Cancel animation.
488
+ async cancel_animation(): Promise<void> {
489
+ if (this.animate_promise != null) {
490
+ this.allow_animation = false;
491
+ await this.animate_promise;
492
+ this.animate_promise = null;
493
+ }
494
+ }
495
+
496
+ // Highlight.
497
+ highlight({
498
+ code = undefined, // only required if the code was not provided by the constructor.
499
+ language = undefined, // code language, precedes element attribute "language".
500
+ animate = false, // animate code writing.
501
+ delay = 25, // animation delay in milliseconds, only used when animatinos are enabled.
502
+ duration = undefined, // animation duration in milliseconds, only used when animatinos are enabled.
503
+ opts = {}, // special args of the language's tokenizer constructor.
504
+ _post_tokenized_callback = undefined,
505
+ }: {
506
+ code?: string,
507
+ language?: string,
508
+ animate?: boolean,
509
+ delay?: number,
510
+ duration?: number,
511
+ opts?: Record<string, any>
512
+ _post_tokenized_callback?: Function,
513
+ } = {}) {
514
+
515
+ console.log("> Highlight")
516
+
517
+ // Vars.
518
+ if (code != null) {
519
+ this.code = code;
520
+ while (this.code.length > 0 && this.code[this.code.length - 1] == "\n") {
521
+ this.code = this.code.slice(-this.code.length, -1);
522
+ }
523
+ // this.code = this.code.replaceAll("<", "&lt;").replaceAll(">", "&gt;") // this causees errors when the CodeBlock uses multi languages for a single block.
524
+ this.innerHTML = code;
525
+ }
526
+ if (language != null) {
527
+ this.language = language;
528
+ }
529
+
530
+ // Stop when no language is defined.
531
+ if (this.language === "" || this.language == null) {
532
+ return this;
533
+ }
534
+
535
+ // Cancel previous animation.
536
+ this.cancel_animation()
537
+ .then(() => {
538
+
539
+ console.log("> Cancelled animation")
540
+
541
+ // Get tokenizer.
542
+ this.tokenizer = vhighlight.init_tokenizer(this.language, opts);
543
+ if (this.tokenizer == null) {
544
+ return this;
545
+ }
546
+
547
+ // Get the tokens.
548
+ this.tokenizer.code = this.code;
549
+ this.tokens = this.tokenizer.tokenize();
550
+
551
+
552
+
553
+ // Build the html.
554
+ const highlighted_code = this.tokenizer.build_html(this.tokens);
555
+
556
+ console.log("> Highlighted:",highlighted_code)
557
+
558
+ // Post tokenize callback.
559
+ if (_post_tokenized_callback != null) {
560
+ _post_tokenized_callback(this.tokens);
561
+ }
562
+
563
+ // Set code.
564
+ if (animate == true) {
565
+ this.animate_writing({code: highlighted_code, delay, duration})
566
+ } else {
567
+ this.innerHTML = highlighted_code;
568
+ }
569
+ })
570
+
571
+ // Response.
572
+ return this;
573
+ }
574
+ }
575
+ export const CodePre = Elements.wrapper(CodePreElement);
576
+ export const NullCodePre = Elements.create_null(CodePreElement);
577
+ declare module './any_element.d.ts' { interface AnyElementMap { CodePreElement: CodePreElement }}
578
+
579
+ // CodeLine.
580
+ /* @docs:
581
+ @nav: Frontend
582
+ @chapter: Elements
583
+ @title: Code Line
584
+ @description: Create an inline code line element.
585
+ @param:
586
+ @name: text
587
+ @type: string
588
+ @descr: The code line content.
589
+ */
590
+ @Elements.register
591
+ export class CodeLineElement extends VElementTagMap.span {
592
+
593
+ static default_style = {
594
+ "font-family": "\"Menlo\", \"Consolas\", monospace",
595
+ "font-size": "0.90em",
596
+ "font-style": "italic",
597
+ "background": "#000000",
598
+ "color": "#FFFFFF",
599
+ "border-radius": "10px",
600
+ "white-space": "pre",
601
+ "padding": "2.5px 7.5px 2.5px 7.5px",
602
+ };
603
+
604
+ // Constructor.
605
+ constructor(text?: string) {
606
+
607
+ // Initialize base class.
608
+ super({
609
+ derived: CodeLineElement,
610
+ });
611
+
612
+ // Set text.
613
+ if (text) { this.inner_html(text); }
614
+
615
+ }
616
+
617
+ /* @docs:
618
+ @title: Fill
619
+ @descr: Fill a string with markdown style codeline elements.
620
+ */
621
+ static fill(text, codeline_callback = () => CodeLine()): string {
622
+ // Fill code line's.
623
+ if (text.indexOf("`") !== -1) {
624
+ const split = text.split("`");
625
+ let is_code = false;
626
+ let filled = "";
627
+ for (let i = 0; i < split.length; i++) {
628
+ if (is_code) {
629
+ filled += codeline_callback().inner_html(split[i]);
630
+ } else {
631
+ filled += split[i];
632
+ }
633
+ is_code = !is_code;
634
+ }
635
+ text = filled;
636
+ }
637
+ return text;
638
+ }
639
+ }
640
+ export const CodeLine = Elements.wrapper(CodeLineElement);
641
+ export const NullCodeLine = Elements.create_null(CodeLineElement);
642
+ declare module './any_element.d.ts' { interface AnyElementMap { CodeLineElement: CodeLineElement }}
643
+
644
+ interface MLContentObject {
645
+ language: string;
646
+ title?: string;
647
+ data: string;
648
+ }
649
+
650
+ interface HeaderExtension {
651
+ selected: none | number;
652
+ selected_lang: none | string;
653
+ selected_code_pre: none | CodePreElement;
654
+ set_selected(index: number): this;
655
+ select (lang_or_index: number | string, recursive?: boolean): this;
656
+ }
657
+
658
+ // Build a code pre that optionally has different code per navigation.
659
+ /* @docs:
660
+ @nav: Frontend
661
+ @chapter: Elements
662
+ @title: Multi Language Code Block
663
+ @description: Build a code pre that optionally has different code per navigation.
664
+ @param:
665
+ @name: code
666
+ @type: CodeObject
667
+ @descr: The array of code objects.
668
+ @attr:
669
+ @name: language
670
+ @descr: The language name.
671
+ @attr:
672
+ @name: title
673
+ @descr: The code title, when left undefined the language name will be used as title.
674
+ @attr:
675
+ @name: data
676
+ @descr: The code data.
677
+ @required: true
678
+ @param:
679
+ @name: highlight
680
+ @type: boolean
681
+ @descr: Highlight the code content.
682
+ */
683
+ @Elements.register
684
+ export class MultiLanguageCodeBlockElement extends VStackElement {
685
+
686
+ static default_style = {
687
+ ...VStackElement.default_style,
688
+ "font-family": "'Menlo', 'Consolas', monospace",
689
+ "background": "black",
690
+ "color": "white",
691
+ "box-shadow": "0px 0px 5px #00000005",
692
+ "font-size": "13px",
693
+ "line-height": "18px",
694
+ "border-radius": "10px",
695
+ "tab-size": 4,
696
+ "--mlcb-tint": "white",
697
+ "--mlcb-div-bg": "grey",
698
+ "--mlcb-title-opac": 0.7,
699
+ };
700
+
701
+ // Attributes.
702
+ public _fg: string;
703
+ public _tint: string;
704
+ public _div_bg: string;
705
+ public _title_opac: number;
706
+ public _pre_nodes: CodePreElement[] = [];
707
+ public _title_nodes: (VStackElement & { divider: VStackElement })[] = [];
708
+
709
+ public header: HStackElement & HeaderExtension;
710
+ public _copy_img: ImageMaskElement;
711
+ // @ts-expect-error
712
+ public content: HStackElement;
713
+ public divider: DividerElement;
714
+
715
+ // Constructor.
716
+ constructor(
717
+ args: MLContentObject | MLContentObject[] | {
718
+ content: string | MLContentObject | MLContentObject[],
719
+ highlight?: boolean,
720
+ }
721
+ ) {
722
+
723
+ // Inherit.
724
+ super();
725
+ this._init_derived({
726
+ derived: MultiLanguageCodeBlockElement,
727
+ })
728
+
729
+ // Specify.
730
+ let content, highlight = true;
731
+ if (typeof args === "object" && !Array.isArray(args) && (args as any).content) {
732
+ ({content, highlight = true} = args as any);
733
+ } else {
734
+ content = args;
735
+ }
736
+
737
+ // Check code.
738
+ let code: MLContentObject[] = [];
739
+ if (typeof content === "string") {
740
+ code = [{language: "__unknown__", title: undefined, data: content}];
741
+ }
742
+ else if (typeof content === "object" && !Array.isArray(content)) {
743
+ code = [content as MLContentObject];
744
+ } else if (Array.isArray(content)) {
745
+ code = content as MLContentObject[];
746
+ } else {
747
+ console.error(`Invalid value type of code block "${typeof content}".`)
748
+ }
749
+
750
+ // Vars.
751
+ const main_this = this;
752
+ this._fg = MultiLanguageCodeBlockElement.default_style.color;
753
+ this._tint = MultiLanguageCodeBlockElement.default_style["--mlcb-tint"];
754
+ this._div_bg = MultiLanguageCodeBlockElement.default_style["--mlcb-div-bg"];
755
+ this._title_opac = typeof MultiLanguageCodeBlockElement.default_style["--mlcb-title-opac"] === "number"
756
+ ? MultiLanguageCodeBlockElement.default_style["--mlcb-title-opac"]
757
+ : parseInt(MultiLanguageCodeBlockElement.default_style["--mlcb-title-opac"]);
758
+
759
+ // The header element.
760
+ this.header = HStack<HeaderExtension>(
761
+
762
+ // Titles.
763
+ HStack(
764
+ ForEach(code, (item, index) => {
765
+ const title = VStack<{ divider: VStackElement }>(
766
+ Span(item.title || item.language || "")
767
+ .font_size(12)
768
+ .line_height(12 + 2)
769
+ .font_weight(500)
770
+ .ellipsis_overflow(true),
771
+ VStack()
772
+ .width(100%)
773
+ .height(2)
774
+ .border_radius(2)
775
+ .transition("background 300ms ease-in-out")
776
+ .background("transparent")
777
+ .assign_to_parent_as("divider")
778
+ .position(null, null, 0, null)
779
+ )
780
+ .transition("opacity 300ms ease-in-out")
781
+ .opacity(this._title_opac)
782
+ .padding(0, 2)
783
+ .flex_shrink(0)
784
+ .center_vertical()
785
+ .height(100%)
786
+ .position("relative")
787
+ .margin_right(20)
788
+ .on_mouse_over(() => {
789
+ if (this.header.selected !== index) {
790
+ title.opacity(1);
791
+ title.divider.opacity(this._title_opac).background(this._fg);
792
+ }
793
+ })
794
+ .on_mouse_out(() => {
795
+ if (this.header.selected !== index) {
796
+ title.opacity(this._title_opac);
797
+ title.divider.opacity(1).background("transparent");
798
+ }
799
+ })
800
+ if (code.length > 1) {
801
+ title.on_click(() => this.header.select(index))
802
+ }
803
+ this._title_nodes.append(title);
804
+ return title;
805
+ }),
806
+ )
807
+ .parent(this)
808
+ .height(100%)
809
+ .class("hide_scrollbar")
810
+ .wrap(false)
811
+ .overflow("visible")
812
+ // .flex("1 1 0"),
813
+ .width(100%),
814
+
815
+ // Spacer.
816
+ code.length > 1 ? null : Spacer(),
817
+
818
+ // Copy image.
819
+ this._copy_img = ImageMask("/volt_static/icons/copy.webp")
820
+ .frame(15, 15)
821
+ .flex_shrink(0)
822
+ .margin(null, null, null, 10)
823
+ .mask_color(this._fg)
824
+ .transform("rotate(90deg)")
825
+ .opacity(this._title_opac)
826
+ .transition("opacity 250ms ease-in-out")
827
+ .on_mouse_over(e => e.opacity(1))
828
+ .on_mouse_out(e => e.opacity(this._title_opac))
829
+ .on_click(async () => {
830
+ if (this.header?.selected_code_pre?.textContent) {
831
+ Utils.copy_to_clipboard(this.header.selected_code_pre.textContent)
832
+ .then(() => {
833
+ // @ts-expect-error
834
+ if (typeof RESPONSE_STATUS !== "undefined") {
835
+ // @ts-expect-error
836
+ RESPONSE_STATUS.message("Copied to clipboard");
837
+ }
838
+ })
839
+ .catch((error) => {
840
+ console.error(error);
841
+ // @ts-expect-error
842
+ if (typeof RESPONSE_STATUS !== "undefined") {
843
+ // @ts-expect-error
844
+ RESPONSE_STATUS.error("Failed to the code to the clipboard");
845
+ }
846
+ })
847
+ }
848
+ }),
849
+ )
850
+ .width(100%)
851
+ .overflow("hidden")
852
+ .height(42.5)
853
+ .padding(0, 15, 0, 15)
854
+ .center_vertical()
855
+ .z_index(2)
856
+ .extend({
857
+ selected: null,
858
+ selected_lang: null,
859
+ selected_code_pre: null,
860
+ set_selected(index) {
861
+ // Do not check for already selected since it is used in func tint() to set divider tint.
862
+
863
+ // Set selected index.
864
+ this.selected = index;
865
+ this.selected_lang = code[index].language ?? "__unknown__";
866
+ this.selected_code_pre = main_this._pre_nodes[index];
867
+
868
+ // Set title.
869
+ main_this._title_nodes.iterate((i) => {
870
+ i.opacity(main_this._title_opac)
871
+ if (code.length > 1) {
872
+ i.divider
873
+ .opacity(1)
874
+ .background("transparent")
875
+ .remove_on_theme_updates()
876
+ }
877
+ });
878
+ main_this._title_nodes[index].opacity(1)
879
+ if (code.length > 1) {
880
+ main_this._title_nodes[index].divider.background(main_this._tint)
881
+ }
882
+
883
+ return this;
884
+ },
885
+ select (lang_or_index, recursive = true) {
886
+
887
+ // Extract lang and index.
888
+ let lang;
889
+ let index;
890
+ if (typeof lang_or_index === "string") {
891
+ for (let i = 0; i < code.length; i++) {
892
+ if (code[i].language === lang_or_index) {
893
+ lang = lang_or_index;
894
+ index = i;
895
+ break;
896
+ }
897
+ }
898
+ // Nothing found.
899
+ if (index === undefined) {
900
+ return ;
901
+ }
902
+ } else {
903
+ if (lang_or_index >= code.length) { return ; }
904
+ index = lang_or_index;
905
+ lang = code[index].language || "__unknown__";
906
+ }
907
+
908
+ // Toggle code pre's.
909
+ if (recursive && lang !== "__unknown__") {
910
+ // localStorage.setItem("__ldoc_code_lang", lang);
911
+ this.select(index, false);
912
+ // LibrisUI.codeblock_lang_headers.iterate((h) => {
913
+ // if (h !== header) {
914
+ // h.select(lang, false)
915
+ // }
916
+ // })
917
+ } else {
918
+ this.set_selected(index);
919
+ for (let i = 0; i < main_this._pre_nodes.length; i++) {
920
+ if (i === index) {
921
+ main_this._pre_nodes[i].show();
922
+ } else {
923
+ main_this._pre_nodes[i].hide();
924
+ }
925
+ }
926
+ }
927
+
928
+ return this;
929
+ }
930
+ } as HeaderExtension)
931
+ // LibrisUI.codeblock_lang_headers.push(header);
932
+
933
+ // Add the code items.
934
+ this.content = HStack() // keep as hstack, for some reason the right side of the pre's will have padding as well then.
935
+ .width(100%)
936
+ .overflow("scroll")
937
+ let index = 0;
938
+ code.iterate((item) => {
939
+ if (item.data == null) {
940
+ console.error("Undefined codeblock data" + (item.language === "__unknown__" ? "" : ` for language ${item.language}`) + ".");
941
+ return null;
942
+ }
943
+ if (highlight) {
944
+ const tokenizer = vhighlight.init_tokenizer(item.language);
945
+ if (tokenizer) {
946
+ item.data = tokenizer.tokenize({code: item.data, build_html: true});
947
+ }
948
+ }
949
+ const pre = CodePre()
950
+ .padding(20, 20)
951
+ .margin(0)
952
+ .inner_html(item.data)
953
+ .overflow("visible")
954
+ .background("transparent")
955
+ .border_radius(0)
956
+ .stretch(true); // keep stretch, for some reason the right side of the pre's will have padding as well then.
957
+ pre.hide();
958
+ this._pre_nodes.append(pre);
959
+ this.content.append(pre);
960
+ ++index;
961
+ })
962
+
963
+ // Main container (this).
964
+ this
965
+ .display("block")
966
+ .white_space("pre")
967
+ .class("hide_scrollbar")
968
+ .max_width(100%)
969
+ .border(1, this._div_bg)
970
+ .position("relative")
971
+ .append(
972
+ this.header,
973
+ this.divider = Divider()
974
+ .parent(this)
975
+ .background(this._div_bg)
976
+ .margin(0, 0, 0, 0),
977
+ this.content,
978
+ )
979
+
980
+ // Select first item.
981
+ // @ts-ignore
982
+ this.header.select(0, false);
983
+
984
+ }
985
+
986
+
987
+ // Set default since it inherits another element.
988
+ set_default(): this {
989
+ return super.set_default(MultiLanguageCodeBlockElement);
990
+ }
991
+
992
+ // Get the styling attributes.
993
+ styles() : Record<string, string>;
994
+ styles(style_dict: Record<string, any>) : this;
995
+ styles(style_dict?: Record<string, any>) : this | Record<string, string> {
996
+ if (style_dict == null) {
997
+ let styles = super.styles();
998
+ styles["--mlcb-tint"] = this._tint;
999
+ styles["--mlcb-div-bg"] = this._div_bg;
1000
+ styles["--mlcb-title-opac"] = this._title_opac.toString();
1001
+ return styles;
1002
+ } else {
1003
+ return super.styles(style_dict);
1004
+ }
1005
+ }
1006
+
1007
+ /* @docs:
1008
+ @title: Set color
1009
+ @description: Set or get foreground tint color.
1010
+ */
1011
+ color(): string;
1012
+ color(value: string): this;
1013
+ color(value?: string): string | this {
1014
+ if (value == null) { return this._fg; }
1015
+ this._fg = value;
1016
+ super.color(value);
1017
+ this._copy_img.mask_color(value);
1018
+ return this;
1019
+ }
1020
+
1021
+ /* @docs:
1022
+ @title: Set tint color
1023
+ @description: Set or get the tint color, mainly used for the divider below the active tab.
1024
+ */
1025
+ tint(): string;
1026
+ tint(value: string): this;
1027
+ tint(value?: string): string | this {
1028
+ if (value == null) { return this._tint; }
1029
+ this._tint = value;
1030
+ this.header.set_selected(this.header.selected); // set tint again.
1031
+ return this;
1032
+ }
1033
+
1034
+ /* @docs:
1035
+ @title: Set divider background
1036
+ @description: Set the background of the divider.
1037
+ */
1038
+ divider_background(): string;
1039
+ divider_background(value: string): this;
1040
+ divider_background(value?: string): string | this {
1041
+ if (value == null) { return this._div_bg; }
1042
+ this._div_bg = value;
1043
+ this.divider.background(value);
1044
+ return this;
1045
+ }
1046
+ }
1047
+ export const MultiLanguageCodeBlock = Elements.wrapper(MultiLanguageCodeBlockElement);
1048
+ export const NullMultiLanguageCodeBlock = Elements.create_null(MultiLanguageCodeBlockElement);
1049
+ declare module './any_element.d.ts' { interface AnyElementMap { MultiLanguageCodeBlockElement: MultiLanguageCodeBlockElement }}