Skip to content

Commit

Permalink
chore: update bonjour-service to v1.2.1 (#475)
Browse files Browse the repository at this point in the history
This version integrates all of our patches except the one for the
`probe` option when starting a `Service`. That version also has some
trickiness around types for `start` and `stop`, which are also fixed
here.

I submitted these patches [upstream] but haven't heard back as of this
writing.

[upstream]: onlxltd/bonjour-service#48
  • Loading branch information
EvanHahn committed Feb 13, 2024
1 parent 4a2cb3c commit 7832935
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 134 deletions.
20 changes: 4 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"better-sqlite3": "^8.7.0",
"big-sparse-array": "^1.0.3",
"bogon": "^1.1.0",
"bonjour-service": "^1.1.1",
"bonjour-service": "^1.2.1",
"compact-encoding": "^2.12.0",
"corestore": "^6.8.4",
"debug": "^4.3.4",
Expand Down
116 changes: 0 additions & 116 deletions patches/bonjour-service+1.1.1.patch

This file was deleted.

77 changes: 77 additions & 0 deletions patches/bonjour-service+1.2.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
diff --git a/node_modules/bonjour-service/dist/lib/registry.js b/node_modules/bonjour-service/dist/lib/registry.js
index 5462ca2..662486d 100644
--- a/node_modules/bonjour-service/dist/lib/registry.js
+++ b/node_modules/bonjour-service/dist/lib/registry.js
@@ -15,14 +15,18 @@ class Registry {
this.server = server;
}
publish(config) {
- function start(service, registry, opts) {
+ const configProbe = config.probe !== false;
+
+ const service = new service_1.default(config, start.bind(null, this), stop.bind(null, this));
+
+ function start(registry, { probe = configProbe } = {}) {
if (service.activated)
return;
service.activated = true;
registry.services.push(service);
if (!(service instanceof service_1.default))
return;
- if (opts === null || opts === void 0 ? void 0 : opts.probe) {
+ if (probe) {
registry.probe(registry.server.mdns, service, (exists) => {
if (exists) {
if (service.stop !== undefined)
@@ -37,7 +41,7 @@ class Registry {
registry.announce(registry.server, service);
}
}
- function stop(service, registry, callback) {
+ function stop(registry, callback) {
if (!callback)
callback = noop;
if (!service.activated)
@@ -49,10 +53,7 @@ class Registry {
if (index !== -1)
registry.services.splice(index, 1);
}
- const service = new service_1.default(config);
- service.start = start.bind(null, service, this);
- service.stop = stop.bind(null, service, this);
- service.start({ probe: config.probe !== false });
+ service.start();
return service;
}
unpublishAll(callback) {
diff --git a/node_modules/bonjour-service/dist/lib/service.d.ts b/node_modules/bonjour-service/dist/lib/service.d.ts
index 2c711f9..c459a07 100644
--- a/node_modules/bonjour-service/dist/lib/service.d.ts
+++ b/node_modules/bonjour-service/dist/lib/service.d.ts
@@ -41,8 +41,8 @@ export declare class Service extends EventEmitter {
published: boolean;
activated: boolean;
destroyed: boolean;
- start?: CallableFunction;
- stop?: CallableFunction;
+ start: CallableFunction;
+ stop: CallableFunction;
private txtService;
constructor(config: ServiceConfig);
records(): Array<ServiceRecord>;
diff --git a/node_modules/bonjour-service/dist/lib/service.js b/node_modules/bonjour-service/dist/lib/service.js
index 41da95a..ac71665 100644
--- a/node_modules/bonjour-service/dist/lib/service.js
+++ b/node_modules/bonjour-service/dist/lib/service.js
@@ -10,8 +10,10 @@ const events_1 = require("events");
const service_types_1 = require("./service-types");
const TLD = '.local';
class Service extends events_1.EventEmitter {
- constructor(config) {
+ constructor(config, start, stop) {
super();
+ this.start = start;
+ this.stop = stop;
this.probe = true;
this.published = false;
this.activated = false;
2 changes: 1 addition & 1 deletion src/discovery/dns-sd.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class DnsSd extends TypedEmitter {
host: this.#name + '.local',
port,
type: SERVICE_NAME,
disableIpv6: this.#disableIpv6,
disableIPv6: this.#disableIpv6,
})
}
this.#advertisingStarting = once(this.#service, 'up')
Expand Down

0 comments on commit 7832935

Please sign in to comment.