UNPKG

@awell-health/navi-js

Version:

Navi.js loading utility - loads the Navi SDK from CDN

47 lines (38 loc) 1.1 kB
import type { RenderOptions } from "@awell-health/navi-core"; export interface NaviLoadOptions { /** Force always fetch the script, even if it's already loaded */ alwaysFetch?: boolean; /** Override the CDN origin for loading navi.js script */ origin?: string; /** Override the embed origin for iframe destinations */ embedOrigin?: string; /** Enable verbose logging */ verbose?: boolean; } export interface NaviInstance { render: ( containerId: string, options: RenderOptions ) => Promise<NaviEmbedInstance>; } // Re-export RenderOptions from navi-core for consistency export type { RenderOptions }; export interface NaviEmbedInstance { instanceId: string; destroy: () => void; iframe: HTMLIFrameElement; on: (event: string, callback: (data: any) => void) => void; } export interface NaviConstructor { (publishableKey: string, options?: NaviLoadOptions): NaviInstance; version?: string; } export interface Navi extends NaviInstance { version?: string; } // Global window interface declare global { interface Window { Navi?: NaviConstructor; } }