import { Config } from 'config.types' import ExternalApi from 'lib/external-api' type ExternalApiArgs = (_config: Partial) => Partial | boolean export default function initializeExternalApi( appConfig: Partial | ExternalApiArgs, ): void { if (window.seamly && !Array.isArray(window.seamly)) { throw new Error( 'Seamly UI has already been initialised. Use the window.seamly object to start new instances instead.', ) } const seamlyActions = Array.isArray(window.seamly) ? window.seamly : [] const seamly = new ExternalApi(appConfig) // @ts-ignore window.seamly = { push: seamly.push.bind(seamly) } seamly.push(...seamlyActions) }