Comparing version 1.4.3 to 1.5.0
@@ -359,4 +359,14 @@ import { MessageEvent, Event, CloseEvent, ErrorEvent } from 'ws'; | ||
interface WmClientOptions { | ||
/** IPC server port to connect to. Defaults to `6123`. */ | ||
/** | ||
* IPC server port to connect to. | ||
* | ||
* Defaults to `6123`. | ||
*/ | ||
port?: number; | ||
/** | ||
* Reconnection interval in milliseconds. | ||
* | ||
* Defaults to `5000` (5 seconds). | ||
*/ | ||
reconnectInterval?: number; | ||
} | ||
@@ -373,6 +383,13 @@ /** Unregisters a callback. */ | ||
private readonly DEFAULT_PORT; | ||
/** Websocket connection to IPC server. */ | ||
private _socket; | ||
/** Promise used to prevent duplicate connections. */ | ||
private _createSocketPromise; | ||
private readonly DEFAULT_RECONNECT_INTERVAL; | ||
/** | ||
* Promise that resolves to `WebSocket` instance if connected. | ||
* | ||
* Prevents duplicate connections. | ||
*/ | ||
private _socketPromise; | ||
/** | ||
* Whether the connection was closed via {@link closeConnection}. | ||
*/ | ||
private _isManuallyClosed; | ||
private _onMessageCallbacks; | ||
@@ -391,2 +408,4 @@ private _onConnectCallbacks; | ||
* Gets all monitors. {@link Monitor} | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -396,2 +415,4 @@ queryMonitors(): Promise<MonitorsResponse>; | ||
* Gets all active workspaces. {@link Workspace} | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -401,2 +422,4 @@ queryWorkspaces(): Promise<WorkspacesResponse>; | ||
* Gets all managed windows. {@link Window} | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -407,2 +430,4 @@ queryWindows(): Promise<WindowsResponse>; | ||
* {@link Window} or a {@link Workspace} without any descendant windows. | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -412,2 +437,4 @@ queryFocused(): Promise<FocusedResponse>; | ||
* Gets the active binding modes. | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -417,2 +444,4 @@ queryBindingModes(): Promise<BindingModesResponse>; | ||
* Gets metadata about the running GlazeWM application. | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -422,2 +451,4 @@ queryAppMetadata(): Promise<AppMetadataResponse>; | ||
* Gets the tiling direction of the focused container. | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -431,3 +462,3 @@ queryTilingDirection(): Promise<TilingDirectionResponse>; | ||
* If not provided, this defaults to the currently focused container. | ||
* @throws If command fails. | ||
* @throws If the command errors or connection to IPC server fails. | ||
*/ | ||
@@ -438,3 +469,3 @@ runCommand(command: string, subjectContainerId?: string): Promise<RunCommandResponse>; | ||
* | ||
* @throws If connection attempt fails. | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -445,6 +476,8 @@ connect(): Promise<void>; | ||
*/ | ||
closeConnection(): void; | ||
closeConnection(): Promise<void>; | ||
/** | ||
* Registers a callback for a GlazeWM event type. | ||
* | ||
* Persists the subscription across reconnections. | ||
* | ||
* @example | ||
@@ -457,2 +490,3 @@ * ```typescript | ||
* ``` | ||
* @throws If *initial* connection to IPC server fails. | ||
*/ | ||
@@ -463,2 +497,4 @@ subscribe<T extends WmEventType>(event: T, callback: SubscribeCallback<T>): Promise<UnlistenFn>; | ||
* | ||
* Persists the subscription across reconnections. | ||
* | ||
* @example | ||
@@ -471,2 +507,3 @@ * ```typescript | ||
* ``` | ||
* @throws If *initial* connection to IPC server fails. | ||
*/ | ||
@@ -484,3 +521,3 @@ subscribeMany<T extends WmEventType[]>(events: T, callback: SubscribeCallback<T[number]>): Promise<UnlistenFn>; | ||
/** | ||
* Registers a callback for when the websocket connects. | ||
* Registers a callback for when the websocket connects or reconnects. | ||
* | ||
@@ -516,4 +553,3 @@ * @example | ||
* @private | ||
* @throws If message is invalid or IPC server is unable to handle the | ||
* message. | ||
* @throws If message is invalid or connection to IPC server fails. | ||
*/ | ||
@@ -537,6 +573,17 @@ private _sendAndWaitReply; | ||
* @private | ||
* @throws On disconnect or close. | ||
*/ | ||
private _waitForConnection; | ||
/** | ||
* @private | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
private _sendSubscribe; | ||
/** | ||
* @private | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
private _sendUnsubscribe; | ||
} | ||
export { AppMetadataResponse, ApplicationExitingEvent, BindingModeConfig, BindingModesChangedEvent, BindingModesResponse, ClientResponseMessage, ConnectCallback, Container, ContainerType, DisconnectCallback, DisplayState, ErrorCallback, EventSubscriptionMessage, FocusChangedEvent, FocusedContainerMovedEvent, FocusedResponse, KeybindingConfig, LengthUnit, MessageCallback, Monitor, MonitorAddedEvent, MonitorRemovedEvent, MonitorUpdatedEvent, MonitorsResponse, Rect, RectDelta, RootContainer, RunCommandResponse, ServerMessage, ServerMessageType, SplitContainer, SubscribeCallback, SubscribeResponse, TilingDirection, TilingDirectionChangedEvent, TilingDirectionResponse, UnlistenFn, UserConfigChangedEvent, Window, WindowManagedEvent, WindowState, WindowType, WindowUnmanagedEvent, WindowsResponse, WmClient, WmClientOptions, WmEvent, WmEventData, WmEventType, Workspace, WorkspaceActivatedEvent, WorkspaceDeactivatedEvent, WorkspaceUpdatedEvent, WorkspacesResponse }; |
@@ -55,6 +55,13 @@ "use strict"; | ||
DEFAULT_PORT = 6123; | ||
/** Websocket connection to IPC server. */ | ||
_socket = null; | ||
/** Promise used to prevent duplicate connections. */ | ||
_createSocketPromise = null; | ||
DEFAULT_RECONNECT_INTERVAL = 5e3; | ||
/** | ||
* Promise that resolves to `WebSocket` instance if connected. | ||
* | ||
* Prevents duplicate connections. | ||
*/ | ||
_socketPromise = null; | ||
/** | ||
* Whether the connection was closed via {@link closeConnection}. | ||
*/ | ||
_isManuallyClosed = false; | ||
_onMessageCallbacks = []; | ||
@@ -66,2 +73,4 @@ _onConnectCallbacks = []; | ||
* Gets all monitors. {@link Monitor} | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -73,2 +82,4 @@ async queryMonitors() { | ||
* Gets all active workspaces. {@link Workspace} | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -80,2 +91,4 @@ async queryWorkspaces() { | ||
* Gets all managed windows. {@link Window} | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -88,2 +101,4 @@ async queryWindows() { | ||
* {@link Window} or a {@link Workspace} without any descendant windows. | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -95,2 +110,4 @@ async queryFocused() { | ||
* Gets the active binding modes. | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -104,2 +121,4 @@ async queryBindingModes() { | ||
* Gets metadata about the running GlazeWM application. | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -113,2 +132,4 @@ async queryAppMetadata() { | ||
* Gets the tiling direction of the focused container. | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -126,3 +147,3 @@ async queryTilingDirection() { | ||
* If not provided, this defaults to the currently focused container. | ||
* @throws If command fails. | ||
* @throws If the command errors or connection to IPC server fails. | ||
*/ | ||
@@ -137,9 +158,7 @@ async runCommand(command, subjectContainerId) { | ||
* | ||
* @throws If connection attempt fails. | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
async connect() { | ||
if (!this._socket) { | ||
const socketPromise = this._createSocketPromise ?? (this._createSocketPromise = this._createSocket()); | ||
this._socket = await socketPromise; | ||
} | ||
this._isManuallyClosed = false; | ||
this._socketPromise ??= this._createSocket(); | ||
await this._waitForConnection(); | ||
@@ -150,4 +169,5 @@ } | ||
*/ | ||
closeConnection() { | ||
this._socket?.close(); | ||
async closeConnection() { | ||
this._isManuallyClosed = true; | ||
(await this._socketPromise)?.close(); | ||
} | ||
@@ -157,2 +177,4 @@ /** | ||
* | ||
* Persists the subscription across reconnections. | ||
* | ||
* @example | ||
@@ -165,2 +187,3 @@ * ```typescript | ||
* ``` | ||
* @throws If *initial* connection to IPC server fails. | ||
*/ | ||
@@ -173,2 +196,4 @@ async subscribe(event, callback) { | ||
* | ||
* Persists the subscription across reconnections. | ||
* | ||
* @example | ||
@@ -181,8 +206,7 @@ * ```typescript | ||
* ``` | ||
* @throws If *initial* connection to IPC server fails. | ||
*/ | ||
async subscribeMany(events, callback) { | ||
const { subscriptionId } = await this._sendAndWaitReply( | ||
`sub --events ${events.join(" ")}` | ||
); | ||
const unlisten = this.onMessage((e) => { | ||
let subscriptionId = await this._sendSubscribe(events); | ||
const unlistenMessage = this.onMessage((e) => { | ||
const serverMessage = JSON.parse( | ||
@@ -196,5 +220,10 @@ e.data | ||
}); | ||
const unlistenConnect = this.onConnect(async (e) => { | ||
this._sendUnsubscribe(subscriptionId); | ||
subscriptionId = await this._sendSubscribe(events); | ||
}); | ||
return async () => { | ||
unlisten(); | ||
await this._sendAndWaitReply(`unsub --id ${subscriptionId}`); | ||
unlistenMessage(); | ||
unlistenConnect(); | ||
await this._sendUnsubscribe(subscriptionId); | ||
}; | ||
@@ -214,3 +243,3 @@ } | ||
/** | ||
* Registers a callback for when the websocket connects. | ||
* Registers a callback for when the websocket connects or reconnects. | ||
* | ||
@@ -252,29 +281,33 @@ * @example | ||
* @private | ||
* @throws If message is invalid or IPC server is unable to handle the | ||
* message. | ||
* @throws If message is invalid or connection to IPC server fails. | ||
*/ | ||
async _sendAndWaitReply(message) { | ||
let unlisten; | ||
if (this._isManuallyClosed) { | ||
throw new Error( | ||
"Websocket connection was closed via `closeConnection`." | ||
); | ||
} | ||
await this.connect(); | ||
const socket = await this._socketPromise; | ||
return new Promise(async (resolve, reject) => { | ||
try { | ||
await this.connect(); | ||
this._socket.send(message); | ||
unlisten = this.onMessage((e) => { | ||
const serverMessage = JSON.parse( | ||
e.data | ||
); | ||
const isReplyMessage = serverMessage.messageType === "client_response" && serverMessage.clientMessage === message; | ||
if (isReplyMessage && serverMessage.error) { | ||
reject( | ||
`Server reply to message '${message}' has error: ${serverMessage.error}` | ||
); | ||
} | ||
if (isReplyMessage) { | ||
socket.send(message, (error) => { | ||
if (error) { | ||
reject(error); | ||
} | ||
}); | ||
const unlisten = this.onMessage((e) => { | ||
const serverMessage = JSON.parse( | ||
e.data | ||
); | ||
const isReplyMessage = serverMessage.messageType === "client_response" && serverMessage.clientMessage === message; | ||
if (isReplyMessage) { | ||
unlisten(); | ||
if (serverMessage.error) { | ||
reject(serverMessage.error); | ||
} else { | ||
resolve(serverMessage.data); | ||
} | ||
}); | ||
} catch (err) { | ||
reject(err); | ||
} | ||
}).finally(() => unlisten()); | ||
} | ||
}); | ||
}); | ||
} | ||
@@ -313,3 +346,11 @@ /** | ||
socket.onerror = (e) => this._onErrorCallbacks.forEach((callback) => callback(e)); | ||
socket.onclose = (e) => this._onDisconnectCallbacks.forEach((callback) => callback(e)); | ||
socket.onclose = (e) => { | ||
this._onDisconnectCallbacks.forEach((callback) => callback(e)); | ||
if (!this._isManuallyClosed) { | ||
setTimeout( | ||
() => this._socketPromise === this._createSocket(), | ||
this._options?.reconnectInterval ?? this.DEFAULT_RECONNECT_INTERVAL | ||
); | ||
} | ||
}; | ||
return socket; | ||
@@ -321,9 +362,11 @@ } | ||
* @private | ||
* @throws On disconnect or close. | ||
*/ | ||
async _waitForConnection() { | ||
if (!this._socket || this._socket.readyState === this._socket.CLOSED || this._socket.readyState === this._socket.CLOSING) { | ||
const socket = await this._socketPromise; | ||
if (!socket || socket.readyState === socket.CLOSED || socket.readyState === socket.CLOSING) { | ||
throw new Error("Websocket connection is closed."); | ||
} | ||
if (this._socket.readyState === this._socket.OPEN) { | ||
return this._socket; | ||
if (socket.readyState === socket.OPEN) { | ||
return socket; | ||
} | ||
@@ -339,3 +382,3 @@ return new Promise(async (resolve, reject) => { | ||
cleanup(); | ||
resolve(this._socket); | ||
resolve(socket); | ||
}); | ||
@@ -348,2 +391,19 @@ const unlistenDisconnect = this.onDisconnect(() => { | ||
} | ||
/** | ||
* @private | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
async _sendSubscribe(events) { | ||
const { subscriptionId } = await this._sendAndWaitReply( | ||
`sub --events ${events.join(" ")}` | ||
); | ||
return subscriptionId; | ||
} | ||
/** | ||
* @private | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
async _sendUnsubscribe(subscriptionId) { | ||
await this._sendAndWaitReply(`unsub --id ${subscriptionId}`); | ||
} | ||
}; | ||
@@ -350,0 +410,0 @@ |
{ | ||
"name": "glazewm", | ||
"version": "1.4.3", | ||
"version": "1.5.0", | ||
"description": "Library for inter-process communication (IPC) with GlazeWM.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -28,4 +28,15 @@ import { | ||
export interface WmClientOptions { | ||
/** IPC server port to connect to. Defaults to `6123`. */ | ||
/** | ||
* IPC server port to connect to. | ||
* | ||
* Defaults to `6123`. | ||
*/ | ||
port?: number; | ||
/** | ||
* Reconnection interval in milliseconds. | ||
* | ||
* Defaults to `5000` (5 seconds). | ||
*/ | ||
reconnectInterval?: number; | ||
} | ||
@@ -46,8 +57,15 @@ | ||
private readonly DEFAULT_PORT = 6123; | ||
private readonly DEFAULT_RECONNECT_INTERVAL = 5000; | ||
/** Websocket connection to IPC server. */ | ||
private _socket: WebSocket | null = null; | ||
/** | ||
* Promise that resolves to `WebSocket` instance if connected. | ||
* | ||
* Prevents duplicate connections. | ||
*/ | ||
private _socketPromise: Promise<WebSocket> | null = null; | ||
/** Promise used to prevent duplicate connections. */ | ||
private _createSocketPromise: Promise<WebSocket> | null = null; | ||
/** | ||
* Whether the connection was closed via {@link closeConnection}. | ||
*/ | ||
private _isManuallyClosed = false; | ||
@@ -69,2 +87,4 @@ private _onMessageCallbacks: MessageCallback[] = []; | ||
* Gets all monitors. {@link Monitor} | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -77,2 +97,4 @@ async queryMonitors(): Promise<MonitorsResponse> { | ||
* Gets all active workspaces. {@link Workspace} | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -85,2 +107,4 @@ async queryWorkspaces(): Promise<WorkspacesResponse> { | ||
* Gets all managed windows. {@link Window} | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -94,2 +118,4 @@ async queryWindows(): Promise<WindowsResponse> { | ||
* {@link Window} or a {@link Workspace} without any descendant windows. | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -102,2 +128,4 @@ async queryFocused(): Promise<FocusedResponse> { | ||
* Gets the active binding modes. | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -112,2 +140,4 @@ async queryBindingModes(): Promise<BindingModesResponse> { | ||
* Gets metadata about the running GlazeWM application. | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -122,2 +152,4 @@ async queryAppMetadata(): Promise<AppMetadataResponse> { | ||
* Gets the tiling direction of the focused container. | ||
* | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
@@ -136,3 +168,3 @@ async queryTilingDirection(): Promise<TilingDirectionResponse> { | ||
* If not provided, this defaults to the currently focused container. | ||
* @throws If command fails. | ||
* @throws If the command errors or connection to IPC server fails. | ||
*/ | ||
@@ -153,13 +185,7 @@ async runCommand( | ||
* | ||
* @throws If connection attempt fails. | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
async connect(): Promise<void> { | ||
if (!this._socket) { | ||
const socketPromise = | ||
this._createSocketPromise ?? | ||
(this._createSocketPromise = this._createSocket()); | ||
this._socket = await socketPromise; | ||
} | ||
this._isManuallyClosed = false; | ||
this._socketPromise ??= this._createSocket(); | ||
await this._waitForConnection(); | ||
@@ -171,4 +197,5 @@ } | ||
*/ | ||
closeConnection(): void { | ||
this._socket?.close(); | ||
async closeConnection(): Promise<void> { | ||
this._isManuallyClosed = true; | ||
(await this._socketPromise)?.close(); | ||
} | ||
@@ -179,2 +206,4 @@ | ||
* | ||
* Persists the subscription across reconnections. | ||
* | ||
* @example | ||
@@ -187,2 +216,3 @@ * ```typescript | ||
* ``` | ||
* @throws If *initial* connection to IPC server fails. | ||
*/ | ||
@@ -199,2 +229,4 @@ async subscribe<T extends WmEventType>( | ||
* | ||
* Persists the subscription across reconnections. | ||
* | ||
* @example | ||
@@ -207,2 +239,3 @@ * ```typescript | ||
* ``` | ||
* @throws If *initial* connection to IPC server fails. | ||
*/ | ||
@@ -213,8 +246,5 @@ async subscribeMany<T extends WmEventType[]>( | ||
): Promise<UnlistenFn> { | ||
const { subscriptionId } = | ||
await this._sendAndWaitReply<SubscribeResponse>( | ||
`sub --events ${events.join(' ')}`, | ||
); | ||
let subscriptionId = await this._sendSubscribe(events); | ||
const unlisten = this.onMessage(e => { | ||
const unlistenMessage = this.onMessage(e => { | ||
const serverMessage: ServerMessage<WmEventData> = JSON.parse( | ||
@@ -233,6 +263,11 @@ e.data as string, | ||
const unlistenConnect = this.onConnect(async e => { | ||
this._sendUnsubscribe(subscriptionId); | ||
subscriptionId = await this._sendSubscribe(events); | ||
}); | ||
return async () => { | ||
unlisten(); | ||
await this._sendAndWaitReply<void>(`unsub --id ${subscriptionId}`); | ||
unlistenMessage(); | ||
unlistenConnect(); | ||
await this._sendUnsubscribe(subscriptionId); | ||
}; | ||
@@ -254,3 +289,3 @@ } | ||
/** | ||
* Registers a callback for when the websocket connects. | ||
* Registers a callback for when the websocket connects or reconnects. | ||
* | ||
@@ -295,38 +330,43 @@ * @example | ||
* @private | ||
* @throws If message is invalid or IPC server is unable to handle the | ||
* message. | ||
* @throws If message is invalid or connection to IPC server fails. | ||
*/ | ||
private async _sendAndWaitReply<T>(message: string): Promise<T> { | ||
let unlisten: UnlistenFn; | ||
if (this._isManuallyClosed) { | ||
throw new Error( | ||
'Websocket connection was closed via `closeConnection`.', | ||
); | ||
} | ||
await this.connect(); | ||
const socket = await this._socketPromise!; | ||
// Resolve when a reply comes in for the client message. | ||
return new Promise<T>(async (resolve, reject) => { | ||
try { | ||
await this.connect(); | ||
this._socket!.send(message); | ||
socket.send(message, error => { | ||
if (error) { | ||
reject(error); | ||
} | ||
}); | ||
unlisten = this.onMessage(e => { | ||
const serverMessage: ServerMessage<T> = JSON.parse( | ||
e.data as string, | ||
); | ||
const unlisten = this.onMessage(e => { | ||
const serverMessage: ServerMessage<T> = JSON.parse( | ||
e.data as string, | ||
); | ||
// Whether the incoming message is a reply to the client message. | ||
const isReplyMessage = | ||
serverMessage.messageType === 'client_response' && | ||
serverMessage.clientMessage === message; | ||
// Whether the incoming message is a reply to the client message. | ||
const isReplyMessage = | ||
serverMessage.messageType === 'client_response' && | ||
serverMessage.clientMessage === message; | ||
if (isReplyMessage && serverMessage.error) { | ||
reject( | ||
`Server reply to message '${message}' has error: ${serverMessage.error}`, | ||
); | ||
} | ||
if (isReplyMessage) { | ||
unlisten(); | ||
if (isReplyMessage) { | ||
if (serverMessage.error) { | ||
reject(serverMessage.error); | ||
} else { | ||
resolve(serverMessage.data as T); | ||
} | ||
}); | ||
} catch (err) { | ||
reject(err); | ||
} | ||
}).finally(() => unlisten()); | ||
} | ||
}); | ||
}); | ||
} | ||
@@ -387,5 +427,15 @@ | ||
socket.onclose = e => | ||
socket.onclose = e => { | ||
this._onDisconnectCallbacks.forEach(callback => callback(e)); | ||
// Attempt to reconnect if not manually closed. | ||
if (!this._isManuallyClosed) { | ||
setTimeout( | ||
() => this._socketPromise === this._createSocket(), | ||
this._options?.reconnectInterval ?? | ||
this.DEFAULT_RECONNECT_INTERVAL, | ||
); | ||
} | ||
}; | ||
return socket; | ||
@@ -398,8 +448,11 @@ } | ||
* @private | ||
* @throws On disconnect or close. | ||
*/ | ||
private async _waitForConnection(): Promise<WebSocket> { | ||
const socket = await this._socketPromise; | ||
if ( | ||
!this._socket || | ||
this._socket.readyState === this._socket.CLOSED || | ||
this._socket.readyState === this._socket.CLOSING | ||
!socket || | ||
socket.readyState === socket.CLOSED || | ||
socket.readyState === socket.CLOSING | ||
) { | ||
@@ -409,4 +462,4 @@ throw new Error('Websocket connection is closed.'); | ||
if (this._socket.readyState === this._socket.OPEN) { | ||
return this._socket; | ||
if (socket.readyState === socket.OPEN) { | ||
return socket; | ||
} | ||
@@ -422,3 +475,3 @@ | ||
cleanup(); | ||
resolve(this._socket!); | ||
resolve(socket); | ||
}); | ||
@@ -432,2 +485,23 @@ | ||
} | ||
/** | ||
* @private | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
private async _sendSubscribe(events: WmEventType[]): Promise<string> { | ||
const { subscriptionId } = | ||
await this._sendAndWaitReply<SubscribeResponse>( | ||
`sub --events ${events.join(' ')}`, | ||
); | ||
return subscriptionId; | ||
} | ||
/** | ||
* @private | ||
* @throws If connection to IPC server fails. | ||
*/ | ||
private async _sendUnsubscribe(subscriptionId: string): Promise<void> { | ||
await this._sendAndWaitReply<void>(`unsub --id ${subscriptionId}`); | ||
} | ||
} |
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
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
77198
2352