homebridge-lib 7.0.0-0 → 7.0.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/cli/hap.js CHANGED
@@ -7,6 +7,11 @@
7
7
  //
8
8
  // Logger for HomeKit accessory announcements.
9
9
 
10
- import { HapTool } from 'hb-lib-tools'
10
+ import { createRequire } from 'node:module'
11
11
 
12
- new HapTool(import.meta.dirname).main()
12
+ import { HapTool } from 'hb-lib-tools/HapTool'
13
+
14
+ const require = createRequire(import.meta.url)
15
+ const packageJson = require('../package.json')
16
+
17
+ new HapTool(packageJson).main()
package/cli/json.js CHANGED
@@ -7,6 +7,11 @@
7
7
  //
8
8
  // JSON formatter.
9
9
 
10
- import { JsonTool } from 'hb-lib-tools'
10
+ import { createRequire } from 'node:module'
11
11
 
12
- new JsonTool(import.meta.dirname).main()
12
+ import { JsonTool } from 'hb-lib-tools/JsonTool'
13
+
14
+ const require = createRequire(import.meta.url)
15
+ const packageJson = require('../package.json')
16
+
17
+ new JsonTool(packageJson).main()
package/cli/sysinfo.js CHANGED
@@ -7,6 +7,11 @@
7
7
  //
8
8
  // Show system info.
9
9
 
10
- import { SysinfoTool } from 'hb-lib-tools'
10
+ import { createRequire } from 'node:module'
11
11
 
12
- new SysinfoTool(import.meta.dirname).main()
12
+ import { SysinfoTool } from 'hb-lib-tools/SysinfoTool'
13
+
14
+ const require = createRequire(import.meta.url)
15
+ const packageJson = require('../package.json')
16
+
17
+ new SysinfoTool(packageJson).main()
package/cli/upnp.js CHANGED
@@ -7,6 +7,11 @@
7
7
  //
8
8
  // Logger for UPnP device announcements.
9
9
 
10
- import { UpnpTool } from 'hb-lib-tools'
10
+ import { createRequire } from 'node:module'
11
11
 
12
- new UpnpTool(import.meta.dirname).main()
12
+ import { UpnpTool } from 'hb-lib-tools/UpnpTool'
13
+
14
+ const require = createRequire(import.meta.url)
15
+ const packageJson = require('../package.json')
16
+
17
+ new UpnpTool(packageJson).main()
package/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  // Copyright © 2017-2024 Erik Baauw. All rights reserved.
5
5
 
6
6
  /** Library for Homebridge plugins.
7
- * see the {@tutorial homebridgeLib} tutorial.
7
+ * see the {@tutorial homebridge-lib} tutorial.
8
8
  *
9
9
  * Homebridge Lib provides:
10
10
  * - A series of base classes for building Homebridge dynamic platform plugins:
@@ -34,7 +34,7 @@
34
34
  * To access the classes provided by Homebridge Lib from your module,
35
35
  * simply load it by:
36
36
  * ```javascript
37
- * import homebridgeLib from 'homebridge-lib'
37
+ * import { Class } from 'homebridge-lib/Class'
38
38
  * ```
39
39
  *
40
40
  * Note that each class provided by Homebridge Lib is implemented as a
@@ -42,188 +42,26 @@
42
42
  * Due to the way NodeJS deals with circular module dependencies, these modules
43
43
  * might not yet be initialised while your module is loading.
44
44
  *
45
- * @module homebridgeLib
45
+ * @module homebridge-lib
46
46
  */
47
47
 
48
- /** Abstract superclass for {@link Platform}, {@link AccessoryDelegate},
49
- * {@link ServiceDelegate}, and {@link CharacteristicDelegate}.
50
- * <br>See {@link Delegate}.
51
- * @name Delegate
52
- * @type {Class}
53
- * @memberof module:homebridgeLib
54
- */
55
- export { Delegate } from './lib/Delegate.js'
56
-
57
- /** Delegate of a HomeKit accessory.
58
- * <br>See {@link AccessoryDelegate}.
59
- * @name AccessoryDelegate
60
- * @type {Class}
61
- * @memberof module:homebridgeLib
62
- */
63
- export { AccessoryDelegate } from './lib/AccessoryDelegate.js'
64
-
65
- /** Adaptive Lighting.
66
- * <br>See {@link AdaptiveLighting}.
67
- * @name AdaptiveLighting
68
- * @type {Class}
69
- * @memberof module:homebridgeLib
70
- */
71
- export { AdaptiveLighting } from './lib/AdaptiveLighting.js'
72
-
73
- /** Return the `Bonjour` class from [`bonjour-hap`](https://github.com/homebridge/bonjour),
74
- * so plugins don't have to list this as a separate dependency.
75
- * @name Bonjour
76
- * @type {Class}
77
- * @memberof module:homebridgeLib
78
- */
79
- export { Bonjour } from 'hb-lib-tools'
80
-
81
- /** Delegate of a HomeKit characteristic.
82
- * <br>See {@link CharacteristicDelegate}.
83
- * @name CharacteristicDelegate
84
- * @type {Class}
85
- * @memberof module:homebridgeLib
86
- */
87
- export { CharacteristicDelegate } from './lib/CharacteristicDelegate.js'
88
-
89
- /** Colour conversions.
90
- * <br>See {@link Colour}.
91
- * @name Colour
92
- * @type {Class}
93
- * @memberof module:homebridgeLib
94
- */
95
- export { Colour } from 'hb-lib-tools'
96
-
97
- /** Parser and validator for command-line arguments.
98
- * <br>See {@link CommandLineParser}.
99
- * @name CommandLineParser
100
- * @type {Class}
101
- * @memberof module:homebridgeLib
102
- */
103
- export { CommandLineParser } from 'hb-lib-tools'
104
-
105
- /** Command-line tool.
106
- * <br>See {@link CommandLineTool}.
107
- * @name CommandLineTool
108
- * @type {Class}
109
- * @memberof module:homebridgeLib
110
- */
111
- export { CommandLineTool } from 'hb-lib-tools'
112
-
113
- /** Abstract superclass for {@link EveHomeKitTypes}
114
- * and {@link MyHomeKitTypes}.
115
- * <br>See {@link CustomHomeKitTypes}.
116
- * @name CustomHomeKitTypes
117
- * @type {Class}
118
- * @memberof module:homebridgeLib
119
- */
120
- export { CustomHomeKitTypes } from './lib/CustomHomeKitTypes.js'
121
-
122
- /** Custom HomeKit services and characteristics used by
123
- * [Eve](https://www.evehome.com/en) accessories and by the
124
- * [Eve app](https://www.evehome.com/en/eve-app).
125
- * <br>See {@link EveHomeKitTypes}.
126
- * @name EveHomeKitTypes
127
- * @type {Class}
128
- * @memberof module:homebridgeLib
129
- */
130
- export { EveHomeKitTypes } from './lib/EveHomeKitTypes.js'
131
-
132
- /** HTTP client.
133
- * <br>See {@link HttpClient}.
134
- * @name HttpClient
135
- * @type {Class}
136
- * @memberof module:homebridgeLib
137
- */
138
- export { HttpClient } from 'hb-lib-tools'
139
-
140
- /** JSON formatter.
141
- * <br>See {@link JsonFormatter}.
142
- * @name JsonFormatter
143
- * @type {Class}
144
- * @memberof module:homebridgeLib
145
- */
146
- export { JsonFormatter } from 'hb-lib-tools'
147
-
148
- /** My own collection of custom HomeKit services and characteristics.
149
- * <br>See {@link MyHomeKitTypes}.
150
- * @name MyHomeKitTypes
151
- * @type {Class}
152
- * @memberof module:homebridgeLib
153
- */
154
- export { MyHomeKitTypes } from './lib/MyHomeKitTypes.js'
155
-
156
- /** Parser and validator for options and other parameters.
157
- * <br>See {@link OptionParser}.
158
- * @name OptionParser
159
- * @type {Class}
160
- * @memberof module:homebridgeLib
161
- */
162
- export { OptionParser } from 'hb-lib-tools'
163
-
164
- /** Homebridge dynamic platform plugin.
165
- * <br>See {@link Platform}.
166
- * @name Platform
167
- * @type {Class}
168
- * @memberof module:homebridgeLib
169
- */
170
- export { Platform } from './lib/Platform.js'
171
-
172
- /** Delegate of a property of a HomeKit accessory or service.
173
- * <br>See {@link PropertyDelegate}.
174
- * @name PropertyDelegate
175
- * @type {Class}
176
- * @memberof module:homebridgeLib
177
- */
178
- export { PropertyDelegate } from './lib/PropertyDelegate.js'
179
-
180
- /** Delegate of a HomeKit service.
181
- * <br>See {@link ServiceDelegate}.
182
- * @name ServiceDelegate
183
- * @type {Class}
184
- * @memberof module:homebridgeLib
185
- */
186
- export { ServiceDelegate } from './lib/ServiceDelegate/index.js'
187
-
188
- /** System information.
189
- * <br>See {@link SystemInfo}.
190
- * @name SystemInfo
191
- * @type {Class}
192
- * @memberof module:homebridgeLib
193
- */
194
- export { SystemInfo } from 'hb-lib-tools'
195
-
196
- /** Universal Plug and Play client.
197
- * <br>See {@link UpnpClient}.
198
- * @name UpnpClient
199
- * @type {Class}
200
- * @memberof module:homebridgeLib
201
- */
202
- export { UpnpClient } from 'hb-lib-tools'
203
-
204
- // /** Server for dynamic configuration settings through Homebridge UI.
205
- // * <br>See {@link UiServer}.
206
- // * @name UiServer
207
- // * @type {Class}
208
- // * @memberof module:homebridgeLib
209
- // */
210
- // export { UiServer } from './lib/UiServer.js'
211
-
212
48
  /** Convert Error to string.
213
49
  *
214
50
  * Include the stack trace only for programming errors (JavaScript and NodeJS
215
51
  * runtime errors).
216
52
  * Translate system errors into more readable messages.
53
+ * @function formatError
217
54
  * @param {Error} e - The error.
218
55
  * @param {boolean} [useChalk=false] - Use chalk to grey out the stack trace.
219
56
  * @returns {string} - The error as string.
220
- * @memberof module:homebridgeLib
57
+ * @memberof module:homebridge-lib
221
58
  */
222
59
  export { formatError } from 'hb-lib-tools'
223
60
 
224
61
  /** Return the recommended version of NodeJS from package.json.
225
62
  * This is the version used to develop and test the software,
226
63
  * typically the latest LTS version.
64
+ * @function recommendedNodeVersion
227
65
  * @param {string} packageJson - The contents of package.json
228
66
  * #return {string} - The recommended version.
229
67
  * @memberof module:hbLibTools
@@ -234,38 +72,24 @@ export { recommendedNodeVersion } from 'hb-lib-tools'
234
72
  *
235
73
  * E.g. to delay execution for 1.5 seconds, issue:
236
74
  * ```javascript
237
- * await homebridgeLib.timeout(1500)
75
+ * import { timeout } from 'homebridge-lib'
76
+ *
77
+ * await timeout(1500)
238
78
  * ```
239
79
  *
80
+ * @function timeout
240
81
  * @param {integer} msec - Period (in msec) to wait.
241
82
  * @throws {TypeError} On invalid parameter type.
242
83
  * @throws {RangeError} On invalid parameter value.
243
- * @memberof module:homebridgeLib
84
+ * @memberof module:homebridge-lib
244
85
  */
245
86
  export { timeout } from 'hb-lib-tools'
246
87
 
247
88
  /** Convert integer to hex string.
89
+ * @function toHexString
248
90
  * @param {integer} i - The integer.
249
91
  * @param {integer} [length=4] - The number of digits in the hex string.
250
92
  * @returns {string} - The hex string.
251
- * @memberof module:homebridgeLib
93
+ * @memberof module:homebridge-lib
252
94
  */
253
95
  export { toHexString } from 'hb-lib-tools'
254
-
255
- /** Return the [`chalk`](https://github.com/chalk/chalk) module,
256
- * so plugins don't have to list this as a separate dependency.
257
- * @memberof module:homebridgeLib
258
- */
259
- export { chalk } from 'hb-lib-tools'
260
-
261
- /** Return the [`semver`](https://github.com/npm/node-semver) module,
262
- * so plugins don't have to list this as a separate dependency.
263
- * @memberof module:homebridgeLib
264
- */
265
- export { semver } from 'hb-lib-tools'
266
-
267
- export { AccessoryInformation } from './lib/ServiceDelegate/AccessoryInformation.js'
268
- export { Battery } from './lib/ServiceDelegate/Battery.js'
269
- export { Dummy } from './lib/ServiceDelegate/Dummy.js'
270
- export { History } from './lib/ServiceDelegate/History.js'
271
- export { ServiceLabel } from './lib/ServiceDelegate/ServiceLabel.js'
@@ -3,10 +3,21 @@
3
3
  // Library for Homebridge plugins.
4
4
  // Copyright © 2017-2024 Erik Baauw. All rights reserved.
5
5
 
6
- import { CharacteristicDelegate, Delegate, PropertyDelegate, ServiceDelegate } from '../index.js'
6
+ import { CharacteristicDelegate } from 'homebridge-lib/CharacteristicDelegate'
7
+ import { Delegate } from 'homebridge-lib/Delegate'
8
+ import { PropertyDelegate } from 'homebridge-lib/PropertyDelegate'
9
+ import { ServiceDelegate } from 'homebridge-lib/ServiceDelegate'
10
+ import 'homebridge-lib/ServiceDelegate/AccessoryInformation'
7
11
 
8
12
  const startsWithUuid = /^[0-9A-F]{8}-[0-9A-F]{4}-[1-5][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}/
9
13
 
14
+ /** Delegate of a HomeKit accessory.
15
+ * <br>See {@link AccessoryDelegate}.
16
+ * @name AccessoryDelegate
17
+ * @type {Class}
18
+ * @memberof module:homebridge-lib
19
+ */
20
+
10
21
  /** Delegate of a HomeKit accessory.
11
22
  *
12
23
  * @abstract
@@ -73,8 +84,7 @@ class AccessoryDelegate extends Delegate {
73
84
 
74
85
  // Create delegate for AccessoryInformation service.
75
86
  this._serviceDelegates = {}
76
- this._accessoryInformationDelegate =
77
- new ServiceDelegate.AccessoryInformation(this, params)
87
+ this._accessoryInformationDelegate = new ServiceDelegate.AccessoryInformation(this, params)
78
88
 
79
89
  // Configure PlatformAccessory.
80
90
  this._accessory.on('identify', this._identify.bind(this))
@@ -3,7 +3,7 @@
3
3
  // Library for Homebridge plugins.
4
4
  // Copyright © 2020-2024 Erik Baauw. All rights reserved.
5
5
 
6
- import { CharacteristicDelegate } from '../index.js'
6
+ import { CharacteristicDelegate } from 'homebridge-lib/CharacteristicDelegate'
7
7
 
8
8
  /* global BigInt */
9
9
 
@@ -162,6 +162,13 @@ function tlvFromHexString (type, value) {
162
162
  return tlvFromBuffer(type, Buffer.from(value, 'hex'))
163
163
  }
164
164
 
165
+ /** Adaptive Lighting.
166
+ * <br>See {@link AdaptiveLighting}.
167
+ * @name AdaptiveLighting
168
+ * @type {Class}
169
+ * @memberof module:homebridge-lib
170
+ */
171
+
165
172
  /** Adaptive Lighting.
166
173
  */
167
174
  class AdaptiveLighting {
package/lib/Bonjour.js ADDED
@@ -0,0 +1,12 @@
1
+ // homebridge-lib/lib/Bonjour.js
2
+ //
3
+ // Library for Homebridge plugins.
4
+ // Copyright © 2020-2024 Erik Baauw. All rights reserved.
5
+
6
+ /** Return the `Bonjour` class from [`bonjour-hap`](https://github.com/homebridge/bonjour),
7
+ * so plugins don't have to list this as a separate dependency.
8
+ * @name Bonjour
9
+ * @type {Class}
10
+ * @memberof module:homebridge-lib
11
+ */
12
+ export { Bonjour } from 'hb-lib-tools/Bonjour'
@@ -3,7 +3,16 @@
3
3
  // Library for Homebridge plugins.
4
4
  // Copyright © 2017-2024 Erik Baauw. All rights reserved.
5
5
 
6
- import { Delegate, OptionParser, ServiceDelegate } from '../index.js'
6
+ import { Delegate } from 'homebridge-lib/Delegate'
7
+ import { OptionParser } from 'homebridge-lib/OptionParser'
8
+ import { ServiceDelegate } from 'homebridge-lib/ServiceDelegate'
9
+
10
+ /** Delegate of a HomeKit characteristic.
11
+ * <br>See {@link CharacteristicDelegate}.
12
+ * @name CharacteristicDelegate
13
+ * @type {Class}
14
+ * @memberof module:homebridge-lib
15
+ */
7
16
 
8
17
  /** Delegate of a HomeKit characteristic.
9
18
  *
package/lib/Colour.js ADDED
@@ -0,0 +1,12 @@
1
+ // homebridge-lib/lib/Colour.js
2
+ //
3
+ // Library for Homebridge plugins.
4
+ // Copyright © 2020-2024 Erik Baauw. All rights reserved.
5
+
6
+ /** Colour conversions.
7
+ * <br>See {@link Colour}.
8
+ * @name Colour
9
+ * @type {Class}
10
+ * @memberof module:homebridge-lib
11
+ */
12
+ export { Colour } from 'hb-lib-tools/Colour'
@@ -0,0 +1,12 @@
1
+ // homebridge-lib/lib/CommandLineParser.js
2
+ //
3
+ // Library for Homebridge plugins.
4
+ // Copyright © 2020-2024 Erik Baauw. All rights reserved.
5
+
6
+ /** Parser and validator for command-line arguments.
7
+ * <br>See {@link CommandLineParser}.
8
+ * @name CommandLineParser
9
+ * @type {Class}
10
+ * @memberof module:homebridge-lib
11
+ */
12
+ export { CommandLineParser } from 'hb-lib-tools/CommandLineParser'
@@ -0,0 +1,12 @@
1
+ // homebridge-lib/lib/CommandLineTool.js
2
+ //
3
+ // Library for Homebridge plugins.
4
+ // Copyright © 2020-2024 Erik Baauw. All rights reserved.
5
+
6
+ /** Command-line tool.
7
+ * <br>See {@link CommandLineTool}.
8
+ * @name CommandLineTool
9
+ * @type {Class}
10
+ * @memberof module:homebridge-lib
11
+ */
12
+ export { CommandLineTool } from 'hb-lib-tools/CommandLineTool'
@@ -13,6 +13,14 @@ let hap
13
13
  let hapCharacteristics
14
14
  let hapServices
15
15
 
16
+ /** Abstract superclass for {@link EveHomeKitTypes}
17
+ * and {@link MyHomeKitTypes}.
18
+ * <br>See {@link CustomHomeKitTypes}.
19
+ * @name CustomHomeKitTypes
20
+ * @type {Class}
21
+ * @memberof module:homebridge-lib
22
+ */
23
+
16
24
  /** Abstract superclass for {@link EveHomeKitTypes} and {@link MyHomeKitTypes}.
17
25
  *
18
26
  * `CustomHomeKitTypes` creates and manages a collection of:
package/lib/Delegate.js CHANGED
@@ -5,7 +5,17 @@
5
5
 
6
6
  import { EventEmitter } from 'node:events'
7
7
 
8
- import { HttpClient, Platform } from '../index.js'
8
+ import { HttpClient } from 'hb-lib-tools/HttpClient'
9
+
10
+ import { Platform } from 'homebridge-lib/Platform'
11
+
12
+ /** Abstract superclass for {@link Platform}, {@link AccessoryDelegate},
13
+ * {@link ServiceDelegate}, and {@link CharacteristicDelegate}.
14
+ * <br>See {@link Delegate}.
15
+ * @name Delegate
16
+ * @type {Class}
17
+ * @memberof module:homebridge-lib
18
+ */
9
19
 
10
20
  /** Abstract superclass for {@link Platform}, {@link AccessoryDelegate},
11
21
  * {@link ServiceDelegate}, and {@link CharacteristicDelegate}.
@@ -3,7 +3,7 @@
3
3
  // Library for Homebridge plugins.
4
4
  // Copyright © 2017-2024 Erik Baauw. All rights reserved.
5
5
 
6
- import { CustomHomeKitTypes } from '../index.js'
6
+ import { CustomHomeKitTypes } from 'homebridge-lib/CustomHomeKitTypes'
7
7
 
8
8
  // Return long Eve UUID.
9
9
  function uuid (id) {
@@ -14,6 +14,15 @@ function uuid (id) {
14
14
  return `E863F${id}-079E-48FF-8F27-9C2605A29F52`
15
15
  }
16
16
 
17
+ /** Custom HomeKit services and characteristics used by
18
+ * [Eve](https://www.evehome.com/en) accessories and by the
19
+ * [Eve app](https://www.evehome.com/en/eve-app).
20
+ * <br>See {@link EveHomeKitTypes}.
21
+ * @name EveHomeKitTypes
22
+ * @type {Class}
23
+ * @memberof module:homebridge-lib
24
+ */
25
+
17
26
  /** Custom HomeKit Services and Characteristic used by
18
27
  * [Eve](https://www.evehome.com/en) accessories and by the
19
28
  * [Eve app](https://www.evehome.com/en/eve-app).
@@ -0,0 +1,7 @@
1
+ /** HTTP client.
2
+ * <br>See {@link HttpClient}.
3
+ * @name HttpClient
4
+ * @type {Class}
5
+ * @memberof module:homebridge-lib
6
+ */
7
+ export { HttpClient } from 'hb-lib-tools/HttpClient'
@@ -0,0 +1,7 @@
1
+ /** JSON formatter.
2
+ * <br>See {@link JsonFormatter}.
3
+ * @name JsonFormatter
4
+ * @type {Class}
5
+ * @memberof module:homebridge-lib
6
+ */
7
+ export { JsonFormatter } from 'hb-lib-tools/JsonFormatter'
@@ -5,16 +5,21 @@
5
5
  //
6
6
  // My own collection of custom HomeKit Services and Characteristics.
7
7
 
8
- import { CustomHomeKitTypes } from '../index.js'
8
+ import { CustomHomeKitTypes } from 'homebridge-lib/CustomHomeKitTypes'
9
9
 
10
10
  function uuid (id) {
11
11
  return MyHomeKitTypes.uuid(id, '-0000-1000-8000-656261617577')
12
12
  }
13
-
14
- /**
15
- * My own collection of custom HomeKit Services and Characteristics.
16
- * @extends CustomHomeKitTypes
17
- */
13
+ /** My own collection of custom HomeKit services and characteristics.
14
+ * <br>See {@link MyHomeKitTypes}.
15
+ * @name MyHomeKitTypes
16
+ * @type {Class}
17
+ * @memberof module:homebridge-lib
18
+ */
19
+
20
+ /** My own collection of custom HomeKit Services and Characteristics.
21
+ * @extends CustomHomeKitTypes
22
+ */
18
23
  class MyHomeKitTypes extends CustomHomeKitTypes {
19
24
  /**
20
25
  * Create my custom HomeKit Services and Characteristics.
@@ -0,0 +1,12 @@
1
+ // homebridge-lib/lib/OptionParser.js
2
+ //
3
+ // Library for Homebridge plugins.
4
+ // Copyright © 2017-2024 Erik Baauw. All rights reserved.
5
+
6
+ /** Parser and validator for options and other parameters.
7
+ * <br>See {@link OptionParser}.
8
+ * @name OptionParser
9
+ * @type {Class}
10
+ * @memberof module:homebridge-lib
11
+ */
12
+ export { OptionParser } from 'hb-lib-tools/OptionParser'
package/lib/Platform.js CHANGED
@@ -4,21 +4,25 @@
4
4
  // Copyright © 2017-2024 Erik Baauw. All rights reserved.
5
5
 
6
6
  import { once } from 'node:events'
7
- import { readFileSync } from 'node:fs'
8
7
  import { writeFile, unlink } from 'node:fs/promises'
9
8
  import { Server, STATUS_CODES } from 'node:http'
10
- import { join } from 'node:path'
9
+ import { createRequire } from 'node:module'
11
10
  import { format, promisify } from 'node:util'
12
11
  import zlib from 'node:zlib'
13
12
 
14
- import {
15
- Delegate, EveHomeKitTypes, HttpClient, MyHomeKitTypes, SystemInfo,
16
- UpnpClient, formatError, recommendedNodeVersion, semver
17
- } from '../index.js'
13
+ import { HttpClient } from 'hb-lib-tools/HttpClient'
14
+ import { SystemInfo } from 'hb-lib-tools/SystemInfo'
15
+ import { UpnpClient } from 'hb-lib-tools/UpnpClient'
18
16
 
19
- const libPackageJson = JSON.parse(
20
- readFileSync(join(import.meta.dirname, '../package.json'), 'utf8')
21
- )
17
+ import { Delegate } from 'homebridge-lib/Delegate'
18
+ import { EveHomeKitTypes } from 'homebridge-lib/EveHomeKitTypes'
19
+ import { MyHomeKitTypes } from 'homebridge-lib/MyHomeKitTypes'
20
+ import { semver } from 'homebridge-lib/semver'
21
+
22
+ import { formatError, recommendedNodeVersion } from 'homebridge-lib'
23
+
24
+ const require = createRequire(import.meta.url)
25
+ const libPackageJson = require('../package.json')
22
26
 
23
27
  const uuid = /^[0-9A-F]{8}-[0-9A-F]{4}-[1-5][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/
24
28
  const gzip = promisify(zlib.gzip)
@@ -36,6 +40,13 @@ const context = {
36
40
  driftWarningThreshold: 2500
37
41
  }
38
42
 
43
+ /** Homebridge dynamic platform plugin.
44
+ * <br>See {@link Platform}.
45
+ * @name Platform
46
+ * @type {Class}
47
+ * @memberof module:homebridge-lib
48
+ */
49
+
39
50
  /** Homebridge dynamic platform plugin.
40
51
  *
41
52
  * `Platform` provides the following features to a platform plugin:
@@ -59,12 +70,12 @@ class Platform extends Delegate {
59
70
  * @static
60
71
  * @param {!API} homebridge - Homebridge
61
72
  * [API](https://github.com/nfarina/homebridge/blob/master/lib/api.js).
62
- * @param {!string} dirName - The name of the plugin's directory.
73
+ * @param {!object} packageJson - The contents of the plugin's `package.json`.
63
74
  * @param {!string} platformName - The name of the platform plugin, as used
64
75
  * in Homebridge's `config.json`.
65
76
  * @param {!Platform} Platform - The constructor of the platform plugin.
66
77
  */
67
- static loadPlatform (homebridge, dirName, platformName, Platform) {
78
+ static loadPlatform (homebridge, packageJson, platformName, Platform) {
68
79
  if (context.homebridge == null) {
69
80
  context.homebridge = homebridge
70
81
  context.homebridgeVersion = homebridge.serverVersion
@@ -109,9 +120,6 @@ class Platform extends Delegate {
109
120
  my: Object.freeze(my.Characteristics)
110
121
  })
111
122
  }
112
- const packageJson = JSON.parse(
113
- readFileSync(join(dirName, 'package.json'), 'utf8')
114
- )
115
123
  context[Platform.name] = { packageJson, platformName }
116
124
  // console.log(
117
125
  // '%s v%s, node v%s, homebridge v%s, %s v%s',
@@ -3,7 +3,15 @@
3
3
  // Library for Homebridge plugins.
4
4
  // Copyright © 2017-2024 Erik Baauw. All rights reserved.
5
5
 
6
- import { AccessoryDelegate, Delegate } from '../index.js'
6
+ import { AccessoryDelegate } from 'homebridge-lib/AccessoryDelegate'
7
+ import { Delegate } from 'homebridge-lib/Delegate'
8
+
9
+ /** Delegate of a property of a HomeKit accessory or service.
10
+ * <br>See {@link PropertyDelegate}.
11
+ * @name PropertyDelegate
12
+ * @type {Class}
13
+ * @memberof module:homebridge-lib
14
+ */
7
15
 
8
16
  /** Delegate of a property of a delegate of a HomeKit accessory or HomeKit
9
17
  * service.
@@ -3,7 +3,7 @@
3
3
  // Library for Homebridge plugins.
4
4
  // Copyright © 2017-2024 Erik Baauw. All rights reserved.
5
5
 
6
- import { ServiceDelegate } from './index.js'
6
+ import { ServiceDelegate } from 'homebridge-lib/ServiceDelegate'
7
7
 
8
8
  /** Class for an _AccessoryInformation_ service delegate.
9
9
  *
@@ -109,4 +109,4 @@ class AccessoryInformation extends ServiceDelegate {
109
109
  }
110
110
  }
111
111
 
112
- export { AccessoryInformation }
112
+ ServiceDelegate.AccessoryInformation = AccessoryInformation
@@ -3,7 +3,7 @@
3
3
  // Library for Homebridge plugins.
4
4
  // Copyright © 2017-2024 Erik Baauw. All rights reserved.
5
5
 
6
- import { ServiceDelegate } from '../../index.js'
6
+ import { ServiceDelegate } from 'homebridge-lib/ServiceDelegate'
7
7
 
8
8
  /** Class for a _Battery_ service delegate.
9
9
  *
@@ -103,4 +103,4 @@ class Battery extends ServiceDelegate {
103
103
  }
104
104
  }
105
105
 
106
- export { Battery }
106
+ ServiceDelegate.Battery = Battery
@@ -3,7 +3,7 @@
3
3
  // Library for Homebridge plugins.
4
4
  // Copyright © 2017-2024 Erik Baauw. All rights reserved.
5
5
 
6
- import { ServiceDelegate } from '../../index.js'
6
+ import { ServiceDelegate } from 'homebridge-lib/ServiceDelegate'
7
7
 
8
8
  /** Class for a delegate for a dummy _StatelessProgrammableSwitch_ service.
9
9
  *
@@ -42,4 +42,4 @@ class Dummy extends ServiceDelegate {
42
42
  }
43
43
  }
44
44
 
45
- export { Dummy }
45
+ ServiceDelegate.Dummy = Dummy
@@ -7,7 +7,8 @@
7
7
  // fakagato-history repository, copyright © 2017 simont77.
8
8
  // See https://github.com/simont77/fakegato-history.
9
9
 
10
- import { CharacteristicDelegate, ServiceDelegate } from '../../index.js'
10
+ import { CharacteristicDelegate } from 'homebridge-lib/CharacteristicDelegate'
11
+ import { ServiceDelegate } from 'homebridge-lib/ServiceDelegate'
11
12
 
12
13
  // Eve history keeps time as # seconds since epoch of 2001/01/01.
13
14
  // @type {integer}
@@ -747,4 +748,4 @@ class History extends ServiceDelegate {
747
748
  }
748
749
  }
749
750
 
750
- export { History }
751
+ ServiceDelegate.History = History
@@ -3,7 +3,7 @@
3
3
  // Library for Homebridge plugins.
4
4
  // Copyright © 2017-2024 Erik Baauw. All rights reserved.
5
5
 
6
- import { ServiceDelegate } from '../../index.js'
6
+ import { ServiceDelegate } from 'homebridge-lib/ServiceDelegate'
7
7
 
8
8
  /** Class for a _ServiceLabel_ service delegate.
9
9
  *
@@ -45,4 +45,4 @@ class ServiceLabel extends ServiceDelegate {
45
45
  }
46
46
  }
47
47
 
48
- export { ServiceLabel }
48
+ ServiceDelegate.ServiceLabel = ServiceLabel
@@ -1,12 +1,18 @@
1
- // homebridge-lib/lib/ServiceDelegate/index.js
1
+ // homebridge-lib/lib/ServiceDelegate.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
4
  // Copyright © 2017-2024 Erik Baauw. All rights reserved.
5
5
 
6
- import {
7
- AccessoryDelegate, CharacteristicDelegate, Delegate,
8
- AccessoryInformation, Battery, Dummy, History, ServiceLabel
9
- } from '../../index.js'
6
+ import { AccessoryDelegate } from 'homebridge-lib/AccessoryDelegate'
7
+ import { CharacteristicDelegate } from 'homebridge-lib/CharacteristicDelegate'
8
+ import { Delegate } from 'homebridge-lib/Delegate'
9
+
10
+ /** Delegate of a HomeKit service.
11
+ * <br>See {@link ServiceDelegate}.
12
+ * @name ServiceDelegate
13
+ * @type {Class}
14
+ * @memberof module:homebridge-lib
15
+ */
10
16
 
11
17
  /** Delegate of a HomeKit service.
12
18
  *
@@ -21,12 +27,6 @@ import {
21
27
  * @extends Delegate
22
28
  */
23
29
  class ServiceDelegate extends Delegate {
24
- static get AccessoryInformation () { return AccessoryInformation }
25
- static get Battery () { return Battery }
26
- static get Dummy () { return Dummy }
27
- static get History () { return History }
28
- static get ServiceLabel () { return ServiceLabel }
29
-
30
30
  /** Create a new instance of a HomeKit service delegate.
31
31
  *
32
32
  * When the associated HomeKit service was restored from persistent
@@ -0,0 +1,12 @@
1
+ // homebridge-lib/lib/SystemInfo.js
2
+ //
3
+ // Library for Homebridge plugins.
4
+ // Copyright © 2020-2024 Erik Baauw. All rights reserved.
5
+
6
+ /** System information.
7
+ * <br>See {@link SystemInfo}.
8
+ * @name SystemInfo
9
+ * @type {Class}
10
+ * @memberof module:homebridge-lib
11
+ */
12
+ export { SystemInfo } from 'hb-lib-tools/SystemInfo'
package/lib/UiServer.js CHANGED
@@ -10,7 +10,16 @@ import { format } from 'node:util'
10
10
  // Somehow this causes Homebridge to crash with SIGTERM after ~9 seconds.
11
11
  import { HomebridgePluginUiServer } from '@homebridge/plugin-ui-utils'
12
12
 
13
- import { HttpClient, chalk, formatError } from '../index.js'
13
+ import { formatError } from 'hb-lib-tools'
14
+ import { chalk } from 'hb-lib-tools/chalk'
15
+ import { HttpClient } from 'hb-lib-tools/HttpClient'
16
+
17
+ /** Server for dynamic configuration settings through Homebridge UI.
18
+ * <br>See {@link UiServer}.
19
+ * @name UiServer
20
+ * @type {Class}
21
+ * @memberof module:homebridge-lib
22
+ */
14
23
 
15
24
  /** Server for handling Homebridge Plugin UI requests.
16
25
  *
@@ -0,0 +1,12 @@
1
+ // homebridge-lib/lib/UpnpClient.js
2
+ //
3
+ // Library for Homebridge plugins.
4
+ // Copyright © 2020-2024 Erik Baauw. All rights reserved.
5
+
6
+ /** Universal Plug and Play client.
7
+ * <br>See {@link UpnpClient}.
8
+ * @name UpnpClient
9
+ * @type {Class}
10
+ * @memberof module:homebridge-lib
11
+ */
12
+ export { UpnpClient } from 'hb-lib-tools/UpnpClient'
package/lib/chalk.js ADDED
@@ -0,0 +1,11 @@
1
+ // homebridge-lib/lib/chalk.js
2
+ //
3
+ // Library for Homebridge plugins.
4
+ // Copyright © 2020-2024 Erik Baauw. All rights reserved.
5
+
6
+ /** Return the [`chalk`](https://github.com/chalk/chalk) module,
7
+ * so plugins don't have to list this as a separate dependency.
8
+ * @name chalk
9
+ * @memberof module:homebridge-lib
10
+ */
11
+ export { chalk } from 'hb-lib-tools/chalk'
package/lib/semver.js ADDED
@@ -0,0 +1,11 @@
1
+ // homebridge-lib/lib/semver.js
2
+ //
3
+ // Library for Homebridge plugins.
4
+ // Copyright © 2020-2024 Erik Baauw. All rights reserved.
5
+
6
+ /** Return the [`semver`](https://github.com/npm/node-semver) module,
7
+ * so plugins don't have to list this as a separate dependency.
8
+ * @name semver
9
+ * @memberof module:homebridge-lib
10
+ */
11
+ export { semver } from 'hb-lib-tools/semver'
package/package.json CHANGED
@@ -3,13 +3,17 @@
3
3
  "description": "Library for homebridge plugins",
4
4
  "author": "Erik Baauw",
5
5
  "license": "Apache-2.0",
6
- "version": "7.0.0-0",
6
+ "version": "7.0.0",
7
7
  "keywords": [
8
8
  "homekit",
9
9
  "homebridge"
10
10
  ],
11
11
  "type": "module",
12
12
  "main": "index.js",
13
+ "exports": {
14
+ ".": "./index.js",
15
+ "./*": "./lib/*.js"
16
+ },
13
17
  "files": [
14
18
  "index.js",
15
19
  "lib",
@@ -22,12 +26,12 @@
22
26
  "upnp": "cli/upnp.js"
23
27
  },
24
28
  "engines": {
25
- "homebridge": "^1.7.0",
29
+ "homebridge": "^1.8.1",
26
30
  "node": "20.12.2||^20||^18"
27
31
  },
28
32
  "dependencies": {
29
33
  "@homebridge/plugin-ui-utils": "~1.0.3",
30
- "hb-lib-tools": "~2.0.0-0"
34
+ "hb-lib-tools": "~2.0.0"
31
35
  },
32
36
  "scripts": {
33
37
  "prepare": "standard && rm -rf out && jsdoc -c jsdoc.json",