123456type Cap = { isNativePlatform?: () => boolean; Plugins?: Record<string, any> };78function cap(): Cap | null {9 const g = globalThis as unknown as { Capacitor?: Cap };10 return g.Capacitor ?? null;11}1213export function isNativePlatform(): boolean {14 const c = cap();15 if (!c) return false;16 if (typeof c.isNativePlatform === "function") return c.isNativePlatform();17 return false;18}192021export function nativePlugin<T = any>(name: string): T | null {22 return (cap()?.Plugins?.[name] as T | undefined) ?? null;23}