home-assistant-js-websocket
Advanced tools
Comparing version 5.2.1 to 5.2.2
@@ -1,3 +0,9 @@ | ||
import { ConnectionOptions, MessageBase } from "./types.js"; | ||
import { MessageBase } from "./types.js"; | ||
import { HaWebSocket } from "./socket.js"; | ||
import type { Auth } from "./auth.js"; | ||
export declare type ConnectionOptions = { | ||
setupRetry: number; | ||
auth?: Auth; | ||
createSocket: (options: ConnectionOptions) => Promise<HaWebSocket>; | ||
}; | ||
export declare type ConnectionEventListener = (conn: Connection, eventData?: any) => void; | ||
@@ -4,0 +10,0 @@ declare type Events = "ready" | "disconnected" | "reconnect-error"; |
@@ -30,4 +30,4 @@ /** | ||
this.socket = socket; | ||
socket.addEventListener("message", ev => this._handleMessage(ev)); | ||
socket.addEventListener("close", ev => this._handleClose(ev)); | ||
socket.addEventListener("message", (ev) => this._handleMessage(ev)); | ||
socket.addEventListener("close", (ev) => this._handleClose(ev)); | ||
if (oldSocket) { | ||
@@ -38,5 +38,5 @@ const oldCommands = this.commands; | ||
this.commands = new Map(); | ||
oldCommands.forEach(info => { | ||
oldCommands.forEach((info) => { | ||
if ("subscribe" in info) { | ||
info.subscribe().then(unsub => { | ||
info.subscribe().then((unsub) => { | ||
info.unsubscribe = unsub; | ||
@@ -72,3 +72,3 @@ // We need to resolve this in case it wasn't resolved yet. | ||
fireEvent(eventType, eventData) { | ||
(this.eventListeners.get(eventType) || []).forEach(callback => callback(this, eventData)); | ||
(this.eventListeners.get(eventType) || []).forEach((callback) => callback(this, eventData)); | ||
} | ||
@@ -131,3 +131,3 @@ close() { | ||
this.commands.delete(commandId); | ||
} | ||
}, | ||
}; | ||
@@ -194,3 +194,3 @@ this.commands.set(commandId, info); | ||
// Reject in-flight sendMessagePromise requests | ||
this.commands.forEach(info => { | ||
this.commands.forEach((info) => { | ||
// We don't cancel subscribeEvents commands in flight | ||
@@ -197,0 +197,0 @@ // as we will be able to recover them. |
@@ -189,4 +189,4 @@ (function (global, factory) { | ||
this.socket = socket; | ||
socket.addEventListener("message", ev => this._handleMessage(ev)); | ||
socket.addEventListener("close", ev => this._handleClose(ev)); | ||
socket.addEventListener("message", (ev) => this._handleMessage(ev)); | ||
socket.addEventListener("close", (ev) => this._handleClose(ev)); | ||
if (oldSocket) { | ||
@@ -197,5 +197,5 @@ const oldCommands = this.commands; | ||
this.commands = new Map(); | ||
oldCommands.forEach(info => { | ||
oldCommands.forEach((info) => { | ||
if ("subscribe" in info) { | ||
info.subscribe().then(unsub => { | ||
info.subscribe().then((unsub) => { | ||
info.unsubscribe = unsub; | ||
@@ -231,3 +231,3 @@ // We need to resolve this in case it wasn't resolved yet. | ||
fireEvent(eventType, eventData) { | ||
(this.eventListeners.get(eventType) || []).forEach(callback => callback(this, eventData)); | ||
(this.eventListeners.get(eventType) || []).forEach((callback) => callback(this, eventData)); | ||
} | ||
@@ -287,3 +287,3 @@ close() { | ||
this.commands.delete(commandId); | ||
} | ||
}, | ||
}; | ||
@@ -343,3 +343,3 @@ this.commands.set(commandId, info); | ||
// Reject in-flight sendMessagePromise requests | ||
this.commands.forEach(info => { | ||
this.commands.forEach((info) => { | ||
// We don't cancel subscribeEvents commands in flight | ||
@@ -792,2 +792,3 @@ // as we will be able to recover them. | ||
// JS extensions in imports allow tsc output to be consumed by browsers. | ||
async function createConnection(options) { | ||
@@ -794,0 +795,0 @@ const connOptions = Object.assign({ setupRetry: 0, createSocket }, options); |
@@ -1,3 +0,2 @@ | ||
import { ConnectionOptions } from "./types.js"; | ||
import { Connection } from "./connection.js"; | ||
import { Connection, ConnectionOptions } from "./connection.js"; | ||
export * from "./auth.js"; | ||
@@ -4,0 +3,0 @@ export * from "./collection.js"; |
@@ -0,1 +1,2 @@ | ||
// JS extensions in imports allow tsc output to be consumed by browsers. | ||
import { createSocket } from "./socket.js"; | ||
@@ -2,0 +3,0 @@ import { Connection } from "./connection.js"; |
@@ -1,2 +0,2 @@ | ||
import { ConnectionOptions } from "./types.js"; | ||
import type { ConnectionOptions } from "./connection.js"; | ||
export declare const MSG_TYPE_AUTH_REQUIRED = "auth_required"; | ||
@@ -3,0 +3,0 @@ export declare const MSG_TYPE_AUTH_INVALID = "auth_invalid"; |
/** | ||
* Create a web socket connection with a Home Assistant instance. | ||
*/ | ||
import { ERR_INVALID_AUTH, ERR_CANNOT_CONNECT, ERR_HASS_HOST_REQUIRED } from "./errors.js"; | ||
import { ERR_INVALID_AUTH, ERR_CANNOT_CONNECT, ERR_HASS_HOST_REQUIRED, } from "./errors.js"; | ||
import * as messages from "./messages.js"; | ||
@@ -6,0 +6,0 @@ const DEBUG = false; |
@@ -1,10 +0,3 @@ | ||
import { Auth } from "./auth.js"; | ||
import { HaWebSocket } from "./socket.js"; | ||
export declare type Error = 1 | 2 | 3 | 4; | ||
export declare type UnsubscribeFunc = () => void; | ||
export declare type ConnectionOptions = { | ||
setupRetry: number; | ||
auth?: Auth; | ||
createSocket: (options: ConnectionOptions) => Promise<HaWebSocket>; | ||
}; | ||
export declare type MessageBase = { | ||
@@ -11,0 +4,0 @@ id?: number; |
@@ -5,3 +5,3 @@ { | ||
"sideEffects": false, | ||
"version": "5.2.1", | ||
"version": "5.2.2", | ||
"description": "Home Assistant websocket client", | ||
@@ -25,13 +25,13 @@ "source": "lib/index.ts", | ||
"devDependencies": { | ||
"@types/assert": "^1.4.6", | ||
"@types/assert": "^1.4.7", | ||
"@types/mocha": "^7.0.2", | ||
"assert": "^2.0.0", | ||
"husky": "^4.2.3", | ||
"lint-staged": "^10.0.8", | ||
"mocha": "^7.1.0", | ||
"prettier": "^1.19.1", | ||
"husky": "^4.2.5", | ||
"lint-staged": "^10.2.7", | ||
"mocha": "^7.2.0", | ||
"prettier": "^2.0.5", | ||
"reify": "^0.20.12", | ||
"rollup": "^2.0.0", | ||
"ts-node": "^8.6.2", | ||
"typescript": "^3.8.3" | ||
"rollup": "^2.12.0", | ||
"ts-node": "^8.10.2", | ||
"typescript": "^3.9.3" | ||
}, | ||
@@ -38,0 +38,0 @@ "files": [ |
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
105331
1963