import { MaybeRefOrGetter, Ref } from '../../node_modules/vue'; import { Parent } from 'pym.js'; declare global { interface Window { pym: { Parent: new (id: string, url: string, options: object) => Parent; }; } } /** * Prefix shared by every container id so generated ids stay recognisable and * collision-free across ICIJ embeds. */ type StartsWithIcijIframe = `icij-iframe-${string}`; /** * Reactive options driving the responsive iframe. They mirror the `url` and * `options` props of the `ResponsiveIframe` component. */ export interface UseResponsiveIframeOptions { /** * URL of the generated iframe code, loaded by the Pym parent. */ url: MaybeRefOrGetter; /** * Options forwarded to the constructor of the Pym parent instance. */ options?: MaybeRefOrGetter; } /** * Reactive API returned by {@link useResponsiveIframe}. */ export interface UseResponsiveIframe { /** * Unique id to bind on the container element the Pym parent mounts into. */ iframeId: Ref; /** * The live Pym parent instance, or `null` until it is created on mount. */ pymParent: Ref; } /** * Owns the parent side of the Pym.js resize messaging for the * `ResponsiveIframe` component: generates a unique container id, lazily loads * the Pym parent bundle on mount, creates the Pym parent that listens for * height messages from the embedded page, and tears it down on unmount. * * @param options - Reactive iframe options (see {@link UseResponsiveIframeOptions}). * @returns The {@link UseResponsiveIframe} API: the `iframeId` ref to bind on * the container element and the live `pymParent` ref. * @example * // Internal building block of the `ResponsiveIframe` component; not exported * // from the package root. Inside a `