@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,1242 @@
1
+ /*
2
+ * Author: Daan van den Bergh
3
+ * Copyright: © 2024 - 2024 Daan van den Bergh.
4
+ */
5
+
6
+ import * as pathlib from 'path';
7
+ import * as fs from 'fs';
8
+ import * as ts from 'typescript';
9
+ import * as esbuild from 'esbuild';
10
+
11
+ // import { rollup, RollupOptions, OutputOptions, Plugin } from 'rollup';
12
+ // import { nodeResolve } from '@rollup/plugin-node-resolve';
13
+ // import * as commonjs from '@rollup/plugin-commonjs';
14
+ // import { terser } from 'rollup-plugin-terser';
15
+
16
+ // Get the directory name of the current module
17
+ import { fileURLToPath } from 'url';
18
+ import { dirname, join } from 'path';
19
+ // @ts-ignore
20
+ declare var __dirname; var __dirname = typeof __dirname !== 'undefined' ? __dirname : dirname(fileURLToPath(new URL('./package.json', import.meta.url)));
21
+
22
+ // Local imports.
23
+
24
+ import { vlib } from "@vinc";
25
+ import * as Preprocessing from "./preprocessing.js";
26
+
27
+ // Resolve path wrapper.
28
+ function resolve_path(path: string) {
29
+ path = pathlib.resolve(path);
30
+ if (process.platform === "darwin" && path.startsWith("/private/tmp/")) {
31
+ path = path.slice(8);
32
+ }
33
+ return path;
34
+ }
35
+
36
+ // Error interface.
37
+ interface CompilerError { data: string, file_name?: string, line?: number, column?: number }[]
38
+
39
+ /**
40
+ * Options for bundling TypeScript code.
41
+ */
42
+ export interface CompileOptions {
43
+
44
+ // Input paths.
45
+ include?: string[],
46
+
47
+ // Excluded paths.
48
+ exclude?: string[],
49
+
50
+ // @deprecated Additional entry paths.
51
+ entry_paths?: string[],
52
+
53
+ // Output.
54
+ output: string,
55
+
56
+ // Error limit.
57
+ error_limit?: number,
58
+
59
+ // Debug a single file by file path.
60
+ debug_file?: string,
61
+
62
+ // Debug file by file.
63
+ file_by_file?: boolean;
64
+
65
+ /**
66
+ * Function to preprocess TypeScript code after transpilation.
67
+ * Receives the file path and its transpiled JavaScript content, returns modified content.
68
+ */
69
+ preprocess?: (file_path: string, content: string) => undefined | string | Promise<undefined | string>;
70
+
71
+ /**
72
+ * TypeScript compiler options.
73
+ */
74
+ compiler_opts?: Record<string, any>;
75
+
76
+ // Add copyright.
77
+ // copyright?: boolean,
78
+
79
+ // Exact files: only compile the entry files and no other files.
80
+ exact_files?: boolean;
81
+
82
+ // Watch mode.
83
+ watch?: boolean | {
84
+ enabled: boolean,
85
+ log_level?: number,
86
+ on_change?: (path: string) => any,
87
+ };
88
+
89
+ // Extract exports.
90
+ extract_exports?: boolean;
91
+
92
+ // Templates.
93
+ templates?: Record<string, any>;
94
+ }
95
+
96
+ /**
97
+ * Result of the bundling process.
98
+ */
99
+ export interface CompileResult {
100
+
101
+ // Input paths.
102
+ inputs: string[],
103
+
104
+ // Output paths.
105
+ outputs: string[],
106
+
107
+ /**
108
+ * Compilation and bundling errors, if any.
109
+ */
110
+ errors: CompilerError[]
111
+
112
+ /**
113
+ * Debug function.
114
+ */
115
+ debug: (_watch?: boolean) => void;
116
+
117
+ /**
118
+ * Function to terminate the watch program. Available only in watch mode.
119
+ */
120
+ stop?: () => void,
121
+
122
+ // Extracted export names.
123
+ // Only defined when `extract_inputs` is enabled.
124
+ exports: Record<string, string[]>;
125
+ }
126
+
127
+ // Format a typescript error.
128
+ function format_ts_error(diagnostic): CompilerError {
129
+ let line, column;
130
+ if (diagnostic.file && diagnostic.start !== undefined) {
131
+ const res = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
132
+ if (res.line !== undefined) { line = res.line + 1; }
133
+ if (res.character !== undefined) { column = res.character + 1; }
134
+ }
135
+ return {
136
+ data: ts.formatDiagnosticsWithColorAndContext([diagnostic], {
137
+ getCurrentDirectory: () => process.cwd(),
138
+ getCanonicalFileName: (file_name) => pathlib.resolve(file_name),
139
+ getNewLine: () => '\n',
140
+ }),
141
+ file_name: diagnostic.file === undefined ? undefined : pathlib.resolve(diagnostic.file.resolvedPath),
142
+ line,
143
+ column,
144
+ }
145
+ }
146
+
147
+ /*
148
+ Compiles TypeScript files after preprocessing them to replace non-string
149
+ literals with units and hex color codes into string literals.
150
+
151
+ ## Macros
152
+
153
+ Macros are supported in the following code style:
154
+ ```
155
+ #macro MyName values
156
+ ```
157
+
158
+ Function macros using templates are also supported.
159
+ ```
160
+ #macro MyMacro(myfuncname) myfuncname(first_name: string) { return `Hello ${first_name}!`}
161
+ ```
162
+
163
+ */
164
+ export async function compile(options: CompileOptions): Promise<CompileResult> {
165
+
166
+ // Extract options with defaults.
167
+ let {
168
+ entry_paths = [],
169
+ include = [],
170
+ exclude = [],
171
+ output,
172
+ error_limit = 25,
173
+ compiler_opts = {},
174
+ preprocess,
175
+ exact_files = false,
176
+ file_by_file = false,
177
+ watch,
178
+ extract_exports,
179
+ debug_file,
180
+ templates = undefined,
181
+ } = options;
182
+ if (entry_paths.length > 0) {
183
+ include = include.concat(entry_paths);
184
+ }
185
+ if (watch === undefined || typeof watch === "boolean") {
186
+ watch = {
187
+ enabled: watch ?? false,
188
+ log_level: 1,
189
+ on_change: undefined,
190
+ };
191
+ }
192
+ const {
193
+ enabled: watch_enabled = false,
194
+ log_level: watch_log_level = 1,
195
+ } = watch;
196
+
197
+ // Initialize compile result.
198
+ let import_order: Map<string, number> | undefined;
199
+ const compile_result: CompileResult = {
200
+ inputs: [],
201
+ outputs: [],
202
+ errors: [],
203
+ debug(_watch: boolean = false) {
204
+
205
+ // Sort the errors based on import order.
206
+ if (import_order !== undefined) {
207
+ this.errors.sort((a, b) => {
208
+
209
+ // Get import order for both files
210
+ const orderA = a.file_name ? ((import_order as any).get(a.file_name) ?? Number.MAX_SAFE_INTEGER) : Number.MAX_SAFE_INTEGER;
211
+ const orderB = b.file_name ? ((import_order as any).get(b.file_name) ?? Number.MAX_SAFE_INTEGER) : Number.MAX_SAFE_INTEGER;
212
+
213
+ // First sort by import order
214
+ if (orderA !== orderB) {
215
+ return orderA - orderB;
216
+ }
217
+
218
+ return 0;
219
+ });
220
+ }
221
+
222
+ // Dump errors up to the error limit.
223
+ let last_file, dumped = 0, file_names = new Set<string>();
224
+ for (let i = 0; i < this.errors.length; i++) {
225
+ if (debug_file == null && !file_by_file) {
226
+ console.error(this.errors[i].data);
227
+ ++dumped;
228
+ } else if (debug_file !== undefined && this.errors[i].file_name?.toLowerCase() === debug_file.toLowerCase()) {
229
+ console.error(this.errors[i].data);
230
+ ++dumped;
231
+ } else if (file_by_file) {
232
+ if (last_file !== undefined && this.errors[i].file_name !== last_file) {
233
+ break;
234
+ }
235
+ last_file = this.errors[i].file_name;
236
+ console.error(this.errors[i].data);
237
+ ++dumped;
238
+ }
239
+ if (this.errors[i].file_name != null && !file_names.has(this.errors[i].file_name!.toLowerCase())) {
240
+ file_names.add(this.errors[i].file_name!.toLowerCase());
241
+ }
242
+ if (dumped >= error_limit) { break; }
243
+ }
244
+ if (this.errors.length > 0 && debug_file !== undefined && dumped === 0) {
245
+ 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)}`)
246
+ }
247
+
248
+ // Map errors per file.
249
+ if (this.errors.length > 0) {
250
+ const error_map: Record<string, number> = {};
251
+ for (const err of this.errors) {
252
+ if (err.file_name) {
253
+ if (error_map[err.file_name] === undefined) {
254
+ error_map[err.file_name] = 0;
255
+ }
256
+ error_map[err.file_name] += 1;
257
+ }
258
+ }
259
+ console.log(`\nErrors per file:`);
260
+ for (const [file_path, error_count] of Object.entries(error_map)) {
261
+ console.log(` - ${file_path}: ${error_count}`);
262
+ }
263
+ console.log("");
264
+ }
265
+
266
+ // Inform about error truncation.
267
+ // if (_watch === false) {
268
+ if (error_limit != null && this.errors.length > error_limit) {
269
+ console.log(`Displayed the first ${error_limit} errors out of ${this.errors.length}.`);
270
+ } else {
271
+ console.log(`Encountered ${this.errors.length} errors.`);
272
+ }
273
+
274
+ if (this.outputs.length > 0) {
275
+ console.log(`Compiled ${this.outputs.length} output files.`);
276
+ }
277
+ // }
278
+ },
279
+ exports: {},
280
+ }
281
+
282
+ let diagnostics: ts.Diagnostic[] = [];
283
+ const processed_files: { [file_name: string]: string } = {};
284
+
285
+ // Process entry paths if exact_files is true.
286
+ if (exact_files) {
287
+ for (let i = 0; i < include.length; i++) {
288
+ const current_path = new vlib.Path(include[i]);
289
+ if (!current_path.exists()) {
290
+ compile_result.errors.push({
291
+ data: `Entry path "${current_path.str()}" does not exist.`
292
+ });
293
+ continue;
294
+ }
295
+ include[i] = current_path.abs().str();
296
+ }
297
+ if (compile_result.errors.length > 0) {
298
+ return compile_result;
299
+ }
300
+ }
301
+
302
+ // Build in-memory tsconfig options.
303
+ const tsconfig: Record<string, any> = {
304
+ compilerOptions: {
305
+ ...compiler_opts,
306
+ outDir: output,
307
+ declaration: compiler_opts.declaration === true ? true : false,
308
+ declarationDir: compiler_opts.declaration === true ? output : undefined,
309
+ // Add other default compiler options as needed
310
+ },
311
+ include: include,
312
+ exclude: exclude,
313
+ };
314
+ if (watch.enabled) {
315
+ tsconfig.compilerOptions.incremental = true;
316
+ tsconfig.compilerOptions.tsBuildInfoFile = output + "/.tsbuildinfo"
317
+ }
318
+ tsconfig.compilerOptions.paths ??= {};
319
+ tsconfig.compilerOptions.paths["volt"] = [new vlib.Path(__dirname + "../../../../../../frontend/dist/volt.js").abs().str()];
320
+ tsconfig.compilerOptions.paths["volt/*"] = [new vlib.Path(__dirname + "../../../../../../frontend/dist/").abs().str() + "/*"];
321
+
322
+ // let now = Date.now();
323
+
324
+ // Parse the in-memory tsconfig options.
325
+ const parsed_tsconfig = ts.parseJsonConfigFileContent(
326
+ tsconfig,
327
+ ts.sys,
328
+ "./",
329
+ );
330
+
331
+ if (parsed_tsconfig.errors.length > 0) {
332
+ parsed_tsconfig.errors.forEach(error => {
333
+ const message = ts.flattenDiagnosticMessageText(error.messageText, '\n');
334
+ compile_result.errors.push({
335
+ data: `TSConfig error: ${message}`,
336
+ });
337
+ });
338
+ return compile_result;
339
+ }
340
+
341
+ // console.log("Init jsonconfig:", Date.now() - now); now = Date.now()
342
+
343
+ // Watch Mode
344
+ if (watch_enabled) {
345
+
346
+ // Define a virtual tsconfig file name
347
+ const virtual_tsconfig_path = pathlib.resolve("tsconfig.virtual.json");
348
+
349
+ // Create a custom system that intercepts readFile and fileExists
350
+ const written_files = new Map<string, string>()
351
+ const custom_ts_sys: ts.System = {
352
+ ...ts.sys,
353
+ fileExists: (file_name: string) => {
354
+ const resolved_file = pathlib.resolve(file_name);
355
+ if (resolved_file === virtual_tsconfig_path) {
356
+ return true;
357
+ }
358
+ if (exact_files && !entry_paths.includes(resolved_file)) {
359
+ return false;
360
+ }
361
+ return fs.existsSync(resolved_file);
362
+ },
363
+ readFile: (file_name: string) => {
364
+ // console.log("Read file", file_name)
365
+ const resolved_file = pathlib.resolve(file_name);
366
+
367
+ // Config path.
368
+ if (resolved_file === virtual_tsconfig_path) {
369
+ return JSON.stringify(tsconfig, null, 4);
370
+ }
371
+
372
+ // Exact files.
373
+ if (exact_files && !entry_paths.includes(resolved_file)) {
374
+ return undefined;
375
+ }
376
+
377
+ // Check existance.
378
+ if (!fs.existsSync(resolved_file)) {
379
+ return undefined;
380
+ }
381
+
382
+ // Load data.
383
+ let source_code = fs.readFileSync(resolved_file, 'utf-8');
384
+
385
+ // Apply preprocessing
386
+ if (!resolved_file.endsWith(".d.ts") && (resolved_file.endsWith(".js") || resolved_file.endsWith(".ts"))) {
387
+ source_code = Preprocessing.preprocess(resolved_file, source_code, { macros: true, templates });
388
+
389
+ // Apply user preprocessing.
390
+ if (preprocess) {
391
+ const preprocessed = preprocess(resolved_file, source_code);
392
+ if (preprocessed instanceof Promise) {
393
+ throw new Error('Asynchronous preprocessing is not supported in watch mode.');
394
+ }
395
+ if (typeof preprocessed === "string") {
396
+ source_code = preprocessed;
397
+ }
398
+ }
399
+ }
400
+
401
+ // Response.
402
+ return source_code;
403
+ },
404
+ writeFile: (file_name: string, data: string, write_byte_order_mark: boolean, on_error?: (message: string) => void, source_files?: readonly string[]) => {
405
+ file_name = pathlib.resolve(file_name);
406
+
407
+ // Check if file has changed.
408
+ if (written_files.has(file_name) && written_files.get(file_name) === data) {
409
+ return ;
410
+ }
411
+
412
+ // Logs.
413
+ if (watch_log_level >= 1) {
414
+ console.log(`ts-watcher: ${vlib.Color.purple("message")} Writing out file ${file_name}.`);
415
+ }
416
+
417
+ // Write the file using the original writeFile method
418
+ ts.sys.writeFile(file_name, data, write_byte_order_mark);
419
+ written_files.set(file_name, data)
420
+
421
+ // Call the on_change callback after writing the file
422
+ if (typeof watch === "object" && typeof watch.on_change === "function" && file_name.endsWith(".js")) {
423
+ watch.on_change(resolve_path(file_name));
424
+ }
425
+ },
426
+ };
427
+
428
+ // Create WatchCompilerHost using createWatchCompilerHost
429
+ const host = ts.createWatchCompilerHost(
430
+ virtual_tsconfig_path, // Use virtual tsconfig path
431
+ undefined, // Override compiler options if needed
432
+ custom_ts_sys,
433
+ ts.createEmitAndSemanticDiagnosticsBuilderProgram,
434
+ // ts.createSemanticDiagnosticsBuilderProgram,
435
+ // reportDiagnostic callback
436
+ (diagnostic) => {
437
+ compile_result.errors.push(format_ts_error(diagnostic))
438
+ },
439
+ // reportWatchStatusChanged callback
440
+ (diagnostic) => {
441
+
442
+ // Show errors on message `Found X errors. Watching for file changes.`
443
+ if (diagnostic.code === 6194) {
444
+ if (import_order === undefined) {
445
+ const interval = setInterval(() => {
446
+ if (import_order !== undefined) {
447
+ compile_result.debug();
448
+ compile_result.errors = [];
449
+ clearInterval(interval);
450
+ }
451
+ }, 100)
452
+ } else {
453
+ if (compile_result.errors.length > 0) {
454
+ compile_result.debug();
455
+ }
456
+ compile_result.errors = [];
457
+ }
458
+ }
459
+
460
+ // Skip.
461
+ if (watch_log_level <= 0 && diagnostic.category === 3) {
462
+ // skip messages (3)
463
+ return ;
464
+ }
465
+ const message = ts.formatDiagnosticsWithColorAndContext([diagnostic], {
466
+ getCurrentDirectory: () => process.cwd(),
467
+ getCanonicalFileName: (file_name) => pathlib.resolve(file_name),
468
+ getNewLine: () => '\n',
469
+ });
470
+ console.log("ts-watcher:", message.trimEnd());
471
+ }
472
+ );
473
+
474
+ // Create the WatchProgram
475
+ const program = ts.createWatchProgram(host);
476
+
477
+ // Define the import order.
478
+ import_order = new Map();
479
+ const source_files = program.getProgram().getSourceFiles();
480
+ for (let i = 0; i < source_files.length; i++) {
481
+ const source = source_files[i];
482
+ const file_name = pathlib.resolve(source.fileName).toLowerCase();
483
+ if (!import_order.has(file_name)) {
484
+ import_order.set(file_name, i);
485
+ }
486
+ }
487
+
488
+ // Assign the stop function to terminate the watch program
489
+ compile_result.stop = () => {
490
+ program.close();
491
+ console.log("ts-watcher:", "Stopped watching.");
492
+ };
493
+ return compile_result;
494
+ }
495
+
496
+ // Non-watch mode continues as before
497
+
498
+ // Create the initial TypeScript program to get all source files.
499
+ const initial_program = ts.createProgram({
500
+ rootNames: parsed_tsconfig.fileNames,
501
+ options: parsed_tsconfig.options,
502
+ });
503
+ const program_source_files = initial_program.getSourceFiles();
504
+ const all_source_files = program_source_files.filter(sf => !sf.isDeclarationFile);
505
+
506
+ // Check empty source files.
507
+ if (all_source_files.length === 0) {
508
+ compile_result.errors.push({ data: "No source files were found. Please check your entry paths." });
509
+ return compile_result;
510
+ }
511
+
512
+ // console.log({
513
+ // entry_paths,
514
+ // // all_source_files,
515
+ // // compiler_opts: parsed_tsconfig.options,
516
+ // file_names: parsed_tsconfig.fileNames,
517
+ // })
518
+
519
+ // Get extracted exports.
520
+ if (extract_exports) {
521
+
522
+ // Obtain the TypeChecker
523
+ const checker = initial_program.getTypeChecker()
524
+
525
+ // Iterate through all source files in the program
526
+ for (let i = 0; i < program_source_files.length; i++) {
527
+ const source = program_source_files[i]
528
+
529
+ // Skip declaration files (.d.ts) if not needed
530
+ if (source.isDeclarationFile) continue;
531
+
532
+ // Get the module symbol for the source file
533
+ const symbol = checker.getSymbolAtLocation(source);
534
+
535
+ // Get exports of the module
536
+ if (symbol) {
537
+ if (compile_result.exports[source.fileName] === undefined) {
538
+ compile_result.exports[source.fileName] = [];
539
+ }
540
+ const list = compile_result.exports[source.fileName];
541
+ const exports = checker.getExportsOfModule(symbol);
542
+ for (const exp of exports) {
543
+ const name = exp.getName();
544
+ if (name !== "default") {
545
+ list.push(name);
546
+ }
547
+ }
548
+ }
549
+ }
550
+ }
551
+
552
+ // console.log("Get source files:", Date.now() - now); now = Date.now()
553
+
554
+ // Preprocess each source file.
555
+ for (let i = 0; i < all_source_files.length; i++) {
556
+ const source_file = all_source_files[i];
557
+ const file_name = pathlib.resolve(source_file.fileName);
558
+
559
+ // Add input file to compile_result.
560
+ compile_result.inputs.push(file_name);
561
+
562
+ // Skip files if exact_files is true and the file is not an entry file.
563
+ if (exact_files && !entry_paths.includes(file_name)) {
564
+ continue;
565
+ }
566
+
567
+ // Apply default preprocessing.
568
+ processed_files[file_name] = Preprocessing.preprocess(
569
+ file_name,
570
+ source_file.text,
571
+ { macros: true, templates },
572
+ );
573
+
574
+ // Apply user-defined preprocessing.
575
+ if (preprocess) {
576
+ let res: any = preprocess(file_name, processed_files[file_name]);
577
+ if (res instanceof Promise) {
578
+ res = await res;
579
+ }
580
+ if (typeof res === "string") {
581
+ processed_files[file_name] = res;
582
+ }
583
+ }
584
+ }
585
+ // console.log("Processed files:", Object.keys(processed_files))
586
+
587
+ // console.log("Apply preprocessing:", Date.now() - now); now = Date.now()
588
+
589
+ // Create a custom CompilerHost for non-watch mode
590
+ const file_exists_cache = new Map<string, boolean>();
591
+ const compiler_host: ts.CompilerHost = {
592
+ fileExists: (file_name) => {
593
+ // console.log("fileExists", file_name)
594
+ const resolved_file = pathlib.resolve(file_name);
595
+ if (processed_files[resolved_file]) {
596
+ return true;
597
+ }
598
+ else if (file_exists_cache.has(resolved_file)) {
599
+ return file_exists_cache.get(resolved_file) as boolean;
600
+ }
601
+ const res = fs.existsSync(resolved_file);
602
+ file_exists_cache.set(resolved_file, res);
603
+ return res;
604
+ },
605
+ directoryExists: ts.sys.directoryExists,
606
+ getCurrentDirectory: ts.sys.getCurrentDirectory,
607
+ getDirectories: ts.sys.getDirectories,
608
+ getCanonicalFileName: ts.sys.useCaseSensitiveFileNames
609
+ ? (file_name) => file_name
610
+ : (file_name) => file_name.toLowerCase(),
611
+ getNewLine: () => ts.sys.newLine,
612
+ getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options),
613
+ getSourceFile: (file_name, language_version, on_error) => {
614
+
615
+ const resolved_file = pathlib.resolve(file_name);
616
+
617
+ if (processed_files[resolved_file]) {
618
+ // if (resolved_file.endsWith("home.ts") || resolved_file.endsWith("home.js")) console.log("getSourceFile1", resolved_file)
619
+ return ts.createSourceFile(
620
+ resolved_file,
621
+ processed_files[resolved_file],
622
+ language_version,
623
+ true
624
+ );
625
+ }
626
+ if (exact_files && !entry_paths.includes(resolved_file)) {
627
+ // if (resolved_file.endsWith("home.ts") || resolved_file.endsWith("home.js")) console.log("getSourceFile2", resolved_file)
628
+ return undefined; // skip by exact files.
629
+ }
630
+ if (!fs.existsSync(resolved_file)) {
631
+ // if (resolved_file.endsWith("home.ts") || resolved_file.endsWith("home.js")) console.log("getSourceFile3", resolved_file)
632
+ if (on_error) on_error(`File not found: ${resolved_file}`);
633
+ return undefined;
634
+ }
635
+ // if (resolved_file.endsWith("home.ts") || resolved_file.endsWith("home.js")) console.log("getSourceFile4", resolved_file)
636
+ const source_code = fs.readFileSync(resolved_file, 'utf-8');
637
+ return ts.createSourceFile(
638
+ resolved_file,
639
+ source_code,
640
+ language_version,
641
+ true
642
+ );
643
+ },
644
+ readFile: (file_name) => {
645
+ // console.log("readFile", file_name)
646
+ const resolved_file = pathlib.resolve(file_name);
647
+ // console.log("readFile2", resolved_file)
648
+ if (processed_files[resolved_file]) {
649
+ // console.log("readFile3", resolved_file)
650
+ return processed_files[resolved_file];
651
+ }
652
+ if (exact_files && !entry_paths.includes(resolved_file)) {
653
+ // console.log("readFile4", resolved_file)
654
+ return undefined; // skip by exact files.
655
+ }
656
+ // console.log("readFile5", resolved_file)
657
+ return fs.readFileSync(resolved_file, 'utf-8');
658
+ },
659
+ useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
660
+ writeFile: (file_name, data, write_byte_order_mark, on_error, source_files) => {
661
+ compile_result.outputs.push(file_name);
662
+
663
+ if (file_name.endsWith('.js')) {
664
+ const paths = parsed_tsconfig.options.paths || {};
665
+ const baseUrl = parsed_tsconfig.options.baseUrl || './';
666
+
667
+ const transformed = data.replace(
668
+ /(import|export)(\s+(?:\*\s+as\s+[^,}\s]+|\{[^}]*\}|[^,}\s]+)(?:\s*,\s*(?:\*\s+as\s+[^,}\s]+|\{[^}]*\}|[^,}\s]+))*\s+from\s+["'])([^"']+)(["'])/g,
669
+ (match, importType, importDetails, importPath, quote) => {
670
+ for (const [alias, targets] of Object.entries(paths)) {
671
+ if (importPath === alias || importPath.startsWith(alias + '/')) {
672
+ const target = targets[0];
673
+ const from = pathlib.dirname(file_name);
674
+ const to = pathlib.resolve(pathlib.dirname(baseUrl), target);
675
+ const relativePath = pathlib.relative(from, to);
676
+ const finalPath = relativePath.startsWith('.') ?
677
+ relativePath :
678
+ './' + relativePath;
679
+ return `${importType}${importDetails}${finalPath}${quote}`;
680
+ }
681
+ }
682
+ return match;
683
+ }
684
+ );
685
+
686
+ ts.sys.writeFile(file_name, transformed, write_byte_order_mark);
687
+ } else {
688
+ ts.sys.writeFile(file_name, data, write_byte_order_mark);
689
+ }
690
+ },
691
+ resolveModuleNames: (moduleNames: string[], containingFile: string) => {
692
+ const matchPath = createMatchPath(parsed_tsconfig.options.paths || {});
693
+
694
+ return moduleNames.map(moduleName => {
695
+ // First try to resolve using paths
696
+ const matchedPath = matchPath(moduleName);
697
+ // console.log(moduleName, matchedPath)
698
+ if (matchedPath) {
699
+ return {
700
+ resolvedFileName: matchedPath,
701
+ isExternalLibraryImport: false,
702
+ extension: pathlib.extname(matchedPath)
703
+ };
704
+ }
705
+
706
+ // Fall back to classic resolution
707
+ const result = ts.resolveModuleName(
708
+ moduleName,
709
+ containingFile,
710
+ parsed_tsconfig.options,
711
+ {
712
+ fileExists: compiler_host.fileExists,
713
+ readFile: compiler_host.readFile,
714
+ }
715
+ );
716
+
717
+ return result.resolvedModule;
718
+ });
719
+ },
720
+ };
721
+ function createMatchPath(patterns: { [key: string]: string[] }) {
722
+ const matchers = Object.entries(patterns).map(([prefix, paths]) => ({
723
+ prefix: prefix.endsWith('/*') ? prefix.slice(0, -2) : prefix,
724
+ paths: paths.map(p => p.endsWith('/*') ? p.slice(0, -2) : p)
725
+ }));
726
+
727
+ return (moduleName: string) => {
728
+ for (const { prefix, paths } of matchers) {
729
+ if (moduleName.startsWith(prefix)) {
730
+ const suffix = moduleName.slice(prefix.length);
731
+ for (const path of paths) {
732
+ const fullPath = path + suffix;
733
+ // Try with .ts, .tsx, and as-is
734
+ for (const ext of ['.ts', '.tsx', '', '.js']) {
735
+ const attemptPath = fullPath + ext;
736
+ if (ts.sys.fileExists(attemptPath)) {
737
+ return attemptPath;
738
+ }
739
+ }
740
+ }
741
+ }
742
+ }
743
+ return undefined;
744
+ };
745
+ }
746
+
747
+
748
+ // Create the TypeScript program
749
+ const program = ts.createProgram({
750
+ rootNames: parsed_tsconfig.fileNames,
751
+ options: parsed_tsconfig.options,
752
+ host: compiler_host,
753
+ });
754
+
755
+ // Emit the compiled JavaScript
756
+ const emit_result = program.emit();
757
+
758
+ // Collect and display diagnostics
759
+ diagnostics = ts.getPreEmitDiagnostics(program).concat(emit_result.diagnostics);
760
+
761
+ // Process diagnostics.
762
+ for (let i = 0; i < diagnostics.length; i++) {
763
+ // if (debug_file == null || diagnostics[i]?.file?.fileName === debug_file) {
764
+ compile_result.errors.push(format_ts_error(diagnostics[i]))
765
+ // }
766
+ }
767
+
768
+ // console.log("Compile:", Date.now() - now); now = Date.now()
769
+
770
+ // Response.
771
+ return compile_result;
772
+
773
+ };
774
+
775
+ /**
776
+ * Options for bundling TypeScript code.
777
+ */
778
+ export interface BundleOptions {
779
+
780
+ // Include paths.
781
+ include?: string[],
782
+
783
+ // Output path.
784
+ output?: string,
785
+
786
+ // @deprecated Additional entry paths.
787
+ entry_paths?: string[],
788
+
789
+ // Error limit.
790
+ error_limit?: number,
791
+
792
+ /**
793
+ * Target platform: 'browser' or 'node'.
794
+ */
795
+ platform?: 'browser' | 'node';
796
+
797
+ /**
798
+ * Target platform: 'ES2023' etc.
799
+ */
800
+ target?: string;
801
+
802
+ /**
803
+ * Output format based on platform.
804
+ * - For 'browser': 'iife' or 'umd'
805
+ * - For 'node': 'cjs' or 'esm'
806
+ */
807
+ format?:
808
+ | 'iife' // Immediately Invoked Function Expression (Browser)
809
+ // | 'umd' // Universal Module Definition (Browser/Node)
810
+ | 'cjs' // CommonJS (Node)
811
+ | 'esm'; // ES Modules (Browser/Node);
812
+
813
+ /**
814
+ * Enable or disable minification.
815
+ */
816
+ minify?: boolean;
817
+
818
+ /**
819
+ * Enable or disable tree shaking.
820
+ */
821
+ tree_shaking?: boolean;
822
+
823
+ /**
824
+ * Enable or disable debug console statements.
825
+ */
826
+ debug?: string | boolean;
827
+
828
+ /**
829
+ * Enable or disable source map generation.
830
+ */
831
+ sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both';
832
+
833
+ // Extract input files.
834
+ extract_inputs?: boolean;
835
+
836
+ /**
837
+ * Specify which bundler to use: 'esbuild' or 'rollup'.
838
+ * If undefined, defaults to 'esbuild'.
839
+ */
840
+ bundler?: 'esbuild' | 'rollup';
841
+
842
+ // Any other esbuild.bundle options.
843
+ opts?: any;
844
+ }
845
+
846
+ /**
847
+ * Result of the bundling process.
848
+ */
849
+ export interface BundleResult {
850
+
851
+ /**
852
+ * Bundled JavaScript code.
853
+ */
854
+ code?: string;
855
+
856
+ /**
857
+ * Compilation and bundling errors, if any.
858
+ */
859
+ errors: CompilerError[];
860
+
861
+ /**
862
+ * Source map, if generated.
863
+ */
864
+ source_map?: string;
865
+
866
+ /**
867
+ * Debug function.
868
+ */
869
+ debug: () => void;
870
+
871
+ // Input paths.
872
+ // Only defined when extract_inputs is `true`.
873
+ inputs: string[];
874
+ }
875
+
876
+ // Format an esbuild warning / error.
877
+ const format_esbuild_warning_error = (warning): CompilerError => {
878
+ let output;
879
+ if (warning.location) {
880
+ const trimmed_line = warning.location.lineText.trimStart();
881
+ const removed_start_indent = warning.location.lineText.length - trimmed_line.length;
882
+ output =
883
+ `${vlib.Color.cyan(warning.location.file)}:${vlib.Color.yellow(warning.location.line)}:${vlib.Color.yellow(warning.location.column)}` +
884
+ ` - ${vlib.Color.yellow("warning")} [esbuild${warning.id === "" ? "" : `-${warning.id}`}]: ${warning.text}\n` +
885
+ "\n" + vlib.Colors.bright_bg.white + vlib.Colors.black + warning.location.line + vlib.Colors.end + " " + trimmed_line +
886
+ "\n" + vlib.Colors.bright_bg.white + vlib.Colors.black + " ".repeat(warning.location.line.toString().length) + vlib.Colors.end +
887
+ " ".repeat(4 + warning.location.column - removed_start_indent) + vlib.Color.red("~".repeat(warning.location.length));
888
+ } else {
889
+ output = `${vlib.Color.yellow("warning")} [esbuild${warning.id === "" ? "" : `-${warning.id}`}]: ${warning.text}`
890
+ }
891
+ if (Array.isArray(warning.notes)) {
892
+ for (const note of warning.notes) {
893
+ if (note.location) {
894
+ const trimmed_line = note.location.lineText.trimStart();
895
+ const removed_start_indent = note.location.lineText.length - trimmed_line.length;
896
+ output +=
897
+ `\n ${vlib.Color.cyan(note.location.file)}:${vlib.Color.yellow(note.location.line)}:${vlib.Color.yellow(note.location.column)}` +
898
+ ` - ${vlib.Color.gray("note")}: ${note.text}\n` +
899
+ "\n" + vlib.Colors.bright_bg.white + vlib.Colors.black + note.location.line + vlib.Colors.end + " " + trimmed_line +
900
+ "\n" + vlib.Colors.bright_bg.white + vlib.Colors.black + " ".repeat(note.location.line.toString().length) + vlib.Colors.end +
901
+ " ".repeat(8 + note.location.column - removed_start_indent) + vlib.Color.red("~".repeat(note.location.length));
902
+ } else {
903
+ output +=
904
+ `\n ${vlib.Color.gray("note")}: ${note.text}`;
905
+ }
906
+ if (note.suggestion) {
907
+ console.error("@todo handle suggestion:" + note.suggestion + " note: " + JSON.stringify(note, null, 4));
908
+ }
909
+ }
910
+ }
911
+ return {
912
+ data: output,
913
+ file_name: warning.location?.file,
914
+ line: warning.location?.line,
915
+ column: warning.location?.column,
916
+ }
917
+ }
918
+
919
+ /*
920
+ * Bundles transpiled JavaScript files using esbuild.
921
+ */
922
+ export async function bundle(options: BundleOptions): Promise<BundleResult> {
923
+ // console.log(">>> BUNDLE", options)
924
+ let {
925
+ entry_paths = [],
926
+ include = [],
927
+ output = undefined,
928
+ platform = 'browser',
929
+ format = 'iife',
930
+ target = 'es2021',
931
+ minify = false,
932
+ sourcemap = false, // 'inline'
933
+ error_limit = 25,
934
+ extract_inputs = false,
935
+ tree_shaking = undefined,
936
+ debug = false,
937
+ bundler = "esbuild",
938
+ opts = {},
939
+ // bundler = "rollup",
940
+ } = options;
941
+ if (entry_paths.length > 0) {
942
+ include = include.concat(entry_paths);
943
+ }
944
+
945
+ const errors: CompilerError[] = [];
946
+ let bundled_code: string | undefined = undefined;
947
+ let bundled_source_map: string | undefined = undefined;
948
+ let inputs: string[] = [];
949
+
950
+ // Bundle using esbuild.
951
+ if (bundler === "esbuild") {
952
+ try {
953
+ const result = await esbuild.build({
954
+ entryPoints: include,
955
+ bundle: true,
956
+ platform: platform,
957
+ format: format,
958
+ target: target,
959
+ minify: minify,
960
+ sourcemap,
961
+ write: false,
962
+ metafile: extract_inputs,
963
+ logLevel: typeof debug === "boolean" ? (debug ? 'debug' : 'silent') : debug as any,
964
+ treeShaking: tree_shaking,
965
+ // logLevel: 'silent',
966
+ // outdir: "/",
967
+ // minifyWhitespace: false,
968
+ // minifySyntax: false,
969
+ // minifyIdentifiers: false,
970
+ ...opts,
971
+ });
972
+ if (result.errors.length > 0) {
973
+ for (const error of result.errors) {
974
+ errors.push(format_esbuild_warning_error(error))
975
+ }
976
+ }
977
+ if (result.warnings.length > 0) {
978
+ for (const warning of result.warnings) {
979
+ errors.push(format_esbuild_warning_error(warning))
980
+ }
981
+ }
982
+
983
+ // Set output paths.
984
+ if (extract_inputs && result.metafile?.inputs != null && typeof result.metafile?.inputs === "object") {
985
+ inputs = Object.keys(result.metafile?.inputs).map(resolve_path);
986
+ }
987
+
988
+ // Process output files.
989
+ if (result.outputFiles && result.outputFiles.length > 0) {
990
+
991
+ // Concatenate all output files
992
+ bundled_code = result.outputFiles
993
+ .filter(file => file.path === "<stdout>" || (file.path.endsWith('.js') && !file.path.endsWith('.d.js')))
994
+ .map(file => file.text)
995
+ .join('\n');
996
+
997
+ if (sourcemap) {
998
+ const source_map_file = result.outputFiles.find(file => file.path.endsWith('.map'));
999
+ if (source_map_file) {
1000
+ bundled_source_map = source_map_file.text;
1001
+ }
1002
+ }
1003
+ } else {
1004
+ errors.push({ data: "No output files were generated during bundling." });
1005
+ }
1006
+
1007
+ } catch (err: any) {
1008
+ let processed = false;
1009
+ if (Array.isArray(err.errors) && err.errors.length > 0) {
1010
+ for (const error of err.errors) {
1011
+ errors.push(format_esbuild_warning_error(error))
1012
+ }
1013
+ processed = true;
1014
+ }
1015
+ if (Array.isArray(err.warnings) && err.warnings.length > 0) {
1016
+ for (const warning of err.warnings) {
1017
+ errors.push(format_esbuild_warning_error(warning))
1018
+ }
1019
+ processed = true;
1020
+ }
1021
+ if (!processed) {
1022
+ errors.push({ data: err.message || String(err) });
1023
+ }
1024
+ }
1025
+ }
1026
+
1027
+ // Bundle using rollup.
1028
+ else {
1029
+ try {
1030
+ throw new Error("Rollup is deprecated since it is currently out of use.");
1031
+
1032
+ // // Determine if minification is needed
1033
+ // const plugins: Plugin[] = [
1034
+ // nodeResolve({
1035
+ // browser: platform === 'browser',
1036
+ // preferBuiltins: platform === 'node',
1037
+ // }),
1038
+ // // commonjs(),
1039
+ // ];
1040
+
1041
+ // if (minify) {
1042
+ // plugins.push(terser());
1043
+ // }
1044
+ // const input_set: Set<string> = new Set();
1045
+ // // if (extract_inputs) {
1046
+ // // plugins.push(
1047
+ // // // Custom plugin to collect all imported files
1048
+ // // {
1049
+ // // name: 'collect-input-files',
1050
+ // // resolveId(source, importer) {
1051
+ // // return null; // Let Rollup handle module resolution
1052
+ // // },
1053
+ // // load(id) {
1054
+ // // console.log("ADD:",id)
1055
+ // // input_set.add(id); // Add each module to the input_set set
1056
+ // // return null; // Let Rollup handle loading the module
1057
+ // // }
1058
+ // // }
1059
+ // // )
1060
+ // // }
1061
+
1062
+ // const rollup_input_options: RollupOptions = {
1063
+ // input: include,
1064
+ // plugins: plugins,
1065
+ // treeshake: tree_shaking !== undefined ? tree_shaking : true,
1066
+ // // Suppress Rollup warnings if not in debug mode
1067
+ // onwarn: (warning, warn) => {
1068
+ // if (debug) {
1069
+ // warn(warning);
1070
+ // }
1071
+ // // Otherwise, suppress warnings
1072
+ // },
1073
+ // };
1074
+
1075
+ // const bundle = await rollup(rollup_input_options);
1076
+
1077
+ // const rollup_output_options: OutputOptions = {
1078
+ // format: format,
1079
+ // sourcemap: sourcemap !== false,
1080
+ // // Name is required for 'iife' format
1081
+ // ...(format === 'iife' ? { name: 'Bundle' } : {}),
1082
+ // // Generate inline source maps if specified
1083
+ // ...(sourcemap === 'inline' ? { sourcemap: 'inline' } : {}),
1084
+ // ...(sourcemap === 'external' ? { sourcemap: true } : {}),
1085
+ // ...(sourcemap === 'linked' ? { sourcemap: true, sourcemapPathTransform: (relativePath: string) => `./${relativePath}` } : {}),
1086
+ // // Additional Rollup output options can be added here
1087
+ // };
1088
+
1089
+ // const { output } = await bundle.generate(rollup_output_options);
1090
+
1091
+ // bundled_code = '';
1092
+ // bundled_source_map = '';
1093
+
1094
+ // // @todo remove as any
1095
+ // for (const item of output as any) {
1096
+ // if (item.type === 'chunk') {
1097
+ // bundled_code += item.code;
1098
+ // if (item.map) {
1099
+ // bundled_source_map += item.map.toString();
1100
+ // }
1101
+ // if (extract_inputs) {
1102
+ // for (const name of Object.keys(item.modules)) {
1103
+ // if (!input_set.has(name)) {
1104
+ // input_set.add(name);
1105
+ // }
1106
+ // }
1107
+ // }
1108
+ // }
1109
+ // }
1110
+ // inputs = extract_inputs ? Array.from(input_set) : []
1111
+
1112
+ } catch (err: any) {
1113
+ errors.push({ data: err.message ?? String(err) });
1114
+ // throw new Error(`Rollup bundling failed: ${err.message || err}`);
1115
+ }
1116
+ }
1117
+
1118
+ // Write to file.
1119
+ if (typeof output === "string") {
1120
+ await new vlib.Path(output).save(bundled_code ?? "");
1121
+ }
1122
+
1123
+ return {
1124
+ code: bundled_code,
1125
+ source_map: bundled_source_map,
1126
+ errors,
1127
+ inputs,
1128
+ debug() {
1129
+ for (let i = 0; i < Math.min(error_limit, errors.length); i++) {
1130
+ console.error(errors[i].data);
1131
+ }
1132
+
1133
+ if (error_limit != null && errors.length > error_limit) {
1134
+ console.log(`Displayed the first ${error_limit} errors out of ${errors.length}.`);
1135
+ } else {
1136
+ console.log(`Encountered ${errors.length} errors.`);
1137
+ }
1138
+
1139
+ if (typeof bundled_code === "string" && bundled_code !== "") {
1140
+ console.log(`Generated code of ${vlib.Utils.format_bytes(Buffer.byteLength(bundled_code as string, 'utf8'))}`)
1141
+ }
1142
+ },
1143
+ }
1144
+ };
1145
+
1146
+ /*
1147
+ // Collect imports.
1148
+ export async function collect_exports(file_path: string, data: string) {
1149
+ const exported_names = new Set<string>();
1150
+
1151
+ const source_file = ts.createSourceFile(
1152
+ file_path,
1153
+ data,
1154
+ ts.ScriptTarget.ESNext,
1155
+ true
1156
+ );
1157
+
1158
+ function visit_node(node: ts.Node) {
1159
+ // Handle named export declarations: export { Utils, Another };
1160
+ if (ts.isExportDeclaration(node)) {
1161
+ if (node.exportClause && ts.isNamedExports(node.exportClause)) {
1162
+ node.exportClause.elements.forEach(element => {
1163
+ const n = element.name.getText();
1164
+ if (!exported_names.has(n)) {
1165
+ exported_names.add(n);
1166
+ }
1167
+ });
1168
+ }
1169
+ }
1170
+ // Handle export specifiers: export { Utils } from './utils';
1171
+ else if (ts.isExportSpecifier(node)) {
1172
+ const n = node.name.getText();
1173
+ if (!exported_names.has(n)) {
1174
+ exported_names.add(n);
1175
+ }
1176
+ }
1177
+ // Handle exported declarations: export function foo() {}, export const bar = 1, etc.
1178
+ else if (ts.isExportAssignment(node)) {
1179
+ // Handle default exports if needed
1180
+ const expr = node.expression;
1181
+ if (ts.isIdentifier(expr)) {
1182
+ const n = expr.getText();
1183
+ if (!exported_names.has(n)) {
1184
+ exported_names.add(n);
1185
+ }
1186
+ }
1187
+ // Handle other export assignment expressions if necessary
1188
+ }
1189
+ else {
1190
+ const modifiers = ts.getModifiers(node as any);
1191
+ if (modifiers && modifiers.some(mod => mod.kind === ts.SyntaxKind.ExportKeyword)) {
1192
+ if (ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node) || ts.isEnumDeclaration(node)) {
1193
+ if (node.name) {
1194
+ const n = node.name.getText();
1195
+ if (!exported_names.has(n)) {
1196
+ exported_names.add(n);
1197
+ }
1198
+ }
1199
+ }
1200
+ else if (ts.isVariableStatement(node)) {
1201
+ node.declarationList.declarations.forEach(declaration => {
1202
+ const n = declaration.name.getText();
1203
+ if (!exported_names.has(n)) {
1204
+ exported_names.add(n);
1205
+ }
1206
+ });
1207
+ }
1208
+ }
1209
+ }
1210
+
1211
+ ts.forEachChild(node, visit_node);
1212
+ }
1213
+
1214
+ visit_node(source_file);
1215
+
1216
+ return Array.from(exported_names);
1217
+ }
1218
+
1219
+ // Get all included soruce files.
1220
+ export async function get_source_files(entry_paths: string[]): Promise<string[]> {
1221
+ const result = await esbuild.build({
1222
+ entryPoints: entry_paths,
1223
+ bundle: true,
1224
+ metafile: true,
1225
+ write: false, // Keep outputs in memory
1226
+ });
1227
+ if (!result.metafile) {
1228
+ throw new Error('Metafile not generated');
1229
+ }
1230
+ return Object.keys(result.metafile.inputs);
1231
+ }
1232
+
1233
+ */
1234
+
1235
+ // Exports.
1236
+ export default {
1237
+ compile,
1238
+ bundle,
1239
+ preprocessing: Preprocessing,
1240
+ // collect_exports,
1241
+ // get_source_files,
1242
+ };