New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

webext-messenger

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webext-messenger - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

10

distribution/index.d.ts
/// <reference types="firefox-webext-browser" />
declare type Arguments = any[];
declare type Method = (this: browser.runtime.MessageSender, ...args: Arguments) => Promise<unknown>;
export declare type Contract<TMmethod extends Method = Method> = {
type: string;
method?: TMmethod;
};
/**
* Registers a handler for a specific method.
* Returns a function that registers a handler for a specific method.
* To be called in the receiving end.
*/
export declare function registerMethod<TContract extends Required<Contract>>(type: TContract["type"], handler: TContract["method"]): void;
export declare function getRegistration(type: string, method: Method): () => void;
/**

@@ -17,3 +13,3 @@ * Replicates the original method, including its types.

*/
export declare function getMethod<TContract extends Contract, LocalMethod extends OmitThisParameter<NonNullable<TContract["method"]>>>({ type }: TContract): LocalMethod;
export declare function getMethod<TMethod extends Method>(type: string): OmitThisParameter<TMethod>;
export {};

@@ -24,11 +24,13 @@ function isObject(value) {

/**
* Registers a handler for a specific method.
* Returns a function that registers a handler for a specific method.
* To be called in the receiving end.
*/
export function registerMethod(type, handler) {
if (handlers.has(type)) {
throw new Error(`Handler already set for ${type}`);
}
handlers.set(type, handler);
browser.runtime.onMessage.addListener(onMessageListener);
export function getRegistration(type, method) {
return () => {
if (handlers.has(type)) {
throw new Error(`Handler already set for ${type}`);
}
handlers.set(type, method);
browser.runtime.onMessage.addListener(onMessageListener);
};
}

@@ -39,3 +41,3 @@ /**

*/
export function getMethod({ type }) {
export function getMethod(type) {
return (async (...args) => browser.runtime.sendMessage({

@@ -42,0 +44,0 @@ type,

{
"name": "webext-messenger",
"version": "0.0.1",
"version": "0.1.0",
"description": "Browser Extension component messaging framework",

@@ -5,0 +5,0 @@ "keywords": [],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc