Skip to content

💬 Messaging in Web Extensions made easy. Batteries included.

License

Notifications You must be signed in to change notification settings

CyberhavenInc/webext-bridge-typed

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

I believe that this type of library should be strongly typed. Additionally, I want message callables to be generated from TypeScript event types (see the example below). This represents a significant shift in API usage, so I decided to fork it.

Install

npm install @cyberhaven/webext-bridge-typed

# or via yarn
yarn add @cyberhaven/webext-bridge-typed

Usage

import { createBridge } from "webext-bridge-typed"

type EventsMap = {
	upload: (file: string) => void;
	download: (file: string, open = false) => void;
}

const bridge = createBridge<EventsMap>();

// In content script (or background)
bridge.upload('test.txt');

// In background
bridge.onUpload((file) => {
	console.log('Upload occured', file);
})

About

💬 Messaging in Web Extensions made easy. Batteries included.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%