@todesktop/client-util
Advanced tools
Comparing version 1.0.4 to 1.1.0
# @todesktop/client-util | ||
## 1.1.0 | ||
### Minor Changes | ||
- a202b4a: feat: add `session.setDisplayMediaRequestHandler` support | ||
## 1.0.4 | ||
@@ -4,0 +10,0 @@ |
/** | ||
* Barebones EventEmitter implementation for API namespaces. | ||
*/ | ||
import type { BrowserWindow, WebContents, Tray, NativeImage, nativeImage, NativeTheme, Menu, MenuItem, BrowserView, Notification, App, Screen, Session, session, SafeStorage, Clipboard } from "@todesktop/client-electron-types"; | ||
import type { BrowserWindow, WebContents, Tray, NativeImage, nativeImage, NativeTheme, Menu, MenuItem, BrowserView, WebContentsView, Notification, App, Screen, Session, session, SafeStorage, Clipboard } from "@todesktop/client-electron-types"; | ||
import type AutoUpdater from "@todesktop/client-todesktop-runtime-types/dist/AutoUpdater.js"; | ||
@@ -14,2 +14,5 @@ import type { AppUpdater } from "@todesktop/client-electron-updater-types"; | ||
}>(eventMappings: E) => (event: keyof E | "*", callback: (...any: any[]) => void) => Promise<() => Promise<void>>; | ||
export declare const typedSetupAddEventListener: <E extends { | ||
[key: string]: string; | ||
}, C extends { [K in keyof E]: (...any: any[]) => void; }>(eventMappings: E) => (event: keyof E | "*", callback: C[keyof E]) => Promise<() => Promise<void>>; | ||
/** | ||
@@ -38,4 +41,5 @@ * Setup the ability to unregister an event handler for the given `eventMappings`. | ||
BrowserView: BrowserView; | ||
WebContentsView: WebContentsView; | ||
process: NodeJS.Process; | ||
Session: Session; | ||
session: Session; | ||
safeStorage: SafeStorage; | ||
@@ -50,2 +54,3 @@ clipboard: Clipboard; | ||
BrowserView: typeof BrowserView; | ||
WebContentsView: typeof WebContentsView; | ||
Notification: typeof Notification; | ||
@@ -52,0 +57,0 @@ electronUpdater: AppUpdater; |
10
index.js
@@ -22,2 +22,12 @@ /** | ||
}; | ||
export const typedSetupAddEventListener = (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, eventId); | ||
} | ||
const off = setupRemoveEventListener(eventMappings); | ||
return async () => off(event, callback, eventId); | ||
}; | ||
// TODO: Remove legacy event support in 2.0 | ||
@@ -24,0 +34,0 @@ /** |
{ | ||
"name": "@todesktop/client-util", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"description": "Utility functions for ToDesktop client libraries", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32207
595