hap-nodejs
Advanced tools
Comparing version 1.1.1-alpha.7 to 1.1.1-alpha.8
import type { MDNSServerOptions, ServiceTxt } from '@homebridge/ciao'; | ||
import type { InterfaceName, IPAddress } from '@homebridge/ciao/lib/NetworkManager.js'; | ||
import type { MessageBus } from 'dbus-ts'; | ||
import type { AccessoryInfo } from './model/AccessoryInfo'; | ||
@@ -156,4 +155,3 @@ import { EventEmitter } from 'node:events'; | ||
private readonly stateChangeHandler; | ||
constructor(accessoryInfo: AccessoryInfo, bus: MessageBus); | ||
static create(accessoryInfo: AccessoryInfo): Promise<AvahiAdvertiser>; | ||
constructor(accessoryInfo: AccessoryInfo); | ||
private createTxt; | ||
@@ -187,4 +185,3 @@ initPort(port: number): void; | ||
private path?; | ||
constructor(accessoryInfo: AccessoryInfo, bus: MessageBus); | ||
static create(accessoryInfo: AccessoryInfo): Promise<ResolvedAdvertiser>; | ||
constructor(accessoryInfo: AccessoryInfo); | ||
private createTxt; | ||
@@ -191,0 +188,0 @@ initPort(port: number): void; |
@@ -6,4 +6,4 @@ import assert from 'node:assert'; | ||
import { getResponder } from '@homebridge/ciao'; | ||
import { systemBus } from '@homebridge/dbus-native'; | ||
import bonjour from 'bonjour-hap'; | ||
import { systemBus } from 'dbus-ts'; | ||
import createDebug from 'debug'; | ||
@@ -237,3 +237,2 @@ import { PromiseTimeout } from './util/promise-utils.js'; | ||
return new Promise((resolve, reject) => { | ||
debug('dbusInvoke(): Invoking DBus method %s.%s on %s at %s', dbusInterface, member, destination, path); | ||
const command = { | ||
@@ -246,11 +245,9 @@ destination, | ||
}; | ||
bus | ||
.invoke(command) | ||
.then((result) => { | ||
debug('dbusInvoke(): DBus method %s.%s on %s at %s succeeded: %o', dbusInterface, member, destination, path, result); | ||
resolve(result); | ||
}) | ||
.catch((error) => { | ||
debug('dbusInvoke(): DBus method %s.%s on %s at %s failed: %s', dbusInterface, member, destination, path, error); | ||
reject(new DBusInvokeError(error)); | ||
bus.invoke(command, (err, result) => { | ||
if (err) { | ||
reject(new DBusInvokeError(err)); | ||
} | ||
else { | ||
resolve(result); | ||
} | ||
}); | ||
@@ -292,3 +289,3 @@ }); | ||
stateChangeHandler; | ||
constructor(accessoryInfo, bus) { | ||
constructor(accessoryInfo) { | ||
super(); | ||
@@ -298,9 +295,5 @@ this.accessoryInfo = accessoryInfo; | ||
debug(`Preparing Advertiser for '${this.accessoryInfo.displayName}' using Avahi backend!`); | ||
this.bus = bus; | ||
this.bus = systemBus(); | ||
this.stateChangeHandler = this.handleStateChangedEvent.bind(this); | ||
} | ||
static async create(accessoryInfo) { | ||
const bus = await systemBus(); | ||
return new AvahiAdvertiser(accessoryInfo, bus); | ||
} | ||
createTxt() { | ||
@@ -341,3 +334,3 @@ return Object | ||
this.avahiServerInterface = await AvahiAdvertiser.avahiInterface(this.bus, 'Server'); | ||
await this.avahiServerInterface.on('StateChanged', this.stateChangeHandler); | ||
this.avahiServerInterface.on('StateChanged', this.stateChangeHandler); | ||
} | ||
@@ -401,3 +394,3 @@ } | ||
if (this.avahiServerInterface) { | ||
await this.avahiServerInterface.removeListener('StateChanged', this.stateChangeHandler); | ||
this.avahiServerInterface.removeListener('StateChanged', this.stateChangeHandler); | ||
this.avahiServerInterface = undefined; | ||
@@ -410,3 +403,3 @@ } | ||
debug('Checking Avahi/DBus availability...'); | ||
const bus = await systemBus(); | ||
const bus = systemBus(); | ||
debug('Avahi/DBus connection established!'); | ||
@@ -445,12 +438,12 @@ try { | ||
return new Promise((resolve, reject) => { | ||
const service = bus.getService('org.freedesktop.Avahi'); | ||
service | ||
.getInterface('/', `org.freedesktop.Avahi.${dbusInterface}`) | ||
.then((iface) => { | ||
if (!iface) { | ||
reject(new Error('Interface not present!')); | ||
bus | ||
.getService('org.freedesktop.Avahi') | ||
.getInterface('/', `org.freedesktop.Avahi.${dbusInterface}`, (error, iface) => { | ||
if (error || !iface) { | ||
reject(error ?? new Error('Interface not present!')); | ||
} | ||
resolve(iface); | ||
}) | ||
.catch(error => reject(error)); | ||
else { | ||
resolve(iface); | ||
} | ||
}); | ||
}); | ||
@@ -476,13 +469,9 @@ } | ||
path; | ||
constructor(accessoryInfo, bus) { | ||
constructor(accessoryInfo) { | ||
super(); | ||
this.accessoryInfo = accessoryInfo; | ||
this.setupHash = CiaoAdvertiser.computeSetupHash(accessoryInfo); | ||
this.bus = bus; | ||
this.bus = systemBus(); | ||
debug(`Preparing Advertiser for '${this.accessoryInfo.displayName}' using systemd-resolved backend!`); | ||
} | ||
static async create(accessoryInfo) { | ||
const bus = await systemBus(); | ||
return new ResolvedAdvertiser(accessoryInfo, bus); | ||
} | ||
createTxt() { | ||
@@ -563,3 +552,3 @@ return Object | ||
static async isAvailable() { | ||
const bus = await systemBus(); | ||
const bus = systemBus(); | ||
try { | ||
@@ -566,0 +555,0 @@ try { |
{ | ||
"name": "hap-nodejs", | ||
"type": "module", | ||
"version": "1.1.1-alpha.7", | ||
"version": "1.1.1-alpha.8", | ||
"description": "HAP-NodeJS is a Node.js implementation of HomeKit Accessory Server.", | ||
@@ -59,4 +59,4 @@ "author": "Khaos Tian <khaos.tian@gmail.com> (https://tz.is/)", | ||
"@homebridge/ciao": "^1.3.1", | ||
"@homebridge/dbus-native": "^0.6.0", | ||
"bonjour-hap": "^3.8.0", | ||
"dbus-ts": "^0.0.7", | ||
"debug": "^4.3.6", | ||
@@ -63,0 +63,0 @@ "fast-srp-hap": "^2.0.4", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
2267700
33845
+ Added@homebridge/dbus-native@0.6.0(transitive)
+ Addedduplexer@0.1.2(transitive)
+ Addedevent-stream@4.0.1(transitive)
+ Addedfrom@0.1.7(transitive)
+ Addedhexy@0.3.5(transitive)
+ Addedmap-stream@0.0.7(transitive)
+ Addedpause-stream@0.0.11(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsplit@1.0.1(transitive)
+ Addedstream-combiner@0.2.2(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedxml2js@0.6.2(transitive)
- Removeddbus-ts@^0.0.7
- Removed@dbus-types/dbus@0.0.4(transitive)
- Removeddbus-ts@0.0.7(transitive)
- Removedxml2js@0.4.23(transitive)