mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
Add `packages/app/src/constants/platform.ts` with canonical gates (isWeb, isNative, getIsElectron) and refactor all ~100 ad-hoc Platform.OS checks across 69 files to use shared imports. Fix sidebar hover crash on native (onPointerEnter → onHoverIn), fix tooltip to use breakpoint instead of platform detection, make sidebar action buttons always visible on native where hover doesn't work, and document the platform gating decision matrix in CLAUDE.md.
35 lines
1.2 KiB
TypeScript
35 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;
|
|
}
|