/** * Safari Extension Module * * Provides utilities and hooks for Safari Web Extensions. * These only work when running in a Safari extension context (web view). */ /// declare global { interface Window { browser?: typeof browser; } namespace browser { namespace tabs { interface Tab { id?: number; url?: string; title?: string; active?: boolean; windowId?: number; } function query(queryInfo: { active?: boolean; currentWindow?: boolean; }): Promise; function sendMessage(tabId: number, message: any): Promise; function create(createProperties: { url: string; }): Promise; } namespace storage { namespace sync { function get(keys?: string | string[] | null): Promise>; function set(items: Record): Promise; function remove(keys: string | string[]): Promise; function clear(): Promise; } namespace local { function get(keys?: string | string[] | null): Promise>; function set(items: Record): Promise; function remove(keys: string | string[]): Promise; function clear(): Promise; } } namespace runtime { function sendNativeMessage(application: string, message: any): Promise; function sendMessage(message: any): Promise; const onMessage: { addListener: (callback: (message: any, sender: any, sendResponse: (response?: any) => void) => boolean | undefined | Promise) => void; removeListener: (callback: (...args: any[]) => any) => void; }; } } } /** * Check if running in a Safari extension web context */ export declare function isSafariExtension(): boolean; /** * Get the browser API (Safari uses 'browser', Chrome uses 'chrome') */ export declare function getBrowserAPI(): typeof browser | null; export interface BrowserTab { id?: number; url: string; title: string; active: boolean; } /** * Hook to get the current active browser tab */ export declare function useBrowserTab(): BrowserTab | null; /** * Hook to manage browser storage (synced across devices) */ export declare function useBrowserStorage(key: string, defaultValue: T): [T, (value: T) => Promise, boolean]; /** * Hook to manage local browser storage (not synced) */ export declare function useLocalBrowserStorage(key: string, defaultValue: T): [T, (value: T) => Promise, boolean]; /** * Hook to send messages to content scripts */ export declare function useSendToContentScript(): (message: any) => Promise; /** * Hook to send messages to the native Swift handler */ export declare function useSendToNative(): (message: any) => Promise; /** * Hook to listen for messages from content scripts or background */ export declare function useMessageListener(callback: (message: any, sender: any) => any | Promise): void; /** * Open a new tab with the specified URL */ export declare function openTab(url: string): Promise; /** * Close the extension popup */ export declare function closePopup(): void; /** * Copy text to clipboard */ export declare function copyToClipboard(text: string): Promise; /** * Bootstrap a React component for Safari extension popup. * ReactDOM lives in `bootstrapWeb.web.ts` so native Metro never sees it. */ export declare function bootstrapSafariExtension(_targetName: string, Component: React.ComponentType): void; //# sourceMappingURL=index.d.ts.map