@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
@@ -0,0 +1,720 @@
1
+ /**
2
+ * @author Daan van den Bergh
3
+ * @copyright © 2022 - 2025 Daan van den Bergh. All rights reserved
4
+ */
5
+ // ---------------------------------------------------------
6
+ // Imports.
7
+ import * as vlib from "@vandenberghinc/vlib";
8
+ import * as vts from "@vandenberghinc/vlib/vts";
9
+ import * as vhighlight from "@vandenberghinc/vhighlight";
10
+ import zlib from 'zlib';
11
+ import { Meta } from "./meta.js";
12
+ import { Route } from './route.js';
13
+ import { Frontend } from './frontend.js';
14
+ import * as crypto from "crypto";
15
+ const { debug } = vlib;
16
+ // ---------------------------------------------------------
17
+ // View.
18
+ // @todo add template vars for callback and css and js include files.
19
+ /**
20
+ * @nav Backend
21
+ * @chapter Endpoints
22
+ * @title View
23
+ * @class
24
+ *
25
+ * @param source
26
+ * The file path to the client side JavaScript source code.
27
+ *
28
+ * @param callback
29
+ * The client side callback function; this function will be executed at the client side.
30
+ * For this feature the `Content-Security-Policy: script-src` must be updated with, for example, `unsafe-inline`.
31
+ *
32
+ * @param includes
33
+ * The included static JS files.
34
+ *
35
+ * By default, the local includes will be embedded into the HTML page. However, this behaviour can be disabled by passing an object of type `IncludeObject` with the attribute `embed = false`.
36
+ *
37
+ * @param links
38
+ * The included static CSS files.
39
+ *
40
+ * By default, the local links will be embedded into the HTML page. However, this behaviour can be disabled by passing an object of type `LinkObject` with the attribute `embed = false`.
41
+ *
42
+ * @param templates
43
+ * Templates that will replace the `callback` code. Templates can be created using the `$TEMPLATE` template style.
44
+ *
45
+ * @warning
46
+ * Templates will only be used on the code of the `callback` attribute.
47
+ *
48
+ * @param meta
49
+ * The meta information object.
50
+ *
51
+ * @param jquery
52
+ * Include jQuery by default.
53
+ *
54
+ * @param body_style
55
+ * The style of the `<body>` element. When left undefined, the static attribute `View.body_style` will be used.
56
+ *
57
+ * @param splash_screen
58
+ * The splash screen settings. When left undefined, the static attribute `View.splash_screen` will be used.
59
+ *
60
+ * @param tree_shaking
61
+ * Optimize JavaScript source code by removing dead code.
62
+ *
63
+ * @param mangle
64
+ * Optimize JavaScript source code by mangling function names.
65
+ *
66
+ * @param _src
67
+ * Internal parameter (ignored).
68
+ *
69
+ * @typedef IncludeObject
70
+ * @property src
71
+ * The source URL of the script to include. (required)
72
+ * @property embed
73
+ * When set to `false`, disables embedding the endpoint's content into the HTML page.
74
+ * @property attributes
75
+ * Any other attributes will be assigned to the `<script>` tag.
76
+ *
77
+ * @typedef LinkObject
78
+ * @property href
79
+ * The source URL of the link to include. (required)
80
+ * @property rel
81
+ * The `rel` attribute of the link tag.
82
+ * @property embed
83
+ * When set to `false`, disables embedding the endpoint's content into the HTML page.
84
+ * @property attributes
85
+ * Any other attributes will be assigned to the `<link>` tag.
86
+ *
87
+ * @static
88
+ * @memberof View
89
+ * @member body_style
90
+ * The style of the `<body>` element. This static attribute will be used on all Views when defined. However,
91
+ * it can be overridden for a single View by defining the parameter.
92
+ *
93
+ * @static
94
+ * @memberof View
95
+ * @member splash_screen
96
+ * The splash screen settings. This static attribute will be used on all Views when defined. However,
97
+ * it can be overridden for a single View by defining the parameter.
98
+ */
99
+ export class View {
100
+ // Global settings.
101
+ static includes = [];
102
+ static links = [];
103
+ static body_style = null; // css string style.
104
+ static splash_screen = undefined; // SplashScreen object.
105
+ // Private static attributes,
106
+ static _volt_css;
107
+ static _vhighlight_css;
108
+ // Attributes.
109
+ source;
110
+ source_path;
111
+ callback;
112
+ includes;
113
+ links;
114
+ templates;
115
+ meta;
116
+ jquery;
117
+ lang;
118
+ body_style;
119
+ splash_screen;
120
+ tree_shaking;
121
+ mangle;
122
+ _src;
123
+ _embedded_sources;
124
+ is_js_ts_view;
125
+ _html;
126
+ raw_html;
127
+ _bundle;
128
+ payments;
129
+ // vhighlight?: string | undefined;
130
+ min_device_width;
131
+ server;
132
+ endpoint;
133
+ // Constructor.
134
+ constructor({ source = null, callback = null, includes = [], links = [], templates = {}, meta = new Meta(), jquery = false, lang = "en", body_style = null, splash_screen = undefined, tree_shaking = false, mangle = false, min_device_width = 600, _src, }) {
135
+ // Arguments.
136
+ this.source = source;
137
+ this.callback = callback;
138
+ this.includes = [...View.includes, ...includes];
139
+ this.links = [...View.links, ...links];
140
+ this.templates = templates;
141
+ this.meta = meta;
142
+ this.jquery = jquery;
143
+ this.lang = lang;
144
+ this.body_style = body_style ?? View.body_style;
145
+ this.splash_screen = splash_screen ?? View.splash_screen;
146
+ this.tree_shaking = tree_shaking;
147
+ this.mangle = mangle;
148
+ this.min_device_width = min_device_width;
149
+ // System arguments.
150
+ this._src = _src;
151
+ this._embedded_sources = [];
152
+ // Clean source, required to match against endpoint's.
153
+ if (this.source != null) {
154
+ this.source_path = new vlib.Path(this.source);
155
+ if (!this.source_path.exists()) {
156
+ throw new Error(`Defined source path "${this.source}" does not exist.`);
157
+ }
158
+ this.source_path = this.source_path.abs();
159
+ this.source = this.source_path.str();
160
+ }
161
+ // Is js/ts bundle view.
162
+ this.is_js_ts_view = this.source_path != null && /\.(jsx?|tsx?)/.test(this.source_path.extension());
163
+ // Check args.
164
+ if (typeof source !== "string" && typeof callback !== "function") {
165
+ throw Error("Invalid usage, define either parameter \"source\" or \"callback\".");
166
+ }
167
+ // Drop duplicate includes.
168
+ this.includes = vlib.Array.drop_duplicates(this.includes);
169
+ // Attributes.
170
+ this._html = undefined;
171
+ this._bundle = undefined;
172
+ }
173
+ // Initialize.
174
+ _initialize(server, endpoint) {
175
+ if (server === undefined) {
176
+ throw Error("Invalid usage, define parameter \"server\".");
177
+ }
178
+ if (endpoint === undefined) {
179
+ throw Error("Invalid usage, define parameter \"endpoint\".");
180
+ }
181
+ this.server = server;
182
+ this.endpoint = endpoint;
183
+ }
184
+ // Bundle the compiled typescript / javascript dynamically on demand to optimize server startup for development purposes.
185
+ async _dynamic_bundle() {
186
+ // Server & endpoint.
187
+ if (this.server === undefined || this.endpoint === undefined) {
188
+ throw Error("View has not been initialized with \"View._initialize()\" yet.");
189
+ }
190
+ // Bundle.
191
+ debug(3, this.endpoint?.route?.id, `: Bundling entry path "${this.source_path?.str()}".`);
192
+ this._bundle = await vts.bundle({
193
+ include: this.source_path ? [this.source_path?.str()] : [],
194
+ output: `/tmp/${this.endpoint.route.method}_${this.source_path.str().replace(/\//g, "_")}.js`, // esbuild requires an output path to resolve .css and .ttf files etc which can be imported by libraries (such as monaco-editor).
195
+ minify: false, //this._server.production,
196
+ platform: "browser",
197
+ format: "esm",
198
+ // format: "iife", // can causes issues with node_modules imports.
199
+ target: "es2022",
200
+ // sourcemap: this.server.production ? false : "inline",
201
+ extract_inputs: true, // since bundle.inputs is used by server.js.
202
+ tree_shaking: true,
203
+ });
204
+ // Set options based on inputs.
205
+ this.payments = this._bundle.inputs.find((path) => path.endsWith("/modules/paddle.js"));
206
+ // this.vhighlight = this.bundle.inputs.find((path: string) => path.endsWith("/vhighlight.js"));
207
+ }
208
+ /** Ensure the view is bundled when required. */
209
+ async ensure_bundle() {
210
+ if (this.is_js_ts_view && !this._bundle) {
211
+ return this._dynamic_bundle();
212
+ }
213
+ }
214
+ /** Create an error HTML file when errors are encountered during the bundle process. */
215
+ async _build_bundle_err_html() {
216
+ // Dont show in production.
217
+ if (this.server?.production) {
218
+ throw new Error("Encountered an error while bundling in production.");
219
+ }
220
+ // A nonce identifier.
221
+ const nonce_identifier = "{{__VOLT_NONCE__}}";
222
+ // Inspect bundle.
223
+ const bundle = await vts.inspect_bundle({
224
+ include: this.source_path ? [this.source_path?.str()] : [],
225
+ output: vlib.Path.tmp().join(`${this.endpoint?.route.method}_${this.source_path.str().replace(/\//g, "_")}.js`), // esbuild requires an output path to resolve .css and .ttf files etc which can be imported by libraries (such as monaco-editor).
226
+ minify: false, //this._server.production,
227
+ platform: "browser",
228
+ format: "esm",
229
+ // format: "iife", // can causes issues with node_modules imports.
230
+ target: "es2022",
231
+ tree_shaking: true,
232
+ });
233
+ // Log to server
234
+ this.server?.log.error(this.endpoint?.route?.id, `: Encountered an error while bundling "${this.source}".\n${bundle.debug({ limit: 25 })}`);
235
+ // HTML escape function
236
+ const escape_html = (str) => vlib.Color.to_html(str
237
+ .replace(/&/g, '&amp;')
238
+ .replace(/</g, '&lt;')
239
+ .replace(/>/g, '&gt;')
240
+ .replace(/"/g, '&quot;')
241
+ .replace(/'/g, '&#39;'));
242
+ if (this.server?.production) {
243
+ this._html = `
244
+ <!DOCTYPE html>
245
+ <html lang='${this.lang}'>
246
+ <head>
247
+ <meta charset="UTF-8">
248
+ <meta name="viewport" content="width=device-width, initial-scale=1">
249
+ <title>Bundling Error</title>
250
+ <style nonce="${nonce_identifier}">
251
+ body {
252
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 2rem; background: #f5f5f5;
253
+ }
254
+ h1 {
255
+ color: #d32f2f; margin-top: 0;
256
+ }
257
+ #error-container {
258
+ max-width: 800px; margin: 0 auto; background: white; padding: 2rem; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
259
+ }
260
+ </style>
261
+ </head>
262
+ <body>
263
+ <div id="error-container">
264
+ <h1>Bundling Error</h1>
265
+ <p>An error occurred while processing your request. Please contact support if this issue persists.</p>
266
+ </div>
267
+ </body>
268
+ </html>
269
+ `.dedent(false);
270
+ }
271
+ else {
272
+ // Development mode - show full debug info
273
+ const formatted_import_chains = bundle.format_import_chains();
274
+ const formatted_errors = bundle.format_errors();
275
+ this._html = `
276
+ <!DOCTYPE html>
277
+ <html lang='${this.lang}'>
278
+ <head>
279
+ <meta charset="UTF-8">
280
+ <meta name="viewport" content="width=device-width, initial-scale=1">
281
+ <title>Bundling Error - ${escape_html(this.source || 'Unknown')}</title>
282
+ <style nonce="${nonce_identifier}">
283
+ body {
284
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
285
+ margin: 0;
286
+ padding: 1rem;
287
+ background: #1e1e1e;
288
+ color: #d4d4d4;
289
+ }
290
+ .container {
291
+ max-width: 1200px;
292
+ margin: 0 auto;
293
+ }
294
+ h1 {
295
+ color: #FFFFFF;
296
+ font-size: 1.5rem;
297
+ margin-bottom: 0.5rem;
298
+ }
299
+ .source {
300
+ color: #C0C0C0;
301
+ font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
302
+ font-size: 0.875rem;
303
+ margin-bottom: 1rem;
304
+ }
305
+ pre {
306
+ background: #2d2d2d;
307
+ border: 1px solid #3e3e3e;
308
+ border-radius: 4px;
309
+ padding: 1rem;
310
+ overflow-x: auto;
311
+ font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
312
+ font-size: 0.875rem;
313
+ line-height: 1.5;
314
+ margin: 20px 0px 0px 0px;
315
+ }
316
+ .error-count {
317
+ background: #f44336;
318
+ color: white;
319
+ padding: 0.25rem 0.5rem;
320
+ border-radius: 4px;
321
+ font-size: 0.875rem;
322
+ display: inline-block;
323
+ margin-bottom: 1rem;
324
+ }
325
+ </style>
326
+ </head>
327
+ <body>
328
+ <div class="container">
329
+ <h1>Bundle Error</h1>
330
+ <div class="source">Source: ${escape_html(this.source || 'Unknown')}</div>
331
+ <div class="error-count">${bundle.errors.length} error${bundle.errors.length === 1 ? '' : 's'}</div>
332
+ <pre>${escape_html(bundle.debug({ limit: -1 }))}</pre>
333
+ <!--<h2>Metafile</h2>
334
+ <pre>${escape_html(bundle.metafile ?? "No metafile detected.")}</pre>
335
+ <h2>Input files</h2>
336
+ <pre>${escape_html(bundle.inputs.length ? bundle.inputs.join("\n") : "No input files detected.")}</pre>
337
+ <h2>Import Chains</h2>
338
+ <pre>${escape_html(formatted_import_chains.length
339
+ ? formatted_import_chains.join("\n")
340
+ : "No import chains detected.")}</pre>
341
+ <h2>Encountered Errors</h2>
342
+ <pre>${escape_html(formatted_errors.length ? formatted_errors.join("\n") : "No errors detected.")}</pre>
343
+ -->
344
+ </div>
345
+ </body>
346
+ </html>
347
+ `.dedent(false);
348
+ }
349
+ this.html_nonce_split = this._html.split(nonce_identifier);
350
+ }
351
+ // Build html.
352
+ async _build_html() {
353
+ // A nonce identifier.
354
+ const nonce_identifier = "{{__VOLT_NONCE__}}";
355
+ // Server & endpoint.
356
+ if (this.server == null || this.endpoint == null) {
357
+ throw Error("View has not been initialized with \"View._initialize()\" yet.");
358
+ }
359
+ // Bundle js files automatically.
360
+ if (this.is_js_ts_view && !this._bundle) {
361
+ await this._dynamic_bundle();
362
+ }
363
+ if (this._bundle != null && this._bundle.errors.length > 0) {
364
+ return this._build_bundle_err_html();
365
+ }
366
+ // Vars.
367
+ const line_break = this.server.production ? "\n" : "\n";
368
+ const has_bundle = this._bundle != null && typeof this._bundle === "object";
369
+ // console.log("Bundle:", this._bundle)
370
+ // Initialize html.
371
+ this._html = "";
372
+ // Doctype.
373
+ this._html += `<!DOCTYPE html><html lang='${this.lang}'>${line_break}`;
374
+ // Headers.
375
+ this._html += `<head>${line_break}`;
376
+ // Meta.
377
+ if (this.meta) {
378
+ this._html += this.meta.build_html(this.server.full_domain) + line_break;
379
+ }
380
+ // this.html = "Hello World!";
381
+ // return;
382
+ // ------------------------------------------------------------------------------------------
383
+ // Stylesheets & links.
384
+ // Default stylesheet to avoid inline `style=""`.
385
+ this._html += `<style nonce="${nonce_identifier}">` +
386
+ `html { min-width:100%;min-height:100%; }` +
387
+ `body { width:100vw;height:100vh;margin:0;padding:0;${this.body_style ?? ""} }` +
388
+ `</style>${line_break}`;
389
+ // Embed stylesheet.
390
+ const embed_stylesheet = (url, embed) => {
391
+ if (embed == null &&
392
+ url != null &&
393
+ url.charAt(0) === "/") {
394
+ for (const endpoint of this.server.endpoints.values()) {
395
+ if (url === endpoint.route.endpoint_str) {
396
+ if (typeof endpoint.raw_data === "string") {
397
+ embed = endpoint.raw_data;
398
+ }
399
+ else if (typeof endpoint.data === "string") {
400
+ embed = endpoint.data;
401
+ }
402
+ break;
403
+ }
404
+ }
405
+ }
406
+ if (embed) {
407
+ this._html += `<style nonce="${nonce_identifier}">${line_break}${embed}${line_break}</style>${line_break}`;
408
+ if (url) {
409
+ this._embedded_sources.push(url);
410
+ }
411
+ return true;
412
+ }
413
+ return false;
414
+ };
415
+ // Include a link async.
416
+ let include_links_script = null;
417
+ const include_link_async = (link) => {
418
+ if (include_links_script == null) {
419
+ include_links_script = "async function __incl_lnk(args){var link = document.createElement('link');for (let key in args) {if (args.hasOwnProperty(key)){link.setAttribute(key,args[key])}}document.head.appendChild(link)}" + line_break;
420
+ }
421
+ if (link.rel == null) {
422
+ link.rel = "stylesheet";
423
+ }
424
+ include_links_script += `__incl_lnk(${JSON.stringify(link)});${line_break}`;
425
+ };
426
+ // Stylesheets.
427
+ if (!View._volt_css) {
428
+ View._volt_css = await new vlib.Path(Frontend.css.volt).load();
429
+ }
430
+ if (!View._vhighlight_css) {
431
+ View._vhighlight_css = await new vlib.Path(vhighlight.web_exports.css).load();
432
+ }
433
+ embed_stylesheet(undefined, View._volt_css);
434
+ embed_stylesheet(undefined, View._vhighlight_css);
435
+ // Add custom stylesheet for minimum device width on smaller screens.
436
+ if (this.min_device_width != null) {
437
+ this._html += `
438
+ <script nonce="${nonce_identifier}">
439
+ let has_min_width = false;
440
+ const viewport = document.querySelector('meta[name="viewport"]');
441
+ function set_min_width() {
442
+ const device_width = window.innerWidth;
443
+ // console.log("Device width [" + device_width + "] below min_device_width [${this.min_device_width} =", (device_width <= ${this.min_device_width}).toString() + "]");
444
+ if (device_width <= ${this.min_device_width}) {
445
+ const content = 'width=${this.min_device_width}, initial-scale=' + (device_width / ${this.min_device_width});
446
+ // console.log("Below ${this.min_device_width}", {content, width: device_width, has_min_width, viewport: viewport.getAttribute('content')});
447
+ if (viewport.getAttribute('content') !== content) {
448
+ // console.log('set min width viewport', device_width, device_width / ${this.min_device_width})
449
+ viewport.setAttribute('content', content);
450
+ has_min_width = true;
451
+ }
452
+ } else if (has_min_width) {
453
+ // console.log('disable min width viewport', device_width)
454
+ viewport.setAttribute('content', 'width=device-width, initial-scale=1');
455
+ has_min_width = false;
456
+ }
457
+ }
458
+ let timeout_load; window.addEventListener('load', () => {clearTimeout(timeout_load); timeout_load = setTimeout(set_min_width, 25); } );
459
+ let timeout_resize; window.addEventListener('resize', () => {clearTimeout(timeout_resize); timeout_resize = setTimeout(set_min_width, 25); } );
460
+ set_min_width();
461
+ </script>
462
+ `.dedent();
463
+ }
464
+ // this.html += `<script nonce="${nonce_identifier}">
465
+ // // This version prevents the infinite loop
466
+ // let resizeTimeout;
467
+ // let viewportChangeInProgress = false;
468
+ // const viewport = document.querySelector('meta[name="viewport"]');
469
+ // const originalContent = viewport.getAttribute('content');
470
+ // function set_min_width() {
471
+ // // Don't run if we're already processing a viewport change
472
+ // if (viewportChangeInProgress) return;
473
+ // // Clear any pending resize timeouts
474
+ // clearTimeout(resizeTimeout);
475
+ // // Set a small delay to prevent rapid successive calls
476
+ // resizeTimeout = setTimeout(() => {
477
+ // viewportChangeInProgress = true;
478
+ // if (window.innerWidth < 400) {
479
+ // // Only update if needed
480
+ // viewport.setAttribute('content', \`width = 400, initial - scale\${ window.innerWidth / 400 }, maximum - scale=1\`);
481
+ // } else {
482
+ // // Restore original viewport
483
+ // viewport.setAttribute('content', originalContent);
484
+ // }
485
+ // // Allow future updates after a delay
486
+ // setTimeout(() => {
487
+ // viewportChangeInProgress = false;
488
+ // }, 300);
489
+ // }, 200);
490
+ // }
491
+ // window.addEventListener('DOMContentLoaded', set_min_width);
492
+ // window.addEventListener('orientationchange', set_min_width);
493
+ // </script>`
494
+ // Custom links.
495
+ this.links.forEach((url) => {
496
+ if (typeof url === "string") {
497
+ this._html += `<link rel="stylesheet" href="${url}">`;
498
+ }
499
+ else if (typeof url === "object") {
500
+ // Embed content.
501
+ if ((typeof url === "object" && url.rel === "stylesheet" && url.embed !== true && typeof url.href === "string") &&
502
+ embed_stylesheet(Route.clean_endpoint(url.href))) { /* skip */ }
503
+ // Create link.
504
+ else {
505
+ if (url.async) {
506
+ include_link_async(url);
507
+ }
508
+ else {
509
+ this._html += "<link";
510
+ Object.keys(url).forEach((key) => {
511
+ if (key !== "embed") {
512
+ this._html += ` ${key}="${url[key]}"`;
513
+ }
514
+ });
515
+ this._html += ">" + line_break;
516
+ }
517
+ }
518
+ }
519
+ else {
520
+ throw Error("Invalid type for a css include, the valid value types are \"string\" and \"object\".");
521
+ }
522
+ });
523
+ // Add include links script.
524
+ if (include_links_script) {
525
+ this._html += `<script nonce="${nonce_identifier}">${line_break}${include_links_script}${line_break}</script>${line_break}`;
526
+ }
527
+ // End headers.
528
+ this._html += "</head>" + line_break;
529
+ // ------------------------------------------------------------------------------------------
530
+ // Body.
531
+ // Body.
532
+ this._html += "<body id='body'>";
533
+ // Create splash screen.
534
+ if (this.splash_screen != null) {
535
+ this._html += this.splash_screen.html + line_break;
536
+ }
537
+ // ------------------------------------------------------------------------------------------
538
+ // Include scripts.
539
+ // Embed the data of an endpoint.
540
+ // Returns `false` when the endpoint is not found.
541
+ const embed_script = (url) => {
542
+ let embed;
543
+ for (const endpoint of this.server.endpoints.values()) {
544
+ if (url === endpoint.route.endpoint_str &&
545
+ (endpoint.raw_data != null || endpoint.data != null)) {
546
+ embed = endpoint;
547
+ }
548
+ }
549
+ // Check if the endpoint has data or raw data to embed.
550
+ if (embed && (embed.raw_data || embed.data)) {
551
+ // Dont embed code.
552
+ if (embed.content_type === "application/javascript") {
553
+ this._html += `<script nonce="${nonce_identifier}">${line_break}${embed.raw_data || embed.data}${line_break}</script>${line_break}`;
554
+ }
555
+ else {
556
+ this._html += `<script nonce="${nonce_identifier}" type='${embed.content_type}'>${line_break}${embed.raw_data || embed.data}${line_break}</script>${line_break}`;
557
+ }
558
+ this._embedded_sources.push(url);
559
+ return true;
560
+ }
561
+ return false;
562
+ };
563
+ // Include js.
564
+ let include_js_script = `async function __volt_incl_js(url, async = true) {var script=document.createElement('script');if(async){script.async = true;}script.src=url;document.head.appendChild(script);};${line_break}`;
565
+ // 3rd party js includes.
566
+ if (this.jquery) {
567
+ // Keep first since it needs to be included before volt.
568
+ this._html += `<script nonce="${nonce_identifier}" src='https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js'></script>${line_break}`;
569
+ }
570
+ if (this.server.google_tag !== undefined) {
571
+ // this.html += `<script async src="https://www.googletagmanager.com/gtag/js?id=${this._server.google_tag}" onload='volt.google._initialize()'></script>`;
572
+ include_js_script += `__volt_incl_js("https://www.googletagmanager.com/gtag/js?id=${this.server.google_tag}");${line_break}`;
573
+ }
574
+ // Primary volt includes do not add them to cached_code since they need to be included before any other includes.
575
+ // Otherwise when including several files, most of them embedded and one not, then the not embedded will not have access to volt.
576
+ // Since volt is
577
+ // embed_script("/volt/api/v1/volt.js", false);
578
+ // Add volt static aspect ratios.
579
+ // @todo volt.static
580
+ this._html += `<script nonce="${nonce_identifier}">${line_break}window.volt_statics_aspect_ratios = ${JSON.stringify(Object.fromEntries(this.server.statics_aspect_ratios))}${line_break}</script>${line_break}`;
581
+ // Embed other scripts.
582
+ if (this.server.payments) {
583
+ if (this.server.payments.type === "paddle") {
584
+ // embed_script("/volt/api/v1/payments/paddle.js", false); // no longer required due to auto imports.
585
+ if (this.payments) {
586
+ include_js_script += `__volt_incl_js("https://cdn.paddle.com/paddle/v2/paddle.js");${line_break}`;
587
+ }
588
+ }
589
+ }
590
+ // Add the include js script.
591
+ this._html += `<script nonce="${nonce_identifier}">${line_break}${include_js_script.trimEnd()}${line_break}</script>${line_break}`;
592
+ // Additional js includes.
593
+ this.includes.forEach((url) => {
594
+ // Embed content.
595
+ if (typeof url === "string" && embed_script(url)) { /* skip. */ }
596
+ // Include.
597
+ else {
598
+ if (typeof url === "string") {
599
+ this._html += `<script nonce="${nonce_identifier}" src='${url}'></script>${line_break}`;
600
+ }
601
+ else if (typeof url === "object") {
602
+ this._html += `<script nonce="${nonce_identifier}"`;
603
+ Object.keys(url).forEach((key) => {
604
+ if (key !== "embed") {
605
+ this._html += ` ${key}="${url[key]}"`;
606
+ }
607
+ });
608
+ this._html += "></script>" + line_break;
609
+ }
610
+ else {
611
+ throw Error("Invalid type for a js include, the valid value types are \"string\" and \"object\".");
612
+ }
613
+ }
614
+ });
615
+ // Add direct source code.
616
+ if (has_bundle && this._bundle != null && typeof this._bundle.code === "string") {
617
+ this._html += `<script nonce="${nonce_identifier}" type='module'>${line_break}${this._bundle.code}${line_break}</script>${line_break}`;
618
+ }
619
+ // Include the source.
620
+ else if (typeof this.source === "string") {
621
+ this._html += `<script nonce="${nonce_identifier}">${line_break}${await new vlib.Path(this.source).load()}${line_break}</script>${line_break}`;
622
+ }
623
+ // JS code.
624
+ else if (this.callback != null) {
625
+ let code = this.callback.toString();
626
+ // @deprecated compile using vhighlight, now esbuild is used for bundling, callback is not supported yet.
627
+ // // Fill templates.
628
+ // const code_hash = this._server.hash(code);
629
+ // // Check cache.
630
+ // const { cache_path, cache_hash, cache_data } = utils.get_compiled_cache(this._server.domain, this._endpoint.method, this._endpoint.endpoint);
631
+ // if (cache_data && code_hash === cache_hash) {
632
+ // code = cache_data;
633
+ // } else {
634
+ // // Compile.
635
+ // const compiler = new vhighlight.JSCompiler({
636
+ // line_breaks: true,
637
+ // double_line_breaks: true,
638
+ // comments: false,
639
+ // white_space: false,
640
+ // })
641
+ // try {
642
+ // code = compiler.compile_code(code, this._src);
643
+ // } catch (err) {
644
+ // console.error("JS Compile error:");
645
+ // console.error(err);
646
+ // }
647
+ // // Cache for restarts.
648
+ // utils.set_compiled_cache(cache_path, code, code_hash);
649
+ // }
650
+ // Add.
651
+ this._html += `<script nonce="${nonce_identifier}">${line_break}(${code})()${line_break}</script>${line_break}`;
652
+ // cached_code += `;(${code})();`;
653
+ }
654
+ // Close body.
655
+ this._html += "</body>" + line_break;
656
+ // End.
657
+ this._html += "</html>" + line_break;
658
+ // Split by nonce.
659
+ this.html_nonce_split = this._html.split(nonce_identifier);
660
+ // console.log("Built HTML for endpoint", this.endpoint?.route?.endpoint_str + "\n" +this.html.slice(0, 25_000) + (this.html.length > 25_000 ? "..." : ""));
661
+ }
662
+ /** Retrieve the content length of the built html. */
663
+ async content_length() {
664
+ // Create nonce.
665
+ const nonce = crypto.randomBytes(16).toString('base64');
666
+ // Build html if needed.
667
+ if (!this._html) {
668
+ await this._build_html();
669
+ }
670
+ // Create html.
671
+ let html = this.html_nonce_split.join(nonce);
672
+ // Return.
673
+ return html.length;
674
+ }
675
+ /** Retrieve the HTML. */
676
+ async html(opts) {
677
+ // Create nonce.
678
+ const nonce = crypto.randomBytes(16).toString('base64');
679
+ // Build html if needed.
680
+ if (!this._html) {
681
+ await this._build_html();
682
+ }
683
+ // Create html.
684
+ let html = this.html_nonce_split.join(nonce);
685
+ // Content length.
686
+ const content_length = Buffer.byteLength(html, 'utf-8');
687
+ // Compress.
688
+ if (opts?.compress) {
689
+ html = zlib.gzipSync(html, { level: zlib.constants.Z_BEST_COMPRESSION });
690
+ }
691
+ // Return.
692
+ return {
693
+ html,
694
+ content_length,
695
+ nonce,
696
+ };
697
+ }
698
+ // Serve a client.
699
+ async _serve(stream, status_code = 200, opts) {
700
+ debug(2, this.endpoint?.route?.id, ": Serving HTML ", this._html?.slice(0, 50), "...");
701
+ // Create html.
702
+ const html = await this.html(opts);
703
+ // Compute content length on view & when not defined.
704
+ stream.set_header("Content-Length", html.content_length.toString());
705
+ // Set nonce.
706
+ const csp = stream.get_header("Content-Security-Policy");
707
+ if (csp == null || typeof csp !== "string") {
708
+ throw new Error("Cannot serve HTML without a string typed Content-Security-Policy (CSP) header defined on the endpoint. This should by default be defined by the Server.");
709
+ }
710
+ const new_csp = csp.replace(/(script-src|style-src)([^;]*)/g, (_, g1, g2) => `${g1}${g2} 'nonce-${html.nonce}'`);
711
+ stream.set_header("Content-Security-Policy", new_csp);
712
+ // Generate a nonce here and use it both in the CSP header and the inline script.
713
+ stream.send({
714
+ status: status_code,
715
+ headers: { "Content-Type": "text/html" },
716
+ data: html.html,
717
+ });
718
+ }
719
+ html_nonce_split;
720
+ }