homebridge-plugin-utils 1.15.3 → 1.17.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.
Files changed (51) hide show
  1. package/README.md +4 -1
  2. package/build/eslint-rules.mjs +1 -0
  3. package/dist/featureoptions.d.ts +83 -5
  4. package/dist/featureoptions.js +65 -6
  5. package/dist/featureoptions.js.map +1 -1
  6. package/dist/ffmpeg/codecs.d.ts +172 -0
  7. package/dist/ffmpeg/codecs.js +374 -0
  8. package/dist/ffmpeg/codecs.js.map +1 -0
  9. package/dist/ffmpeg/exec.d.ts +108 -0
  10. package/dist/ffmpeg/exec.js +122 -0
  11. package/dist/ffmpeg/exec.js.map +1 -0
  12. package/dist/ffmpeg/index.d.ts +8 -0
  13. package/dist/ffmpeg/index.js +13 -0
  14. package/dist/ffmpeg/index.js.map +1 -0
  15. package/dist/ffmpeg/options.d.ts +345 -0
  16. package/dist/ffmpeg/options.js +750 -0
  17. package/dist/ffmpeg/options.js.map +1 -0
  18. package/dist/ffmpeg/process.d.ts +155 -0
  19. package/dist/ffmpeg/process.js +344 -0
  20. package/dist/ffmpeg/process.js.map +1 -0
  21. package/dist/ffmpeg/record.d.ts +237 -0
  22. package/dist/ffmpeg/record.js +512 -0
  23. package/dist/ffmpeg/record.js.map +1 -0
  24. package/dist/ffmpeg/rtp.d.ts +205 -0
  25. package/dist/ffmpeg/rtp.js +335 -0
  26. package/dist/ffmpeg/rtp.js.map +1 -0
  27. package/dist/ffmpeg/settings.d.ts +6 -0
  28. package/dist/ffmpeg/settings.js +17 -0
  29. package/dist/ffmpeg/settings.js.map +1 -0
  30. package/dist/ffmpeg/stream.d.ts +143 -0
  31. package/dist/ffmpeg/stream.js +186 -0
  32. package/dist/ffmpeg/stream.js.map +1 -0
  33. package/dist/index.d.ts +1 -1
  34. package/dist/index.js +1 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/mqttclient.d.ts +161 -1
  37. package/dist/mqttclient.js +161 -9
  38. package/dist/mqttclient.js.map +1 -1
  39. package/dist/service.d.ts +9 -2
  40. package/dist/service.js +6 -0
  41. package/dist/service.js.map +1 -1
  42. package/dist/ui/featureoptions.js +65 -6
  43. package/dist/ui/featureoptions.js.map +1 -1
  44. package/dist/ui/webUi-featureoptions.mjs +4 -4
  45. package/dist/util.d.ts +203 -12
  46. package/dist/util.js +95 -12
  47. package/dist/util.js.map +1 -1
  48. package/package.json +14 -10
  49. package/dist/rtp.d.ts +0 -32
  50. package/dist/rtp.js +0 -178
  51. package/dist/rtp.js.map +0 -1
package/dist/util.d.ts CHANGED
@@ -1,35 +1,133 @@
1
1
  /**
2
- * @internal
2
+ * TypeScript Utilities.
3
3
  *
4
- * A utility type that recursively makes all properties of an object, including nested objects, optional. This should only be used on JSON objects only. Otherwise,
5
- * you're going to end up with class methods marked as optional as well. Credit for this belongs to: https://github.com/joonhocho/tsdef.
4
+ * @module
5
+ */
6
+ /**
7
+ * A utility type that recursively makes all properties of an object, including nested objects, optional.
8
+ *
9
+ * This should only be used on JSON objects. If used on classes, class methods will also be marked as optional.
10
+ *
11
+ * @remarks Credit for this type goes to: https://github.com/joonhocho/tsdef.
12
+ *
13
+ * @typeParam T - The type to make recursively partial.
14
+ *
15
+ * @example
16
+ *
17
+ * ```ts
18
+ * type Original = {
19
+ *
20
+ * id: string;
21
+ * nested: { value: number };
22
+ * };
23
+ *
24
+ * // All properties, including nested ones, are optional.
25
+ * type PartialObj = DeepPartial<Original>;
6
26
  *
7
- * @template T - The type to make recursively partial.
27
+ * const obj: PartialObj = { nested: {} };
28
+ * ```
29
+ *
30
+ * @category Utilities
8
31
  */
9
32
  export type DeepPartial<T> = {
10
33
  [P in keyof T]?: T[P] extends Array<infer I> ? Array<DeepPartial<I>> : DeepPartial<T[P]>;
11
34
  };
12
35
  /**
13
- * @internal
36
+ * A utility type that recursively makes all properties of an object, including nested objects, readonly.
37
+ *
38
+ * This should only be used on JSON objects. If used on classes, class methods will also be marked as readonly.
39
+ *
40
+ * @remarks Credit for this type goes to: https://github.com/joonhocho/tsdef.
41
+ *
42
+ * @typeParam T - The type to make recursively readonly.
43
+ *
44
+ * @example
45
+ *
46
+ * ```ts
47
+ * type Original = {
48
+ * id: string;
49
+ * nested: { value: number };
50
+ * };
51
+ *
52
+ * // All properties, including nested ones, are readonly.
53
+ * type ReadonlyObj = DeepReadonly<Original>;
14
54
  *
15
- * A utility type that recursively makes all properties of an object, including nested objects, optional. This should only be used on JSON objects only. Otherwise,
16
- * you're going to end up with class methods marked as optional as well. Credit for this belongs to: https://github.com/joonhocho/tsdef.
55
+ * const obj: ReadonlyObj = { id: "a", nested: { value: 1 } };
56
+ * // obj.id = "b"; // Error: cannot assign to readonly property.
57
+ * ```
17
58
  *
18
- * @template T - The type to make recursively partial.
59
+ * @category Utilities
19
60
  */
20
61
  export type DeepReadonly<T> = {
21
62
  readonly [P in keyof T]: T[P] extends Array<infer I> ? Array<DeepReadonly<I>> : DeepReadonly<T[P]>;
22
63
  };
23
64
  /**
24
- * @internal
65
+ * Utility type that allows a value to be either the given type or `null`.
66
+ *
67
+ * This type is used to explicitly indicate that a variable, property, or return value may be either a specific type or `null`.
68
+ *
69
+ * @typeParam T - The type to make nullable.
70
+ *
71
+ * @example
25
72
  *
26
- * A utility type that makes a given type assignable to it's type or null.
73
+ * ```ts
74
+ * let id: Nullable<string> = null;
75
+ *
76
+ * // Later...
77
+ * id = "device-001";
78
+ * ```
79
+ *
80
+ * @category Utilities
27
81
  */
28
82
  export type Nullable<T> = T | null;
83
+ /**
84
+ * Logging interface for Homebridge plugins.
85
+ *
86
+ * This interface defines the standard logging methods (`debug`, `info`, `warn`, `error`) that plugins should use to output log messages at different severity levels. It
87
+ * is intended to be compatible with Homebridge's builtin logger and can be implemented by any custom logger used within Homebridge plugins.
88
+ *
89
+ * @example
90
+ *
91
+ * ```ts
92
+ * function example(log: HomebridgePluginLogging) {
93
+ *
94
+ * log.debug("Debug message: %s", "details");
95
+ * log.info("Informational message.");
96
+ * log.warn("Warning message!");
97
+ * log.error("Error message: %s", "problem");
98
+ * }
99
+ * ```
100
+ *
101
+ * @category Utilities
102
+ */
29
103
  export interface HomebridgePluginLogging {
104
+ /**
105
+ * Logs a debug-level message.
106
+ *
107
+ * @param message - The message string, with optional format specifiers.
108
+ * @param parameters - Optional parameters for message formatting.
109
+ */
30
110
  debug: (message: string, ...parameters: unknown[]) => void;
111
+ /**
112
+ * Logs an error-level message.
113
+ *
114
+ * @param message - The message string, with optional format specifiers.
115
+ * @param parameters - Optional parameters for message formatting.
116
+ */
31
117
  error: (message: string, ...parameters: unknown[]) => void;
118
+ /**
119
+ * Logs an info-level message.
120
+ *
121
+ * @param message - The message string, with optional format specifiers.
122
+ * @param parameters - Optional parameters for message formatting.
123
+ */
32
124
  info: (message: string, ...parameters: unknown[]) => void;
125
+ /**
126
+ * Logs a warning-level message.
127
+ *
128
+ * @param message - The message string, with optional format specifiers.
129
+ * @param parameters - Optional parameters for message formatting.
130
+ */
33
131
  warn: (message: string, ...parameters: unknown[]) => void;
34
132
  }
35
133
  /**
@@ -38,10 +136,20 @@ export interface HomebridgePluginLogging {
38
136
  * @param value - The bitrate value to convert.
39
137
  *
40
138
  * @returns Returns the value as a human-readable string.
139
+ * @example
140
+ *
141
+ * ```ts
142
+ * formatBps(500); // "500 bps".
143
+ * formatBps(2000); // "2.0 kbps".
144
+ * formatBps(15000); // "15.0 kbps".
145
+ * formatBps(1000000); // "1.0 Mbps".
146
+ * formatBps(2560000); // "2.6 Mbps".
147
+ * ```
41
148
  */
42
149
  export declare function formatBps(value: number): string;
43
150
  /**
44
151
  * A utility method that retries an operation at a specific interval for up to an absolute total number of retries.
152
+ *
45
153
  * @param operation - The operation callback to try until successful.
46
154
  * @param retryInterval - Interval to retry, in milliseconds.
47
155
  * @param totalRetries - Optionally, specify the total number of retries.
@@ -50,18 +158,101 @@ export declare function formatBps(value: number): string;
50
158
  *
51
159
  * @remarks `operation` must be an asynchronous function that returns `true` when successful, and `false` otherwise.
52
160
  *
161
+ * @example
162
+ * ```ts
163
+ * // Example: Retry an async operation up to 5 times, waiting 1 second between each try.
164
+ * let attempt = 0;
165
+ * const result = await retry(async () => {
166
+ *
167
+ * attempt++;
168
+ *
169
+ * // Simulate a 50% chance of success
170
+ * return Math.random() > 0.5 || attempt === 5;
171
+ * }, 1000, 5);
172
+ *
173
+ * console.log(result); // true if operation succeeded within 5 tries, otherwise false.
174
+ * ```
175
+ *
53
176
  * @category Utilities
54
177
  */
55
178
  export declare function retry(operation: () => Promise<boolean>, retryInterval: number, totalRetries?: number): Promise<boolean>;
179
+ /**
180
+ * Run a promise with a guaranteed timeout to complete.
181
+ *
182
+ * @typeParam T - The type of value the promise resolves with.
183
+ * @param promise - The promise you want to run.
184
+ * @param timeout - The amount of time, in milliseconds, to wait for the promise to resolve.
185
+ *
186
+ * @returns Returns the result of resolving the promise it's been passed if it completes before timeout, or null if the timeout expires.
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * // Resolves in 100ms, timeout is 500ms, so it resolves to 42.
191
+ * const result = await runWithTimeout(Promise.resolve(42), 500);
192
+ * console.log(result); // 42
193
+ *
194
+ * // Resolves in 1000ms, timeout is 500ms, so it resolves to null.
195
+ * const slowPromise = new Promise<number>(resolve => setTimeout(() => resolve(42), 1000));
196
+ * const result2 = await runWithTimeout(slowPromise, 500);
197
+ * console.log(result2); // null
198
+ * ```
199
+ *
200
+ * @category Utilities
201
+ */
56
202
  export declare function runWithTimeout<T>(promise: Promise<T>, timeout: number): Promise<Nullable<T>>;
203
+ /**
204
+ * Emulate a sleep function.
205
+ *
206
+ * @param sleepTimer - The amount of time to sleep, in milliseconds.
207
+ *
208
+ * @returns Returns a promise that resolves after the specified time elapses.
209
+ *
210
+ * @example
211
+ * To sleep for 3 seconds before continuing execute:
212
+ *
213
+ * ```ts
214
+ * await sleep(3000)
215
+ * ```
216
+ *
217
+ * @category Utilities
218
+ */
57
219
  export declare function sleep(sleepTimer: number): Promise<NodeJS.Timeout>;
58
220
  /**
59
- * A utility method that camel case's a string.
60
- * @param string - The string to camel case.
221
+ * Camel case a string.
222
+ *
223
+ * @param input - The string to camel case.
61
224
  *
62
225
  * @returns Returns the camel cased string.
63
226
  *
227
+ * @example
228
+ * ```ts
229
+ * toCamelCase(This is a test)
230
+ * ```
231
+ *
232
+ * Returns: `This Is A Test`, capitalizing the first letter of each word.
64
233
  * @category Utilities
65
234
  */
66
235
  export declare function toCamelCase(input: string): string;
236
+ /**
237
+ * Validate an accessory name according to HomeKit naming conventions.
238
+ *
239
+ * @param name - The name to validate.
240
+ *
241
+ * @returns Returns the HomeKit-validated version of the name, replacing invalid characters with a space and squashing multiple spaces.
242
+ *
243
+ * @remarks This validates names using [HomeKit's naming rulesets](https://developer.apple.com/design/human-interface-guidelines/homekit#Help-people-choose-useful-names):
244
+ *
245
+ * - Use only alphanumeric, space, and apostrophe characters.
246
+ * - Start and end with an alphabetic or numeric character.
247
+ * - Don’t include emojis.
248
+ *
249
+ * @example
250
+ * ```ts
251
+ * validateName("Test.Switch")
252
+ * ```ts
253
+ *
254
+ * Returns: `Test Switch`, replacing the period (an invalid character in HomeKit's naming ruleset) with a space.
255
+ *
256
+ * @category Utilities
257
+ */
67
258
  export declare function validateName(name: string): string;
package/dist/util.js CHANGED
@@ -8,6 +8,15 @@
8
8
  * @param value - The bitrate value to convert.
9
9
  *
10
10
  * @returns Returns the value as a human-readable string.
11
+ * @example
12
+ *
13
+ * ```ts
14
+ * formatBps(500); // "500 bps".
15
+ * formatBps(2000); // "2.0 kbps".
16
+ * formatBps(15000); // "15.0 kbps".
17
+ * formatBps(1000000); // "1.0 Mbps".
18
+ * formatBps(2560000); // "2.6 Mbps".
19
+ * ```
11
20
  */
12
21
  export function formatBps(value) {
13
22
  // Return the bitrate as-is.
@@ -25,6 +34,7 @@ export function formatBps(value) {
25
34
  }
26
35
  /**
27
36
  * A utility method that retries an operation at a specific interval for up to an absolute total number of retries.
37
+ *
28
38
  * @param operation - The operation callback to try until successful.
29
39
  * @param retryInterval - Interval to retry, in milliseconds.
30
40
  * @param totalRetries - Optionally, specify the total number of retries.
@@ -33,6 +43,21 @@ export function formatBps(value) {
33
43
  *
34
44
  * @remarks `operation` must be an asynchronous function that returns `true` when successful, and `false` otherwise.
35
45
  *
46
+ * @example
47
+ * ```ts
48
+ * // Example: Retry an async operation up to 5 times, waiting 1 second between each try.
49
+ * let attempt = 0;
50
+ * const result = await retry(async () => {
51
+ *
52
+ * attempt++;
53
+ *
54
+ * // Simulate a 50% chance of success
55
+ * return Math.random() > 0.5 || attempt === 5;
56
+ * }, 1000, 5);
57
+ *
58
+ * console.log(result); // true if operation succeeded within 5 tries, otherwise false.
59
+ * ```
60
+ *
36
61
  * @category Utilities
37
62
  */
38
63
  export async function retry(operation, retryInterval, totalRetries) {
@@ -48,35 +73,93 @@ export async function retry(operation, retryInterval, totalRetries) {
48
73
  // We were successful - we're done.
49
74
  return true;
50
75
  }
51
- // Run a promise with a guaranteed timeout to complete.
76
+ /**
77
+ * Run a promise with a guaranteed timeout to complete.
78
+ *
79
+ * @typeParam T - The type of value the promise resolves with.
80
+ * @param promise - The promise you want to run.
81
+ * @param timeout - The amount of time, in milliseconds, to wait for the promise to resolve.
82
+ *
83
+ * @returns Returns the result of resolving the promise it's been passed if it completes before timeout, or null if the timeout expires.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * // Resolves in 100ms, timeout is 500ms, so it resolves to 42.
88
+ * const result = await runWithTimeout(Promise.resolve(42), 500);
89
+ * console.log(result); // 42
90
+ *
91
+ * // Resolves in 1000ms, timeout is 500ms, so it resolves to null.
92
+ * const slowPromise = new Promise<number>(resolve => setTimeout(() => resolve(42), 1000));
93
+ * const result2 = await runWithTimeout(slowPromise, 500);
94
+ * console.log(result2); // null
95
+ * ```
96
+ *
97
+ * @category Utilities
98
+ */
52
99
  export async function runWithTimeout(promise, timeout) {
53
100
  const timeoutPromise = new Promise((resolve) => setTimeout(() => resolve(null), timeout));
54
101
  return Promise.race([promise, timeoutPromise]);
55
102
  }
56
- // Emulate a sleep function.
103
+ /**
104
+ * Emulate a sleep function.
105
+ *
106
+ * @param sleepTimer - The amount of time to sleep, in milliseconds.
107
+ *
108
+ * @returns Returns a promise that resolves after the specified time elapses.
109
+ *
110
+ * @example
111
+ * To sleep for 3 seconds before continuing execute:
112
+ *
113
+ * ```ts
114
+ * await sleep(3000)
115
+ * ```
116
+ *
117
+ * @category Utilities
118
+ */
57
119
  export async function sleep(sleepTimer) {
58
120
  return new Promise(resolve => setTimeout(resolve, sleepTimer));
59
121
  }
60
122
  /**
61
- * A utility method that camel case's a string.
62
- * @param string - The string to camel case.
123
+ * Camel case a string.
124
+ *
125
+ * @param input - The string to camel case.
63
126
  *
64
127
  * @returns Returns the camel cased string.
65
128
  *
129
+ * @example
130
+ * ```ts
131
+ * toCamelCase(This is a test)
132
+ * ```
133
+ *
134
+ * Returns: `This Is A Test`, capitalizing the first letter of each word.
66
135
  * @category Utilities
67
136
  */
68
137
  export function toCamelCase(input) {
69
138
  return input.replace(/(^\w|\s+\w)/g, match => match.toUpperCase());
70
139
  }
71
- // Validate a name according to HomeKit naming conventions.
140
+ /**
141
+ * Validate an accessory name according to HomeKit naming conventions.
142
+ *
143
+ * @param name - The name to validate.
144
+ *
145
+ * @returns Returns the HomeKit-validated version of the name, replacing invalid characters with a space and squashing multiple spaces.
146
+ *
147
+ * @remarks This validates names using [HomeKit's naming rulesets](https://developer.apple.com/design/human-interface-guidelines/homekit#Help-people-choose-useful-names):
148
+ *
149
+ * - Use only alphanumeric, space, and apostrophe characters.
150
+ * - Start and end with an alphabetic or numeric character.
151
+ * - Don’t include emojis.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * validateName("Test.Switch")
156
+ * ```ts
157
+ *
158
+ * Returns: `Test Switch`, replacing the period (an invalid character in HomeKit's naming ruleset) with a space.
159
+ *
160
+ * @category Utilities
161
+ */
72
162
  export function validateName(name) {
73
- // Validate our names using [HomeKit's naming rulesets](https://developer.apple.com/design/human-interface-guidelines/homekit#Help-people-choose-useful-names):
74
- //
75
- // - Use only alphanumeric, space, and apostrophe characters.
76
- // - Start and end with an alphabetic or numeric character.
77
- // - Don’t include emojis.
78
- //
79
- // Invalid characters will be replaced by a space, and multiple spaces will be squashed.
80
163
  return name.replace(/[^\p{L}\p{N} ']+/gu, " ").replace(/\s+/g, " ").trim();
81
164
  }
82
165
  //# sourceMappingURL=util.js.map
package/dist/util.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA2CH;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IAErC,4BAA4B;IAC5B,IAAG,KAAK,GAAG,IAAI,EAAE,CAAC;QAEhB,OAAO,KAAK,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC;IACnC,CAAC;IAED,kCAAkC;IAClC,IAAG,KAAK,GAAG,OAAO,EAAE,CAAC;QAEnB,MAAM,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC;QAE1B,OAAO,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAC1E,CAAC;IAED,kCAAkC;IAClC,MAAM,IAAI,GAAG,KAAK,GAAG,OAAO,CAAC;IAE7B,OAAO,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;AAC1E,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,SAAiC,EAAE,aAAqB,EAAE,YAAqB;IAEzG,IA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AE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-plugin-utils",
3
- "version": "1.15.3",
3
+ "version": "1.17.0",
4
4
  "displayName": "Homebridge Plugin Utilities",
5
5
  "description": "Opinionated utilities to provide common capabilities and create rich configuration webUI experiences for Homebridge plugins.",
6
6
  "author": {
@@ -31,23 +31,27 @@
31
31
  ],
32
32
  "scripts": {
33
33
  "build": "npm run clean && tsc && shx cp dist/featureoptions.js{,.map} dist/ui",
34
+ "build-docs": "shx rm -f ./docs/[^CO]*.md ./docs/ffmpeg/*.md && npx typedoc",
34
35
  "build-ui": "shx mkdir -p dist/ui && shx cp ui/**.mjs dist/ui",
35
36
  "clean": "shx rm -rf dist && npm run build-ui",
36
- "lint": "eslint --max-warnings=${ESLINT_MAX_WARNINGS:-\"-1\"} eslint.config.mjs build/**.mjs src/**.ts \"ui/**/*.@(js|mjs)\"",
37
+ "lint": "eslint --max-warnings=${ESLINT_MAX_WARNINGS:-\"-1\"} eslint.config.mjs build/**.mjs src \"ui/**/*.@(js|mjs)\"",
37
38
  "postpublish": "npm run clean",
38
39
  "prepublishOnly": "npm run lint && npm run build"
39
40
  },
40
41
  "main": "dist/index.js",
41
42
  "devDependencies": {
42
- "@stylistic/eslint-plugin": "4.2.0",
43
- "@types/node": "22.13.10",
44
- "eslint": "^9.22.0",
45
- "homebridge": "1.8.4",
46
- "shx": "0.3.4",
47
- "typescript": "5.8.2",
48
- "typescript-eslint": "^8.26.1"
43
+ "@stylistic/eslint-plugin": "4.4.0",
44
+ "@types/node": "22.15.21",
45
+ "@types/ws": "^8.18.1",
46
+ "eslint": "^9.27.0",
47
+ "homebridge": "1.9.0",
48
+ "shx": "0.4.0",
49
+ "typedoc": "0.28.4",
50
+ "typedoc-plugin-markdown": "4.6.3",
51
+ "typescript": "5.8.3",
52
+ "typescript-eslint": "^8.32.1"
49
53
  },
50
54
  "dependencies": {
51
- "mqtt": "5.10.4"
55
+ "mqtt": "5.13.0"
52
56
  }
53
57
  }
package/dist/rtp.d.ts DELETED
@@ -1,32 +0,0 @@
1
- import { EventEmitter } from "node:events";
2
- import { HomebridgePluginLogging } from "./util.js";
3
- /**
4
- * Here's the problem this class solves: FFmpeg doesn't support multiplexing RTP and RTCP data on a single UDP port (RFC 5761). If it did, we wouldn't need this
5
- * workaround for HomeKit compatibility, which does multiplex RTP and RTCP over a single UDP port.
6
- *
7
- * This class inspects all packets coming in from inputPort and demultiplexes RTP and RTCP traffic to rtpPort and rtcpPort, respectively.
8
- *
9
- * Credit to @dgreif and @brandawg93 who graciously shared their code as a starting point, and their collaboration in answering the questions needed to bring all this
10
- * together. A special thank you to @Sunoo for the many hours of discussion and brainstorming on this and other topics.
11
- */
12
- export declare class RtpDemuxer extends EventEmitter {
13
- private heartbeatTimer;
14
- private heartbeatMsg;
15
- private _isRunning;
16
- private log?;
17
- private inputPort;
18
- readonly socket: import("dgram").Socket;
19
- constructor(ipFamily: ("ipv4" | "ipv6"), inputPort: number, rtcpPort: number, rtpPort: number, log: HomebridgePluginLogging);
20
- private heartbeat;
21
- close(): void;
22
- private getPayloadType;
23
- private isRtpMessage;
24
- get isRunning(): boolean;
25
- }
26
- export declare class RtpPortAllocator {
27
- private portsInUse;
28
- constructor();
29
- private getPort;
30
- reserve(ipFamily?: ("ipv4" | "ipv6"), portCount?: (1 | 2), attempts?: number): Promise<number>;
31
- cancel(port: number): void;
32
- }