@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.
- package/backend/dist/cjs/{blacklist.d.ts → backend/src/blacklist.d.ts} +5 -3
- package/backend/dist/cjs/{blacklist.js → backend/src/blacklist.js} +8 -5
- package/backend/dist/cjs/{cli.js → backend/src/cli.js} +29 -47
- package/backend/dist/cjs/backend/src/database/collection.d.ts +1543 -0
- package/backend/dist/cjs/backend/src/database/collection.js +3042 -0
- package/backend/dist/cjs/backend/src/database/database.d.ts +66 -0
- package/backend/dist/cjs/{database → backend/src/database}/database.js +48 -43
- package/backend/dist/cjs/backend/src/database/filters/filters.d.ts +6 -0
- package/backend/dist/cjs/backend/src/database/filters/filters.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter.d.ts +223 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_test.js +443 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_test_v0.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.d.ts +50 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.d.ts +76 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.d.ts +75 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.d.ts +219 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.d.ts +165 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.d.ts +5 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.js +355 -0
- package/backend/dist/cjs/backend/src/database/flatten.d.ts +75 -0
- package/backend/dist/cjs/{logger.js → backend/src/database/flatten.js} +18 -7
- package/backend/dist/cjs/backend/src/database/flatten_test.js +175 -0
- package/backend/dist/cjs/backend/src/database/quota/quota.d.ts +461 -0
- package/backend/dist/cjs/backend/src/database/quota/quota.js +1014 -0
- package/backend/dist/cjs/backend/src/database/quota/quota_v1.d.ts +534 -0
- package/backend/dist/cjs/backend/src/database/quota/quota_v1.js +1087 -0
- package/backend/dist/cjs/backend/src/database/quota/safe_int.d.ts +293 -0
- package/backend/dist/cjs/backend/src/database/quota/safe_int.js +573 -0
- package/backend/dist/{esm → cjs/backend/src}/endpoint.d.ts +69 -46
- package/backend/dist/cjs/{endpoint.js → backend/src/endpoint.js} +87 -101
- package/backend/dist/cjs/backend/src/errors/index.d.ts +7 -0
- package/backend/dist/cjs/backend/src/errors/index.js +25 -0
- package/backend/dist/{esm/utils.d.ts → cjs/backend/src/errors/internal_external.d.ts} +14 -22
- package/backend/dist/cjs/backend/src/errors/internal_external.js +85 -0
- package/backend/dist/cjs/backend/src/errors/invalid_usage_error.d.ts +38 -0
- package/backend/dist/cjs/{mutex.js → backend/src/errors/invalid_usage_error.js} +20 -37
- package/backend/dist/cjs/backend/src/errors/system_error.d.ts +230 -0
- package/backend/dist/cjs/backend/src/errors/system_error.js +393 -0
- package/backend/dist/cjs/backend/src/events.d.ts +54 -0
- package/backend/dist/cjs/backend/src/events.js +15 -0
- package/backend/dist/cjs/{frontend.js → backend/src/frontend.js} +1 -1
- package/backend/dist/cjs/{image_endpoint.d.ts → backend/src/image_endpoint.d.ts} +16 -1
- package/backend/dist/cjs/{image_endpoint.js → backend/src/image_endpoint.js} +3 -5
- package/backend/dist/cjs/backend/src/logger.d.ts +5 -0
- package/backend/dist/cjs/backend/src/logger.js +15 -0
- package/backend/dist/cjs/backend/src/meta.d.ts +64 -0
- package/backend/dist/cjs/{meta.js → backend/src/meta.js} +9 -12
- package/backend/dist/cjs/backend/src/payments/paddle.d.ts +326 -0
- package/backend/dist/cjs/{payments → backend/src/payments}/paddle.js +377 -327
- package/backend/dist/cjs/backend/src/plugins/browser.d.ts +1 -0
- package/backend/dist/cjs/backend/src/plugins/browser.js +15 -0
- package/backend/dist/cjs/backend/src/plugins/mail/mail.d.ts +248 -0
- package/backend/dist/cjs/backend/src/plugins/mail/mail.js +379 -0
- package/backend/dist/{esm → cjs/backend/src}/plugins/mail/ui.d.ts +23 -0
- package/backend/dist/cjs/backend/src/plugins/pdf.d.ts +1 -0
- package/backend/dist/cjs/backend/src/rate_limit.d.ts +145 -0
- package/backend/dist/cjs/backend/src/rate_limit.js +549 -0
- package/backend/dist/cjs/{route.d.ts → backend/src/route.d.ts} +3 -10
- package/backend/dist/cjs/{route.js → backend/src/route.js} +23 -21
- package/backend/dist/cjs/backend/src/server.d.ts +485 -0
- package/backend/dist/cjs/{server.js → backend/src/server.js} +688 -873
- package/backend/dist/cjs/backend/src/splash_screen.d.ts +80 -0
- package/backend/dist/cjs/{splash_screen.js → backend/src/splash_screen.js} +24 -3
- package/backend/dist/cjs/backend/src/status.d.ts +74 -0
- package/backend/dist/cjs/{status.js → backend/src/status.js} +64 -64
- package/backend/dist/cjs/backend/src/stream.d.ts +376 -0
- package/backend/dist/cjs/{stream.js → backend/src/stream.js} +299 -276
- package/backend/dist/cjs/backend/src/users.d.ts +807 -0
- package/backend/dist/cjs/backend/src/users.js +1971 -0
- package/backend/dist/cjs/backend/src/utils.d.ts +16 -0
- package/backend/dist/cjs/{utils.js → backend/src/utils.js} +14 -77
- package/backend/dist/{esm → cjs/backend/src}/view.d.ts +33 -11
- package/backend/dist/cjs/backend/src/view.js +508 -0
- package/backend/dist/{esm → cjs/backend/src}/volt.d.ts +10 -1
- package/backend/dist/cjs/{volt.js → backend/src/volt.js} +8 -5
- package/backend/dist/cjs/frontend/src/modules/request.d.ts +70 -0
- package/backend/dist/cjs/frontend/src/modules/request.js +99 -0
- package/backend/dist/esm/{blacklist.d.ts → backend/src/blacklist.d.ts} +5 -3
- package/backend/dist/esm/{blacklist.js → backend/src/blacklist.js} +9 -6
- package/backend/dist/esm/{cli.js → backend/src/cli.js} +43 -60
- package/backend/dist/esm/backend/src/database/collection.d.ts +1543 -0
- package/backend/dist/esm/backend/src/database/collection.js +3510 -0
- package/backend/dist/esm/backend/src/database/database.d.ts +66 -0
- package/backend/dist/esm/{database → backend/src/database}/database.js +62 -103
- package/backend/dist/esm/backend/src/database/document.d.ts +1 -0
- package/backend/dist/esm/backend/src/database/document.js +558 -0
- package/backend/dist/esm/backend/src/database/filters/filters.d.ts +6 -0
- package/backend/dist/esm/backend/src/database/filters/filters.js +1 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter.d.ts +223 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter.js +3 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test.d.ts +1 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test.js +505 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.d.ts +1 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.js +712 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.d.ts +50 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.js +5 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.d.ts +76 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.js +44 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.d.ts +75 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.js +5 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.d.ts +219 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.js +1 -0
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter.d.ts +165 -0
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter.js +5 -0
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.d.ts +5 -0
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.js +405 -0
- package/backend/dist/esm/backend/src/database/flatten.d.ts +75 -0
- package/backend/dist/esm/backend/src/database/flatten.js +22 -0
- package/backend/dist/esm/backend/src/database/flatten_test.d.ts +1 -0
- package/backend/dist/esm/backend/src/database/flatten_test.js +174 -0
- package/backend/dist/esm/backend/src/database/quota/quota.d.ts +461 -0
- package/backend/dist/esm/backend/src/database/quota/quota.js +1118 -0
- package/backend/dist/esm/backend/src/database/quota/quota_v1.d.ts +534 -0
- package/backend/dist/esm/backend/src/database/quota/quota_v1.js +1242 -0
- package/backend/dist/esm/backend/src/database/quota/safe_int.d.ts +293 -0
- package/backend/dist/esm/backend/src/database/quota/safe_int.js +602 -0
- package/backend/dist/{cjs → esm/backend/src}/endpoint.d.ts +69 -46
- package/backend/dist/esm/{endpoint.js → backend/src/endpoint.js} +136 -127
- package/backend/dist/esm/backend/src/errors/index.d.ts +7 -0
- package/backend/dist/esm/backend/src/errors/index.js +7 -0
- package/backend/dist/{cjs/utils.d.ts → esm/backend/src/errors/internal_external.d.ts} +14 -22
- package/backend/dist/esm/backend/src/errors/internal_external.js +70 -0
- package/backend/dist/esm/backend/src/errors/invalid_usage_error.d.ts +38 -0
- package/backend/dist/esm/backend/src/errors/invalid_usage_error.js +30 -0
- package/backend/dist/esm/backend/src/errors/system_error.d.ts +230 -0
- package/backend/dist/esm/backend/src/errors/system_error.js +402 -0
- package/backend/dist/esm/backend/src/events.d.ts +54 -0
- package/backend/dist/esm/backend/src/events.js +5 -0
- package/backend/dist/esm/{frontend.js → backend/src/frontend.js} +1 -1
- package/backend/dist/esm/{image_endpoint.d.ts → backend/src/image_endpoint.d.ts} +16 -1
- package/backend/dist/esm/{image_endpoint.js → backend/src/image_endpoint.js} +16 -20
- package/backend/dist/esm/backend/src/logger.d.ts +5 -0
- package/backend/dist/esm/backend/src/logger.js +8 -0
- package/backend/dist/esm/backend/src/meta.d.ts +64 -0
- package/backend/dist/esm/{meta.js → backend/src/meta.js} +15 -54
- package/backend/dist/esm/backend/src/payments/paddle.d.ts +326 -0
- package/backend/dist/esm/{payments → backend/src/payments}/paddle.js +417 -452
- package/backend/dist/esm/backend/src/plugins/browser.d.ts +1 -0
- package/backend/dist/esm/backend/src/plugins/browser.js +170 -0
- package/backend/dist/esm/backend/src/plugins/mail/mail.d.ts +248 -0
- package/backend/dist/esm/backend/src/plugins/mail/mail.js +389 -0
- package/backend/dist/{cjs → esm/backend/src}/plugins/mail/ui.d.ts +23 -0
- package/backend/dist/esm/{plugins → backend/src/plugins}/mail/ui.js +3 -6
- package/backend/dist/esm/backend/src/plugins/pdf.d.ts +1 -0
- package/backend/dist/esm/{plugins → backend/src/plugins}/pdf.js +3 -3
- package/backend/dist/esm/backend/src/rate_limit.d.ts +145 -0
- package/backend/dist/esm/backend/src/rate_limit.js +667 -0
- package/backend/dist/esm/{route.d.ts → backend/src/route.d.ts} +3 -10
- package/backend/dist/esm/{route.js → backend/src/route.js} +26 -21
- package/backend/dist/esm/backend/src/server.d.ts +485 -0
- package/backend/dist/esm/{server.js → backend/src/server.js} +891 -1441
- package/backend/dist/esm/backend/src/splash_screen.d.ts +80 -0
- package/backend/dist/esm/{splash_screen.js → backend/src/splash_screen.js} +42 -55
- package/backend/dist/esm/backend/src/status.d.ts +74 -0
- package/backend/dist/esm/backend/src/status.js +199 -0
- package/backend/dist/esm/backend/src/stream.d.ts +376 -0
- package/backend/dist/esm/{stream.js → backend/src/stream.js} +327 -292
- package/backend/dist/esm/backend/src/users.d.ts +809 -0
- package/backend/dist/esm/backend/src/users.js +2140 -0
- package/backend/dist/esm/backend/src/utils.d.ts +16 -0
- package/backend/dist/esm/{utils.js → backend/src/utils.js} +20 -81
- package/backend/dist/{cjs → esm/backend/src}/view.d.ts +33 -11
- package/backend/dist/esm/{view.js → backend/src/view.js} +266 -86
- package/backend/dist/{cjs → esm/backend/src}/volt.d.ts +10 -1
- package/backend/dist/esm/{volt.js → backend/src/volt.js} +7 -4
- package/backend/dist/esm/frontend/src/modules/request.d.ts +70 -0
- package/backend/dist/esm/frontend/src/modules/request.js +117 -0
- package/frontend/dist/backend/src/database/collection.d.ts +1543 -0
- package/frontend/dist/backend/src/database/collection.js +3510 -0
- package/frontend/dist/backend/src/database/database.d.ts +66 -0
- package/frontend/dist/backend/src/database/database.js +196 -0
- package/frontend/dist/backend/src/database/filters/filters.d.ts +6 -0
- package/frontend/dist/backend/src/database/filters/filters.js +1 -0
- package/frontend/dist/backend/src/database/filters/strict_filter.d.ts +223 -0
- package/frontend/dist/backend/src/database/filters/strict_filter.js +3 -0
- package/frontend/dist/backend/src/database/filters/strict_update_filter.d.ts +165 -0
- package/frontend/dist/backend/src/database/filters/strict_update_filter.js +5 -0
- package/frontend/dist/backend/src/database/flatten.d.ts +75 -0
- package/frontend/dist/backend/src/database/flatten.js +22 -0
- package/frontend/dist/backend/src/endpoint.d.ts +204 -0
- package/frontend/dist/backend/src/endpoint.js +570 -0
- package/frontend/dist/backend/src/errors/index.d.ts +7 -0
- package/frontend/dist/backend/src/errors/index.js +7 -0
- package/frontend/dist/backend/src/errors/internal_external.d.ts +38 -0
- package/frontend/dist/backend/src/errors/internal_external.js +70 -0
- package/frontend/dist/backend/src/errors/invalid_usage_error.d.ts +38 -0
- package/frontend/dist/backend/src/errors/invalid_usage_error.js +30 -0
- package/frontend/dist/backend/src/errors/system_error.d.ts +230 -0
- package/frontend/dist/backend/src/errors/system_error.js +402 -0
- package/frontend/dist/backend/src/events.d.ts +54 -0
- package/frontend/dist/backend/src/events.js +5 -0
- package/frontend/dist/backend/src/frontend.d.ts +11 -0
- package/frontend/dist/backend/src/frontend.js +12 -0
- package/frontend/dist/backend/src/image_endpoint.d.ts +39 -0
- package/frontend/dist/backend/src/image_endpoint.js +202 -0
- package/frontend/dist/backend/src/meta.d.ts +64 -0
- package/frontend/dist/backend/src/meta.js +110 -0
- package/frontend/dist/backend/src/payments/paddle.d.ts +326 -0
- package/frontend/dist/backend/src/payments/paddle.js +2256 -0
- package/frontend/dist/backend/src/plugins/mail/mail.d.ts +248 -0
- package/frontend/dist/backend/src/plugins/mail/mail.js +389 -0
- package/{backend/dist/esm/plugins/mail.d.ts → frontend/dist/backend/src/plugins/mail/ui.d.ts} +23 -0
- package/{backend/dist/esm/plugins/mail.js → frontend/dist/backend/src/plugins/mail/ui.js} +3 -6
- package/frontend/dist/backend/src/rate_limit.d.ts +145 -0
- package/frontend/dist/backend/src/rate_limit.js +673 -0
- package/frontend/dist/backend/src/route.d.ts +35 -0
- package/frontend/dist/backend/src/route.js +212 -0
- package/frontend/dist/backend/src/server.d.ts +485 -0
- package/frontend/dist/backend/src/server.js +2670 -0
- package/frontend/dist/backend/src/splash_screen.d.ts +80 -0
- package/frontend/dist/backend/src/splash_screen.js +135 -0
- package/frontend/dist/backend/src/status.d.ts +74 -0
- package/frontend/dist/backend/src/status.js +199 -0
- package/frontend/dist/backend/src/stream.d.ts +376 -0
- package/frontend/dist/backend/src/stream.js +1007 -0
- package/frontend/dist/backend/src/users.d.ts +807 -0
- package/frontend/dist/backend/src/users.js +2118 -0
- package/frontend/dist/backend/src/utils.d.ts +16 -0
- package/frontend/dist/backend/src/utils.js +241 -0
- package/frontend/dist/backend/src/view.d.ts +162 -0
- package/frontend/dist/backend/src/view.js +720 -0
- package/frontend/dist/frontend/src/elements/base.d.ts +4414 -0
- package/frontend/dist/{elements → frontend/src/elements}/base.js +3624 -260
- package/frontend/dist/frontend/src/elements/module.d.ts +95 -0
- package/frontend/dist/{elements → frontend/src/elements}/module.js +53 -52
- package/frontend/dist/frontend/src/elements/types.d.ts +52 -0
- package/frontend/dist/frontend/src/elements/types.js +5 -0
- package/frontend/dist/frontend/src/modules/attachment.d.ts +126 -0
- package/frontend/dist/frontend/src/modules/attachment.js +306 -0
- package/frontend/dist/frontend/src/modules/auth.d.ts +44 -0
- package/frontend/dist/frontend/src/modules/auth.js +80 -0
- package/frontend/dist/{modules → frontend/src/modules}/color.js +2 -2
- package/frontend/dist/frontend/src/modules/compression.d.ts +39 -0
- package/frontend/dist/frontend/src/modules/compression.js +102 -0
- package/frontend/dist/frontend/src/modules/cookies.d.ts +44 -0
- package/frontend/dist/frontend/src/modules/cookies.js +143 -0
- package/frontend/dist/frontend/src/modules/events.d.ts +31 -0
- package/frontend/dist/frontend/src/modules/events.js +74 -0
- package/frontend/dist/frontend/src/modules/google.d.ts +23 -0
- package/frontend/dist/frontend/src/modules/google.js +52 -0
- package/frontend/dist/frontend/src/modules/meta.d.ts +14 -0
- package/frontend/dist/{modules → frontend/src/modules}/meta.js +9 -7
- package/frontend/dist/{modules → frontend/src/modules}/paddle.d.ts +37 -134
- package/frontend/dist/{modules → frontend/src/modules}/paddle.js +620 -568
- package/frontend/dist/frontend/src/modules/request.d.ts +70 -0
- package/frontend/dist/frontend/src/modules/request.js +117 -0
- package/frontend/dist/frontend/src/modules/settings.d.ts +3 -0
- package/frontend/dist/frontend/src/modules/settings.js +5 -0
- package/frontend/dist/frontend/src/modules/statics.d.ts +21 -0
- package/frontend/dist/{modules → frontend/src/modules}/statics.js +15 -18
- package/frontend/dist/frontend/src/modules/support.d.ts +30 -0
- package/frontend/dist/frontend/src/modules/support.js +53 -0
- package/frontend/dist/{modules → frontend/src/modules}/theme.d.ts +67 -0
- package/frontend/dist/{modules → frontend/src/modules}/theme.js +68 -38
- package/frontend/dist/frontend/src/modules/themes.d.ts +12 -0
- package/frontend/dist/frontend/src/modules/themes.js +22 -0
- package/frontend/dist/frontend/src/modules/user.d.ts +164 -0
- package/frontend/dist/frontend/src/modules/user.js +268 -0
- package/frontend/dist/frontend/src/modules/utils.d.ts +176 -0
- package/frontend/dist/frontend/src/modules/utils.js +569 -0
- package/frontend/dist/frontend/src/types/gradient.d.ts +29 -0
- package/frontend/dist/{types → frontend/src/types}/gradient.js +14 -18
- package/frontend/dist/frontend/src/ui/border_button.d.ts +94 -0
- package/frontend/dist/{ui → frontend/src/ui}/border_button.js +7 -13
- package/frontend/dist/frontend/src/ui/button.d.ts +28 -0
- package/frontend/dist/{ui → frontend/src/ui}/button.js +21 -12
- package/frontend/dist/frontend/src/ui/canvas.d.ts +138 -0
- package/frontend/dist/{ui → frontend/src/ui}/canvas.js +88 -55
- package/frontend/dist/frontend/src/ui/checkbox.d.ts +74 -0
- package/frontend/dist/{ui → frontend/src/ui}/checkbox.js +80 -41
- package/frontend/dist/{ui → frontend/src/ui}/code.d.ts +73 -6
- package/frontend/dist/{ui → frontend/src/ui}/code.js +55 -52
- package/frontend/dist/{ui → frontend/src/ui}/context_menu.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/context_menu.js +12 -17
- package/frontend/dist/{ui → frontend/src/ui}/css.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/css.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/divider.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/divider.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/dropdown.d.ts +57 -2
- package/frontend/dist/{ui → frontend/src/ui}/dropdown.js +87 -94
- package/frontend/dist/{ui → frontend/src/ui}/for_each.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/for_each.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/form.d.ts +6 -2
- package/frontend/dist/{ui → frontend/src/ui}/form.js +10 -7
- package/frontend/dist/frontend/src/ui/frame_modes.d.ts +37 -0
- package/frontend/dist/{ui → frontend/src/ui}/frame_modes.js +16 -22
- package/frontend/dist/{ui → frontend/src/ui}/google_map.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/google_map.js +4 -4
- package/frontend/dist/{ui → frontend/src/ui}/gradient.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/gradient.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/image.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/image.js +5 -5
- package/frontend/dist/frontend/src/ui/input.d.ts +392 -0
- package/frontend/dist/{ui → frontend/src/ui}/input.js +346 -360
- package/frontend/dist/{ui → frontend/src/ui}/link.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/link.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/list.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/list.js +12 -6
- package/frontend/dist/frontend/src/ui/loader_button.d.ts +80 -0
- package/frontend/dist/{ui → frontend/src/ui}/loader_button.js +35 -47
- package/frontend/dist/frontend/src/ui/loaders.d.ts +57 -0
- package/frontend/dist/{ui → frontend/src/ui}/loaders.js +11 -11
- package/frontend/dist/{ui → frontend/src/ui}/popup.d.ts +11 -6
- package/frontend/dist/{ui → frontend/src/ui}/popup.js +32 -18
- package/frontend/dist/frontend/src/ui/pseudo.d.ts +44 -0
- package/frontend/dist/{ui → frontend/src/ui}/pseudo.js +84 -8
- package/frontend/dist/{ui → frontend/src/ui}/scroller.d.ts +14 -2
- package/frontend/dist/{ui → frontend/src/ui}/scroller.js +37 -43
- package/frontend/dist/{ui → frontend/src/ui}/slider.d.ts +5 -1
- package/frontend/dist/{ui → frontend/src/ui}/slider.js +4 -4
- package/frontend/dist/{ui → frontend/src/ui}/spacer.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/spacer.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/span.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/span.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/stack.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/stack.js +3 -9
- package/frontend/dist/frontend/src/ui/steps.d.ts +131 -0
- package/frontend/dist/{ui → frontend/src/ui}/steps.js +30 -45
- package/frontend/dist/{ui → frontend/src/ui}/style.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/style.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/switch.d.ts +5 -1
- package/frontend/dist/{ui → frontend/src/ui}/switch.js +4 -4
- package/frontend/dist/{ui → frontend/src/ui}/table.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/table.js +6 -6
- package/frontend/dist/{ui → frontend/src/ui}/tabs.d.ts +45 -3
- package/frontend/dist/{ui → frontend/src/ui}/tabs.js +65 -40
- package/frontend/dist/{ui → frontend/src/ui}/text.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/text.js +3 -3
- package/frontend/dist/frontend/src/ui/title.d.ts +91 -0
- package/frontend/dist/frontend/src/ui/title.js +272 -0
- package/frontend/dist/{ui → frontend/src/ui}/view.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/view.js +3 -3
- package/frontend/dist/{volt.d.ts → frontend/src/volt.d.ts} +3 -0
- package/frontend/dist/{volt.js → frontend/src/volt.js} +4 -0
- package/frontend/tools/bundle_d_ts.js +71 -0
- package/frontend/tools/convert_to_jsdoc_input.txt +9452 -0
- package/frontend/tools/convert_to_jsdoc_output.txt +7626 -0
- package/frontend/tools/convert_to_jsdoc_tmp.js +345 -0
- package/package.json +11 -12
- package/backend/dist/cjs/database/collection.d.ts +0 -160
- package/backend/dist/cjs/database/collection.js +0 -842
- package/backend/dist/cjs/database/database.d.ts +0 -121
- package/backend/dist/cjs/database/document.d.ts +0 -131
- package/backend/dist/cjs/database/document.js +0 -224
- package/backend/dist/cjs/database.d.ts +0 -502
- package/backend/dist/cjs/database.js +0 -2248
- package/backend/dist/cjs/logger.d.ts +0 -3
- package/backend/dist/cjs/meta.d.ts +0 -50
- package/backend/dist/cjs/mutex.d.ts +0 -24
- package/backend/dist/cjs/payments/paddle.d.ts +0 -160
- package/backend/dist/cjs/plugins/browser.d.ts +0 -36
- package/backend/dist/cjs/plugins/browser.js +0 -198
- package/backend/dist/cjs/plugins/css.d.ts +0 -11
- package/backend/dist/cjs/plugins/css.js +0 -80
- package/backend/dist/cjs/plugins/mail.d.ts +0 -277
- package/backend/dist/cjs/plugins/mail.js +0 -1370
- package/backend/dist/cjs/plugins/ts/compiler.d.ts +0 -139
- package/backend/dist/cjs/plugins/ts/compiler.js +0 -750
- package/backend/dist/cjs/plugins/ts/preprocessing.d.ts +0 -14
- package/backend/dist/cjs/plugins/ts/preprocessing.js +0 -440
- package/backend/dist/cjs/rate_limit.d.ts +0 -63
- package/backend/dist/cjs/rate_limit.js +0 -348
- package/backend/dist/cjs/request.deprc.d.ts +0 -48
- package/backend/dist/cjs/request.deprc.js +0 -572
- package/backend/dist/cjs/response.deprc.d.ts +0 -55
- package/backend/dist/cjs/response.deprc.js +0 -275
- package/backend/dist/cjs/server.d.ts +0 -342
- package/backend/dist/cjs/splash_screen.d.ts +0 -35
- package/backend/dist/cjs/status.d.ts +0 -61
- package/backend/dist/cjs/stream.d.ts +0 -79
- package/backend/dist/cjs/users.d.ts +0 -111
- package/backend/dist/cjs/users.js +0 -1817
- package/backend/dist/cjs/view.js +0 -352
- package/backend/dist/cjs/vinc.dev.d.ts +0 -3
- package/backend/dist/cjs/vinc.dev.js +0 -7
- package/backend/dist/css/adyen.css +0 -92
- package/backend/dist/css/volt.css +0 -70
- package/backend/dist/esm/database/collection.d.ts +0 -160
- package/backend/dist/esm/database/collection.js +0 -1328
- package/backend/dist/esm/database/database.d.ts +0 -121
- package/backend/dist/esm/database/document.d.ts +0 -131
- package/backend/dist/esm/database/document.js +0 -247
- package/backend/dist/esm/database.d.ts +0 -502
- package/backend/dist/esm/database.js +0 -2423
- package/backend/dist/esm/file_watcher.js +0 -329
- package/backend/dist/esm/logger.d.ts +0 -3
- package/backend/dist/esm/logger.js +0 -11
- package/backend/dist/esm/meta.d.ts +0 -50
- package/backend/dist/esm/mutex.d.ts +0 -24
- package/backend/dist/esm/mutex.js +0 -48
- package/backend/dist/esm/payments/paddle.d.ts +0 -160
- package/backend/dist/esm/plugins/browser.d.ts +0 -36
- package/backend/dist/esm/plugins/browser.js +0 -176
- package/backend/dist/esm/plugins/css.d.ts +0 -11
- package/backend/dist/esm/plugins/css.js +0 -90
- package/backend/dist/esm/plugins/ts/compiler.d.ts +0 -139
- package/backend/dist/esm/plugins/ts/compiler.js +0 -1194
- package/backend/dist/esm/plugins/ts/preprocessing.d.ts +0 -14
- package/backend/dist/esm/plugins/ts/preprocessing.js +0 -726
- package/backend/dist/esm/rate_limit.d.ts +0 -63
- package/backend/dist/esm/rate_limit.js +0 -417
- package/backend/dist/esm/request.deprc.d.ts +0 -48
- package/backend/dist/esm/request.deprc.js +0 -572
- package/backend/dist/esm/response.deprc.d.ts +0 -55
- package/backend/dist/esm/response.deprc.js +0 -275
- package/backend/dist/esm/server.d.ts +0 -342
- package/backend/dist/esm/splash_screen.d.ts +0 -35
- package/backend/dist/esm/status.d.ts +0 -61
- package/backend/dist/esm/status.js +0 -197
- package/backend/dist/esm/stream.d.ts +0 -79
- package/backend/dist/esm/users.d.ts +0 -111
- package/backend/dist/esm/users.js +0 -1935
- package/backend/dist/esm/vinc.dev.d.ts +0 -3
- package/backend/dist/esm/vinc.dev.js +0 -7
- package/frontend/dist/elements/base.d.ts +0 -9889
- package/frontend/dist/elements/module.d.ts +0 -30
- package/frontend/dist/modules/array.d.ts +0 -94
- package/frontend/dist/modules/array.js +0 -634
- package/frontend/dist/modules/auth.d.ts +0 -46
- package/frontend/dist/modules/auth.js +0 -139
- package/frontend/dist/modules/colors.d.ts +0 -1
- package/frontend/dist/modules/colors.js +0 -417
- package/frontend/dist/modules/compression.d.ts +0 -6
- package/frontend/dist/modules/compression.js +0 -999
- package/frontend/dist/modules/cookies.d.ts +0 -18
- package/frontend/dist/modules/cookies.js +0 -167
- package/frontend/dist/modules/date.d.ts +0 -142
- package/frontend/dist/modules/date.js +0 -493
- package/frontend/dist/modules/events.d.ts +0 -8
- package/frontend/dist/modules/events.js +0 -91
- package/frontend/dist/modules/google.d.ts +0 -11
- package/frontend/dist/modules/google.js +0 -54
- package/frontend/dist/modules/meta.d.ts +0 -10
- package/frontend/dist/modules/mutex.d.ts +0 -7
- package/frontend/dist/modules/mutex.js +0 -51
- package/frontend/dist/modules/number.d.ts +0 -16
- package/frontend/dist/modules/number.js +0 -23
- package/frontend/dist/modules/object.d.ts +0 -52
- package/frontend/dist/modules/object.js +0 -383
- package/frontend/dist/modules/scheme.d.ts +0 -227
- package/frontend/dist/modules/scheme.js +0 -531
- package/frontend/dist/modules/settings.d.ts +0 -3
- package/frontend/dist/modules/settings.js +0 -4
- package/frontend/dist/modules/statics.d.ts +0 -5
- package/frontend/dist/modules/string.d.ts +0 -124
- package/frontend/dist/modules/string.js +0 -745
- package/frontend/dist/modules/support.d.ts +0 -19
- package/frontend/dist/modules/support.js +0 -103
- package/frontend/dist/modules/themes.d.ts +0 -8
- package/frontend/dist/modules/themes.js +0 -18
- package/frontend/dist/modules/user.d.ts +0 -59
- package/frontend/dist/modules/user.js +0 -280
- package/frontend/dist/modules/utils.d.ts +0 -87
- package/frontend/dist/modules/utils.js +0 -923
- package/frontend/dist/types/gradient.d.ts +0 -12
- package/frontend/dist/ui/border_button.d.ts +0 -152
- package/frontend/dist/ui/button.d.ts +0 -21
- package/frontend/dist/ui/canvas.d.ts +0 -56
- package/frontend/dist/ui/checkbox.d.ts +0 -52
- package/frontend/dist/ui/frame_modes.d.ts +0 -25
- package/frontend/dist/ui/input.d.ts +0 -241
- package/frontend/dist/ui/loader_button.d.ts +0 -93
- package/frontend/dist/ui/loaders.d.ts +0 -57
- package/frontend/dist/ui/pseudo.d.ts +0 -16
- package/frontend/dist/ui/steps.d.ts +0 -59
- package/frontend/dist/ui/title.d.ts +0 -21
- package/frontend/dist/ui/title.js +0 -121
- package/frontend/examples/dashboard/dashboard.ts +0 -776
- /package/backend/dist/cjs/{cli.d.ts → backend/src/cli.d.ts} +0 -0
- /package/backend/dist/cjs/{file_watcher.d.ts → backend/src/database/document.d.ts} +0 -0
- /package/backend/dist/cjs/{file_watcher.js → backend/src/database/document.js} +0 -0
- /package/backend/dist/cjs/{plugins/pdf.d.ts → backend/src/database/filters/strict_filter_test.d.ts} +0 -0
- /package/backend/dist/{esm/file_watcher.d.ts → cjs/backend/src/database/filters/strict_filter_test_v0.d.ts} +0 -0
- /package/backend/dist/{esm/plugins/pdf.d.ts → cjs/backend/src/database/flatten_test.d.ts} +0 -0
- /package/backend/dist/cjs/{frontend.d.ts → backend/src/frontend.d.ts} +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/communication.d.ts +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/communication.js +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/mail/ui.js +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/pdf.js +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/thread_monitor.d.ts +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/thread_monitor.js +0 -0
- /package/backend/dist/cjs/{vinc.d.ts → backend/src/vinc.d.ts} +0 -0
- /package/backend/dist/cjs/{vinc.js → backend/src/vinc.js} +0 -0
- /package/backend/dist/esm/{cli.d.ts → backend/src/cli.d.ts} +0 -0
- /package/backend/dist/esm/{frontend.d.ts → backend/src/frontend.d.ts} +0 -0
- /package/backend/dist/esm/{plugins → backend/src/plugins}/communication.d.ts +0 -0
- /package/backend/dist/esm/{plugins → backend/src/plugins}/communication.js +0 -0
- /package/backend/dist/esm/{plugins → backend/src/plugins}/thread_monitor.d.ts +0 -0
- /package/backend/dist/esm/{plugins → backend/src/plugins}/thread_monitor.js +0 -0
- /package/backend/dist/esm/{vinc.d.ts → backend/src/vinc.d.ts} +0 -0
- /package/backend/dist/esm/{vinc.js → backend/src/vinc.js} +0 -0
- /package/frontend/dist/{elements → frontend/src/elements}/register_element.d.ts +0 -0
- /package/frontend/dist/{elements → frontend/src/elements}/register_element.js +0 -0
- /package/frontend/dist/{modules → frontend/src/modules}/color.d.ts +0 -0
- /package/frontend/dist/{ui → frontend/src/ui}/ui.d.ts +0 -0
- /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, '&')
|
|
238
|
+
.replace(/</g, '<')
|
|
239
|
+
.replace(/>/g, '>')
|
|
240
|
+
.replace(/"/g, '"')
|
|
241
|
+
.replace(/'/g, '''));
|
|
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
|
+
}
|