bonjour-hap 3.6.4 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ![NPM-Version](https://badgen.net/npm/v/bonjour-hap)
4
4
  ![NPM-Downloads](https://badgen.net/npm/dt/bonjour-hap)
5
- ![Node-CI](https://github.com/homebridge/bonjour/workflows/Node-CI/badge.svg)
5
+ [![Node Build](https://github.com/homebridge/bonjour/actions/workflows/nodejs.yml/badge.svg)](https://github.com/homebridge/bonjour/actions/workflows/nodejs.yml)
6
6
  [![Coverage Status](https://coveralls.io/repos/github/homebridge/bonjour/badge.svg?branch=master)](https://coveralls.io/github/homebridge/bonjour?branch=master)
7
7
 
8
8
  A Bonjour/Zeroconf protocol implementation in pure JavaScript. Publish
@@ -112,6 +112,10 @@ Options are the same as given in the `browser.find` function.
112
112
 
113
113
  Emitted every time a new service is found that matches the browser.
114
114
 
115
+ #### `Event: update`
116
+
117
+ Emitted every time an update is received for existing service is found that matches the browser.
118
+
115
119
  #### `Event: down`
116
120
 
117
121
  Emitted every time an existing service emmits a goodbye message.
@@ -136,7 +140,7 @@ Broadcast the query again.
136
140
 
137
141
  #### `Event: up`
138
142
 
139
- Emitted when the service is up.
143
+ Emitted when the service is up, and if the txt record of the service is updated `service.updateTxt(object)`.
140
144
 
141
145
  #### `Event: error`
142
146
 
package/lib/Browser.js CHANGED
@@ -82,8 +82,11 @@ Browser.prototype.start = function () {
82
82
  if (matches.length === 0) return
83
83
 
84
84
  matches.forEach(function (service) {
85
- if (self._serviceMap[service.fqdn]) return // ignore already registered services
86
- self._addService(service)
85
+ if (self._serviceMap[service.fqdn]) {
86
+ self._updateService(service)
87
+ } else {
88
+ self._addService(service)
89
+ }
87
90
  })
88
91
  })
89
92
  }
@@ -109,6 +112,21 @@ Browser.prototype._addService = function (service) {
109
112
  this.emit('up', service)
110
113
  }
111
114
 
115
+ Browser.prototype._updateService = function (service) {
116
+ let cachedService, index
117
+ this.services.some(function (s, i) {
118
+ if (dnsEqual(s.fqdn, service.fqdn)) {
119
+ cachedService = s
120
+ index = i
121
+ return true
122
+ }
123
+ return false
124
+ })
125
+ if (!cachedService) return
126
+ this.services[index] = service
127
+ this.emit('update', service)
128
+ }
129
+
112
130
  Browser.prototype._removeService = function (fqdn) {
113
131
  let service, index
114
132
  this.services.some(function (s, i) {
package/lib/Server.js CHANGED
@@ -55,8 +55,8 @@ Server.prototype = {
55
55
  }
56
56
 
57
57
  this.mdns.respond({
58
- answers: answers,
59
- additionals: additionals
58
+ answers,
59
+ additionals
60
60
  }, err => {
61
61
  if (err) throw err // TODO: Handle this (if no callback is given, the error will be ignored)
62
62
  })
package/lib/Service.js CHANGED
@@ -239,7 +239,7 @@ const proto = {
239
239
  type: 'TXT',
240
240
  ttl: 4500,
241
241
  flush: true,
242
- data: data
242
+ data
243
243
  }
244
244
  },
245
245
 
@@ -13,5 +13,5 @@ function resolveInterface (address) {
13
13
  }
14
14
 
15
15
  module.exports = {
16
- resolveInterface: resolveInterface
16
+ resolveInterface
17
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bonjour-hap",
3
- "version": "3.6.4",
3
+ "version": "3.7.0",
4
4
  "description": "A Bonjour/Zeroconf implementation in pure JavaScript (for HAP)",
5
5
  "main": "index.js",
6
6
  "author": "Thomas Watson Steen <w@tson.dk> (https://twitter.com/wa7son)",
@@ -41,16 +41,15 @@
41
41
  ],
42
42
  "dependencies": {
43
43
  "array-flatten": "^2.1.2",
44
- "deep-equal": "^2.0.5",
44
+ "deep-equal": "^2.2.3",
45
45
  "multicast-dns": "^7.2.5",
46
- "multicast-dns-service-types": "^1.1.0",
47
- "ip": "^1.1.8"
46
+ "multicast-dns-service-types": "^1.1.0"
48
47
  },
49
48
  "devDependencies": {
50
49
  "after-all": "^2.0.2",
51
- "standard": "^17.0.0",
52
- "tape": "^5.6.1",
50
+ "standard": "^17.1.0",
51
+ "tape": "^5.7.5",
53
52
  "nyc": "^15.1.0",
54
- "rimraf": "^3.0.2"
53
+ "rimraf": "^5.0.5"
55
54
  }
56
55
  }