Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@todesktop/client-util

Package Overview
Dependencies
Maintainers
3
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@todesktop/client-util - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

index.d.ts

@@ -19,3 +19,3 @@ /**

[key: string]: string;
}>(eventMappings: E) => (event: "*" | keyof E, callback: (...any: any[]) => void) => void;
}>(eventMappings: E) => (event: "*" | keyof E, callback: (...any: any[]) => void, eventId?: string) => void;
export declare type MethodFunc = (...args: any[]) => unknown;

@@ -22,0 +22,0 @@ export declare type ConstructorFunc = new (...args: unknown[]) => unknown;

/**
* Barebones EventEmitter implementation for API namespaces.
*/
import { nanoid } from "nanoid";
import { checkIfCompatibleWithBackend } from "./checkIfCompatibleWithBackend.js";

@@ -12,9 +13,10 @@ const safeWindowToDesktop = typeof window !== "undefined" && window["todesktop"];

export const setupAddEventListener = (eventMappings) => async (event, callback) => {
const eventId = nanoid();
const eventsToListenFor = event === "*" ? Object.keys(eventMappings) : [event];
for (const eventName of eventsToListenFor) {
const legacyName = eventMappings[eventName];
safeWindowToDesktop === null || safeWindowToDesktop === void 0 ? void 0 : safeWindowToDesktop.on(legacyName, callback);
safeWindowToDesktop === null || safeWindowToDesktop === void 0 ? void 0 : safeWindowToDesktop.on(legacyName, callback, eventId);
}
const off = setupRemoveEventListener(eventMappings);
return async () => off(event, callback);
return async () => off(event, callback, eventId);
};

@@ -26,7 +28,7 @@ // TODO: Remove legacy event support in 2.0

*/
export const setupRemoveEventListener = (eventMappings) => (event, callback) => {
export const setupRemoveEventListener = (eventMappings) => (event, callback, eventId) => {
const eventsToListenFor = event === "*" ? Object.keys(eventMappings) : [event];
for (const eventName of eventsToListenFor) {
const legacyName = eventMappings[eventName];
safeWindowToDesktop === null || safeWindowToDesktop === void 0 ? void 0 : safeWindowToDesktop.off(legacyName, callback);
safeWindowToDesktop === null || safeWindowToDesktop === void 0 ? void 0 : safeWindowToDesktop.off(legacyName, callback, eventId);
}

@@ -33,0 +35,0 @@ };

{
"name": "@todesktop/client-util",
"version": "1.0.1",
"version": "1.0.2",
"description": "Utility functions for ToDesktop client libraries",

@@ -29,4 +29,5 @@ "main": "index.js",

"@todesktop/client-electron-types": "^16.0.9",
"@todesktop/client-electron-updater-types": "^5.2.3"
"@todesktop/client-electron-updater-types": "^5.2.3",
"nanoid": "^4.0.2"
}
}
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