@todesktop/client-util
Advanced tools
Comparing version 1.0.0-alpha2 to 1.0.0-alpha3
@@ -20,14 +20,9 @@ /** | ||
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 interface NamespacesInstancesV1 { | ||
BrowserWindow: BrowserWindow; | ||
WebContents: WebContents; | ||
} | ||
export interface NamespacesStaticV1 { | ||
BrowserWindow: typeof BrowserWindow; | ||
} | ||
/** | ||
@@ -38,3 +33,3 @@ * @internal | ||
*/ | ||
export interface InvokeCommand<NS, M, Func extends MethodFunc> { | ||
export interface InvokeMethodCommand<NS, M, Func extends MethodFunc, IR> { | ||
/** | ||
@@ -49,11 +44,24 @@ * 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: 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 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,7 +73,7 @@ * @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>; | ||
} | ||
@@ -104,3 +112,3 @@ /** | ||
} | ||
export interface InvokeOptions<NS, M, Func extends MethodFunc> { | ||
export interface InvokeOptions<NS, M, Func, IR> { | ||
metadata: { | ||
@@ -115,3 +123,3 @@ package: { | ||
}; | ||
payload: InvokePayload<NS, M, Func>; | ||
payload: InvokePayload<NS, M, Func, IR>; | ||
} | ||
@@ -128,3 +136,2 @@ /** | ||
*/ | ||
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): <NS = NamespacesStaticV1 & NamespacesInstancesV1, NSName extends keyof NS = keyof NS, MethodName extends keyof NS[NSName] = keyof NS[NSName], Func = NS[NSName][MethodName], InstanceRef = void | Record<string, unknown>>(command: Func extends MethodFunc ? InvokeMethodCommand<NSName, MethodName, Func, InstanceRef> : InvokePropCommand<NSName, MethodName, InstanceRef>) => Promise<Func extends MethodFunc ? ReturnType<Func> : Func>; |
@@ -37,4 +37,5 @@ /** | ||
*/ | ||
export function _createInvokeWithMetadata(name, version) { | ||
return function _invoke(command) { | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
export function createInvokeWithMetadata(name, version) { | ||
function _invoke(command) { | ||
const options = { | ||
@@ -50,3 +51,4 @@ metadata: { | ||
return window["todesktop"]["invoke"](options); | ||
}; | ||
} | ||
return _invoke; | ||
} |
{ | ||
"name": "@todesktop/client-util", | ||
"version": "1.0.0-alpha2", | ||
"version": "1.0.0-alpha3", | ||
"description": "Utility functions for ToDesktop client libraries", | ||
@@ -25,4 +25,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"@todesktop/client-electron-types": "^12.0.0" | ||
"@todesktop/client-electron-types": "^16.0.9" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
242375
191
+ Added@todesktop/client-electron-types@16.1.0(transitive)
+ Addedtypescript@4.9.5(transitive)
- Removed@todesktop/client-electron-types@12.0.0(transitive)