@musubi/browser-extension-link
v0.12.0
Published
<div style="text-align: center;width:100%"> <h1> Musubi πͺ’ </h1> <strong>End-to-end typesafe communication. π</strong> </div>
Downloads
30
Readme
@musubi/browser-extension-link
Adapter for using Musubi in browser extension.
Documentation
Full documentation for musubi
can be found here.
Installation
# npm
npm install @musubi/browser-extension-link
# Yarn
yarn add @musubi/browser-extension-link
Usage
// Background/service worker script
import { createBrowserExtensionLink } from '@musubi/browser-extension-link';
import { MusubiReceiver } from '@musubi/core';
import { schema } from '../schema';
import * as browser from 'webextension-polyfill';
async function main() {
const link = createBrowserExtensionLink('background');
const receiver = new MusubiReceiver(schema, [
link.receiver,
]);
receiver.handleQuery('getTabs', async () => {
return browser.tabs.query({});
});
console.info('background script ready');
}
main().catch(console.error);