import { RpcClient, RpcServer, injectRpcInfo, } from 'webextension-rpc'; // Only import the *types* of the remote script’s functions. import type { backgroundScriptRpcServer } from './background-script'; // From background to content script. const contentScriptRpcServer = new RpcServer({ async setColour(colour: string) { document.body.style.backgroundColor = colour; }, }); export type { contentScriptRpcServer } // From content to background script. const duplicateMe = new RpcClient().func('duplicateTab'); // The injectRpcInfo placeholder will be replaced by actual info. const newTabId = await duplicateMe(injectRpcInfo, true);