@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,907 @@
1
+ /*
2
+ * Author: Daan van den Bergh
3
+ * Copyright: © 2024 - 2024 Daan van den Bergh.
4
+ */
5
+ import * as pathlib from 'path';
6
+ import * as fs from 'fs';
7
+ import * as ts from 'typescript';
8
+ import * as esbuild from 'esbuild';
9
+ // import { rollup, RollupOptions, OutputOptions, Plugin } from 'rollup';
10
+ // import { nodeResolve } from '@rollup/plugin-node-resolve';
11
+ // import * as commonjs from '@rollup/plugin-commonjs';
12
+ // import { terser } from 'rollup-plugin-terser';
13
+ // Get the directory name of the current module
14
+ import { fileURLToPath } from 'url';
15
+ import { dirname } from 'path';
16
+ var __dirname = typeof __dirname !== 'undefined' ? __dirname : dirname(fileURLToPath(new URL('./package.json', import.meta.url)));
17
+ // Local imports.
18
+ import { vlib } from "../../vinc.js";
19
+ import * as Preprocessing from "./preprocessing.js";
20
+ // Resolve path wrapper.
21
+ function resolve_path(path) {
22
+ path = pathlib.resolve(path);
23
+ if (process.platform === "darwin" && path.startsWith("/private/tmp/")) {
24
+ path = path.slice(8);
25
+ }
26
+ return path;
27
+ }
28
+ [];
29
+ // Format a typescript error.
30
+ function format_ts_error(diagnostic) {
31
+ let line, column;
32
+ if (diagnostic.file && diagnostic.start !== undefined) {
33
+ const res = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
34
+ if (res.line !== undefined) {
35
+ line = res.line + 1;
36
+ }
37
+ if (res.character !== undefined) {
38
+ column = res.character + 1;
39
+ }
40
+ }
41
+ return {
42
+ data: ts.formatDiagnosticsWithColorAndContext([diagnostic], {
43
+ getCurrentDirectory: () => process.cwd(),
44
+ getCanonicalFileName: (file_name) => pathlib.resolve(file_name),
45
+ getNewLine: () => '\n',
46
+ }),
47
+ file_name: diagnostic.file === undefined ? undefined : pathlib.resolve(diagnostic.file.resolvedPath),
48
+ line,
49
+ column,
50
+ };
51
+ }
52
+ /*
53
+ Compiles TypeScript files after preprocessing them to replace non-string
54
+ literals with units and hex color codes into string literals.
55
+
56
+ ## Macros
57
+
58
+ Macros are supported in the following code style:
59
+ ```
60
+ #macro MyName values
61
+ ```
62
+
63
+ Function macros using templates are also supported.
64
+ ```
65
+ #macro MyMacro(myfuncname) myfuncname(first_name: string) { return `Hello ${first_name}!`}
66
+ ```
67
+
68
+ */
69
+ export async function compile(options) {
70
+ // Extract options with defaults.
71
+ let { entry_paths = [], include = [], exclude = [], output, error_limit = 25, compiler_opts = {}, preprocess, exact_files = false, file_by_file = false, watch, extract_exports, debug_file, templates = undefined, } = options;
72
+ if (entry_paths.length > 0) {
73
+ include = include.concat(entry_paths);
74
+ }
75
+ if (watch === undefined || typeof watch === "boolean") {
76
+ watch = {
77
+ enabled: watch ?? false,
78
+ log_level: 1,
79
+ on_change: undefined,
80
+ };
81
+ }
82
+ const { enabled: watch_enabled = false, log_level: watch_log_level = 1, } = watch;
83
+ // Initialize compile result.
84
+ let import_order;
85
+ const compile_result = {
86
+ inputs: [],
87
+ outputs: [],
88
+ errors: [],
89
+ debug(_watch = false) {
90
+ // Sort the errors based on import order.
91
+ if (import_order !== undefined) {
92
+ this.errors.sort((a, b) => {
93
+ // Get import order for both files
94
+ const orderA = a.file_name ? (import_order.get(a.file_name) ?? Number.MAX_SAFE_INTEGER) : Number.MAX_SAFE_INTEGER;
95
+ const orderB = b.file_name ? (import_order.get(b.file_name) ?? Number.MAX_SAFE_INTEGER) : Number.MAX_SAFE_INTEGER;
96
+ // First sort by import order
97
+ if (orderA !== orderB) {
98
+ return orderA - orderB;
99
+ }
100
+ return 0;
101
+ });
102
+ }
103
+ // Dump errors up to the error limit.
104
+ let last_file, dumped = 0, file_names = new Set();
105
+ for (let i = 0; i < this.errors.length; i++) {
106
+ if (debug_file == null && !file_by_file) {
107
+ console.error(this.errors[i].data);
108
+ ++dumped;
109
+ }
110
+ else if (debug_file !== undefined && this.errors[i].file_name?.toLowerCase() === debug_file.toLowerCase()) {
111
+ console.error(this.errors[i].data);
112
+ ++dumped;
113
+ }
114
+ else if (file_by_file) {
115
+ if (last_file !== undefined && this.errors[i].file_name !== last_file) {
116
+ break;
117
+ }
118
+ last_file = this.errors[i].file_name;
119
+ console.error(this.errors[i].data);
120
+ ++dumped;
121
+ }
122
+ if (this.errors[i].file_name != null && !file_names.has(this.errors[i].file_name.toLowerCase())) {
123
+ file_names.add(this.errors[i].file_name.toLowerCase());
124
+ }
125
+ if (dumped >= error_limit) {
126
+ break;
127
+ }
128
+ }
129
+ if (this.errors.length > 0 && debug_file !== undefined && dumped === 0) {
130
+ console.error(`${vlib.Color.yellow("warning")}: Did not find any files matching "${debug_file}". Valid file names: ${JSON.stringify(Array.from(file_names), null, 4)}`);
131
+ }
132
+ // Map errors per file.
133
+ if (this.errors.length > 0) {
134
+ const error_map = {};
135
+ for (const err of this.errors) {
136
+ if (err.file_name) {
137
+ if (error_map[err.file_name] === undefined) {
138
+ error_map[err.file_name] = 0;
139
+ }
140
+ error_map[err.file_name] += 1;
141
+ }
142
+ }
143
+ console.log(`\nErrors per file:`);
144
+ for (const [file_path, error_count] of Object.entries(error_map)) {
145
+ console.log(` - ${file_path}: ${error_count}`);
146
+ }
147
+ console.log("");
148
+ }
149
+ // Inform about error truncation.
150
+ // if (_watch === false) {
151
+ if (error_limit != null && this.errors.length > error_limit) {
152
+ console.log(`Displayed the first ${error_limit} errors out of ${this.errors.length}.`);
153
+ }
154
+ else {
155
+ console.log(`Encountered ${this.errors.length} errors.`);
156
+ }
157
+ if (this.outputs.length > 0) {
158
+ console.log(`Compiled ${this.outputs.length} output files.`);
159
+ }
160
+ // }
161
+ },
162
+ exports: {},
163
+ };
164
+ let diagnostics = [];
165
+ const processed_files = {};
166
+ // Process entry paths if exact_files is true.
167
+ if (exact_files) {
168
+ for (let i = 0; i < include.length; i++) {
169
+ const current_path = new vlib.Path(include[i]);
170
+ if (!current_path.exists()) {
171
+ compile_result.errors.push({
172
+ data: `Entry path "${current_path.str()}" does not exist.`
173
+ });
174
+ continue;
175
+ }
176
+ include[i] = current_path.abs().str();
177
+ }
178
+ if (compile_result.errors.length > 0) {
179
+ return compile_result;
180
+ }
181
+ }
182
+ // Build in-memory tsconfig options.
183
+ const tsconfig = {
184
+ compilerOptions: {
185
+ ...compiler_opts,
186
+ outDir: output,
187
+ declaration: compiler_opts.declaration === true ? true : false,
188
+ declarationDir: compiler_opts.declaration === true ? output : undefined,
189
+ // Add other default compiler options as needed
190
+ },
191
+ include: include,
192
+ exclude: exclude,
193
+ };
194
+ if (watch.enabled) {
195
+ tsconfig.compilerOptions.incremental = true;
196
+ tsconfig.compilerOptions.tsBuildInfoFile = output + "/.tsbuildinfo";
197
+ }
198
+ tsconfig.compilerOptions.paths ??= {};
199
+ tsconfig.compilerOptions.paths["volt"] = [new vlib.Path(__dirname + "../../../../../../frontend/dist/volt.js").abs().str()];
200
+ tsconfig.compilerOptions.paths["volt/*"] = [new vlib.Path(__dirname + "../../../../../../frontend/dist/").abs().str() + "/*"];
201
+ // let now = Date.now();
202
+ // Parse the in-memory tsconfig options.
203
+ const parsed_tsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, "./");
204
+ if (parsed_tsconfig.errors.length > 0) {
205
+ parsed_tsconfig.errors.forEach(error => {
206
+ const message = ts.flattenDiagnosticMessageText(error.messageText, '\n');
207
+ compile_result.errors.push({
208
+ data: `TSConfig error: ${message}`,
209
+ });
210
+ });
211
+ return compile_result;
212
+ }
213
+ // console.log("Init jsonconfig:", Date.now() - now); now = Date.now()
214
+ // Watch Mode
215
+ if (watch_enabled) {
216
+ // Define a virtual tsconfig file name
217
+ const virtual_tsconfig_path = pathlib.resolve("tsconfig.virtual.json");
218
+ // Create a custom system that intercepts readFile and fileExists
219
+ const written_files = new Map();
220
+ const custom_ts_sys = {
221
+ ...ts.sys,
222
+ fileExists: (file_name) => {
223
+ const resolved_file = pathlib.resolve(file_name);
224
+ if (resolved_file === virtual_tsconfig_path) {
225
+ return true;
226
+ }
227
+ if (exact_files && !entry_paths.includes(resolved_file)) {
228
+ return false;
229
+ }
230
+ return fs.existsSync(resolved_file);
231
+ },
232
+ readFile: (file_name) => {
233
+ // console.log("Read file", file_name)
234
+ const resolved_file = pathlib.resolve(file_name);
235
+ // Config path.
236
+ if (resolved_file === virtual_tsconfig_path) {
237
+ return JSON.stringify(tsconfig, null, 4);
238
+ }
239
+ // Exact files.
240
+ if (exact_files && !entry_paths.includes(resolved_file)) {
241
+ return undefined;
242
+ }
243
+ // Check existance.
244
+ if (!fs.existsSync(resolved_file)) {
245
+ return undefined;
246
+ }
247
+ // Load data.
248
+ let source_code = fs.readFileSync(resolved_file, 'utf-8');
249
+ // Apply preprocessing
250
+ if (!resolved_file.endsWith(".d.ts") && (resolved_file.endsWith(".js") || resolved_file.endsWith(".ts"))) {
251
+ source_code = Preprocessing.preprocess(resolved_file, source_code, { macros: true, templates });
252
+ // Apply user preprocessing.
253
+ if (preprocess) {
254
+ const preprocessed = preprocess(resolved_file, source_code);
255
+ if (preprocessed instanceof Promise) {
256
+ throw new Error('Asynchronous preprocessing is not supported in watch mode.');
257
+ }
258
+ if (typeof preprocessed === "string") {
259
+ source_code = preprocessed;
260
+ }
261
+ }
262
+ }
263
+ // Response.
264
+ return source_code;
265
+ },
266
+ writeFile: (file_name, data, write_byte_order_mark, on_error, source_files) => {
267
+ file_name = pathlib.resolve(file_name);
268
+ // Check if file has changed.
269
+ if (written_files.has(file_name) && written_files.get(file_name) === data) {
270
+ return;
271
+ }
272
+ // Logs.
273
+ if (watch_log_level >= 1) {
274
+ console.log(`ts-watcher: ${vlib.Color.purple("message")} Writing out file ${file_name}.`);
275
+ }
276
+ // Write the file using the original writeFile method
277
+ ts.sys.writeFile(file_name, data, write_byte_order_mark);
278
+ written_files.set(file_name, data);
279
+ // Call the on_change callback after writing the file
280
+ if (typeof watch === "object" && typeof watch.on_change === "function" && file_name.endsWith(".js")) {
281
+ watch.on_change(resolve_path(file_name));
282
+ }
283
+ },
284
+ };
285
+ // Create WatchCompilerHost using createWatchCompilerHost
286
+ const host = ts.createWatchCompilerHost(virtual_tsconfig_path, // Use virtual tsconfig path
287
+ undefined, // Override compiler options if needed
288
+ custom_ts_sys, ts.createEmitAndSemanticDiagnosticsBuilderProgram,
289
+ // ts.createSemanticDiagnosticsBuilderProgram,
290
+ // reportDiagnostic callback
291
+ (diagnostic) => {
292
+ compile_result.errors.push(format_ts_error(diagnostic));
293
+ },
294
+ // reportWatchStatusChanged callback
295
+ (diagnostic) => {
296
+ // Show errors on message `Found X errors. Watching for file changes.`
297
+ if (diagnostic.code === 6194) {
298
+ if (import_order === undefined) {
299
+ const interval = setInterval(() => {
300
+ if (import_order !== undefined) {
301
+ compile_result.debug();
302
+ compile_result.errors = [];
303
+ clearInterval(interval);
304
+ }
305
+ }, 100);
306
+ }
307
+ else {
308
+ if (compile_result.errors.length > 0) {
309
+ compile_result.debug();
310
+ }
311
+ compile_result.errors = [];
312
+ }
313
+ }
314
+ // Skip.
315
+ if (watch_log_level <= 0 && diagnostic.category === 3) {
316
+ // skip messages (3)
317
+ return;
318
+ }
319
+ const message = ts.formatDiagnosticsWithColorAndContext([diagnostic], {
320
+ getCurrentDirectory: () => process.cwd(),
321
+ getCanonicalFileName: (file_name) => pathlib.resolve(file_name),
322
+ getNewLine: () => '\n',
323
+ });
324
+ console.log("ts-watcher:", message.trimEnd());
325
+ });
326
+ // Create the WatchProgram
327
+ const program = ts.createWatchProgram(host);
328
+ // Define the import order.
329
+ import_order = new Map();
330
+ const source_files = program.getProgram().getSourceFiles();
331
+ for (let i = 0; i < source_files.length; i++) {
332
+ const source = source_files[i];
333
+ const file_name = pathlib.resolve(source.fileName).toLowerCase();
334
+ if (!import_order.has(file_name)) {
335
+ import_order.set(file_name, i);
336
+ }
337
+ }
338
+ // Assign the stop function to terminate the watch program
339
+ compile_result.stop = () => {
340
+ program.close();
341
+ console.log("ts-watcher:", "Stopped watching.");
342
+ };
343
+ return compile_result;
344
+ }
345
+ // Non-watch mode continues as before
346
+ // Create the initial TypeScript program to get all source files.
347
+ const initial_program = ts.createProgram({
348
+ rootNames: parsed_tsconfig.fileNames,
349
+ options: parsed_tsconfig.options,
350
+ });
351
+ const program_source_files = initial_program.getSourceFiles();
352
+ const all_source_files = program_source_files.filter(sf => !sf.isDeclarationFile);
353
+ // Check empty source files.
354
+ if (all_source_files.length === 0) {
355
+ compile_result.errors.push({ data: "No source files were found. Please check your entry paths." });
356
+ return compile_result;
357
+ }
358
+ // console.log({
359
+ // entry_paths,
360
+ // // all_source_files,
361
+ // // compiler_opts: parsed_tsconfig.options,
362
+ // file_names: parsed_tsconfig.fileNames,
363
+ // })
364
+ // Get extracted exports.
365
+ if (extract_exports) {
366
+ // Obtain the TypeChecker
367
+ const checker = initial_program.getTypeChecker();
368
+ // Iterate through all source files in the program
369
+ for (let i = 0; i < program_source_files.length; i++) {
370
+ const source = program_source_files[i];
371
+ // Skip declaration files (.d.ts) if not needed
372
+ if (source.isDeclarationFile)
373
+ continue;
374
+ // Get the module symbol for the source file
375
+ const symbol = checker.getSymbolAtLocation(source);
376
+ // Get exports of the module
377
+ if (symbol) {
378
+ if (compile_result.exports[source.fileName] === undefined) {
379
+ compile_result.exports[source.fileName] = [];
380
+ }
381
+ const list = compile_result.exports[source.fileName];
382
+ const exports = checker.getExportsOfModule(symbol);
383
+ for (const exp of exports) {
384
+ const name = exp.getName();
385
+ if (name !== "default") {
386
+ list.push(name);
387
+ }
388
+ }
389
+ }
390
+ }
391
+ }
392
+ // console.log("Get source files:", Date.now() - now); now = Date.now()
393
+ // Preprocess each source file.
394
+ for (let i = 0; i < all_source_files.length; i++) {
395
+ const source_file = all_source_files[i];
396
+ const file_name = pathlib.resolve(source_file.fileName);
397
+ // Add input file to compile_result.
398
+ compile_result.inputs.push(file_name);
399
+ // Skip files if exact_files is true and the file is not an entry file.
400
+ if (exact_files && !entry_paths.includes(file_name)) {
401
+ continue;
402
+ }
403
+ // Apply default preprocessing.
404
+ processed_files[file_name] = Preprocessing.preprocess(file_name, source_file.text, { macros: true, templates });
405
+ // Apply user-defined preprocessing.
406
+ if (preprocess) {
407
+ let res = preprocess(file_name, processed_files[file_name]);
408
+ if (res instanceof Promise) {
409
+ res = await res;
410
+ }
411
+ if (typeof res === "string") {
412
+ processed_files[file_name] = res;
413
+ }
414
+ }
415
+ }
416
+ // console.log("Processed files:", Object.keys(processed_files))
417
+ // console.log("Apply preprocessing:", Date.now() - now); now = Date.now()
418
+ // Create a custom CompilerHost for non-watch mode
419
+ const file_exists_cache = new Map();
420
+ const compiler_host = {
421
+ fileExists: (file_name) => {
422
+ // console.log("fileExists", file_name)
423
+ const resolved_file = pathlib.resolve(file_name);
424
+ if (processed_files[resolved_file]) {
425
+ return true;
426
+ }
427
+ else if (file_exists_cache.has(resolved_file)) {
428
+ return file_exists_cache.get(resolved_file);
429
+ }
430
+ const res = fs.existsSync(resolved_file);
431
+ file_exists_cache.set(resolved_file, res);
432
+ return res;
433
+ },
434
+ directoryExists: ts.sys.directoryExists,
435
+ getCurrentDirectory: ts.sys.getCurrentDirectory,
436
+ getDirectories: ts.sys.getDirectories,
437
+ getCanonicalFileName: ts.sys.useCaseSensitiveFileNames
438
+ ? (file_name) => file_name
439
+ : (file_name) => file_name.toLowerCase(),
440
+ getNewLine: () => ts.sys.newLine,
441
+ getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options),
442
+ getSourceFile: (file_name, language_version, on_error) => {
443
+ const resolved_file = pathlib.resolve(file_name);
444
+ if (processed_files[resolved_file]) {
445
+ // if (resolved_file.endsWith("home.ts") || resolved_file.endsWith("home.js")) console.log("getSourceFile1", resolved_file)
446
+ return ts.createSourceFile(resolved_file, processed_files[resolved_file], language_version, true);
447
+ }
448
+ if (exact_files && !entry_paths.includes(resolved_file)) {
449
+ // if (resolved_file.endsWith("home.ts") || resolved_file.endsWith("home.js")) console.log("getSourceFile2", resolved_file)
450
+ return undefined; // skip by exact files.
451
+ }
452
+ if (!fs.existsSync(resolved_file)) {
453
+ // if (resolved_file.endsWith("home.ts") || resolved_file.endsWith("home.js")) console.log("getSourceFile3", resolved_file)
454
+ if (on_error)
455
+ on_error(`File not found: ${resolved_file}`);
456
+ return undefined;
457
+ }
458
+ // if (resolved_file.endsWith("home.ts") || resolved_file.endsWith("home.js")) console.log("getSourceFile4", resolved_file)
459
+ const source_code = fs.readFileSync(resolved_file, 'utf-8');
460
+ return ts.createSourceFile(resolved_file, source_code, language_version, true);
461
+ },
462
+ readFile: (file_name) => {
463
+ // console.log("readFile", file_name)
464
+ const resolved_file = pathlib.resolve(file_name);
465
+ // console.log("readFile2", resolved_file)
466
+ if (processed_files[resolved_file]) {
467
+ // console.log("readFile3", resolved_file)
468
+ return processed_files[resolved_file];
469
+ }
470
+ if (exact_files && !entry_paths.includes(resolved_file)) {
471
+ // console.log("readFile4", resolved_file)
472
+ return undefined; // skip by exact files.
473
+ }
474
+ // console.log("readFile5", resolved_file)
475
+ return fs.readFileSync(resolved_file, 'utf-8');
476
+ },
477
+ useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
478
+ writeFile: (file_name, data, write_byte_order_mark, on_error, source_files) => {
479
+ compile_result.outputs.push(file_name);
480
+ if (file_name.endsWith('.js')) {
481
+ const paths = parsed_tsconfig.options.paths || {};
482
+ const baseUrl = parsed_tsconfig.options.baseUrl || './';
483
+ const transformed = data.replace(/(import|export)(\s+(?:\*\s+as\s+[^,}\s]+|\{[^}]*\}|[^,}\s]+)(?:\s*,\s*(?:\*\s+as\s+[^,}\s]+|\{[^}]*\}|[^,}\s]+))*\s+from\s+["'])([^"']+)(["'])/g, (match, importType, importDetails, importPath, quote) => {
484
+ for (const [alias, targets] of Object.entries(paths)) {
485
+ if (importPath === alias || importPath.startsWith(alias + '/')) {
486
+ const target = targets[0];
487
+ const from = pathlib.dirname(file_name);
488
+ const to = pathlib.resolve(pathlib.dirname(baseUrl), target);
489
+ const relativePath = pathlib.relative(from, to);
490
+ const finalPath = relativePath.startsWith('.') ?
491
+ relativePath :
492
+ './' + relativePath;
493
+ return `${importType}${importDetails}${finalPath}${quote}`;
494
+ }
495
+ }
496
+ return match;
497
+ });
498
+ ts.sys.writeFile(file_name, transformed, write_byte_order_mark);
499
+ }
500
+ else {
501
+ ts.sys.writeFile(file_name, data, write_byte_order_mark);
502
+ }
503
+ },
504
+ resolveModuleNames: (moduleNames, containingFile) => {
505
+ const matchPath = createMatchPath(parsed_tsconfig.options.paths || {});
506
+ return moduleNames.map(moduleName => {
507
+ // First try to resolve using paths
508
+ const matchedPath = matchPath(moduleName);
509
+ // console.log(moduleName, matchedPath)
510
+ if (matchedPath) {
511
+ return {
512
+ resolvedFileName: matchedPath,
513
+ isExternalLibraryImport: false,
514
+ extension: pathlib.extname(matchedPath)
515
+ };
516
+ }
517
+ // Fall back to classic resolution
518
+ const result = ts.resolveModuleName(moduleName, containingFile, parsed_tsconfig.options, {
519
+ fileExists: compiler_host.fileExists,
520
+ readFile: compiler_host.readFile,
521
+ });
522
+ return result.resolvedModule;
523
+ });
524
+ },
525
+ };
526
+ function createMatchPath(patterns) {
527
+ const matchers = Object.entries(patterns).map(([prefix, paths]) => ({
528
+ prefix: prefix.endsWith('/*') ? prefix.slice(0, -2) : prefix,
529
+ paths: paths.map(p => p.endsWith('/*') ? p.slice(0, -2) : p)
530
+ }));
531
+ return (moduleName) => {
532
+ for (const { prefix, paths } of matchers) {
533
+ if (moduleName.startsWith(prefix)) {
534
+ const suffix = moduleName.slice(prefix.length);
535
+ for (const path of paths) {
536
+ const fullPath = path + suffix;
537
+ // Try with .ts, .tsx, and as-is
538
+ for (const ext of ['.ts', '.tsx', '', '.js']) {
539
+ const attemptPath = fullPath + ext;
540
+ if (ts.sys.fileExists(attemptPath)) {
541
+ return attemptPath;
542
+ }
543
+ }
544
+ }
545
+ }
546
+ }
547
+ return undefined;
548
+ };
549
+ }
550
+ // Create the TypeScript program
551
+ const program = ts.createProgram({
552
+ rootNames: parsed_tsconfig.fileNames,
553
+ options: parsed_tsconfig.options,
554
+ host: compiler_host,
555
+ });
556
+ // Emit the compiled JavaScript
557
+ const emit_result = program.emit();
558
+ // Collect and display diagnostics
559
+ diagnostics = ts.getPreEmitDiagnostics(program).concat(emit_result.diagnostics);
560
+ // Process diagnostics.
561
+ for (let i = 0; i < diagnostics.length; i++) {
562
+ // if (debug_file == null || diagnostics[i]?.file?.fileName === debug_file) {
563
+ compile_result.errors.push(format_ts_error(diagnostics[i]));
564
+ // }
565
+ }
566
+ // console.log("Compile:", Date.now() - now); now = Date.now()
567
+ // Response.
568
+ return compile_result;
569
+ }
570
+ ;
571
+ // Format an esbuild warning / error.
572
+ const format_esbuild_warning_error = (warning) => {
573
+ let output;
574
+ if (warning.location) {
575
+ const trimmed_line = warning.location.lineText.trimStart();
576
+ const removed_start_indent = warning.location.lineText.length - trimmed_line.length;
577
+ output =
578
+ `${vlib.Color.cyan(warning.location.file)}:${vlib.Color.yellow(warning.location.line)}:${vlib.Color.yellow(warning.location.column)}` +
579
+ ` - ${vlib.Color.yellow("warning")} [esbuild${warning.id === "" ? "" : `-${warning.id}`}]: ${warning.text}\n` +
580
+ "\n" + vlib.Colors.bright_bg.white + vlib.Colors.black + warning.location.line + vlib.Colors.end + " " + trimmed_line +
581
+ "\n" + vlib.Colors.bright_bg.white + vlib.Colors.black + " ".repeat(warning.location.line.toString().length) + vlib.Colors.end +
582
+ " ".repeat(4 + warning.location.column - removed_start_indent) + vlib.Color.red("~".repeat(warning.location.length));
583
+ }
584
+ else {
585
+ output = `${vlib.Color.yellow("warning")} [esbuild${warning.id === "" ? "" : `-${warning.id}`}]: ${warning.text}`;
586
+ }
587
+ if (Array.isArray(warning.notes)) {
588
+ for (const note of warning.notes) {
589
+ if (note.location) {
590
+ const trimmed_line = note.location.lineText.trimStart();
591
+ const removed_start_indent = note.location.lineText.length - trimmed_line.length;
592
+ output +=
593
+ `\n ${vlib.Color.cyan(note.location.file)}:${vlib.Color.yellow(note.location.line)}:${vlib.Color.yellow(note.location.column)}` +
594
+ ` - ${vlib.Color.gray("note")}: ${note.text}\n` +
595
+ "\n" + vlib.Colors.bright_bg.white + vlib.Colors.black + note.location.line + vlib.Colors.end + " " + trimmed_line +
596
+ "\n" + vlib.Colors.bright_bg.white + vlib.Colors.black + " ".repeat(note.location.line.toString().length) + vlib.Colors.end +
597
+ " ".repeat(8 + note.location.column - removed_start_indent) + vlib.Color.red("~".repeat(note.location.length));
598
+ }
599
+ else {
600
+ output +=
601
+ `\n ${vlib.Color.gray("note")}: ${note.text}`;
602
+ }
603
+ if (note.suggestion) {
604
+ console.error("@todo handle suggestion:" + note.suggestion + " note: " + JSON.stringify(note, null, 4));
605
+ }
606
+ }
607
+ }
608
+ return {
609
+ data: output,
610
+ file_name: warning.location?.file,
611
+ line: warning.location?.line,
612
+ column: warning.location?.column,
613
+ };
614
+ };
615
+ /*
616
+ * Bundles transpiled JavaScript files using esbuild.
617
+ */
618
+ export async function bundle(options) {
619
+ // console.log(">>> BUNDLE", options)
620
+ let { entry_paths = [], include = [], output = undefined, platform = 'browser', format = 'iife', target = 'es2021', minify = false, sourcemap = false, // 'inline'
621
+ error_limit = 25, extract_inputs = false, tree_shaking = undefined, debug = false, bundler = "esbuild", opts = {},
622
+ // bundler = "rollup",
623
+ } = options;
624
+ if (entry_paths.length > 0) {
625
+ include = include.concat(entry_paths);
626
+ }
627
+ const errors = [];
628
+ let bundled_code = undefined;
629
+ let bundled_source_map = undefined;
630
+ let inputs = [];
631
+ // Bundle using esbuild.
632
+ if (bundler === "esbuild") {
633
+ try {
634
+ const result = await esbuild.build({
635
+ entryPoints: include,
636
+ bundle: true,
637
+ platform: platform,
638
+ format: format,
639
+ target: target,
640
+ minify: minify,
641
+ sourcemap,
642
+ write: false,
643
+ metafile: extract_inputs,
644
+ logLevel: typeof debug === "boolean" ? (debug ? 'debug' : 'silent') : debug,
645
+ treeShaking: tree_shaking,
646
+ // logLevel: 'silent',
647
+ // outdir: "/",
648
+ // minifyWhitespace: false,
649
+ // minifySyntax: false,
650
+ // minifyIdentifiers: false,
651
+ ...opts,
652
+ });
653
+ if (result.errors.length > 0) {
654
+ for (const error of result.errors) {
655
+ errors.push(format_esbuild_warning_error(error));
656
+ }
657
+ }
658
+ if (result.warnings.length > 0) {
659
+ for (const warning of result.warnings) {
660
+ errors.push(format_esbuild_warning_error(warning));
661
+ }
662
+ }
663
+ // Set output paths.
664
+ if (extract_inputs && result.metafile?.inputs != null && typeof result.metafile?.inputs === "object") {
665
+ inputs = Object.keys(result.metafile?.inputs).map(resolve_path);
666
+ }
667
+ // Process output files.
668
+ if (result.outputFiles && result.outputFiles.length > 0) {
669
+ // Concatenate all output files
670
+ bundled_code = result.outputFiles
671
+ .filter(file => file.path === "<stdout>" || (file.path.endsWith('.js') && !file.path.endsWith('.d.js')))
672
+ .map(file => file.text)
673
+ .join('\n');
674
+ if (sourcemap) {
675
+ const source_map_file = result.outputFiles.find(file => file.path.endsWith('.map'));
676
+ if (source_map_file) {
677
+ bundled_source_map = source_map_file.text;
678
+ }
679
+ }
680
+ }
681
+ else {
682
+ errors.push({ data: "No output files were generated during bundling." });
683
+ }
684
+ }
685
+ catch (err) {
686
+ let processed = false;
687
+ if (Array.isArray(err.errors) && err.errors.length > 0) {
688
+ for (const error of err.errors) {
689
+ errors.push(format_esbuild_warning_error(error));
690
+ }
691
+ processed = true;
692
+ }
693
+ if (Array.isArray(err.warnings) && err.warnings.length > 0) {
694
+ for (const warning of err.warnings) {
695
+ errors.push(format_esbuild_warning_error(warning));
696
+ }
697
+ processed = true;
698
+ }
699
+ if (!processed) {
700
+ errors.push({ data: err.message || String(err) });
701
+ }
702
+ }
703
+ }
704
+ // Bundle using rollup.
705
+ else {
706
+ try {
707
+ throw new Error("Rollup is deprecated since it is currently out of use.");
708
+ // // Determine if minification is needed
709
+ // const plugins: Plugin[] = [
710
+ // nodeResolve({
711
+ // browser: platform === 'browser',
712
+ // preferBuiltins: platform === 'node',
713
+ // }),
714
+ // // commonjs(),
715
+ // ];
716
+ // if (minify) {
717
+ // plugins.push(terser());
718
+ // }
719
+ // const input_set: Set<string> = new Set();
720
+ // // if (extract_inputs) {
721
+ // // plugins.push(
722
+ // // // Custom plugin to collect all imported files
723
+ // // {
724
+ // // name: 'collect-input-files',
725
+ // // resolveId(source, importer) {
726
+ // // return null; // Let Rollup handle module resolution
727
+ // // },
728
+ // // load(id) {
729
+ // // console.log("ADD:",id)
730
+ // // input_set.add(id); // Add each module to the input_set set
731
+ // // return null; // Let Rollup handle loading the module
732
+ // // }
733
+ // // }
734
+ // // )
735
+ // // }
736
+ // const rollup_input_options: RollupOptions = {
737
+ // input: include,
738
+ // plugins: plugins,
739
+ // treeshake: tree_shaking !== undefined ? tree_shaking : true,
740
+ // // Suppress Rollup warnings if not in debug mode
741
+ // onwarn: (warning, warn) => {
742
+ // if (debug) {
743
+ // warn(warning);
744
+ // }
745
+ // // Otherwise, suppress warnings
746
+ // },
747
+ // };
748
+ // const bundle = await rollup(rollup_input_options);
749
+ // const rollup_output_options: OutputOptions = {
750
+ // format: format,
751
+ // sourcemap: sourcemap !== false,
752
+ // // Name is required for 'iife' format
753
+ // ...(format === 'iife' ? { name: 'Bundle' } : {}),
754
+ // // Generate inline source maps if specified
755
+ // ...(sourcemap === 'inline' ? { sourcemap: 'inline' } : {}),
756
+ // ...(sourcemap === 'external' ? { sourcemap: true } : {}),
757
+ // ...(sourcemap === 'linked' ? { sourcemap: true, sourcemapPathTransform: (relativePath: string) => `./${relativePath}` } : {}),
758
+ // // Additional Rollup output options can be added here
759
+ // };
760
+ // const { output } = await bundle.generate(rollup_output_options);
761
+ // bundled_code = '';
762
+ // bundled_source_map = '';
763
+ // // @todo remove as any
764
+ // for (const item of output as any) {
765
+ // if (item.type === 'chunk') {
766
+ // bundled_code += item.code;
767
+ // if (item.map) {
768
+ // bundled_source_map += item.map.toString();
769
+ // }
770
+ // if (extract_inputs) {
771
+ // for (const name of Object.keys(item.modules)) {
772
+ // if (!input_set.has(name)) {
773
+ // input_set.add(name);
774
+ // }
775
+ // }
776
+ // }
777
+ // }
778
+ // }
779
+ // inputs = extract_inputs ? Array.from(input_set) : []
780
+ }
781
+ catch (err) {
782
+ errors.push({ data: err.message ?? String(err) });
783
+ // throw new Error(`Rollup bundling failed: ${err.message || err}`);
784
+ }
785
+ }
786
+ // Write to file.
787
+ if (typeof output === "string") {
788
+ await new vlib.Path(output).save(bundled_code ?? "");
789
+ }
790
+ return {
791
+ code: bundled_code,
792
+ source_map: bundled_source_map,
793
+ errors,
794
+ inputs,
795
+ debug() {
796
+ for (let i = 0; i < Math.min(error_limit, errors.length); i++) {
797
+ console.error(errors[i].data);
798
+ }
799
+ if (error_limit != null && errors.length > error_limit) {
800
+ console.log(`Displayed the first ${error_limit} errors out of ${errors.length}.`);
801
+ }
802
+ else {
803
+ console.log(`Encountered ${errors.length} errors.`);
804
+ }
805
+ if (typeof bundled_code === "string" && bundled_code !== "") {
806
+ console.log(`Generated code of ${vlib.Utils.format_bytes(Buffer.byteLength(bundled_code, 'utf8'))}`);
807
+ }
808
+ },
809
+ };
810
+ }
811
+ ;
812
+ /*
813
+ // Collect imports.
814
+ export async function collect_exports(file_path: string, data: string) {
815
+ const exported_names = new Set<string>();
816
+
817
+ const source_file = ts.createSourceFile(
818
+ file_path,
819
+ data,
820
+ ts.ScriptTarget.ESNext,
821
+ true
822
+ );
823
+
824
+ function visit_node(node: ts.Node) {
825
+ // Handle named export declarations: export { Utils, Another };
826
+ if (ts.isExportDeclaration(node)) {
827
+ if (node.exportClause && ts.isNamedExports(node.exportClause)) {
828
+ node.exportClause.elements.forEach(element => {
829
+ const n = element.name.getText();
830
+ if (!exported_names.has(n)) {
831
+ exported_names.add(n);
832
+ }
833
+ });
834
+ }
835
+ }
836
+ // Handle export specifiers: export { Utils } from './utils';
837
+ else if (ts.isExportSpecifier(node)) {
838
+ const n = node.name.getText();
839
+ if (!exported_names.has(n)) {
840
+ exported_names.add(n);
841
+ }
842
+ }
843
+ // Handle exported declarations: export function foo() {}, export const bar = 1, etc.
844
+ else if (ts.isExportAssignment(node)) {
845
+ // Handle default exports if needed
846
+ const expr = node.expression;
847
+ if (ts.isIdentifier(expr)) {
848
+ const n = expr.getText();
849
+ if (!exported_names.has(n)) {
850
+ exported_names.add(n);
851
+ }
852
+ }
853
+ // Handle other export assignment expressions if necessary
854
+ }
855
+ else {
856
+ const modifiers = ts.getModifiers(node as any);
857
+ if (modifiers && modifiers.some(mod => mod.kind === ts.SyntaxKind.ExportKeyword)) {
858
+ if (ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node) || ts.isEnumDeclaration(node)) {
859
+ if (node.name) {
860
+ const n = node.name.getText();
861
+ if (!exported_names.has(n)) {
862
+ exported_names.add(n);
863
+ }
864
+ }
865
+ }
866
+ else if (ts.isVariableStatement(node)) {
867
+ node.declarationList.declarations.forEach(declaration => {
868
+ const n = declaration.name.getText();
869
+ if (!exported_names.has(n)) {
870
+ exported_names.add(n);
871
+ }
872
+ });
873
+ }
874
+ }
875
+ }
876
+
877
+ ts.forEachChild(node, visit_node);
878
+ }
879
+
880
+ visit_node(source_file);
881
+
882
+ return Array.from(exported_names);
883
+ }
884
+
885
+ // Get all included soruce files.
886
+ export async function get_source_files(entry_paths: string[]): Promise<string[]> {
887
+ const result = await esbuild.build({
888
+ entryPoints: entry_paths,
889
+ bundle: true,
890
+ metafile: true,
891
+ write: false, // Keep outputs in memory
892
+ });
893
+ if (!result.metafile) {
894
+ throw new Error('Metafile not generated');
895
+ }
896
+ return Object.keys(result.metafile.inputs);
897
+ }
898
+
899
+ */
900
+ // Exports.
901
+ export default {
902
+ compile,
903
+ bundle,
904
+ preprocessing: Preprocessing,
905
+ // collect_exports,
906
+ // get_source_files,
907
+ };