@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.
- package/backend/dist/cjs/database.d.ts +41 -68
- package/backend/dist/cjs/database.js +127 -76
- package/backend/dist/cjs/endpoint.d.ts +23 -9
- package/backend/dist/cjs/endpoint.js +98 -21
- package/backend/dist/cjs/frontend.d.ts +0 -2
- package/backend/dist/cjs/frontend.js +9 -9
- package/backend/dist/cjs/image_endpoint.d.ts +3 -1
- package/backend/dist/cjs/image_endpoint.js +2 -1
- package/backend/dist/cjs/payments/paddle.js +10 -2
- package/backend/dist/cjs/plugins/css.d.ts +6 -5
- package/backend/dist/cjs/plugins/css.js +32 -7
- package/backend/dist/cjs/plugins/ts/compiler.d.ts +6 -1
- package/backend/dist/cjs/plugins/ts/compiler.js +26 -2
- package/backend/dist/cjs/plugins/ts/preprocessing.js +5 -3
- package/backend/dist/cjs/server.d.ts +7 -13
- package/backend/dist/cjs/server.js +184 -303
- package/backend/dist/cjs/status.d.ts +1 -0
- package/backend/dist/cjs/status.js +2 -1
- package/backend/dist/cjs/stream.d.ts +5 -3
- package/backend/dist/cjs/stream.js +13 -4
- package/backend/dist/cjs/users.d.ts +1 -1
- package/backend/dist/cjs/users.js +87 -72
- package/backend/dist/cjs/utils.d.ts +17 -9
- package/backend/dist/cjs/utils.js +22 -64
- package/backend/dist/cjs/view.d.ts +2 -2
- package/backend/dist/cjs/view.js +38 -40
- package/backend/dist/cjs/volt.d.ts +3 -2
- package/backend/dist/cjs/volt.js +2 -2
- package/backend/dist/css/volt.css +5 -0
- package/backend/dist/esm/database.d.ts +41 -68
- package/backend/dist/esm/database.js +127 -76
- package/backend/dist/esm/endpoint.d.ts +23 -9
- package/backend/dist/esm/endpoint.js +99 -22
- package/backend/dist/esm/frontend.d.ts +0 -2
- package/backend/dist/esm/frontend.js +9 -9
- package/backend/dist/esm/image_endpoint.d.ts +3 -1
- package/backend/dist/esm/image_endpoint.js +2 -1
- package/backend/dist/esm/payments/paddle.js +11 -3
- package/backend/dist/esm/plugins/css.d.ts +6 -5
- package/backend/dist/esm/plugins/css.js +32 -6
- package/backend/dist/esm/plugins/ts/compiler.d.ts +6 -1
- package/backend/dist/esm/plugins/ts/compiler.js +26 -2
- package/backend/dist/esm/plugins/ts/preprocessing.js +5 -3
- package/backend/dist/esm/server.d.ts +7 -13
- package/backend/dist/esm/server.js +182 -301
- package/backend/dist/esm/status.d.ts +1 -0
- package/backend/dist/esm/status.js +1 -0
- package/backend/dist/esm/stream.d.ts +5 -3
- package/backend/dist/esm/stream.js +13 -4
- package/backend/dist/esm/users.d.ts +1 -1
- package/backend/dist/esm/users.js +87 -72
- package/backend/dist/esm/utils.d.ts +17 -9
- package/backend/dist/esm/utils.js +21 -62
- package/backend/dist/esm/view.d.ts +2 -2
- package/backend/dist/esm/view.js +38 -40
- package/backend/dist/esm/volt.d.ts +3 -2
- package/backend/dist/esm/volt.js +2 -1
- package/backend/dist/esm-dev/blacklist.js +1 -1
- package/backend/dist/esm-dev/cli.js +2 -2
- package/backend/dist/esm-dev/database.d.ts +41 -68
- package/backend/dist/esm-dev/database.js +128 -77
- package/backend/dist/esm-dev/endpoint.d.ts +23 -9
- package/backend/dist/esm-dev/endpoint.js +100 -23
- package/backend/dist/esm-dev/file_watcher.js +1 -1
- package/backend/dist/esm-dev/frontend.d.ts +0 -2
- package/backend/dist/esm-dev/frontend.js +9 -9
- package/backend/dist/esm-dev/image_endpoint.d.ts +3 -1
- package/backend/dist/esm-dev/image_endpoint.js +2 -1
- package/backend/dist/esm-dev/logger.js +1 -1
- package/backend/dist/esm-dev/payments/paddle.js +12 -4
- package/backend/dist/esm-dev/plugins/css.d.ts +6 -5
- package/backend/dist/esm-dev/plugins/css.js +33 -7
- package/backend/dist/esm-dev/plugins/ts/compiler.d.ts +6 -1
- package/backend/dist/esm-dev/plugins/ts/compiler.js +27 -3
- package/backend/dist/esm-dev/plugins/ts/preprocessing.js +7 -5
- package/backend/dist/esm-dev/rate_limit.js +1 -1
- package/backend/dist/esm-dev/server.d.ts +7 -13
- package/backend/dist/esm-dev/server.js +184 -303
- package/backend/dist/esm-dev/status.d.ts +1 -0
- package/backend/dist/esm-dev/status.js +1 -0
- package/backend/dist/esm-dev/stream.d.ts +5 -3
- package/backend/dist/esm-dev/stream.js +13 -4
- package/backend/dist/esm-dev/users.d.ts +1 -1
- package/backend/dist/esm-dev/users.js +88 -73
- package/backend/dist/esm-dev/utils.d.ts +17 -9
- package/backend/dist/esm-dev/utils.js +22 -63
- package/backend/dist/esm-dev/view.d.ts +2 -2
- package/backend/dist/esm-dev/view.js +39 -41
- package/backend/dist/esm-dev/volt.d.ts +3 -2
- package/backend/dist/esm-dev/volt.js +2 -1
- package/backend/src/database.ts +163 -152
- package/backend/src/endpoint.ts +123 -31
- package/backend/src/frontend.ts +9 -8
- package/backend/src/image_endpoint.ts +4 -0
- package/backend/src/payments/paddle.ts +11 -3
- package/backend/src/plugins/css.ts +36 -8
- package/backend/src/plugins/ts/compiler.ts +37 -1
- package/backend/src/plugins/ts/preprocessing.ts +5 -3
- package/backend/src/server.ts +167 -306
- package/backend/src/status.ts +1 -0
- package/backend/src/stream.ts +28 -8
- package/backend/src/users.ts +87 -72
- package/backend/src/utils.ts +58 -25
- package/backend/src/view.ts +30 -28
- package/backend/src/{volt.js → volt.ts} +2 -1
- package/backend/tsconfig.cjs.json +3 -3
- package/backend/tsconfig.esm.json +3 -3
- package/frontend/dist/elements/base.d.ts +397 -415
- package/frontend/dist/elements/base.js +565 -328
- package/frontend/dist/elements/module.d.ts +26 -12
- package/frontend/dist/elements/module.js +69 -32
- package/frontend/dist/elements/register_element.d.ts +3 -0
- package/frontend/dist/elements/register_element.js +22 -0
- package/frontend/dist/modules/auth.d.ts +1 -0
- package/frontend/dist/modules/auth.js +6 -5
- package/frontend/dist/modules/color.d.ts +159 -0
- package/frontend/dist/modules/color.js +315 -0
- package/frontend/dist/modules/colors.d.ts +1 -26
- package/frontend/dist/modules/colors.js +417 -338
- package/frontend/dist/modules/cookies.d.ts +1 -0
- package/frontend/dist/modules/cookies.js +1 -0
- package/frontend/dist/modules/events.d.ts +1 -0
- package/frontend/dist/modules/events.js +1 -0
- package/frontend/dist/modules/google.d.ts +1 -0
- package/frontend/dist/modules/google.js +1 -0
- package/frontend/dist/modules/meta.d.ts +1 -0
- package/frontend/dist/modules/meta.js +1 -0
- package/frontend/dist/modules/mutex.d.ts +1 -2
- package/frontend/dist/modules/mutex.js +3 -4
- package/frontend/dist/modules/paddle.d.ts +1 -0
- package/frontend/dist/modules/paddle.js +14 -13
- package/frontend/dist/modules/scheme.d.ts +1 -0
- package/frontend/dist/modules/scheme.js +4 -2
- package/frontend/dist/modules/statics.d.ts +1 -0
- package/frontend/dist/modules/statics.js +1 -0
- package/frontend/dist/modules/support.d.ts +1 -0
- package/frontend/dist/modules/support.js +3 -2
- package/frontend/dist/modules/theme.d.ts +56 -0
- package/frontend/dist/{ui → modules}/theme.js +186 -75
- package/frontend/dist/modules/themes.d.ts +1 -1
- package/frontend/dist/modules/themes.js +1 -0
- package/frontend/dist/modules/user.d.ts +1 -0
- package/frontend/dist/modules/user.js +11 -10
- package/frontend/dist/modules/utils.d.ts +23 -2
- package/frontend/dist/modules/utils.js +93 -1
- package/frontend/dist/types/gradient.js +4 -0
- package/frontend/dist/ui/border_button.d.ts +0 -25
- package/frontend/dist/ui/border_button.js +50 -51
- package/frontend/dist/ui/button.d.ts +0 -21
- package/frontend/dist/ui/button.js +41 -46
- package/frontend/dist/ui/canvas.js +15 -15
- package/frontend/dist/ui/checkbox.d.ts +3 -17
- package/frontend/dist/ui/checkbox.js +36 -30
- package/frontend/dist/ui/code.d.ts +15 -82
- package/frontend/dist/ui/code.js +150 -125
- package/frontend/dist/ui/color.d.ts +0 -1
- package/frontend/dist/ui/color.js +1 -1
- package/frontend/dist/ui/context_menu.d.ts +4 -2
- package/frontend/dist/ui/context_menu.js +16 -17
- package/frontend/dist/ui/css.js +2 -0
- package/frontend/dist/ui/divider.d.ts +0 -7
- package/frontend/dist/ui/divider.js +21 -25
- package/frontend/dist/ui/dropdown.d.ts +13 -7
- package/frontend/dist/ui/dropdown.js +65 -30
- package/frontend/dist/ui/for_each.d.ts +0 -5
- package/frontend/dist/ui/for_each.js +17 -22
- package/frontend/dist/ui/form.d.ts +17 -12
- package/frontend/dist/ui/form.js +21 -18
- package/frontend/dist/ui/frame_modes.d.ts +9 -12
- package/frontend/dist/ui/frame_modes.js +8 -10
- package/frontend/dist/ui/google_map.d.ts +0 -11
- package/frontend/dist/ui/google_map.js +23 -28
- package/frontend/dist/ui/gradient.d.ts +0 -5
- package/frontend/dist/ui/gradient.js +17 -22
- package/frontend/dist/ui/image.d.ts +27 -58
- package/frontend/dist/ui/image.js +99 -93
- package/frontend/dist/ui/input.d.ts +20 -97
- package/frontend/dist/ui/input.js +192 -170
- package/frontend/dist/ui/link.d.ts +0 -18
- package/frontend/dist/ui/link.js +42 -48
- package/frontend/dist/ui/list.js +36 -37
- package/frontend/dist/ui/loader_button.d.ts +4 -19
- package/frontend/dist/ui/loader_button.js +35 -37
- package/frontend/dist/ui/loaders.d.ts +0 -8
- package/frontend/dist/ui/loaders.js +20 -25
- package/frontend/dist/ui/popup.d.ts +11 -8
- package/frontend/dist/ui/popup.js +183 -24
- package/frontend/dist/ui/pseudo.d.ts +3 -3
- package/frontend/dist/ui/pseudo.js +14 -17
- package/frontend/dist/ui/scroller.d.ts +10 -48
- package/frontend/dist/ui/scroller.js +306 -300
- package/frontend/dist/ui/slider.d.ts +9 -3
- package/frontend/dist/ui/slider.js +31 -17
- package/frontend/dist/ui/spacer.d.ts +0 -9
- package/frontend/dist/ui/spacer.js +21 -26
- package/frontend/dist/ui/span.js +13 -15
- package/frontend/dist/ui/stack.d.ts +14 -75
- package/frontend/dist/ui/stack.js +166 -169
- package/frontend/dist/ui/steps.d.ts +10 -23
- package/frontend/dist/ui/steps.js +47 -34
- package/frontend/dist/ui/style.d.ts +4 -3
- package/frontend/dist/ui/style.js +13 -18
- package/frontend/dist/ui/switch.d.ts +10 -4
- package/frontend/dist/ui/switch.js +24 -16
- package/frontend/dist/ui/table.d.ts +0 -23
- package/frontend/dist/ui/table.js +113 -119
- package/frontend/dist/ui/tabs.d.ts +3 -19
- package/frontend/dist/ui/tabs.js +35 -29
- package/frontend/dist/ui/text.d.ts +0 -8
- package/frontend/dist/ui/text.js +20 -25
- package/frontend/dist/ui/title.d.ts +0 -15
- package/frontend/dist/ui/title.js +39 -45
- package/frontend/dist/ui/ui.d.ts +0 -2
- package/frontend/dist/ui/ui.js +0 -2
- package/frontend/dist/ui/view.d.ts +3 -17
- package/frontend/dist/ui/view.js +27 -32
- package/frontend/dist/volt.d.ts +2 -1
- package/frontend/dist/volt.js +3 -1
- package/frontend/examples/dashboard/dashboard.ts +774 -0
- package/frontend/examples/theme/theme.ts +58 -0
- package/frontend/src/css/volt.css +5 -0
- package/frontend/src/elements/base.ts +767 -545
- package/frontend/src/elements/module.ts +90 -29
- package/frontend/src/elements/register_element.ts +24 -0
- package/frontend/src/modules/auth.ts +7 -6
- package/frontend/src/modules/color.ts +348 -0
- package/frontend/src/modules/colors.ts +468 -449
- package/frontend/src/modules/cookies.ts +1 -0
- package/frontend/src/modules/events.ts +1 -0
- package/frontend/src/modules/google.ts +1 -0
- package/frontend/src/modules/meta.ts +2 -1
- package/frontend/src/modules/mutex.ts +2 -4
- package/frontend/src/modules/paddle.ts +21 -20
- package/frontend/src/modules/scheme.ts +4 -3
- package/frontend/src/modules/statics.ts +2 -1
- package/frontend/src/modules/support.ts +3 -2
- package/frontend/src/modules/theme.ts +413 -0
- package/frontend/src/modules/themes.ts +2 -1
- package/frontend/src/modules/user.ts +12 -11
- package/frontend/src/modules/utils.ts +125 -2
- package/frontend/src/ui/border_button.ts +41 -37
- package/frontend/src/ui/button.ts +33 -32
- package/frontend/src/ui/canvas.ts +5 -2
- package/frontend/src/ui/checkbox.ts +21 -22
- package/frontend/src/ui/code.ts +92 -86
- package/frontend/src/ui/context_menu.ts +7 -5
- package/frontend/src/ui/css.ts +1 -1
- package/frontend/src/ui/divider.ts +15 -10
- package/frontend/src/ui/dropdown.ts +38 -21
- package/frontend/src/ui/for_each.ts +9 -8
- package/frontend/src/ui/form.ts +26 -21
- package/frontend/src/ui/frame_modes.ts +13 -17
- package/frontend/src/ui/google_map.ts +15 -13
- package/frontend/src/ui/gradient.ts +9 -8
- package/frontend/src/ui/image.ts +108 -86
- package/frontend/src/ui/input.ts +145 -144
- package/frontend/src/ui/link.ts +25 -23
- package/frontend/src/ui/list.ts +12 -6
- package/frontend/src/ui/loader_button.ts +26 -25
- package/frontend/src/ui/loaders.ts +12 -11
- package/frontend/src/ui/popup.ts +168 -14
- package/frontend/src/ui/pseudo.ts +5 -3
- package/frontend/src/ui/scroller.ts +303 -294
- package/frontend/src/ui/slider.ts +15 -10
- package/frontend/src/ui/spacer.ts +14 -11
- package/frontend/src/ui/span.ts +6 -2
- package/frontend/src/ui/stack.ts +196 -183
- package/frontend/src/ui/steps.ts +38 -22
- package/frontend/src/ui/style.ts +7 -4
- package/frontend/src/ui/switch.ts +16 -11
- package/frontend/src/ui/table.ts +42 -34
- package/frontend/src/ui/tabs.ts +20 -19
- package/frontend/src/ui/text.ts +12 -11
- package/frontend/src/ui/title.ts +22 -20
- package/frontend/src/ui/ui.ts +0 -2
- package/frontend/src/ui/view.ts +20 -19
- package/frontend/src/volt.ts +3 -1
- package/frontend/{compile.js → tools/compile.old.js} +2 -2
- package/frontend/tools/embed_scripts.js +69 -0
- package/frontend/tsconfig.json +26 -0
- package/package.json +8 -8
- package/frontend/dist/ui/theme.d.ts +0 -25
- package/frontend/exports.json +0 -1340
- package/frontend/src/modules/date.js +0 -535
- package/frontend/src/ui/color.ts +0 -117
- package/frontend/src/ui/theme.ts +0 -279
- /package/backend/src/{vinc.dev.js → vinc.dev.ts} +0 -0
|
@@ -141,7 +141,7 @@ export namespace User {
|
|
|
141
141
|
* @type: boolean
|
|
142
142
|
*/
|
|
143
143
|
export async function get(): Promise<UserObject> {
|
|
144
|
-
return Utils.
|
|
144
|
+
return Utils.request_v1({
|
|
145
145
|
method: "GET",
|
|
146
146
|
url: "/volt/user/",
|
|
147
147
|
data: {
|
|
@@ -167,7 +167,7 @@ export namespace User {
|
|
|
167
167
|
email?: string,
|
|
168
168
|
is_activated?: boolean,
|
|
169
169
|
}): Promise<any> {
|
|
170
|
-
return Utils.
|
|
170
|
+
return Utils.request_v1({
|
|
171
171
|
method: "POST",
|
|
172
172
|
url: "/volt/user/",
|
|
173
173
|
data: user,
|
|
@@ -183,7 +183,7 @@ export namespace User {
|
|
|
183
183
|
* @return: Returns a promise with a successful update response or a request error on a failed request.
|
|
184
184
|
*/
|
|
185
185
|
export async function activate(code: string = ""): Promise<Response> {
|
|
186
|
-
return Utils.
|
|
186
|
+
return Utils.request_v1({
|
|
187
187
|
method: "POST",
|
|
188
188
|
url: "/volt/auth/activate",
|
|
189
189
|
data: {
|
|
@@ -205,7 +205,7 @@ export namespace User {
|
|
|
205
205
|
password = "",
|
|
206
206
|
verify_password = "",
|
|
207
207
|
}: { current_password: string; password: string; verify_password: string }): Promise<Response> {
|
|
208
|
-
return Utils.
|
|
208
|
+
return Utils.request_v1({
|
|
209
209
|
method: "POST",
|
|
210
210
|
url: "/volt/user/change_password",
|
|
211
211
|
data: {
|
|
@@ -225,7 +225,7 @@ export namespace User {
|
|
|
225
225
|
* @return: Returns a promise with a successful update response or a request error on a failed request.
|
|
226
226
|
*/
|
|
227
227
|
export async function delete_account(): Promise<Response> {
|
|
228
|
-
return Utils.
|
|
228
|
+
return Utils.request_v1({
|
|
229
229
|
method: "DELETE",
|
|
230
230
|
url: "/volt/user",
|
|
231
231
|
});
|
|
@@ -240,7 +240,7 @@ export namespace User {
|
|
|
240
240
|
* @return: Returns a promise with a successful update response with the newly generated API key as an attribute or a request error on a failed request.
|
|
241
241
|
*/
|
|
242
242
|
export async function generate_api_key(): Promise<GenerateAPIKeyResponse> {
|
|
243
|
-
return Utils.
|
|
243
|
+
return Utils.request_v1({
|
|
244
244
|
method: "POST",
|
|
245
245
|
url: "/volt/user/api_key",
|
|
246
246
|
});
|
|
@@ -255,7 +255,7 @@ export namespace User {
|
|
|
255
255
|
* @return: Returns a promise with a successful update response or a request error on a failed request.
|
|
256
256
|
*/
|
|
257
257
|
export async function revoke_api_key(): Promise<Response> {
|
|
258
|
-
return Utils.
|
|
258
|
+
return Utils.request_v1({
|
|
259
259
|
method: "DELETE",
|
|
260
260
|
url: "/volt/user/api_key",
|
|
261
261
|
});
|
|
@@ -270,7 +270,7 @@ export namespace User {
|
|
|
270
270
|
* @return: Returns a promise with the loaded user's data or a request error on a failed request.
|
|
271
271
|
*/
|
|
272
272
|
export async function load(path: string, def: string = ""): Promise<any> {
|
|
273
|
-
return Utils.
|
|
273
|
+
return Utils.request_v1({
|
|
274
274
|
method: "GET",
|
|
275
275
|
url: "/volt/user/data",
|
|
276
276
|
data: {
|
|
@@ -289,7 +289,7 @@ export namespace User {
|
|
|
289
289
|
* @return: Returns a promise with a successful update response or a request error on a failed request.
|
|
290
290
|
*/
|
|
291
291
|
export async function save(path: string = "", data: Record<string, any> = {}): Promise<any> {
|
|
292
|
-
return Utils.
|
|
292
|
+
return Utils.request_v1({
|
|
293
293
|
method: "POST",
|
|
294
294
|
url: "/volt/user/data",
|
|
295
295
|
data: {
|
|
@@ -308,7 +308,7 @@ export namespace User {
|
|
|
308
308
|
* @return: Returns a promise with the loaded user's data or a request error on a failed request.
|
|
309
309
|
*/
|
|
310
310
|
export async function load_protected(path: string, def: string = ""): Promise<any> {
|
|
311
|
-
return Utils.
|
|
311
|
+
return Utils.request_v1({
|
|
312
312
|
method: "GET",
|
|
313
313
|
url: "/volt/user/data/protected",
|
|
314
314
|
data: {
|
|
@@ -318,4 +318,5 @@ export namespace User {
|
|
|
318
318
|
});
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
};
|
|
321
|
+
};
|
|
322
|
+
export { User as user }; // also export as lowercase for compatibility.
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* Copyright: © 2022 - 2024 Daan van den Bergh.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { AnyElement } from "../ui/any_element";
|
|
7
|
+
|
|
6
8
|
// Utils module.
|
|
7
9
|
const Utils = {
|
|
8
10
|
is_apple: navigator.vendor.includes('Apple') as boolean,
|
|
@@ -560,6 +562,126 @@ const Utils = {
|
|
|
560
562
|
}
|
|
561
563
|
},
|
|
562
564
|
|
|
565
|
+
|
|
566
|
+
/** New request method. */
|
|
567
|
+
async request<Data = any>(options: {
|
|
568
|
+
method?: string;
|
|
569
|
+
url?: string | null;
|
|
570
|
+
data?: any;
|
|
571
|
+
json?: boolean;
|
|
572
|
+
credentials?: RequestCredentials;
|
|
573
|
+
headers?: Record<string, string>;
|
|
574
|
+
}): Promise<{
|
|
575
|
+
error?: {
|
|
576
|
+
message: string;
|
|
577
|
+
type?: string;
|
|
578
|
+
invalid_fields?: { [name: string]: string };
|
|
579
|
+
};
|
|
580
|
+
status: number;
|
|
581
|
+
data?: Data;
|
|
582
|
+
}> {
|
|
583
|
+
const {
|
|
584
|
+
method = 'GET',
|
|
585
|
+
url = null,
|
|
586
|
+
data = null,
|
|
587
|
+
json = true,
|
|
588
|
+
credentials = "same-origin",
|
|
589
|
+
headers = {},
|
|
590
|
+
} = options;
|
|
591
|
+
|
|
592
|
+
// — prepare headers —
|
|
593
|
+
if (json && data != null && !headers['Content-Type']) {
|
|
594
|
+
headers['Content-Type'] = 'application/json';
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
// — build URL + body —
|
|
598
|
+
let finalUrl = url!;
|
|
599
|
+
let body: string | undefined;
|
|
600
|
+
if (data != null && typeof data === 'object') {
|
|
601
|
+
if (method.toUpperCase() === 'GET') {
|
|
602
|
+
finalUrl = `${url}?${new URLSearchParams(data).toString()}`;
|
|
603
|
+
} else {
|
|
604
|
+
body = JSON.stringify(data);
|
|
605
|
+
}
|
|
606
|
+
} else if (data != null) {
|
|
607
|
+
body = String(data);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
const init: RequestInit = { method, credentials, headers };
|
|
611
|
+
if (body !== undefined) init.body = body;
|
|
612
|
+
|
|
613
|
+
try {
|
|
614
|
+
const response = await fetch(finalUrl, init);
|
|
615
|
+
const status = response.status;
|
|
616
|
+
|
|
617
|
+
// — parse payload once —
|
|
618
|
+
let payload: any;
|
|
619
|
+
const clone = response.clone(); // @dev.
|
|
620
|
+
if (json) {
|
|
621
|
+
try {
|
|
622
|
+
payload = await response.json();
|
|
623
|
+
} catch (e: any) {
|
|
624
|
+
// malformed JSON still counts as a “success” fetch
|
|
625
|
+
console.log("[debug] Unable to parse a json from response:", await clone.text(), "- Error: ", JSON.stringify(e, null, 4))
|
|
626
|
+
console.log("rsponse:", response);
|
|
627
|
+
return {
|
|
628
|
+
status,
|
|
629
|
+
error: { message: `Failed to parse JSON response: ${e.message}` },
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
} else {
|
|
633
|
+
try {
|
|
634
|
+
payload = await response.text();
|
|
635
|
+
} catch (e: any) {
|
|
636
|
+
return {
|
|
637
|
+
status,
|
|
638
|
+
error: { message: `Failed to parse text response: ${e.message}` },
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
console.log("Payload", json, payload)
|
|
643
|
+
|
|
644
|
+
// — handle HTTP errors (4xx/5xx) by resolving with an error object —
|
|
645
|
+
if (!response.ok) {
|
|
646
|
+
// if server wrapped its error in { error: { message, type?, invalid_fields? }, … }
|
|
647
|
+
if (
|
|
648
|
+
payload &&
|
|
649
|
+
typeof payload === 'object' &&
|
|
650
|
+
typeof payload.error === 'object' &&
|
|
651
|
+
typeof payload.error.message === 'string'
|
|
652
|
+
) {
|
|
653
|
+
return {
|
|
654
|
+
status,
|
|
655
|
+
error: {
|
|
656
|
+
message: payload.error.message,
|
|
657
|
+
type: payload.error.type,
|
|
658
|
+
invalid_fields: payload.error.invalid_fields,
|
|
659
|
+
},
|
|
660
|
+
data: payload.data,
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// otherwise fall back to a generic single‐message error
|
|
665
|
+
const msg =
|
|
666
|
+
typeof payload === 'string'
|
|
667
|
+
? payload
|
|
668
|
+
: payload?.error?.toString() ?? JSON.stringify(payload);
|
|
669
|
+
return {
|
|
670
|
+
status,
|
|
671
|
+
error: { message: msg },
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// — 2xx: success —
|
|
676
|
+
return { status, data: payload };
|
|
677
|
+
} catch (networkErr) {
|
|
678
|
+
// genuine network / system failure
|
|
679
|
+
throw networkErr;
|
|
680
|
+
}
|
|
681
|
+
},
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
// @deprecated.
|
|
563
685
|
/* @docs:
|
|
564
686
|
@nav: Frontend
|
|
565
687
|
@chapter: Utils
|
|
@@ -580,7 +702,7 @@ const Utils = {
|
|
|
580
702
|
@desc: A Promise that resolves with the response data.
|
|
581
703
|
@type: Promise<any>
|
|
582
704
|
*/
|
|
583
|
-
|
|
705
|
+
request_v1(options: {
|
|
584
706
|
method?: string,
|
|
585
707
|
url?: string | null,
|
|
586
708
|
data?: any,
|
|
@@ -721,7 +843,7 @@ const Utils = {
|
|
|
721
843
|
@desc: void
|
|
722
844
|
@type: void
|
|
723
845
|
*/
|
|
724
|
-
async on_load(func: () => HTMLElement | Promise<HTMLElement> | null): Promise<void> {
|
|
846
|
+
async on_load(func: () => HTMLElement | AnyElement | Promise<HTMLElement | AnyElement> | null | undefined): Promise<void> {
|
|
725
847
|
// document.addEventListener("DOMContentLoaded", async () => {
|
|
726
848
|
const splash = document.getElementById("__volt_splash_screen");
|
|
727
849
|
if (splash != null) {
|
|
@@ -1258,3 +1380,4 @@ const Utils = {
|
|
|
1258
1380
|
|
|
1259
1381
|
// Export.
|
|
1260
1382
|
export { Utils };
|
|
1383
|
+
export { Utils as utils }; // also export as lowercase for compatibility.
|
|
@@ -4,51 +4,52 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// Imports.
|
|
7
|
-
import { Elements, VAnchorElement, VDivElement, VDiv, VElementTagMap } from "../elements/module.js";
|
|
7
|
+
import { Elements, VElement, VElementBaseSignature, VAnchorElement, VDivElement, VDiv, VElementTagMap } from "../elements/module.js";
|
|
8
8
|
|
|
9
9
|
// BorderButton.
|
|
10
10
|
/**
|
|
11
11
|
* Supports a gradient color for the border combined with border radius.
|
|
12
12
|
* Warning: this class is still experimental and may be subject to future change.
|
|
13
13
|
*/
|
|
14
|
-
@Elements.
|
|
14
|
+
@Elements.create({
|
|
15
|
+
name: "BorderButtonElement",
|
|
16
|
+
default_style: {
|
|
17
|
+
"margin": "0px 0px 0px 0px",
|
|
18
|
+
"display": "inline-block",
|
|
19
|
+
"color": "inherit",
|
|
20
|
+
"text-align": "center",
|
|
21
|
+
"cursor": "pointer",
|
|
22
|
+
"position": "relative",
|
|
23
|
+
"z-index": "0",
|
|
24
|
+
"background": "none",
|
|
25
|
+
"user-select": "none",
|
|
26
|
+
"outline": "none",
|
|
27
|
+
"border": "none",
|
|
28
|
+
"text-decoration": "none",
|
|
29
|
+
// Custom.
|
|
30
|
+
"--child-color": "black",
|
|
31
|
+
"--child-background": "black",
|
|
32
|
+
"--child-border-width": "2px",
|
|
33
|
+
"--child-border-radius": "10px",
|
|
34
|
+
"--child-padding": "5px 10px 5px 10px",
|
|
35
|
+
},
|
|
36
|
+
default_events: {
|
|
37
|
+
"onmousedown": function (this: any): void {
|
|
38
|
+
this.style.filter = "brightness(80%)";
|
|
39
|
+
},
|
|
40
|
+
"onmouseover": function (this: any): void {
|
|
41
|
+
this.style.filter = "brightness(90%)";
|
|
42
|
+
},
|
|
43
|
+
"onmouseup": function (this: any): void {
|
|
44
|
+
this.style.filter = "brightness(100%)";
|
|
45
|
+
},
|
|
46
|
+
"onmouseout": function (this: any): void {
|
|
47
|
+
this.style.filter = "brightness(100%)";
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
})
|
|
15
51
|
export class BorderButtonElement extends VElementTagMap.a {
|
|
16
52
|
|
|
17
|
-
static default_style = {
|
|
18
|
-
"margin": "0px 0px 0px 0px",
|
|
19
|
-
"display": "inline-block",
|
|
20
|
-
"color": "inherit",
|
|
21
|
-
"text-align": "center",
|
|
22
|
-
"cursor": "pointer",
|
|
23
|
-
"position": "relative",
|
|
24
|
-
"z-index": "0",
|
|
25
|
-
"background": "none",
|
|
26
|
-
"user-select": "none",
|
|
27
|
-
"outline": "none",
|
|
28
|
-
"border": "none",
|
|
29
|
-
"text-decoration": "none",
|
|
30
|
-
// Custom.
|
|
31
|
-
"--child-color": "black",
|
|
32
|
-
"--child-background": "black",
|
|
33
|
-
"--child-border-width": "2px",
|
|
34
|
-
"--child-border-radius": "10px",
|
|
35
|
-
"--child-padding": "5px 10px 5px 10px",
|
|
36
|
-
};
|
|
37
|
-
static default_events = {
|
|
38
|
-
"onmousedown": function (this: any): void {
|
|
39
|
-
this.style.filter = "brightness(80%)";
|
|
40
|
-
},
|
|
41
|
-
"onmouseover": function (this: any): void {
|
|
42
|
-
this.style.filter = "brightness(90%)";
|
|
43
|
-
},
|
|
44
|
-
"onmouseup": function (this: any): void {
|
|
45
|
-
this.style.filter = "brightness(100%)";
|
|
46
|
-
},
|
|
47
|
-
"onmouseout": function (this: any): void {
|
|
48
|
-
this.style.filter = "brightness(100%)";
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
53
|
public nodes: {
|
|
53
54
|
border: VDivElement;
|
|
54
55
|
text: VDivElement;
|
|
@@ -311,6 +312,9 @@ export class BorderButtonElement extends VElementTagMap.a {
|
|
|
311
312
|
transition_border_color(val: string): this;
|
|
312
313
|
transition_border_color(val?: string): string | this {
|
|
313
314
|
if (val == null) { return this.nodes.border.transition(); }
|
|
315
|
+
else if (/[0-9]/.test(val.charAt(0))) {
|
|
316
|
+
val = "border-color " + val;
|
|
317
|
+
}
|
|
314
318
|
this.nodes.border.transition(typeof val !== "string" ? val : val.replace("border-color ", "background "));
|
|
315
319
|
return this;
|
|
316
320
|
}
|
|
@@ -4,42 +4,43 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// Imports.
|
|
7
|
-
import { Elements, VElementTagMap } from "../elements/module.js";
|
|
7
|
+
import { Elements, VElementBaseSignature, VElement, VElementTagMap, VHTMLElement } from "../elements/module.js";
|
|
8
8
|
|
|
9
9
|
// Button.
|
|
10
|
-
@Elements.
|
|
10
|
+
@Elements.create({
|
|
11
|
+
name: "ButtonElement",
|
|
12
|
+
default_style: {
|
|
13
|
+
"margin": "0px 0px 0px",
|
|
14
|
+
"padding": "5px 10px 5px 10px",
|
|
15
|
+
"outline": "none",
|
|
16
|
+
"border": "none",
|
|
17
|
+
"border-radius": "10px",
|
|
18
|
+
"cursor": "pointer",
|
|
19
|
+
"color": "inherit",
|
|
20
|
+
"text-align": "center",
|
|
21
|
+
"display": "grid",
|
|
22
|
+
"align-items": "center",
|
|
23
|
+
"white-space": "nowrap",
|
|
24
|
+
"user-select": "none",
|
|
25
|
+
"text-decoration": "none",
|
|
26
|
+
},
|
|
27
|
+
default_events: {
|
|
28
|
+
"onmousedown": function (this: any): void {
|
|
29
|
+
this.style.filter = "brightness(80%)";
|
|
30
|
+
},
|
|
31
|
+
"onmouseover": function (this: any): void {
|
|
32
|
+
this.style.filter = "brightness(90%)";
|
|
33
|
+
},
|
|
34
|
+
"onmouseup": function (this: any): void {
|
|
35
|
+
this.style.filter = "brightness(100%)";
|
|
36
|
+
},
|
|
37
|
+
"onmouseout": function (this: any): void {
|
|
38
|
+
this.style.filter = "brightness(100%)";
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
})
|
|
11
42
|
export class ButtonElement extends VElementTagMap.a {
|
|
12
43
|
|
|
13
|
-
static default_style = {
|
|
14
|
-
"margin": "0px 0px 0px",
|
|
15
|
-
"padding": "5px 10px 5px 10px",
|
|
16
|
-
"outline": "none",
|
|
17
|
-
"border": "none",
|
|
18
|
-
"border-radius": "10px",
|
|
19
|
-
"cursor": "pointer",
|
|
20
|
-
"color": "inherit",
|
|
21
|
-
"text-align": "center",
|
|
22
|
-
"display": "grid",
|
|
23
|
-
"align-items": "center",
|
|
24
|
-
"white-space": "nowrap",
|
|
25
|
-
"user-select": "none",
|
|
26
|
-
"text-decoration": "none",
|
|
27
|
-
};
|
|
28
|
-
static default_events = {
|
|
29
|
-
"onmousedown": function (this: any): void {
|
|
30
|
-
this.style.filter = "brightness(80%)";
|
|
31
|
-
},
|
|
32
|
-
"onmouseover": function (this: any): void {
|
|
33
|
-
this.style.filter = "brightness(90%)";
|
|
34
|
-
},
|
|
35
|
-
"onmouseup": function (this: any): void {
|
|
36
|
-
this.style.filter = "brightness(100%)";
|
|
37
|
-
},
|
|
38
|
-
"onmouseout": function (this: any): void {
|
|
39
|
-
this.style.filter = "brightness(100%)";
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
44
|
/**
|
|
44
45
|
* @docs:
|
|
45
46
|
* @nav: Frontend
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
// Imports.
|
|
7
7
|
import { Utils } from "../modules/utils.js"
|
|
8
|
-
import { Elements, VElementTagMap } from "../elements/module.js"
|
|
8
|
+
import { Elements, VElementBaseSignature, VElement, VElementTagMap } from "../elements/module.js"
|
|
9
9
|
import { GradientType } from "../types/gradient.js"
|
|
10
10
|
|
|
11
11
|
// Types.
|
|
@@ -23,9 +23,12 @@ type DotObject = {x: number, y: number, tension?: number};
|
|
|
23
23
|
* @warning:
|
|
24
24
|
* This class is still experimental and may be subject to future change.
|
|
25
25
|
*/
|
|
26
|
-
@Elements.
|
|
26
|
+
@Elements.create({
|
|
27
|
+
name: "CanvasElement",
|
|
28
|
+
})
|
|
27
29
|
export class CanvasElement extends VElementTagMap.canvas {
|
|
28
30
|
|
|
31
|
+
// Attributes.
|
|
29
32
|
public _e: any;
|
|
30
33
|
public ctx_2d: any;
|
|
31
34
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// Imports.
|
|
7
|
-
import { Elements } from "../elements/module.js"
|
|
7
|
+
import { Elements, VElementBaseSignature, VElement } from "../elements/module.js"
|
|
8
8
|
import { VStack, VStackElement, HStack, HStackElement } from "./stack"
|
|
9
9
|
import { Text, TextElement } from "./text"
|
|
10
10
|
|
|
@@ -17,23 +17,22 @@ interface CircleExtension {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// Extended input.
|
|
20
|
-
@Elements.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"--missing-color": "#E8454E",
|
|
35
|
-
}
|
|
20
|
+
@Elements.create({
|
|
21
|
+
name: "CheckBoxElement",
|
|
22
|
+
default_style: {
|
|
23
|
+
...VStackElement.default_style,
|
|
24
|
+
"color": "inherit",
|
|
25
|
+
"font-size": "16px",
|
|
26
|
+
// Custom.
|
|
27
|
+
"--circle-border-color": "gray",
|
|
28
|
+
"--circle-inner-bg": "#FFFFFF",
|
|
29
|
+
"--focus-color": "#8EB8EB",
|
|
30
|
+
"--missing-color": "#E8454E",
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
export class CheckBoxElement extends (VStackElement as any as VElementBaseSignature) {
|
|
36
34
|
|
|
35
|
+
// Attributes.
|
|
37
36
|
public _border_color: string;
|
|
38
37
|
public _inner_bg: string;
|
|
39
38
|
public _focus_color: string;
|
|
@@ -60,7 +59,7 @@ export class CheckBoxElement extends VStackElement {
|
|
|
60
59
|
|
|
61
60
|
// Initialize super.
|
|
62
61
|
super();
|
|
63
|
-
this.
|
|
62
|
+
this._init({
|
|
64
63
|
derived: CheckBoxElement,
|
|
65
64
|
})
|
|
66
65
|
|
|
@@ -85,8 +84,8 @@ export class CheckBoxElement extends VStackElement {
|
|
|
85
84
|
this.circle = VStack(
|
|
86
85
|
VStack()
|
|
87
86
|
.assign_to_parent_as("inner")
|
|
88
|
-
.border_radius(50%)
|
|
89
|
-
.frame(35
|
|
87
|
+
.border_radius("50%")
|
|
88
|
+
.frame("35%", "35%")
|
|
90
89
|
.background(this._inner_bg)
|
|
91
90
|
.flex_shrink(0)
|
|
92
91
|
)
|
|
@@ -95,7 +94,7 @@ export class CheckBoxElement extends VStackElement {
|
|
|
95
94
|
.border_width(1)
|
|
96
95
|
.border_style("solid")
|
|
97
96
|
.border_color(this._border_color)
|
|
98
|
-
.border_radius(50%)
|
|
97
|
+
.border_radius("50%")
|
|
99
98
|
.frame(15, 15)
|
|
100
99
|
.margin(2.5, 10, 0, 0)
|
|
101
100
|
.background("transparent")
|
|
@@ -137,7 +136,7 @@ export class CheckBoxElement extends VStackElement {
|
|
|
137
136
|
|
|
138
137
|
// The content.
|
|
139
138
|
this.content = HStack(this.circle, this.text)
|
|
140
|
-
.width(100%)
|
|
139
|
+
.width("100%")
|
|
141
140
|
|
|
142
141
|
// The error message.
|
|
143
142
|
this.error = Text("Incomplete field")
|