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.0-alpha2 to 1.0.0-alpha20

checkIfCompatibleWithBackend.d.ts

109

index.d.ts
/**
* Barebones EventEmitter implementation for API namespaces.
*/
import type { BrowserWindow, WebContents } from "@todesktop/client-electron-types";
import type { BrowserWindow, WebContents, Tray, NativeImage, nativeImage, NativeTheme, Menu, MenuItem, BrowserView, Notification } from "@todesktop/client-electron-types";
import type { AppUpdater } from "@todesktop/client-electron-updater-types";
/**

@@ -20,14 +21,36 @@ * Setup the ability to register an event handler for the given `eventMappings`.

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;
export declare type ConstructorFunc = new (...args: any) => any;
export interface NamespacesInstancesV1 {
BrowserWindow: BrowserWindow;
WebContents: WebContents;
Tray: Tray;
NativeImage: NativeImage;
NativeTheme: NativeTheme;
Notification: Notification;
Menu: Menu;
MenuItem: MenuItem;
BrowserView: BrowserView;
process: NodeJS.Process;
}
export interface NamespacesStaticV1 {
BrowserWindow: typeof BrowserWindow;
Tray: typeof Tray;
Menu: typeof Menu;
MenuItem: typeof MenuItem;
BrowserView: typeof BrowserView;
Notification: typeof Notification;
electronUpdater: AppUpdater;
NativeImage: typeof nativeImage;
dock: Electron.Dock;
}
export interface InstanceRefObject {
id: string;
namespace: string;
type: string;
}
declare type ChangeInstancesToInstanceRefsSingle<T> = T extends NamespacesInstancesV1[keyof NamespacesInstancesV1] ? InstanceRefObject : T;
declare type ChangeInstancesToInstanceRefsInParams<Obj> = {
[K in keyof Obj]: ChangeInstancesToInstanceRefsSingle<Obj[K]>;
};
declare type ChangeInstancesToInstanceRefs<T> = T extends any[] ? ChangeInstancesToInstanceRefsInParams<T> : ChangeInstancesToInstanceRefsSingle<T>;
/**

@@ -38,3 +61,3 @@ * @internal

*/
export interface InvokeCommand<NS, M, Func extends MethodFunc> {
export interface InvokeMethodCommand<NS, M, Func extends MethodFunc, IR> {
/**

@@ -49,11 +72,39 @@ * The namespace containing the method you wish to invoke.

/**
* Optional argument to specify an identifier this method call should
* act on.
* Any arguments required by the method.
*/
id?: unknown;
args: ChangeInstancesToInstanceRefs<Parameters<Func>>;
/**
* Any arguments required by the method.
* A refernce to the instance on which to invoke the method
*/
args: Parameters<Func>;
instanceRef?: IR;
}
export interface InvokeConstructorCommand<NS, Func extends ConstructorFunc> {
/**
* The namespace containing the class you wish to construct.
*/
namespace: NS;
/**
* Any arguments required by the constructor.
*/
args: ChangeInstancesToInstanceRefs<ConstructorParameters<Func>>;
}
export interface InvokeConstructorCommandWithPlaceholderMethod<NS, Func extends ConstructorFunc> {
namespace: NS;
args: ChangeInstancesToInstanceRefs<ConstructorParameters<Func>>;
method: ":new";
}
export interface InvokePropCommand<NS, M, IR> {
/**
* The namespace containing the peroperty you wish to invoke.
*/
namespace: NS;
/**
* The property you wish to invoke on the given namespace.
*/
property: M;
/**
* A refernce to the instance on which to access the property
*/
instanceRef?: IR;
}
/**

@@ -65,8 +116,14 @@ * @internal

*/
export interface InvokePayload<NS, M, Func extends MethodFunc> {
export interface InvokePayload<NS, M, Func, IR> {
/**
* The command to execute.
*/
command: InvokeCommand<NS, M, Func>;
command: Func extends MethodFunc ? InvokeMethodCommand<NS, M, Func, IR> : InvokePropCommand<NS, M, IR>;
}
export interface InvokeConstructorPayload<NS, Func> {
/**
* The command to execute.
*/
command: Func extends ConstructorFunc ? InvokeConstructorCommand<NS, Func> : never;
}
/**

@@ -104,3 +161,3 @@ * @internal

}
export interface InvokeOptions<NS, M, Func extends MethodFunc> {
export interface InvokeOptions<T> {
metadata: {

@@ -115,3 +172,3 @@ package: {

};
payload: InvokePayload<NS, M, Func>;
payload: T;
}

@@ -128,3 +185,7 @@ /**

*/
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 {};
export declare function createInvokeWithMetadata(name: string, version: string): {
invoke: <NS = NamespacesStaticV1 & NamespacesInstancesV1, NSName extends keyof NS = keyof NS, MethodName extends keyof NS[NSName] = keyof NS[NSName], Func = NS[NSName][MethodName], InstanceRef = void | InstanceRefObject>(command: Func extends MethodFunc ? InvokeMethodCommand<NSName, MethodName, Func, InstanceRef> : InvokePropCommand<NSName, MethodName, InstanceRef>) => Promise<Func extends MethodFunc ? ChangeInstancesToInstanceRefs<ReturnType<Func>> : Func>;
construct: <NS_1 = NamespacesStaticV1, NSName_1 extends keyof NS_1 = keyof NS_1, Func_1 = NS_1[NSName_1]>(command: Func_1 extends ConstructorFunc ? InvokeConstructorCommand<NSName_1, Func_1> : never) => Promise<InstanceRefObject>;
};
export { checkIfCompatibleWithBackend } from "./checkIfCompatibleWithBackend.js";
export { checkIfCompatibleWithPlugin } from "./checkIfCompatibleWithPlugin.js";
/**
* Barebones EventEmitter implementation for API namespaces.
*/
const legacy = window["todesktop"];
const legacy = typeof window !== "undefined" && window["todesktop"];
// TODO: Remove legacy event support in 2.0
/**

@@ -16,2 +17,3 @@ * Setup the ability to register an event handler for the given `eventMappings`.

};
// TODO: Remove legacy event support in 2.0
/**

@@ -38,9 +40,11 @@ * Setup the ability to unregister an event handler for the given `eventMappings`.

*/
export function _createInvokeWithMetadata(name, version) {
return function _invoke(command) {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function createInvokeWithMetadata(name, version) {
const metadata = {
package: { name, version },
invoke: { version: "1.0.0" },
};
function invoke(command) {
const options = {
metadata: {
package: { name, version },
invoke: { version: "1.0.0" },
},
metadata,
payload: {

@@ -51,3 +55,15 @@ command,

return window["todesktop"]["invoke"](options);
};
}
function construct(command) {
const options = {
metadata,
payload: {
command: Object.assign(Object.assign({}, command), { method: ":new" }),
},
};
return window["todesktop"]["invoke"](options);
}
return { invoke, construct };
}
export { checkIfCompatibleWithBackend } from "./checkIfCompatibleWithBackend.js";
export { checkIfCompatibleWithPlugin } from "./checkIfCompatibleWithPlugin.js";
{
"name": "@todesktop/client-util",
"version": "1.0.0-alpha2",
"version": "1.0.0-alpha20",
"description": "Utility functions for ToDesktop client libraries",
"main": "index.js",
"type": "module",
"scripts": {

@@ -22,7 +23,8 @@ "lint:fix": "npm run lint:check -- --fix",

"agadoo": "^2.0.0",
"typescript": "^4.3.4"
"typescript": "^4.7.2"
},
"dependencies": {
"@todesktop/client-electron-types": "^12.0.0"
"@todesktop/client-electron-types": "^16.0.9",
"@todesktop/client-electron-updater-types": "^5.2.3"
}
}
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./"
"outDir": "./",
"skipLibCheck": true
},

@@ -6,0 +7,0 @@ "include": ["./"],

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