HEX
Server: Apache
System: Linux webd006.cluster128.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User: zwafgyp (177615)
PHP: 7.4.33
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/zwafgyp/locationdebateau/wp-content/plugins/leadin/scripts/iframe/useBackgroundApp.ts
import { createContext, useContext } from 'react';
import {
  deviceId,
  hubspotBaseUrl,
  locale,
  portalId,
} from '../constants/leadinConfig';
import { Message } from './messageMiddleware';

export const BackgroudAppContext = createContext<any>(null);

export function useBackgroundAppContext() {
  return useContext(BackgroudAppContext);
}

export function usePostBackgroundMessage() {
  const app = useBackgroundAppContext();

  return (message: Message) => {
    app.postMessage(message);
  };
}

export function usePostAsyncBackgroundMessage(): (
  message: Message
) => Promise<any> {
  const app = useBackgroundAppContext();
  return (message: Message) => app.postAsyncMessage(message);
}