UNPKG

@awell-health/navi-js

Version:

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

34 lines (33 loc) 1.04 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>; } 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; } declare global { interface Window { Navi?: NaviConstructor; } }