Skip to content

Commit

Permalink
Add TypeScript typing, dependency updates, and housekeeping. (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
hjdhjd authored Dec 21, 2024
1 parent c7ca772 commit 411c067
Show file tree
Hide file tree
Showing 4 changed files with 1,544 additions and 1,015 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to `hap-nodejs` will be documented in this file. This project tries to adhere to [Semantic Versioning](http://semver.org/).

## v3.8.0 (2024-12-21)

- Add TypeScript typing.
- Dependency updates.
- Housekeeping.

## v3.8.0 (2024-06-26)

### Other Changes
Expand Down
66 changes: 66 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { SocketOptions } from "dgram";

export type BonjourFindOptions = {
type: string;
subtypes?: string[];
protocol?: "tcp" | "udp";
txt?: Record<string, any>;
};

export interface BonjourService {
name: string;
type: string;
protocol: "tcp" | "udp";
host: string;
port: number;
addresses: string[];
txt: Record<string, string>;
rawTxt?: Buffer;
}

export interface MulticastOptions extends SocketOptions {
multicastAddress?: string;
multicastInterface?: string;
multicastTTL?: number;
reuseAddr?: boolean;
}

export class Browser {
start(): void;
stop(): void;
update(): void;
on(event: "up" | "down", listener: (service: BonjourService) => void): this;
}

export class Advertisement {
stop(): void;
start(): void;
update(txt: Record<string, string>): void;
on(event: "error", listener: (err: Error) => void): this;
}

export interface PublishOptions {
name: string;
type: string;
subtypes?: string[];
port: number;
host?: string;
txt?: Record<string, string>;
protocol?: "tcp" | "udp";
}

export default class Bonjour {
constructor(options?: MulticastOptions);

publish(options: PublishOptions): Advertisement;
unpublishAll(callback?: () => void): void;
find(
options: BonjourFindOptions,
onUp?: (service: BonjourService) => void
): Browser;
findOne(
options: BonjourFindOptions,
callback: (service: BonjourService) => void
): Browser;
destroy(): void;
}
Loading

0 comments on commit 411c067

Please sign in to comment.