homebridge-plugin-utils 1.13.0 → 1.15.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/LICENSE.md +1 -1
- package/build/eslint-rules.mjs +1 -1
- package/build/tsconfig.json +5 -5
- package/dist/index.js +1 -1
- package/dist/rtp.js +1 -1
- package/dist/ui/webUi-featureoptions.mjs +1 -1
- package/dist/ui/webUi.mjs +1 -1
- package/dist/util.d.ts +17 -0
- package/dist/util.js +33 -1
- package/dist/util.js.map +1 -1
- package/package.json +8 -8
package/LICENSE.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Internet Systems Consortium License
|
|
2
2
|
===================================
|
|
3
3
|
|
|
4
|
-
Copyright (c) `2017-
|
|
4
|
+
Copyright (c) `2017-2025`, `HJD https://github.com/hjdhjd`
|
|
5
5
|
|
|
6
6
|
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
7
7
|
with or without fee is hereby granted, provided that the above copyright notice
|
package/build/eslint-rules.mjs
CHANGED
package/build/tsconfig.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Copyright(C) 2017-
|
|
1
|
+
/* Copyright(C) 2017-2025, HJD (https://github.com/hjdhjd). All rights reserved.
|
|
2
2
|
*
|
|
3
3
|
* tsconfig.json: Default TypeScript transpiler options for ESM Homebridge plugins.
|
|
4
4
|
*/
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
*
|
|
28
28
|
* {
|
|
29
29
|
* "compilerOptions": {
|
|
30
|
-
*
|
|
30
|
+
*
|
|
31
31
|
* "outDir": "dist",
|
|
32
32
|
* "rootDir": "src"
|
|
33
33
|
* },
|
|
34
|
-
*
|
|
34
|
+
*
|
|
35
35
|
* "extends": "./build/tsconfig.json",
|
|
36
|
-
*
|
|
36
|
+
*
|
|
37
37
|
* "include": [
|
|
38
|
-
*
|
|
38
|
+
*
|
|
39
39
|
* "build",
|
|
40
40
|
* "eslint.config.mjs",
|
|
41
41
|
* "src",
|
package/dist/index.js
CHANGED
package/dist/rtp.js
CHANGED
package/dist/ui/webUi.mjs
CHANGED
package/dist/util.d.ts
CHANGED
|
@@ -32,6 +32,14 @@ export interface HomebridgePluginLogging {
|
|
|
32
32
|
info: (message: string, ...parameters: unknown[]) => void;
|
|
33
33
|
warn: (message: string, ...parameters: unknown[]) => void;
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* A utility method that formats a bitrate value into a human-readable form as kbps or Mbps.
|
|
37
|
+
*
|
|
38
|
+
* @param value - The bitrate value to convert.
|
|
39
|
+
*
|
|
40
|
+
* @returns Returns the value as a human-readable string.
|
|
41
|
+
*/
|
|
42
|
+
export declare function formatBps(value: number): string;
|
|
35
43
|
/**
|
|
36
44
|
* A utility method that retries an operation at a specific interval for up to an absolute total number of retries.
|
|
37
45
|
* @param operation - The operation callback to try until successful.
|
|
@@ -47,4 +55,13 @@ export interface HomebridgePluginLogging {
|
|
|
47
55
|
export declare function retry(operation: () => Promise<boolean>, retryInterval: number, totalRetries?: number): Promise<boolean>;
|
|
48
56
|
export declare function runWithTimeout<T>(promise: Promise<T>, timeout: number): Promise<Nullable<T>>;
|
|
49
57
|
export declare function sleep(sleepTimer: number): Promise<NodeJS.Timeout>;
|
|
58
|
+
/**
|
|
59
|
+
* A utility method that camel case's a string.
|
|
60
|
+
* @param string - The string to camel case.
|
|
61
|
+
*
|
|
62
|
+
* @returns Returns the camel cased string.
|
|
63
|
+
*
|
|
64
|
+
* @category Utilities
|
|
65
|
+
*/
|
|
66
|
+
export declare function toCamelCase(input: string): string;
|
|
50
67
|
export declare function validateName(name: string): string;
|
package/dist/util.js
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
|
-
/* Copyright(C) 2017-
|
|
1
|
+
/* Copyright(C) 2017-2025, HJD (https://github.com/hjdhjd). All rights reserved.
|
|
2
2
|
*
|
|
3
3
|
* util.ts: Useful utility functions when writing TypeScript.
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* A utility method that formats a bitrate value into a human-readable form as kbps or Mbps.
|
|
7
|
+
*
|
|
8
|
+
* @param value - The bitrate value to convert.
|
|
9
|
+
*
|
|
10
|
+
* @returns Returns the value as a human-readable string.
|
|
11
|
+
*/
|
|
12
|
+
export function formatBps(value) {
|
|
13
|
+
// Return the bitrate as-is.
|
|
14
|
+
if (value < 1000) {
|
|
15
|
+
return value.toString() + " bps";
|
|
16
|
+
}
|
|
17
|
+
// Return the bitrate in kilobits.
|
|
18
|
+
if (value < 1000000) {
|
|
19
|
+
const kbps = value / 1000;
|
|
20
|
+
return ((kbps % 1) === 0 ? kbps.toFixed(0) : kbps.toFixed(1)) + " kbps";
|
|
21
|
+
}
|
|
22
|
+
// Return the bitrate in megabits.
|
|
23
|
+
const mbps = value / 1000000;
|
|
24
|
+
return ((mbps % 1) === 0 ? mbps.toFixed(0) : mbps.toFixed(1)) + " Mbps";
|
|
25
|
+
}
|
|
5
26
|
/**
|
|
6
27
|
* A utility method that retries an operation at a specific interval for up to an absolute total number of retries.
|
|
7
28
|
* @param operation - The operation callback to try until successful.
|
|
@@ -36,6 +57,17 @@ export async function runWithTimeout(promise, timeout) {
|
|
|
36
57
|
export async function sleep(sleepTimer) {
|
|
37
58
|
return new Promise(resolve => setTimeout(resolve, sleepTimer));
|
|
38
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* A utility method that camel case's a string.
|
|
62
|
+
* @param string - The string to camel case.
|
|
63
|
+
*
|
|
64
|
+
* @returns Returns the camel cased string.
|
|
65
|
+
*
|
|
66
|
+
* @category Utilities
|
|
67
|
+
*/
|
|
68
|
+
export function toCamelCase(input) {
|
|
69
|
+
return input.replace(/(^\w|\s+\w)/g, match => match.toUpperCase());
|
|
70
|
+
}
|
|
39
71
|
// Validate a name according to HomeKit naming conventions.
|
|
40
72
|
export function validateName(name) {
|
|
41
73
|
// Validate our names using [HomeKit's naming rulesets](https://developer.apple.com/design/human-interface-guidelines/homekit#Help-people-cho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BAA0B;IAC1B,EAAE;IACF,wFAAwF;IACxF,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,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.
|
|
3
|
+
"version": "1.15.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": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"type": "module",
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
21
|
+
"node": ">=20"
|
|
22
22
|
},
|
|
23
23
|
"keywords": [
|
|
24
24
|
"homebridge",
|
|
@@ -39,15 +39,15 @@
|
|
|
39
39
|
},
|
|
40
40
|
"main": "dist/index.js",
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@stylistic/eslint-plugin": "2.
|
|
43
|
-
"@types/node": "22.10
|
|
44
|
-
"eslint": "^9.
|
|
42
|
+
"@stylistic/eslint-plugin": "4.2.0",
|
|
43
|
+
"@types/node": "22.13.10",
|
|
44
|
+
"eslint": "^9.22.0",
|
|
45
45
|
"homebridge": "1.8.4",
|
|
46
46
|
"shx": "0.3.4",
|
|
47
|
-
"typescript": "5.
|
|
48
|
-
"typescript-eslint": "^8.
|
|
47
|
+
"typescript": "5.8.2",
|
|
48
|
+
"typescript-eslint": "^8.26.1"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"mqtt": "5.10.
|
|
51
|
+
"mqtt": "5.10.4"
|
|
52
52
|
}
|
|
53
53
|
}
|