@vandenberghinc/volt 1.1.5 → 1.1.7

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 (287) hide show
  1. package/backend/dist/cjs/database.d.ts +41 -68
  2. package/backend/dist/cjs/database.js +127 -76
  3. package/backend/dist/cjs/endpoint.d.ts +23 -9
  4. package/backend/dist/cjs/endpoint.js +98 -21
  5. package/backend/dist/cjs/frontend.d.ts +0 -2
  6. package/backend/dist/cjs/frontend.js +9 -9
  7. package/backend/dist/cjs/image_endpoint.d.ts +3 -1
  8. package/backend/dist/cjs/image_endpoint.js +2 -1
  9. package/backend/dist/cjs/payments/paddle.js +10 -2
  10. package/backend/dist/cjs/plugins/css.d.ts +6 -5
  11. package/backend/dist/cjs/plugins/css.js +32 -7
  12. package/backend/dist/cjs/plugins/ts/compiler.d.ts +6 -1
  13. package/backend/dist/cjs/plugins/ts/compiler.js +26 -2
  14. package/backend/dist/cjs/plugins/ts/preprocessing.js +5 -3
  15. package/backend/dist/cjs/server.d.ts +7 -13
  16. package/backend/dist/cjs/server.js +184 -303
  17. package/backend/dist/cjs/status.d.ts +1 -0
  18. package/backend/dist/cjs/status.js +2 -1
  19. package/backend/dist/cjs/stream.d.ts +5 -3
  20. package/backend/dist/cjs/stream.js +13 -4
  21. package/backend/dist/cjs/users.d.ts +1 -1
  22. package/backend/dist/cjs/users.js +87 -72
  23. package/backend/dist/cjs/utils.d.ts +17 -9
  24. package/backend/dist/cjs/utils.js +22 -64
  25. package/backend/dist/cjs/view.d.ts +2 -2
  26. package/backend/dist/cjs/view.js +38 -40
  27. package/backend/dist/cjs/volt.d.ts +3 -2
  28. package/backend/dist/cjs/volt.js +2 -2
  29. package/backend/dist/css/volt.css +5 -0
  30. package/backend/dist/esm/database.d.ts +41 -68
  31. package/backend/dist/esm/database.js +127 -76
  32. package/backend/dist/esm/endpoint.d.ts +23 -9
  33. package/backend/dist/esm/endpoint.js +99 -22
  34. package/backend/dist/esm/frontend.d.ts +0 -2
  35. package/backend/dist/esm/frontend.js +9 -9
  36. package/backend/dist/esm/image_endpoint.d.ts +3 -1
  37. package/backend/dist/esm/image_endpoint.js +2 -1
  38. package/backend/dist/esm/payments/paddle.js +11 -3
  39. package/backend/dist/esm/plugins/css.d.ts +6 -5
  40. package/backend/dist/esm/plugins/css.js +32 -6
  41. package/backend/dist/esm/plugins/ts/compiler.d.ts +6 -1
  42. package/backend/dist/esm/plugins/ts/compiler.js +26 -2
  43. package/backend/dist/esm/plugins/ts/preprocessing.js +5 -3
  44. package/backend/dist/esm/server.d.ts +7 -13
  45. package/backend/dist/esm/server.js +182 -301
  46. package/backend/dist/esm/status.d.ts +1 -0
  47. package/backend/dist/esm/status.js +1 -0
  48. package/backend/dist/esm/stream.d.ts +5 -3
  49. package/backend/dist/esm/stream.js +13 -4
  50. package/backend/dist/esm/users.d.ts +1 -1
  51. package/backend/dist/esm/users.js +87 -72
  52. package/backend/dist/esm/utils.d.ts +17 -9
  53. package/backend/dist/esm/utils.js +21 -62
  54. package/backend/dist/esm/view.d.ts +2 -2
  55. package/backend/dist/esm/view.js +38 -40
  56. package/backend/dist/esm/volt.d.ts +3 -2
  57. package/backend/dist/esm/volt.js +2 -1
  58. package/backend/dist/esm-dev/blacklist.js +1 -1
  59. package/backend/dist/esm-dev/cli.js +2 -2
  60. package/backend/dist/esm-dev/database.d.ts +41 -68
  61. package/backend/dist/esm-dev/database.js +128 -77
  62. package/backend/dist/esm-dev/endpoint.d.ts +23 -9
  63. package/backend/dist/esm-dev/endpoint.js +100 -23
  64. package/backend/dist/esm-dev/file_watcher.js +1 -1
  65. package/backend/dist/esm-dev/frontend.d.ts +0 -2
  66. package/backend/dist/esm-dev/frontend.js +9 -9
  67. package/backend/dist/esm-dev/image_endpoint.d.ts +3 -1
  68. package/backend/dist/esm-dev/image_endpoint.js +2 -1
  69. package/backend/dist/esm-dev/logger.js +1 -1
  70. package/backend/dist/esm-dev/payments/paddle.js +12 -4
  71. package/backend/dist/esm-dev/plugins/css.d.ts +6 -5
  72. package/backend/dist/esm-dev/plugins/css.js +33 -7
  73. package/backend/dist/esm-dev/plugins/ts/compiler.d.ts +6 -1
  74. package/backend/dist/esm-dev/plugins/ts/compiler.js +27 -3
  75. package/backend/dist/esm-dev/plugins/ts/preprocessing.js +7 -5
  76. package/backend/dist/esm-dev/rate_limit.js +1 -1
  77. package/backend/dist/esm-dev/server.d.ts +7 -13
  78. package/backend/dist/esm-dev/server.js +184 -303
  79. package/backend/dist/esm-dev/status.d.ts +1 -0
  80. package/backend/dist/esm-dev/status.js +1 -0
  81. package/backend/dist/esm-dev/stream.d.ts +5 -3
  82. package/backend/dist/esm-dev/stream.js +13 -4
  83. package/backend/dist/esm-dev/users.d.ts +1 -1
  84. package/backend/dist/esm-dev/users.js +88 -73
  85. package/backend/dist/esm-dev/utils.d.ts +17 -9
  86. package/backend/dist/esm-dev/utils.js +22 -63
  87. package/backend/dist/esm-dev/view.d.ts +2 -2
  88. package/backend/dist/esm-dev/view.js +39 -41
  89. package/backend/dist/esm-dev/volt.d.ts +3 -2
  90. package/backend/dist/esm-dev/volt.js +2 -1
  91. package/backend/src/database.ts +163 -152
  92. package/backend/src/endpoint.ts +123 -31
  93. package/backend/src/frontend.ts +9 -8
  94. package/backend/src/image_endpoint.ts +4 -0
  95. package/backend/src/payments/paddle.ts +11 -3
  96. package/backend/src/plugins/css.ts +36 -8
  97. package/backend/src/plugins/ts/compiler.ts +37 -1
  98. package/backend/src/plugins/ts/preprocessing.ts +5 -3
  99. package/backend/src/server.ts +167 -306
  100. package/backend/src/status.ts +1 -0
  101. package/backend/src/stream.ts +28 -8
  102. package/backend/src/users.ts +87 -72
  103. package/backend/src/utils.ts +58 -25
  104. package/backend/src/view.ts +30 -28
  105. package/backend/src/{volt.js → volt.ts} +2 -1
  106. package/backend/tsconfig.cjs.json +3 -3
  107. package/backend/tsconfig.esm.json +3 -3
  108. package/frontend/dist/elements/base.d.ts +397 -415
  109. package/frontend/dist/elements/base.js +565 -328
  110. package/frontend/dist/elements/module.d.ts +26 -12
  111. package/frontend/dist/elements/module.js +69 -32
  112. package/frontend/dist/elements/register_element.d.ts +3 -0
  113. package/frontend/dist/elements/register_element.js +22 -0
  114. package/frontend/dist/modules/auth.d.ts +1 -0
  115. package/frontend/dist/modules/auth.js +6 -5
  116. package/frontend/dist/modules/color.d.ts +159 -0
  117. package/frontend/dist/modules/color.js +315 -0
  118. package/frontend/dist/modules/colors.d.ts +1 -26
  119. package/frontend/dist/modules/colors.js +417 -338
  120. package/frontend/dist/modules/cookies.d.ts +1 -0
  121. package/frontend/dist/modules/cookies.js +1 -0
  122. package/frontend/dist/modules/events.d.ts +1 -0
  123. package/frontend/dist/modules/events.js +1 -0
  124. package/frontend/dist/modules/google.d.ts +1 -0
  125. package/frontend/dist/modules/google.js +1 -0
  126. package/frontend/dist/modules/meta.d.ts +1 -0
  127. package/frontend/dist/modules/meta.js +1 -0
  128. package/frontend/dist/modules/mutex.d.ts +1 -2
  129. package/frontend/dist/modules/mutex.js +3 -4
  130. package/frontend/dist/modules/paddle.d.ts +1 -0
  131. package/frontend/dist/modules/paddle.js +14 -13
  132. package/frontend/dist/modules/scheme.d.ts +1 -0
  133. package/frontend/dist/modules/scheme.js +4 -2
  134. package/frontend/dist/modules/statics.d.ts +1 -0
  135. package/frontend/dist/modules/statics.js +1 -0
  136. package/frontend/dist/modules/support.d.ts +1 -0
  137. package/frontend/dist/modules/support.js +3 -2
  138. package/frontend/dist/modules/theme.d.ts +56 -0
  139. package/frontend/dist/{ui → modules}/theme.js +186 -75
  140. package/frontend/dist/modules/themes.d.ts +1 -1
  141. package/frontend/dist/modules/themes.js +1 -0
  142. package/frontend/dist/modules/user.d.ts +1 -0
  143. package/frontend/dist/modules/user.js +11 -10
  144. package/frontend/dist/modules/utils.d.ts +23 -2
  145. package/frontend/dist/modules/utils.js +93 -1
  146. package/frontend/dist/types/gradient.js +4 -0
  147. package/frontend/dist/ui/border_button.d.ts +0 -25
  148. package/frontend/dist/ui/border_button.js +50 -51
  149. package/frontend/dist/ui/button.d.ts +0 -21
  150. package/frontend/dist/ui/button.js +41 -46
  151. package/frontend/dist/ui/canvas.js +15 -15
  152. package/frontend/dist/ui/checkbox.d.ts +3 -17
  153. package/frontend/dist/ui/checkbox.js +36 -30
  154. package/frontend/dist/ui/code.d.ts +15 -82
  155. package/frontend/dist/ui/code.js +150 -125
  156. package/frontend/dist/ui/color.d.ts +0 -1
  157. package/frontend/dist/ui/color.js +1 -1
  158. package/frontend/dist/ui/context_menu.d.ts +4 -2
  159. package/frontend/dist/ui/context_menu.js +16 -17
  160. package/frontend/dist/ui/css.js +2 -0
  161. package/frontend/dist/ui/divider.d.ts +0 -7
  162. package/frontend/dist/ui/divider.js +21 -25
  163. package/frontend/dist/ui/dropdown.d.ts +13 -7
  164. package/frontend/dist/ui/dropdown.js +65 -30
  165. package/frontend/dist/ui/for_each.d.ts +0 -5
  166. package/frontend/dist/ui/for_each.js +17 -22
  167. package/frontend/dist/ui/form.d.ts +17 -12
  168. package/frontend/dist/ui/form.js +21 -18
  169. package/frontend/dist/ui/frame_modes.d.ts +9 -12
  170. package/frontend/dist/ui/frame_modes.js +8 -10
  171. package/frontend/dist/ui/google_map.d.ts +0 -11
  172. package/frontend/dist/ui/google_map.js +23 -28
  173. package/frontend/dist/ui/gradient.d.ts +0 -5
  174. package/frontend/dist/ui/gradient.js +17 -22
  175. package/frontend/dist/ui/image.d.ts +27 -58
  176. package/frontend/dist/ui/image.js +99 -93
  177. package/frontend/dist/ui/input.d.ts +20 -97
  178. package/frontend/dist/ui/input.js +192 -170
  179. package/frontend/dist/ui/link.d.ts +0 -18
  180. package/frontend/dist/ui/link.js +42 -48
  181. package/frontend/dist/ui/list.js +36 -37
  182. package/frontend/dist/ui/loader_button.d.ts +4 -19
  183. package/frontend/dist/ui/loader_button.js +35 -37
  184. package/frontend/dist/ui/loaders.d.ts +0 -8
  185. package/frontend/dist/ui/loaders.js +20 -25
  186. package/frontend/dist/ui/popup.d.ts +11 -8
  187. package/frontend/dist/ui/popup.js +183 -24
  188. package/frontend/dist/ui/pseudo.d.ts +3 -3
  189. package/frontend/dist/ui/pseudo.js +14 -17
  190. package/frontend/dist/ui/scroller.d.ts +10 -48
  191. package/frontend/dist/ui/scroller.js +306 -300
  192. package/frontend/dist/ui/slider.d.ts +9 -3
  193. package/frontend/dist/ui/slider.js +31 -17
  194. package/frontend/dist/ui/spacer.d.ts +0 -9
  195. package/frontend/dist/ui/spacer.js +21 -26
  196. package/frontend/dist/ui/span.js +13 -15
  197. package/frontend/dist/ui/stack.d.ts +14 -75
  198. package/frontend/dist/ui/stack.js +166 -169
  199. package/frontend/dist/ui/steps.d.ts +10 -23
  200. package/frontend/dist/ui/steps.js +47 -34
  201. package/frontend/dist/ui/style.d.ts +4 -3
  202. package/frontend/dist/ui/style.js +13 -18
  203. package/frontend/dist/ui/switch.d.ts +10 -4
  204. package/frontend/dist/ui/switch.js +24 -16
  205. package/frontend/dist/ui/table.d.ts +0 -23
  206. package/frontend/dist/ui/table.js +113 -119
  207. package/frontend/dist/ui/tabs.d.ts +3 -19
  208. package/frontend/dist/ui/tabs.js +35 -29
  209. package/frontend/dist/ui/text.d.ts +0 -8
  210. package/frontend/dist/ui/text.js +20 -25
  211. package/frontend/dist/ui/title.d.ts +0 -15
  212. package/frontend/dist/ui/title.js +39 -45
  213. package/frontend/dist/ui/ui.d.ts +0 -2
  214. package/frontend/dist/ui/ui.js +0 -2
  215. package/frontend/dist/ui/view.d.ts +3 -17
  216. package/frontend/dist/ui/view.js +27 -32
  217. package/frontend/dist/volt.d.ts +2 -1
  218. package/frontend/dist/volt.js +3 -1
  219. package/frontend/examples/dashboard/dashboard.ts +774 -0
  220. package/frontend/examples/theme/theme.ts +58 -0
  221. package/frontend/src/css/volt.css +5 -0
  222. package/frontend/src/elements/base.ts +767 -545
  223. package/frontend/src/elements/module.ts +90 -29
  224. package/frontend/src/elements/register_element.ts +24 -0
  225. package/frontend/src/modules/auth.ts +7 -6
  226. package/frontend/src/modules/color.ts +348 -0
  227. package/frontend/src/modules/colors.ts +468 -449
  228. package/frontend/src/modules/cookies.ts +1 -0
  229. package/frontend/src/modules/events.ts +1 -0
  230. package/frontend/src/modules/google.ts +1 -0
  231. package/frontend/src/modules/meta.ts +2 -1
  232. package/frontend/src/modules/mutex.ts +2 -4
  233. package/frontend/src/modules/paddle.ts +21 -20
  234. package/frontend/src/modules/scheme.ts +4 -3
  235. package/frontend/src/modules/statics.ts +2 -1
  236. package/frontend/src/modules/support.ts +3 -2
  237. package/frontend/src/modules/theme.ts +413 -0
  238. package/frontend/src/modules/themes.ts +2 -1
  239. package/frontend/src/modules/user.ts +12 -11
  240. package/frontend/src/modules/utils.ts +125 -2
  241. package/frontend/src/ui/border_button.ts +41 -37
  242. package/frontend/src/ui/button.ts +33 -32
  243. package/frontend/src/ui/canvas.ts +5 -2
  244. package/frontend/src/ui/checkbox.ts +21 -22
  245. package/frontend/src/ui/code.ts +92 -86
  246. package/frontend/src/ui/context_menu.ts +7 -5
  247. package/frontend/src/ui/css.ts +1 -1
  248. package/frontend/src/ui/divider.ts +15 -10
  249. package/frontend/src/ui/dropdown.ts +38 -21
  250. package/frontend/src/ui/for_each.ts +9 -8
  251. package/frontend/src/ui/form.ts +26 -21
  252. package/frontend/src/ui/frame_modes.ts +13 -17
  253. package/frontend/src/ui/google_map.ts +15 -13
  254. package/frontend/src/ui/gradient.ts +9 -8
  255. package/frontend/src/ui/image.ts +108 -86
  256. package/frontend/src/ui/input.ts +145 -144
  257. package/frontend/src/ui/link.ts +25 -23
  258. package/frontend/src/ui/list.ts +12 -6
  259. package/frontend/src/ui/loader_button.ts +26 -25
  260. package/frontend/src/ui/loaders.ts +12 -11
  261. package/frontend/src/ui/popup.ts +168 -14
  262. package/frontend/src/ui/pseudo.ts +5 -3
  263. package/frontend/src/ui/scroller.ts +303 -294
  264. package/frontend/src/ui/slider.ts +15 -10
  265. package/frontend/src/ui/spacer.ts +14 -11
  266. package/frontend/src/ui/span.ts +6 -2
  267. package/frontend/src/ui/stack.ts +196 -183
  268. package/frontend/src/ui/steps.ts +38 -22
  269. package/frontend/src/ui/style.ts +7 -4
  270. package/frontend/src/ui/switch.ts +16 -11
  271. package/frontend/src/ui/table.ts +42 -34
  272. package/frontend/src/ui/tabs.ts +20 -19
  273. package/frontend/src/ui/text.ts +12 -11
  274. package/frontend/src/ui/title.ts +22 -20
  275. package/frontend/src/ui/ui.ts +0 -2
  276. package/frontend/src/ui/view.ts +20 -19
  277. package/frontend/src/volt.ts +3 -1
  278. package/frontend/{compile.js → tools/compile.old.js} +2 -2
  279. package/frontend/tools/embed_scripts.js +69 -0
  280. package/frontend/tsconfig.json +26 -0
  281. package/package.json +8 -8
  282. package/frontend/dist/ui/theme.d.ts +0 -25
  283. package/frontend/exports.json +0 -1340
  284. package/frontend/src/modules/date.js +0 -535
  285. package/frontend/src/ui/color.ts +0 -117
  286. package/frontend/src/ui/theme.ts +0 -279
  287. /package/backend/src/{vinc.dev.js → vinc.dev.ts} +0 -0
@@ -1,4 +1,3 @@
1
- import { vlib } from "./vinc.js";
2
1
  // Get the directory name of the current module
3
2
  import { fileURLToPath } from 'url';
4
3
  import { dirname } from 'path';
@@ -10,14 +9,15 @@ export const web_exports = {
10
9
  };
11
10
  export const Frontend = {
12
11
  // Load frontend globals.
13
- async load_globals() {
14
- const data = await (new vlib.Path(`${__dirname}/../../../frontend/exports.json`).load());
15
- return Object.values(data).flat();
16
- },
17
- load_globals_sync() {
18
- const data = new vlib.Path(`${__dirname}/../../../frontend/exports.json`).load_sync();
19
- return Object.values(data).flat();
20
- },
12
+ // @deprecated
13
+ // async load_globals(): Promise<string[]> {
14
+ // const data: { [key: string]: string[] } = await (new vlib.Path(`${__dirname}/../../../frontend/exports.json`).load());
15
+ // return Object.values(data).flat();
16
+ // },
17
+ // load_globals_sync(): string[] {
18
+ // const data: { [key: string]: string[] } = new vlib.Path(`${__dirname}/../../../frontend/exports.json`).load_sync();
19
+ // return Object.values(data).flat();
20
+ // },
21
21
  // Path to css files.
22
22
  css: {
23
23
  adyen: __dirname + "../../../../frontend/src/css/adyen.css",
@@ -1,6 +1,7 @@
1
1
  import { vlib } from "./vinc.js";
2
2
  import { Endpoint } from "./endpoint.js";
3
3
  import { RateLimitGroup } from "./rate_limit.js";
4
+ import type { Server } from "./server.js";
4
5
  declare class ImageEndpoint extends Endpoint implements Endpoint {
5
6
  static cache_in_memory: boolean;
6
7
  static supported_images: string[];
@@ -9,13 +10,14 @@ declare class ImageEndpoint extends Endpoint implements Endpoint {
9
10
  private i_data?;
10
11
  private i_cache;
11
12
  is_image_endpoint: boolean;
12
- constructor({ endpoint, path, content_type, cache, _is_static, rate_limit, }: {
13
+ constructor({ endpoint, path, content_type, cache, _is_static, rate_limit, _server, }: {
13
14
  endpoint: string;
14
15
  path: vlib.Path;
15
16
  content_type: string;
16
17
  cache?: boolean | number;
17
18
  _is_static?: boolean;
18
19
  rate_limit?: string | RateLimitGroup;
20
+ _server: Server;
19
21
  });
20
22
  transform(type?: string | null, width?: number | string | null, height?: number | string | null, aspect_ratio?: string | boolean | null): Promise<Buffer>;
21
23
  get_aspect_ratio(): Promise<string | null>;
@@ -45,7 +45,7 @@ class ImageEndpoint extends Endpoint {
45
45
  i_data;
46
46
  i_cache;
47
47
  is_image_endpoint;
48
- constructor({ endpoint, path, content_type, cache = true, _is_static = true, rate_limit = undefined, }) {
48
+ constructor({ endpoint, path, content_type, cache = true, _is_static = true, rate_limit = undefined, _server, }) {
49
49
  // Initialize base.
50
50
  super({
51
51
  method: "GET",
@@ -62,6 +62,7 @@ class ImageEndpoint extends Endpoint {
62
62
  rate_limit,
63
63
  _path: path.str(),
64
64
  _is_static,
65
+ _server,
65
66
  });
66
67
  // Attributes.
67
68
  this.i_path = path.abs();
@@ -8,7 +8,7 @@ import * as PDFDocument from "pdfkit";
8
8
  import * as libcrypto from "crypto";
9
9
  import blobstream from 'blob-stream';
10
10
  import { vlib } from "../vinc.js";
11
- import { Utils, FrontendError } from "../utils.js";
11
+ import { Utils, APIError } from "../utils.js";
12
12
  import { logger } from "../logger.js";
13
13
  import { Status } from "../status.js";
14
14
  const log_source = logger.LogSource("Payments");
@@ -585,7 +585,11 @@ export class Paddle {
585
585
  }
586
586
  // Cancel.
587
587
  if (subscription.status !== "active") {
588
- throw new FrontendError(`This subscription does not contain any cancellable items, the subscription is likely already cancelled.`, Status.bad_request);
588
+ throw new APIError({
589
+ type: "NoActiveSubscriptionError",
590
+ message: `This subscription is already cancelled and will become inactive at the end of the billing period.`,
591
+ status: Status.bad_request,
592
+ });
589
593
  }
590
594
  await this._req("POST", `/subscriptions/${subscription.id}/cancel`, {
591
595
  effective_from: immediate ? "immediately" : null,
@@ -1947,7 +1951,11 @@ export class Paddle {
1947
1951
  }
1948
1952
  });
1949
1953
  if (_throw_no_cancelled_err && cancelled.length === 0) {
1950
- throw new FrontendError("No cancellable subscriptions found.", Status.bad_request);
1954
+ throw new APIError({
1955
+ type: "NoCancellableSubscriptions",
1956
+ message: "No cancellable subscriptions found.",
1957
+ status: Status.bad_request,
1958
+ });
1951
1959
  }
1952
1960
  }
1953
1961
  // Cancel subscription by subscription id.
@@ -1,10 +1,11 @@
1
- export declare class CSS {
2
- static minify(data: string): string;
3
- static bundle({ data, paths, minify, output, }: {
1
+ export declare namespace CSS {
2
+ function minify(data: string): string;
3
+ function bundle({ data, paths, minify, output, postprocess, log_level, }: {
4
4
  data: string;
5
5
  paths?: string[];
6
6
  minify?: boolean;
7
- output?: string;
7
+ output?: string | string[];
8
+ postprocess?: undefined | ((data: string) => string | Promise<string>);
9
+ log_level?: number;
8
10
  }): Promise<string>;
9
11
  }
10
- export default CSS;
@@ -9,7 +9,8 @@ import { vlib } from "../vinc.js";
9
9
  // ---------------------------------------------------------
10
10
  // CSS utils.
11
11
  // Implementation
12
- export class CSS {
12
+ export var CSS;
13
+ (function (CSS) {
13
14
  /* @docs:
14
15
  @nav: Backend
15
16
  @title: Minify
@@ -23,9 +24,10 @@ export class CSS {
23
24
  @descr: The css data.
24
25
  @type: string
25
26
  */
26
- static minify(data) {
27
+ function minify(data) {
27
28
  return new CleanCSS().minify(data).styles;
28
29
  }
30
+ CSS.minify = minify;
29
31
  /* @docs:
30
32
  @nav: Backend
31
33
  @title: Bundle
@@ -42,9 +44,10 @@ export class CSS {
42
44
  @descr: The css data.
43
45
  @type: string
44
46
  */
45
- static async bundle({ data = "", paths = undefined, minify = false, output = undefined, }) {
47
+ async function bundle({ data, paths = undefined, minify = false, output = undefined, postprocess = undefined, log_level = 0, }) {
46
48
  // Load via paths.
47
49
  if (paths !== undefined) {
50
+ data = "";
48
51
  for (const path of paths) {
49
52
  data += await new vlib.Path(path).load();
50
53
  }
@@ -53,12 +56,35 @@ export class CSS {
53
56
  if (minify) {
54
57
  data = CSS.minify(data);
55
58
  }
59
+ // Postprocess.
60
+ if (typeof postprocess === "function") {
61
+ const res = postprocess(data);
62
+ if (res instanceof Promise) {
63
+ data = await res;
64
+ }
65
+ else {
66
+ data = res;
67
+ }
68
+ }
56
69
  // Save.
57
- if (output) {
70
+ if (typeof output === "string") {
58
71
  await new vlib.Path(output).save(data);
59
72
  }
73
+ else if (Array.isArray(output)) {
74
+ for (let i = 0; i < output.length; i++) {
75
+ await new vlib.Path(output[i]).save(data);
76
+ }
77
+ }
78
+ // Logs.
79
+ if (log_level >= 1) {
80
+ const first_path = typeof output === "string" ? output : (Array.isArray(output) ? output[0] : undefined);
81
+ if (first_path != null) {
82
+ const p = new vlib.Path(first_path);
83
+ vlib.Utils.print_marker(`Bundled ${p.name()} (${p.str()}) [${vlib.Utils.format_bytes(p.size)}].`);
84
+ }
85
+ }
60
86
  // Return.
61
87
  return data;
62
88
  }
63
- }
64
- export default CSS;
89
+ CSS.bundle = bundle;
90
+ })(CSS || (CSS = {}));
@@ -60,7 +60,7 @@ export declare function compile(options: CompileOptions): Promise<CompileResult>
60
60
  */
61
61
  export interface BundleOptions {
62
62
  include?: string[];
63
- output?: string;
63
+ output?: string | string[];
64
64
  entry_paths?: string[];
65
65
  error_limit?: number;
66
66
  /**
@@ -85,6 +85,8 @@ export interface BundleOptions {
85
85
  * Enable or disable tree shaking.
86
86
  */
87
87
  tree_shaking?: boolean;
88
+ /** External library names not to be included in the bundle */
89
+ externals?: string[];
88
90
  /**
89
91
  * Enable or disable debug console statements.
90
92
  */
@@ -100,6 +102,9 @@ export interface BundleOptions {
100
102
  */
101
103
  bundler?: 'esbuild' | 'rollup';
102
104
  opts?: any;
105
+ postprocess?: undefined | ((data: string) => string | Promise<string>);
106
+ /** Log level (default is 0) */
107
+ log_level?: number;
103
108
  }
104
109
  /**
105
110
  * Result of the bundling process.
@@ -617,8 +617,8 @@ const format_esbuild_warning_error = (warning) => {
617
617
  */
618
618
  export async function bundle(options) {
619
619
  // console.log(">>> BUNDLE", options)
620
- let { entry_paths = [], include = [], output = undefined, platform = 'browser', format = 'iife', target = 'es2021', minify = false, sourcemap = false, // 'inline'
621
- error_limit = 25, extract_inputs = false, tree_shaking = undefined, debug = false, bundler = "esbuild", opts = {},
620
+ let { entry_paths = [], include = [], externals = [], output = undefined, platform = 'browser', format = 'iife', target = 'es2021', minify = false, sourcemap = false, // 'inline'
621
+ error_limit = 25, extract_inputs = false, tree_shaking = undefined, debug = false, bundler = "esbuild", opts = {}, postprocess = undefined, log_level = 0,
622
622
  // bundler = "rollup",
623
623
  } = options;
624
624
  if (entry_paths.length > 0) {
@@ -648,6 +648,7 @@ export async function bundle(options) {
648
648
  // minifyWhitespace: false,
649
649
  // minifySyntax: false,
650
650
  // minifyIdentifiers: false,
651
+ external: externals,
651
652
  ...opts,
652
653
  });
653
654
  if (result.errors.length > 0) {
@@ -783,10 +784,33 @@ export async function bundle(options) {
783
784
  // throw new Error(`Rollup bundling failed: ${err.message || err}`);
784
785
  }
785
786
  }
787
+ // Postprocess.
788
+ if (bundled_code && typeof postprocess === "function") {
789
+ const res = postprocess(bundled_code);
790
+ if (res instanceof Promise) {
791
+ bundled_code = await res;
792
+ }
793
+ else {
794
+ bundled_code = res;
795
+ }
796
+ }
786
797
  // Write to file.
787
798
  if (typeof output === "string") {
788
799
  await new vlib.Path(output).save(bundled_code ?? "");
789
800
  }
801
+ else if (Array.isArray(output)) {
802
+ for (let i = 0; i < output.length; i++) {
803
+ await new vlib.Path(output[i]).save(bundled_code ?? "");
804
+ }
805
+ }
806
+ // Logs.
807
+ if (log_level >= 1) {
808
+ const first_path = typeof output === "string" ? output : (Array.isArray(output) ? output[0] : undefined);
809
+ if (first_path != null) {
810
+ const p = new vlib.Path(first_path);
811
+ vlib.Utils.print_marker(`Bundled ${p.name()} (${p.str()}) [${vlib.Utils.format_bytes(p.size)}].`);
812
+ }
813
+ }
790
814
  return {
791
815
  code: bundled_code,
792
816
  source_map: bundled_source_map,
@@ -498,9 +498,11 @@ let volt_exports = undefined;
498
498
  function detect_unused_imports(source_file) {
499
499
  // Load volt exports.
500
500
  if (volt_exports === undefined) {
501
- volt_exports = new vlib.Path(`${__dirname}/../../../../../frontend/exports.json`).load_sync({ type: "object" });
502
- volt_exports["ui/ui.ts"] = ["VoltUI"];
503
- volt_exports["volt.ts"] = ["Volt"];
501
+ volt_exports = {};
502
+ // @deprecated.
503
+ // volt_exports = new vlib.Path(`${__dirname}/../../../../../frontend/exports.json`).load_sync({type: "object"}) as Record<string, string[]>;
504
+ // volt_exports["ui/ui.ts"] = ["VoltUI"];
505
+ // volt_exports["volt.ts"] = ["Volt"];
504
506
  }
505
507
  // Vars.
506
508
  // const source_file = ts.createSourceFile(file_path, file_content, ts.ScriptTarget.Latest, true);
@@ -7,13 +7,12 @@ import * as Mail from './plugins/mail.js';
7
7
  import { Status } from "./status.js";
8
8
  import { Endpoint, EndpointOptions } from "./endpoint.js";
9
9
  import { Database, Collection } from "./database.js";
10
- import { StaticFileWatcher, FileWatcher } from "./file_watcher.js";
10
+ import { /*StaticFileWatcher,*/ FileWatcher } from "./file_watcher.js";
11
11
  import { Users } from "./users.js";
12
12
  import { Paddle } from "./payments/paddle.js";
13
13
  import { RateLimits, RateLimitServer, RateLimitClient } from "./rate_limit.js";
14
14
  import { Blacklist } from "./blacklist.js";
15
15
  import logger, { LogSource } from "./logger.js";
16
- import { BrowserPreview } from "./plugins/browser.js";
17
16
  declare global {
18
17
  type none = null | undefined;
19
18
  }
@@ -110,6 +109,7 @@ export declare class Server {
110
109
  token_expiration: number;
111
110
  google_tag?: string;
112
111
  production: boolean;
112
+ localhost: boolean;
113
113
  multiprocessing: boolean;
114
114
  processes: number;
115
115
  company: CompanyInfo;
@@ -122,8 +122,7 @@ export declare class Server {
122
122
  log_level: number;
123
123
  tls?: TLSConfig;
124
124
  file_watcher?: FileWatcher;
125
- admin: AdminConfig;
126
- ts: TypeScriptConfig;
125
+ lightweight: boolean;
127
126
  performance: vlib.Performance;
128
127
  csp: Record<string, string>;
129
128
  default_headers: Record<string, string>;
@@ -142,8 +141,6 @@ export declare class Server {
142
141
  keys: Record<string, string>;
143
142
  private _on_start;
144
143
  private _on_stop;
145
- browser_preview?: BrowserPreview;
146
- static_file_watcher: StaticFileWatcher;
147
144
  is_file_watcher: boolean;
148
145
  daemon?: vlib.Daemon;
149
146
  private _stop_tscompiler_watcher?;
@@ -152,7 +149,7 @@ export declare class Server {
152
149
  status: typeof Status;
153
150
  rate_limits: typeof RateLimits;
154
151
  logger: typeof logger;
155
- constructor({ ip, port, domain, is_primary, source, database, statics, favicon, company, meta, tls, smtp, mail_style, rate_limit, keys, payments, default_headers, google_tag, token_expiration, enable_2fa, enable_account_activation, production, multiprocessing, processes, file_watcher, offline, additional_sitemap_endpoints, log_level, daemon, admin, ts, browser_preview, }: {
152
+ constructor({ ip, port, domain, is_primary, source, database, statics, favicon, company, meta, tls, smtp, mail_style, rate_limit, keys, payments, default_headers, google_tag, token_expiration, enable_2fa, enable_account_activation, production, localhost, multiprocessing, processes, file_watcher, offline, additional_sitemap_endpoints, log_level, daemon, lightweight, }: {
156
153
  ip?: string;
157
154
  port?: number;
158
155
  domain: string;
@@ -166,7 +163,7 @@ export declare class Server {
166
163
  tls?: TLSConfig;
167
164
  smtp?: nodemailer.TransportOptions;
168
165
  mail_style?: Partial<MailStyle>;
169
- rate_limit?: RateLimitConfig;
166
+ rate_limit?: false | RateLimitConfig;
170
167
  keys?: Array<string | {
171
168
  name: string;
172
169
  length: number;
@@ -178,6 +175,7 @@ export declare class Server {
178
175
  enable_2fa?: boolean;
179
176
  enable_account_activation?: boolean;
180
177
  production?: boolean;
178
+ localhost?: boolean;
181
179
  multiprocessing?: boolean;
182
180
  processes?: number | null;
183
181
  file_watcher?: FileWatcher | Record<string, any> | boolean;
@@ -185,9 +183,7 @@ export declare class Server {
185
183
  additional_sitemap_endpoints?: string[];
186
184
  log_level?: number;
187
185
  daemon?: Record<string, any> | boolean;
188
- admin?: Partial<AdminConfig>;
189
- ts?: Partial<TypeScriptConfig>;
190
- browser_preview?: string;
186
+ lightweight?: boolean;
191
187
  });
192
188
  get_content_type(extension: string): string;
193
189
  set_log_level(level: number): void;
@@ -201,9 +197,7 @@ export declare class Server {
201
197
  private _create_default_endpoints;
202
198
  private _create_sitemap;
203
199
  private _create_robots_txt;
204
- private _create_admin_endpoint;
205
200
  private _initialize_statics;
206
- _init_ts(): Promise<void>;
207
201
  initialize(): Promise<void>;
208
202
  _serve(http2_stream?: http2.ServerHttp2Stream, headers?: Record<string, string>, req?: http.IncomingMessage | http2.Http2ServerRequest, res?: http.ServerResponse | http2.Http2ServerResponse): Promise<void>;
209
203
  start(): Promise<void>;