From 0033625866905d147c3ad64715103f4d93c54bba Mon Sep 17 00:00:00 2001 From: chenhang Date: Tue, 14 Jul 2026 18:13:55 +0800 Subject: [PATCH] perf(bundle): replace broad storage and utils imports --- docs/performance-baseline.md | 17 ++++++++++++----- src/app/_hooks/use-payment-launch-flow.ts | 3 ++- src/app/auth/auth-screen.tsx | 2 +- .../components/auth-other-options-dialog.tsx | 2 +- src/app/auth/components/email-login-form.tsx | 3 ++- src/app/auth/components/email-register-form.tsx | 2 +- src/app/chat/chat-screen.helpers.ts | 3 ++- src/app/chat/components/chat-input-bar.tsx | 2 +- src/app/chat/components/pwa-install-overlay.tsx | 2 +- .../chat/hooks/use-chat-promotion-bootstrap.ts | 2 +- src/app/error.tsx | 2 +- .../external-entry/external-entry-persist.tsx | 2 +- src/app/sidebar/use-pwa-install-entry.ts | 2 +- .../splash/hooks/use-splash-latest-message.ts | 3 ++- src/app/splash/splash-screen.tsx | 2 +- .../components/stripe-payment-dialog.tsx | 2 +- .../components/subscription-checkout-button.tsx | 2 +- src/app/tip/tip-checkout-button.tsx | 2 +- src/core/net/chat-websocket.ts | 3 ++- src/core/net/config/api_config.ts | 2 +- .../net/interceptor/auth_refresh_interceptor.ts | 4 +++- src/core/net/interceptor/logging_interceptor.ts | 3 ++- src/core/net/interceptor/token_interceptor.ts | 2 +- src/core/net/message-queue.ts | 2 +- .../auth_repository.facebook_identity.test.ts | 2 +- .../__tests__/auth_repository.session.test.ts | 2 +- .../__tests__/chat_cache_identity.test.ts | 2 +- .../__tests__/chat_local_message_store.test.ts | 2 +- .../chat_media_cache_coordinator.test.ts | 2 +- .../__tests__/payment_repository.test.ts | 2 +- src/data/repositories/auth_repository.ts | 12 +++++------- src/data/repositories/chat_cache_identity.ts | 2 +- .../repositories/chat_local_message_store.ts | 2 +- .../chat_media_cache_coordinator.ts | 3 ++- .../repositories/chat_remote_data_source.ts | 2 +- src/data/repositories/chat_repository.ts | 2 +- .../repositories/interfaces/iauth_repository.ts | 2 +- .../repositories/interfaces/ichat_repository.ts | 2 +- .../interfaces/imetrics_repository.ts | 2 +- .../repositories/interfaces/iuser_repository.ts | 2 +- src/data/repositories/metrics_repository.ts | 2 +- src/data/repositories/user_repository.ts | 2 +- .../services/api/__tests__/http_client.test.ts | 4 +++- src/data/services/api/auth_api.ts | 2 +- src/data/services/facebook-graph.ts | 3 ++- .../storage/__tests__/storage_migration.test.ts | 2 +- src/data/storage/app/app_storage.ts | 3 ++- src/data/storage/auth/auth_storage.ts | 3 ++- src/data/storage/auth/iauth_storage.ts | 2 +- .../storage/chat/local_chat_media_storage.ts | 2 +- src/data/storage/chat/local_chat_storage.ts | 2 +- .../__tests__/navigation_storage.test.ts | 2 +- .../storage/navigation/navigation_storage.ts | 3 ++- .../storage/payment/payment_plans_storage.ts | 3 ++- .../payment/pending_payment_order_storage.ts | 3 ++- src/data/storage/storage_migration.ts | 3 ++- .../storage/user/__tests__/user_storage.test.ts | 2 +- src/data/storage/user/iuser_storage.ts | 2 +- src/data/storage/user/user_storage.ts | 3 ++- src/hooks/use-keyboard-height/environment.ts | 3 ++- src/hooks/use-keyboard-height/index.ts | 2 +- src/integrations/media-recorder.ts | 2 +- src/lib/auth/__tests__/auth_session.test.ts | 2 +- src/lib/browser/persistent_storage.ts | 2 +- .../__tests__/splash_latest_message.test.ts | 2 +- src/lib/chat/chat_external_browser.ts | 2 +- src/lib/chat/chat_media_cache_client.ts | 2 +- src/lib/chat/splash_latest_message.ts | 2 +- src/lib/chat/use_cached_chat_media_url.ts | 5 ++++- src/lib/payment/payment_launch.ts | 3 ++- src/lib/payment/pending_payment_order.ts | 4 ++-- src/providers/viewport-css-vars-provider.tsx | 4 +++- src/stores/auth/auth-actors.ts | 4 +++- src/stores/auth/auth-status-checker.tsx | 4 ++-- src/stores/chat/chat-history-flow.ts | 2 +- src/stores/chat/chat-history-sync.ts | 4 +++- src/stores/chat/chat-media-flow.ts | 3 ++- src/stores/chat/chat-message-mappers.ts | 2 +- src/stores/chat/chat-promotion.ts | 2 +- src/stores/chat/chat-send-flow.ts | 4 +++- src/stores/chat/chat-unlock-flow.ts | 3 ++- src/stores/payment/payment-machine.actors.ts | 2 +- .../private-room/private-room-machine.actors.ts | 2 +- src/stores/user/user-machine.actors.ts | 2 +- src/stores/user/user-machine.helpers.ts | 2 +- 85 files changed, 136 insertions(+), 97 deletions(-) diff --git a/docs/performance-baseline.md b/docs/performance-baseline.md index c742f9ba..9f79f6bc 100644 --- a/docs/performance-baseline.md +++ b/docs/performance-baseline.md @@ -24,12 +24,19 @@ The command uses the built-in Next.js Turbopack analyzer and writes: Compressed sizes below are Turbopack module estimates. `Eager` is the route's synchronous client graph; `async` is code behind at least one dynamic import. -| Route | Eager before | Eager baseline | Change | Async baseline | +| Route | Before direct imports | Eager baseline | Change | Async baseline | | --- | ---: | ---: | ---: | ---: | -| `/splash` | 644.4 KiB | 644.4 KiB | 0.0 KiB | 14.3 KiB | -| `/chat` | 666.2 KiB | 666.2 KiB | 0.0 KiB | 14.7 KiB | -| `/subscription` | 660.7 KiB | 657.0 KiB | -3.7 KiB | 20.7 KiB | -| `/tip` | 653.9 KiB | 650.4 KiB | -3.5 KiB | 20.7 KiB | +| `/splash` | 647.2 KiB | 646.2 KiB | -1.0 KiB | 14.3 KiB | +| `/chat` | 670.5 KiB | 669.8 KiB | -0.7 KiB | 14.7 KiB | +| `/subscription` | 660.1 KiB | 658.4 KiB | -1.7 KiB | 20.6 KiB | +| `/tip` | 653.3 KiB | 651.6 KiB | -1.7 KiB | 20.6 KiB | + +The direct-import pass replaces root `@/utils` and `@/data/storage` barrel +imports with symbol-level module paths. Turbopack already eliminated most unused +barrel exports, so the immediate size reduction is modest. The explicit paths +keep future barrel exports from silently expanding the client graph. Dexie and +UA Parser remain in the analyzed routes through active feature dependencies and +require separate feature-boundary work to remove from the eager graph. Module loading baseline: diff --git a/src/app/_hooks/use-payment-launch-flow.ts b/src/app/_hooks/use-payment-launch-flow.ts index d721cc74..6e3722cb 100644 --- a/src/app/_hooks/use-payment-launch-flow.ts +++ b/src/app/_hooks/use-payment-launch-flow.ts @@ -18,7 +18,8 @@ import type { PaymentContextState, } from "@/stores/payment/payment-context"; import type { PaymentEvent } from "@/stores/payment/payment-events"; -import { AppEnvUtil, Logger } from "@/utils"; +import { AppEnvUtil } from "@/utils/app-env"; +import { Logger } from "@/utils/logger"; const UNSUPPORTED_PAYMENT_PARAMS_MESSAGE = "Payment parameters did not include a supported URL or Stripe client secret."; diff --git a/src/app/auth/auth-screen.tsx b/src/app/auth/auth-screen.tsx index 29bc9461..164a229c 100644 --- a/src/app/auth/auth-screen.tsx +++ b/src/app/auth/auth-screen.tsx @@ -13,7 +13,7 @@ import { ROUTES } from "@/router/routes"; import { useAppNavigator } from "@/router/use-app-navigator"; import { AuthBackground, AuthPanel } from "./components"; -import { Logger } from "@/utils"; +import { Logger } from "@/utils/logger"; const log = new Logger("AppAuthAuthScreen"); diff --git a/src/app/auth/components/auth-other-options-dialog.tsx b/src/app/auth/components/auth-other-options-dialog.tsx index 81287bc3..6ad992ae 100644 --- a/src/app/auth/components/auth-other-options-dialog.tsx +++ b/src/app/auth/components/auth-other-options-dialog.tsx @@ -3,7 +3,7 @@ import type { ReactNode } from "react"; import { MdEmail } from "react-icons/md"; import { BottomSheet } from "@/app/_components/core/bottom-sheet"; -import { AppEnvUtil } from "@/utils"; +import { AppEnvUtil } from "@/utils/app-env"; import { AuthProviderIcon } from "./auth-provider-icon"; import { AuthSocialButton } from "./auth-social-button"; diff --git a/src/app/auth/components/email-login-form.tsx b/src/app/auth/components/email-login-form.tsx index c837e1e7..74e1b488 100644 --- a/src/app/auth/components/email-login-form.tsx +++ b/src/app/auth/components/email-login-form.tsx @@ -13,7 +13,8 @@ import { import { AuthTextField } from "./auth-text-field"; import { AuthPrimaryButton } from "./auth-primary-button"; import { AuthErrorMessage } from "./auth-error-message"; -import { AppEnvUtil, Logger } from "@/utils"; +import { AppEnvUtil } from "@/utils/app-env"; +import { Logger } from "@/utils/logger"; const log = new Logger("AppAuthComponentsEmailLoginForm"); const NON_PRODUCTION_DEFAULT_EMAIL = "chanwillian0@gmail.com"; diff --git a/src/app/auth/components/email-register-form.tsx b/src/app/auth/components/email-register-form.tsx index fb0aa0d9..9b687a1c 100644 --- a/src/app/auth/components/email-register-form.tsx +++ b/src/app/auth/components/email-register-form.tsx @@ -24,7 +24,7 @@ import { import { AuthTextField } from "./auth-text-field"; import { AuthPrimaryButton } from "./auth-primary-button"; import { AuthErrorMessage } from "./auth-error-message"; -import { Logger } from "@/utils"; +import { Logger } from "@/utils/logger"; const log = new Logger("AppAuthComponentsEmailRegisterForm"); diff --git a/src/app/chat/chat-screen.helpers.ts b/src/app/chat/chat-screen.helpers.ts index ed3f258a..c932d89e 100644 --- a/src/app/chat/chat-screen.helpers.ts +++ b/src/app/chat/chat-screen.helpers.ts @@ -2,7 +2,8 @@ import type { LoginStatus } from "@/data/dto/auth"; import type { ChatUpgradeReason } from "@/stores/chat/chat-state"; -import { AppEnvUtil, BrowserDetector } from "@/utils"; +import { AppEnvUtil } from "@/utils/app-env"; +import { BrowserDetector } from "@/utils/browser-detect"; export interface ExternalBrowserPromptState { hasInitialized: boolean; diff --git a/src/app/chat/components/chat-input-bar.tsx b/src/app/chat/components/chat-input-bar.tsx index b197f94a..a7a42481 100644 --- a/src/app/chat/components/chat-input-bar.tsx +++ b/src/app/chat/components/chat-input-bar.tsx @@ -3,7 +3,7 @@ import { useRef, useState } from "react"; import { useChatDispatch } from "@/stores/chat/chat-context"; import { useKeyboardHeight } from "@/hooks"; -import { Logger } from "@/utils"; +import { Logger } from "@/utils/logger"; import { ChatInputTextField } from "./chat-input-text-field"; import { ChatSendButton } from "./chat-send-button"; diff --git a/src/app/chat/components/pwa-install-overlay.tsx b/src/app/chat/components/pwa-install-overlay.tsx index 186e450c..c7571fb4 100644 --- a/src/app/chat/components/pwa-install-overlay.tsx +++ b/src/app/chat/components/pwa-install-overlay.tsx @@ -19,7 +19,7 @@ import { canShowPwaInstallPromptOnce, recordPwaInstallPromptShown, } from "@/lib/chat/pwa_install_prompt"; -import { pwaUtil } from "@/utils"; +import { pwaUtil } from "@/utils/pwa"; import { PwaInstallDialog } from "./pwa-install-dialog"; diff --git a/src/app/chat/hooks/use-chat-promotion-bootstrap.ts b/src/app/chat/hooks/use-chat-promotion-bootstrap.ts index d553d0db..39dc57d4 100644 --- a/src/app/chat/hooks/use-chat-promotion-bootstrap.ts +++ b/src/app/chat/hooks/use-chat-promotion-bootstrap.ts @@ -7,7 +7,7 @@ import { peekPendingChatUnlock, } from "@/lib/navigation/chat_unlock_session"; import { useChatDispatch } from "@/stores/chat/chat-context"; -import { Logger } from "@/utils"; +import { Logger } from "@/utils/logger"; const log = new Logger("UseChatPromotionBootstrap"); diff --git a/src/app/error.tsx b/src/app/error.tsx index fe4d4948..2279de03 100644 --- a/src/app/error.tsx +++ b/src/app/error.tsx @@ -15,7 +15,7 @@ import Link from "next/link"; import { ExceptionHandler } from "@/core/errors"; import { ROUTES } from "@/router/routes"; -import { Logger } from "@/utils"; +import { Logger } from "@/utils/logger"; const log = new Logger("AppError"); diff --git a/src/app/external-entry/external-entry-persist.tsx b/src/app/external-entry/external-entry-persist.tsx index fa158394..6f8ecdb6 100644 --- a/src/app/external-entry/external-entry-persist.tsx +++ b/src/app/external-entry/external-entry-persist.tsx @@ -15,7 +15,7 @@ import { savePendingChatPromotion, } from "@/lib/navigation/chat_unlock_session"; import { ROUTES } from "@/router/routes"; -import { Logger } from "@/utils"; +import { Logger } from "@/utils/logger"; import { useAuthDispatch, useAuthState } from "@/stores/auth/auth-context"; const log = new Logger("ExternalEntryPersist"); diff --git a/src/app/sidebar/use-pwa-install-entry.ts b/src/app/sidebar/use-pwa-install-entry.ts index bdbdabe5..6a8b7c05 100644 --- a/src/app/sidebar/use-pwa-install-entry.ts +++ b/src/app/sidebar/use-pwa-install-entry.ts @@ -2,7 +2,7 @@ import { useEffect, useState } from "react"; -import { pwaUtil } from "@/utils"; +import { pwaUtil } from "@/utils/pwa"; type PwaInstallResult = Awaited>; diff --git a/src/app/splash/hooks/use-splash-latest-message.ts b/src/app/splash/hooks/use-splash-latest-message.ts index a1bcc949..426ed294 100644 --- a/src/app/splash/hooks/use-splash-latest-message.ts +++ b/src/app/splash/hooks/use-splash-latest-message.ts @@ -6,7 +6,8 @@ import type { LoginStatus } from "@/data/dto/auth"; import { useHasHydrated } from "@/hooks/use-has-hydrated"; import { loadSplashLatestMessagePreview } from "@/lib/chat/splash_latest_message"; import { useSplashLatestMessageCache } from "@/providers/splash-latest-message-provider"; -import { Logger, Result } from "@/utils"; +import { Logger } from "@/utils/logger"; +import { Result } from "@/utils/result"; const log = new Logger("SplashLatestMessage"); diff --git a/src/app/splash/splash-screen.tsx b/src/app/splash/splash-screen.tsx index 06723e0d..ff93b8a4 100644 --- a/src/app/splash/splash-screen.tsx +++ b/src/app/splash/splash-screen.tsx @@ -6,7 +6,7 @@ import { AppBottomNav, MobileShell } from "@/app/_components/core"; import { ROUTES } from "@/router/routes"; import { useAppNavigator } from "@/router/use-app-navigator"; import { useAuthState } from "@/stores/auth/auth-context"; -import { pwaUtil } from "@/utils"; +import { pwaUtil } from "@/utils/pwa"; import { SplashBackground, diff --git a/src/app/subscription/components/stripe-payment-dialog.tsx b/src/app/subscription/components/stripe-payment-dialog.tsx index c2bb0fa8..839a24fd 100644 --- a/src/app/subscription/components/stripe-payment-dialog.tsx +++ b/src/app/subscription/components/stripe-payment-dialog.tsx @@ -15,7 +15,7 @@ import { loadStripe } from "@stripe/stripe-js"; import { ExceptionHandler } from "@/core/errors"; import { ROUTES } from "@/router/routes"; -import { Logger } from "@/utils"; +import { Logger } from "@/utils/logger"; import { stripePaymentDialogStyles as styles } from "./stripe-payment-dialog.styles"; diff --git a/src/app/subscription/components/subscription-checkout-button.tsx b/src/app/subscription/components/subscription-checkout-button.tsx index 075658ab..12a57419 100644 --- a/src/app/subscription/components/subscription-checkout-button.tsx +++ b/src/app/subscription/components/subscription-checkout-button.tsx @@ -9,7 +9,7 @@ import { usePaymentDispatch, usePaymentState, } from "@/stores/payment/payment-context"; -import { Logger } from "@/utils"; +import { Logger } from "@/utils/logger"; import { LazyStripePaymentDialog } from "./lazy-stripe-payment-dialog"; import { stripePaymentDialogStyles as dialogStyles } from "./stripe-payment-dialog.styles"; diff --git a/src/app/tip/tip-checkout-button.tsx b/src/app/tip/tip-checkout-button.tsx index bd1df32b..3d9c12e5 100644 --- a/src/app/tip/tip-checkout-button.tsx +++ b/src/app/tip/tip-checkout-button.tsx @@ -6,7 +6,7 @@ import { usePaymentDispatch, usePaymentState, } from "@/stores/payment/payment-context"; -import { Logger } from "@/utils"; +import { Logger } from "@/utils/logger"; import { LazyStripePaymentDialog } from "../subscription/components/lazy-stripe-payment-dialog"; import { stripePaymentDialogStyles as dialogStyles } from "../subscription/components/stripe-payment-dialog.styles"; diff --git a/src/core/net/chat-websocket.ts b/src/core/net/chat-websocket.ts index a3c35c6a..0cf03ff9 100644 --- a/src/core/net/chat-websocket.ts +++ b/src/core/net/chat-websocket.ts @@ -10,7 +10,8 @@ */ import { getApiConfig } from "@/core/net/config/api_config"; import { ExceptionHandler } from "@/core/errors"; -import { AppEnvUtil, Logger } from "@/utils"; +import { AppEnvUtil } from "@/utils/app-env"; +import { Logger } from "@/utils/logger"; const log = new Logger("ChatWebSocket"); const RECONNECT_DELAY_MS = 3000; diff --git a/src/core/net/config/api_config.ts b/src/core/net/config/api_config.ts index 0ed59abd..d44ea80c 100644 --- a/src/core/net/config/api_config.ts +++ b/src/core/net/config/api_config.ts @@ -4,7 +4,7 @@ * 通过环境变量配置后端服务地址与超时时间。 * */ -import { AppEnvUtil, type AppEnv } from "@/utils"; +import { AppEnvUtil, type AppEnv } from "@/utils/app-env"; export type { AppEnv }; diff --git a/src/core/net/interceptor/auth_refresh_interceptor.ts b/src/core/net/interceptor/auth_refresh_interceptor.ts index a52ed755..b30ca089 100644 --- a/src/core/net/interceptor/auth_refresh_interceptor.ts +++ b/src/core/net/interceptor/auth_refresh_interceptor.ts @@ -8,7 +8,9 @@ import type { FetchHook } from "ofetch"; import { ApiPath } from "../../../data/services/api/api_path"; import { ApiError, ErrorCode } from "../../../data/services/api/api_result"; import { AuthStorage } from "@/data/storage/auth/auth_storage"; -import { AppEnvUtil, deviceIdentifier, Result } from "@/utils"; +import { AppEnvUtil } from "@/utils/app-env"; +import { deviceIdentifier } from "@/utils/device_identifier"; +import { Result } from "@/utils/result"; /** * 不需要 auth token 刷新的路径 diff --git a/src/core/net/interceptor/logging_interceptor.ts b/src/core/net/interceptor/logging_interceptor.ts index bfb9bd08..5db2a105 100644 --- a/src/core/net/interceptor/logging_interceptor.ts +++ b/src/core/net/interceptor/logging_interceptor.ts @@ -6,7 +6,8 @@ */ import type { FetchHook } from "ofetch"; -import { AppEnvUtil, Logger } from "@/utils"; +import { AppEnvUtil } from "@/utils/app-env"; +import { Logger } from "@/utils/logger"; const log = new Logger("ApiLoggingInterceptor"); diff --git a/src/core/net/interceptor/token_interceptor.ts b/src/core/net/interceptor/token_interceptor.ts index 08ec4339..083534e3 100644 --- a/src/core/net/interceptor/token_interceptor.ts +++ b/src/core/net/interceptor/token_interceptor.ts @@ -6,7 +6,7 @@ * */ import type { FetchHook } from "ofetch"; -import { Logger } from "@/utils"; +import { Logger } from "@/utils/logger"; import { ApiPath } from "../../../data/services/api/api_path"; import { AuthStorage } from "../../../data/storage/auth/auth_storage"; diff --git a/src/core/net/message-queue.ts b/src/core/net/message-queue.ts index 873940d9..9146b472 100644 --- a/src/core/net/message-queue.ts +++ b/src/core/net/message-queue.ts @@ -7,7 +7,7 @@ * - 队列只负责发送节奏,不关心每批消息是否成功消费 * - 队列可在任意时刻清空(dispose) */ -import { Logger } from "@/utils"; +import { Logger } from "@/utils/logger"; export type MessageConsumer = (content: string) => void | Promise; diff --git a/src/data/repositories/__tests__/auth_repository.facebook_identity.test.ts b/src/data/repositories/__tests__/auth_repository.facebook_identity.test.ts index 2b5e82f9..04776b80 100644 --- a/src/data/repositories/__tests__/auth_repository.facebook_identity.test.ts +++ b/src/data/repositories/__tests__/auth_repository.facebook_identity.test.ts @@ -9,7 +9,7 @@ import { AuthRepository } from "@/data/repositories/auth_repository"; import type { AuthApi } from "@/data/services/api"; import type { IAuthStorage } from "@/data/storage/auth"; import type { IUserStorage } from "@/data/storage/user"; -import { Result } from "@/utils"; +import { Result } from "@/utils/result"; function createRepository(overrides: Partial) { const storage = { diff --git a/src/data/repositories/__tests__/auth_repository.session.test.ts b/src/data/repositories/__tests__/auth_repository.session.test.ts index 6e7923b7..e9e86954 100644 --- a/src/data/repositories/__tests__/auth_repository.session.test.ts +++ b/src/data/repositories/__tests__/auth_repository.session.test.ts @@ -8,7 +8,7 @@ import { AuthRepository } from "@/data/repositories/auth_repository"; import type { AuthApi } from "@/data/services/api"; import type { IAuthStorage } from "@/data/storage/auth"; import type { IUserStorage } from "@/data/storage/user"; -import { Result } from "@/utils"; +import { Result } from "@/utils/result"; function createRepository(input: { api?: Partial; diff --git a/src/data/repositories/__tests__/chat_cache_identity.test.ts b/src/data/repositories/__tests__/chat_cache_identity.test.ts index be288a3c..532881eb 100644 --- a/src/data/repositories/__tests__/chat_cache_identity.test.ts +++ b/src/data/repositories/__tests__/chat_cache_identity.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from "vitest"; import { LoginStatus } from "@/data/dto/auth"; -import { Result } from "@/utils"; +import { Result } from "@/utils/result"; import { resolveChatCacheOwnerKey } from "../chat_cache_identity"; diff --git a/src/data/repositories/__tests__/chat_local_message_store.test.ts b/src/data/repositories/__tests__/chat_local_message_store.test.ts index 575355d4..9e9bbf43 100644 --- a/src/data/repositories/__tests__/chat_local_message_store.test.ts +++ b/src/data/repositories/__tests__/chat_local_message_store.test.ts @@ -2,7 +2,7 @@ import { describe, expect, it, vi } from "vitest"; import { ChatMessage } from "@/data/dto/chat"; import { LocalMessage } from "@/data/storage/chat"; -import { Result } from "@/utils"; +import { Result } from "@/utils/result"; import { ChatLocalMessageStore } from "../chat_local_message_store"; diff --git a/src/data/repositories/__tests__/chat_media_cache_coordinator.test.ts b/src/data/repositories/__tests__/chat_media_cache_coordinator.test.ts index fe518b9c..18fe5f39 100644 --- a/src/data/repositories/__tests__/chat_media_cache_coordinator.test.ts +++ b/src/data/repositories/__tests__/chat_media_cache_coordinator.test.ts @@ -1,6 +1,6 @@ import { afterEach, describe, expect, it, vi } from "vitest"; -import { Result } from "@/utils"; +import { Result } from "@/utils/result"; import { ChatMediaCacheCoordinator } from "../chat_media_cache_coordinator"; diff --git a/src/data/repositories/__tests__/payment_repository.test.ts b/src/data/repositories/__tests__/payment_repository.test.ts index 02b097b5..ba193e7f 100644 --- a/src/data/repositories/__tests__/payment_repository.test.ts +++ b/src/data/repositories/__tests__/payment_repository.test.ts @@ -3,7 +3,7 @@ import { describe, expect, it, vi } from "vitest"; import { TipPaymentPlansResponse } from "@/data/dto/payment"; import { PaymentRepository } from "@/data/repositories/payment_repository"; import type { PaymentApi } from "@/data/services/api"; -import { Result } from "@/utils"; +import { Result } from "@/utils/result"; describe("PaymentRepository", () => { it("adapts tip plans without caching them as subscription plans", async () => { diff --git a/src/data/repositories/auth_repository.ts b/src/data/repositories/auth_repository.ts index c443db71..dbf97dde 100644 --- a/src/data/repositories/auth_repository.ts +++ b/src/data/repositories/auth_repository.ts @@ -19,13 +19,11 @@ import { RegisterRequest, } from "@/data/dto/auth"; import { User } from "@/data/dto/user"; -import { - AppEnvUtil, - PlatformDetector, - Result, - Logger, - deviceIdentifier, -} from "@/utils"; +import { AppEnvUtil } from "@/utils/app-env"; +import { PlatformDetector } from "@/utils/platform-detect"; +import { Result } from "@/utils/result"; +import { Logger } from "@/utils/logger"; +import { deviceIdentifier } from "@/utils/device_identifier"; import type { IAuthRepository } from "@/data/repositories/interfaces"; import { AuthStorage, type IAuthStorage } from "@/data/storage/auth"; import { UserStorage, type IUserStorage } from "@/data/storage/user"; diff --git a/src/data/repositories/chat_cache_identity.ts b/src/data/repositories/chat_cache_identity.ts index 315e0686..9eb72c6b 100644 --- a/src/data/repositories/chat_cache_identity.ts +++ b/src/data/repositories/chat_cache_identity.ts @@ -3,7 +3,7 @@ import { LoginStatus } from "@/data/dto/auth"; import { AuthStorage, type IAuthStorage } from "@/data/storage/auth"; import { UserStorage, type IUserStorage } from "@/data/storage/user"; -import { Result, type Result as ResultT } from "@/utils"; +import { Result, type Result as ResultT } from "@/utils/result"; export type ChatCacheIdentityResolver = () => Promise>; diff --git a/src/data/repositories/chat_local_message_store.ts b/src/data/repositories/chat_local_message_store.ts index 2ba64c6b..c1ebd0a2 100644 --- a/src/data/repositories/chat_local_message_store.ts +++ b/src/data/repositories/chat_local_message_store.ts @@ -3,7 +3,7 @@ import { ChatMessage } from "@/data/dto/chat"; import type { UnlockedPrivateMessageLocalPatch } from "@/data/repositories/interfaces"; import { LocalChatStorage, LocalMessage } from "@/data/storage/chat"; -import { Result } from "@/utils"; +import { Result } from "@/utils/result"; import { resolveChatCacheOwnerKey, diff --git a/src/data/repositories/chat_media_cache_coordinator.ts b/src/data/repositories/chat_media_cache_coordinator.ts index 90ff3c8a..c0c937bb 100644 --- a/src/data/repositories/chat_media_cache_coordinator.ts +++ b/src/data/repositories/chat_media_cache_coordinator.ts @@ -6,7 +6,8 @@ import { type LocalChatMediaRow, } from "@/data/storage/chat"; import { requestBrowserPersistentStorageOnce } from "@/lib/browser/persistent_storage"; -import { Logger, Result } from "@/utils"; +import { Logger } from "@/utils/logger"; +import { Result } from "@/utils/result"; import type { CacheRemoteChatMediaInput, ChatMediaLookupInput, diff --git a/src/data/repositories/chat_remote_data_source.ts b/src/data/repositories/chat_remote_data_source.ts index d72bc7c0..47f87b21 100644 --- a/src/data/repositories/chat_remote_data_source.ts +++ b/src/data/repositories/chat_remote_data_source.ts @@ -10,7 +10,7 @@ import { } from "@/data/dto/chat"; import type { ChatApi } from "@/data/services/api"; import type { UnlockPrivateMessageInput } from "@/data/repositories/interfaces"; -import { Result } from "@/utils"; +import { Result } from "@/utils/result"; export class ChatRemoteDataSource { constructor(private readonly api: ChatApi) {} diff --git a/src/data/repositories/chat_repository.ts b/src/data/repositories/chat_repository.ts index 27361395..6e3ea311 100644 --- a/src/data/repositories/chat_repository.ts +++ b/src/data/repositories/chat_repository.ts @@ -20,7 +20,7 @@ import type { UnlockPrivateMessageInput, UnlockedPrivateMessageLocalPatch, } from "@/data/repositories/interfaces"; -import type { Result } from "@/utils"; +import type { Result } from "@/utils/result"; import { ChatLocalMessageStore } from "./chat_local_message_store"; import { ChatMediaCacheCoordinator } from "./chat_media_cache_coordinator"; diff --git a/src/data/repositories/interfaces/iauth_repository.ts b/src/data/repositories/interfaces/iauth_repository.ts index 44e892c1..0c53e909 100644 --- a/src/data/repositories/interfaces/iauth_repository.ts +++ b/src/data/repositories/interfaces/iauth_repository.ts @@ -13,7 +13,7 @@ * */ -import type { Result } from "@/utils"; +import type { Result } from "@/utils/result"; import type { GuestLoginResponse, LoginStatus, diff --git a/src/data/repositories/interfaces/ichat_repository.ts b/src/data/repositories/interfaces/ichat_repository.ts index ad6bda3a..137bc01f 100644 --- a/src/data/repositories/interfaces/ichat_repository.ts +++ b/src/data/repositories/interfaces/ichat_repository.ts @@ -6,7 +6,7 @@ * 聚合聊天远程操作、身份隔离的本地历史,以及媒体缓存能力。 */ -import type { Result } from "@/utils"; +import type { Result } from "@/utils/result"; import type { ChatHistoryResponse, ChatMediaKind, diff --git a/src/data/repositories/interfaces/imetrics_repository.ts b/src/data/repositories/interfaces/imetrics_repository.ts index 05dae80f..651e51d3 100644 --- a/src/data/repositories/interfaces/imetrics_repository.ts +++ b/src/data/repositories/interfaces/imetrics_repository.ts @@ -9,7 +9,7 @@ * */ -import type { Result } from "@/utils"; +import type { Result } from "@/utils/result"; export interface IMetricsRepository { /** 上报 PWA 事件。自动注入当前秒级时间戳。 */ diff --git a/src/data/repositories/interfaces/iuser_repository.ts b/src/data/repositories/interfaces/iuser_repository.ts index 292ba6e5..dedc9681 100644 --- a/src/data/repositories/interfaces/iuser_repository.ts +++ b/src/data/repositories/interfaces/iuser_repository.ts @@ -4,7 +4,7 @@ * IUserRepository 接口 */ -import type { Result } from "@/utils"; +import type { Result } from "@/utils/result"; import type { User, UserEntitlements, diff --git a/src/data/repositories/metrics_repository.ts b/src/data/repositories/metrics_repository.ts index e79d7351..f3b026f8 100644 --- a/src/data/repositories/metrics_repository.ts +++ b/src/data/repositories/metrics_repository.ts @@ -7,7 +7,7 @@ */ import { MetricsApi, metricsApi } from "@/data/services/api"; import { AppEvent, PwaEvent } from "@/data/dto/metrics"; -import { Result } from "@/utils"; +import { Result } from "@/utils/result"; import type { IMetricsRepository } from "@/data/repositories/interfaces"; import { createLazySingleton } from "./lazy_singleton"; diff --git a/src/data/repositories/user_repository.ts b/src/data/repositories/user_repository.ts index f6232210..e024a2f0 100644 --- a/src/data/repositories/user_repository.ts +++ b/src/data/repositories/user_repository.ts @@ -4,7 +4,7 @@ import { User, UserEntitlements, } from "@/data/dto/user"; -import { Result } from "@/utils"; +import { Result } from "@/utils/result"; import type { IUserRepository } from "@/data/repositories/interfaces"; import { createLazySingleton } from "./lazy_singleton"; diff --git a/src/data/services/api/__tests__/http_client.test.ts b/src/data/services/api/__tests__/http_client.test.ts index c71e7920..7986a27a 100644 --- a/src/data/services/api/__tests__/http_client.test.ts +++ b/src/data/services/api/__tests__/http_client.test.ts @@ -3,7 +3,9 @@ import { createStorage } from "unstorage"; import memoryDriver from "unstorage/drivers/memory"; import { AuthStorage } from "@/data/storage/auth"; -import { deviceIdentifier, Result, SpAsyncUtil } from "@/utils"; +import { deviceIdentifier } from "@/utils/device_identifier"; +import { Result } from "@/utils/result"; +import { SpAsyncUtil } from "@/utils/storage"; import { ErrorCode } from "../api_result"; import { createHttpClient } from "../http_client"; diff --git a/src/data/services/api/auth_api.ts b/src/data/services/api/auth_api.ts index 2a64dcd2..0a43dcd2 100644 --- a/src/data/services/api/auth_api.ts +++ b/src/data/services/api/auth_api.ts @@ -27,7 +27,7 @@ import { } from "@/data/dto/auth"; import { User } from "@/data/dto/user"; import type { UserData } from "@/data/schemas/user/user"; -import { Logger } from "@/utils"; +import { Logger } from "@/utils/logger"; const log = new Logger("DataServicesApiAuthApi"); diff --git a/src/data/services/facebook-graph.ts b/src/data/services/facebook-graph.ts index 4dc7d34a..c51a8752 100644 --- a/src/data/services/facebook-graph.ts +++ b/src/data/services/facebook-graph.ts @@ -12,7 +12,8 @@ * - 不需要 appId / appSecret(accessToken 自身就是凭证) */ import { FacebookUserData } from "@/data/dto/auth"; -import { Logger, Result, toError } from "@/utils"; +import { Logger } from "@/utils/logger"; +import { Result, toError } from "@/utils/result"; const log = new Logger("FacebookGraph"); diff --git a/src/data/storage/__tests__/storage_migration.test.ts b/src/data/storage/__tests__/storage_migration.test.ts index fcc357cc..13847e64 100644 --- a/src/data/storage/__tests__/storage_migration.test.ts +++ b/src/data/storage/__tests__/storage_migration.test.ts @@ -4,7 +4,7 @@ import memoryDriver from "unstorage/drivers/memory"; import { StorageKeys } from "@/data/storage/storage_keys"; import { runStorageMigrations } from "@/data/storage/storage_migration"; -import { SpAsyncUtil } from "@/utils"; +import { SpAsyncUtil } from "@/utils/storage"; describe("runStorageMigrations", () => { beforeEach(() => { diff --git a/src/data/storage/app/app_storage.ts b/src/data/storage/app/app_storage.ts index 6bbea25c..b77d920a 100644 --- a/src/data/storage/app/app_storage.ts +++ b/src/data/storage/app/app_storage.ts @@ -12,7 +12,8 @@ * PWA 对话框使用布尔标记;每日上报类方法仍使用 `yyyy-MM-dd` 字符串比对。 */ -import { Result, type Result as ResultT, SpAsyncUtil } from "@/utils"; +import { Result, type Result as ResultT } from "@/utils/result"; +import { SpAsyncUtil } from "@/utils/storage"; import { StorageKeys } from "../storage_keys"; export class AppStorage { diff --git a/src/data/storage/auth/auth_storage.ts b/src/data/storage/auth/auth_storage.ts index e9fc724b..ab5cb3b0 100644 --- a/src/data/storage/auth/auth_storage.ts +++ b/src/data/storage/auth/auth_storage.ts @@ -1,7 +1,8 @@ "use client"; import { LoginStatus, type LoginStatus as LoginStatusT } from "@/data/dto/auth"; -import { Result, type Result as ResultT, SpAsyncUtil } from "@/utils"; +import { Result, type Result as ResultT } from "@/utils/result"; +import { SpAsyncUtil } from "@/utils/storage"; import { StorageKeys } from "../storage_keys"; import type { IAuthStorage } from "./iauth_storage"; diff --git a/src/data/storage/auth/iauth_storage.ts b/src/data/storage/auth/iauth_storage.ts index 971bc7dd..136def06 100644 --- a/src/data/storage/auth/iauth_storage.ts +++ b/src/data/storage/auth/iauth_storage.ts @@ -10,7 +10,7 @@ * - 所有方法返回 `Promise>`,与 Dart `Future>` 对齐 */ -import type { Result } from "@/utils"; +import type { Result } from "@/utils/result"; import type { LoginStatus } from "@/data/dto/auth"; export interface IAuthStorage { diff --git a/src/data/storage/chat/local_chat_media_storage.ts b/src/data/storage/chat/local_chat_media_storage.ts index d0fdbb94..5723c2c6 100644 --- a/src/data/storage/chat/local_chat_media_storage.ts +++ b/src/data/storage/chat/local_chat_media_storage.ts @@ -1,6 +1,6 @@ "use client"; -import { Result, type Result as ResultT } from "@/utils"; +import { Result, type Result as ResultT } from "@/utils/result"; import type { ChatMediaKind } from "@/data/dto/chat"; import { diff --git a/src/data/storage/chat/local_chat_storage.ts b/src/data/storage/chat/local_chat_storage.ts index 98c5d018..938cccff 100644 --- a/src/data/storage/chat/local_chat_storage.ts +++ b/src/data/storage/chat/local_chat_storage.ts @@ -9,7 +9,7 @@ * 登录用户及多个账号共享缓存。 */ -import { Result, type Result as ResultT } from "@/utils"; +import { Result, type Result as ResultT } from "@/utils/result"; import { LocalChatDB } from "./local_chat_db"; import { LocalMessage } from "./local_message"; diff --git a/src/data/storage/navigation/__tests__/navigation_storage.test.ts b/src/data/storage/navigation/__tests__/navigation_storage.test.ts index 1b2ce80b..1cee66ea 100644 --- a/src/data/storage/navigation/__tests__/navigation_storage.test.ts +++ b/src/data/storage/navigation/__tests__/navigation_storage.test.ts @@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import { createStorage } from "unstorage"; import memoryDriver from "unstorage/drivers/memory"; -import { SessionAsyncUtil } from "@/utils"; +import { SessionAsyncUtil } from "@/utils/session-storage"; import { NavigationStorage } from "../navigation_storage"; diff --git a/src/data/storage/navigation/navigation_storage.ts b/src/data/storage/navigation/navigation_storage.ts index 346b0677..499ccd58 100644 --- a/src/data/storage/navigation/navigation_storage.ts +++ b/src/data/storage/navigation/navigation_storage.ts @@ -4,7 +4,8 @@ import { z } from "zod"; import { StorageKeys } from "@/data/storage/storage_keys"; import { ChatLockTypeSchema } from "@/data/schemas/chat"; -import { Result, SessionAsyncUtil } from "@/utils"; +import { Result } from "@/utils/result"; +import { SessionAsyncUtil } from "@/utils/session-storage"; const MAX_AGE_MS = 30 * 60 * 1000; diff --git a/src/data/storage/payment/payment_plans_storage.ts b/src/data/storage/payment/payment_plans_storage.ts index ed58cefa..699c5e90 100644 --- a/src/data/storage/payment/payment_plans_storage.ts +++ b/src/data/storage/payment/payment_plans_storage.ts @@ -4,7 +4,8 @@ import { PaymentPlansResponseSchema, type PaymentPlansResponseData, } from "@/data/schemas/payment"; -import { type Result as ResultT, SpAsyncUtil } from "@/utils"; +import { type Result as ResultT } from "@/utils/result"; +import { SpAsyncUtil } from "@/utils/storage"; import { StorageKeys } from "../storage_keys"; diff --git a/src/data/storage/payment/pending_payment_order_storage.ts b/src/data/storage/payment/pending_payment_order_storage.ts index 7740bbc9..9820906c 100644 --- a/src/data/storage/payment/pending_payment_order_storage.ts +++ b/src/data/storage/payment/pending_payment_order_storage.ts @@ -2,7 +2,8 @@ import { z } from "zod"; -import { Result, type Result as ResultT, SpAsyncUtil } from "@/utils"; +import { Result, type Result as ResultT } from "@/utils/result"; +import { SpAsyncUtil } from "@/utils/storage"; import { StorageKeys } from "../storage_keys"; diff --git a/src/data/storage/storage_migration.ts b/src/data/storage/storage_migration.ts index c0a19cb4..cd594ca6 100644 --- a/src/data/storage/storage_migration.ts +++ b/src/data/storage/storage_migration.ts @@ -1,6 +1,7 @@ "use client"; -import { Result, type Result as ResultT, SpAsyncUtil } from "@/utils"; +import { Result, type Result as ResultT } from "@/utils/result"; +import { SpAsyncUtil } from "@/utils/storage"; import { StorageKeys } from "./storage_keys"; diff --git a/src/data/storage/user/__tests__/user_storage.test.ts b/src/data/storage/user/__tests__/user_storage.test.ts index e6f3549e..c518900e 100644 --- a/src/data/storage/user/__tests__/user_storage.test.ts +++ b/src/data/storage/user/__tests__/user_storage.test.ts @@ -4,7 +4,7 @@ import memoryDriver from "unstorage/drivers/memory"; import { StorageKeys } from "@/data/storage/storage_keys"; import { UserStorage } from "@/data/storage/user/user_storage"; -import { SpAsyncUtil } from "@/utils"; +import { SpAsyncUtil } from "@/utils/storage"; describe("UserStorage", () => { beforeEach(() => { diff --git a/src/data/storage/user/iuser_storage.ts b/src/data/storage/user/iuser_storage.ts index 08cd1864..c1bde49c 100644 --- a/src/data/storage/user/iuser_storage.ts +++ b/src/data/storage/user/iuser_storage.ts @@ -11,7 +11,7 @@ * 当前需要的最小字段,避免把完整后端 profile 长期写入 localStorage。 */ -import type { Result } from "@/utils"; +import type { Result } from "@/utils/result"; import type { UserEntitlementSnapshotData } from "@/data/schemas/user/user_entitlement_snapshot"; import type { PersistedUserData, diff --git a/src/data/storage/user/user_storage.ts b/src/data/storage/user/user_storage.ts index adf0b5f9..f4e3e269 100644 --- a/src/data/storage/user/user_storage.ts +++ b/src/data/storage/user/user_storage.ts @@ -24,7 +24,8 @@ import { type PersistedUserData, type PersistedUserInput, } from "@/data/schemas/user/persisted_user"; -import { type Result as ResultT, SpAsyncUtil } from "@/utils"; +import { type Result as ResultT } from "@/utils/result"; +import { SpAsyncUtil } from "@/utils/storage"; import { StorageKeys } from "../storage_keys"; import type { IUserStorage } from "./iuser_storage"; diff --git a/src/hooks/use-keyboard-height/environment.ts b/src/hooks/use-keyboard-height/environment.ts index 8e67bee7..f3f083c5 100644 --- a/src/hooks/use-keyboard-height/environment.ts +++ b/src/hooks/use-keyboard-height/environment.ts @@ -1,4 +1,5 @@ -import { BrowserDetector, PlatformDetector } from "@/utils"; +import { BrowserDetector } from "@/utils/browser-detect"; +import { PlatformDetector } from "@/utils/platform-detect"; import type { KeyboardAdaptEnvironment } from "./types"; diff --git a/src/hooks/use-keyboard-height/index.ts b/src/hooks/use-keyboard-height/index.ts index 7c92ba91..30b3d66a 100644 --- a/src/hooks/use-keyboard-height/index.ts +++ b/src/hooks/use-keyboard-height/index.ts @@ -14,7 +14,7 @@ */ import { useEffect } from "react"; -import { Logger } from "@/utils"; +import { Logger } from "@/utils/logger"; import { FALLBACK_INPUT_LIFT_PX, diff --git a/src/integrations/media-recorder.ts b/src/integrations/media-recorder.ts index 57b058f0..2c4aa8d5 100644 --- a/src/integrations/media-recorder.ts +++ b/src/integrations/media-recorder.ts @@ -9,7 +9,7 @@ * * 注:Web Speech API 在 Chrome / Edge 完整支持;Safari / Firefox 仅录音。 */ -import { Result } from "@/utils"; +import { Result } from "@/utils/result"; export interface SpeechRecognitionResultEvent { transcript: string; diff --git a/src/lib/auth/__tests__/auth_session.test.ts b/src/lib/auth/__tests__/auth_session.test.ts index 71d9bcfe..093ae780 100644 --- a/src/lib/auth/__tests__/auth_session.test.ts +++ b/src/lib/auth/__tests__/auth_session.test.ts @@ -2,7 +2,7 @@ import { describe, expect, it, vi } from "vitest"; import type { IAuthStorage } from "@/data/storage/auth"; import { LoginStatus } from "@/data/dto/auth"; -import { Result } from "@/utils"; +import { Result } from "@/utils/result"; import { hasCompleteBusinessAuthSession } from "../auth_session"; diff --git a/src/lib/browser/persistent_storage.ts b/src/lib/browser/persistent_storage.ts index 3cb9980a..7df8fd55 100644 --- a/src/lib/browser/persistent_storage.ts +++ b/src/lib/browser/persistent_storage.ts @@ -1,6 +1,6 @@ "use client"; -import { Logger } from "@/utils"; +import { Logger } from "@/utils/logger"; const log = new Logger("LibBrowserPersistentStorage"); let storagePersistenceRequested = false; diff --git a/src/lib/chat/__tests__/splash_latest_message.test.ts b/src/lib/chat/__tests__/splash_latest_message.test.ts index 5b20a655..90273ef6 100644 --- a/src/lib/chat/__tests__/splash_latest_message.test.ts +++ b/src/lib/chat/__tests__/splash_latest_message.test.ts @@ -1,6 +1,6 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; -import { Result } from "@/utils"; +import { Result } from "@/utils/result"; const getHistoryMock = vi.hoisted(() => vi.fn()); diff --git a/src/lib/chat/chat_external_browser.ts b/src/lib/chat/chat_external_browser.ts index e1c14ee9..abe5c02a 100644 --- a/src/lib/chat/chat_external_browser.ts +++ b/src/lib/chat/chat_external_browser.ts @@ -3,7 +3,7 @@ import { AuthStorage } from "@/data/storage/auth/auth_storage"; import { UserStorage } from "@/data/storage/user/user_storage"; import { ROUTES } from "@/router/routes"; -import { UrlLauncherUtil } from "@/utils"; +import { UrlLauncherUtil } from "@/utils/url-launcher-util"; export async function openChatInExternalBrowser(): Promise { const authStorage = AuthStorage.getInstance(); diff --git a/src/lib/chat/chat_media_cache_client.ts b/src/lib/chat/chat_media_cache_client.ts index c88464fd..cece084d 100644 --- a/src/lib/chat/chat_media_cache_client.ts +++ b/src/lib/chat/chat_media_cache_client.ts @@ -2,7 +2,7 @@ import type { ChatMediaKind } from "@/data/dto/chat"; import { getChatRepository } from "@/data/repositories/chat_repository"; -import { Result, type Result as ResultT } from "@/utils"; +import { Result, type Result as ResultT } from "@/utils/result"; import { localChatMediaRowToBlob } from "./chat_media_blob"; diff --git a/src/lib/chat/splash_latest_message.ts b/src/lib/chat/splash_latest_message.ts index c505aa14..ae3da20c 100644 --- a/src/lib/chat/splash_latest_message.ts +++ b/src/lib/chat/splash_latest_message.ts @@ -5,7 +5,7 @@ import { resolveChatCacheOwnerKey, type ChatCacheIdentityResolver, } from "@/data/repositories/chat_cache_identity"; -import { Result, type Result as ResultT } from "@/utils"; +import { Result, type Result as ResultT } from "@/utils/result"; import type { SplashLatestMessageCache } from "./splash_latest_message_cache"; import { getLatestSplashMessagePreview } from "./splash_latest_message_preview"; diff --git a/src/lib/chat/use_cached_chat_media_url.ts b/src/lib/chat/use_cached_chat_media_url.ts index 474d8ab0..c6978986 100644 --- a/src/lib/chat/use_cached_chat_media_url.ts +++ b/src/lib/chat/use_cached_chat_media_url.ts @@ -3,7 +3,10 @@ import { useEffect, useRef, useState } from "react"; import type { ChatMediaKind } from "@/data/dto/chat"; -import { BrowserDetector, Logger, PlatformDetector, Result } from "@/utils"; +import { BrowserDetector } from "@/utils/browser-detect"; +import { Logger } from "@/utils/logger"; +import { PlatformDetector } from "@/utils/platform-detect"; +import { Result } from "@/utils/result"; import { cacheRemoteChatMediaBlob, diff --git a/src/lib/payment/payment_launch.ts b/src/lib/payment/payment_launch.ts index 704e8b8f..1151fbce 100644 --- a/src/lib/payment/payment_launch.ts +++ b/src/lib/payment/payment_launch.ts @@ -1,6 +1,7 @@ "use client"; -import { Logger, Result } from "@/utils"; +import { Logger } from "@/utils/logger"; +import { Result } from "@/utils/result"; import { savePendingEzpayOrder, diff --git a/src/lib/payment/pending_payment_order.ts b/src/lib/payment/pending_payment_order.ts index aa4a609f..a1b2f60a 100644 --- a/src/lib/payment/pending_payment_order.ts +++ b/src/lib/payment/pending_payment_order.ts @@ -3,13 +3,13 @@ import { PendingPaymentOrderStorage, type PendingPaymentOrder, -} from "@/data/storage"; +} from "@/data/storage/payment/pending_payment_order_storage"; import { ROUTES } from "@/router/routes"; import { DEFAULT_TIP_COFFEE_TYPE, TIP_COFFEE_TYPE_PARAM, } from "@/lib/tip/tip_coffee"; -import type { Result } from "@/utils"; +import type { Result } from "@/utils/result"; export type PendingPaymentSubscriptionType = PendingPaymentOrder["subscriptionType"]; diff --git a/src/providers/viewport-css-vars-provider.tsx b/src/providers/viewport-css-vars-provider.tsx index 8d448164..045283d6 100644 --- a/src/providers/viewport-css-vars-provider.tsx +++ b/src/providers/viewport-css-vars-provider.tsx @@ -2,7 +2,9 @@ import { useEffect, type ReactNode } from "react"; -import { BrowserDetector, Logger, PlatformDetector } from "@/utils"; +import { BrowserDetector } from "@/utils/browser-detect"; +import { Logger } from "@/utils/logger"; +import { PlatformDetector } from "@/utils/platform-detect"; const CSS_VAR_VIEWPORT_HEIGHT = "--app-viewport-height"; const CSS_VAR_VISIBLE_HEIGHT = "--app-visible-height"; diff --git a/src/stores/auth/auth-actors.ts b/src/stores/auth/auth-actors.ts index 52c26a85..48ed5d6b 100644 --- a/src/stores/auth/auth-actors.ts +++ b/src/stores/auth/auth-actors.ts @@ -9,7 +9,9 @@ import { getAuthRepository } from "@/data/repositories/auth_repository"; import { fetchFacebookUserData } from "@/data/services"; import { AuthStorage } from "@/data/storage/auth/auth_storage"; import { UserStorage } from "@/data/storage/user/user_storage"; -import { deviceIdentifier, Logger, Result } from "@/utils"; +import { deviceIdentifier } from "@/utils/device_identifier"; +import { Logger } from "@/utils/logger"; +import { Result } from "@/utils/result"; import { hasCompleteBusinessAuthSession } from "@/lib/auth/auth_session"; import { readGuestId, readPsid } from "./auth-helpers"; diff --git a/src/stores/auth/auth-status-checker.tsx b/src/stores/auth/auth-status-checker.tsx index c59a2143..d9d940b8 100644 --- a/src/stores/auth/auth-status-checker.tsx +++ b/src/stores/auth/auth-status-checker.tsx @@ -10,9 +10,9 @@ */ import { useEffect } from "react"; -import { runStorageMigrations } from "@/data/storage"; +import { runStorageMigrations } from "@/data/storage/storage_migration"; import { useAuthDispatch } from "./auth-context"; -import { Logger } from "@/utils"; +import { Logger } from "@/utils/logger"; const log = new Logger("StoresAuthAuthStatusChecker"); diff --git a/src/stores/chat/chat-history-flow.ts b/src/stores/chat/chat-history-flow.ts index 453bfd2e..41a30a53 100644 --- a/src/stores/chat/chat-history-flow.ts +++ b/src/stores/chat/chat-history-flow.ts @@ -1,6 +1,6 @@ import { fromCallback } from "xstate"; -import { Logger } from "@/utils"; +import { Logger } from "@/utils/logger"; import { readLocalHistorySnapshot, diff --git a/src/stores/chat/chat-history-sync.ts b/src/stores/chat/chat-history-sync.ts index d706e5b8..15003ef0 100644 --- a/src/stores/chat/chat-history-sync.ts +++ b/src/stores/chat/chat-history-sync.ts @@ -1,7 +1,9 @@ import type { UiMessage } from "@/data/dto/chat"; import { resolveChatCacheOwnerKey } from "@/data/repositories/chat_cache_identity"; import { getChatRepository } from "@/data/repositories/chat_repository"; -import { Logger, Result, todayString } from "@/utils"; +import { Logger } from "@/utils/logger"; +import { Result } from "@/utils/result"; +import { todayString } from "@/utils/date"; import { CHAT_HISTORY_LIMIT, diff --git a/src/stores/chat/chat-media-flow.ts b/src/stores/chat/chat-media-flow.ts index 3a0ef2c0..aea8fcef 100644 --- a/src/stores/chat/chat-media-flow.ts +++ b/src/stores/chat/chat-media-flow.ts @@ -1,4 +1,5 @@ -import { Logger, todayString } from "@/utils"; +import { Logger } from "@/utils/logger"; +import { todayString } from "@/utils/date"; import { chatAssign, type ChatActionArgs } from "./chat-flow-actions"; import { beginPendingReply } from "./chat-machine.helpers"; diff --git a/src/stores/chat/chat-message-mappers.ts b/src/stores/chat/chat-message-mappers.ts index 8d3cde56..d7021c99 100644 --- a/src/stores/chat/chat-message-mappers.ts +++ b/src/stores/chat/chat-message-mappers.ts @@ -1,6 +1,6 @@ import { type ChatSendResponse, type UiMessage } from "@/data/dto/chat"; import type { ChatLockDetailData } from "@/data/schemas/chat"; -import { todayString } from "@/utils"; +import { todayString } from "@/utils/date"; /** * ChatMessage[] -> UiMessage[]. diff --git a/src/stores/chat/chat-promotion.ts b/src/stores/chat/chat-promotion.ts index 8e789539..640501b4 100644 --- a/src/stores/chat/chat-promotion.ts +++ b/src/stores/chat/chat-promotion.ts @@ -1,6 +1,6 @@ import type { UiMessage } from "@/data/dto/chat"; import type { PendingChatPromotion } from "@/data/storage/navigation"; -import { todayString } from "@/utils"; +import { todayString } from "@/utils/date"; import { applySingleUnlockOutput, diff --git a/src/stores/chat/chat-send-flow.ts b/src/stores/chat/chat-send-flow.ts index 74ac04b6..7f2f6bb3 100644 --- a/src/stores/chat/chat-send-flow.ts +++ b/src/stores/chat/chat-send-flow.ts @@ -5,7 +5,9 @@ import { MessageQueue } from "@/core/net/message-queue"; import type { ChatSendResponse } from "@/data/dto/chat"; import { getChatRepository } from "@/data/repositories/chat_repository"; import { resolveChatCacheOwnerKey } from "@/data/repositories/chat_cache_identity"; -import { Logger, Result, todayString } from "@/utils"; +import { Logger } from "@/utils/logger"; +import { Result } from "@/utils/result"; +import { todayString } from "@/utils/date"; import type { ChatEvent } from "./chat-events"; import { diff --git a/src/stores/chat/chat-unlock-flow.ts b/src/stores/chat/chat-unlock-flow.ts index fc7e08a6..ad6d7863 100644 --- a/src/stores/chat/chat-unlock-flow.ts +++ b/src/stores/chat/chat-unlock-flow.ts @@ -2,7 +2,8 @@ import { fromPromise } from "xstate"; import { getChatRepository } from "@/data/repositories/chat_repository"; import { resolveChatCacheOwnerKey } from "@/data/repositories/chat_cache_identity"; -import { Logger, Result } from "@/utils"; +import { Logger } from "@/utils/logger"; +import { Result } from "@/utils/result"; import { chatAssign, diff --git a/src/stores/payment/payment-machine.actors.ts b/src/stores/payment/payment-machine.actors.ts index 7a987ddb..d8b3bb05 100644 --- a/src/stores/payment/payment-machine.actors.ts +++ b/src/stores/payment/payment-machine.actors.ts @@ -10,7 +10,7 @@ import { PaymentPlansResponse, } from "@/data/dto/payment"; import { getPaymentRepository } from "@/data/repositories/payment_repository"; -import { Result } from "@/utils"; +import { Result } from "@/utils/result"; import type { PaymentPlanCatalog } from "./payment-state"; diff --git a/src/stores/private-room/private-room-machine.actors.ts b/src/stores/private-room/private-room-machine.actors.ts index 25fdb538..12267acf 100644 --- a/src/stores/private-room/private-room-machine.actors.ts +++ b/src/stores/private-room/private-room-machine.actors.ts @@ -5,7 +5,7 @@ import type { PrivateAlbumUnlockResponse, } from "@/data/dto/private-room"; import { getPrivateRoomRepository } from "@/data/repositories/private_room_repository"; -import { Result } from "@/utils"; +import { Result } from "@/utils/result"; import { PRIVATE_ROOM_CHARACTER, diff --git a/src/stores/user/user-machine.actors.ts b/src/stores/user/user-machine.actors.ts index 3655a983..fe47eee8 100644 --- a/src/stores/user/user-machine.actors.ts +++ b/src/stores/user/user-machine.actors.ts @@ -16,7 +16,7 @@ import { fromPromise } from "xstate"; import { getUserRepository } from "@/data/repositories/user_repository"; import { getAuthRepository } from "@/data/repositories/auth_repository"; -import { Result } from "@/utils"; +import { Result } from "@/utils/result"; import { applyEntitlementSnapshotToView, diff --git a/src/stores/user/user-machine.helpers.ts b/src/stores/user/user-machine.helpers.ts index 799a6a6e..9dfa1f1a 100644 --- a/src/stores/user/user-machine.helpers.ts +++ b/src/stores/user/user-machine.helpers.ts @@ -16,7 +16,7 @@ import type { UserView } from "@/data/dto/user"; import type { UserEntitlementSnapshotData } from "@/data/schemas/user"; import { UserStorage } from "@/data/storage/user/user_storage"; -import { Result } from "@/utils"; +import { Result } from "@/utils/result"; // ============================================================ // Storage singleton