home-assistant-js-websocket
Advanced tools
Comparing version 5.1.2 to 5.2.0
import { HassConfig, UnsubscribeFunc } from "./types.js"; | ||
import { Connection } from "./connection.js"; | ||
export declare const subscribeConfig: (conn: Connection, onChange: (state: HassConfig) => void) => UnsubscribeFunc; | ||
export declare const STATE_NOT_RUNNING = "NOT_RUNNING"; | ||
export declare const STATE_STARTING = "STARTING"; | ||
export declare const STATE_RUNNING = "RUNNING"; | ||
export declare const STATE_STOPPING = "STOPPING"; | ||
export declare const STATE_FINAL_WRITE = "FINAL_WRITE"; |
@@ -7,3 +7,3 @@ import { getCollection } from "./collection.js"; | ||
return { | ||
components: state.components.concat(event.data.component) | ||
components: state.components.concat(event.data.component), | ||
}; | ||
@@ -14,5 +14,10 @@ } | ||
conn.subscribeEvents(store.action(processComponentLoaded), "component_loaded"), | ||
conn.subscribeEvents(() => fetchConfig(conn).then(config => store.setState(config, true)), "core_config_updated") | ||
]).then(unsubs => () => unsubs.forEach(unsub => unsub())); | ||
conn.subscribeEvents(() => fetchConfig(conn).then((config) => store.setState(config, true)), "core_config_updated"), | ||
]).then((unsubs) => () => unsubs.forEach((unsub) => unsub())); | ||
const configColl = (conn) => getCollection(conn, "_cnf", fetchConfig, subscribeUpdates); | ||
export const subscribeConfig = (conn, onChange) => configColl(conn).subscribe(onChange); | ||
export const STATE_NOT_RUNNING = "NOT_RUNNING"; | ||
export const STATE_STARTING = "STARTING"; | ||
export const STATE_RUNNING = "RUNNING"; | ||
export const STATE_STOPPING = "STOPPING"; | ||
export const STATE_FINAL_WRITE = "FINAL_WRITE"; |
@@ -616,5 +616,3 @@ (function (global, factory) { | ||
if (ret != null) { | ||
if (ret.then) | ||
return ret.then(apply); | ||
return apply(ret); | ||
return ret instanceof Promise ? ret.then(apply) : apply(ret); | ||
} | ||
@@ -716,3 +714,3 @@ }; | ||
return { | ||
components: state.components.concat(event.data.component) | ||
components: state.components.concat(event.data.component), | ||
}; | ||
@@ -723,6 +721,11 @@ } | ||
conn.subscribeEvents(store.action(processComponentLoaded), "component_loaded"), | ||
conn.subscribeEvents(() => fetchConfig(conn).then(config => store.setState(config, true)), "core_config_updated") | ||
]).then(unsubs => () => unsubs.forEach(unsub => unsub())); | ||
conn.subscribeEvents(() => fetchConfig(conn).then((config) => store.setState(config, true)), "core_config_updated"), | ||
]).then((unsubs) => () => unsubs.forEach((unsub) => unsub())); | ||
const configColl = (conn) => getCollection(conn, "_cnf", fetchConfig, subscribeUpdates); | ||
const subscribeConfig = (conn, onChange) => configColl(conn).subscribe(onChange); | ||
const STATE_NOT_RUNNING = "NOT_RUNNING"; | ||
const STATE_STARTING = "STARTING"; | ||
const STATE_RUNNING = "RUNNING"; | ||
const STATE_STOPPING = "STOPPING"; | ||
const STATE_FINAL_WRITE = "FINAL_WRITE"; | ||
@@ -804,2 +807,7 @@ function processServiceRegistered(state, event) { | ||
exports.MSG_TYPE_AUTH_REQUIRED = MSG_TYPE_AUTH_REQUIRED; | ||
exports.STATE_FINAL_WRITE = STATE_FINAL_WRITE; | ||
exports.STATE_NOT_RUNNING = STATE_NOT_RUNNING; | ||
exports.STATE_RUNNING = STATE_RUNNING; | ||
exports.STATE_STARTING = STATE_STARTING; | ||
exports.STATE_STOPPING = STATE_STOPPING; | ||
exports.callService = callService$1; | ||
@@ -806,0 +814,0 @@ exports.createCollection = createCollection; |
@@ -11,2 +11,3 @@ import { createSocket } from "./socket.js"; | ||
export * from "./socket.js"; | ||
export * from "./types.js"; | ||
export * from "./commands.js"; | ||
@@ -13,0 +14,0 @@ export async function createConnection(options) { |
@@ -49,5 +49,3 @@ export const createStore = (state) => { | ||
if (ret != null) { | ||
if (ret.then) | ||
return ret.then(apply); | ||
return apply(ret); | ||
return ret instanceof Promise ? ret.then(apply) : apply(ret); | ||
} | ||
@@ -54,0 +52,0 @@ }; |
@@ -55,2 +55,3 @@ import { Auth } from "./auth.js"; | ||
safe_mode: boolean; | ||
state: "NOT_RUNNING" | "STARTING" | "RUNNING" | "STOPPING" | "FINAL_WRITE"; | ||
external_url: string | null; | ||
@@ -57,0 +58,0 @@ internal_url: string | null; |
@@ -5,3 +5,3 @@ { | ||
"sideEffects": false, | ||
"version": "5.1.2", | ||
"version": "5.2.0", | ||
"description": "Home Assistant websocket client", | ||
@@ -8,0 +8,0 @@ "source": "lib/index.ts", |
105137
1961