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

@todesktop/client-util

Package Overview
Dependencies
Maintainers
4
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.0-alpha1 to 1.0.0-alpha2

todesktop-client-util-1.0.0-alpha1.tgz

106

index.d.ts
/**
* Barebones EventEmitter implementation for API namespaces.
*/
import type { BrowserWindow, WebContents } from "@todesktop/client-electron-types";
/**

@@ -18,1 +19,106 @@ * Setup the ability to register an event handler for the given `eventMappings`.

}>(eventMappings: E) => (event: "*" | keyof E, callback: (...any: any[]) => void) => void;
export declare type MethodFunc = (...args: any[]) => unknown;
declare type MethodsOnly<O, N extends keyof O> = Pick<O, N>;
declare type PropsOnly<O, N extends keyof O> = Pick<O, N>;
declare type _BrowserWindowMethodWhitelist = MethodsOnly<BrowserWindow, "show" | "isMinimized" | "setAspectRatio">;
declare type _BrowserWindowPropWhitelist = PropsOnly<BrowserWindow, "id">;
declare type _BrowserWindow = _BrowserWindowMethodWhitelist & _BrowserWindowPropWhitelist;
declare type _WebContentsMethodWhitelist = MethodsOnly<WebContents, "getZoomLevel" | "setZoomLevel" | "getZoomFactor" | "setZoomFactor">;
declare type _WebContentsPropWhitelist = PropsOnly<WebContents, "id">;
declare type _WebContents = _WebContentsMethodWhitelist & _WebContentsPropWhitelist;
export interface NamespacesV1 {
_BrowserWindow: _BrowserWindow;
_WebContents: _WebContents;
}
/**
* @internal
* @privateRemarks
* Options to set when invoking a remote request.
*/
export interface InvokeCommand<NS, M, Func extends MethodFunc> {
/**
* The namespace containing the method you wish to invoke.
*/
namespace: NS;
/**
* The method you wish to invoke on the given namespace.
*/
method: M;
/**
* Optional argument to specify an identifier this method call should
* act on.
*/
id?: unknown;
/**
* Any arguments required by the method.
*/
args: Parameters<Func>;
}
/**
* @internal
* @privateRemarks
* The payload to be executed/processed by the backend.
* Currently, this is simply a single command.
*/
export interface InvokePayload<NS, M, Func extends MethodFunc> {
/**
* The command to execute.
*/
command: InvokeCommand<NS, M, Func>;
}
/**
* @internal
* @privateRemarks
* Metadata that may optionally be processed by the backend to determine
* behaviour.
* This is used to provide additional context, potentially to correct incorrect
* behaviour identified in the future.
*/
export interface InvokeMetadata {
/**
* Information relating to the package invoking a remote method.
*/
package: {
/**
* The name of the package invoking a remote method.
*/
name: string;
/**
* The version of the package invoking a remote method.
*/
version: string;
};
/**
* Information relating to the `invoke()` interface currently being used
*/
invoke: {
/**
* Specifies the version of `invoke()` to be used.
*/
version: string;
};
}
export interface InvokeOptions<NS, M, Func extends MethodFunc> {
metadata: {
package: {
name: string;
version: string;
};
invoke: {
version: string;
};
};
payload: InvokePayload<NS, M, Func>;
}
/**
* Method to interact with ToDesktop's messaging API.
*
* @privateRemarks
* Use this API to invoke exposed methods from wthin the renderer.
* It provides additional type safety, and a standard interface for mapping
* calls to the global `todesktop.invoke()` function.
*
* @internal
*/
export declare function _createInvokeWithMetadata(name: string, version: string): <NS extends NamespacesV1 = NamespacesV1, NSName extends keyof NS = keyof NS, MethodName extends keyof NS[NSName] = keyof NS[NSName], Func extends MethodFunc = NS[NSName][MethodName]>(command: InvokeCommand<NSName, MethodName, Func>) => Promise<ReturnType<Func>>;
export {};

@@ -27,1 +27,25 @@ /**

};
/**
* Method to interact with ToDesktop's messaging API.
*
* @privateRemarks
* Use this API to invoke exposed methods from wthin the renderer.
* It provides additional type safety, and a standard interface for mapping
* calls to the global `todesktop.invoke()` function.
*
* @internal
*/
export function _createInvokeWithMetadata(name, version) {
return function _invoke(command) {
const options = {
metadata: {
package: { name, version },
invoke: { version: "1.0.0" },
},
payload: {
command,
},
};
return window["todesktop"]["invoke"](options);
};
}

6

package.json
{
"name": "@todesktop/client-util",
"version": "1.0.0-alpha1",
"version": "1.0.0-alpha2",
"description": "Utility functions for ToDesktop client libraries",

@@ -22,5 +22,7 @@ "main": "index.js",

"agadoo": "^2.0.0",
"electron": "^12.0.12",
"typescript": "^4.3.4"
},
"dependencies": {
"@todesktop/client-electron-types": "^12.0.0"
}
}
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