@vitnode/core 1.2.0-canary.52 → 1.2.0-canary.53
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/config/next.config.ts +3 -3
- package/dist/scripts/get-config.d.ts +2 -2
- package/dist/scripts/get-config.d.ts.map +1 -1
- package/dist/scripts/plugin.d.ts.map +1 -1
- package/dist/scripts/prepare-database.d.ts.map +1 -1
- package/dist/scripts/prepare-plugins-files.d.ts.map +1 -1
- package/dist/scripts/scripts.js +4 -4
- package/dist/scripts/shared/file-utils.d.ts.map +1 -1
- package/dist/src/api/adapters/email/nodemailer.d.ts +1 -1
- package/dist/src/api/adapters/email/nodemailer.js +3 -3
- package/dist/src/api/adapters/email/resend.d.ts +1 -1
- package/dist/src/api/adapters/email/resend.js +2 -2
- package/dist/src/api/adapters/sso/discord.d.ts +1 -1
- package/dist/src/api/adapters/sso/discord.d.ts.map +1 -1
- package/dist/src/api/adapters/sso/discord.js +21 -21
- package/dist/src/api/adapters/sso/facebook.d.ts +1 -1
- package/dist/src/api/adapters/sso/facebook.d.ts.map +1 -1
- package/dist/src/api/adapters/sso/facebook.js +23 -23
- package/dist/src/api/adapters/sso/google.d.ts +1 -1
- package/dist/src/api/adapters/sso/google.d.ts.map +1 -1
- package/dist/src/api/adapters/sso/google.js +21 -21
- package/dist/src/api/config.d.ts +3 -3
- package/dist/src/api/config.d.ts.map +1 -1
- package/dist/src/api/config.js +11 -11
- package/dist/src/api/lib/check-plugin-id.js +8 -8
- package/dist/src/api/lib/logger-middleware.d.ts +1 -1
- package/dist/src/api/lib/logger-middleware.js +9 -9
- package/dist/src/api/lib/module.d.ts +2 -2
- package/dist/src/api/lib/plugin.d.ts +2 -2
- package/dist/src/api/lib/plugin.d.ts.map +1 -1
- package/dist/src/api/lib/route.d.ts +2 -2
- package/dist/src/api/lib/route.d.ts.map +1 -1
- package/dist/src/api/lib/route.js +1 -1
- package/dist/src/api/lib/with-pagination.d.ts +7 -7
- package/dist/src/api/lib/with-pagination.d.ts.map +1 -1
- package/dist/src/api/lib/with-pagination.js +37 -24
- package/dist/src/api/middlewares/captcha.middleware.d.ts +1 -1
- package/dist/src/api/middlewares/captcha.middleware.d.ts.map +1 -1
- package/dist/src/api/middlewares/captcha.middleware.js +14 -13
- package/dist/src/api/middlewares/global.middleware.d.ts +12 -12
- package/dist/src/api/middlewares/global.middleware.d.ts.map +1 -1
- package/dist/src/api/middlewares/global.middleware.js +29 -28
- package/dist/src/api/middlewares/rate-limiter.middleware.d.ts +3 -3
- package/dist/src/api/middlewares/rate-limiter.middleware.d.ts.map +1 -1
- package/dist/src/api/middlewares/rate-limiter.middleware.js +4 -4
- package/dist/src/api/models/device.d.ts +1 -1
- package/dist/src/api/models/device.d.ts.map +1 -1
- package/dist/src/api/models/device.js +13 -13
- package/dist/src/api/models/email.d.ts +15 -15
- package/dist/src/api/models/email.d.ts.map +1 -1
- package/dist/src/api/models/email.js +11 -10
- package/dist/src/api/models/password.js +9 -9
- package/dist/src/api/models/session-admin.d.ts +1 -1
- package/dist/src/api/models/session-admin.d.ts.map +1 -1
- package/dist/src/api/models/session-admin.js +19 -19
- package/dist/src/api/models/session.d.ts +1 -1
- package/dist/src/api/models/session.d.ts.map +1 -1
- package/dist/src/api/models/session.js +17 -17
- package/dist/src/api/models/sso.d.ts +1 -1
- package/dist/src/api/models/sso.d.ts.map +1 -1
- package/dist/src/api/models/sso.js +22 -25
- package/dist/src/api/models/user/get-user-by-id.d.ts +1 -1
- package/dist/src/api/models/user/get-user-by-id.d.ts.map +1 -1
- package/dist/src/api/models/user/get-user-by-id.js +1 -1
- package/dist/src/api/models/user/sign-in-with-passwords.d.ts +1 -1
- package/dist/src/api/models/user/sign-in-with-passwords.d.ts.map +1 -1
- package/dist/src/api/models/user/sign-in-with-passwords.js +1 -1
- package/dist/src/api/models/user/sign-up.d.ts +1 -1
- package/dist/src/api/models/user/sign-up.d.ts.map +1 -1
- package/dist/src/api/models/user/sign-up.js +11 -12
- package/dist/src/api/models/user.d.ts.map +1 -1
- package/dist/src/api/modules/admin/admin.module.d.ts +3 -3
- package/dist/src/api/modules/admin/admin.module.js +1 -1
- package/dist/src/api/modules/admin/debug/debug.admin.module.d.ts +1 -1
- package/dist/src/api/modules/admin/debug/debug.admin.module.js +1 -1
- package/dist/src/api/modules/admin/debug/routes/logs.route.d.ts +2 -2
- package/dist/src/api/modules/admin/debug/routes/logs.route.js +16 -16
- package/dist/src/api/modules/admin/routes/session.route.d.ts +2 -2
- package/dist/src/api/modules/admin/routes/session.route.js +7 -7
- package/dist/src/api/modules/admin/users/routes/list.route.d.ts +2 -2
- package/dist/src/api/modules/admin/users/routes/list.route.js +12 -12
- package/dist/src/api/modules/admin/users/routes/users.route.d.ts +2 -2
- package/dist/src/api/modules/admin/users/routes/users.route.js +15 -15
- package/dist/src/api/modules/admin/users/users.admin.module.d.ts +1 -1
- package/dist/src/api/modules/admin/users/users.admin.module.js +1 -1
- package/dist/src/api/modules/middleware/middleware.module.d.ts +1 -1
- package/dist/src/api/modules/middleware/middleware.module.js +1 -1
- package/dist/src/api/modules/middleware/route.d.ts +2 -2
- package/dist/src/api/modules/middleware/route.js +12 -12
- package/dist/src/api/modules/users/routes/change-password.route.d.ts +2 -2
- package/dist/src/api/modules/users/routes/change-password.route.js +13 -13
- package/dist/src/api/modules/users/routes/reset-passowrd.route.d.ts +2 -2
- package/dist/src/api/modules/users/routes/reset-passowrd.route.js +17 -17
- package/dist/src/api/modules/users/routes/session.route.d.ts +2 -2
- package/dist/src/api/modules/users/routes/session.route.js +6 -6
- package/dist/src/api/modules/users/routes/sign-in.route.d.ts +3 -3
- package/dist/src/api/modules/users/routes/sign-in.route.js +10 -10
- package/dist/src/api/modules/users/routes/sign-out.route.d.ts +2 -2
- package/dist/src/api/modules/users/routes/sign-out.route.js +7 -7
- package/dist/src/api/modules/users/routes/sign-up.route.d.ts +3 -3
- package/dist/src/api/modules/users/routes/sign-up.route.js +14 -14
- package/dist/src/api/modules/users/routes/test.route.d.ts +3 -3
- package/dist/src/api/modules/users/routes/test.route.js +9 -9
- package/dist/src/api/modules/users/sso/routes/callback.route.d.ts +2 -2
- package/dist/src/api/modules/users/sso/routes/callback.route.js +8 -8
- package/dist/src/api/modules/users/sso/routes/create-url.route.d.ts +2 -2
- package/dist/src/api/modules/users/sso/routes/create-url.route.js +6 -6
- package/dist/src/api/modules/users/sso/sso.module.d.ts +2 -2
- package/dist/src/api/modules/users/sso/sso.module.js +1 -1
- package/dist/src/api/modules/users/users.module.d.ts +12 -12
- package/dist/src/api/modules/users/users.module.js +1 -1
- package/dist/src/app/login/page.d.ts +1 -1
- package/dist/src/app/login/page.js +2 -2
- package/dist/src/app/login/reset-password/page.d.ts +2 -2
- package/dist/src/app/login/reset-password/page.js +2 -2
- package/dist/src/app/register/page.d.ts +1 -1
- package/dist/src/app/register/page.js +2 -2
- package/dist/src/app_admin/core/debug/page.d.ts +1 -1
- package/dist/src/app_admin/core/debug/page.js +8 -8
- package/dist/src/app_admin/core/users/page.d.ts +2 -2
- package/dist/src/app_admin/core/users/page.d.ts.map +1 -1
- package/dist/src/app_admin/core/users/page.js +7 -7
- package/dist/src/components/avatar.d.ts +1 -1
- package/dist/src/components/avatar.js +1 -1
- package/dist/src/components/confirm-action/confirm-action-alert-dialog.d.ts +2 -2
- package/dist/src/components/confirm-action/confirm-action-alert-dialog.js +5 -5
- package/dist/src/components/confirm-action/content.d.ts.map +1 -1
- package/dist/src/components/confirm-action/content.js +3 -4
- package/dist/src/components/date-format.js +8 -8
- package/dist/src/components/form/auto-form.d.ts +16 -16
- package/dist/src/components/form/auto-form.d.ts.map +1 -1
- package/dist/src/components/form/auto-form.js +13 -12
- package/dist/src/components/form/common/desc.js +1 -1
- package/dist/src/components/form/common/label.d.ts +1 -1
- package/dist/src/components/form/common/label.js +1 -1
- package/dist/src/components/form/fields/checkbox.d.ts +2 -2
- package/dist/src/components/form/fields/checkbox.d.ts.map +1 -1
- package/dist/src/components/form/fields/combobox-async.d.ts +3 -3
- package/dist/src/components/form/fields/combobox-async.d.ts.map +1 -1
- package/dist/src/components/form/fields/combobox-async.js +29 -23
- package/dist/src/components/form/fields/combobox.d.ts +3 -3
- package/dist/src/components/form/fields/combobox.d.ts.map +1 -1
- package/dist/src/components/form/fields/combobox.js +6 -7
- package/dist/src/components/form/fields/input.d.ts +2 -2
- package/dist/src/components/form/fields/input.d.ts.map +1 -1
- package/dist/src/components/form/fields/input.js +2 -2
- package/dist/src/components/form/fields/radio-group.d.ts +3 -3
- package/dist/src/components/form/fields/radio-group.d.ts.map +1 -1
- package/dist/src/components/form/fields/radio-group.js +0 -1
- package/dist/src/components/form/fields/select.d.ts +3 -3
- package/dist/src/components/form/fields/select.d.ts.map +1 -1
- package/dist/src/components/form/fields/select.js +2 -3
- package/dist/src/components/form/fields/switch.d.ts +2 -2
- package/dist/src/components/form/fields/switch.d.ts.map +1 -1
- package/dist/src/components/form/fields/textarea.d.ts +3 -3
- package/dist/src/components/form/fields/textarea.d.ts.map +1 -1
- package/dist/src/components/form/fields/textarea.js +1 -2
- package/dist/src/components/i18n-provider.d.ts +2 -2
- package/dist/src/components/i18n-provider.js +3 -3
- package/dist/src/components/logo-vitnode.d.ts.map +1 -1
- package/dist/src/components/logo-vitnode.js +8 -2
- package/dist/src/components/switchers/langs/language-swietcher.d.ts +1 -1
- package/dist/src/components/switchers/langs/language-swietcher.d.ts.map +1 -1
- package/dist/src/components/switchers/langs/language-swietcher.js +3 -3
- package/dist/src/components/switchers/themes/theme-switcher.js +4 -4
- package/dist/src/components/table/content.d.ts +1 -1
- package/dist/src/components/table/content.d.ts.map +1 -1
- package/dist/src/components/table/content.js +5 -5
- package/dist/src/components/table/data-table.d.ts +7 -7
- package/dist/src/components/table/data-table.d.ts.map +1 -1
- package/dist/src/components/table/data-table.js +22 -15
- package/dist/src/components/table/order-table-head.d.ts +4 -4
- package/dist/src/components/table/order-table-head.d.ts.map +1 -1
- package/dist/src/components/table/order-table-head.js +20 -9
- package/dist/src/components/table/pagination.js +19 -19
- package/dist/src/components/ui/accordion.d.ts +2 -2
- package/dist/src/components/ui/accordion.d.ts.map +1 -1
- package/dist/src/components/ui/accordion.js +4 -5
- package/dist/src/components/ui/alert-dialog.d.ts +7 -7
- package/dist/src/components/ui/alert-dialog.d.ts.map +1 -1
- package/dist/src/components/ui/alert-dialog.js +12 -12
- package/dist/src/components/ui/alert.d.ts +5 -5
- package/dist/src/components/ui/alert.d.ts.map +1 -1
- package/dist/src/components/ui/alert.js +6 -7
- package/dist/src/components/ui/badge.d.ts +3 -3
- package/dist/src/components/ui/badge.d.ts.map +1 -1
- package/dist/src/components/ui/badge.js +7 -8
- package/dist/src/components/ui/button-client.d.ts +1 -1
- package/dist/src/components/ui/button-client.js +9 -9
- package/dist/src/components/ui/button.d.ts +8 -8
- package/dist/src/components/ui/button.d.ts.map +1 -1
- package/dist/src/components/ui/button.js +13 -14
- package/dist/src/components/ui/card.d.ts +8 -8
- package/dist/src/components/ui/card.js +7 -7
- package/dist/src/components/ui/checkbox.d.ts +2 -2
- package/dist/src/components/ui/checkbox.d.ts.map +1 -1
- package/dist/src/components/ui/checkbox.js +2 -3
- package/dist/src/components/ui/collapsible.d.ts +1 -1
- package/dist/src/components/ui/collapsible.js +1 -1
- package/dist/src/components/ui/command.d.ts +4 -4
- package/dist/src/components/ui/command.d.ts.map +1 -1
- package/dist/src/components/ui/command.js +9 -10
- package/dist/src/components/ui/context-menu.d.ts +4 -4
- package/dist/src/components/ui/context-menu.d.ts.map +1 -1
- package/dist/src/components/ui/context-menu.js +7 -8
- package/dist/src/components/ui/dialog.d.ts +6 -6
- package/dist/src/components/ui/dialog.d.ts.map +1 -1
- package/dist/src/components/ui/dialog.js +16 -16
- package/dist/src/components/ui/drawer.d.ts +4 -4
- package/dist/src/components/ui/drawer.d.ts.map +1 -1
- package/dist/src/components/ui/drawer.js +7 -8
- package/dist/src/components/ui/dropdown-menu.d.ts +4 -4
- package/dist/src/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/src/components/ui/dropdown-menu.js +8 -9
- package/dist/src/components/ui/form.d.ts +10 -10
- package/dist/src/components/ui/form.d.ts.map +1 -1
- package/dist/src/components/ui/form.js +15 -15
- package/dist/src/components/ui/header-content.js +1 -1
- package/dist/src/components/ui/hover-card.d.ts +2 -2
- package/dist/src/components/ui/hover-card.d.ts.map +1 -1
- package/dist/src/components/ui/hover-card.js +3 -4
- package/dist/src/components/ui/input-otp.d.ts +5 -5
- package/dist/src/components/ui/input-otp.d.ts.map +1 -1
- package/dist/src/components/ui/input-otp.js +6 -7
- package/dist/src/components/ui/input.d.ts +2 -2
- package/dist/src/components/ui/input.d.ts.map +1 -1
- package/dist/src/components/ui/input.js +1 -2
- package/dist/src/components/ui/label.d.ts +2 -2
- package/dist/src/components/ui/label.d.ts.map +1 -1
- package/dist/src/components/ui/label.js +2 -3
- package/dist/src/components/ui/loader.js +3 -3
- package/dist/src/components/ui/menubar.d.ts +4 -4
- package/dist/src/components/ui/menubar.d.ts.map +1 -1
- package/dist/src/components/ui/menubar.js +11 -12
- package/dist/src/components/ui/navigation-menu.d.ts +2 -2
- package/dist/src/components/ui/navigation-menu.d.ts.map +1 -1
- package/dist/src/components/ui/navigation-menu.js +10 -11
- package/dist/src/components/ui/popover.d.ts +2 -2
- package/dist/src/components/ui/popover.d.ts.map +1 -1
- package/dist/src/components/ui/popover.js +3 -4
- package/dist/src/components/ui/progress.d.ts +2 -2
- package/dist/src/components/ui/progress.d.ts.map +1 -1
- package/dist/src/components/ui/progress.js +2 -3
- package/dist/src/components/ui/radio-group.d.ts +2 -2
- package/dist/src/components/ui/radio-group.d.ts.map +1 -1
- package/dist/src/components/ui/radio-group.js +3 -4
- package/dist/src/components/ui/select.d.ts +3 -3
- package/dist/src/components/ui/select.d.ts.map +1 -1
- package/dist/src/components/ui/select.js +9 -10
- package/dist/src/components/ui/separator.d.ts +2 -2
- package/dist/src/components/ui/separator.d.ts.map +1 -1
- package/dist/src/components/ui/separator.js +3 -4
- package/dist/src/components/ui/sheet.d.ts +5 -5
- package/dist/src/components/ui/sheet.d.ts.map +1 -1
- package/dist/src/components/ui/sheet.js +8 -9
- package/dist/src/components/ui/sidebar.d.ts +31 -31
- package/dist/src/components/ui/sidebar.d.ts.map +1 -1
- package/dist/src/components/ui/sidebar.js +67 -69
- package/dist/src/components/ui/skeleton.d.ts +1 -1
- package/dist/src/components/ui/skeleton.js +1 -1
- package/dist/src/components/ui/slider.d.ts +2 -2
- package/dist/src/components/ui/slider.d.ts.map +1 -1
- package/dist/src/components/ui/slider.js +16 -8
- package/dist/src/components/ui/sonner.d.ts +1 -1
- package/dist/src/components/ui/sonner.d.ts.map +1 -1
- package/dist/src/components/ui/sonner.js +6 -6
- package/dist/src/components/ui/switch.d.ts +2 -2
- package/dist/src/components/ui/switch.d.ts.map +1 -1
- package/dist/src/components/ui/switch.js +3 -4
- package/dist/src/components/ui/table.d.ts +9 -9
- package/dist/src/components/ui/table.d.ts.map +1 -1
- package/dist/src/components/ui/table.js +8 -9
- package/dist/src/components/ui/tabs.d.ts +2 -2
- package/dist/src/components/ui/tabs.d.ts.map +1 -1
- package/dist/src/components/ui/tabs.js +4 -5
- package/dist/src/components/ui/textarea.d.ts +2 -2
- package/dist/src/components/ui/textarea.d.ts.map +1 -1
- package/dist/src/components/ui/textarea.js +1 -2
- package/dist/src/components/ui/toggle-group.d.ts +4 -4
- package/dist/src/components/ui/toggle-group.d.ts.map +1 -1
- package/dist/src/components/ui/toggle-group.js +6 -6
- package/dist/src/components/ui/toggle.d.ts +3 -3
- package/dist/src/components/ui/toggle.d.ts.map +1 -1
- package/dist/src/components/ui/toggle.js +8 -9
- package/dist/src/components/ui/tooltip.d.ts +2 -2
- package/dist/src/components/ui/tooltip.d.ts.map +1 -1
- package/dist/src/components/ui/tooltip.js +2 -3
- package/dist/src/config.js +2 -2
- package/dist/src/database/admins.js +10 -10
- package/dist/src/database/languages.js +7 -7
- package/dist/src/database/logs.js +9 -9
- package/dist/src/database/moderators.js +5 -5
- package/dist/src/database/roles.js +1 -1
- package/dist/src/database/sessions.js +6 -6
- package/dist/src/database/users.js +13 -13
- package/dist/src/drizzle.config.d.ts +2 -2
- package/dist/src/drizzle.config.d.ts.map +1 -1
- package/dist/src/drizzle.config.js +19 -12
- package/dist/src/emails/default-template.d.ts +3 -3
- package/dist/src/emails/default-template.d.ts.map +1 -1
- package/dist/src/emails/default-template.js +39 -38
- package/dist/src/emails/reset-password.d.ts +1 -1
- package/dist/src/emails/reset-password.d.ts.map +1 -1
- package/dist/src/emails/reset-password.js +51 -51
- package/dist/src/emails/ui/button.d.ts +2 -2
- package/dist/src/emails/ui/button.js +13 -13
- package/dist/src/emails/ui/card.d.ts +1 -1
- package/dist/src/emails/ui/card.js +6 -6
- package/dist/src/hooks/use-before-unload.js +3 -3
- package/dist/src/hooks/use-captcha.d.ts +2 -2
- package/dist/src/hooks/use-captcha.d.ts.map +1 -1
- package/dist/src/hooks/use-captcha.js +29 -37
- package/dist/src/hooks/use-mobile.d.ts.map +1 -1
- package/dist/src/hooks/use-mobile.js +3 -4
- package/dist/src/lib/api/get-middleware-api.js +4 -4
- package/dist/src/lib/api/get-session-admin-api.js +5 -5
- package/dist/src/lib/api/get-session-api.js +4 -4
- package/dist/src/lib/colors.js +28 -19
- package/dist/src/lib/colors.test.js +60 -60
- package/dist/src/lib/config.js +3 -3
- package/dist/src/lib/fetcher/cookie-from-string-to-object.d.ts.map +1 -1
- package/dist/src/lib/fetcher/cookie-from-string-to-object.js +1 -1
- package/dist/src/lib/fetcher/cookie-from-string-to-object.test.js +27 -27
- package/dist/src/lib/fetcher/core.d.ts +5 -5
- package/dist/src/lib/fetcher/core.d.ts.map +1 -1
- package/dist/src/lib/fetcher/core.js +11 -10
- package/dist/src/lib/fetcher/helpers-server.d.ts +1 -1
- package/dist/src/lib/fetcher/helpers-server.js +1 -1
- package/dist/src/lib/fetcher/helpers.test.js +17 -17
- package/dist/src/lib/fetcher/types.d.ts +26 -26
- package/dist/src/lib/fetcher/types.d.ts.map +1 -1
- package/dist/src/lib/fetcher-client.d.ts +4 -4
- package/dist/src/lib/fetcher-client.d.ts.map +1 -1
- package/dist/src/lib/fetcher-client.js +3 -3
- package/dist/src/lib/fetcher.d.ts +5 -5
- package/dist/src/lib/fetcher.d.ts.map +1 -1
- package/dist/src/lib/fetcher.js +4 -4
- package/dist/src/lib/helpers/auto-form.d.ts +3 -3
- package/dist/src/lib/helpers/auto-form.d.ts.map +1 -1
- package/dist/src/lib/helpers/auto-form.js +16 -15
- package/dist/src/lib/helpers/auto-form.test.js +129 -129
- package/dist/src/lib/navigation.d.ts +2 -2
- package/dist/src/lib/navigation.d.ts.map +1 -1
- package/dist/src/lib/plugin.d.ts +3 -3
- package/dist/src/lib/special-characters.js +1 -1
- package/dist/src/lib/special-characters.test.js +36 -36
- package/dist/src/lib/utils.d.ts +1 -1
- package/dist/src/tests/setup.d.ts +1 -1
- package/dist/src/views/admin/layouts/admin-layout.d.ts +1 -1
- package/dist/src/views/admin/layouts/admin-layout.d.ts.map +1 -1
- package/dist/src/views/admin/layouts/admin-layout.js +4 -8
- package/dist/src/views/admin/layouts/sidebar/nav/item.d.ts.map +1 -1
- package/dist/src/views/admin/layouts/sidebar/nav/item.js +11 -12
- package/dist/src/views/admin/layouts/sidebar/nav/nav.d.ts +1 -1
- package/dist/src/views/admin/layouts/sidebar/nav/nav.js +11 -11
- package/dist/src/views/admin/layouts/sidebar/sidebar.d.ts +1 -1
- package/dist/src/views/admin/layouts/sidebar/sidebar.d.ts.map +1 -1
- package/dist/src/views/admin/layouts/sidebar/sidebar.js +1 -2
- package/dist/src/views/admin/layouts/sidebar/sign-out.js +1 -1
- package/dist/src/views/admin/layouts/user-bar/client.js +5 -5
- package/dist/src/views/admin/layouts/user-bar/user-bar.d.ts +1 -1
- package/dist/src/views/admin/layouts/user-bar/user-bar.d.ts.map +1 -1
- package/dist/src/views/admin/layouts/user-bar/user-bar.js +1 -1
- package/dist/src/views/admin/sign-in/sign-in-admin-view.js +1 -1
- package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.js +3 -3
- package/dist/src/views/admin/views/core/debug/actions/clear-cache/clear-cache.js +10 -10
- package/dist/src/views/admin/views/core/debug/actions/clear-cache/mutation-api.js +2 -2
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/content.d.ts +1 -1
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/content.d.ts.map +1 -1
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/content.js +15 -15
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/more.d.ts +1 -1
- package/dist/src/views/admin/views/core/debug/system-logs/actions/more/more.js +7 -7
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-status.d.ts.map +1 -1
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-status.js +7 -1
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-type-log.d.ts +1 -1
- package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-type-log.js +3 -3
- package/dist/src/views/admin/views/core/debug/system-logs/system-logs-view.js +25 -25
- package/dist/src/views/admin/views/core/test.js +43 -43
- package/dist/src/views/admin/views/core/users/users-admin-view.d.ts.map +1 -1
- package/dist/src/views/admin/views/core/users/users-admin-view.js +13 -14
- package/dist/src/views/auth/password-reset/change-password-form/form.js +9 -9
- package/dist/src/views/auth/password-reset/change-password-form/mutation-api.d.ts +2 -2
- package/dist/src/views/auth/password-reset/change-password-form/mutation-api.js +5 -5
- package/dist/src/views/auth/password-reset/change-password-form/use-form.d.ts +2 -2
- package/dist/src/views/auth/password-reset/change-password-form/use-form.d.ts.map +1 -1
- package/dist/src/views/auth/password-reset/change-password-form/use-form.js +7 -7
- package/dist/src/views/auth/password-reset/form/form.d.ts +2 -2
- package/dist/src/views/auth/password-reset/form/form.d.ts.map +1 -1
- package/dist/src/views/auth/password-reset/form/form.js +15 -15
- package/dist/src/views/auth/password-reset/form/mutation-api.js +5 -5
- package/dist/src/views/auth/password-reset/form/use-form.d.ts +2 -2
- package/dist/src/views/auth/password-reset/form/use-form.js +7 -7
- package/dist/src/views/auth/password-reset/password-reset-view.js +4 -4
- package/dist/src/views/auth/sign-in/form/form.js +9 -9
- package/dist/src/views/auth/sign-in/form/mutation-api.d.ts +2 -2
- package/dist/src/views/auth/sign-in/form/mutation-api.d.ts.map +1 -1
- package/dist/src/views/auth/sign-in/form/mutation-api.js +10 -10
- package/dist/src/views/auth/sign-in/form/use-form.d.ts +2 -2
- package/dist/src/views/auth/sign-in/form/use-form.js +11 -11
- package/dist/src/views/auth/sign-in/sign-in-view.js +5 -5
- package/dist/src/views/auth/sign-up/components/password-input.d.ts +3 -3
- package/dist/src/views/auth/sign-up/components/password-input.d.ts.map +1 -1
- package/dist/src/views/auth/sign-up/components/password-input.js +9 -10
- package/dist/src/views/auth/sign-up/email-confirmation-view.js +4 -4
- package/dist/src/views/auth/sign-up/form/form.d.ts +2 -2
- package/dist/src/views/auth/sign-up/form/form.d.ts.map +1 -1
- package/dist/src/views/auth/sign-up/form/form.js +18 -18
- package/dist/src/views/auth/sign-up/form/mutation-api.d.ts +2 -2
- package/dist/src/views/auth/sign-up/form/mutation-api.d.ts.map +1 -1
- package/dist/src/views/auth/sign-up/form/mutation-api.js +6 -6
- package/dist/src/views/auth/sign-up/form/use-form.d.ts +2 -2
- package/dist/src/views/auth/sign-up/form/use-form.js +21 -21
- package/dist/src/views/auth/sign-up/sign-up-view.js +5 -5
- package/dist/src/views/auth/sign-up/wrapper.d.ts +1 -1
- package/dist/src/views/auth/sign-up/wrapper.d.ts.map +1 -1
- package/dist/src/views/auth/sign-up/wrapper.js +5 -8
- package/dist/src/views/auth/sso/buttons/client.js +4 -4
- package/dist/src/views/auth/sso/buttons/mutation-api.js +5 -5
- package/dist/src/views/auth/sso/buttons/sso-buttons.js +2 -2
- package/dist/src/views/auth/sso/callback/callback-sso-view.js +6 -6
- package/dist/src/views/auth/sso/callback/client/client.d.ts +1 -1
- package/dist/src/views/auth/sso/callback/client/client.d.ts.map +1 -1
- package/dist/src/views/auth/sso/callback/client/client.js +9 -9
- package/dist/src/views/auth/sso/callback/client/mutation-api.js +7 -7
- package/dist/src/views/error/back-button.js +1 -1
- package/dist/src/views/error/error-view.js +4 -4
- package/dist/src/views/error/global-error-view.d.ts +3 -3
- package/dist/src/views/error/global-error-view.d.ts.map +1 -1
- package/dist/src/views/error/global-error-view.js +36 -44
- package/dist/src/views/layouts/provider.d.ts +4 -4
- package/dist/src/views/layouts/provider.d.ts.map +1 -1
- package/dist/src/views/layouts/provider.js +3 -3
- package/dist/src/views/layouts/root-layout.d.ts +3 -3
- package/dist/src/views/layouts/root-layout.d.ts.map +1 -1
- package/dist/src/views/layouts/root-layout.js +1 -2
- package/dist/src/views/layouts/theme/header/header.d.ts +2 -2
- package/dist/src/views/layouts/theme/header/header.d.ts.map +1 -1
- package/dist/src/views/layouts/theme/header/header.js +1 -1
- package/dist/src/views/layouts/theme/header/user/auth/client.d.ts +1 -1
- package/dist/src/views/layouts/theme/header/user/auth/client.d.ts.map +1 -1
- package/dist/src/views/layouts/theme/header/user/auth/client.js +4 -4
- package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.js +8 -8
- package/dist/src/views/layouts/theme/header/user/user.js +4 -4
- package/dist/src/views/layouts/theme/layout.d.ts +2 -2
- package/dist/src/views/layouts/theme/layout.js +1 -1
- package/dist/src/vitnode.config.d.ts +16 -16
- package/dist/src/vitnode.config.d.ts.map +1 -1
- package/dist/src/vitnode.config.js +3 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -5
- package/src/app/login/page.tsx +5 -5
- package/src/app/login/reset-password/page.tsx +5 -5
- package/src/app/login/sso/[providerId]/page.tsx +1 -1
- package/src/app/register/page.tsx +5 -5
- package/src/app_admin/core/debug/page.tsx +14 -14
- package/src/app_admin/core/page.tsx +1 -1
- package/src/app_admin/core/test/page.tsx +1 -1
- package/src/app_admin/core/users/page.tsx +12 -13
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Section, Text } from
|
|
1
|
+
import { Section, Text } from "@react-email/components";
|
|
2
2
|
export declare const EmailCard: ({ className, ...props }: React.ComponentProps<typeof Section>) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export declare const EmailCardHeader: ({ className, ...props }: React.ComponentProps<typeof Section>) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export declare const EmailCardTitle: ({ className, ...props }: React.ComponentProps<typeof Text>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,37 +3,37 @@ import { Section, Text } from "@react-email/components";
|
|
|
3
3
|
import { cn } from "../../lib/utils.js";
|
|
4
4
|
export const EmailCard = ({ className, ...props })=>{
|
|
5
5
|
return /*#__PURE__*/ _jsx(Section, {
|
|
6
|
-
className: cn(
|
|
6
|
+
className: cn("bg-card text-card-foreground border-border rounded-xl border border-solid py-6 shadow-sm", className),
|
|
7
7
|
...props
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
export const EmailCardHeader = ({ className, ...props })=>{
|
|
11
11
|
return /*#__PURE__*/ _jsx(Section, {
|
|
12
|
-
className: cn(
|
|
12
|
+
className: cn("mb-6 px-6", className),
|
|
13
13
|
...props
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
export const EmailCardTitle = ({ className, ...props })=>{
|
|
17
17
|
return /*#__PURE__*/ _jsx(Text, {
|
|
18
|
-
className: cn(
|
|
18
|
+
className: cn("text-xl font-semibold leading-[0]", className),
|
|
19
19
|
...props
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
export const EmailCardDescription = ({ className, ...props })=>{
|
|
23
23
|
return /*#__PURE__*/ _jsx(Text, {
|
|
24
|
-
className: cn(
|
|
24
|
+
className: cn("text-muted-foreground m-0 text-sm", className),
|
|
25
25
|
...props
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
28
|
export const EmailCardContent = ({ className, ...props })=>{
|
|
29
29
|
return /*#__PURE__*/ _jsx(Section, {
|
|
30
|
-
className: cn(
|
|
30
|
+
className: cn("px-6", className),
|
|
31
31
|
...props
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
export const EmailCardFooter = ({ className, ...props })=>{
|
|
35
35
|
return /*#__PURE__*/ _jsx(Section, {
|
|
36
|
-
className: cn(
|
|
36
|
+
className: cn("mt-6 px-6", className),
|
|
37
37
|
...props
|
|
38
38
|
});
|
|
39
39
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export const useBeforeUnload = (enabled = true, message)=>{
|
|
3
3
|
const handler = React.useCallback((event)=>{
|
|
4
|
-
const finalEnabled = typeof enabled ===
|
|
4
|
+
const finalEnabled = typeof enabled === "function" ? enabled() : true;
|
|
5
5
|
if (!finalEnabled) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
@@ -19,9 +19,9 @@ export const useBeforeUnload = (enabled = true, message)=>{
|
|
|
19
19
|
if (!enabled) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
window.addEventListener(
|
|
22
|
+
window.addEventListener("beforeunload", handler);
|
|
23
23
|
return ()=>{
|
|
24
|
-
window.removeEventListener(
|
|
24
|
+
window.removeEventListener("beforeunload", handler);
|
|
25
25
|
};
|
|
26
26
|
}, [
|
|
27
27
|
enabled,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { z } from
|
|
2
|
-
import type { routeMiddlewareSchema } from
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { routeMiddlewareSchema } from "../api/modules/middleware/route";
|
|
3
3
|
export declare const useCaptcha: (captcha: z.infer<typeof routeMiddlewareSchema>["captcha"]) => {
|
|
4
4
|
isReady: boolean;
|
|
5
5
|
onReset: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-captcha.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-captcha.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-captcha.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-captcha.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAI7B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAE7E,eAAO,MAAM,UAAU,GACrB,SAAS,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC,SAAS,CAAC;;;oBA4G9B,OAAO,CAAC,MAAM,CAAC;CA4B3C,CAAC"}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/** biome-ignore-all lint/suspicious/noConsole: <no needed> */ import { useLocale, useTranslations } from "next-intl";
|
|
2
2
|
import { useTheme } from "next-themes";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { toast } from "sonner";
|
|
5
5
|
import { usePathname } from "../lib/navigation.js";
|
|
6
6
|
export const useCaptcha = (captcha)=>{
|
|
7
|
-
const t = useTranslations(
|
|
7
|
+
const t = useTranslations("core.global.errors");
|
|
8
8
|
const locale = useLocale();
|
|
9
9
|
const { resolvedTheme } = useTheme();
|
|
10
10
|
const [isReady, setIsReady] = React.useState(false);
|
|
11
|
-
const [token, setToken] = React.useState(
|
|
11
|
+
const [token, setToken] = React.useState("");
|
|
12
12
|
const pathname = usePathname();
|
|
13
13
|
const handleLoaded = ()=>{
|
|
14
14
|
if (!captcha) return;
|
|
15
|
-
const elementId =
|
|
16
|
-
if (captcha.type ===
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
15
|
+
const elementId = "vitnode_captcha";
|
|
16
|
+
if (captcha.type === "cloudflare_turnstile") {
|
|
18
17
|
// @ts-expect-error
|
|
19
18
|
window.turnstile.render(`#${elementId}`, {
|
|
20
19
|
sitekey: captcha.siteKey,
|
|
@@ -26,7 +25,7 @@ export const useCaptcha = (captcha)=>{
|
|
|
26
25
|
setIsReady(true);
|
|
27
26
|
},
|
|
28
27
|
// Optional: Add more callbacks for a better user experience
|
|
29
|
-
|
|
28
|
+
"expired-callback": ()=>{
|
|
30
29
|
onReset();
|
|
31
30
|
}
|
|
32
31
|
});
|
|
@@ -36,10 +35,11 @@ export const useCaptcha = (captcha)=>{
|
|
|
36
35
|
}
|
|
37
36
|
};
|
|
38
37
|
const handleError = ()=>{
|
|
39
|
-
toast.error(t(
|
|
40
|
-
description: t(
|
|
38
|
+
toast.error(t("title"), {
|
|
39
|
+
description: t("captcha_internal_error")
|
|
41
40
|
});
|
|
42
41
|
};
|
|
42
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: <needed>
|
|
43
43
|
React.useEffect(()=>{
|
|
44
44
|
if (!captcha) {
|
|
45
45
|
// If no captcha is required, consider it "ready"
|
|
@@ -48,30 +48,30 @@ export const useCaptcha = (captcha)=>{
|
|
|
48
48
|
}
|
|
49
49
|
// Reset state on captcha type change
|
|
50
50
|
setIsReady(false);
|
|
51
|
-
setToken(
|
|
51
|
+
setToken("");
|
|
52
52
|
const googleCaptchaDomain = `https://www.google.com/recaptcha/api.js?hl=${locale}`;
|
|
53
|
-
const script = document.createElement(
|
|
54
|
-
if (captcha.type ===
|
|
55
|
-
script.src =
|
|
56
|
-
} else if (captcha.type ===
|
|
53
|
+
const script = document.createElement("script");
|
|
54
|
+
if (captcha.type === "cloudflare_turnstile") {
|
|
55
|
+
script.src = "https://challenges.cloudflare.com/turnstile/v0/api.js";
|
|
56
|
+
} else if (captcha.type === "recaptcha_v3") {
|
|
57
57
|
script.src = `${googleCaptchaDomain}&render=${captcha.siteKey}`;
|
|
58
58
|
}
|
|
59
59
|
if (!script.src) return;
|
|
60
60
|
script.async = true;
|
|
61
61
|
script.defer = true;
|
|
62
62
|
document.body.appendChild(script);
|
|
63
|
-
script.addEventListener(
|
|
64
|
-
script.addEventListener(
|
|
63
|
+
script.addEventListener("load", handleLoaded);
|
|
64
|
+
script.addEventListener("error", handleError);
|
|
65
65
|
return ()=>{
|
|
66
|
-
script.removeEventListener(
|
|
67
|
-
script.removeEventListener(
|
|
66
|
+
script.removeEventListener("load", handleLoaded);
|
|
67
|
+
script.removeEventListener("error", handleError);
|
|
68
68
|
if (document.body.contains(script)) {
|
|
69
69
|
document.body.removeChild(script);
|
|
70
70
|
}
|
|
71
71
|
// Clean up the captcha widget if it exists
|
|
72
|
-
const widget = document.getElementById(
|
|
72
|
+
const widget = document.getElementById("vitnode_captcha");
|
|
73
73
|
if (widget) {
|
|
74
|
-
widget.innerHTML =
|
|
74
|
+
widget.innerHTML = "";
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
}, [
|
|
@@ -82,36 +82,28 @@ export const useCaptcha = (captcha)=>{
|
|
|
82
82
|
]);
|
|
83
83
|
const onReset = ()=>{
|
|
84
84
|
if (!captcha) return;
|
|
85
|
-
if (captcha.type ===
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
85
|
+
if (captcha.type === "cloudflare_turnstile" && window.turnstile) {
|
|
87
86
|
// @ts-expect-error
|
|
88
|
-
|
|
89
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
90
|
-
// @ts-expect-error
|
|
91
|
-
window.turnstile.reset();
|
|
92
|
-
}
|
|
87
|
+
window.turnstile.reset();
|
|
93
88
|
}
|
|
94
|
-
setToken(
|
|
89
|
+
setToken("");
|
|
95
90
|
setIsReady(false);
|
|
96
91
|
};
|
|
97
92
|
const getToken = async ()=>{
|
|
98
|
-
if (!captcha) return
|
|
99
|
-
if (captcha.type ===
|
|
100
|
-
return new Promise((resolve)=>{
|
|
101
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
93
|
+
if (!captcha) return "";
|
|
94
|
+
if (captcha.type === "recaptcha_v3") {
|
|
95
|
+
return await new Promise((resolve)=>{
|
|
102
96
|
// @ts-expect-error
|
|
103
97
|
window.grecaptcha.ready(async ()=>{
|
|
104
98
|
try {
|
|
105
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
106
99
|
// @ts-expect-error
|
|
107
100
|
const token = await window.grecaptcha.execute(captcha.siteKey, {
|
|
108
|
-
action:
|
|
101
|
+
action: "submit"
|
|
109
102
|
});
|
|
110
103
|
resolve(token);
|
|
111
104
|
} catch (error) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
resolve('');
|
|
105
|
+
console.error("Captcha error", error);
|
|
106
|
+
resolve("");
|
|
115
107
|
}
|
|
116
108
|
});
|
|
117
109
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-mobile.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-mobile.ts"],"names":[],"mappings":"AAIA,wBAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"use-mobile.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-mobile.ts"],"names":[],"mappings":"AAIA,wBAAgB,WAAW,YAiB1B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
const MOBILE_BREAKPOINT = 768;
|
|
3
3
|
export function useIsMobile() {
|
|
4
4
|
const [isMobile, setIsMobile] = React.useState(undefined);
|
|
@@ -7,10 +7,9 @@ export function useIsMobile() {
|
|
|
7
7
|
const onChange = ()=>{
|
|
8
8
|
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
9
9
|
};
|
|
10
|
-
mql.addEventListener(
|
|
11
|
-
// eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
|
|
10
|
+
mql.addEventListener("change", onChange);
|
|
12
11
|
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
13
|
-
return ()=>mql.removeEventListener(
|
|
12
|
+
return ()=>mql.removeEventListener("change", onChange);
|
|
14
13
|
}, []);
|
|
15
14
|
return !!isMobile;
|
|
16
15
|
}
|
|
@@ -2,11 +2,11 @@ import { middlewareModule } from "../../api/modules/middleware/middleware.module
|
|
|
2
2
|
import { fetcher } from "../fetcher.js";
|
|
3
3
|
export const getMiddlewareApi = async ()=>{
|
|
4
4
|
const res = await fetcher(middlewareModule, {
|
|
5
|
-
path:
|
|
6
|
-
method:
|
|
7
|
-
module:
|
|
5
|
+
path: "/",
|
|
6
|
+
method: "get",
|
|
7
|
+
module: "middleware",
|
|
8
8
|
options: {
|
|
9
|
-
cache:
|
|
9
|
+
cache: "force-cache"
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
return await res.json();
|
|
@@ -3,15 +3,15 @@ import { fetcher } from "../fetcher.js";
|
|
|
3
3
|
import { redirect } from "../navigation.js";
|
|
4
4
|
export const getSessionAdminApi = async ()=>{
|
|
5
5
|
const res = await fetcher(adminModule, {
|
|
6
|
-
path:
|
|
7
|
-
method:
|
|
8
|
-
module:
|
|
6
|
+
path: "/session",
|
|
7
|
+
method: "get",
|
|
8
|
+
module: "admin",
|
|
9
9
|
options: {
|
|
10
|
-
cache:
|
|
10
|
+
cache: "force-cache"
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
if (res.status !== 200) {
|
|
14
|
-
await redirect(
|
|
14
|
+
await redirect("/admin");
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
const data = await res.json();
|
|
@@ -2,11 +2,11 @@ import { usersModule } from "../../api/modules/users/users.module.js";
|
|
|
2
2
|
import { fetcher } from "../fetcher.js";
|
|
3
3
|
export const getSessionApi = async ()=>{
|
|
4
4
|
const res = await fetcher(usersModule, {
|
|
5
|
-
path:
|
|
6
|
-
method:
|
|
7
|
-
module:
|
|
5
|
+
path: "/session",
|
|
6
|
+
method: "get",
|
|
7
|
+
module: "users",
|
|
8
8
|
options: {
|
|
9
|
-
cache:
|
|
9
|
+
cache: "force-cache"
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
const data = await res.json();
|
package/dist/src/lib/colors.js
CHANGED
|
@@ -5,19 +5,21 @@ export const convertColor = {
|
|
|
5
5
|
const f = (n)=>{
|
|
6
6
|
const k = (n + h / 30) % 12;
|
|
7
7
|
const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
8
|
-
return Math.round(255 * color).toString(16).padStart(2,
|
|
8
|
+
return Math.round(255 * color).toString(16).padStart(2, "0");
|
|
9
9
|
};
|
|
10
10
|
return `${f(0)}${f(8)}${f(4)}`;
|
|
11
11
|
},
|
|
12
12
|
hexToHSL: (hex)=>{
|
|
13
13
|
if (!hexRegex.test(hex)) return undefined;
|
|
14
|
-
let b = 0
|
|
14
|
+
let b = 0;
|
|
15
|
+
let g = 0;
|
|
16
|
+
let r = 0;
|
|
15
17
|
// 3 digits
|
|
16
|
-
if (hex.length
|
|
18
|
+
if (hex.length === 4) {
|
|
17
19
|
r = parseInt(hex[1] + hex[1], 16);
|
|
18
20
|
g = parseInt(hex[2] + hex[2], 16);
|
|
19
21
|
b = parseInt(hex[3] + hex[3], 16);
|
|
20
|
-
} else if (hex.length
|
|
22
|
+
} else if (hex.length === 7) {
|
|
21
23
|
r = parseInt(hex[1] + hex[2], 16);
|
|
22
24
|
g = parseInt(hex[3] + hex[4], 16);
|
|
23
25
|
b = parseInt(hex[5] + hex[6], 16);
|
|
@@ -25,15 +27,18 @@ export const convertColor = {
|
|
|
25
27
|
return undefined;
|
|
26
28
|
}
|
|
27
29
|
// Check if any of the parsed values are NaN
|
|
28
|
-
if (isNaN(r) || isNaN(g) || isNaN(b)) {
|
|
30
|
+
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
29
31
|
return undefined;
|
|
30
32
|
}
|
|
31
33
|
r /= 255;
|
|
32
34
|
g /= 255;
|
|
33
35
|
b /= 255;
|
|
34
|
-
const max = Math.max(r, g, b)
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
const max = Math.max(r, g, b);
|
|
37
|
+
const min = Math.min(r, g, b);
|
|
38
|
+
const l = (max + min) / 2;
|
|
39
|
+
let h = 0;
|
|
40
|
+
let s = 0;
|
|
41
|
+
if (max === min) {
|
|
37
42
|
h = s = 0; // achromatic
|
|
38
43
|
} else {
|
|
39
44
|
const d = max - min;
|
|
@@ -63,12 +68,16 @@ export const convertColor = {
|
|
|
63
68
|
g /= 255;
|
|
64
69
|
b /= 255;
|
|
65
70
|
// Find greatest and smallest channel values
|
|
66
|
-
const cmax = Math.max(r, g, b)
|
|
67
|
-
|
|
71
|
+
const cmax = Math.max(r, g, b);
|
|
72
|
+
const cmin = Math.min(r, g, b);
|
|
73
|
+
const delta = cmax - cmin;
|
|
74
|
+
let h = 0;
|
|
75
|
+
let l = 0;
|
|
76
|
+
let s = 0;
|
|
68
77
|
// Calculate hue
|
|
69
|
-
if (delta
|
|
70
|
-
else if (cmax
|
|
71
|
-
else if (cmax
|
|
78
|
+
if (delta === 0) h = 0;
|
|
79
|
+
else if (cmax === r) h = (g - b) / delta % 6;
|
|
80
|
+
else if (cmax === g) h = (b - r) / delta + 2;
|
|
72
81
|
else h = (r - g) / delta + 4;
|
|
73
82
|
h = Math.round(h * 60);
|
|
74
83
|
// Make negative hues positive behind 360°
|
|
@@ -76,7 +85,7 @@ export const convertColor = {
|
|
|
76
85
|
// Calculate lightness
|
|
77
86
|
l = (cmax + cmin) / 2;
|
|
78
87
|
// Calculate saturation
|
|
79
|
-
s = delta
|
|
88
|
+
s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
|
|
80
89
|
// Multiply l and s by 100
|
|
81
90
|
s = +(s * 100).toFixed(1);
|
|
82
91
|
l = +(l * 100).toFixed(1);
|
|
@@ -92,7 +101,7 @@ export const convertColor = {
|
|
|
92
101
|
const f = (n)=>{
|
|
93
102
|
const k = (n + h / 30) % 12;
|
|
94
103
|
const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
95
|
-
return Math.round(255 * color).toString(16).padStart(2,
|
|
104
|
+
return Math.round(255 * color).toString(16).padStart(2, "0"); // convert to Hex and prefix "0" if needed
|
|
96
105
|
};
|
|
97
106
|
return {
|
|
98
107
|
r: f(0),
|
|
@@ -107,19 +116,19 @@ export const rgbWithCommaRegex = /^rgb\(\s*([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][
|
|
|
107
116
|
export const rgbWithoutCommaRegex = /^rgb\(\s*([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\s+([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\s+([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\s*\)$/;
|
|
108
117
|
export const checkColorType = (strColor)=>{
|
|
109
118
|
if (hexRegex.test(strColor)) {
|
|
110
|
-
return
|
|
119
|
+
return "hex";
|
|
111
120
|
}
|
|
112
121
|
if (hslRegex.test(strColor)) {
|
|
113
|
-
return
|
|
122
|
+
return "hsl";
|
|
114
123
|
}
|
|
115
124
|
if (rgbWithoutCommaRegex.test(strColor) || rgbWithCommaRegex.test(strColor)) {
|
|
116
|
-
return
|
|
125
|
+
return "rgb";
|
|
117
126
|
}
|
|
118
127
|
return null;
|
|
119
128
|
};
|
|
120
129
|
export const getHSLFromString = (string)=>{
|
|
121
130
|
if (!hslRegex.test(string)) return null;
|
|
122
|
-
const [h, s, l] = string.replaceAll(
|
|
131
|
+
const [h, s, l] = string.replaceAll("hsl(", "").replaceAll(")", "").replaceAll("%", "").split(",").map(Number);
|
|
123
132
|
return {
|
|
124
133
|
h,
|
|
125
134
|
s,
|
|
@@ -1,71 +1,71 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
import { checkColorType, convertColor, getHSLFromString, getStringFromHSL } from "./colors.js";
|
|
3
|
-
describe(
|
|
4
|
-
describe(
|
|
5
|
-
it(
|
|
3
|
+
describe("convertColor", ()=>{
|
|
4
|
+
describe("hslToHex", ()=>{
|
|
5
|
+
it("should convert HSL to hex correctly", ()=>{
|
|
6
6
|
const hsl = {
|
|
7
7
|
h: 0,
|
|
8
8
|
s: 100,
|
|
9
9
|
l: 50
|
|
10
10
|
}; // Red
|
|
11
|
-
expect(convertColor.hslToHex(hsl)).toBe(
|
|
11
|
+
expect(convertColor.hslToHex(hsl)).toBe("ff0000");
|
|
12
12
|
const hsl2 = {
|
|
13
13
|
h: 120,
|
|
14
14
|
s: 100,
|
|
15
15
|
l: 50
|
|
16
16
|
}; // Green
|
|
17
|
-
expect(convertColor.hslToHex(hsl2)).toBe(
|
|
17
|
+
expect(convertColor.hslToHex(hsl2)).toBe("00ff00");
|
|
18
18
|
const hsl3 = {
|
|
19
19
|
h: 240,
|
|
20
20
|
s: 100,
|
|
21
21
|
l: 50
|
|
22
22
|
}; // Blue
|
|
23
|
-
expect(convertColor.hslToHex(hsl3)).toBe(
|
|
23
|
+
expect(convertColor.hslToHex(hsl3)).toBe("0000ff");
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
|
-
describe(
|
|
27
|
-
it(
|
|
28
|
-
expect(convertColor.hexToHSL(
|
|
26
|
+
describe("hexToHSL", ()=>{
|
|
27
|
+
it("should convert 6-digit hex to HSL correctly", ()=>{
|
|
28
|
+
expect(convertColor.hexToHSL("#ff0000")).toEqual({
|
|
29
29
|
h: 0,
|
|
30
30
|
s: 100,
|
|
31
31
|
l: 50
|
|
32
32
|
});
|
|
33
|
-
expect(convertColor.hexToHSL(
|
|
33
|
+
expect(convertColor.hexToHSL("#00ff00")).toEqual({
|
|
34
34
|
h: 120,
|
|
35
35
|
s: 100,
|
|
36
36
|
l: 50
|
|
37
37
|
});
|
|
38
|
-
expect(convertColor.hexToHSL(
|
|
38
|
+
expect(convertColor.hexToHSL("#0000ff")).toEqual({
|
|
39
39
|
h: 240,
|
|
40
40
|
s: 100,
|
|
41
41
|
l: 50
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
|
-
it(
|
|
45
|
-
expect(convertColor.hexToHSL(
|
|
44
|
+
it("should convert 3-digit hex to HSL correctly", ()=>{
|
|
45
|
+
expect(convertColor.hexToHSL("#f00")).toEqual({
|
|
46
46
|
h: 0,
|
|
47
47
|
s: 100,
|
|
48
48
|
l: 50
|
|
49
49
|
});
|
|
50
|
-
expect(convertColor.hexToHSL(
|
|
50
|
+
expect(convertColor.hexToHSL("#0f0")).toEqual({
|
|
51
51
|
h: 120,
|
|
52
52
|
s: 100,
|
|
53
53
|
l: 50
|
|
54
54
|
});
|
|
55
|
-
expect(convertColor.hexToHSL(
|
|
55
|
+
expect(convertColor.hexToHSL("#00f")).toEqual({
|
|
56
56
|
h: 240,
|
|
57
57
|
s: 100,
|
|
58
58
|
l: 50
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
|
-
it(
|
|
62
|
-
expect(convertColor.hexToHSL(
|
|
63
|
-
expect(convertColor.hexToHSL(
|
|
64
|
-
expect(convertColor.hexToHSL(
|
|
61
|
+
it("should return undefined for invalid hex values", ()=>{
|
|
62
|
+
expect(convertColor.hexToHSL("#xyz")).toBeUndefined();
|
|
63
|
+
expect(convertColor.hexToHSL("#12")).toBeUndefined();
|
|
64
|
+
expect(convertColor.hexToHSL("invalid")).toBeUndefined();
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
|
-
describe(
|
|
68
|
-
it(
|
|
67
|
+
describe("RGBToHSL", ()=>{
|
|
68
|
+
it("should convert RGB to HSL correctly", ()=>{
|
|
69
69
|
expect(convertColor.RGBToHSL(255, 0, 0)).toEqual({
|
|
70
70
|
h: 0,
|
|
71
71
|
s: 100,
|
|
@@ -93,81 +93,81 @@ describe('convertColor', ()=>{
|
|
|
93
93
|
});
|
|
94
94
|
});
|
|
95
95
|
});
|
|
96
|
-
describe(
|
|
97
|
-
it(
|
|
96
|
+
describe("hslToRgb", ()=>{
|
|
97
|
+
it("should convert HSL to RGB correctly", ()=>{
|
|
98
98
|
expect(convertColor.hslToRgb(0, 100, 50)).toEqual({
|
|
99
|
-
r:
|
|
100
|
-
g:
|
|
101
|
-
b:
|
|
99
|
+
r: "ff",
|
|
100
|
+
g: "00",
|
|
101
|
+
b: "00"
|
|
102
102
|
});
|
|
103
103
|
expect(convertColor.hslToRgb(120, 100, 50)).toEqual({
|
|
104
|
-
r:
|
|
105
|
-
g:
|
|
106
|
-
b:
|
|
104
|
+
r: "00",
|
|
105
|
+
g: "ff",
|
|
106
|
+
b: "00"
|
|
107
107
|
});
|
|
108
108
|
expect(convertColor.hslToRgb(240, 100, 50)).toEqual({
|
|
109
|
-
r:
|
|
110
|
-
g:
|
|
111
|
-
b:
|
|
109
|
+
r: "00",
|
|
110
|
+
g: "00",
|
|
111
|
+
b: "ff"
|
|
112
112
|
});
|
|
113
113
|
});
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
|
-
describe(
|
|
117
|
-
it(
|
|
118
|
-
expect(checkColorType(
|
|
119
|
-
expect(checkColorType(
|
|
120
|
-
expect(checkColorType(
|
|
116
|
+
describe("checkColorType", ()=>{
|
|
117
|
+
it("should identify hex colors correctly", ()=>{
|
|
118
|
+
expect(checkColorType("#fff")).toBe("hex");
|
|
119
|
+
expect(checkColorType("#ffffff")).toBe("hex");
|
|
120
|
+
expect(checkColorType("#FF0000")).toBe("hex");
|
|
121
121
|
});
|
|
122
|
-
it(
|
|
123
|
-
expect(checkColorType(
|
|
124
|
-
expect(checkColorType(
|
|
122
|
+
it("should identify HSL colors correctly", ()=>{
|
|
123
|
+
expect(checkColorType("hsl(0, 100%, 50%)")).toBe("hsl");
|
|
124
|
+
expect(checkColorType("hsl(120, 60%, 70%)")).toBe("hsl");
|
|
125
125
|
});
|
|
126
|
-
it(
|
|
127
|
-
expect(checkColorType(
|
|
128
|
-
expect(checkColorType(
|
|
126
|
+
it("should identify RGB colors correctly", ()=>{
|
|
127
|
+
expect(checkColorType("rgb(255, 0, 0)")).toBe("rgb");
|
|
128
|
+
expect(checkColorType("rgb(255 0 0)")).toBe("rgb");
|
|
129
129
|
});
|
|
130
|
-
it(
|
|
131
|
-
expect(checkColorType(
|
|
132
|
-
expect(checkColorType(
|
|
133
|
-
expect(checkColorType(
|
|
130
|
+
it("should return null for invalid colors", ()=>{
|
|
131
|
+
expect(checkColorType("invalid")).toBeNull();
|
|
132
|
+
expect(checkColorType("rgb(300, 0, 0)")).toBeNull();
|
|
133
|
+
expect(checkColorType("hsl(400, 100%, 50%)")).toBeNull();
|
|
134
134
|
});
|
|
135
135
|
});
|
|
136
|
-
describe(
|
|
137
|
-
it(
|
|
138
|
-
expect(getHSLFromString(
|
|
136
|
+
describe("getHSLFromString", ()=>{
|
|
137
|
+
it("should parse valid HSL strings correctly", ()=>{
|
|
138
|
+
expect(getHSLFromString("hsl(0, 100%, 50%)")).toEqual({
|
|
139
139
|
h: 0,
|
|
140
140
|
s: 100,
|
|
141
141
|
l: 50
|
|
142
142
|
});
|
|
143
|
-
expect(getHSLFromString(
|
|
143
|
+
expect(getHSLFromString("hsl(120, 60%, 70%)")).toEqual({
|
|
144
144
|
h: 120,
|
|
145
145
|
s: 60,
|
|
146
146
|
l: 70
|
|
147
147
|
});
|
|
148
148
|
});
|
|
149
|
-
it(
|
|
150
|
-
expect(getHSLFromString(
|
|
151
|
-
expect(getHSLFromString(
|
|
152
|
-
expect(getHSLFromString(
|
|
149
|
+
it("should return null for invalid HSL strings", ()=>{
|
|
150
|
+
expect(getHSLFromString("invalid")).toBeNull();
|
|
151
|
+
expect(getHSLFromString("rgb(255, 0, 0)")).toBeNull();
|
|
152
|
+
expect(getHSLFromString("hsl(400, 100%, 50%")).toBeNull();
|
|
153
153
|
});
|
|
154
154
|
});
|
|
155
|
-
describe(
|
|
156
|
-
it(
|
|
155
|
+
describe("getStringFromHSL", ()=>{
|
|
156
|
+
it("should format HSL color object to string correctly", ()=>{
|
|
157
157
|
expect(getStringFromHSL({
|
|
158
158
|
h: 0,
|
|
159
159
|
s: 100,
|
|
160
160
|
l: 50
|
|
161
|
-
})).toBe(
|
|
161
|
+
})).toBe("hsl(0, 100%, 50%)");
|
|
162
162
|
expect(getStringFromHSL({
|
|
163
163
|
h: 120,
|
|
164
164
|
s: 60,
|
|
165
165
|
l: 70
|
|
166
|
-
})).toBe(
|
|
166
|
+
})).toBe("hsl(120, 60%, 70%)");
|
|
167
167
|
expect(getStringFromHSL({
|
|
168
168
|
h: 240,
|
|
169
169
|
s: 50,
|
|
170
170
|
l: 30
|
|
171
|
-
})).toBe(
|
|
171
|
+
})).toBe("hsl(240, 50%, 30%)");
|
|
172
172
|
});
|
|
173
173
|
});
|