@vandenberghinc/volt 1.1.2
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/.vrepo +28 -0
- package/.vscode/tasks.json +87 -0
- package/README.md +67 -0
- package/backend/dist/cjs/blacklist.d.ts +10 -0
- package/backend/dist/cjs/blacklist.js +53 -0
- package/backend/dist/cjs/cli.d.ts +2 -0
- package/backend/dist/cjs/cli.js +263 -0
- package/backend/dist/cjs/database.d.ts +364 -0
- package/backend/dist/cjs/database.js +1962 -0
- package/backend/dist/cjs/endpoint.d.ts +57 -0
- package/backend/dist/cjs/endpoint.js +425 -0
- package/backend/dist/cjs/file_watcher.d.ts +44 -0
- package/backend/dist/cjs/file_watcher.js +348 -0
- package/backend/dist/cjs/frontend.d.ts +13 -0
- package/backend/dist/cjs/frontend.js +30 -0
- package/backend/dist/cjs/image_endpoint.d.ts +24 -0
- package/backend/dist/cjs/image_endpoint.js +210 -0
- package/backend/dist/cjs/logger.d.ts +5 -0
- package/backend/dist/cjs/logger.js +16 -0
- package/backend/dist/cjs/meta.d.ts +50 -0
- package/backend/dist/cjs/meta.js +153 -0
- package/backend/dist/cjs/mutex.d.ts +24 -0
- package/backend/dist/cjs/mutex.js +52 -0
- package/backend/dist/cjs/package.json +1 -0
- package/backend/dist/cjs/payments/paddle.d.ts +161 -0
- package/backend/dist/cjs/payments/paddle.js +2301 -0
- package/backend/dist/cjs/plugins/browser.d.ts +36 -0
- package/backend/dist/cjs/plugins/browser.js +183 -0
- package/backend/dist/cjs/plugins/communication.d.ts +70 -0
- package/backend/dist/cjs/plugins/communication.js +177 -0
- package/backend/dist/cjs/plugins/css.d.ts +10 -0
- package/backend/dist/cjs/plugins/css.js +71 -0
- package/backend/dist/cjs/plugins/mail.d.ts +277 -0
- package/backend/dist/cjs/plugins/mail.js +1419 -0
- package/backend/dist/cjs/plugins/pdf.d.ts +757 -0
- package/backend/dist/cjs/plugins/pdf.js +1694 -0
- package/backend/dist/cjs/plugins/thread_monitor.d.ts +18 -0
- package/backend/dist/cjs/plugins/thread_monitor.js +127 -0
- package/backend/dist/cjs/plugins/ts/compiler.d.ts +132 -0
- package/backend/dist/cjs/plugins/ts/compiler.js +944 -0
- package/backend/dist/cjs/plugins/ts/preprocessing.d.ts +14 -0
- package/backend/dist/cjs/plugins/ts/preprocessing.js +762 -0
- package/backend/dist/cjs/rate_limit.d.ts +65 -0
- package/backend/dist/cjs/rate_limit.js +463 -0
- package/backend/dist/cjs/request.deprc.d.ts +48 -0
- package/backend/dist/cjs/request.deprc.js +572 -0
- package/backend/dist/cjs/response.deprc.d.ts +55 -0
- package/backend/dist/cjs/response.deprc.js +275 -0
- package/backend/dist/cjs/server.d.ts +311 -0
- package/backend/dist/cjs/server.js +3475 -0
- package/backend/dist/cjs/splash_screen.d.ts +35 -0
- package/backend/dist/cjs/splash_screen.js +152 -0
- package/backend/dist/cjs/status.d.ts +60 -0
- package/backend/dist/cjs/status.js +199 -0
- package/backend/dist/cjs/stream.d.ts +75 -0
- package/backend/dist/cjs/stream.js +954 -0
- package/backend/dist/cjs/users.d.ts +111 -0
- package/backend/dist/cjs/users.js +1945 -0
- package/backend/dist/cjs/utils.d.ts +27 -0
- package/backend/dist/cjs/utils.js +329 -0
- package/backend/dist/cjs/view.d.ts +52 -0
- package/backend/dist/cjs/view.js +568 -0
- package/backend/dist/cjs/vinc.d.ts +2 -0
- package/backend/dist/cjs/vinc.dev.d.ts +2 -0
- package/backend/dist/cjs/vinc.dev.js +42 -0
- package/backend/dist/cjs/vinc.js +42 -0
- package/backend/dist/cjs/volt.d.ts +15 -0
- package/backend/dist/cjs/volt.js +64 -0
- package/backend/dist/css/adyen.css +92 -0
- package/backend/dist/css/volt.css +65 -0
- package/backend/dist/esm/blacklist.d.ts +10 -0
- package/backend/dist/esm/blacklist.js +49 -0
- package/backend/dist/esm/cli.d.ts +2 -0
- package/backend/dist/esm/cli.js +228 -0
- package/backend/dist/esm/database.d.ts +364 -0
- package/backend/dist/esm/database.js +1957 -0
- package/backend/dist/esm/endpoint.d.ts +57 -0
- package/backend/dist/esm/endpoint.js +421 -0
- package/backend/dist/esm/file_watcher.d.ts +44 -0
- package/backend/dist/esm/file_watcher.js +313 -0
- package/backend/dist/esm/frontend.d.ts +13 -0
- package/backend/dist/esm/frontend.js +27 -0
- package/backend/dist/esm/image_endpoint.d.ts +24 -0
- package/backend/dist/esm/image_endpoint.js +206 -0
- package/backend/dist/esm/logger.d.ts +5 -0
- package/backend/dist/esm/logger.js +13 -0
- package/backend/dist/esm/meta.d.ts +50 -0
- package/backend/dist/esm/meta.js +149 -0
- package/backend/dist/esm/mutex.d.ts +24 -0
- package/backend/dist/esm/mutex.js +48 -0
- package/backend/dist/esm/payments/paddle.d.ts +161 -0
- package/backend/dist/esm/payments/paddle.js +2261 -0
- package/backend/dist/esm/plugins/browser.d.ts +36 -0
- package/backend/dist/esm/plugins/browser.js +176 -0
- package/backend/dist/esm/plugins/communication.d.ts +70 -0
- package/backend/dist/esm/plugins/communication.js +169 -0
- package/backend/dist/esm/plugins/css.d.ts +10 -0
- package/backend/dist/esm/plugins/css.js +64 -0
- package/backend/dist/esm/plugins/mail.d.ts +277 -0
- package/backend/dist/esm/plugins/mail.js +1403 -0
- package/backend/dist/esm/plugins/pdf.d.ts +757 -0
- package/backend/dist/esm/plugins/pdf.js +1694 -0
- package/backend/dist/esm/plugins/thread_monitor.d.ts +18 -0
- package/backend/dist/esm/plugins/thread_monitor.js +120 -0
- package/backend/dist/esm/plugins/ts/compiler.d.ts +132 -0
- package/backend/dist/esm/plugins/ts/compiler.js +907 -0
- package/backend/dist/esm/plugins/ts/preprocessing.d.ts +14 -0
- package/backend/dist/esm/plugins/ts/preprocessing.js +724 -0
- package/backend/dist/esm/rate_limit.d.ts +65 -0
- package/backend/dist/esm/rate_limit.js +425 -0
- package/backend/dist/esm/request.deprc.d.ts +48 -0
- package/backend/dist/esm/request.deprc.js +572 -0
- package/backend/dist/esm/response.deprc.d.ts +55 -0
- package/backend/dist/esm/response.deprc.js +275 -0
- package/backend/dist/esm/server.d.ts +311 -0
- package/backend/dist/esm/server.js +3435 -0
- package/backend/dist/esm/splash_screen.d.ts +35 -0
- package/backend/dist/esm/splash_screen.js +148 -0
- package/backend/dist/esm/status.d.ts +60 -0
- package/backend/dist/esm/status.js +196 -0
- package/backend/dist/esm/stream.d.ts +75 -0
- package/backend/dist/esm/stream.js +947 -0
- package/backend/dist/esm/users.d.ts +111 -0
- package/backend/dist/esm/users.js +1908 -0
- package/backend/dist/esm/utils.d.ts +27 -0
- package/backend/dist/esm/utils.js +324 -0
- package/backend/dist/esm/view.d.ts +52 -0
- package/backend/dist/esm/view.js +561 -0
- package/backend/dist/esm/vinc.d.ts +2 -0
- package/backend/dist/esm/vinc.dev.d.ts +2 -0
- package/backend/dist/esm/vinc.dev.js +6 -0
- package/backend/dist/esm/vinc.js +6 -0
- package/backend/dist/esm/volt.d.ts +15 -0
- package/backend/dist/esm/volt.js +23 -0
- package/backend/dist/esm-dev/blacklist.d.ts +10 -0
- package/backend/dist/esm-dev/blacklist.js +49 -0
- package/backend/dist/esm-dev/cli.d.ts +2 -0
- package/backend/dist/esm-dev/cli.js +228 -0
- package/backend/dist/esm-dev/database.d.ts +364 -0
- package/backend/dist/esm-dev/database.js +1957 -0
- package/backend/dist/esm-dev/endpoint.d.ts +57 -0
- package/backend/dist/esm-dev/endpoint.js +421 -0
- package/backend/dist/esm-dev/file_watcher.d.ts +44 -0
- package/backend/dist/esm-dev/file_watcher.js +313 -0
- package/backend/dist/esm-dev/frontend.d.ts +13 -0
- package/backend/dist/esm-dev/frontend.js +27 -0
- package/backend/dist/esm-dev/image_endpoint.d.ts +24 -0
- package/backend/dist/esm-dev/image_endpoint.js +206 -0
- package/backend/dist/esm-dev/logger.d.ts +5 -0
- package/backend/dist/esm-dev/logger.js +13 -0
- package/backend/dist/esm-dev/meta.d.ts +50 -0
- package/backend/dist/esm-dev/meta.js +149 -0
- package/backend/dist/esm-dev/mutex.d.ts +24 -0
- package/backend/dist/esm-dev/mutex.js +48 -0
- package/backend/dist/esm-dev/payments/paddle.d.ts +161 -0
- package/backend/dist/esm-dev/payments/paddle.js +2261 -0
- package/backend/dist/esm-dev/plugins/browser.d.ts +36 -0
- package/backend/dist/esm-dev/plugins/browser.js +176 -0
- package/backend/dist/esm-dev/plugins/communication.d.ts +70 -0
- package/backend/dist/esm-dev/plugins/communication.js +169 -0
- package/backend/dist/esm-dev/plugins/css.d.ts +10 -0
- package/backend/dist/esm-dev/plugins/css.js +64 -0
- package/backend/dist/esm-dev/plugins/mail.d.ts +277 -0
- package/backend/dist/esm-dev/plugins/mail.js +1403 -0
- package/backend/dist/esm-dev/plugins/pdf.d.ts +757 -0
- package/backend/dist/esm-dev/plugins/pdf.js +1694 -0
- package/backend/dist/esm-dev/plugins/thread_monitor.d.ts +18 -0
- package/backend/dist/esm-dev/plugins/thread_monitor.js +120 -0
- package/backend/dist/esm-dev/plugins/ts/compiler.d.ts +132 -0
- package/backend/dist/esm-dev/plugins/ts/compiler.js +907 -0
- package/backend/dist/esm-dev/plugins/ts/preprocessing.d.ts +14 -0
- package/backend/dist/esm-dev/plugins/ts/preprocessing.js +724 -0
- package/backend/dist/esm-dev/rate_limit.d.ts +65 -0
- package/backend/dist/esm-dev/rate_limit.js +425 -0
- package/backend/dist/esm-dev/request.deprc.d.ts +48 -0
- package/backend/dist/esm-dev/request.deprc.js +572 -0
- package/backend/dist/esm-dev/response.deprc.d.ts +55 -0
- package/backend/dist/esm-dev/response.deprc.js +275 -0
- package/backend/dist/esm-dev/server.d.ts +311 -0
- package/backend/dist/esm-dev/server.js +3435 -0
- package/backend/dist/esm-dev/splash_screen.d.ts +35 -0
- package/backend/dist/esm-dev/splash_screen.js +148 -0
- package/backend/dist/esm-dev/status.d.ts +60 -0
- package/backend/dist/esm-dev/status.js +196 -0
- package/backend/dist/esm-dev/stream.d.ts +75 -0
- package/backend/dist/esm-dev/stream.js +947 -0
- package/backend/dist/esm-dev/users.d.ts +111 -0
- package/backend/dist/esm-dev/users.js +1908 -0
- package/backend/dist/esm-dev/utils.d.ts +27 -0
- package/backend/dist/esm-dev/utils.js +324 -0
- package/backend/dist/esm-dev/view.d.ts +52 -0
- package/backend/dist/esm-dev/view.js +561 -0
- package/backend/dist/esm-dev/vinc.d.ts +2 -0
- package/backend/dist/esm-dev/vinc.dev.d.ts +2 -0
- package/backend/dist/esm-dev/vinc.dev.js +6 -0
- package/backend/dist/esm-dev/vinc.js +6 -0
- package/backend/dist/esm-dev/volt.d.ts +15 -0
- package/backend/dist/esm-dev/volt.js +23 -0
- package/backend/src/blacklist.ts +69 -0
- package/backend/src/cli.js +245 -0
- package/backend/src/database.ts +2241 -0
- package/backend/src/endpoint.ts +494 -0
- package/backend/src/file_watcher.ts +359 -0
- package/backend/src/frontend.ts +35 -0
- package/backend/src/globals.d.ts +8 -0
- package/backend/src/image_endpoint.ts +258 -0
- package/backend/src/logger.ts +18 -0
- package/backend/src/meta.ts +202 -0
- package/backend/src/mutex.ts +51 -0
- package/backend/src/payments/paddle.ts +2659 -0
- package/backend/src/plugins/browser.ts +188 -0
- package/backend/src/plugins/communication.ts +204 -0
- package/backend/src/plugins/css.ts +84 -0
- package/backend/src/plugins/fonts/Menlo-Bold.ttf +0 -0
- package/backend/src/plugins/fonts/Menlo-Regular.ttf +0 -0
- package/backend/src/plugins/mail.ts +1720 -0
- package/backend/src/plugins/pdf.js +1932 -0
- package/backend/src/plugins/thread_monitor.ts +164 -0
- package/backend/src/plugins/ts/compiler.ts +1242 -0
- package/backend/src/plugins/ts/preprocessing.ts +812 -0
- package/backend/src/rate_limit.ts +503 -0
- package/backend/src/request.deprc.js +626 -0
- package/backend/src/response.deprc.js +354 -0
- package/backend/src/server.ts +4149 -0
- package/backend/src/splash_screen.ts +192 -0
- package/backend/src/status.ts +199 -0
- package/backend/src/stream.ts +1070 -0
- package/backend/src/users.ts +2077 -0
- package/backend/src/utils.ts +359 -0
- package/backend/src/view.ts +655 -0
- package/backend/src/vinc.dev.js +6 -0
- package/backend/src/vinc.ts +6 -0
- package/backend/src/volt.js +25 -0
- package/backend/tsconfig.cjs.json +29 -0
- package/backend/tsconfig.esm.dev.json +34 -0
- package/backend/tsconfig.esm.json +30 -0
- package/backend/tsconfig.json +2 -0
- package/frontend/compile.js +436 -0
- package/frontend/dist/elements/base.d.ts +9891 -0
- package/frontend/dist/elements/base.js +8818 -0
- package/frontend/dist/elements/module.d.ts +16 -0
- package/frontend/dist/elements/module.js +178 -0
- package/frontend/dist/modules/array.d.ts +37 -0
- package/frontend/dist/modules/array.js +284 -0
- package/frontend/dist/modules/auth.d.ts +45 -0
- package/frontend/dist/modules/auth.js +138 -0
- package/frontend/dist/modules/colors.d.ts +26 -0
- package/frontend/dist/modules/colors.js +340 -0
- package/frontend/dist/modules/compression.d.ts +6 -0
- package/frontend/dist/modules/compression.js +999 -0
- package/frontend/dist/modules/cookies.d.ts +17 -0
- package/frontend/dist/modules/cookies.js +166 -0
- package/frontend/dist/modules/date.d.ts +142 -0
- package/frontend/dist/modules/date.js +493 -0
- package/frontend/dist/modules/events.d.ts +7 -0
- package/frontend/dist/modules/events.js +90 -0
- package/frontend/dist/modules/google.d.ts +10 -0
- package/frontend/dist/modules/google.js +53 -0
- package/frontend/dist/modules/meta.d.ts +9 -0
- package/frontend/dist/modules/meta.js +45 -0
- package/frontend/dist/modules/mutex.d.ts +8 -0
- package/frontend/dist/modules/mutex.js +52 -0
- package/frontend/dist/modules/number.d.ts +12 -0
- package/frontend/dist/modules/number.js +8 -0
- package/frontend/dist/modules/object.d.ts +50 -0
- package/frontend/dist/modules/object.js +147 -0
- package/frontend/dist/modules/paddle.d.ts +1403 -0
- package/frontend/dist/modules/paddle.js +2641 -0
- package/frontend/dist/modules/scheme.d.ts +207 -0
- package/frontend/dist/modules/scheme.js +649 -0
- package/frontend/dist/modules/settings.d.ts +3 -0
- package/frontend/dist/modules/settings.js +4 -0
- package/frontend/dist/modules/statics.d.ts +4 -0
- package/frontend/dist/modules/statics.js +45 -0
- package/frontend/dist/modules/string.d.ts +163 -0
- package/frontend/dist/modules/string.js +291 -0
- package/frontend/dist/modules/support.d.ts +18 -0
- package/frontend/dist/modules/support.js +102 -0
- package/frontend/dist/modules/themes.d.ts +8 -0
- package/frontend/dist/modules/themes.js +17 -0
- package/frontend/dist/modules/user.d.ts +58 -0
- package/frontend/dist/modules/user.js +279 -0
- package/frontend/dist/modules/utils.d.ts +58 -0
- package/frontend/dist/modules/utils.js +1159 -0
- package/frontend/dist/types/gradient.d.ts +12 -0
- package/frontend/dist/types/gradient.js +79 -0
- package/frontend/dist/ui/border_button.d.ts +177 -0
- package/frontend/dist/ui/border_button.js +235 -0
- package/frontend/dist/ui/button.d.ts +42 -0
- package/frontend/dist/ui/button.js +114 -0
- package/frontend/dist/ui/canvas.d.ts +56 -0
- package/frontend/dist/ui/canvas.js +411 -0
- package/frontend/dist/ui/checkbox.d.ts +72 -0
- package/frontend/dist/ui/checkbox.js +277 -0
- package/frontend/dist/ui/code.d.ts +232 -0
- package/frontend/dist/ui/code.js +977 -0
- package/frontend/dist/ui/color.d.ts +1 -0
- package/frontend/dist/ui/color.js +110 -0
- package/frontend/dist/ui/context_menu.d.ts +30 -0
- package/frontend/dist/ui/context_menu.js +211 -0
- package/frontend/dist/ui/css.d.ts +10 -0
- package/frontend/dist/ui/css.js +44 -0
- package/frontend/dist/ui/divider.d.ts +18 -0
- package/frontend/dist/ui/divider.js +82 -0
- package/frontend/dist/ui/dropdown.d.ts +115 -0
- package/frontend/dist/ui/dropdown.js +446 -0
- package/frontend/dist/ui/for_each.d.ts +38 -0
- package/frontend/dist/ui/for_each.js +97 -0
- package/frontend/dist/ui/form.d.ts +25 -0
- package/frontend/dist/ui/form.js +227 -0
- package/frontend/dist/ui/frame_modes.d.ts +28 -0
- package/frontend/dist/ui/frame_modes.js +116 -0
- package/frontend/dist/ui/google_map.d.ts +31 -0
- package/frontend/dist/ui/google_map.js +111 -0
- package/frontend/dist/ui/gradient.d.ts +24 -0
- package/frontend/dist/ui/gradient.js +115 -0
- package/frontend/dist/ui/image.d.ts +138 -0
- package/frontend/dist/ui/image.js +570 -0
- package/frontend/dist/ui/input.d.ts +316 -0
- package/frontend/dist/ui/input.js +1187 -0
- package/frontend/dist/ui/link.d.ts +39 -0
- package/frontend/dist/ui/link.js +146 -0
- package/frontend/dist/ui/list.d.ts +33 -0
- package/frontend/dist/ui/list.js +161 -0
- package/frontend/dist/ui/loader_button.d.ts +108 -0
- package/frontend/dist/ui/loader_button.js +207 -0
- package/frontend/dist/ui/loaders.d.ts +60 -0
- package/frontend/dist/ui/loaders.js +150 -0
- package/frontend/dist/ui/popup.d.ts +84 -0
- package/frontend/dist/ui/popup.js +331 -0
- package/frontend/dist/ui/pseudo.d.ts +16 -0
- package/frontend/dist/ui/pseudo.js +81 -0
- package/frontend/dist/ui/scroller.d.ts +131 -0
- package/frontend/dist/ui/scroller.js +1251 -0
- package/frontend/dist/ui/slider.d.ts +35 -0
- package/frontend/dist/ui/slider.js +203 -0
- package/frontend/dist/ui/spacer.d.ts +20 -0
- package/frontend/dist/ui/spacer.js +83 -0
- package/frontend/dist/ui/span.d.ts +11 -0
- package/frontend/dist/ui/span.js +75 -0
- package/frontend/dist/ui/stack.d.ts +123 -0
- package/frontend/dist/ui/stack.js +344 -0
- package/frontend/dist/ui/steps.d.ts +72 -0
- package/frontend/dist/ui/steps.js +306 -0
- package/frontend/dist/ui/style.d.ts +12 -0
- package/frontend/dist/ui/style.js +78 -0
- package/frontend/dist/ui/switch.d.ts +44 -0
- package/frontend/dist/ui/switch.js +280 -0
- package/frontend/dist/ui/table.d.ts +118 -0
- package/frontend/dist/ui/table.js +411 -0
- package/frontend/dist/ui/tabs.d.ts +85 -0
- package/frontend/dist/ui/tabs.js +392 -0
- package/frontend/dist/ui/text.d.ts +19 -0
- package/frontend/dist/ui/text.js +88 -0
- package/frontend/dist/ui/theme.d.ts +25 -0
- package/frontend/dist/ui/theme.js +237 -0
- package/frontend/dist/ui/title.d.ts +36 -0
- package/frontend/dist/ui/title.js +127 -0
- package/frontend/dist/ui/ui.d.ts +38 -0
- package/frontend/dist/ui/ui.js +41 -0
- package/frontend/dist/ui/view.d.ts +25 -0
- package/frontend/dist/ui/view.js +93 -0
- package/frontend/dist/volt.d.ts +22 -0
- package/frontend/dist/volt.js +27 -0
- package/frontend/exports.json +1340 -0
- package/frontend/src/css/adyen.css +92 -0
- package/frontend/src/css/volt.css +65 -0
- package/frontend/src/elements/base.ts +16790 -0
- package/frontend/src/elements/module.ts +184 -0
- package/frontend/src/elements/types.d.ts +155 -0
- package/frontend/src/modules/array.ts +366 -0
- package/frontend/src/modules/auth.ts +188 -0
- package/frontend/src/modules/colors.ts +449 -0
- package/frontend/src/modules/compression.ts +67 -0
- package/frontend/src/modules/cookies.ts +182 -0
- package/frontend/src/modules/date.js +535 -0
- package/frontend/src/modules/date.ts +583 -0
- package/frontend/src/modules/events.ts +96 -0
- package/frontend/src/modules/google.ts +60 -0
- package/frontend/src/modules/meta.ts +59 -0
- package/frontend/src/modules/mutex.ts +59 -0
- package/frontend/src/modules/number.ts +20 -0
- package/frontend/src/modules/object.ts +212 -0
- package/frontend/src/modules/paddle.ts +2990 -0
- package/frontend/src/modules/scheme.ts +740 -0
- package/frontend/src/modules/settings.ts +5 -0
- package/frontend/src/modules/statics.ts +47 -0
- package/frontend/src/modules/string.ts +500 -0
- package/frontend/src/modules/support.ts +118 -0
- package/frontend/src/modules/themes.ts +24 -0
- package/frontend/src/modules/user.ts +321 -0
- package/frontend/src/modules/utils.ts +1260 -0
- package/frontend/src/static/admin/admin.png +0 -0
- package/frontend/src/static/admin/password.webp +0 -0
- package/frontend/src/static/icons/copy.webp +0 -0
- package/frontend/src/static/payments/arrow.long.webp +0 -0
- package/frontend/src/static/payments/arrow.long2.webp +0 -0
- package/frontend/src/static/payments/cancelled.webp +0 -0
- package/frontend/src/static/payments/check.sign.webp +0 -0
- package/frontend/src/static/payments/check.webp +0 -0
- package/frontend/src/static/payments/close.webp +0 -0
- package/frontend/src/static/payments/error.webp +0 -0
- package/frontend/src/static/payments/exclamation.webp +0 -0
- package/frontend/src/static/payments/minus.webp +0 -0
- package/frontend/src/static/payments/party.webp +0 -0
- package/frontend/src/static/payments/plus.webp +0 -0
- package/frontend/src/static/payments/shopping_cart.webp +0 -0
- package/frontend/src/static/payments/trash.webp +0 -0
- package/frontend/src/types/global.d.ts +4 -0
- package/frontend/src/types/gradient.ts +87 -0
- package/frontend/src/ui/any_element.d.ts +5 -0
- package/frontend/src/ui/border_button.ts +320 -0
- package/frontend/src/ui/button.ts +62 -0
- package/frontend/src/ui/canvas.ts +431 -0
- package/frontend/src/ui/checkbox.ts +284 -0
- package/frontend/src/ui/code.ts +1049 -0
- package/frontend/src/ui/color.ts +117 -0
- package/frontend/src/ui/context_menu.ts +194 -0
- package/frontend/src/ui/css.ts +57 -0
- package/frontend/src/ui/divider.ts +28 -0
- package/frontend/src/ui/dropdown.ts +503 -0
- package/frontend/src/ui/for_each.ts +71 -0
- package/frontend/src/ui/form.ts +208 -0
- package/frontend/src/ui/frame_modes.ts +140 -0
- package/frontend/src/ui/google_map.ts +70 -0
- package/frontend/src/ui/gradient.ts +73 -0
- package/frontend/src/ui/image.ts +587 -0
- package/frontend/src/ui/input.ts +1284 -0
- package/frontend/src/ui/link.ts +77 -0
- package/frontend/src/ui/list.ts +88 -0
- package/frontend/src/ui/loader_button.ts +192 -0
- package/frontend/src/ui/loaders.ts +126 -0
- package/frontend/src/ui/popup.ts +370 -0
- package/frontend/src/ui/pseudo.ts +33 -0
- package/frontend/src/ui/scroller.ts +1324 -0
- package/frontend/src/ui/slider.ts +215 -0
- package/frontend/src/ui/spacer.ts +29 -0
- package/frontend/src/ui/span.ts +23 -0
- package/frontend/src/ui/stack.ts +238 -0
- package/frontend/src/ui/steps.ts +334 -0
- package/frontend/src/ui/style.ts +26 -0
- package/frontend/src/ui/switch.ts +286 -0
- package/frontend/src/ui/table.ts +323 -0
- package/frontend/src/ui/tabs.ts +441 -0
- package/frontend/src/ui/text.ts +38 -0
- package/frontend/src/ui/theme.ts +279 -0
- package/frontend/src/ui/title.ts +64 -0
- package/frontend/src/ui/ui.ts +47 -0
- package/frontend/src/ui/view.ts +44 -0
- package/frontend/src/volt.ts +31 -0
- package/package.json +58 -0
|
@@ -0,0 +1,944 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Author: Daan van den Bergh
|
|
4
|
+
* Copyright: © 2024 - 2024 Daan van den Bergh.
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.compile = compile;
|
|
41
|
+
exports.bundle = bundle;
|
|
42
|
+
const pathlib = __importStar(require("path"));
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const ts = __importStar(require("typescript"));
|
|
45
|
+
const esbuild = __importStar(require("esbuild"));
|
|
46
|
+
// import { rollup, RollupOptions, OutputOptions, Plugin } from 'rollup';
|
|
47
|
+
// import { nodeResolve } from '@rollup/plugin-node-resolve';
|
|
48
|
+
// import * as commonjs from '@rollup/plugin-commonjs';
|
|
49
|
+
// import { terser } from 'rollup-plugin-terser';
|
|
50
|
+
// Get the directory name of the current module
|
|
51
|
+
const url_1 = require("url");
|
|
52
|
+
const path_1 = require("path");
|
|
53
|
+
var __dirname = typeof __dirname !== 'undefined' ? __dirname : (0, path_1.dirname)((0, url_1.fileURLToPath)(new URL('./package.json', import.meta.url)));
|
|
54
|
+
// Local imports.
|
|
55
|
+
const _vinc_1 = require("../../vinc.js");
|
|
56
|
+
const Preprocessing = __importStar(require("./preprocessing.js"));
|
|
57
|
+
// Resolve path wrapper.
|
|
58
|
+
function resolve_path(path) {
|
|
59
|
+
path = pathlib.resolve(path);
|
|
60
|
+
if (process.platform === "darwin" && path.startsWith("/private/tmp/")) {
|
|
61
|
+
path = path.slice(8);
|
|
62
|
+
}
|
|
63
|
+
return path;
|
|
64
|
+
}
|
|
65
|
+
[];
|
|
66
|
+
// Format a typescript error.
|
|
67
|
+
function format_ts_error(diagnostic) {
|
|
68
|
+
let line, column;
|
|
69
|
+
if (diagnostic.file && diagnostic.start !== undefined) {
|
|
70
|
+
const res = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
|
71
|
+
if (res.line !== undefined) {
|
|
72
|
+
line = res.line + 1;
|
|
73
|
+
}
|
|
74
|
+
if (res.character !== undefined) {
|
|
75
|
+
column = res.character + 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
data: ts.formatDiagnosticsWithColorAndContext([diagnostic], {
|
|
80
|
+
getCurrentDirectory: () => process.cwd(),
|
|
81
|
+
getCanonicalFileName: (file_name) => pathlib.resolve(file_name),
|
|
82
|
+
getNewLine: () => '\n',
|
|
83
|
+
}),
|
|
84
|
+
file_name: diagnostic.file === undefined ? undefined : pathlib.resolve(diagnostic.file.resolvedPath),
|
|
85
|
+
line,
|
|
86
|
+
column,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/*
|
|
90
|
+
Compiles TypeScript files after preprocessing them to replace non-string
|
|
91
|
+
literals with units and hex color codes into string literals.
|
|
92
|
+
|
|
93
|
+
## Macros
|
|
94
|
+
|
|
95
|
+
Macros are supported in the following code style:
|
|
96
|
+
```
|
|
97
|
+
#macro MyName values
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Function macros using templates are also supported.
|
|
101
|
+
```
|
|
102
|
+
#macro MyMacro(myfuncname) myfuncname(first_name: string) { return `Hello ${first_name}!`}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
*/
|
|
106
|
+
async function compile(options) {
|
|
107
|
+
// Extract options with defaults.
|
|
108
|
+
let { entry_paths = [], include = [], exclude = [], output, error_limit = 25, compiler_opts = {}, preprocess, exact_files = false, file_by_file = false, watch, extract_exports, debug_file, templates = undefined, } = options;
|
|
109
|
+
if (entry_paths.length > 0) {
|
|
110
|
+
include = include.concat(entry_paths);
|
|
111
|
+
}
|
|
112
|
+
if (watch === undefined || typeof watch === "boolean") {
|
|
113
|
+
watch = {
|
|
114
|
+
enabled: watch ?? false,
|
|
115
|
+
log_level: 1,
|
|
116
|
+
on_change: undefined,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const { enabled: watch_enabled = false, log_level: watch_log_level = 1, } = watch;
|
|
120
|
+
// Initialize compile result.
|
|
121
|
+
let import_order;
|
|
122
|
+
const compile_result = {
|
|
123
|
+
inputs: [],
|
|
124
|
+
outputs: [],
|
|
125
|
+
errors: [],
|
|
126
|
+
debug(_watch = false) {
|
|
127
|
+
// Sort the errors based on import order.
|
|
128
|
+
if (import_order !== undefined) {
|
|
129
|
+
this.errors.sort((a, b) => {
|
|
130
|
+
// Get import order for both files
|
|
131
|
+
const orderA = a.file_name ? (import_order.get(a.file_name) ?? Number.MAX_SAFE_INTEGER) : Number.MAX_SAFE_INTEGER;
|
|
132
|
+
const orderB = b.file_name ? (import_order.get(b.file_name) ?? Number.MAX_SAFE_INTEGER) : Number.MAX_SAFE_INTEGER;
|
|
133
|
+
// First sort by import order
|
|
134
|
+
if (orderA !== orderB) {
|
|
135
|
+
return orderA - orderB;
|
|
136
|
+
}
|
|
137
|
+
return 0;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
// Dump errors up to the error limit.
|
|
141
|
+
let last_file, dumped = 0, file_names = new Set();
|
|
142
|
+
for (let i = 0; i < this.errors.length; i++) {
|
|
143
|
+
if (debug_file == null && !file_by_file) {
|
|
144
|
+
console.error(this.errors[i].data);
|
|
145
|
+
++dumped;
|
|
146
|
+
}
|
|
147
|
+
else if (debug_file !== undefined && this.errors[i].file_name?.toLowerCase() === debug_file.toLowerCase()) {
|
|
148
|
+
console.error(this.errors[i].data);
|
|
149
|
+
++dumped;
|
|
150
|
+
}
|
|
151
|
+
else if (file_by_file) {
|
|
152
|
+
if (last_file !== undefined && this.errors[i].file_name !== last_file) {
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
last_file = this.errors[i].file_name;
|
|
156
|
+
console.error(this.errors[i].data);
|
|
157
|
+
++dumped;
|
|
158
|
+
}
|
|
159
|
+
if (this.errors[i].file_name != null && !file_names.has(this.errors[i].file_name.toLowerCase())) {
|
|
160
|
+
file_names.add(this.errors[i].file_name.toLowerCase());
|
|
161
|
+
}
|
|
162
|
+
if (dumped >= error_limit) {
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (this.errors.length > 0 && debug_file !== undefined && dumped === 0) {
|
|
167
|
+
console.error(`${_vinc_1.vlib.Color.yellow("warning")}: Did not find any files matching "${debug_file}". Valid file names: ${JSON.stringify(Array.from(file_names), null, 4)}`);
|
|
168
|
+
}
|
|
169
|
+
// Map errors per file.
|
|
170
|
+
if (this.errors.length > 0) {
|
|
171
|
+
const error_map = {};
|
|
172
|
+
for (const err of this.errors) {
|
|
173
|
+
if (err.file_name) {
|
|
174
|
+
if (error_map[err.file_name] === undefined) {
|
|
175
|
+
error_map[err.file_name] = 0;
|
|
176
|
+
}
|
|
177
|
+
error_map[err.file_name] += 1;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
console.log(`\nErrors per file:`);
|
|
181
|
+
for (const [file_path, error_count] of Object.entries(error_map)) {
|
|
182
|
+
console.log(` - ${file_path}: ${error_count}`);
|
|
183
|
+
}
|
|
184
|
+
console.log("");
|
|
185
|
+
}
|
|
186
|
+
// Inform about error truncation.
|
|
187
|
+
// if (_watch === false) {
|
|
188
|
+
if (error_limit != null && this.errors.length > error_limit) {
|
|
189
|
+
console.log(`Displayed the first ${error_limit} errors out of ${this.errors.length}.`);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
console.log(`Encountered ${this.errors.length} errors.`);
|
|
193
|
+
}
|
|
194
|
+
if (this.outputs.length > 0) {
|
|
195
|
+
console.log(`Compiled ${this.outputs.length} output files.`);
|
|
196
|
+
}
|
|
197
|
+
// }
|
|
198
|
+
},
|
|
199
|
+
exports: {},
|
|
200
|
+
};
|
|
201
|
+
let diagnostics = [];
|
|
202
|
+
const processed_files = {};
|
|
203
|
+
// Process entry paths if exact_files is true.
|
|
204
|
+
if (exact_files) {
|
|
205
|
+
for (let i = 0; i < include.length; i++) {
|
|
206
|
+
const current_path = new _vinc_1.vlib.Path(include[i]);
|
|
207
|
+
if (!current_path.exists()) {
|
|
208
|
+
compile_result.errors.push({
|
|
209
|
+
data: `Entry path "${current_path.str()}" does not exist.`
|
|
210
|
+
});
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
include[i] = current_path.abs().str();
|
|
214
|
+
}
|
|
215
|
+
if (compile_result.errors.length > 0) {
|
|
216
|
+
return compile_result;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// Build in-memory tsconfig options.
|
|
220
|
+
const tsconfig = {
|
|
221
|
+
compilerOptions: {
|
|
222
|
+
...compiler_opts,
|
|
223
|
+
outDir: output,
|
|
224
|
+
declaration: compiler_opts.declaration === true ? true : false,
|
|
225
|
+
declarationDir: compiler_opts.declaration === true ? output : undefined,
|
|
226
|
+
// Add other default compiler options as needed
|
|
227
|
+
},
|
|
228
|
+
include: include,
|
|
229
|
+
exclude: exclude,
|
|
230
|
+
};
|
|
231
|
+
if (watch.enabled) {
|
|
232
|
+
tsconfig.compilerOptions.incremental = true;
|
|
233
|
+
tsconfig.compilerOptions.tsBuildInfoFile = output + "/.tsbuildinfo";
|
|
234
|
+
}
|
|
235
|
+
tsconfig.compilerOptions.paths ??= {};
|
|
236
|
+
tsconfig.compilerOptions.paths["volt"] = [new _vinc_1.vlib.Path(__dirname + "../../../../../../frontend/dist/volt.js").abs().str()];
|
|
237
|
+
tsconfig.compilerOptions.paths["volt/*"] = [new _vinc_1.vlib.Path(__dirname + "../../../../../../frontend/dist/").abs().str() + "/*"];
|
|
238
|
+
// let now = Date.now();
|
|
239
|
+
// Parse the in-memory tsconfig options.
|
|
240
|
+
const parsed_tsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, "./");
|
|
241
|
+
if (parsed_tsconfig.errors.length > 0) {
|
|
242
|
+
parsed_tsconfig.errors.forEach(error => {
|
|
243
|
+
const message = ts.flattenDiagnosticMessageText(error.messageText, '\n');
|
|
244
|
+
compile_result.errors.push({
|
|
245
|
+
data: `TSConfig error: ${message}`,
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
return compile_result;
|
|
249
|
+
}
|
|
250
|
+
// console.log("Init jsonconfig:", Date.now() - now); now = Date.now()
|
|
251
|
+
// Watch Mode
|
|
252
|
+
if (watch_enabled) {
|
|
253
|
+
// Define a virtual tsconfig file name
|
|
254
|
+
const virtual_tsconfig_path = pathlib.resolve("tsconfig.virtual.json");
|
|
255
|
+
// Create a custom system that intercepts readFile and fileExists
|
|
256
|
+
const written_files = new Map();
|
|
257
|
+
const custom_ts_sys = {
|
|
258
|
+
...ts.sys,
|
|
259
|
+
fileExists: (file_name) => {
|
|
260
|
+
const resolved_file = pathlib.resolve(file_name);
|
|
261
|
+
if (resolved_file === virtual_tsconfig_path) {
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
if (exact_files && !entry_paths.includes(resolved_file)) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
return fs.existsSync(resolved_file);
|
|
268
|
+
},
|
|
269
|
+
readFile: (file_name) => {
|
|
270
|
+
// console.log("Read file", file_name)
|
|
271
|
+
const resolved_file = pathlib.resolve(file_name);
|
|
272
|
+
// Config path.
|
|
273
|
+
if (resolved_file === virtual_tsconfig_path) {
|
|
274
|
+
return JSON.stringify(tsconfig, null, 4);
|
|
275
|
+
}
|
|
276
|
+
// Exact files.
|
|
277
|
+
if (exact_files && !entry_paths.includes(resolved_file)) {
|
|
278
|
+
return undefined;
|
|
279
|
+
}
|
|
280
|
+
// Check existance.
|
|
281
|
+
if (!fs.existsSync(resolved_file)) {
|
|
282
|
+
return undefined;
|
|
283
|
+
}
|
|
284
|
+
// Load data.
|
|
285
|
+
let source_code = fs.readFileSync(resolved_file, 'utf-8');
|
|
286
|
+
// Apply preprocessing
|
|
287
|
+
if (!resolved_file.endsWith(".d.ts") && (resolved_file.endsWith(".js") || resolved_file.endsWith(".ts"))) {
|
|
288
|
+
source_code = Preprocessing.preprocess(resolved_file, source_code, { macros: true, templates });
|
|
289
|
+
// Apply user preprocessing.
|
|
290
|
+
if (preprocess) {
|
|
291
|
+
const preprocessed = preprocess(resolved_file, source_code);
|
|
292
|
+
if (preprocessed instanceof Promise) {
|
|
293
|
+
throw new Error('Asynchronous preprocessing is not supported in watch mode.');
|
|
294
|
+
}
|
|
295
|
+
if (typeof preprocessed === "string") {
|
|
296
|
+
source_code = preprocessed;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// Response.
|
|
301
|
+
return source_code;
|
|
302
|
+
},
|
|
303
|
+
writeFile: (file_name, data, write_byte_order_mark, on_error, source_files) => {
|
|
304
|
+
file_name = pathlib.resolve(file_name);
|
|
305
|
+
// Check if file has changed.
|
|
306
|
+
if (written_files.has(file_name) && written_files.get(file_name) === data) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
// Logs.
|
|
310
|
+
if (watch_log_level >= 1) {
|
|
311
|
+
console.log(`ts-watcher: ${_vinc_1.vlib.Color.purple("message")} Writing out file ${file_name}.`);
|
|
312
|
+
}
|
|
313
|
+
// Write the file using the original writeFile method
|
|
314
|
+
ts.sys.writeFile(file_name, data, write_byte_order_mark);
|
|
315
|
+
written_files.set(file_name, data);
|
|
316
|
+
// Call the on_change callback after writing the file
|
|
317
|
+
if (typeof watch === "object" && typeof watch.on_change === "function" && file_name.endsWith(".js")) {
|
|
318
|
+
watch.on_change(resolve_path(file_name));
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
};
|
|
322
|
+
// Create WatchCompilerHost using createWatchCompilerHost
|
|
323
|
+
const host = ts.createWatchCompilerHost(virtual_tsconfig_path, // Use virtual tsconfig path
|
|
324
|
+
undefined, // Override compiler options if needed
|
|
325
|
+
custom_ts_sys, ts.createEmitAndSemanticDiagnosticsBuilderProgram,
|
|
326
|
+
// ts.createSemanticDiagnosticsBuilderProgram,
|
|
327
|
+
// reportDiagnostic callback
|
|
328
|
+
(diagnostic) => {
|
|
329
|
+
compile_result.errors.push(format_ts_error(diagnostic));
|
|
330
|
+
},
|
|
331
|
+
// reportWatchStatusChanged callback
|
|
332
|
+
(diagnostic) => {
|
|
333
|
+
// Show errors on message `Found X errors. Watching for file changes.`
|
|
334
|
+
if (diagnostic.code === 6194) {
|
|
335
|
+
if (import_order === undefined) {
|
|
336
|
+
const interval = setInterval(() => {
|
|
337
|
+
if (import_order !== undefined) {
|
|
338
|
+
compile_result.debug();
|
|
339
|
+
compile_result.errors = [];
|
|
340
|
+
clearInterval(interval);
|
|
341
|
+
}
|
|
342
|
+
}, 100);
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
if (compile_result.errors.length > 0) {
|
|
346
|
+
compile_result.debug();
|
|
347
|
+
}
|
|
348
|
+
compile_result.errors = [];
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
// Skip.
|
|
352
|
+
if (watch_log_level <= 0 && diagnostic.category === 3) {
|
|
353
|
+
// skip messages (3)
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
const message = ts.formatDiagnosticsWithColorAndContext([diagnostic], {
|
|
357
|
+
getCurrentDirectory: () => process.cwd(),
|
|
358
|
+
getCanonicalFileName: (file_name) => pathlib.resolve(file_name),
|
|
359
|
+
getNewLine: () => '\n',
|
|
360
|
+
});
|
|
361
|
+
console.log("ts-watcher:", message.trimEnd());
|
|
362
|
+
});
|
|
363
|
+
// Create the WatchProgram
|
|
364
|
+
const program = ts.createWatchProgram(host);
|
|
365
|
+
// Define the import order.
|
|
366
|
+
import_order = new Map();
|
|
367
|
+
const source_files = program.getProgram().getSourceFiles();
|
|
368
|
+
for (let i = 0; i < source_files.length; i++) {
|
|
369
|
+
const source = source_files[i];
|
|
370
|
+
const file_name = pathlib.resolve(source.fileName).toLowerCase();
|
|
371
|
+
if (!import_order.has(file_name)) {
|
|
372
|
+
import_order.set(file_name, i);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
// Assign the stop function to terminate the watch program
|
|
376
|
+
compile_result.stop = () => {
|
|
377
|
+
program.close();
|
|
378
|
+
console.log("ts-watcher:", "Stopped watching.");
|
|
379
|
+
};
|
|
380
|
+
return compile_result;
|
|
381
|
+
}
|
|
382
|
+
// Non-watch mode continues as before
|
|
383
|
+
// Create the initial TypeScript program to get all source files.
|
|
384
|
+
const initial_program = ts.createProgram({
|
|
385
|
+
rootNames: parsed_tsconfig.fileNames,
|
|
386
|
+
options: parsed_tsconfig.options,
|
|
387
|
+
});
|
|
388
|
+
const program_source_files = initial_program.getSourceFiles();
|
|
389
|
+
const all_source_files = program_source_files.filter(sf => !sf.isDeclarationFile);
|
|
390
|
+
// Check empty source files.
|
|
391
|
+
if (all_source_files.length === 0) {
|
|
392
|
+
compile_result.errors.push({ data: "No source files were found. Please check your entry paths." });
|
|
393
|
+
return compile_result;
|
|
394
|
+
}
|
|
395
|
+
// console.log({
|
|
396
|
+
// entry_paths,
|
|
397
|
+
// // all_source_files,
|
|
398
|
+
// // compiler_opts: parsed_tsconfig.options,
|
|
399
|
+
// file_names: parsed_tsconfig.fileNames,
|
|
400
|
+
// })
|
|
401
|
+
// Get extracted exports.
|
|
402
|
+
if (extract_exports) {
|
|
403
|
+
// Obtain the TypeChecker
|
|
404
|
+
const checker = initial_program.getTypeChecker();
|
|
405
|
+
// Iterate through all source files in the program
|
|
406
|
+
for (let i = 0; i < program_source_files.length; i++) {
|
|
407
|
+
const source = program_source_files[i];
|
|
408
|
+
// Skip declaration files (.d.ts) if not needed
|
|
409
|
+
if (source.isDeclarationFile)
|
|
410
|
+
continue;
|
|
411
|
+
// Get the module symbol for the source file
|
|
412
|
+
const symbol = checker.getSymbolAtLocation(source);
|
|
413
|
+
// Get exports of the module
|
|
414
|
+
if (symbol) {
|
|
415
|
+
if (compile_result.exports[source.fileName] === undefined) {
|
|
416
|
+
compile_result.exports[source.fileName] = [];
|
|
417
|
+
}
|
|
418
|
+
const list = compile_result.exports[source.fileName];
|
|
419
|
+
const exports = checker.getExportsOfModule(symbol);
|
|
420
|
+
for (const exp of exports) {
|
|
421
|
+
const name = exp.getName();
|
|
422
|
+
if (name !== "default") {
|
|
423
|
+
list.push(name);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
// console.log("Get source files:", Date.now() - now); now = Date.now()
|
|
430
|
+
// Preprocess each source file.
|
|
431
|
+
for (let i = 0; i < all_source_files.length; i++) {
|
|
432
|
+
const source_file = all_source_files[i];
|
|
433
|
+
const file_name = pathlib.resolve(source_file.fileName);
|
|
434
|
+
// Add input file to compile_result.
|
|
435
|
+
compile_result.inputs.push(file_name);
|
|
436
|
+
// Skip files if exact_files is true and the file is not an entry file.
|
|
437
|
+
if (exact_files && !entry_paths.includes(file_name)) {
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
// Apply default preprocessing.
|
|
441
|
+
processed_files[file_name] = Preprocessing.preprocess(file_name, source_file.text, { macros: true, templates });
|
|
442
|
+
// Apply user-defined preprocessing.
|
|
443
|
+
if (preprocess) {
|
|
444
|
+
let res = preprocess(file_name, processed_files[file_name]);
|
|
445
|
+
if (res instanceof Promise) {
|
|
446
|
+
res = await res;
|
|
447
|
+
}
|
|
448
|
+
if (typeof res === "string") {
|
|
449
|
+
processed_files[file_name] = res;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
// console.log("Processed files:", Object.keys(processed_files))
|
|
454
|
+
// console.log("Apply preprocessing:", Date.now() - now); now = Date.now()
|
|
455
|
+
// Create a custom CompilerHost for non-watch mode
|
|
456
|
+
const file_exists_cache = new Map();
|
|
457
|
+
const compiler_host = {
|
|
458
|
+
fileExists: (file_name) => {
|
|
459
|
+
// console.log("fileExists", file_name)
|
|
460
|
+
const resolved_file = pathlib.resolve(file_name);
|
|
461
|
+
if (processed_files[resolved_file]) {
|
|
462
|
+
return true;
|
|
463
|
+
}
|
|
464
|
+
else if (file_exists_cache.has(resolved_file)) {
|
|
465
|
+
return file_exists_cache.get(resolved_file);
|
|
466
|
+
}
|
|
467
|
+
const res = fs.existsSync(resolved_file);
|
|
468
|
+
file_exists_cache.set(resolved_file, res);
|
|
469
|
+
return res;
|
|
470
|
+
},
|
|
471
|
+
directoryExists: ts.sys.directoryExists,
|
|
472
|
+
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
473
|
+
getDirectories: ts.sys.getDirectories,
|
|
474
|
+
getCanonicalFileName: ts.sys.useCaseSensitiveFileNames
|
|
475
|
+
? (file_name) => file_name
|
|
476
|
+
: (file_name) => file_name.toLowerCase(),
|
|
477
|
+
getNewLine: () => ts.sys.newLine,
|
|
478
|
+
getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options),
|
|
479
|
+
getSourceFile: (file_name, language_version, on_error) => {
|
|
480
|
+
const resolved_file = pathlib.resolve(file_name);
|
|
481
|
+
if (processed_files[resolved_file]) {
|
|
482
|
+
// if (resolved_file.endsWith("home.ts") || resolved_file.endsWith("home.js")) console.log("getSourceFile1", resolved_file)
|
|
483
|
+
return ts.createSourceFile(resolved_file, processed_files[resolved_file], language_version, true);
|
|
484
|
+
}
|
|
485
|
+
if (exact_files && !entry_paths.includes(resolved_file)) {
|
|
486
|
+
// if (resolved_file.endsWith("home.ts") || resolved_file.endsWith("home.js")) console.log("getSourceFile2", resolved_file)
|
|
487
|
+
return undefined; // skip by exact files.
|
|
488
|
+
}
|
|
489
|
+
if (!fs.existsSync(resolved_file)) {
|
|
490
|
+
// if (resolved_file.endsWith("home.ts") || resolved_file.endsWith("home.js")) console.log("getSourceFile3", resolved_file)
|
|
491
|
+
if (on_error)
|
|
492
|
+
on_error(`File not found: ${resolved_file}`);
|
|
493
|
+
return undefined;
|
|
494
|
+
}
|
|
495
|
+
// if (resolved_file.endsWith("home.ts") || resolved_file.endsWith("home.js")) console.log("getSourceFile4", resolved_file)
|
|
496
|
+
const source_code = fs.readFileSync(resolved_file, 'utf-8');
|
|
497
|
+
return ts.createSourceFile(resolved_file, source_code, language_version, true);
|
|
498
|
+
},
|
|
499
|
+
readFile: (file_name) => {
|
|
500
|
+
// console.log("readFile", file_name)
|
|
501
|
+
const resolved_file = pathlib.resolve(file_name);
|
|
502
|
+
// console.log("readFile2", resolved_file)
|
|
503
|
+
if (processed_files[resolved_file]) {
|
|
504
|
+
// console.log("readFile3", resolved_file)
|
|
505
|
+
return processed_files[resolved_file];
|
|
506
|
+
}
|
|
507
|
+
if (exact_files && !entry_paths.includes(resolved_file)) {
|
|
508
|
+
// console.log("readFile4", resolved_file)
|
|
509
|
+
return undefined; // skip by exact files.
|
|
510
|
+
}
|
|
511
|
+
// console.log("readFile5", resolved_file)
|
|
512
|
+
return fs.readFileSync(resolved_file, 'utf-8');
|
|
513
|
+
},
|
|
514
|
+
useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
|
|
515
|
+
writeFile: (file_name, data, write_byte_order_mark, on_error, source_files) => {
|
|
516
|
+
compile_result.outputs.push(file_name);
|
|
517
|
+
if (file_name.endsWith('.js')) {
|
|
518
|
+
const paths = parsed_tsconfig.options.paths || {};
|
|
519
|
+
const baseUrl = parsed_tsconfig.options.baseUrl || './';
|
|
520
|
+
const transformed = data.replace(/(import|export)(\s+(?:\*\s+as\s+[^,}\s]+|\{[^}]*\}|[^,}\s]+)(?:\s*,\s*(?:\*\s+as\s+[^,}\s]+|\{[^}]*\}|[^,}\s]+))*\s+from\s+["'])([^"']+)(["'])/g, (match, importType, importDetails, importPath, quote) => {
|
|
521
|
+
for (const [alias, targets] of Object.entries(paths)) {
|
|
522
|
+
if (importPath === alias || importPath.startsWith(alias + '/')) {
|
|
523
|
+
const target = targets[0];
|
|
524
|
+
const from = pathlib.dirname(file_name);
|
|
525
|
+
const to = pathlib.resolve(pathlib.dirname(baseUrl), target);
|
|
526
|
+
const relativePath = pathlib.relative(from, to);
|
|
527
|
+
const finalPath = relativePath.startsWith('.') ?
|
|
528
|
+
relativePath :
|
|
529
|
+
'./' + relativePath;
|
|
530
|
+
return `${importType}${importDetails}${finalPath}${quote}`;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
return match;
|
|
534
|
+
});
|
|
535
|
+
ts.sys.writeFile(file_name, transformed, write_byte_order_mark);
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
ts.sys.writeFile(file_name, data, write_byte_order_mark);
|
|
539
|
+
}
|
|
540
|
+
},
|
|
541
|
+
resolveModuleNames: (moduleNames, containingFile) => {
|
|
542
|
+
const matchPath = createMatchPath(parsed_tsconfig.options.paths || {});
|
|
543
|
+
return moduleNames.map(moduleName => {
|
|
544
|
+
// First try to resolve using paths
|
|
545
|
+
const matchedPath = matchPath(moduleName);
|
|
546
|
+
// console.log(moduleName, matchedPath)
|
|
547
|
+
if (matchedPath) {
|
|
548
|
+
return {
|
|
549
|
+
resolvedFileName: matchedPath,
|
|
550
|
+
isExternalLibraryImport: false,
|
|
551
|
+
extension: pathlib.extname(matchedPath)
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
// Fall back to classic resolution
|
|
555
|
+
const result = ts.resolveModuleName(moduleName, containingFile, parsed_tsconfig.options, {
|
|
556
|
+
fileExists: compiler_host.fileExists,
|
|
557
|
+
readFile: compiler_host.readFile,
|
|
558
|
+
});
|
|
559
|
+
return result.resolvedModule;
|
|
560
|
+
});
|
|
561
|
+
},
|
|
562
|
+
};
|
|
563
|
+
function createMatchPath(patterns) {
|
|
564
|
+
const matchers = Object.entries(patterns).map(([prefix, paths]) => ({
|
|
565
|
+
prefix: prefix.endsWith('/*') ? prefix.slice(0, -2) : prefix,
|
|
566
|
+
paths: paths.map(p => p.endsWith('/*') ? p.slice(0, -2) : p)
|
|
567
|
+
}));
|
|
568
|
+
return (moduleName) => {
|
|
569
|
+
for (const { prefix, paths } of matchers) {
|
|
570
|
+
if (moduleName.startsWith(prefix)) {
|
|
571
|
+
const suffix = moduleName.slice(prefix.length);
|
|
572
|
+
for (const path of paths) {
|
|
573
|
+
const fullPath = path + suffix;
|
|
574
|
+
// Try with .ts, .tsx, and as-is
|
|
575
|
+
for (const ext of ['.ts', '.tsx', '', '.js']) {
|
|
576
|
+
const attemptPath = fullPath + ext;
|
|
577
|
+
if (ts.sys.fileExists(attemptPath)) {
|
|
578
|
+
return attemptPath;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
return undefined;
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
// Create the TypeScript program
|
|
588
|
+
const program = ts.createProgram({
|
|
589
|
+
rootNames: parsed_tsconfig.fileNames,
|
|
590
|
+
options: parsed_tsconfig.options,
|
|
591
|
+
host: compiler_host,
|
|
592
|
+
});
|
|
593
|
+
// Emit the compiled JavaScript
|
|
594
|
+
const emit_result = program.emit();
|
|
595
|
+
// Collect and display diagnostics
|
|
596
|
+
diagnostics = ts.getPreEmitDiagnostics(program).concat(emit_result.diagnostics);
|
|
597
|
+
// Process diagnostics.
|
|
598
|
+
for (let i = 0; i < diagnostics.length; i++) {
|
|
599
|
+
// if (debug_file == null || diagnostics[i]?.file?.fileName === debug_file) {
|
|
600
|
+
compile_result.errors.push(format_ts_error(diagnostics[i]));
|
|
601
|
+
// }
|
|
602
|
+
}
|
|
603
|
+
// console.log("Compile:", Date.now() - now); now = Date.now()
|
|
604
|
+
// Response.
|
|
605
|
+
return compile_result;
|
|
606
|
+
}
|
|
607
|
+
;
|
|
608
|
+
// Format an esbuild warning / error.
|
|
609
|
+
const format_esbuild_warning_error = (warning) => {
|
|
610
|
+
let output;
|
|
611
|
+
if (warning.location) {
|
|
612
|
+
const trimmed_line = warning.location.lineText.trimStart();
|
|
613
|
+
const removed_start_indent = warning.location.lineText.length - trimmed_line.length;
|
|
614
|
+
output =
|
|
615
|
+
`${_vinc_1.vlib.Color.cyan(warning.location.file)}:${_vinc_1.vlib.Color.yellow(warning.location.line)}:${_vinc_1.vlib.Color.yellow(warning.location.column)}` +
|
|
616
|
+
` - ${_vinc_1.vlib.Color.yellow("warning")} [esbuild${warning.id === "" ? "" : `-${warning.id}`}]: ${warning.text}\n` +
|
|
617
|
+
"\n" + _vinc_1.vlib.Colors.bright_bg.white + _vinc_1.vlib.Colors.black + warning.location.line + _vinc_1.vlib.Colors.end + " " + trimmed_line +
|
|
618
|
+
"\n" + _vinc_1.vlib.Colors.bright_bg.white + _vinc_1.vlib.Colors.black + " ".repeat(warning.location.line.toString().length) + _vinc_1.vlib.Colors.end +
|
|
619
|
+
" ".repeat(4 + warning.location.column - removed_start_indent) + _vinc_1.vlib.Color.red("~".repeat(warning.location.length));
|
|
620
|
+
}
|
|
621
|
+
else {
|
|
622
|
+
output = `${_vinc_1.vlib.Color.yellow("warning")} [esbuild${warning.id === "" ? "" : `-${warning.id}`}]: ${warning.text}`;
|
|
623
|
+
}
|
|
624
|
+
if (Array.isArray(warning.notes)) {
|
|
625
|
+
for (const note of warning.notes) {
|
|
626
|
+
if (note.location) {
|
|
627
|
+
const trimmed_line = note.location.lineText.trimStart();
|
|
628
|
+
const removed_start_indent = note.location.lineText.length - trimmed_line.length;
|
|
629
|
+
output +=
|
|
630
|
+
`\n ${_vinc_1.vlib.Color.cyan(note.location.file)}:${_vinc_1.vlib.Color.yellow(note.location.line)}:${_vinc_1.vlib.Color.yellow(note.location.column)}` +
|
|
631
|
+
` - ${_vinc_1.vlib.Color.gray("note")}: ${note.text}\n` +
|
|
632
|
+
"\n" + _vinc_1.vlib.Colors.bright_bg.white + _vinc_1.vlib.Colors.black + note.location.line + _vinc_1.vlib.Colors.end + " " + trimmed_line +
|
|
633
|
+
"\n" + _vinc_1.vlib.Colors.bright_bg.white + _vinc_1.vlib.Colors.black + " ".repeat(note.location.line.toString().length) + _vinc_1.vlib.Colors.end +
|
|
634
|
+
" ".repeat(8 + note.location.column - removed_start_indent) + _vinc_1.vlib.Color.red("~".repeat(note.location.length));
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
output +=
|
|
638
|
+
`\n ${_vinc_1.vlib.Color.gray("note")}: ${note.text}`;
|
|
639
|
+
}
|
|
640
|
+
if (note.suggestion) {
|
|
641
|
+
console.error("@todo handle suggestion:" + note.suggestion + " note: " + JSON.stringify(note, null, 4));
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
return {
|
|
646
|
+
data: output,
|
|
647
|
+
file_name: warning.location?.file,
|
|
648
|
+
line: warning.location?.line,
|
|
649
|
+
column: warning.location?.column,
|
|
650
|
+
};
|
|
651
|
+
};
|
|
652
|
+
/*
|
|
653
|
+
* Bundles transpiled JavaScript files using esbuild.
|
|
654
|
+
*/
|
|
655
|
+
async function bundle(options) {
|
|
656
|
+
// console.log(">>> BUNDLE", options)
|
|
657
|
+
let { entry_paths = [], include = [], output = undefined, platform = 'browser', format = 'iife', target = 'es2021', minify = false, sourcemap = false, // 'inline'
|
|
658
|
+
error_limit = 25, extract_inputs = false, tree_shaking = undefined, debug = false, bundler = "esbuild", opts = {},
|
|
659
|
+
// bundler = "rollup",
|
|
660
|
+
} = options;
|
|
661
|
+
if (entry_paths.length > 0) {
|
|
662
|
+
include = include.concat(entry_paths);
|
|
663
|
+
}
|
|
664
|
+
const errors = [];
|
|
665
|
+
let bundled_code = undefined;
|
|
666
|
+
let bundled_source_map = undefined;
|
|
667
|
+
let inputs = [];
|
|
668
|
+
// Bundle using esbuild.
|
|
669
|
+
if (bundler === "esbuild") {
|
|
670
|
+
try {
|
|
671
|
+
const result = await esbuild.build({
|
|
672
|
+
entryPoints: include,
|
|
673
|
+
bundle: true,
|
|
674
|
+
platform: platform,
|
|
675
|
+
format: format,
|
|
676
|
+
target: target,
|
|
677
|
+
minify: minify,
|
|
678
|
+
sourcemap,
|
|
679
|
+
write: false,
|
|
680
|
+
metafile: extract_inputs,
|
|
681
|
+
logLevel: typeof debug === "boolean" ? (debug ? 'debug' : 'silent') : debug,
|
|
682
|
+
treeShaking: tree_shaking,
|
|
683
|
+
// logLevel: 'silent',
|
|
684
|
+
// outdir: "/",
|
|
685
|
+
// minifyWhitespace: false,
|
|
686
|
+
// minifySyntax: false,
|
|
687
|
+
// minifyIdentifiers: false,
|
|
688
|
+
...opts,
|
|
689
|
+
});
|
|
690
|
+
if (result.errors.length > 0) {
|
|
691
|
+
for (const error of result.errors) {
|
|
692
|
+
errors.push(format_esbuild_warning_error(error));
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
if (result.warnings.length > 0) {
|
|
696
|
+
for (const warning of result.warnings) {
|
|
697
|
+
errors.push(format_esbuild_warning_error(warning));
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
// Set output paths.
|
|
701
|
+
if (extract_inputs && result.metafile?.inputs != null && typeof result.metafile?.inputs === "object") {
|
|
702
|
+
inputs = Object.keys(result.metafile?.inputs).map(resolve_path);
|
|
703
|
+
}
|
|
704
|
+
// Process output files.
|
|
705
|
+
if (result.outputFiles && result.outputFiles.length > 0) {
|
|
706
|
+
// Concatenate all output files
|
|
707
|
+
bundled_code = result.outputFiles
|
|
708
|
+
.filter(file => file.path === "<stdout>" || (file.path.endsWith('.js') && !file.path.endsWith('.d.js')))
|
|
709
|
+
.map(file => file.text)
|
|
710
|
+
.join('\n');
|
|
711
|
+
if (sourcemap) {
|
|
712
|
+
const source_map_file = result.outputFiles.find(file => file.path.endsWith('.map'));
|
|
713
|
+
if (source_map_file) {
|
|
714
|
+
bundled_source_map = source_map_file.text;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
else {
|
|
719
|
+
errors.push({ data: "No output files were generated during bundling." });
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
catch (err) {
|
|
723
|
+
let processed = false;
|
|
724
|
+
if (Array.isArray(err.errors) && err.errors.length > 0) {
|
|
725
|
+
for (const error of err.errors) {
|
|
726
|
+
errors.push(format_esbuild_warning_error(error));
|
|
727
|
+
}
|
|
728
|
+
processed = true;
|
|
729
|
+
}
|
|
730
|
+
if (Array.isArray(err.warnings) && err.warnings.length > 0) {
|
|
731
|
+
for (const warning of err.warnings) {
|
|
732
|
+
errors.push(format_esbuild_warning_error(warning));
|
|
733
|
+
}
|
|
734
|
+
processed = true;
|
|
735
|
+
}
|
|
736
|
+
if (!processed) {
|
|
737
|
+
errors.push({ data: err.message || String(err) });
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
// Bundle using rollup.
|
|
742
|
+
else {
|
|
743
|
+
try {
|
|
744
|
+
throw new Error("Rollup is deprecated since it is currently out of use.");
|
|
745
|
+
// // Determine if minification is needed
|
|
746
|
+
// const plugins: Plugin[] = [
|
|
747
|
+
// nodeResolve({
|
|
748
|
+
// browser: platform === 'browser',
|
|
749
|
+
// preferBuiltins: platform === 'node',
|
|
750
|
+
// }),
|
|
751
|
+
// // commonjs(),
|
|
752
|
+
// ];
|
|
753
|
+
// if (minify) {
|
|
754
|
+
// plugins.push(terser());
|
|
755
|
+
// }
|
|
756
|
+
// const input_set: Set<string> = new Set();
|
|
757
|
+
// // if (extract_inputs) {
|
|
758
|
+
// // plugins.push(
|
|
759
|
+
// // // Custom plugin to collect all imported files
|
|
760
|
+
// // {
|
|
761
|
+
// // name: 'collect-input-files',
|
|
762
|
+
// // resolveId(source, importer) {
|
|
763
|
+
// // return null; // Let Rollup handle module resolution
|
|
764
|
+
// // },
|
|
765
|
+
// // load(id) {
|
|
766
|
+
// // console.log("ADD:",id)
|
|
767
|
+
// // input_set.add(id); // Add each module to the input_set set
|
|
768
|
+
// // return null; // Let Rollup handle loading the module
|
|
769
|
+
// // }
|
|
770
|
+
// // }
|
|
771
|
+
// // )
|
|
772
|
+
// // }
|
|
773
|
+
// const rollup_input_options: RollupOptions = {
|
|
774
|
+
// input: include,
|
|
775
|
+
// plugins: plugins,
|
|
776
|
+
// treeshake: tree_shaking !== undefined ? tree_shaking : true,
|
|
777
|
+
// // Suppress Rollup warnings if not in debug mode
|
|
778
|
+
// onwarn: (warning, warn) => {
|
|
779
|
+
// if (debug) {
|
|
780
|
+
// warn(warning);
|
|
781
|
+
// }
|
|
782
|
+
// // Otherwise, suppress warnings
|
|
783
|
+
// },
|
|
784
|
+
// };
|
|
785
|
+
// const bundle = await rollup(rollup_input_options);
|
|
786
|
+
// const rollup_output_options: OutputOptions = {
|
|
787
|
+
// format: format,
|
|
788
|
+
// sourcemap: sourcemap !== false,
|
|
789
|
+
// // Name is required for 'iife' format
|
|
790
|
+
// ...(format === 'iife' ? { name: 'Bundle' } : {}),
|
|
791
|
+
// // Generate inline source maps if specified
|
|
792
|
+
// ...(sourcemap === 'inline' ? { sourcemap: 'inline' } : {}),
|
|
793
|
+
// ...(sourcemap === 'external' ? { sourcemap: true } : {}),
|
|
794
|
+
// ...(sourcemap === 'linked' ? { sourcemap: true, sourcemapPathTransform: (relativePath: string) => `./${relativePath}` } : {}),
|
|
795
|
+
// // Additional Rollup output options can be added here
|
|
796
|
+
// };
|
|
797
|
+
// const { output } = await bundle.generate(rollup_output_options);
|
|
798
|
+
// bundled_code = '';
|
|
799
|
+
// bundled_source_map = '';
|
|
800
|
+
// // @todo remove as any
|
|
801
|
+
// for (const item of output as any) {
|
|
802
|
+
// if (item.type === 'chunk') {
|
|
803
|
+
// bundled_code += item.code;
|
|
804
|
+
// if (item.map) {
|
|
805
|
+
// bundled_source_map += item.map.toString();
|
|
806
|
+
// }
|
|
807
|
+
// if (extract_inputs) {
|
|
808
|
+
// for (const name of Object.keys(item.modules)) {
|
|
809
|
+
// if (!input_set.has(name)) {
|
|
810
|
+
// input_set.add(name);
|
|
811
|
+
// }
|
|
812
|
+
// }
|
|
813
|
+
// }
|
|
814
|
+
// }
|
|
815
|
+
// }
|
|
816
|
+
// inputs = extract_inputs ? Array.from(input_set) : []
|
|
817
|
+
}
|
|
818
|
+
catch (err) {
|
|
819
|
+
errors.push({ data: err.message ?? String(err) });
|
|
820
|
+
// throw new Error(`Rollup bundling failed: ${err.message || err}`);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
// Write to file.
|
|
824
|
+
if (typeof output === "string") {
|
|
825
|
+
await new _vinc_1.vlib.Path(output).save(bundled_code ?? "");
|
|
826
|
+
}
|
|
827
|
+
return {
|
|
828
|
+
code: bundled_code,
|
|
829
|
+
source_map: bundled_source_map,
|
|
830
|
+
errors,
|
|
831
|
+
inputs,
|
|
832
|
+
debug() {
|
|
833
|
+
for (let i = 0; i < Math.min(error_limit, errors.length); i++) {
|
|
834
|
+
console.error(errors[i].data);
|
|
835
|
+
}
|
|
836
|
+
if (error_limit != null && errors.length > error_limit) {
|
|
837
|
+
console.log(`Displayed the first ${error_limit} errors out of ${errors.length}.`);
|
|
838
|
+
}
|
|
839
|
+
else {
|
|
840
|
+
console.log(`Encountered ${errors.length} errors.`);
|
|
841
|
+
}
|
|
842
|
+
if (typeof bundled_code === "string" && bundled_code !== "") {
|
|
843
|
+
console.log(`Generated code of ${_vinc_1.vlib.Utils.format_bytes(Buffer.byteLength(bundled_code, 'utf8'))}`);
|
|
844
|
+
}
|
|
845
|
+
},
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
;
|
|
849
|
+
/*
|
|
850
|
+
// Collect imports.
|
|
851
|
+
export async function collect_exports(file_path: string, data: string) {
|
|
852
|
+
const exported_names = new Set<string>();
|
|
853
|
+
|
|
854
|
+
const source_file = ts.createSourceFile(
|
|
855
|
+
file_path,
|
|
856
|
+
data,
|
|
857
|
+
ts.ScriptTarget.ESNext,
|
|
858
|
+
true
|
|
859
|
+
);
|
|
860
|
+
|
|
861
|
+
function visit_node(node: ts.Node) {
|
|
862
|
+
// Handle named export declarations: export { Utils, Another };
|
|
863
|
+
if (ts.isExportDeclaration(node)) {
|
|
864
|
+
if (node.exportClause && ts.isNamedExports(node.exportClause)) {
|
|
865
|
+
node.exportClause.elements.forEach(element => {
|
|
866
|
+
const n = element.name.getText();
|
|
867
|
+
if (!exported_names.has(n)) {
|
|
868
|
+
exported_names.add(n);
|
|
869
|
+
}
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
// Handle export specifiers: export { Utils } from './utils';
|
|
874
|
+
else if (ts.isExportSpecifier(node)) {
|
|
875
|
+
const n = node.name.getText();
|
|
876
|
+
if (!exported_names.has(n)) {
|
|
877
|
+
exported_names.add(n);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
// Handle exported declarations: export function foo() {}, export const bar = 1, etc.
|
|
881
|
+
else if (ts.isExportAssignment(node)) {
|
|
882
|
+
// Handle default exports if needed
|
|
883
|
+
const expr = node.expression;
|
|
884
|
+
if (ts.isIdentifier(expr)) {
|
|
885
|
+
const n = expr.getText();
|
|
886
|
+
if (!exported_names.has(n)) {
|
|
887
|
+
exported_names.add(n);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
// Handle other export assignment expressions if necessary
|
|
891
|
+
}
|
|
892
|
+
else {
|
|
893
|
+
const modifiers = ts.getModifiers(node as any);
|
|
894
|
+
if (modifiers && modifiers.some(mod => mod.kind === ts.SyntaxKind.ExportKeyword)) {
|
|
895
|
+
if (ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node) || ts.isEnumDeclaration(node)) {
|
|
896
|
+
if (node.name) {
|
|
897
|
+
const n = node.name.getText();
|
|
898
|
+
if (!exported_names.has(n)) {
|
|
899
|
+
exported_names.add(n);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
else if (ts.isVariableStatement(node)) {
|
|
904
|
+
node.declarationList.declarations.forEach(declaration => {
|
|
905
|
+
const n = declaration.name.getText();
|
|
906
|
+
if (!exported_names.has(n)) {
|
|
907
|
+
exported_names.add(n);
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
ts.forEachChild(node, visit_node);
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
visit_node(source_file);
|
|
918
|
+
|
|
919
|
+
return Array.from(exported_names);
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
// Get all included soruce files.
|
|
923
|
+
export async function get_source_files(entry_paths: string[]): Promise<string[]> {
|
|
924
|
+
const result = await esbuild.build({
|
|
925
|
+
entryPoints: entry_paths,
|
|
926
|
+
bundle: true,
|
|
927
|
+
metafile: true,
|
|
928
|
+
write: false, // Keep outputs in memory
|
|
929
|
+
});
|
|
930
|
+
if (!result.metafile) {
|
|
931
|
+
throw new Error('Metafile not generated');
|
|
932
|
+
}
|
|
933
|
+
return Object.keys(result.metafile.inputs);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
*/
|
|
937
|
+
// Exports.
|
|
938
|
+
exports.default = {
|
|
939
|
+
compile,
|
|
940
|
+
bundle,
|
|
941
|
+
preprocessing: Preprocessing,
|
|
942
|
+
// collect_exports,
|
|
943
|
+
// get_source_files,
|
|
944
|
+
};
|