mirror of
https://github.com/XFox111/TabsAsideExtension.git
synced 2026-04-22 07:58:01 +03:00
27 lines
664 B
TypeScript
27 lines
664 B
TypeScript
import { GraphicsStorage } from "@/models/CollectionModels";
|
|
import { defineExtensionMessaging, ExtensionMessenger } from "@webext-core/messaging";
|
|
|
|
type ProtocolMap =
|
|
{
|
|
addThumbnail(data: { url: string; thumbnail: string; }): void;
|
|
getGraphicsCache(): GraphicsStorage;
|
|
refreshCollections(): void;
|
|
};
|
|
|
|
const protocol: ExtensionMessenger<ProtocolMap> = defineExtensionMessaging<ProtocolMap>();
|
|
|
|
export const onMessage = protocol.onMessage;
|
|
|
|
export const sendMessage: ExtensionMessenger<ProtocolMap>["sendMessage"] = async (...args) =>
|
|
{
|
|
try
|
|
{
|
|
return await protocol.sendMessage(...args);
|
|
}
|
|
catch (ex)
|
|
{
|
|
console.error(ex);
|
|
return undefined!;
|
|
}
|
|
};
|