perf(bundle): replace broad storage and utils imports

This commit is contained in:
2026-07-14 18:13:55 +08:00
parent e270be9bd9
commit 0033625866
85 changed files with 136 additions and 97 deletions
@@ -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<AuthApi>) {
const storage = {
@@ -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<AuthApi>;
@@ -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";
@@ -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";
@@ -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";
@@ -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 () => {
+5 -7
View File
@@ -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";
+1 -1
View File
@@ -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<ResultT<string>>;
@@ -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,
@@ -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,
@@ -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) {}
+1 -1
View File
@@ -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";
@@ -13,7 +13,7 @@
*
*/
import type { Result } from "@/utils";
import type { Result } from "@/utils/result";
import type {
GuestLoginResponse,
LoginStatus,
@@ -6,7 +6,7 @@
* 聚合聊天远程操作、身份隔离的本地历史,以及媒体缓存能力。
*/
import type { Result } from "@/utils";
import type { Result } from "@/utils/result";
import type {
ChatHistoryResponse,
ChatMediaKind,
@@ -9,7 +9,7 @@
*
*/
import type { Result } from "@/utils";
import type { Result } from "@/utils/result";
export interface IMetricsRepository {
/** 上报 PWA 事件。自动注入当前秒级时间戳。 */
@@ -4,7 +4,7 @@
* IUserRepository 接口
*/
import type { Result } from "@/utils";
import type { Result } from "@/utils/result";
import type {
User,
UserEntitlements,
+1 -1
View File
@@ -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";
+1 -1
View File
@@ -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";