@vandenberghinc/volt 1.1.26 → 1.1.28

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