From f75e253e59ead11d8cf4f7e53bfb44f60d5697d4 Mon Sep 17 00:00:00 2001 From: melvinchia3636 Date: Sat, 30 May 2026 11:44:18 +0800 Subject: [PATCH] feat: refactor client codebase in progress --- .vscode/settings.json | 2 +- apps/lifeforge--achievements | 1 + apps/package.json | 14 +- .../components/ErrorScreen.tsx | 4 +- .../hooks/useQRLoginApproval.ts | 8 +- .../dashboard/components/DashboardGrid.tsx | 140 +++++++++--------- .../dashboard/components/SaveButtonPopup.tsx | 43 ++++++ client/src/core/dashboard/index.tsx | 25 +--- .../components/ComponentItem.tsx | 73 ++++++--- .../modals/ManageWidgetsModal/index.tsx | 10 +- .../components/BgImageSelector/index.tsx | 8 +- .../components/FontListItem.tsx | 22 ++- .../providers/CoreFederationProvider.tsx | 1 - client/src/i18n.ts | 49 +++--- client/src/index.tsx | 1 + .../providers/features/I18nInitProvider.tsx | 37 +++++ .../features/UserPersonalizationProvider.tsx | 8 +- client/src/providers/index.tsx | 12 +- client/tsconfig.json | 29 +--- locales/lifeforge--lang-en/dashboard.json | 2 +- .../TagsFilter/TagsFilter.stories.tsx | 1 - .../data-display/VirtualGrid/index.tsx | 2 +- .../data-display/Widget/Widget.stories.tsx | 11 +- .../src/components/feedback/Alert/index.tsx | 3 +- .../feedback/EmptyStateScreen/index.tsx | 4 +- .../src/components/inputs/Checkbox/index.tsx | 3 +- .../modals/FlatUIColorsModal/index.tsx | 7 +- .../modals/ModandiColorPaletteModal/index.tsx | 5 +- .../components/ColorItem.tsx | 3 +- .../modals/TailwindCSSColorsModal/index.tsx | 3 +- .../components/ComboboxOption.tsx | 2 +- .../components/inputs/ComboboxInput/index.tsx | 3 +- .../FilePickerModal/components/ImageURL.tsx | 3 +- .../LocalUpload/components/DnDContainer.tsx | 3 +- .../components/PreviewContainer.tsx | 3 +- .../components/CategoryFilter.tsx | 5 +- .../components/ColorFilter.tsx | 2 +- .../components/EditorsChoiceSwitch.tsx | 3 +- .../components/ImageTypeFilter.tsx | 5 +- .../components/Pixabay/index.tsx | 1 - .../components/ChipSelector.tsx | 3 +- .../IconInput/IconPickerModal/index.tsx | 3 +- .../IconSetList/components/CategoryEntry.tsx | 2 +- .../pages/IconSetList/components/Header.tsx | 7 +- .../ListboxInput/ListboxInput.stories.tsx | 1 - .../components/ListboxNullOption.tsx | 2 +- .../ListboxInput/components/ListboxOption.tsx | 2 +- .../components/inputs/LocationInput/index.tsx | 1 - .../inputs/RRuleInput/RRuleInput.stories.tsx | 1 - .../SearchInput/SearchInput.stories.tsx | 3 +- .../SliderInput/components/SliderHeader.tsx | 3 +- .../components/inputs/SliderInput/index.tsx | 2 +- .../shared/components/InputActionButton.tsx | 5 +- .../shared/components/InputLabel/index.tsx | 3 +- .../shared/contexts/InputFocusContext.tsx | 2 +- .../ModuleWrapper/ModuleWrapper.stories.tsx | 2 +- .../Pagination/components/EllipsisIcon.tsx | 3 +- .../navigation/Tabs/Tabs.stories.tsx | 1 - .../SidebarItem/SidebarItem.stories.tsx | 1 - .../components/SidebarActionButton.tsx | 3 +- .../components/SidebarCancelButton.tsx | 3 +- .../components/SidebarItemIcon.tsx | 3 +- .../SidebarItemSubsectionExpandIcon.tsx | 3 +- .../components/SidebarSubsectionItemLink.tsx | 6 +- .../SidebarSubsectionItemWithOnClick.tsx | 3 +- .../components/ContextMenuGroup.tsx | 3 +- .../components/ContextMenuItem.tsx | 1 - .../components/primitives/Box/Box.stories.tsx | 2 +- .../utilities/EncryptionWrapper/index.tsx | 2 +- .../utilities/Tooltip/Tooltip.stories.tsx | 3 +- .../ui/src/system/responsive/index.css.ts | 6 +- packages/ui/tsconfig.json | 21 +-- .../functions/database/PBService/index.ts | 3 +- .../database/PBService/services/create.ts | 3 +- .../database/PBService/services/delete.ts | 3 +- .../PBService/services/getFirstListItem.ts | 3 +- .../PBService/services/getFullList.ts | 3 +- .../database/PBService/services/getList.ts | 3 +- .../database/PBService/services/getOne.ts | 3 +- .../database/PBService/services/update.ts | 3 +- .../src/core/functions/database/getAPIKey.ts | 5 +- .../core/functions/encryption/constants.ts | 3 +- server/src/core/functions/external/ai.ts | 9 +- .../initialization/ensureCredentials.ts | 5 +- .../functions/initialization/localeService.ts | 3 +- .../functions/modules/loadModuleRoutes.ts | 3 +- .../routes/functions/controllerLogic.ts | 6 +- .../routes/utils/checkRecordExistence.ts | 3 +- .../functions/routes/utils/coreContext.ts | 6 +- .../core/functions/routes/utils/getAESKey.ts | 3 +- .../routes/utils/splitMediaAndData.ts | 3 +- .../routes/utils/validateAuthToken.ts | 3 +- .../core/functions/socketio/setupSocket.ts | 3 +- .../src/core/middlewares/morganMiddleware.ts | 3 +- server/src/core/routes/core.routes.ts | 1 - server/src/core/routes/index.ts | 9 +- server/src/index.ts | 9 +- server/src/lib/backups/index.ts | 9 +- server/src/lib/database/routes/collections.ts | 4 +- server/src/lib/locales/index.ts | 9 +- server/src/lib/locations/index.ts | 3 +- server/src/lib/user/index.ts | 4 +- server/src/lib/user/routes/auth.ts | 11 +- server/src/lib/user/utils/otp.ts | 3 +- .../src/providers/APIOnlineStatusProvider.tsx | 36 ++--- .../hooks/useLanguageEffect.tsx | 14 +- tsconfig.eslint.json | 2 +- 107 files changed, 448 insertions(+), 415 deletions(-) create mode 160000 apps/lifeforge--achievements create mode 100644 client/src/core/dashboard/components/SaveButtonPopup.tsx create mode 100644 client/src/providers/features/I18nInitProvider.tsx diff --git a/.vscode/settings.json b/.vscode/settings.json index 16ef10dd3..2b722c059 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,4 +12,4 @@ ], "typescript.tsdk": "node_modules/typescript/lib", "typescript.experimental.useTsgo": false -} \ No newline at end of file +} diff --git a/apps/lifeforge--achievements b/apps/lifeforge--achievements new file mode 160000 index 000000000..207155caa --- /dev/null +++ b/apps/lifeforge--achievements @@ -0,0 +1 @@ +Subproject commit 207155caa77993b10ce02a477bf4e5efbe9e6018 diff --git a/apps/package.json b/apps/package.json index 50213a2a0..811049837 100644 --- a/apps/package.json +++ b/apps/package.json @@ -1,9 +1,9 @@ { - "name": "@lifeforge/apps", - "private": true, - "description": "LifeForge modules", - "dependencies": { - "@lifeforge/TedMeadow--lang-ru": "workspace:*", - "@lifeforge/lifeforge--achievements": "workspace:*" - } + "name": "@lifeforge/apps", + "private": true, + "description": "LifeForge modules", + "dependencies": { + "@lifeforge/TedMeadow--lang-ru": "workspace:*", + "@lifeforge/lifeforge--achievements": "workspace:*" + } } diff --git a/client/src/core/accountSettings/modals/QRLoginScannerModal/components/ErrorScreen.tsx b/client/src/core/accountSettings/modals/QRLoginScannerModal/components/ErrorScreen.tsx index 25f4b97bd..aabf1d077 100644 --- a/client/src/core/accountSettings/modals/QRLoginScannerModal/components/ErrorScreen.tsx +++ b/client/src/core/accountSettings/modals/QRLoginScannerModal/components/ErrorScreen.tsx @@ -16,7 +16,7 @@ function ErrorScreen({ errorMessage: string }) { return ( - + - + {errorMessage} diff --git a/client/src/core/accountSettings/modals/QRLoginScannerModal/hooks/useQRLoginApproval.ts b/client/src/core/accountSettings/modals/QRLoginScannerModal/hooks/useQRLoginApproval.ts index ac9585938..a60dcb4c8 100644 --- a/client/src/core/accountSettings/modals/QRLoginScannerModal/hooks/useQRLoginApproval.ts +++ b/client/src/core/accountSettings/modals/QRLoginScannerModal/hooks/useQRLoginApproval.ts @@ -54,11 +54,9 @@ function useQRLoginApproval(scannedData: string) { if (!sessionData) return try { - const response = await forgeAPI - .user.qrLogin.approveQRLogin - .mutate({ - sessionId: sessionData.sessionId - } as never) + const response = await forgeAPI.user.qrLogin.approveQRLogin.mutate({ + sessionId: sessionData.sessionId + } as never) setBrowserInfo(response.browserInfo) setStep('success') diff --git a/client/src/core/dashboard/components/DashboardGrid.tsx b/client/src/core/dashboard/components/DashboardGrid.tsx index 717ff2b6c..943f83b11 100644 --- a/client/src/core/dashboard/components/DashboardGrid.tsx +++ b/client/src/core/dashboard/components/DashboardGrid.tsx @@ -69,79 +69,83 @@ function DashboardGrid({ } return ( - { - changeDashboardLayout(layouts as never) - }} + - {[ - ...new Set( - Object.values(enabledWidgets) - .map(widgetArray => widgetArray.map(widget => widget.i)) - .flat() - ) - ].map(widgetId => ( -
- {(() => { - if (!width || !height) { - return null - } + { + changeDashboardLayout(layouts as never) + }} + > + {[ + ...new Set( + Object.values(enabledWidgets) + .map(widgetArray => widgetArray.map(widget => widget.i)) + .flat() + ) + ].map(widgetId => ( +
+ {(() => { + if (!width || !height) { + return null + } - const Component = (COMPONENTS[ - widgetId as keyof typeof COMPONENTS - ] ?? NotFoundWidget) as React.FC<{ - dimension: { w: number; h: number } - widgetId?: string - }> + const Component = (COMPONENTS[ + widgetId as keyof typeof COMPONENTS + ] ?? NotFoundWidget) as React.FC<{ + dimension: { w: number; h: number } + widgetId?: string + }> - const dimension = ( - enabledWidgets[getBreakpointFromWidth(width)] || [] - ).find(l => l.i === widgetId) + const dimension = ( + enabledWidgets[getBreakpointFromWidth(width)] || [] + ).find(l => l.i === widgetId) - return ( - - ) - })()} - {canLayoutChange && ( - <> -
- - - - - )} -
- ))} - + ) + })()} + {canLayoutChange && ( + <> +
+ + + + + )} +
+ ))} + + ) } diff --git a/client/src/core/dashboard/components/SaveButtonPopup.tsx b/client/src/core/dashboard/components/SaveButtonPopup.tsx new file mode 100644 index 000000000..0a259f9a5 --- /dev/null +++ b/client/src/core/dashboard/components/SaveButtonPopup.tsx @@ -0,0 +1,43 @@ +import React from 'react' + +import { useMainSidebarState } from '@lifeforge/shared' +import { Button, Flex, Text } from '@lifeforge/ui' + +function SaveButtonPopup({ + canChange, + setCanChange +}: { + canChange: boolean + setCanChange: React.Dispatch> +}) { + const { sidebarExpanded } = useMainSidebarState() + + if (!canChange) return null + + return ( + + + You are editing dashboard layout + + + + ) +} + +export default SaveButtonPopup diff --git a/client/src/core/dashboard/index.tsx b/client/src/core/dashboard/index.tsx index 91bbd1b3f..2fb8ebbd7 100644 --- a/client/src/core/dashboard/index.tsx +++ b/client/src/core/dashboard/index.tsx @@ -1,7 +1,6 @@ import { useCallback, useRef, useState } from 'react' import { - Button, ContextMenuItem, Flex, ModuleHeader, @@ -9,6 +8,7 @@ import { } from '@lifeforge/ui' import DashboardGrid from './components/DashboardGrid' +import SaveButtonPopup from './components/SaveButtonPopup' import './index.css' import ManageWidgetsModal from './modals/ManageWidgetsModal' import WidgetProvider, { useWidgets } from './providers/WidgetProvider' @@ -56,25 +56,10 @@ function DashboardContent() { /> {/* Save Button Popup */} - {canLayoutChange && ( -
-
-
-
- You are Editing Dashboard Layout -
-
-
- -
-
-
- )} + ) } diff --git a/client/src/core/dashboard/modals/ManageWidgetsModal/components/ComponentItem.tsx b/client/src/core/dashboard/modals/ManageWidgetsModal/components/ComponentItem.tsx index be485db48..63747ecf2 100644 --- a/client/src/core/dashboard/modals/ManageWidgetsModal/components/ComponentItem.tsx +++ b/client/src/core/dashboard/modals/ManageWidgetsModal/components/ComponentItem.tsx @@ -3,7 +3,16 @@ import { useMemo } from 'react' import { useTranslation } from 'react-i18next' import { type IDashboardLayout, usePersonalization } from '@lifeforge/shared' -import { Icon, Switch } from '@lifeforge/ui' +import { + COLORS, + Card, + Flex, + Icon, + Switch, + Text, + Transition, + withOpacity +} from '@lifeforge/ui' import { useUserPersonalization } from '@/providers/features/UserPersonalizationProvider' @@ -106,21 +115,49 @@ function ComponentListItem({ } return ( -
  • -
    -
    - -
    + + + + + +
    {t([ @@ -131,21 +168,21 @@ function ComponentListItem({ id ])}
    -
    + {t([ `widgets.${namespace}.${id}.description`, `widgets.${id}.description` ])} -
    +
    -
    + { toggleComponent() }} /> -
  • + ) } diff --git a/client/src/core/dashboard/modals/ManageWidgetsModal/index.tsx b/client/src/core/dashboard/modals/ManageWidgetsModal/index.tsx index dbcb8de44..11194aaa9 100644 --- a/client/src/core/dashboard/modals/ManageWidgetsModal/index.tsx +++ b/client/src/core/dashboard/modals/ManageWidgetsModal/index.tsx @@ -1,4 +1,4 @@ -import { ModalHeader } from '@lifeforge/ui' +import { Box, ModalHeader, Stack } from '@lifeforge/ui' import type { WidgetEntry } from '../../providers/WidgetProvider' import ComponentListItem from './components/ComponentItem' @@ -11,14 +11,14 @@ function ManageWidgetsModal({ data: { widgets: Record } }) { return ( -
    + -
      + {Object.entries(widgets).map( ([key, { icon, minW, minH, maxW, maxH, namespace }]) => ( ) )} -
    -
    + + ) } diff --git a/client/src/core/personalization/components/BgImageSelector/index.tsx b/client/src/core/personalization/components/BgImageSelector/index.tsx index d87dded73..4b87b5c80 100644 --- a/client/src/core/personalization/components/BgImageSelector/index.tsx +++ b/client/src/core/personalization/components/BgImageSelector/index.tsx @@ -60,11 +60,9 @@ function BgImageSelector() { async function onSubmit(file: string | File) { try { - const data = await forgeAPI - .user.personalization.updateBgImage - .mutate({ - file - }) + const data = await forgeAPI.user.personalization.updateBgImage.mutate({ + file + }) setBgImage(forgeAPI.getMedia(data)) toast.success('Background image updated') diff --git a/client/src/core/personalization/components/FontFamilySelector/components/FontFamilySelectorModal/components/FontListItem.tsx b/client/src/core/personalization/components/FontFamilySelector/components/FontFamilySelectorModal/components/FontListItem.tsx index 34a70656d..099211ffe 100644 --- a/client/src/core/personalization/components/FontFamilySelector/components/FontFamilySelectorModal/components/FontListItem.tsx +++ b/client/src/core/personalization/components/FontFamilySelector/components/FontFamilySelectorModal/components/FontListItem.tsx @@ -29,18 +29,16 @@ function FontListItem({ const queryClient = useQueryClient() const togglePinMutation = useMutation( - forgeAPI - .user.personalization.toggleGoogleFontsPin - .mutationOptions({ - onSuccess: () => { - queryClient.invalidateQueries({ - queryKey: ['user', 'personalization', 'listGoogleFontsPin'] - }) - }, - onError: () => { - toast.error('Failed to toggle font pin') - } - }) + forgeAPI.user.personalization.toggleGoogleFontsPin.mutationOptions({ + onSuccess: () => { + queryClient.invalidateQueries({ + queryKey: ['user', 'personalization', 'listGoogleFontsPin'] + }) + }, + onError: () => { + toast.error('Failed to toggle font pin') + } + }) ) const [loadingPin, handleTogglePin] = usePromiseLoading(async () => { diff --git a/client/src/federation/providers/CoreFederationProvider.tsx b/client/src/federation/providers/CoreFederationProvider.tsx index 044d4ba1f..42a5f0fef 100644 --- a/client/src/federation/providers/CoreFederationProvider.tsx +++ b/client/src/federation/providers/CoreFederationProvider.tsx @@ -30,7 +30,6 @@ export default function CoreFederationProvider({ try { const result = await loadModules() - setModules(result.routes) setGlobalProviders(result.globalProviders) setCategoryTranslations(result.categoryTranslations) diff --git a/client/src/i18n.ts b/client/src/i18n.ts index aefe8a0b6..41c2c2421 100644 --- a/client/src/i18n.ts +++ b/client/src/i18n.ts @@ -4,24 +4,39 @@ import { initReactI18next } from 'react-i18next' import forgeAPI from './forgeAPI' -const AVAILABLE_LANG = (await fetch( - `${import.meta.env.VITE_API_HOST}/locales/listLanguages` -) - .then(res => res.json()) - .then(data => data.data) - .catch(err => { - console.warn('Failed to fetch available languages from backend:', err) - return [{ name: 'en', icon: 'twemoji:flag-united-states' }] - })) as { +export let AVAILABLE_LANG: { name: string alternative?: string[] icon: string -}[] +}[] = [{ name: 'en', icon: 'circle-flags:gb' }] -i18n - .use(I18NextHttpBackend) - .use(initReactI18next) - .init({ +i18n.use(I18NextHttpBackend).use(initReactI18next) + +export async function initI18n() { + if (i18n.isInitialized) { + return i18n + } + + try { + const langRes = await fetch( + `${import.meta.env.VITE_API_HOST}/locales/listLanguages` + ) + + if (langRes.ok) { + const data = await langRes.json() + + if (data?.data) { + AVAILABLE_LANG = data.data + } + } + } catch (err) { + console.warn( + 'Failed to fetch available languages, falling back to default:', + err + ) + } + + await i18n.init({ lng: 'en', fallbackLng: 'en', cache: { @@ -82,8 +97,6 @@ i18n } } }) - .catch(err => { - console.error('Failed to initialize i18n: ', err) - }) -export default i18n + return i18n +} diff --git a/client/src/index.tsx b/client/src/index.tsx index 83e473ca3..b9606412c 100644 --- a/client/src/index.tsx +++ b/client/src/index.tsx @@ -1,2 +1,3 @@ import './index.css' + import('./bootstrap') diff --git a/client/src/providers/features/I18nInitProvider.tsx b/client/src/providers/features/I18nInitProvider.tsx new file mode 100644 index 000000000..83d91fe2a --- /dev/null +++ b/client/src/providers/features/I18nInitProvider.tsx @@ -0,0 +1,37 @@ +import { useEffect, useState } from 'react' + +import { ErrorScreen, LoadingScreen } from '@lifeforge/ui' + +import { initI18n } from '@/i18n' + +export default function I18nInitProvider({ + children +}: { + children: React.ReactNode +}) { + const [initialized, setInitialized] = useState(false) + + useEffect(() => { + initI18n() + .then(() => { + setInitialized(true) + }) + .catch(err => { + console.error('Failed to initialize i18n:', err) + + setInitialized('error') + }) + }, []) + + if (!initialized) { + return + } + + if (initialized === 'error') { + return ( + + ) + } + + return children +} diff --git a/client/src/providers/features/UserPersonalizationProvider.tsx b/client/src/providers/features/UserPersonalizationProvider.tsx index d706c36e6..2742e0452 100644 --- a/client/src/providers/features/UserPersonalizationProvider.tsx +++ b/client/src/providers/features/UserPersonalizationProvider.tsx @@ -24,11 +24,9 @@ async function syncUserData( setUserData: React.Dispatch> ) { try { - await forgeAPI - .user.personalization.updatePersonalization - .mutate({ - data - }) + await forgeAPI.user.personalization.updatePersonalization.mutate({ + data + }) if (setUserData) { setUserData((oldData: any) => { diff --git a/client/src/providers/index.tsx b/client/src/providers/index.tsx index cbe1d3067..b1b6ff364 100644 --- a/client/src/providers/index.tsx +++ b/client/src/providers/index.tsx @@ -26,6 +26,7 @@ import forgeAPI from '@/forgeAPI' import AppRoutesProvider from '@/routes/providers/AppRoutesProvider' import ExternalModuleProviders from './features/ExternalModuleProviders' +import I18nInitProvider from './features/I18nInitProvider' import UserPersonalizationProvider from './features/UserPersonalizationProvider' import { constructComponentTree, defineProviders } from './utils/providerUtils' @@ -47,10 +48,6 @@ function Providers() { // Provider that tells components the API endpoint to use [APIEndpointProvider, { endpoint: import.meta.env.VITE_API_HOST }], - // Provider that initializes end-to-end encryption (fetches server public key) - [EncryptionProvider, { apiHost: import.meta.env.VITE_API_HOST }], - [EncryptionWrapper], - // Provider that stores all the theming information [PersonalizationProvider, { forgeAPI }], @@ -66,6 +63,13 @@ function Providers() { ], [APIOnlineStatusWrapper], + // All subsequent providers are gated behind the API status check! + [I18nInitProvider], + + // Provider that initializes end-to-end encryption (fetches server public key) + [EncryptionProvider, { apiHost: import.meta.env.VITE_API_HOST }], + [EncryptionWrapper], + // Provider that handles authentication, very obviously [ AuthProvider, diff --git a/client/tsconfig.json b/client/tsconfig.json index 5c2adad8b..d276026ec 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -2,17 +2,10 @@ "compilerOptions": { "target": "ES2020", "useDefineForClassFields": true, - "lib": [ - "ES2020", - "DOM", - "DOM.Iterable", - "ES2024.Object" - ], + "lib": ["ES2020", "DOM", "DOM.Iterable", "ES2024.Object"], "module": "ESNext", "skipLibCheck": true, - "types": [ - "node" - ], + "types": ["node"], /* Bundler mode */ "outDir": "${configDir}/tsbuild", "moduleResolution": "bundler", @@ -29,15 +22,9 @@ "rootDir": "../", "baseUrl": "./", "paths": { - "@/*": [ - "./src/*" - ], - "@core/*": [ - "../core/*" - ], - "@functions/*": [ - "../server/src/core/functions/*" - ], + "@/*": ["./src/*"], + "@core/*": ["../core/*"], + "@functions/*": ["../server/src/core/functions/*"] } }, "references": [ @@ -45,7 +32,5 @@ "path": "../server" } ], - "include": [ - "./src/**/*" - ] -} \ No newline at end of file + "include": ["./src/**/*"] +} diff --git a/locales/lifeforge--lang-en/dashboard.json b/locales/lifeforge--lang-en/dashboard.json index 07e43ecb4..63a0b1370 100644 --- a/locales/lifeforge--lang-en/dashboard.json +++ b/locales/lifeforge--lang-en/dashboard.json @@ -27,7 +27,7 @@ "empty": { "welcome": { "title": "Welcome to LifeForge!", - "description": "Get started by installing some modules from the ForgeStore." + "description": "Get started by installing some modules from Forgistry." }, "notFound": { "title": "Widget Not Found", diff --git a/packages/ui/src/components/data-display/TagsFilter/TagsFilter.stories.tsx b/packages/ui/src/components/data-display/TagsFilter/TagsFilter.stories.tsx index fb1252d99..5d0fa2437 100644 --- a/packages/ui/src/components/data-display/TagsFilter/TagsFilter.stories.tsx +++ b/packages/ui/src/components/data-display/TagsFilter/TagsFilter.stories.tsx @@ -3,7 +3,6 @@ import { useState } from 'react' import { Button } from '@/components/inputs' import { Box, Flex, Text } from '@/components/primitives' - import { TAILWIND_PALETTE } from '@/system' import { TagsFilter } from './index' diff --git a/packages/ui/src/components/data-display/VirtualGrid/index.tsx b/packages/ui/src/components/data-display/VirtualGrid/index.tsx index 5f083016d..4c7242873 100644 --- a/packages/ui/src/components/data-display/VirtualGrid/index.tsx +++ b/packages/ui/src/components/data-display/VirtualGrid/index.tsx @@ -79,10 +79,10 @@ export function VirtualGrid({ > {items.slice(fromIndex, toIndex).map(item => ( diff --git a/packages/ui/src/components/data-display/Widget/Widget.stories.tsx b/packages/ui/src/components/data-display/Widget/Widget.stories.tsx index d2855a3bc..7eccb3610 100644 --- a/packages/ui/src/components/data-display/Widget/Widget.stories.tsx +++ b/packages/ui/src/components/data-display/Widget/Widget.stories.tsx @@ -2,7 +2,6 @@ import type { Meta, StoryObj } from '@storybook/react-vite' import { Button, Listbox, ListboxOption } from '@/components/inputs' import { Box, Grid, Text } from '@/components/primitives' - import { ScrollableStory } from '@/storybook/ScrollableStory' import { TAILWIND_PALETTE } from '@/system' @@ -25,7 +24,7 @@ export const Default: Story = { title: 'Cool Widget' }, render: args => ( - + This is a dashboard item. @@ -63,7 +62,7 @@ export const WithDescription: Story = { title: 'Cool Widget' }, render: args => ( - + This is a dashboard item. @@ -101,7 +100,7 @@ export const WithIconColor: Story = { }, render: args => ( - + {[ TAILWIND_PALETTE.red[500], TAILWIND_PALETTE.blue[500], @@ -130,7 +129,7 @@ export const WithActionComponent: Story = { title: 'A Cool Widget' }, render: args => ( - + This widget has a plus button beside the title. When clicked, maybe a @@ -204,7 +203,7 @@ export const LargeIconWithIconColor: Story = { }, render: args => ( - + {[ TAILWIND_PALETTE.red[500], TAILWIND_PALETTE.blue[500], diff --git a/packages/ui/src/components/feedback/Alert/index.tsx b/packages/ui/src/components/feedback/Alert/index.tsx index b89f1036a..0187a77e2 100644 --- a/packages/ui/src/components/feedback/Alert/index.tsx +++ b/packages/ui/src/components/feedback/Alert/index.tsx @@ -1,8 +1,7 @@ import clsx from 'clsx' import React from 'react' -import { Icon } from '@/components/primitives' -import { Flex, Text } from '@/components/primitives' +import { Flex, Icon, Text } from '@/components/primitives' import * as styles from './Alert.css' diff --git a/packages/ui/src/components/feedback/EmptyStateScreen/index.tsx b/packages/ui/src/components/feedback/EmptyStateScreen/index.tsx index 29b24769f..a4feb0072 100644 --- a/packages/ui/src/components/feedback/EmptyStateScreen/index.tsx +++ b/packages/ui/src/components/feedback/EmptyStateScreen/index.tsx @@ -1,8 +1,7 @@ import { useTranslation } from 'react-i18next' import { Button } from '@/components/inputs' -import { Icon } from '@/components/primitives' -import { Box, Flex, Text } from '@/components/primitives' +import { Box, Flex, Icon, Text } from '@/components/primitives' interface EmptyStateScreenProps { /** Props for the call-to-action button. Refer to the Button component for available props. */ @@ -71,6 +70,7 @@ export function EmptyStateScreen({ {PALETTES.map(({ name, icon, colors }) => ( @@ -44,7 +43,7 @@ function FlatUIColorsModal({ {name} - + {colors.map((flatUiColor, index) => ( {MORANDI_COLORS.sort(sortFn).map((morandiColor, index) => ( diff --git a/packages/ui/src/components/inputs/ColorInput/ColorPickerModal/components/modals/TailwindCSSColorsModal/components/ColorItem.tsx b/packages/ui/src/components/inputs/ColorInput/ColorPickerModal/components/modals/TailwindCSSColorsModal/components/ColorItem.tsx index 3938bd754..9bd148d30 100644 --- a/packages/ui/src/components/inputs/ColorInput/ColorPickerModal/components/modals/TailwindCSSColorsModal/components/ColorItem.tsx +++ b/packages/ui/src/components/inputs/ColorInput/ColorPickerModal/components/modals/TailwindCSSColorsModal/components/ColorItem.tsx @@ -4,8 +4,7 @@ import { memo, useMemo } from 'react' import { usePersonalization } from '@lifeforge/shared' -import { Icon } from '@/components/primitives' -import { Box, Flex, Text } from '@/components/primitives' +import { Box, Flex, Icon, Text } from '@/components/primitives' import * as styles from './ColorItem.css' diff --git a/packages/ui/src/components/inputs/ColorInput/ColorPickerModal/components/modals/TailwindCSSColorsModal/index.tsx b/packages/ui/src/components/inputs/ColorInput/ColorPickerModal/components/modals/TailwindCSSColorsModal/index.tsx index 3abbf6c29..6648c3ee2 100644 --- a/packages/ui/src/components/inputs/ColorInput/ColorPickerModal/components/modals/TailwindCSSColorsModal/index.tsx +++ b/packages/ui/src/components/inputs/ColorInput/ColorPickerModal/components/modals/TailwindCSSColorsModal/index.tsx @@ -1,6 +1,5 @@ import { ModalHeader } from '@/components/overlays' import { Box, Flex, Grid, Text } from '@/components/primitives' - import { TAILWIND_PALETTE } from '@/system' import * as styles from './TailwindCSSColorsModal.css' @@ -53,8 +52,8 @@ function TailwindCSSColorsModal({ {Object.entries( diff --git a/packages/ui/src/components/inputs/ComboboxInput/components/ComboboxOption.tsx b/packages/ui/src/components/inputs/ComboboxInput/components/ComboboxOption.tsx index 0f9e0bcd1..27f7ac314 100644 --- a/packages/ui/src/components/inputs/ComboboxInput/components/ComboboxOption.tsx +++ b/packages/ui/src/components/inputs/ComboboxInput/components/ComboboxOption.tsx @@ -1,10 +1,10 @@ import { ComboboxOption as HeadlessComboboxOption } from '@headlessui/react' -import { Icon } from '@/components/primitives' import { Bordered, Box, Flex, + Icon, Text, Transition, WithDivide diff --git a/packages/ui/src/components/inputs/ComboboxInput/index.tsx b/packages/ui/src/components/inputs/ComboboxInput/index.tsx index 70aba8ee8..77b4943a6 100644 --- a/packages/ui/src/components/inputs/ComboboxInput/index.tsx +++ b/packages/ui/src/components/inputs/ComboboxInput/index.tsx @@ -4,8 +4,7 @@ import { } from '@headlessui/react' import { useCallback, useMemo } from 'react' -import { Icon } from '@/components/primitives' -import { Box, Flex, Text } from '@/components/primitives' +import { Box, Flex, Icon, Text } from '@/components/primitives' import { InputActionButton } from '../shared/components/InputActionButton' import { InputIcon } from '../shared/components/InputIcon' diff --git a/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/ImageURL.tsx b/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/ImageURL.tsx index 4c2780a9d..667f51a02 100644 --- a/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/ImageURL.tsx +++ b/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/ImageURL.tsx @@ -1,6 +1,5 @@ import { TextInput } from '@/components/inputs' -import { Icon } from '@/components/primitives' -import { Box, Text } from '@/components/primitives' +import { Box, Icon, Text } from '@/components/primitives' export function ImageURL({ file, diff --git a/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/LocalUpload/components/DnDContainer.tsx b/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/LocalUpload/components/DnDContainer.tsx index 1006089e7..abcb6f60e 100644 --- a/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/LocalUpload/components/DnDContainer.tsx +++ b/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/LocalUpload/components/DnDContainer.tsx @@ -4,8 +4,7 @@ import type { DropzoneInputProps, DropzoneRootProps } from 'react-dropzone' import { useTranslation } from 'react-i18next' import { Button } from '@/components/inputs' -import { Icon } from '@/components/primitives' -import { Flex, Text } from '@/components/primitives' +import { Flex, Icon, Text } from '@/components/primitives' import * as styles from './DnDContainer.css' diff --git a/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/LocalUpload/components/PreviewContainer.tsx b/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/LocalUpload/components/PreviewContainer.tsx index f54fb4bfa..75749d0a0 100644 --- a/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/LocalUpload/components/PreviewContainer.tsx +++ b/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/LocalUpload/components/PreviewContainer.tsx @@ -1,8 +1,7 @@ import { useMemo } from 'react' import { Button } from '@/components/inputs' -import { Icon } from '@/components/primitives' -import { Box, Flex, Text } from '@/components/primitives' +import { Box, Flex, Icon, Text } from '@/components/primitives' import { FILE_ICONS } from '../../../constants/file_icons' diff --git a/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/components/SearchFilterModal/components/CategoryFilter.tsx b/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/components/SearchFilterModal/components/CategoryFilter.tsx index 586ab33b8..4bd74cedd 100644 --- a/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/components/SearchFilterModal/components/CategoryFilter.tsx +++ b/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/components/SearchFilterModal/components/CategoryFilter.tsx @@ -1,6 +1,5 @@ import { ListboxInput, ListboxOption } from '@/components/inputs' -import { Icon } from '@/components/primitives' -import { Text } from '@/components/primitives' +import { Icon, Text } from '@/components/primitives' import { type IPixabaySearchFilter, @@ -26,9 +25,9 @@ export function CategoryFilter({ style={{ height: '1.25rem', width: '1.25rem' }} /> {CATEGORIES.find(l => l.id === category)?.name ?? 'None'} diff --git a/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/components/SearchFilterModal/components/ColorFilter.tsx b/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/components/SearchFilterModal/components/ColorFilter.tsx index c8424f131..df89f8710 100644 --- a/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/components/SearchFilterModal/components/ColorFilter.tsx +++ b/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/components/SearchFilterModal/components/ColorFilter.tsx @@ -30,9 +30,9 @@ export function ColorFilter({ colors, updateFilters }: ColorFilterProps) {
    {COLORS.find(l => l.id === colors)?.name ?? 'None'} diff --git a/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/components/SearchFilterModal/components/EditorsChoiceSwitch.tsx b/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/components/SearchFilterModal/components/EditorsChoiceSwitch.tsx index c3c5c2570..b4a89cd74 100644 --- a/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/components/SearchFilterModal/components/EditorsChoiceSwitch.tsx +++ b/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/components/SearchFilterModal/components/EditorsChoiceSwitch.tsx @@ -1,8 +1,7 @@ import { useTranslation } from 'react-i18next' import { Switch } from '@/components/inputs' -import { Icon } from '@/components/primitives' -import { Flex, Text } from '@/components/primitives' +import { Flex, Icon, Text } from '@/components/primitives' import { type PixabaySearchFilterAction } from '../../../typescript/pixabay_interfaces' diff --git a/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/components/SearchFilterModal/components/ImageTypeFilter.tsx b/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/components/SearchFilterModal/components/ImageTypeFilter.tsx index ae33dabc5..d41a7545f 100644 --- a/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/components/SearchFilterModal/components/ImageTypeFilter.tsx +++ b/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/components/SearchFilterModal/components/ImageTypeFilter.tsx @@ -1,8 +1,7 @@ import { useTranslation } from 'react-i18next' import { ListboxInput, ListboxOption } from '@/components/inputs' -import { Icon } from '@/components/primitives' -import { Text } from '@/components/primitives' +import { Icon, Text } from '@/components/primitives' import { type IPixabaySearchFilter, @@ -30,9 +29,9 @@ export function ImageTypeFilter({ style={{ height: '1.25rem', width: '1.25rem' }} /> {t( `imagePicker.imageType.${IMAGE_TYPES.find(l => l.id === imageType)?.id}` diff --git a/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/index.tsx b/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/index.tsx index aab67a2f0..8e8751022 100644 --- a/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/index.tsx +++ b/packages/ui/src/components/inputs/FileInput/FilePickerModal/components/Pixabay/index.tsx @@ -11,7 +11,6 @@ import { import { Button, SearchInput } from '@/components/inputs' import { Flex } from '@/components/primitives' import { WithQueryData } from '@/components/utilities' - import { forgeAPI } from '@/utils/forgeAPI' import { SearchFilterModal } from './components/SearchFilterModal' diff --git a/packages/ui/src/components/inputs/IconInput/IconPickerModal/components/ChipSelector.tsx b/packages/ui/src/components/inputs/IconInput/IconPickerModal/components/ChipSelector.tsx index 4e75efff0..287bb259b 100644 --- a/packages/ui/src/components/inputs/IconInput/IconPickerModal/components/ChipSelector.tsx +++ b/packages/ui/src/components/inputs/IconInput/IconPickerModal/components/ChipSelector.tsx @@ -3,8 +3,7 @@ import { useCallback, useMemo, useState } from 'react' import { usePersonalization } from '@lifeforge/shared' import { TagChip } from '@/components/data-display' -import { Icon } from '@/components/primitives' -import { Flex, Text, Transition } from '@/components/primitives' +import { Flex, Icon, Text, Transition } from '@/components/primitives' export function ChipSelector({ options, diff --git a/packages/ui/src/components/inputs/IconInput/IconPickerModal/index.tsx b/packages/ui/src/components/inputs/IconInput/IconPickerModal/index.tsx index f9226774e..5baa26a93 100644 --- a/packages/ui/src/components/inputs/IconInput/IconPickerModal/index.tsx +++ b/packages/ui/src/components/inputs/IconInput/IconPickerModal/index.tsx @@ -2,8 +2,7 @@ import { useCallback, useState } from 'react' import { GoBackButton } from '@/components/navigation' import { ModalHeader } from '@/components/overlays' -import { Icon } from '@/components/primitives' -import { Box, Flex, Text, Transition } from '@/components/primitives' +import { Box, Flex, Icon, Text, Transition } from '@/components/primitives' import { IconSet } from './pages/IconSet' import { IconSetList } from './pages/IconSetList/index' diff --git a/packages/ui/src/components/inputs/IconInput/IconPickerModal/pages/IconSetList/components/CategoryEntry.tsx b/packages/ui/src/components/inputs/IconInput/IconPickerModal/pages/IconSetList/components/CategoryEntry.tsx index 5d9cf0e88..7a6020099 100644 --- a/packages/ui/src/components/inputs/IconInput/IconPickerModal/pages/IconSetList/components/CategoryEntry.tsx +++ b/packages/ui/src/components/inputs/IconInput/IconPickerModal/pages/IconSetList/components/CategoryEntry.tsx @@ -40,11 +40,11 @@ function _CategoryEntry({ {iconSets.map(iconSet => ( = importedCollections diff --git a/packages/ui/src/components/inputs/ListboxInput/ListboxInput.stories.tsx b/packages/ui/src/components/inputs/ListboxInput/ListboxInput.stories.tsx index 59a6c9ea4..2e4bbe80e 100644 --- a/packages/ui/src/components/inputs/ListboxInput/ListboxInput.stories.tsx +++ b/packages/ui/src/components/inputs/ListboxInput/ListboxInput.stories.tsx @@ -2,7 +2,6 @@ import type { Meta, StoryObj } from '@storybook/react-vite' import { useState } from 'react' import { Box, Flex, Icon, Text } from '@/components/primitives' - import { COLORS, TAILWIND_PALETTE } from '@/system' import { ListboxNullOption } from './components/ListboxNullOption' diff --git a/packages/ui/src/components/inputs/ListboxInput/components/ListboxNullOption.tsx b/packages/ui/src/components/inputs/ListboxInput/components/ListboxNullOption.tsx index 722636dcd..eca20c88a 100644 --- a/packages/ui/src/components/inputs/ListboxInput/components/ListboxNullOption.tsx +++ b/packages/ui/src/components/inputs/ListboxInput/components/ListboxNullOption.tsx @@ -1,9 +1,9 @@ import { ListboxOption as HeadlessListboxOption } from '@headlessui/react' -import { Icon } from '@/components/primitives' import { Box, Flex, + Icon, Text, Transition, WithDivide diff --git a/packages/ui/src/components/inputs/ListboxInput/components/ListboxOption.tsx b/packages/ui/src/components/inputs/ListboxInput/components/ListboxOption.tsx index 0995a395f..2da57c236 100644 --- a/packages/ui/src/components/inputs/ListboxInput/components/ListboxOption.tsx +++ b/packages/ui/src/components/inputs/ListboxInput/components/ListboxOption.tsx @@ -1,11 +1,11 @@ import { ListboxOption as HeadlessListboxOption } from '@headlessui/react' import { formatHex, parse } from 'culori' -import { Icon } from '@/components/primitives' import { Bordered, Box, Flex, + Icon, Text, Transition, WithDivide diff --git a/packages/ui/src/components/inputs/LocationInput/index.tsx b/packages/ui/src/components/inputs/LocationInput/index.tsx index ceb069652..3d99ca5b8 100644 --- a/packages/ui/src/components/inputs/LocationInput/index.tsx +++ b/packages/ui/src/components/inputs/LocationInput/index.tsx @@ -7,7 +7,6 @@ import { useAPIEndpoint } from '@lifeforge/shared' import { ComboboxInput, ComboboxOption } from '@/components/inputs' import type { InputVariants } from '@/components/inputs/shared/types' import { Box, Flex, Icon, Text } from '@/components/primitives' - import { forgeAPI } from '@/utils/forgeAPI' import { useInputLabel } from '../shared/hooks/useInputLabel' diff --git a/packages/ui/src/components/inputs/RRuleInput/RRuleInput.stories.tsx b/packages/ui/src/components/inputs/RRuleInput/RRuleInput.stories.tsx index 1f9ab04ec..74e348de3 100644 --- a/packages/ui/src/components/inputs/RRuleInput/RRuleInput.stories.tsx +++ b/packages/ui/src/components/inputs/RRuleInput/RRuleInput.stories.tsx @@ -2,7 +2,6 @@ import type { Meta, StoryObj } from '@storybook/react-vite' import { useState } from 'react' import { Text } from '@/components/primitives' - import { ScrollableStory } from '@/storybook/ScrollableStory' import { RRuleInput } from './index' diff --git a/packages/ui/src/components/inputs/SearchInput/SearchInput.stories.tsx b/packages/ui/src/components/inputs/SearchInput/SearchInput.stories.tsx index 23a4471ce..308aabb59 100644 --- a/packages/ui/src/components/inputs/SearchInput/SearchInput.stories.tsx +++ b/packages/ui/src/components/inputs/SearchInput/SearchInput.stories.tsx @@ -2,8 +2,7 @@ import type { StoryObj, Meta as _Meta } from '@storybook/react-vite' import { useQuery } from '@tanstack/react-query' import { useState } from 'react' -import { Icon } from '@/components/primitives' -import { Box, Flex, Text } from '@/components/primitives' +import { Box, Flex, Icon, Text } from '@/components/primitives' import { WithQuery } from '@/components/utilities' import { SearchInput } from './index' diff --git a/packages/ui/src/components/inputs/SliderInput/components/SliderHeader.tsx b/packages/ui/src/components/inputs/SliderInput/components/SliderHeader.tsx index 2392021e3..8137ead32 100644 --- a/packages/ui/src/components/inputs/SliderInput/components/SliderHeader.tsx +++ b/packages/ui/src/components/inputs/SliderInput/components/SliderHeader.tsx @@ -1,6 +1,5 @@ import { useInputLabel } from '@/components/inputs/shared/hooks/useInputLabel' -import { Icon } from '@/components/primitives' -import { Flex, Text } from '@/components/primitives' +import { Flex, Icon, Text } from '@/components/primitives' export function SliderHeader({ icon, diff --git a/packages/ui/src/components/inputs/SliderInput/index.tsx b/packages/ui/src/components/inputs/SliderInput/index.tsx index 6a675c154..279a6cf28 100644 --- a/packages/ui/src/components/inputs/SliderInput/index.tsx +++ b/packages/ui/src/components/inputs/SliderInput/index.tsx @@ -57,13 +57,13 @@ export function SliderInput({ > { onChange(parseFloat(e.target.value)) }} diff --git a/packages/ui/src/components/inputs/shared/components/InputActionButton.tsx b/packages/ui/src/components/inputs/shared/components/InputActionButton.tsx index ce868810f..61d66eefd 100644 --- a/packages/ui/src/components/inputs/shared/components/InputActionButton.tsx +++ b/packages/ui/src/components/inputs/shared/components/InputActionButton.tsx @@ -1,7 +1,6 @@ import { type ComponentPropsWithoutRef, type ReactNode } from 'react' -import { Icon } from '@/components/primitives' -import { Flex, Text, Transition } from '@/components/primitives' +import { Flex, Icon, Text, Transition } from '@/components/primitives' import type { InputVariant } from '../types' @@ -42,8 +41,8 @@ export function InputActionButton({ justify="center" p="sm" position="absolute" - right={hasError ? (variant === 'classic' ? '3em' : '2.5em') : '0'} r="lg" + right={hasError ? (variant === 'classic' ? '3em' : '2.5em') : '0'} style={{ // the `mr` props cannot be used since the 0.75rem value is required to be exact for the plain variant marginRight: variant === 'classic' ? '1em' : '0.75em', diff --git a/packages/ui/src/components/inputs/shared/components/InputLabel/index.tsx b/packages/ui/src/components/inputs/shared/components/InputLabel/index.tsx index b01df9085..4ae563c36 100644 --- a/packages/ui/src/components/inputs/shared/components/InputLabel/index.tsx +++ b/packages/ui/src/components/inputs/shared/components/InputLabel/index.tsx @@ -1,8 +1,7 @@ import clsx from 'clsx' import { type CSSProperties, memo } from 'react' -import { Icon } from '@/components/primitives' -import { Flex, Text, Transition } from '@/components/primitives' +import { Flex, Icon, Text, Transition } from '@/components/primitives' import { useInputFocused } from '../../contexts/InputFocusContext' import { diff --git a/packages/ui/src/components/inputs/shared/contexts/InputFocusContext.tsx b/packages/ui/src/components/inputs/shared/contexts/InputFocusContext.tsx index 37d91a2b7..84912e8e8 100644 --- a/packages/ui/src/components/inputs/shared/contexts/InputFocusContext.tsx +++ b/packages/ui/src/components/inputs/shared/contexts/InputFocusContext.tsx @@ -36,9 +36,9 @@ export function InputFocusProvider({ return ( } + style={{ display: 'contents' }} onBlur={handleBlur} onFocus={handleFocus} - style={{ display: 'contents' }} > {children} diff --git a/packages/ui/src/components/layout/ModuleWrapper/ModuleWrapper.stories.tsx b/packages/ui/src/components/layout/ModuleWrapper/ModuleWrapper.stories.tsx index fd8de290a..a7a365e0a 100644 --- a/packages/ui/src/components/layout/ModuleWrapper/ModuleWrapper.stories.tsx +++ b/packages/ui/src/components/layout/ModuleWrapper/ModuleWrapper.stories.tsx @@ -66,9 +66,9 @@ export const Default: Story = { diff --git a/packages/ui/src/components/navigation/Pagination/components/EllipsisIcon.tsx b/packages/ui/src/components/navigation/Pagination/components/EllipsisIcon.tsx index 5b33fce09..705dc34fd 100644 --- a/packages/ui/src/components/navigation/Pagination/components/EllipsisIcon.tsx +++ b/packages/ui/src/components/navigation/Pagination/components/EllipsisIcon.tsx @@ -1,7 +1,6 @@ import React from 'react' -import { Icon } from '@/components/primitives' -import { Text } from '@/components/primitives' +import { Icon, Text } from '@/components/primitives' export function EllipsisIcon() { return ( diff --git a/packages/ui/src/components/navigation/Tabs/Tabs.stories.tsx b/packages/ui/src/components/navigation/Tabs/Tabs.stories.tsx index 14a7efe66..1bab78ddf 100644 --- a/packages/ui/src/components/navigation/Tabs/Tabs.stories.tsx +++ b/packages/ui/src/components/navigation/Tabs/Tabs.stories.tsx @@ -2,7 +2,6 @@ import type { Meta, StoryObj } from '@storybook/react-vite' import { useState } from 'react' import { Box } from '@/components/primitives' - import { TAILWIND_PALETTE } from '@/system' import { Tabs } from '../Tabs' diff --git a/packages/ui/src/components/navigation/sidebar/SidebarItem/SidebarItem.stories.tsx b/packages/ui/src/components/navigation/sidebar/SidebarItem/SidebarItem.stories.tsx index 6e88cad15..634931379 100644 --- a/packages/ui/src/components/navigation/sidebar/SidebarItem/SidebarItem.stories.tsx +++ b/packages/ui/src/components/navigation/sidebar/SidebarItem/SidebarItem.stories.tsx @@ -4,7 +4,6 @@ import { BrowserRouter } from 'react-router' import { ContextMenuItem } from '@/components/overlays' import { Flex, Text } from '@/components/primitives' - import { TAILWIND_PALETTE } from '@/system' import { SidebarWrapper } from '../SidebarWrapper' diff --git a/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarActionButton.tsx b/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarActionButton.tsx index 3f997164d..7e8d6c9cb 100644 --- a/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarActionButton.tsx +++ b/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarActionButton.tsx @@ -1,7 +1,6 @@ import { useModuleSidebarState } from '@lifeforge/shared' -import { Icon } from '@/components/primitives' -import { Box, Transition } from '@/components/primitives' +import { Box, Icon, Transition } from '@/components/primitives' import * as styles from './SidebarActionButton.css' diff --git a/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarCancelButton.tsx b/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarCancelButton.tsx index b28021e01..e0350a6c4 100644 --- a/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarCancelButton.tsx +++ b/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarCancelButton.tsx @@ -1,7 +1,6 @@ import { useModuleSidebarState } from '@lifeforge/shared' -import { Icon } from '@/components/primitives' -import { Box, Text } from '@/components/primitives' +import { Box, Icon, Text } from '@/components/primitives' export function SidebarCancelButton({ onClick }: { onClick: () => void }) { const { setIsSidebarOpen } = useModuleSidebarState() diff --git a/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarItemIcon.tsx b/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarItemIcon.tsx index 3754b1809..120361afe 100644 --- a/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarItemIcon.tsx +++ b/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarItemIcon.tsx @@ -1,5 +1,4 @@ -import { Icon } from '@/components/primitives' -import { Bordered, Text } from '@/components/primitives' +import { Bordered, Icon, Text } from '@/components/primitives' export function SidebarItemIcon({ icon, diff --git a/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarItemSubsectionExpandIcon.tsx b/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarItemSubsectionExpandIcon.tsx index 6f7d1ae5f..0f7d3e8a7 100644 --- a/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarItemSubsectionExpandIcon.tsx +++ b/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarItemSubsectionExpandIcon.tsx @@ -1,5 +1,4 @@ -import { Icon } from '@/components/primitives' -import { Box, Text, Transition } from '@/components/primitives' +import { Box, Icon, Text, Transition } from '@/components/primitives' export function SidebarItemSubsectionExpandIcon({ toggleSubsection, diff --git a/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarSubsectionItemLink.tsx b/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarSubsectionItemLink.tsx index 01e7e0d56..8105c66ea 100644 --- a/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarSubsectionItemLink.tsx +++ b/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarSubsectionItemLink.tsx @@ -3,11 +3,9 @@ import _ from 'lodash' import { useCallback, useMemo } from 'react' import { useTranslation } from 'react-i18next' -import { Link, useLocation } from '@lifeforge/shared' -import { useMainSidebarState } from '@lifeforge/shared' +import { Link, useLocation, useMainSidebarState } from '@lifeforge/shared' -import { Icon } from '@/components/primitives' -import { Flex, Text } from '@/components/primitives' +import { Flex, Icon, Text } from '@/components/primitives' import * as styles from './SidebarSubsectionItemLink.css' diff --git a/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarSubsectionItemWithOnClick.tsx b/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarSubsectionItemWithOnClick.tsx index f59c81cea..154f5e646 100644 --- a/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarSubsectionItemWithOnClick.tsx +++ b/packages/ui/src/components/navigation/sidebar/SidebarItem/components/SidebarSubsectionItemWithOnClick.tsx @@ -5,8 +5,7 @@ import { useTranslation } from 'react-i18next' import { useModuleSidebarState } from '@lifeforge/shared' -import { Icon } from '@/components/primitives' -import { Flex, Text } from '@/components/primitives' +import { Flex, Icon, Text } from '@/components/primitives' import * as styles from './SidebarSubsectionItemWithOnClick.css' diff --git a/packages/ui/src/components/overlays/ContextMenu/components/ContextMenuGroup.tsx b/packages/ui/src/components/overlays/ContextMenu/components/ContextMenuGroup.tsx index f832c0a86..ddbd253eb 100644 --- a/packages/ui/src/components/overlays/ContextMenu/components/ContextMenuGroup.tsx +++ b/packages/ui/src/components/overlays/ContextMenu/components/ContextMenuGroup.tsx @@ -1,7 +1,6 @@ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu' -import { Icon } from '@/components/primitives' -import { Box, Flex, Text } from '@/components/primitives' +import { Box, Flex, Icon, Text } from '@/components/primitives' import * as styles from './ContextMenuGroup.css' diff --git a/packages/ui/src/components/overlays/ContextMenu/components/ContextMenuItem.tsx b/packages/ui/src/components/overlays/ContextMenu/components/ContextMenuItem.tsx index e73c58570..568ec629a 100644 --- a/packages/ui/src/components/overlays/ContextMenu/components/ContextMenuItem.tsx +++ b/packages/ui/src/components/overlays/ContextMenu/components/ContextMenuItem.tsx @@ -4,7 +4,6 @@ import _ from 'lodash' import { useTranslation } from 'react-i18next' import { Flex, Icon, Text } from '@/components/primitives' - import { vars } from '@/system' import * as styles from './ContextMenuItem.css' diff --git a/packages/ui/src/components/primitives/Box/Box.stories.tsx b/packages/ui/src/components/primitives/Box/Box.stories.tsx index 9b7db0e07..11eb8d668 100644 --- a/packages/ui/src/components/primitives/Box/Box.stories.tsx +++ b/packages/ui/src/components/primitives/Box/Box.stories.tsx @@ -291,8 +291,8 @@ export const Positioning: Story = { bottom="0" p="xs" position="absolute" - right="0" r="md" + right="0" style={{ margin: '0.5rem' }} > + return } if (error) { diff --git a/packages/ui/src/components/utilities/Tooltip/Tooltip.stories.tsx b/packages/ui/src/components/utilities/Tooltip/Tooltip.stories.tsx index b839ba74a..4183744ae 100644 --- a/packages/ui/src/components/utilities/Tooltip/Tooltip.stories.tsx +++ b/packages/ui/src/components/utilities/Tooltip/Tooltip.stories.tsx @@ -1,7 +1,6 @@ import type { Meta, StoryObj } from '@storybook/react-vite' -import { Icon } from '@/components/primitives' -import { Box, Flex, Text } from '@/components/primitives' +import { Box, Flex, Icon, Text } from '@/components/primitives' import { Tooltip } from './index' diff --git a/packages/ui/src/system/responsive/index.css.ts b/packages/ui/src/system/responsive/index.css.ts index 04c1ce0f8..c7f46892c 100644 --- a/packages/ui/src/system/responsive/index.css.ts +++ b/packages/ui/src/system/responsive/index.css.ts @@ -29,7 +29,11 @@ const RESPONSIVE_PROPS = [ { className: 'lf-gtr', property: 'gridTemplateRows', customProp: '--lf-gtr' }, { className: 'lf-zi', property: 'zIndex', customProp: '--lf-zi' }, { className: 'lf-rw', property: '--lf-ring-width', customProp: '--lf-rw' }, - { className: 'lf-row', property: '--lf-ring-offset-width', customProp: '--lf-row' } + { + className: 'lf-row', + property: '--lf-ring-offset-width', + customProp: '--lf-row' + } ] as const // Breakpoint media queries diff --git a/packages/ui/tsconfig.json b/packages/ui/tsconfig.json index 9fe09223a..6abd68c2e 100644 --- a/packages/ui/tsconfig.json +++ b/packages/ui/tsconfig.json @@ -4,18 +4,10 @@ "jsx": "react-jsx", "module": "esnext", "moduleResolution": "bundler", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], + "lib": ["dom", "dom.iterable", "esnext"], "paths": { - "@/components/*": [ - "./src/components/*" - ], - "@/*": [ - "./src/*" - ] + "@/components/*": ["./src/components/*"], + "@/*": ["./src/*"] }, "declaration": true, "declarationMap": true, @@ -28,8 +20,5 @@ "skipLibCheck": true, "verbatimModuleSyntax": true }, - "include": [ - "./src/**/*", - "./.storybook/*" - ] -} \ No newline at end of file + "include": ["./src/**/*", "./.storybook/*"] +} diff --git a/server/src/core/functions/database/PBService/index.ts b/server/src/core/functions/database/PBService/index.ts index d94bcf934..f0bf70c93 100644 --- a/server/src/core/functions/database/PBService/index.ts +++ b/server/src/core/functions/database/PBService/index.ts @@ -1,9 +1,8 @@ +import { createServiceLogger } from '@functions/logging' import PocketBase from 'pocketbase' import { CleanedSchemas, IPBService } from '@lifeforge/server-utils' -import { createServiceLogger } from '@functions/logging' - import create from './services/create' import deleteRecord from './services/delete' import getFirstListItem from './services/getFirstListItem' diff --git a/server/src/core/functions/database/PBService/services/create.ts b/server/src/core/functions/database/PBService/services/create.ts index 432c15cd4..3c7cf67c5 100644 --- a/server/src/core/functions/database/PBService/services/create.ts +++ b/server/src/core/functions/database/PBService/services/create.ts @@ -1,3 +1,4 @@ +import { toPocketBaseCollectionName } from '@functions/database/dbUtils' import chalk from 'chalk' import PocketBase from 'pocketbase' @@ -11,8 +12,6 @@ import { ICreateFactory } from '@lifeforge/server-utils' -import { toPocketBaseCollectionName } from '@functions/database/dbUtils' - import { PBLogger } from '..' import getFinalCollectionName from '../utils/getFinalCollectionName' diff --git a/server/src/core/functions/database/PBService/services/delete.ts b/server/src/core/functions/database/PBService/services/delete.ts index d8447f472..814cd387f 100644 --- a/server/src/core/functions/database/PBService/services/delete.ts +++ b/server/src/core/functions/database/PBService/services/delete.ts @@ -1,3 +1,4 @@ +import { toPocketBaseCollectionName } from '@functions/database/dbUtils' import chalk from 'chalk' import PocketBase from 'pocketbase' @@ -9,8 +10,6 @@ import { IDeleteFactory } from '@lifeforge/server-utils' -import { toPocketBaseCollectionName } from '@functions/database/dbUtils' - import { PBLogger } from '..' import getFinalCollectionName from '../utils/getFinalCollectionName' diff --git a/server/src/core/functions/database/PBService/services/getFirstListItem.ts b/server/src/core/functions/database/PBService/services/getFirstListItem.ts index a8db6c1fa..5a961b973 100644 --- a/server/src/core/functions/database/PBService/services/getFirstListItem.ts +++ b/server/src/core/functions/database/PBService/services/getFirstListItem.ts @@ -1,3 +1,4 @@ +import { toPocketBaseCollectionName } from '@functions/database/dbUtils' import chalk from 'chalk' import PocketBase from 'pocketbase' @@ -12,8 +13,6 @@ import { IGetFirstListItemFactory } from '@lifeforge/server-utils' -import { toPocketBaseCollectionName } from '@functions/database/dbUtils' - import { PBLogger } from '..' import getFinalCollectionName from '../utils/getFinalCollectionName' import { recursivelyBuildFilter } from '../utils/recursivelyConstructFilter' diff --git a/server/src/core/functions/database/PBService/services/getFullList.ts b/server/src/core/functions/database/PBService/services/getFullList.ts index 55de9076e..24e4dc330 100644 --- a/server/src/core/functions/database/PBService/services/getFullList.ts +++ b/server/src/core/functions/database/PBService/services/getFullList.ts @@ -1,3 +1,4 @@ +import { toPocketBaseCollectionName } from '@functions/database/dbUtils' import chalk from 'chalk' import PocketBase from 'pocketbase' @@ -12,8 +13,6 @@ import { IGetFullListFactory } from '@lifeforge/server-utils' -import { toPocketBaseCollectionName } from '@functions/database/dbUtils' - import { PBLogger } from '..' import getFinalCollectionName from '../utils/getFinalCollectionName' import { recursivelyBuildFilter } from '../utils/recursivelyConstructFilter' diff --git a/server/src/core/functions/database/PBService/services/getList.ts b/server/src/core/functions/database/PBService/services/getList.ts index 38f0867ca..8dd6199f8 100644 --- a/server/src/core/functions/database/PBService/services/getList.ts +++ b/server/src/core/functions/database/PBService/services/getList.ts @@ -1,3 +1,4 @@ +import { toPocketBaseCollectionName } from '@functions/database/dbUtils' import chalk from 'chalk' import PocketBase from 'pocketbase' @@ -13,8 +14,6 @@ import { IGetListReturnType } from '@lifeforge/server-utils' -import { toPocketBaseCollectionName } from '@functions/database/dbUtils' - import { PBLogger } from '..' import getFinalCollectionName from '../utils/getFinalCollectionName' import { recursivelyBuildFilter } from '../utils/recursivelyConstructFilter' diff --git a/server/src/core/functions/database/PBService/services/getOne.ts b/server/src/core/functions/database/PBService/services/getOne.ts index 96d89e81e..3ac582013 100644 --- a/server/src/core/functions/database/PBService/services/getOne.ts +++ b/server/src/core/functions/database/PBService/services/getOne.ts @@ -1,3 +1,4 @@ +import { toPocketBaseCollectionName } from '@functions/database/dbUtils' import chalk from 'chalk' import PocketBase from 'pocketbase' @@ -10,8 +11,6 @@ import { IGetOneFactory } from '@lifeforge/server-utils' -import { toPocketBaseCollectionName } from '@functions/database/dbUtils' - import { PBLogger } from '..' import getFinalCollectionName from '../utils/getFinalCollectionName' diff --git a/server/src/core/functions/database/PBService/services/update.ts b/server/src/core/functions/database/PBService/services/update.ts index fe4b32266..ccebf816b 100644 --- a/server/src/core/functions/database/PBService/services/update.ts +++ b/server/src/core/functions/database/PBService/services/update.ts @@ -1,3 +1,4 @@ +import { toPocketBaseCollectionName } from '@functions/database/dbUtils' import chalk from 'chalk' import PocketBase from 'pocketbase' @@ -11,8 +12,6 @@ import { IUpdateFactory } from '@lifeforge/server-utils' -import { toPocketBaseCollectionName } from '@functions/database/dbUtils' - import { PBLogger } from '..' import getFinalCollectionName from '../utils/getFinalCollectionName' diff --git a/server/src/core/functions/database/getAPIKey.ts b/server/src/core/functions/database/getAPIKey.ts index 35229fb00..28cb13bce 100644 --- a/server/src/core/functions/database/getAPIKey.ts +++ b/server/src/core/functions/database/getAPIKey.ts @@ -1,13 +1,12 @@ import { ROOT_DIR } from '@constants' +import { decrypt2 } from '@functions/auth/encryption' +import { createServiceLogger } from '@functions/logging' import chalk from 'chalk' import fs from 'fs' import path from 'path' import { IPBService } from '@lifeforge/server-utils' -import { decrypt2 } from '@functions/auth/encryption' -import { createServiceLogger } from '@functions/logging' - import PBService from './PBService' const logger = createServiceLogger('API Key Vault') diff --git a/server/src/core/functions/encryption/constants.ts b/server/src/core/functions/encryption/constants.ts index 5fb629028..6b1d0edbf 100644 --- a/server/src/core/functions/encryption/constants.ts +++ b/server/src/core/functions/encryption/constants.ts @@ -1,7 +1,6 @@ import { ROOT_DIR } from '@constants' -import path from 'path' - import { createServiceLogger } from '@functions/logging' +import path from 'path' // Key storage paths export const KEYS_DIR = path.join(ROOT_DIR, 'keys') diff --git a/server/src/core/functions/external/ai.ts b/server/src/core/functions/external/ai.ts index 1546ca715..e21f7e9d8 100644 --- a/server/src/core/functions/external/ai.ts +++ b/server/src/core/functions/external/ai.ts @@ -1,3 +1,7 @@ +import { getAPIKey } from '@functions/database' +import { validateCallerAccess } from '@functions/database/getAPIKey' +import { createServiceLogger } from '@functions/logging' +import { zodTextFormat } from '@functions/utils/zodResponseFormat' import chalk from 'chalk' import Groq from 'groq-sdk' import { ChatCompletionMessageParam as GroqChatCompletionMessageParam } from 'groq-sdk/resources/chat/completions.mjs' @@ -10,11 +14,6 @@ import { getCallerModuleId } from '@lifeforge/server-utils' -import { getAPIKey } from '@functions/database' -import { validateCallerAccess } from '@functions/database/getAPIKey' -import { createServiceLogger } from '@functions/logging' -import { zodTextFormat } from '@functions/utils/zodResponseFormat' - const logger = createServiceLogger('AI') const fetchAI: FetchAIFunc = async ({ diff --git a/server/src/core/functions/initialization/ensureCredentials.ts b/server/src/core/functions/initialization/ensureCredentials.ts index 02361fcf7..29d0a10e3 100644 --- a/server/src/core/functions/initialization/ensureCredentials.ts +++ b/server/src/core/functions/initialization/ensureCredentials.ts @@ -1,9 +1,8 @@ import { ROOT_DIR } from '@constants' -import dotenv from 'dotenv' -import path from 'path' - import { ensureKeysExist } from '@functions/encryption' import { coreLogger } from '@functions/logging' +import dotenv from 'dotenv' +import path from 'path' export default function ensureCredentials(): void { dotenv.config({ diff --git a/server/src/core/functions/initialization/localeService.ts b/server/src/core/functions/initialization/localeService.ts index 454052d6c..0b380e281 100644 --- a/server/src/core/functions/initialization/localeService.ts +++ b/server/src/core/functions/initialization/localeService.ts @@ -1,11 +1,10 @@ import { ROOT_DIR } from '@constants' +import { createServiceLogger } from '@functions/logging' import chalk from 'chalk' import fs from 'fs' import path from 'path' import z from 'zod' -import { createServiceLogger } from '@functions/logging' - const localeLogger = createServiceLogger('Locale') export const ALLOWED_NAMESPACE = ['apps', 'common'] as const diff --git a/server/src/core/functions/modules/loadModuleRoutes.ts b/server/src/core/functions/modules/loadModuleRoutes.ts index 06d94ec6f..f7635d690 100644 --- a/server/src/core/functions/modules/loadModuleRoutes.ts +++ b/server/src/core/functions/modules/loadModuleRoutes.ts @@ -1,11 +1,10 @@ import { ROOT_DIR } from '@constants' +import { createServiceLogger } from '@functions/logging' import chalk from 'chalk' import fs from 'fs' import _ from 'lodash' import path from 'path' -import { createServiceLogger } from '@functions/logging' - const IS_PRODUCTION = process.env.NODE_ENV === 'production' const logger = createServiceLogger('Route Loader') diff --git a/server/src/core/functions/routes/functions/controllerLogic.ts b/server/src/core/functions/routes/functions/controllerLogic.ts index 66920d9fd..226ffbd80 100755 --- a/server/src/core/functions/routes/functions/controllerLogic.ts +++ b/server/src/core/functions/routes/functions/controllerLogic.ts @@ -13,6 +13,8 @@ * The main export is: * - `registerController`: Function to register a ForgeControllerBuilder with an Express router */ +import { encryptResponse } from '@functions/encryption' +import { coreLogger } from '@functions/logging' import type { Request, Response, Router } from 'express' import { @@ -24,9 +26,6 @@ import { MediaConfig } from '@lifeforge/server-utils' -import { encryptResponse } from '@functions/encryption' -import { coreLogger } from '@functions/logging' - import checkRecordExistence from '../utils/checkRecordExistence' import { createCoreContext } from '../utils/coreContext' import getAESKey from '../utils/getAESKey' @@ -89,7 +88,6 @@ function createHandler< const aesKey = getAESKey(req, res, encrypted, callerModuleId) - try { parseQuery(req, schema.query) diff --git a/server/src/core/functions/routes/utils/checkRecordExistence.ts b/server/src/core/functions/routes/utils/checkRecordExistence.ts index 6b900d306..9d02acf96 100644 --- a/server/src/core/functions/routes/utils/checkRecordExistence.ts +++ b/server/src/core/functions/routes/utils/checkRecordExistence.ts @@ -1,10 +1,9 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ +import { PBService, checkExistence } from '@functions/database' import { Request } from 'express' import { ClientError } from '@lifeforge/server-utils' -import { PBService, checkExistence } from '@functions/database' - async function check( pb: PBService, collection: string, diff --git a/server/src/core/functions/routes/utils/coreContext.ts b/server/src/core/functions/routes/utils/coreContext.ts index 90343eecb..d83710a8f 100644 --- a/server/src/core/functions/routes/utils/coreContext.ts +++ b/server/src/core/functions/routes/utils/coreContext.ts @@ -4,9 +4,6 @@ * This module provides the implementation of core utilities that modules * access via the `core` parameter in their callbacks. */ -import { type Logger, createLogger } from '@lifeforge/log' -import { CoreContext, IPBService } from '@lifeforge/server-utils' - import { decrypt, decrypt2, @@ -28,6 +25,9 @@ import { import { checkModulesAvailability } from '@functions/utils/checkModulesAvailability' import TempFileManager from '@functions/utils/tempFileManager' +import { type Logger, createLogger } from '@lifeforge/log' +import { CoreContext, IPBService } from '@lifeforge/server-utils' + // Cache loggers per module to avoid creating new file stream listeners per request const loggerCache = new Map() diff --git a/server/src/core/functions/routes/utils/getAESKey.ts b/server/src/core/functions/routes/utils/getAESKey.ts index 32f888826..5f552005f 100644 --- a/server/src/core/functions/routes/utils/getAESKey.ts +++ b/server/src/core/functions/routes/utils/getAESKey.ts @@ -1,6 +1,5 @@ -import { Request, Response } from 'express' - import { decryptAESKey } from '@functions/encryption' +import { Request, Response } from 'express' import { clientError } from './response' diff --git a/server/src/core/functions/routes/utils/splitMediaAndData.ts b/server/src/core/functions/routes/utils/splitMediaAndData.ts index 35260df10..a56d73acf 100644 --- a/server/src/core/functions/routes/utils/splitMediaAndData.ts +++ b/server/src/core/functions/routes/utils/splitMediaAndData.ts @@ -1,9 +1,8 @@ +import { coreLogger } from '@functions/logging' import chalk from 'chalk' import { MediaConfig } from '@lifeforge/server-utils' -import { coreLogger } from '@functions/logging' - type MediaResponse = Record< string, Express.Multer.File | Express.Multer.File[] | undefined diff --git a/server/src/core/functions/routes/utils/validateAuthToken.ts b/server/src/core/functions/routes/utils/validateAuthToken.ts index 4b0b92a42..c8ecb4d80 100644 --- a/server/src/core/functions/routes/utils/validateAuthToken.ts +++ b/server/src/core/functions/routes/utils/validateAuthToken.ts @@ -1,8 +1,7 @@ +import { PBService } from '@functions/database' import { Request, Response } from 'express' import Pocketbase from 'pocketbase' -import { PBService } from '@functions/database' - export default async function isAuthTokenValid( req: Request, res: Response, diff --git a/server/src/core/functions/socketio/setupSocket.ts b/server/src/core/functions/socketio/setupSocket.ts index fc05ea4a6..49fb1414e 100644 --- a/server/src/core/functions/socketio/setupSocket.ts +++ b/server/src/core/functions/socketio/setupSocket.ts @@ -1,8 +1,7 @@ +import { globalTaskPool } from '@functions/socketio/taskPool' import Pocketbase from 'pocketbase' import { Server } from 'socket.io' -import { globalTaskPool } from '@functions/socketio/taskPool' - export function setupSocket(io: Server) { // QR Login namespace - no authentication required // This allows unauthenticated desktop clients to listen for login approval diff --git a/server/src/core/middlewares/morganMiddleware.ts b/server/src/core/middlewares/morganMiddleware.ts index a3e099169..02844d48d 100755 --- a/server/src/core/middlewares/morganMiddleware.ts +++ b/server/src/core/middlewares/morganMiddleware.ts @@ -1,9 +1,8 @@ +import { coreLogger } from '@functions/logging' import chalk from 'chalk' import { Request, Response } from 'express' import morgan from 'morgan' -import { coreLogger } from '@functions/logging' - const METHOD_COLOR = { GET: '#34ace0', POST: '#2ed573' diff --git a/server/src/core/routes/core.routes.ts b/server/src/core/routes/core.routes.ts index 809438199..e3b1c5ed1 100644 --- a/server/src/core/routes/core.routes.ts +++ b/server/src/core/routes/core.routes.ts @@ -103,5 +103,4 @@ const coreRoutes = forgeRouter({ encryptionPublicKey }) - export default coreRoutes diff --git a/server/src/core/routes/index.ts b/server/src/core/routes/index.ts index 215371301..6ccdd8d12 100644 --- a/server/src/core/routes/index.ts +++ b/server/src/core/routes/index.ts @@ -1,13 +1,12 @@ import { ROOT_DIR } from '@constants' -import express from 'express' -import path from 'path' - -import { forgeRouter } from '@lifeforge/server-utils' - import traceRouteStack from '@functions/initialization/traceRouteStack' import { loadModuleRoutes } from '@functions/modules/loadModuleRoutes' import { registerRoutes } from '@functions/routes/functions/forgeRouter' import { clientError } from '@functions/routes/utils/response' +import express from 'express' +import path from 'path' + +import { forgeRouter } from '@lifeforge/server-utils' import coreRoutes from './core.routes' import forge from './forge' diff --git a/server/src/index.ts b/server/src/index.ts index 1bddb6b9a..865956729 100755 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -1,15 +1,14 @@ import { PORT } from '@constants' -import chalk from 'chalk' -import { program } from 'commander' -import fs from 'fs' -import { createServer } from 'node:http' - import checkDB from '@functions/database/dbUtils' import ensureCredentials from '@functions/initialization/ensureCredentials' import { LocaleService } from '@functions/initialization/localeService' import traceRouteStack from '@functions/initialization/traceRouteStack' import { LOG_LEVELS, type LogLevel, coreLogger } from '@functions/logging' import createSocketServer from '@functions/socketio/createSocketServer' +import chalk from 'chalk' +import { program } from 'commander' +import fs from 'fs' +import { createServer } from 'node:http' import app from './core/app' diff --git a/server/src/lib/backups/index.ts b/server/src/lib/backups/index.ts index ca1e29e38..b501a408d 100644 --- a/server/src/lib/backups/index.ts +++ b/server/src/lib/backups/index.ts @@ -1,12 +1,11 @@ -import dayjs from 'dayjs' -import z from 'zod' - -import { createForge, forgeRouter } from '@lifeforge/server-utils' - import { connectToPocketBase, validateEnvironmentVariables } from '@functions/database/dbUtils' +import dayjs from 'dayjs' +import z from 'zod' + +import { createForge, forgeRouter } from '@lifeforge/server-utils' const forge = createForge({}, 'backups') diff --git a/server/src/lib/database/routes/collections.ts b/server/src/lib/database/routes/collections.ts index ef5d1c0b3..d7c21f19d 100644 --- a/server/src/lib/database/routes/collections.ts +++ b/server/src/lib/database/routes/collections.ts @@ -1,10 +1,10 @@ -import { createForge, forgeRouter } from '@lifeforge/server-utils' - import { connectToPocketBase, validateEnvironmentVariables } from '@functions/database/dbUtils' +import { createForge, forgeRouter } from '@lifeforge/server-utils' + const forge = createForge({}, 'database') const list = forge diff --git a/server/src/lib/locales/index.ts b/server/src/lib/locales/index.ts index f09cbd3b6..921173d4b 100644 --- a/server/src/lib/locales/index.ts +++ b/server/src/lib/locales/index.ts @@ -1,4 +1,8 @@ import { ROOT_DIR } from '@constants' +import { + ALLOWED_NAMESPACE, + LocaleService +} from '@functions/initialization/localeService' import chalk from 'chalk' import fs from 'fs' import path from 'path' @@ -7,11 +11,6 @@ import z from 'zod' import { ClientError, createForge, forgeRouter } from '@lifeforge/server-utils' import { normalizeSubnamespace } from '@lifeforge/shared' -import { - ALLOWED_NAMESPACE, - LocaleService -} from '@functions/initialization/localeService' - const forge = createForge({}, 'locales') // Scan apps directory for modules with locales diff --git a/server/src/lib/locations/index.ts b/server/src/lib/locations/index.ts index f2b0fda2e..c3ed39e4b 100644 --- a/server/src/lib/locations/index.ts +++ b/server/src/lib/locations/index.ts @@ -1,9 +1,8 @@ +import searchLocations from '@functions/external/location' import z from 'zod' import { ClientError, createForge, forgeRouter } from '@lifeforge/server-utils' -import searchLocations from '@functions/external/location' - const forge = createForge({}, 'locations') const search = forge diff --git a/server/src/lib/user/index.ts b/server/src/lib/user/index.ts index 95469c6ab..74752275f 100755 --- a/server/src/lib/user/index.ts +++ b/server/src/lib/user/index.ts @@ -1,10 +1,10 @@ -import { forgeRouter } from '@lifeforge/server-utils' - import { connectToPocketBase, validateEnvironmentVariables } from '@functions/database/dbUtils' +import { forgeRouter } from '@lifeforge/server-utils' + import forge from './forge' import * as authRoutes from './routes/auth' import * as customFontsRoutes from './routes/customFonts' diff --git a/server/src/lib/user/routes/auth.ts b/server/src/lib/user/routes/auth.ts index fcd054ae0..8fdb57bb4 100644 --- a/server/src/lib/user/routes/auth.ts +++ b/server/src/lib/user/routes/auth.ts @@ -1,3 +1,8 @@ +import { default as _validateOTP } from '@functions/auth/validateOTP' +import { + connectToPocketBase, + validateEnvironmentVariables +} from '@functions/database/dbUtils' import dayjs from 'dayjs' import PocketBase from 'pocketbase' import { v4 } from 'uuid' @@ -5,12 +10,6 @@ import z from 'zod' import { ClientError } from '@lifeforge/server-utils' -import { default as _validateOTP } from '@functions/auth/validateOTP' -import { - connectToPocketBase, - validateEnvironmentVariables -} from '@functions/database/dbUtils' - import { currentSession } from '..' import forge from '../forge' import { removeSensitiveData, updateNullData } from '../utils/auth' diff --git a/server/src/lib/user/utils/otp.ts b/server/src/lib/user/utils/otp.ts index 2e9f955ee..67fade738 100644 --- a/server/src/lib/user/utils/otp.ts +++ b/server/src/lib/user/utils/otp.ts @@ -1,8 +1,7 @@ +import { decrypt } from '@functions/auth/encryption' import PocketBase from 'pocketbase' import speakeasy from 'speakeasy' -import { decrypt } from '@functions/auth/encryption' - import { currentSession } from '..' export const verifyAppOTP = async ( diff --git a/shared/src/providers/APIOnlineStatusProvider.tsx b/shared/src/providers/APIOnlineStatusProvider.tsx index 016aecac2..331ed52fa 100644 --- a/shared/src/providers/APIOnlineStatusProvider.tsx +++ b/shared/src/providers/APIOnlineStatusProvider.tsx @@ -17,22 +17,23 @@ async function checkAPIStatus( controller.abort() }, 5000) - return await fetch(`${apiEndpoint}/status`, { - signal: controller.signal - }) - .then(async res => { - if (res.ok) { - const data: any = await res.json() - - return data.data.environment - } - - return false - }) - .catch(() => false) - .finally(() => { - clearTimeout(timeoutId) + try { + const res = await fetch(`${apiEndpoint}/status`, { + signal: controller.signal }) + + if (res.ok) { + const data: any = await res.json() + + return data.data.environment + } + + return false + } catch (err) { + return false + } finally { + clearTimeout(timeoutId) + } } interface IAPIOnlineStatus { @@ -70,10 +71,11 @@ export default function APIOnlineStatusProvider({ setEnvironment(status === false ? null : status) setIsOnline(status !== false) }) - .catch(() => { + .catch(err => { + console.error(err) setIsOnline(false) }) - }, []) + }, [apiEndpoint]) useEffect(() => { handleRetry() diff --git a/shared/src/providers/PersonalizationProvider/hooks/useLanguageEffect.tsx b/shared/src/providers/PersonalizationProvider/hooks/useLanguageEffect.tsx index 887c0096b..2ef86b9e4 100644 --- a/shared/src/providers/PersonalizationProvider/hooks/useLanguageEffect.tsx +++ b/shared/src/providers/PersonalizationProvider/hooks/useLanguageEffect.tsx @@ -1,10 +1,8 @@ import { useEffect } from 'react' -import { useTranslation } from 'react-i18next' +import i18n from 'i18next' import { toast } from 'react-toastify' function useLanguageEffect(language: string) { - const { i18n } = useTranslation() - useEffect(() => { if (!i18n || !i18n.changeLanguage) { console.error('i18n instance is not available') @@ -12,10 +10,12 @@ function useLanguageEffect(language: string) { return } - i18n.changeLanguage(language).catch(() => { - toast.error('Failed to change language.') - }) - }, [language, i18n]) + if (i18n.isInitialized && i18n.language !== language) { + i18n.changeLanguage(language).catch(() => { + toast.error('Failed to change language.') + }) + } + }, [language]) } export default useLanguageEffect diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index 2a986e0f7..78683fe83 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -12,4 +12,4 @@ "tools/src", "tools/scripts" ] -} \ No newline at end of file +}