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

webext-messenger

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webext-messenger - npm Package Compare versions

Comparing version

to
0.14.0

@@ -1,2 +0,2 @@

import { PublicMethod, PublicMethodWithTarget, Options, Target, UrlTarget } from "./types.js";
import { PublicMethod, PublicMethodWithTarget, Options, Target, PageTarget } from "./types.js";
import { SetReturnType } from "type-fest";

@@ -6,11 +6,9 @@ export declare const errorNonExistingTarget = "Could not establish connection. Receiving end does not exist.";

isNotification: true;
}, target: Target | UrlTarget, ...args: Parameters<Method>): void;
declare function messenger<Type extends keyof MessengerMethods, Method extends MessengerMethods[Type], ReturnValue extends ReturnType<Method>>(type: Type, options: Options, target: Target | UrlTarget, ...args: Parameters<Method>): ReturnValue;
declare function getMethod<Type extends keyof MessengerMethods, Method extends MessengerMethods[Type], PublicMethodType extends PublicMethod<Method>>(type: Type, target: Target | UrlTarget): PublicMethodType;
}, target: Target | PageTarget, ...args: Parameters<Method>): void;
declare function messenger<Type extends keyof MessengerMethods, Method extends MessengerMethods[Type], ReturnValue extends ReturnType<Method>>(type: Type, options: Options, target: Target | PageTarget, ...args: Parameters<Method>): ReturnValue;
declare function getMethod<Type extends keyof MessengerMethods, Method extends MessengerMethods[Type], PublicMethodType extends PublicMethod<Method>>(type: Type, target: Target | PageTarget): PublicMethodType;
declare function getMethod<Type extends keyof MessengerMethods, Method extends MessengerMethods[Type], PublicMethodWithDynamicTarget extends PublicMethodWithTarget<Method>>(type: Type): PublicMethodWithDynamicTarget;
declare function getNotifier<Type extends keyof MessengerMethods, Method extends MessengerMethods[Type], PublicMethodType extends SetReturnType<PublicMethod<Method>, void>>(type: Type, target: Target | UrlTarget): PublicMethodType;
declare function getNotifier<Type extends keyof MessengerMethods, Method extends MessengerMethods[Type], PublicMethodType extends SetReturnType<PublicMethod<Method>, void>>(type: Type, target: Target | PageTarget): PublicMethodType;
declare function getNotifier<Type extends keyof MessengerMethods, Method extends MessengerMethods[Type], PublicMethodWithDynamicTarget extends SetReturnType<PublicMethodWithTarget<Method>, void>>(type: Type): PublicMethodWithDynamicTarget;
export { messenger, getMethod, getNotifier };
export declare const backgroundTarget: {
url: string;
};
export declare const backgroundTarget: PageTarget;

@@ -50,4 +50,4 @@ import browser from "webextension-polyfill";

function messenger(type, options, target, ...args) {
if ("url" in target) {
if (target.url === "background" && isBackgroundPage()) {
if ("page" in target) {
if (target.page === "background" && isBackgroundPage()) {
const handler = handlers.get(type);

@@ -100,2 +100,2 @@ if (handler) {

export { messenger, getMethod, getNotifier };
export const backgroundTarget = { url: "background" };
export const backgroundTarget = { page: "background" };

@@ -51,6 +51,6 @@ import { Runtime } from "webextension-polyfill";

}
export interface UrlTarget {
export interface PageTarget {
tabId?: number;
url: string;
page: string;
}
export {};
{
"name": "webext-messenger",
"version": "0.14.0-0",
"version": "0.14.0",
"description": "Browser Extension component messaging framework",

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