Apply prettier-compatible formatting across the repo to match the incoming oxfmt configuration. Mechanical reformat only — no logic changes. Covers YAML quote normalization, package.json key sorting, Markdown/TOML formatting, and minor TS whitespace tweaks.
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
import { isElectronRuntime } from "@/desktop/host";
|
|
import type { AttachmentStore } from "@/attachments/types";
|
|
import { isWeb } from "@/constants/platform";
|
|
|
|
let attachmentStorePromise: Promise<AttachmentStore> | null = null;
|
|
|
|
async function createAttachmentStore(): Promise<AttachmentStore> {
|
|
if (isWeb) {
|
|
if (isElectronRuntime()) {
|
|
const { createDesktopAttachmentStore } =
|
|
await import("../desktop/attachments/desktop-attachment-store");
|
|
return createDesktopAttachmentStore();
|
|
}
|
|
|
|
const { createIndexedDbAttachmentStore } = await import("./web/indexeddb-attachment-store");
|
|
return createIndexedDbAttachmentStore();
|
|
}
|
|
|
|
const { createNativeFileAttachmentStore } = await import("./native/native-file-attachment-store");
|
|
return createNativeFileAttachmentStore();
|
|
}
|
|
|
|
export async function getAttachmentStore(): Promise<AttachmentStore> {
|
|
if (!attachmentStorePromise) {
|
|
attachmentStorePromise = createAttachmentStore();
|
|
}
|
|
return await attachmentStorePromise;
|
|
}
|
|
|
|
/** Test-only hook to inject a deterministic store implementation. */
|
|
export function __setAttachmentStoreForTests(store: AttachmentStore | null): void {
|
|
attachmentStorePromise = store ? Promise.resolve(store) : null;
|
|
}
|